mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 01:34:22 +01:00
1.3 KiB
1.3 KiB
opencode agent guidelines
Build/Test Commands
- Install:
bun install - Run:
bun run 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)
Code Style
- 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())
Architecture
- Tools: Implement
Tool.Infointerface withexecute()method - Context: Pass
sessionIDin tool context, useApp.provide()for DI - Validation: All inputs validated with Zod schemas
- Logging: Use
Log.create({ service: "name" })pattern - Storage: Use
Storagenamespace for persistence - API Client: Go TUI communicates with TypeScript server via stainless SDK. When adding/modifying server endpoints in
packages/opencode/src/server/server.ts, ask the user to generate a new client SDK to proceed with client-side changes.