@@ -4,114 +4,50 @@ This file is for coding agents working in `/Users/ryanvogel/dev/opencode`.
44
55## Scope And Precedence
66
7- - Start with this file for repo-wide defaults.
8- - Then check package-local ` AGENTS.md ` files for stricter rules.
9- - Existing local guides include ` packages/opencode/AGENTS.md ` and ` packages/app/AGENTS.md ` .
10- - Package-specific guides override this file when they conflict.
7+ - Keep things in one function unless composable or reusable
8+ - Avoid ` try ` /` catch ` where possible
9+ - Avoid using the ` any ` type
10+ - Use Bun APIs when possible, like ` Bun.file() `
11+ - Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
12+ - Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream
1113
12- ## Repo Facts
14+ Reduce total variable count by inlining when a value is only used once.
1315
14- - Package manager: ` bun ` (` bun@1.3.11 ` ).
15- - Monorepo tool: ` turbo ` .
16- - Default branch: ` dev ` .
17- - Root test script intentionally fails; do not run tests from root.
16+ ``` ts
17+ // Good
18+ const journal = await Bun .file (path .join (dir , " journal.json" )).json ()
1819
19- ## Cursor / Copilot Rules
20+ // Bad
21+ const journalPath = path .join (dir , " journal.json" )
22+ const journal = await Bun .file (journalPath ).json ()
23+ ```
2024
21- - No ` .cursor/rules/ ` directory found.
22- - No ` .cursorrules ` file found.
23- - No ` .github/copilot-instructions.md ` file found.
24- - If these files are added later, treat them as mandatory project policy.
25+ ### Destructuring
2526
26- ## High-Value Commands
27+ Avoid unnecessary destructuring. Use dot notation to preserve context.
2728
28- Run commands from the correct package directory unless noted.
29+ ``` ts
30+ // Good
31+ obj .a
32+ obj .b
2933
30- ### Root
34+ // Bad
35+ const { a, b } = obj
36+ ```
3137
32- - Install deps: ` bun install `
33- - Run all typechecks via turbo: ` bun run typecheck `
34- - OpenCode dev CLI entry: ` bun run dev `
35- - OpenCode serve (common): ` bun run dev serve --hostname 0.0.0.0 --port 4096 `
38+ ### Variables
3639
37- ### ` packages/opencode `
40+ Prefer ` const ` over ` let ` . Use ternaries or early returns instead of reassignment.
3841
39- - Dev CLI: ` bun run dev `
40- - Typecheck: ` bun run typecheck `
41- - Tests (all): ` bun test --timeout 30000 `
42- - Tests (single file): ` bun test test/path/to/file.test.ts --timeout 30000 `
43- - Tests (single test name): ` bun test test/path/to/file.test.ts -t "name fragment" --timeout 30000 `
44- - Build: ` bun run build `
45- - Drizzle helper: ` bun run db `
42+ ``` ts
43+ // Good
44+ const foo = condition ? 1 : 2
4645
47- ### ` packages/app `
48-
49- - Dev server: ` bun dev `
50- - Build: ` bun run build `
51- - Typecheck: ` bun run typecheck `
52- - Unit tests (all): ` bun run test:unit `
53- - Unit tests (single file): ` bun test --preload ./happydom.ts ./src/path/to/file.test.ts `
54- - Unit tests (single test name): ` bun test --preload ./happydom.ts ./src/path/to/file.test.ts -t "name fragment" `
55- - E2E tests: ` bun run test:e2e `
56-
57- ### ` packages/mobile-voice `
58-
59- - Start Expo: ` bun run start `
60- - Start Expo dev client: ` bunx expo start --dev-client --clear --host lan `
61- - iOS native run: ` bun run ios `
62- - Android native run: ` bun run android `
63- - Lint: ` bun run lint `
64- - Expo doctor: ` bunx expo-doctor `
65- - Dependency compatibility check: ` bunx expo install --check `
66-
67- ### ` packages/apn-relay `
68-
69- - Start relay: ` bun run dev `
70- - Typecheck: ` bun run typecheck `
71- - DB connectivity check: ` bun run db:check `
72-
73- ## Build / Lint / Test Expectations
74-
75- - Always run the narrowest checks that prove your change.
76- - For backend changes: run package typecheck + relevant tests.
77- - For mobile changes: run ` expo lint ` and at least one ` expo ` compile-style command if possible.
78- - Never claim tests passed unless you ran them in this workspace.
79-
80- ## Single-Test Guidance
81-
82- - Prefer running one file first, then broaden scope.
83- - For Bun tests, pass the file path directly.
84- - For name filtering, use ` -t "..." ` .
85- - Keep original timeouts when scripts define them.
86-
87- ## Code Style Guidelines
88-
89- These conventions are already used heavily in this repo and should be preserved.
90-
91- ### Formatting
92-
93- - Use Prettier defaults configured in root: ` semi: false ` , ` printWidth: 120 ` .
94- - Keep imports grouped and stable; avoid noisy reorder-only edits.
95- - Avoid unrelated formatting churn in touched files.
96-
97- ### Imports
98-
99- - Prefer explicit imports over dynamic imports unless runtime gating is required.
100- - Prefer existing alias patterns (for example ` @/... ` ) where already configured.
101- - Do not introduce new dependency layers when a local util already exists.
102-
103- ### Types
104-
105- - Avoid ` any ` .
106- - Prefer inference for local variables.
107- - Add explicit annotations for exported APIs and complex boundaries.
108- - Prefer ` zod ` schemas for request/response validation and parsing.
109-
110- ### Naming
111-
112- - Follow existing repo preference for short, clear names.
113- - Use single-word names when readable; use multi-word only for clarity.
114- - Keep naming consistent with nearby code.
46+ // Bad
47+ let foo
48+ if (condition ) foo = 1
49+ else foo = 2
50+ ```
11551
11652### Control Flow
11753
0 commit comments