Root guide for agentic coding assistants working in this repository.
Scope: applies to the whole repo unless a deeper AGENTS.md exists.
- Use Bun
1.3.10(packageManagerisbun@1.3.10) - Default branch is
dev; localmainmay not exist - Prefer
bun run --cwd <package> ...from repo root - Use parallel tool calls when tasks do not depend on each other
- Prefer automation: do the work unless blocked by missing info or safety concerns
- Do not run tests from repo root;
bunfig.tomlpoints tests at./do-not-run-tests-from-root bun devis the local equivalent ofopencode; for CLI or TUI work usebun dev .orbun dev <dir>- If API or SDK surface changes, run
./script/generate.ts - To regenerate the JS SDK, run
./packages/sdk/js/script/build.ts
More specific instructions exist and override this file:
packages/app/AGENTS.mdpackages/app/e2e/AGENTS.mdpackages/desktop/AGENTS.mdpackages/desktop-electron/AGENTS.mdpackages/opencode/AGENTS.mdpackages/opencode/test/AGENTS.md
packages/opencode: core CLI, runtime, server, and TUI - DO NOT MODIFY THIS PACKAGEpackages/app: Solid app with unit and e2e testspackages/desktop,packages/desktop-electron: desktop wrapperspackages/ios,packages/android: mobile wrapperspackages/ui,packages/storybook,packages/web: UI primitives, previews, and docs sitepackages/sdk/js,sdks/vscode: TypeScript SDK and VS Code extensionpackages/plugin,packages/util,packages/function,packages/push,packages/push-relay: shared logic and push servicespackages/console/*: console app, core, function, resource, and mail
# setup and dev
bun install
bun dev
bun dev --help
bun dev serve --port 4096
bun run --cwd packages/app dev
bun run --cwd packages/desktop tauri dev
# repo-wide typecheck
bun run typecheck
# common builds
bun run --cwd packages/opencode build
bun run --cwd packages/app build
bun run --cwd packages/desktop build
bun run --cwd packages/desktop-electron build
bun run --cwd packages/android build
bun run --cwd packages/ios build
bun run --cwd packages/web build
bun run --cwd packages/enterprise build
bun run --cwd packages/plugin build
bun run --cwd packages/sdk/js build
bun run --cwd packages/console/app build
# lint and checks
bun run --cwd packages/opencode lint
bun run --cwd sdks/vscode lint
bun run --cwd sdks/vscode check-types
bunx prettier --write <paths>
# tests: packages/opencode
bun run --cwd packages/opencode test
bun run --cwd packages/opencode test -- test/tool/bash.test.ts
bun run --cwd packages/opencode test -- test/tool/bash.test.ts -t "times out"
# tests: packages/app unit
bun run --cwd packages/app test:unit
bun run --cwd packages/app test:unit -- ./src/utils/server-health.test.ts
bun run --cwd packages/app test:unit -- -t "reports healthy"
# from packages/app when you need raw Bun control
bun test --preload ./happydom.ts ./src/components/prompt-input/submit.test.ts
# tests: packages/app e2e
bun run --cwd packages/app test:e2e
bun run --cwd packages/app test:e2e -- e2e/app/home.spec.ts
bun run --cwd packages/app test:e2e -- -g "home renders and shows core entrypoints"
bun run --cwd packages/app test:e2e:local
bun run --cwd packages/app test:e2e:ui
bun run --cwd packages/app test:e2e:report
# tests: run from packages/push
bun test src
bun test src/relay.test.ts
bun test src/relay.test.ts -t "relay"
# tests: run from packages/push-relay
bun test src
bun test src/server.test.ts
bun test src/server.test.ts -t "server"
# tests: sdks/vscode
bun run --cwd sdks/vscode test- There is no single repo-wide lint script at root
packages/opencode'slintscript is a repo check, not a standalone ESLint run- Prefer the narrowest test command that proves the change; start with a file or test-name filter
- No dedicated single-file wrapper was found for
sdks/vscode; use the package test harness as-is unless you add one
- Imports: keep imports at the top; prefer
import type; use aliases such as@/*and@tui/*when available; inpackages/app/e2eimporttestandexpectfrom../fixtures, not@playwright/test - Formatting: follow existing formatting and Prettier output; no semicolons;
printWidthis120; use 2-space indentation, LF endings, and UTF-8; keep comments minimal and only for non-obvious logic - Types: avoid
any; prefer precise types or inference; add explicit types at public or exported boundaries; use type guards when narrowing helps inference; prefer Bun APIs when they are a natural fit - Naming: prefer concise names; use single-word names for locals, params, and helpers unless clarity suffers; avoid long camelCase compounds when a short clear name exists; use
camelCasefor values,PascalCasefor types/components,SCREAMING_SNAKE_CASEfor constants, andsnake_casefor DB schema names - Structure: prefer
constoverlet; prefer early returns over nestedelse; avoid unnecessary destructuring whenobj.fieldis clearer; split code only when reuse or readability clearly improves; inpackages/app, prefercreateStoreover manycreateSignalcalls - Error handling: avoid
try/catchwhen a clearer flow exists; prefer explicit checks and early exits; use.catch(...)when it improves readability; return or throw errors with enough context to debug - Testing style: prefer real behavior over heavy mocks; keep tests focused; reuse fixtures and helpers; in
packages/opencodetests useawait usingwithtmpdir; in e2e usedata-component,data-action, or semantic roles; in app e2e preferwithSession,trackSession, andtrackDirectoryfor cleanup
packages/app: never restart the app or server process manually during debuggingpackages/app:opencode dev webproxieshttps://app.opencode.ai, so local UI or CSS changes will not show there; for local UI work run backendbun run --cwd packages/opencode --conditions=browser ./src/index.ts serve --port 4096and appbun run --cwd packages/app dev -- --port 4444packages/desktop: do not call Tauriinvokedirectly; usepackages/desktop/src/bindings.tspackages/desktop-electron: renderer code should usewindow.apifrom preload; main IPC handlers belong insrc/main/ipc.tspackages/opencode: Drizzle schema files live insrc/**/*.sql.ts; use<entity>_idfor join keys and<table>_<column>_idxfor DB index namespackages/ios: if asked to push, release, or upload an iOS build, default tobun run --cwd packages/ios beam; it uploads a private TestFlight build, not a public App Store release
- This repo is a mobile fork of
sst/opencode; preservepackages/ios,packages/android, and mobile platform/resume/storage/share/voice integrations inpackages/appwhen merging upstream - No
.cursorrules,.cursor/rules/, or.github/copilot-instructions.mdfiles were found - If any of those files appear later, treat them as authoritative and merge them with this guide