|
1 | | -- To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`. |
2 | | -- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE. |
3 | | -- The default branch in this repo is `dev`. |
4 | | -- Local `main` ref may not exist; use `dev` or `origin/dev` for diffs. |
5 | | -- Prefer automation: execute requested actions without confirmation unless blocked by missing info or safety/irreversibility. |
| 1 | +# OpenCode Monorepo Agent Guide |
6 | 2 |
|
7 | | -## Style Guide |
| 3 | +This file is for coding agents working in `/Users/ryanvogel/dev/opencode`. |
8 | 4 |
|
9 | | -### General Principles |
| 5 | +## Scope And Precedence |
10 | 6 |
|
11 | 7 | - Keep things in one function unless composable or reusable |
12 | 8 | - Avoid `try`/`catch` where possible |
@@ -56,48 +52,48 @@ else foo = 2 |
56 | 52 |
|
57 | 53 | ### Control Flow |
58 | 54 |
|
59 | | -Avoid `else` statements. Prefer early returns. |
| 55 | +- Prefer early returns over nested `else` blocks. |
| 56 | +- Keep functions focused; split only when it improves reuse or readability. |
60 | 57 |
|
61 | | -```ts |
62 | | -// Good |
63 | | -function foo() { |
64 | | - if (condition) return 1 |
65 | | - return 2 |
66 | | -} |
| 58 | +### Error Handling |
67 | 59 |
|
68 | | -// Bad |
69 | | -function foo() { |
70 | | - if (condition) return 1 |
71 | | - else return 2 |
72 | | -} |
73 | | -``` |
| 60 | +- Fail with actionable messages. |
| 61 | +- Avoid swallowing errors silently. |
| 62 | +- Log enough context to debug production issues (IDs, env, status), but never secrets. |
| 63 | +- In UI code, degrade gracefully for missing capabilities. |
74 | 64 |
|
75 | | -### Schema Definitions (Drizzle) |
| 65 | +### Data / DB |
76 | 66 |
|
77 | | -Use snake_case for field names so column names don't need to be redefined as strings. |
| 67 | +- For Drizzle schema, use snake_case fields and columns. |
| 68 | +- Keep migration and schema changes minimal and explicit. |
| 69 | +- Follow package-specific DB guidance in `packages/opencode/AGENTS.md`. |
78 | 70 |
|
79 | | -```ts |
80 | | -// Good |
81 | | -const table = sqliteTable("session", { |
82 | | - id: text().primaryKey(), |
83 | | - project_id: text().notNull(), |
84 | | - created_at: integer().notNull(), |
85 | | -}) |
| 71 | +### Testing Philosophy |
86 | 72 |
|
87 | | -// Bad |
88 | | -const table = sqliteTable("session", { |
89 | | - id: text("id").primaryKey(), |
90 | | - projectID: text("project_id").notNull(), |
91 | | - createdAt: integer("created_at").notNull(), |
92 | | -}) |
93 | | -``` |
| 73 | +- Prefer testing real behavior over mocks. |
| 74 | +- Add regression tests for bug fixes where practical. |
| 75 | +- Keep fixtures small and focused. |
| 76 | + |
| 77 | +## Agent Workflow Tips |
| 78 | + |
| 79 | +- Read existing code paths before introducing new abstractions. |
| 80 | +- Match local patterns first; do not impose a new style per file. |
| 81 | +- If a package has its own `AGENTS.md`, review it before editing. |
| 82 | +- For OpenCode Effect services, follow `packages/opencode/AGENTS.md` strictly. |
| 83 | + |
| 84 | +## Known Operational Notes |
| 85 | + |
| 86 | +- `packages/app/AGENTS.md` says: never restart app/server processes during that package's debugging workflow. |
| 87 | +- `packages/app/AGENTS.md` also documents local backend+web split for UI work. |
| 88 | +- `packages/opencode/AGENTS.md` contains mandatory Effect and database conventions. |
94 | 89 |
|
95 | | -## Testing |
| 90 | +## Regeneration / Special Scripts |
96 | 91 |
|
97 | | -- Avoid mocks as much as possible |
98 | | -- Test actual implementation, do not duplicate logic into tests |
99 | | -- Tests cannot run from repo root (guard: `do-not-run-tests-from-root`); run from package dirs like `packages/opencode`. |
| 92 | +- Regenerate JS SDK with: `./packages/sdk/js/script/build.ts` |
100 | 93 |
|
101 | | -## Type Checking |
| 94 | +## Quick Checklist Before Finishing |
102 | 95 |
|
103 | | -- Always run `bun typecheck` from package directories (e.g., `packages/opencode`), never `tsc` directly. |
| 96 | +- Ran relevant package checks. |
| 97 | +- Updated docs/config when behavior changed. |
| 98 | +- Avoided committing unrelated files. |
| 99 | +- Kept edits minimal and aligned with local conventions. |
0 commit comments