2025-09-05 19:29:28 -04:00
# AGENTS Instructions
2025-09-26 23:44:38 -05:00
goose is an AI agent framework in Rust with CLI and Electron desktop interfaces.
2025-09-05 19:29:28 -04:00
## Setup
``` bash
source bin/activate-hermit
cargo build
```
## Commands
### Build
``` bash
cargo build # debug
cargo build --release # release
2026-07-02 10:29:29 +10:00
just release-binary # release binary
2025-09-05 19:29:28 -04:00
```
### Test
``` bash
cargo test # all tests
cargo test -p goose # specific crate
cargo test --package goose --test mcp_integration_test
just record-mcp-tests # record MCP
```
### Lint/Format
``` bash
cargo fmt
2026-02-06 20:10:24 -08:00
cargo clippy --all-targets -- -D warnings
2025-09-05 19:29:28 -04:00
```
### UI
``` bash
just run-ui # start desktop
2026-07-02 10:29:29 +10:00
cd ui/desktop && pnpm run typecheck
2026-03-11 08:46:05 -04:00
cd ui/desktop && pnpm test # test UI
2025-09-05 19:29:28 -04:00
```
## Structure
```
crates/
2026-03-04 13:45:29 -03:00
├── goose # core logic
├── goose-acp-macros # ACP proc macros
├── goose-cli # CLI entry
├── goose-mcp # MCP extensions
├── goose-test # test utilities
└── goose-test-support # test helpers
2025-09-05 19:29:28 -04:00
2026-03-04 13:45:29 -03:00
ui/desktop/ # Electron app
2025-09-05 19:29:28 -04:00
```
## Development Loop
``` bash
# 1. source bin/activate-hermit
# 2. Make changes
# 3. cargo fmt
2026-03-17 09:20:03 -04:00
```
### Run these only if the user has asked you to build/test your changes:
```
# 1. cargo build
# 2. cargo test -p <crate>
# 3. cargo clippy --all-targets -- -D warnings
2025-09-05 19:29:28 -04:00
```
## Rules
2026-05-03 20:36:08 -05:00
- Test: Prefer tests/ folder, e.g. crates/goose/tests/
- Test: When adding features, update goose-self-test.yaml, rebuild, then run `goose run --recipe goose-self-test.yaml` to validate
- Error: Use anyhow::Result
- Provider: Implement Provider trait see providers/base.rs
- MCP: Extensions in crates/goose-mcp/
2026-07-02 10:29:29 +10:00
- UI Desktop: Use ACP SDK types or local `src/types/*` types. Do not import generated OpenAPI types/client code from `ui/desktop/src/api`
2025-09-05 19:29:28 -04:00
2025-11-10 12:35:41 -06:00
## Code Quality
2026-05-03 20:36:08 -05:00
- Comments: Write self-documenting code - prefer clear names over comments
- Comments: Never add comments that restate what code does
- Comments: Only comment for complex algorithms, non-obvious business logic, or "why" not "what"
- Simplicity: Don't make things optional that don't need to be - the compiler will enforce
- Simplicity: Booleans should default to false, not be optional
- Errors: Don't add error context that doesn't add useful information (e.g., `.context("Failed to X")` when error already says it failed)
- Simplicity: Avoid overly defensive code - trust Rust's type system
- Logging: Clean up existing logs, don't add more unless for errors or security events
2025-11-10 12:35:41 -06:00
2025-09-05 19:29:28 -04:00
## Never
2026-07-02 10:29:29 +10:00
- Never: Recreate `ui/desktop/src/api` or add `@hey-api/openapi-ts` to `ui/desktop`
2026-05-03 20:36:08 -05:00
- Cargo.toml: For human-authored dependency changes, use `cargo add` instead of manually editing dependency entries unless there is a specific reason not to.
- Cargo.toml: Automated dependency bump PRs are exempt; when manual edits are necessary, keep `Cargo.lock` consistent.
- Never: Skip cargo fmt
- Never: Merge without running clippy
- Never: Comment self-evident operations (`// Initialize` , `// Return result` ), getters/setters, constructors, or standard Rust idioms
2025-09-05 19:29:28 -04:00
## Entry Points
- CLI: crates/goose-cli/src/main.rs
- UI: ui/desktop/src/main.ts
- Agent: crates/goose/src/agents/agent.rs