This document provides guidelines for AI agents operating in this repository.
oh-my-opencode-slim - A lightweight agent orchestration plugin for OpenCode, a slimmed-down fork of oh-my-opencode. Built with TypeScript, Bun, and Biome.
| Command | Description |
|---|---|
bun run build |
Build TypeScript to dist/ (both index.ts and cli/index.ts) |
bun run typecheck |
Run TypeScript type checking without emitting |
bun test |
Run all tests with Bun |
bun run lint |
Run Biome linter on entire codebase |
bun run format |
Format entire codebase with Biome |
bun run check |
Run Biome check with auto-fix (lint + format + organize imports) |
bun run check:ci |
Run Biome check without auto-fix (CI mode) |
bun run dev |
Build and run with OpenCode |
Running a single test: Use Bun's test filtering with the -t flag:
bun test -t "test-name-pattern"
biome.json)tsconfig.jsonany: Generates a linter warning (disabled for test files)bundler strategy.d.ts files in dist/organizeImports: "on")bun run check:ci before pushingoh-my-opencode-slim/
├── src/
│ ├── agents/ # Agent factories (orchestrator, explorer, oracle, etc.)
│ ├── background/ # Background task management
│ ├── cli/ # CLI entry point
│ ├── config/ # Constants, schemas, MCP defaults
│ ├── council/ # Council manager (multi-LLM session orchestration)
│ ├── hooks/ # OpenCode lifecycle hooks
│ ├── mcp/ # MCP server definitions
│ ├── skills/ # Skill definitions (included in package publish)
│ ├── tools/ # Tool definitions (background tasks, council, etc.)
│ └── utils/ # Shared utilities (tmux, session helpers)
├── dist/ # Built JavaScript and declarations
├── docs/ # User-facing documentation
├── biome.json # Biome configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Project manifest and scripts
@modelcontextprotocol/sdk - MCP protocol implementation@opencode-ai/sdk - OpenCode AI SDKzod - Runtime validationvscode-jsonrpc / vscode-languageserver-protocol - LSP supportbun run check:ci to verify linting and formattingbun run typecheck to verify typesbun test to verify tests passWhen working with tmux integration, understanding the session lifecycle is crucial for preventing orphaned processes and ghost panes.
Task Launch:
session.create() → tmux pane spawned → task runs
Task Completes Normally:
session.status (idle) → extract results → session.abort()
→ session.deleted event → tmux pane closed
Task Cancelled:
cancel() → session.abort() → session.deleted event
→ tmux pane closed
Session Deleted Externally:
session.deleted event → task cleanup → tmux pane closed
1. Graceful Shutdown (src/utils/tmux.ts)
// Always send Ctrl+C before killing pane
spawn([tmux, "send-keys", "-t", paneId, "C-c"])
await delay(250)
spawn([tmux, "kill-pane", "-t", paneId])
2. Session Abort Timing (src/background/background-manager.ts)
session.abort() AFTER extracting task resultssession.deleted event for cleanup3. Event Handlers (src/index.ts) Both handlers must be wired up:
backgroundManager.handleSessionDeleted() - cleans up task statetmuxSessionManager.onSessionDeleted() - closes tmux paneAfter making changes to session management:
# 1. Build the plugin
bun run build
# 2. Run from local fork (in ~/.config/opencode/opencode.jsonc):
# "plugin": ["file:///path/to/oh-my-opencode-slim"]
# 3. Launch test tasks
@explorer count files in src/
@librarian search for Bun documentation
# 4. Verify no orphans
ps aux | grep "opencode attach" | grep -v grep
# Should return 0 processes after tasks complete
Ghost panes remaining open:
session.abort() is called after result extractionsession.deleted handler is wired in src/index.tsOrphaned opencode attach processes:
Before pushing changes to the repository, always run a code review to catch issues like:
/review Command (Recommended)OpenCode has a built-in /review command that automatically performs comprehensive code reviews:
# Review uncommitted changes (default)
/review
# Review specific commit
/review <commit-hash>
# Review branch comparison
/review <branch-name>
# Review PR
/review <pr-url-or-number>
Why use /review instead of asking @oracle manually?
Make your changes
# ... edit files ...
Stage changes
git add .
Run code review
/review
Address any issues found
Run checks
bun run check:ci
bun test
Commit and push
git commit -m "..."
git push origin <branch>
Note: The /review command found issues in our PR #127 (duplicate code, redundant abort calls) that neither linter nor tests caught. Always use it before pushing!
src/src/cli/index.tssrc/index.tssrc/agents/ — each agent has its own file + optional .test.tssrc/skills/ (included in package publish)src/background/src/council/src/utils/tmux.tsbun test to verify