GeezerVison is showing github.com — opencode/packages/opencode/AGENTS.md at dev · typesafe/opencode
27 lines (21 loc) · 1.37 KB
File metadata and controls
27 lines (21 loc) · 1.37 KB
Copy raw file
Download raw file
OutlineEdit and raw actions
opencode agent guidelines
- Install:
bun install
- Run:
bun run --conditions=browser ./src/index.ts
- Typecheck:
bun run typecheck (npm run typecheck)
- Test:
bun test (runs all tests)
- Single test:
bun test test/tool/tool.test.ts (specific test file)
- Runtime: Bun with TypeScript ESM modules
- Imports: Use relative imports for local modules, named imports preferred
- Types: Zod schemas for validation, TypeScript interfaces for structure
- Naming: camelCase for variables/functions, PascalCase for classes/namespaces
- Error handling: Use Result patterns, avoid throwing exceptions in tools
- File structure: Namespace-based organization (e.g.,
Tool.define(), Session.create())
- Tools: Implement
Tool.Info interface with execute() method
- Context: Pass
sessionID in tool context, use App.provide() for DI
- Validation: All inputs validated with Zod schemas
- Logging: Use
Log.create({ service: "name" }) pattern
- Storage: Use
Storage namespace for persistence
- API Client: The TypeScript TUI (built with SolidJS + OpenTUI) communicates with the OpenCode server using
@opencode-ai/sdk. When adding/modifying server endpoints in packages/opencode/src/server/server.ts, run ./script/generate.ts to regenerate the SDK and related files.