2025-12-05 01:50:02 +09:00
# PROJECT KNOWLEDGE BASE
2026-02-02 21:19:21 +09:00
**Generated: ** 2026-02-02T21:16:00+09:00
**Commit: ** d80adac3
**Branch: ** dev
2025-12-05 01:50:02 +09:00
2026-01-26 11:48:30 +09:00
---
2026-02-03 11:04:00 +09:00
## CRITICAL: PULL REQUEST TARGET BRANCH (NEVER DELETE THIS SECTION)
2026-01-26 11:48:30 +09:00
2026-02-03 11:04:00 +09:00
> **THIS SECTION MUST NEVER BE REMOVED OR MODIFIED**
### Git Workflow
```
master (deployed/published)
↑
dev (integration branch)
↑
feature branches (your work)
```
### Rules (MANDATORY)
| Rule | Description |
|------|-------------|
| **ALL PRs → `dev` ** | Every pull request MUST target the `dev` branch |
| **NEVER PR → `master` ** | PRs to `master` are **automatically rejected ** by CI |
| * * "Create a PR" = target `dev` ** | When asked to create a new PR, it ALWAYS means targeting `dev` |
### Why This Matters
- `master` = production/published npm package
- `dev` = integration branch where features are merged and tested
- Feature branches → `dev` → (after testing) → `master`
**If you create a PR targeting `master`, it WILL be rejected. No exceptions. **
---
## CRITICAL: OPENCODE SOURCE CODE REFERENCE (NEVER DELETE THIS SECTION)
> **THIS SECTION MUST NEVER BE REMOVED OR MODIFIED**
### This is an OpenCode Plugin
Oh-My-OpenCode is a **plugin for OpenCode ** . You will frequently need to examine OpenCode's source code to:
- Understand plugin APIs and hooks
- Debug integration issues
- Implement features that interact with OpenCode internals
- Answer questions about how OpenCode works
### How to Access OpenCode Source Code
**When you need to examine OpenCode source: **
1. **Clone to system temp directory: **
```bash
git clone https://github.com/sst/opencode /tmp/opencode-source
` ``
2. **Explore the codebase** from there (do NOT clone into the project directory)
3. **Clean up** when done (optional, temp dirs are ephemeral)
### Librarian Agent: YOUR PRIMARY TOOL for Plugin Work
**CRITICAL**: When working on plugin-related tasks or answering plugin questions:
| Scenario | Action |
|----------|--------|
| Implementing new hooks | Fire ` librarian` to search OpenCode hook implementations |
| Adding new tools | Fire ` librarian` to find OpenCode tool patterns |
| Understanding SDK behavior | Fire ` librarian` to examine OpenCode SDK source |
| Debugging plugin issues | Fire ` librarian` to find relevant OpenCode internals |
| Answering "how does OpenCode do X?" | Fire ` librarian` FIRST |
**The ` librarian` agent is specialized for:**
- Searching remote codebases (GitHub)
- Retrieving official documentation
- Finding implementation examples in open source
**DO NOT guess or hallucinate about OpenCode internals.** Always verify by examining actual source code via ` librarian` or direct clone.
2026-01-26 11:48:30 +09:00
---
2026-02-03 12:11:23 +09:00
## CRITICAL: ENGLISH-ONLY POLICY (NEVER DELETE THIS SECTION)
> **THIS SECTION MUST NEVER BE REMOVED OR MODIFIED**
### All Project Communications MUST Be in English
This is an **international open-source project**. To ensure accessibility and maintainability:
| Context | Language Requirement |
|---------|---------------------|
| **GitHub Issues** | English ONLY |
| **Pull Requests** | English ONLY (title, description, comments) |
| **Commit Messages** | English ONLY |
| **Code Comments** | English ONLY |
| **Documentation** | English ONLY |
| **AGENTS.md files** | English ONLY |
### Why This Matters
- **Global Collaboration**: Contributors from all countries can participate
- **Searchability**: English keywords are universally searchable
- **AI Agent Compatibility**: AI tools work best with English content
- **Consistency**: Mixed languages create confusion and fragmentation
### Enforcement
- Issues/PRs with non-English content may be closed with a request to resubmit in English
- Commit messages must be in English - CI may reject non-English commits
- Translated READMEs exist (README.ko.md, README.ja.md, etc.) but the primary docs are English
**If you're not comfortable writing in English, use translation tools. Broken English is fine - we'll help fix it. Non-English is not acceptable.**
---
2025-12-05 01:50:02 +09:00
## OVERVIEW
2026-02-02 21:19:21 +09:00
O P E N C O D E plugin: multi-model agent orchestration (Claude Opus 4.5, GPT-5.2, Gemini 3 Flash). 34 lifecycle hooks, 20+ tools (LSP, AST-Grep, delegation), 11 specialized agents, full Claude Code compatibility. "oh-my-zsh" for O P E N C O D E.
2025-12-05 01:50:02 +09:00
## STRUCTURE
` ``
oh-my-opencode/
├── src/
2026-02-01 19:26:57 +09:00
│ ├── agents/ # 11 AI agents - see src/agents/AGENTS.md
│ ├── hooks/ # 34 lifecycle hooks - see src/hooks/AGENTS.md
2026-01-23 02:14:08 +09:00
│ ├── tools/ # 20+ tools - see src/tools/AGENTS.md
│ ├── features/ # Background agents, Claude Code compat - see src/features/AGENTS.md
2026-01-26 11:48:30 +09:00
│ ├── shared/ # 55 cross-cutting utilities - see src/shared/AGENTS.md
2026-01-23 02:14:08 +09:00
│ ├── cli/ # CLI installer, doctor - see src/cli/AGENTS.md
│ ├── mcp/ # Built-in MCPs - see src/mcp/AGENTS.md
2026-01-15 15:53:51 +09:00
│ ├── config/ # Zod schema, TypeScript types
2026-02-02 21:19:21 +09:00
│ └── index.ts # Main plugin entry (788 lines)
2026-01-23 02:14:08 +09:00
├── script/ # build-schema.ts, build-binaries.ts
2026-02-01 19:26:57 +09:00
├── packages/ # 11 platform-specific binaries
2025-12-14 17:18:09 +09:00
└── dist/ # Build output (ESM + .d.ts)
2025-12-05 01:50:02 +09:00
` ``
## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
2026-01-23 02:14:08 +09:00
| Add agent | ` src/agents/` | Create .ts with factory, add to ` agentSources` |
2026-01-17 22:01:56 +09:00
| Add hook | ` src/hooks/` | Create dir with ` createXXXHook()`, register in index.ts |
2026-01-23 02:14:08 +09:00
| Add tool | ` src/tools/` | Dir with index/types/constants/tools.ts |
2026-01-17 22:01:56 +09:00
| Add MCP | ` src/mcp/` | Create config, add to index.ts |
| Add skill | ` src/features/builtin-skills/` | Create dir with SKILL.md |
2026-01-25 13:12:40 +09:00
| Add command | ` src/features/builtin-commands/` | Add template + register in commands.ts |
2026-01-23 02:14:08 +09:00
| Config schema | ` src/config/schema.ts` | Zod schema, run ` bun run build:schema` |
2026-02-01 19:26:57 +09:00
| Background agents | ` src/features/background-agent/` | manager.ts (1418 lines) |
| Orchestrator | ` src/hooks/atlas/` | Main orchestration hook (757 lines) |
2025-12-05 01:50:02 +09:00
2026-01-03 10:05:03 +09:00
## TDD (Test-Driven Development)
2026-01-23 02:14:08 +09:00
**MANDATORY.** RED-GREEN-REFACTOR:
1. **RED**: Write test → ` bun test` → FAIL
2. **GREEN**: Implement minimum → PASS
3. **REFACTOR**: Clean up → stay GREEN
2026-01-03 10:05:03 +09:00
**Rules:**
- NEVER write implementation before test
2026-01-23 02:14:08 +09:00
- NEVER delete failing tests - fix the code
2026-01-26 11:48:30 +09:00
- Test file: ` *.test.ts` alongside source (100 test files)
- BDD comments: ` //#given `, ` //#when `, ` //#then `
2026-01-03 10:05:03 +09:00
2025-12-05 01:50:02 +09:00
## CONVENTIONS
2026-01-09 02:24:43 +09:00
- **Package manager**: Bun only (` bun run`, ` bun build`, ` bunx`)
2026-01-23 02:14:08 +09:00
- **Types**: bun-types (NEVER @types/node)
2026-01-02 10:42:38 +09:00
- **Build**: ` bun build` (ESM) + ` tsc --emitDeclarationOnly`
2026-01-23 02:14:08 +09:00
- **Exports**: Barrel pattern via index.ts
- **Naming**: kebab-case dirs, ` createXXXHook`/` createXXXTool` factories
2026-01-26 11:48:30 +09:00
- **Testing**: BDD comments, 100 test files
2026-01-02 10:42:38 +09:00
- **Temperature**: 0.1 for code agents, max 0.3
2026-01-23 02:14:08 +09:00
## ANTI-PATTERNS
2026-01-09 02:24:43 +09:00
2026-01-17 22:01:56 +09:00
| Category | Forbidden |
|----------|-----------|
2026-01-23 02:14:08 +09:00
| Package Manager | npm, yarn - Bun exclusively |
| Types | @types/node - use bun-types |
| File Ops | mkdir/touch/rm/cp/mv in code - use bash tool |
| Publishing | Direct ` bun publish` - GitHub Actions only |
| Versioning | Local version bump - CI manages |
| Type Safety | ` as any`, ` @ts -ignore`, ` @ts -expect-error` |
| Error Handling | Empty catch blocks |
| Testing | Deleting failing tests |
| Agent Calls | Sequential - use ` delegate_task` parallel |
| Hook Logic | Heavy PreToolUse - slows every call |
| Commits | Giant (3+ files), separate test from impl |
| Temperature | >0.3 for code agents |
| Trust | Agent self-reports - ALWAYS verify |
2025-12-05 01:50:02 +09:00
## AGENT MODELS
2026-01-23 02:14:08 +09:00
| Agent | Model | Purpose |
|-------|-------|---------|
2026-01-30 16:15:00 +09:00
| Sisyphus | anthropic/claude-opus-4-5 | Primary orchestrator (fallback: kimi-k2.5 → glm-4.7 → gpt-5.2-codex → gemini-3-pro) |
2026-02-01 19:26:57 +09:00
| Hephaestus | openai/gpt-5.2-codex | Autonomous deep worker, "The Legitimate Craftsman" (requires gpt-5.2-codex, no fallback) |
2026-01-30 14:52:45 +09:00
| Atlas | anthropic/claude-sonnet-4-5 | Master orchestrator (fallback: kimi-k2.5 → gpt-5.2) |
2026-01-23 02:14:08 +09:00
| oracle | openai/gpt-5.2 | Consultation, debugging |
2026-01-30 14:52:45 +09:00
| librarian | zai-coding-plan/glm-4.7 | Docs, GitHub search (fallback: glm-4.7-free) |
2026-02-02 21:19:21 +09:00
| explore | xai/grok-code-fast-1 | Fast codebase grep (fallback: claude-haiku-4-5 → gpt-5-mini → gpt-5-nano) |
2026-01-24 15:30:35 +09:00
| multimodal-looker | google/gemini-3-flash | PDF/image analysis |
2026-01-30 14:52:45 +09:00
| Prometheus | anthropic/claude-opus-4-5 | Strategic planning (fallback: kimi-k2.5 → gpt-5.2) |
2025-12-05 01:50:02 +09:00
## COMMANDS
` ``bash
2025-12-24 17:11:18 +09:00
bun run typecheck # Type check
bun run build # ESM + declarations + schema
bun run rebuild # Clean + Build
2026-01-26 11:48:30 +09:00
bun test # 100 test files
2025-12-05 01:50:02 +09:00
` ``
2025-12-05 15:32:09 +09:00
## DEPLOYMENT
2026-01-23 02:14:08 +09:00
**GitHub Actions workflow_dispatch ONLY**
1. Commit & push changes
2. Trigger: ` gh workflow run publish -f bump=patch`
3. Never ` bun publish` directly, never bump version locally
2025-12-31 14:07:14 +09:00
## COMPLEXITY HOTSPOTS
| File | Lines | Description |
|------|-------|-------------|
2026-01-26 11:48:30 +09:00
| ` src/features/builtin-skills/skills.ts` | 1729 | Skill definitions |
2026-02-02 21:19:21 +09:00
| ` src/features/background-agent/manager.ts` | 1457 | Task lifecycle, concurrency |
2026-02-01 19:26:57 +09:00
| ` src/agents/prometheus-prompt.ts` | 1283 | Planning agent prompt |
| ` src/tools/delegate-task/tools.ts` | 1135 | Category-based delegation |
| ` src/hooks/atlas/index.ts` | 757 | Orchestrator hook |
| ` src/index.ts` | 788 | Main plugin entry |
| ` src/cli/config-manager.ts` | 667 | JSONC config parsing |
2026-01-25 13:12:40 +09:00
| ` src/features/builtin-commands/templates/refactor.ts` | 619 | Refactor command template |
2026-01-13 21:00:00 +09:00
## MCP ARCHITECTURE
2026-01-23 02:14:08 +09:00
Three-tier system:
1. **Built-in**: websearch (Exa), context7 (docs), grep_app (GitHub)
2. **Claude Code compat**: .mcp.json with ` ${VAR}` expansion
3. **Skill-embedded**: YAML frontmatter in skills
2026-01-13 21:00:00 +09:00
## CONFIG SYSTEM
2026-01-15 15:53:51 +09:00
- **Zod validation**: ` src/config/schema.ts`
2026-01-23 02:14:08 +09:00
- **JSONC support**: Comments, trailing commas
2026-01-17 22:01:56 +09:00
- **Multi-level**: Project (` .opencode/`) → User (` ~/.config/opencode/`)
2025-12-22 02:25:05 +09:00
2025-12-05 01:50:02 +09:00
## NOTES
2026-02-02 21:19:21 +09:00
- **O P E N C O D E**: Requires >= 1.0.150
2026-01-23 02:14:08 +09:00
- **Flaky tests**: ralph-loop (CI timeout), session-state (parallel pollution)
2026-01-09 02:24:43 +09:00
- **Trusted deps**: @ast -grep/cli, @ast -grep/napi, @code -yeongyu/comment-checker