Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
abd9e19
fix: use parentID matching instead of ID ordering for prompt loop exi…
MakonnenMak Feb 19, 2026
fc258ea
fix: remove as any type cast in processor exit logic
MakonnenMak Feb 19, 2026
e993ace
Merge remote-tracking branch 'upstream/dev' into fix/clock-skew-promp…
MakonnenMak Mar 2, 2026
1392d86
Merge remote-tracking branch 'upstream/dev' into fix/clock-skew-promp…
MakonnenMak Mar 13, 2026
342719d
fix(opencode): image paste on Windows Terminal 1.25+ with kitty keyboard
Hona Mar 16, 2026
01c0902
fix(opencode): gate kitty keyboard events to windows
Hona Mar 18, 2026
ca2099e
refactor: replace BunProc with Npm module using @npmcli/arborist
thdxr Mar 19, 2026
816a5f7
refactor: replace Bun.serve with Node http.createServer in OAuth hand…
thdxr Mar 20, 2026
34c676b
fix: scope Npm.add() lock to per-package key
thdxr Mar 20, 2026
c075a5d
fix: force reinstall in which() when .bin is missing
thdxr Mar 20, 2026
7409ce8
fix: remove BUN_BE_BUN workaround, use node for ESLint server
thdxr Mar 20, 2026
205affa
fix: type error in mcp env and add missing @npmcli/arborist dependency
thdxr Mar 20, 2026
20249bb
Apply suggestion from @greptile-apps[bot]
thdxr Mar 20, 2026
e48da96
Update packages/opencode/src/npm/index.ts
thdxr Mar 20, 2026
3b669e7
fix type
thdxr Mar 20, 2026
bc43bf3
sync
thdxr Mar 20, 2026
9f5713e
Merge branch 'dev' into refactor/oauth-node-http
thdxr Mar 20, 2026
b1d537b
Merge branch 'dev' into refactor/npm-over-bunproc
thdxr Mar 20, 2026
df44b41
fix: handle undefined from Npm.which in all callers
thdxr Mar 20, 2026
e1f06de
fix(core): restore SIGHUP exit handler (#16057)
thdxr Mar 21, 2026
9f1f625
fix(core): move SIGHUP handler into exit context for proper cleanup
thdxr Mar 21, 2026
a724b01
effectify Bus service: migrate to Effect PubSub + InstanceState
kitlangton Mar 22, 2026
050336f
effectify Bus service: migrate to Effect PubSub + InstanceState
kitlangton Mar 22, 2026
83916ca
simplify: extract forkStream, fix dead event test subscribers, update…
kitlangton Mar 22, 2026
ee8025f
add runCallback to makeRuntime, simplify forkStream, add bus tests
kitlangton Mar 22, 2026
0f5bd32
test(bus): add instance isolation and multiple subscriber tests
kitlangton Mar 22, 2026
8c559c2
fix(bus): prevent race in getOrCreate with double-check after yield
kitlangton Mar 22, 2026
fcec621
remove unnecessary double-check in getOrCreate (Effect.sync is atomic)
kitlangton Mar 22, 2026
aeceb37
integrate effectified services with Bus Effect-native API
kitlangton Mar 22, 2026
ea31863
cleanup: remove unused memoMap import, fix extra blank line
kitlangton Mar 22, 2026
aceadf1
restore File.Event.Edited publish for plugin hooks (fire-and-forget)
kitlangton Mar 22, 2026
99fc519
docs: update effect-migration with runCallback, Stream subscription p…
kitlangton Mar 22, 2026
d1d1c89
docs: update AGENTS.md to reflect InstanceState and makeRuntime patterns
kitlangton Mar 22, 2026
b7371de
add tmpdirScoped with ChildProcessSpawner, Effect-native bus tests
kitlangton Mar 22, 2026
34b7173
simplify git helper to flatMap
kitlangton Mar 22, 2026
e241b89
add runSync safety comment
kitlangton Mar 22, 2026
822e292
refactor test fixtures: provideTmpdirInstance, delete withServices, r…
kitlangton Mar 22, 2026
c15bf90
docs: add acquireRelease example for non-Bus resources
kitlangton Mar 22, 2026
211e765
test(bus): add Effect-native test for InstanceDisposed delivery on di…
kitlangton Mar 22, 2026
b0cb887
Merge branch 'dev' into fix/windows-image-paste
Hona Mar 23, 2026
601131c
tui: clarify Windows Terminal paste path comments
Hona Mar 23, 2026
18f96e2
tui: remove invalid markdown color props
Hona Mar 23, 2026
a9dd7ac
tui: restore markdown color props
Hona Mar 23, 2026
0dc20d9
Apply PR #12633: feat(tui): add auto-accept mode for permission requests
opencode-agent[bot] Mar 23, 2026
082cf9c
Apply PR #14307: fix: use parentID matching instead of ID ordering fo…
opencode-agent[bot] Mar 23, 2026
b1cc57f
Apply PR #14471: [DO NOT MERGE]: beta badge for desktop app
opencode-agent[bot] Mar 23, 2026
9d4203b
Apply PR #15697: tweak(ui): make questions popup collapsible
opencode-agent[bot] Mar 23, 2026
73e351c
Apply PR #17674: fix(opencode): image paste on Windows Terminal 1.25+…
opencode-agent[bot] Mar 23, 2026
a283d0f
Apply PR #18308: refactor: replace BunProc with Npm module using @npm…
opencode-agent[bot] Mar 23, 2026
92ec289
Apply PR #18327: refactor: replace Bun.serve with Node http.createSer…
opencode-agent[bot] Mar 23, 2026
317301b
Apply PR #18527: fix(core): restore SIGHUP exit handler (#16057)
opencode-agent[bot] Mar 23, 2026
e54161e
Apply PR #18579: effectify Bus service: migrate to Effect PubSub + In…
opencode-agent[bot] Mar 23, 2026
bbb79d1
chore: update nix node_modules hashes
opencode-agent[bot] Mar 23, 2026
e8a3388
docs: expand AGENTS.md docs with Npm module support
noahbentusi Mar 23, 2026
dd33d45
docs: add mobile touch optimization design spec
noahbentusi Mar 23, 2026
d6cc8e3
feat(app): add toolbar overflow menu for mobile responsiveness
noahbentusi Mar 23, 2026
4443fca
feat(app): add mobile fullscreen panel layout for review and file tree
noahbentusi Mar 23, 2026
33a425b
fix(app): address code quality issues in mobile fullscreen panel
noahbentusi Mar 23, 2026
c57dbfb
fix(app): keep mobile panel open when opening files from file tree
noahbentusi Mar 23, 2026
10f0bd5
feat(ui): add touch selection toolbar for comments on mobile
noahbentusi Mar 23, 2026
2356ebe
fix(ui): fix touch selection toolbar to use line selection
noahbentusi Mar 23, 2026
700184a
feat(app): add long-press context menu to file tree
noahbentusi Mar 23, 2026
e280e5e
feat(app): add markdown render/source toggle
noahbentusi Mar 23, 2026
998a794
fix(app): fix tabs context error in markdown toggle
noahbentusi Mar 23, 2026
b8a18c2
feat(app): add 'Back to chat' button to overflow menu
noahbentusi Mar 23, 2026
425ffb3
fix(file-tree): use ContextMenu instead of DropdownMenu
noahbentusi Mar 23, 2026
9ebdf56
fix(app): move 'Back to chat' button from overflow menu to toolbar
noahbentusi Mar 23, 2026
ab87b60
fix(app): move 'Back to chat' button to first position in toolbar
noahbentusi Mar 23, 2026
8f03842
Apply PR #12633: feat(tui): add auto-accept mode for permission requests
opencode-agent[bot] Mar 23, 2026
c05aaa2
Apply PR #14307: fix: use parentID matching instead of ID ordering fo…
opencode-agent[bot] Mar 23, 2026
08b085b
Apply PR #14471: [DO NOT MERGE]: beta badge for desktop app
opencode-agent[bot] Mar 23, 2026
3bca8c5
Apply PR #15697: tweak(ui): make questions popup collapsible
opencode-agent[bot] Mar 23, 2026
50d5f3d
Apply PR #17674: fix(opencode): image paste on Windows Terminal 1.25+…
opencode-agent[bot] Mar 23, 2026
67763c2
Apply PR #18308: refactor: replace BunProc with Npm module using @npm…
opencode-agent[bot] Mar 23, 2026
232c62f
Apply PR #18327: refactor: replace Bun.serve with Node http.createSer…
opencode-agent[bot] Mar 23, 2026
647766e
Apply PR #18527: fix(core): restore SIGHUP exit handler (#16057)
opencode-agent[bot] Mar 23, 2026
5aef61c
Apply PR #18579: effectify Bus service: migrate to Effect PubSub + In…
opencode-agent[bot] Mar 23, 2026
fba58b5
refactor(ui): simplify selection comment to work for both mouse and t…
noahbentusi Mar 23, 2026
0f12367
chore: update nix node_modules hashes
opencode-agent[bot] Mar 23, 2026
2e2c377
Merge branch 'beta' into yjh/dev
noahbentusi Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ opencode-dev
logs/
*.bun-build
tsconfig.tsbuildinfo
**/.superpowers
218 changes: 143 additions & 75 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,128 +1,196 @@
- To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`.
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
- The default branch in this repo is `dev`.
- Local `main` ref may not exist; use `dev` or `origin/dev` for diffs.
- Prefer automation: execute requested actions without confirmation unless blocked by missing info or safety/irreversibility.
# OpenCode Agent Guidelines

## Style Guide
## Project Overview

### General Principles

- Keep things in one function unless composable or reusable
- Avoid `try`/`catch` where possible
- Avoid using the `any` type
- Prefer single word variable names where possible
- Use Bun APIs when possible, like `Bun.file()`
- Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
- Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream
Monorepo using Bun workspaces. Main packages:

### Naming
- `packages/opencode` — CLI backend (Node.js/Bun)
- `packages/app` — SolidJS web app
- `packages/ui` — Shared UI components
- `packages/sdk/js` — JavaScript SDK

Prefer single word names for variables and functions. Only use multiple words if necessary.
## Commands

### Naming Enforcement (Read This)
### Build & Type Check

THIS RULE IS MANDATORY FOR AGENT WRITTEN CODE.
```bash
bun turbo build # Build all packages
bun run --cwd packages/opencode build # Build opencode only
bun typecheck # Type check all packages
bun run --cwd packages/opencode typecheck # Type check opencode (never use tsc directly)
bun run --cwd packages/app typecheck # Type check app
```

- Use single word names by default for new locals, params, and helper functions.
- Multi-word names are allowed only when a single word would be unclear or ambiguous.
- Do not introduce new camelCase compounds when a short single-word alternative is clear.
- Before finishing edits, review touched lines and shorten newly introduced identifiers where possible.
- Good short names to prefer: `pid`, `cfg`, `err`, `opts`, `dir`, `root`, `child`, `state`, `timeout`.
- Examples to avoid unless truly required: `inputPID`, `existingClient`, `connectTimeout`, `workerPath`.
### Testing

```ts
// Good
const foo = 1
function journal(dir: string) {}
```bash
# OpenCode package tests
bun run --cwd packages/opencode test # Run all tests
bun test --cwd packages/opencode test/agent/agent.test.ts # Run single test file
bun test --cwd packages/opencode -t "timeout" # Run tests matching pattern
bun test --cwd packages/opencode -t "should resolve" test/util/* # Run specific test in file

// Bad
const fooBar = 1
function prepareJournal(dir: string) {}
# App tests
bun run --cwd packages/app test:unit # Unit tests
bun run --cwd packages/app test:unit:watch # Unit tests (watch mode)
bun run --cwd packages/app test:e2e # E2E tests (Playwright)
bun run --cwd packages/app test:e2e:ui # E2E tests with UI
```

Reduce total variable count by inlining when a value is only used once.
**CRITICAL**: Tests cannot run from repo root. Always run from package directories.

```ts
// Good
const journal = await Bun.file(path.join(dir, "journal.json")).json()
### Formatting & Database

// Bad
const journalPath = path.join(dir, "journal.json")
const journal = await Bun.file(journalPath).json()
```bash
bunx prettier --write <file> # Format file (semi: false, printWidth: 120)
bun run db generate --name <slug> # Generate migration (from packages/opencode)
bun ./packages/sdk/js/script/build.ts # SDK generation
```

### Destructuring
## Local Development

Avoid unnecessary destructuring. Use dot notation to preserve context.
`opencode dev web` proxies `https://app.opencode.ai` — local UI changes won't appear. For local UI changes, run servers separately:

```ts
// Good
obj.a
obj.b
```bash
# Terminal 1 - Backend (from packages/opencode)
bun run --conditions=browser ./src/index.ts serve --port 4096

// Bad
const { a, b } = obj
# Terminal 2 - App (from packages/app)
bun dev -- --port 4444

# Open http://localhost:4444 (targets backend at localhost:4096)
```

### Variables
- **NEVER** restart the app or server process during debugging

## Code Style

### General Principles

- Keep logic in one function unless composable/reusable
- Avoid `try`/`catch` — prefer Effect's error handling
- Avoid `any` type
- Use Bun APIs when possible (e.g., `Bun.file()`)
- Rely on type inference; explicit types only for exports
- Prefer functional array methods (flatMap, filter, map) over for loops

Prefer `const` over `let`. Use ternaries or early returns instead of reassignment.
### Naming (MANDATORY)

Single word by default. Multi-word only when clarity requires it.

```ts
// Good: pid, cfg, err, opts, dir, root, child, state, timeout
// Bad: inputPID, existingClient, connectTimeout, workerPath

// Good
const foo = condition ? 1 : 2
const foo = 1
function journal(dir: string) {}
const data = await Bun.file(path.join(dir, "file.json")).json()

// Bad
let foo
if (condition) foo = 1
else foo = 2
const fooBar = 1
function prepareJournal(dir: string) {}
const filePath = path.join(dir, "file.json")
```

### Control Flow

Avoid `else` statements. Prefer early returns.
### Destructuring & Control Flow

```ts
// Good
// Prefer dot notation
obj.a // Good
const { a } = obj // Bad

// Prefer const with ternary
const foo = condition ? 1 : 2 // Good

// Prefer early returns (no else after return)
function foo() {
if (condition) return 1
return 2
}
```

// Bad
function foo() {
if (condition) return 1
else return 2
}
### Imports

Group: external packages → internal (`@/`) → relative:

```ts
import { Effect, Schema } from "effect"
import { Database } from "@/storage/db"
import { AccountTable } from "./account.sql"
```

### Schema Definitions (Drizzle)

Use snake_case for field names so column names don't need to be redefined as strings.
Use snake_case for field names:

```ts
// Good
const table = sqliteTable("session", {
id: text().primaryKey(),
project_id: text().notNull(),
created_at: integer().notNull(),
})
```

// Bad
const table = sqliteTable("session", {
id: text("id").primaryKey(),
projectID: text("project_id").notNull(),
createdAt: integer("created_at").notNull(),
})
## Effect Library (Backend)

- Use `Effect.gen(function* () { ... })` for composition
- Use `Effect.fn("Domain.method")` for named effects
- Use `Schema.Class` for multi-field data, `Schema.brand` for single-value types
- Use `Schema.TaggedErrorClass` for typed errors
- Prefer Effect services: `FileSystem`, `ChildProcessSpawner`, `HttpClient`, `Path`, `Clock`

## SolidJS (App/UI)

- Always prefer `createStore` over multiple `createSignal` calls
- Use `splitProps` to separate local props from rest props
- Use `createMemo` for derived state
- Use `createSimpleContext` from `@opencode-ai/ui/context` for context creation

```tsx
export function Link(props: LinkProps) {
const platform = usePlatform()
const [local, rest] = splitProps(props, ["href", "children", "class"])

return (
<a href={local.href} class={`text-text-strong underline ${local.class ?? ""}`} {...rest}>
{local.children}
</a>
)
}
```

## Browser Automation (App)

Use `agent-browser` for web automation. Core workflow:

1. `agent-browser open <url>` - Navigate to page
2. `agent-browser snapshot -i` - Get interactive elements with refs (@e1, @e2)
3. `agent-browser click @e1` / `fill @e2 "text"` - Interact using refs
4. Re-snapshot after page changes

## Testing

- Avoid mocks as much as possible
- Test actual implementation, do not duplicate logic into tests
- Tests cannot run from repo root (guard: `do-not-run-tests-from-root`); run from package dirs like `packages/opencode`.
- Avoid mocks; test actual implementation
- Use `tmpdir` fixture for temporary directories:

```ts
import { describe, expect, test } from "bun:test"
import { tmpdir } from "../fixture/fixture"

test("example", async () => {
await using tmp = await tmpdir({ git: true })
})
```

## Git

- Default branch is `dev` (not `main`)
- Local `main` may not exist; use `dev` or `origin/dev` for diffs

## Type Checking
## Notes

- Always run `bun typecheck` from package directories (e.g., `packages/opencode`), never `tsc` directly.
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE
- Package manager: Bun 1.3.11
- TypeScript: 5.8.2
- Prettier: `semi: false`, `printWidth: 120`
Loading
Loading