|
| 1 | +# AGENTS.md — Developer & Agent Reference |
| 2 | + |
| 3 | +Internal reference for AI agents and human developers working on OpenCode Advance. |
| 4 | +For user-facing documentation, see [`README.md`](README.md). |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Project Overview |
| 9 | + |
| 10 | +**OpenCode Advance** (`oca`) is the environment and configuration platform for [OpenCode](https://opencode.ai). It replaces the earlier `open-chad` project with a Go-based, declarative rewrite. It pairs with the [Advance](https://github.com/Sharper-Flow/Advance) spec-driven workflow plugin as a required dependency. |
| 11 | + |
| 12 | +- **Repo**: `https://github.com/Sharper-Flow/Opencode-Advance.git` |
| 13 | +- **Branch**: `trunk` (default), remote `origin` |
| 14 | +- **Language**: Go 1.22+ (CLI core), Bash (tmux/shell integration only), Markdown (design docs, proposals) |
| 15 | +- **Test framework**: Go stdlib `testing` + golden files; bash test scripts for shell integration |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Relationship to Advance |
| 20 | + |
| 21 | +OpenCode Advance depends on Advance; Advance does not depend on OpenCode Advance. |
| 22 | + |
| 23 | +- OpenCode Advance clones, builds, and wires the Advance plugin as part of `oca install` / `oca apply` |
| 24 | +- OpenCode Advance delegates all Advance-owned asset sync to `advance/scripts/sync-global.sh --fix` |
| 25 | +- OpenCode Advance does **not** duplicate any files that Advance owns: `adv-*.md` commands, ADV agents (`plan`, `scout`, `refine`, `adv-researcher`, `tron`), ADV skills (`adv-*`), or ADV instructions |
| 26 | +- OpenCode Advance owns the non-ADV slice of the environment: environment-level agents (`build`, `explore`, `librarian`, `general`, `mechanic`), instructions (rules.yaml, identity, shell_strategy, etc.), MCP server lifecycle, plugin management, providers, session/tmux UX |
| 27 | + |
| 28 | +This clean boundary is the central reason OpenCode Advance exists as a separate project. Each file in `~/.config/opencode/` has exactly one owner. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Architecture |
| 33 | + |
| 34 | +``` |
| 35 | +opencodeadvance/ |
| 36 | +├── stack.toml # THE source of truth (user creates; oca reads) |
| 37 | +├── stack.example.toml # Complete example reference |
| 38 | +│ |
| 39 | +├── cmd/oca/ # CLI entry point (Go) |
| 40 | +│ └── main.go |
| 41 | +│ |
| 42 | +├── internal/ # Internal Go packages |
| 43 | +│ ├── config/ # stack.toml parser + schema validation |
| 44 | +│ ├── render/ # Templates + JSON merge logic |
| 45 | +│ ├── health/ # MCP/plugin/instruction health checks |
| 46 | +│ └── migrate/ # open-chad → opencode-advance importer |
| 47 | +│ |
| 48 | +├── assets/ # Static files, copied as-is to ~/.config/opencode/ |
| 49 | +│ ├── agents/ # build.md, explore.md, librarian.md, general.md, mechanic.md |
| 50 | +│ ├── instructions/ # identity.md, rules.yaml, shell_strategy.md, etc. |
| 51 | +│ ├── skills/ # lgrep, mcp-selection, morph, worktree, prioritizer |
| 52 | +│ └── themes/ |
| 53 | +│ ├── obsidian.json # OpenCode UI theme (obsidian palette, indigo accent) |
| 54 | +│ ├── obsidian.tmux.conf # Tmux 2-row status bar theme |
| 55 | +│ └── obsidian-light.tmux.conf # Optional light variant (future) |
| 56 | +│ |
| 57 | +├── templates/ # Go text/template files rendered by oca apply |
| 58 | +│ ├── opencode.json.gotmpl # Merged into ~/.config/opencode/opencode.json |
| 59 | +│ ├── vision-servers.yaml.gotmpl # Rendered to ~/.config/vision/servers.yaml |
| 60 | +│ └── tmux.conf.block.gotmpl # Block injected into ~/.tmux.conf |
| 61 | +│ |
| 62 | +├── bin/ # Shell-level entry points (post-install) |
| 63 | +│ ├── oca # Thin wrapper calling the Go binary |
| 64 | +│ ├── oc # Short alias (retains muscle memory) |
| 65 | +│ ├── cds # Scratch dir launcher |
| 66 | +│ └── ocashell.sh # Completion bootstrap |
| 67 | +│ |
| 68 | +├── lib/ # Shell-only helpers (tmux theming, status bar) |
| 69 | +│ ├── obsidian.tmux.conf # Live theme file (also present in assets/) |
| 70 | +│ ├── status_bar.sh # Status bar renderer |
| 71 | +│ ├── boot_splash.sh # Boot splash with wordmark reveal |
| 72 | +│ ├── session_lifecycle.sh # tmux session teardown hooks |
| 73 | +│ └── discord/ # Discord Rich Presence integration |
| 74 | +│ |
| 75 | +├── tests/ # Test suites |
| 76 | +│ ├── config_test.go # stack.toml parse/validate |
| 77 | +│ ├── render_test.go # Template rendering golden files |
| 78 | +│ ├── apply_test.go # End-to-end apply with mock home |
| 79 | +│ └── shell/ # Bash tests for shell integration |
| 80 | +│ |
| 81 | +├── docs/ |
| 82 | +│ ├── design/ # Architecture, brand, schema, CLI reference |
| 83 | +│ │ ├── architecture.md |
| 84 | +│ │ ├── brand.md |
| 85 | +│ │ ├── wordmark.md |
| 86 | +│ │ ├── palette.md |
| 87 | +│ │ ├── theme.md |
| 88 | +│ │ ├── stack-toml-schema.md |
| 89 | +│ │ └── cli-surface.md |
| 90 | +│ ├── proposals/ # Implementation planning docs |
| 91 | +│ │ ├── v1-implementation.md # Full v1.0 proposal content (for first ADV change) |
| 92 | +│ │ ├── phases.md # Phase sequencing |
| 93 | +│ │ └── first-boot.md # How to initialize ADV in this repo |
| 94 | +│ └── specs/ # Generated spec docs (populated by ADV) |
| 95 | +│ |
| 96 | +├── .adv/ # ADV state directories (plugin-managed) |
| 97 | +│ ├── specs/ # Capability specs (written by ADV) |
| 98 | +│ ├── changes/ # Active change proposals (written by ADV) |
| 99 | +│ └── archive/ # Completed changes (written by ADV) |
| 100 | +│ |
| 101 | +└── .github/ |
| 102 | + └── workflows/ # CI (populated in Phase 1) |
| 103 | +``` |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## Development Model |
| 108 | + |
| 109 | +This project is developed through the Advance spec-driven workflow. Every non-trivial change is an ADV change with: |
| 110 | + |
| 111 | +- A proposal (problem statement, success criteria, constraints) |
| 112 | +- Research (validated architectural decisions) |
| 113 | +- Prep (task graph synthesized from research) |
| 114 | +- Apply (TDD-driven implementation) |
| 115 | +- Review (code review across multiple dimensions) |
| 116 | +- Harden (quality verification and cleanup) |
| 117 | +- Signoff (user approval) |
| 118 | + |
| 119 | +The v1.0 initial implementation is scoped in [`docs/proposals/v1-implementation.md`](docs/proposals/v1-implementation.md) and phased in [`docs/proposals/phases.md`](docs/proposals/phases.md). |
| 120 | + |
| 121 | +### First ADV change |
| 122 | + |
| 123 | +See [`docs/proposals/first-boot.md`](docs/proposals/first-boot.md) for the exact sequence to initialize ADV state in this repo and create the first change from the scaffolded proposal content. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## Clean cutover policy |
| 128 | + |
| 129 | +During development, OpenCode Advance MUST NOT modify the user's live OpenCode configuration. All development and testing happens in isolated config directories: |
| 130 | + |
| 131 | +- `~/.config/opencode-advance-dev/` (instead of `~/.config/opencode/`) |
| 132 | +- `~/.config/vision-dev/` (instead of `~/.config/vision/`) |
| 133 | +- Isolated tmux socket if needed |
| 134 | + |
| 135 | +The `oca` CLI accepts environment overrides for all target paths so tests and dev runs never touch production state: |
| 136 | + |
| 137 | +| Override | Purpose | |
| 138 | +| ------------------------- | --------------------------------------------------------------- | |
| 139 | +| `OCA_OPENCODE_CONFIG_DIR` | Target OpenCode config dir (default: `~/.config/opencode`) | |
| 140 | +| `OCA_VISION_CONFIG_DIR` | Target Vision config dir (default: `~/.config/vision`) | |
| 141 | +| `OCA_PLUGIN_CHECKOUT_ROOT` | Where plugins are cloned (default: `~/dev/oc-plugins/`) | |
| 142 | +| `OCA_CACHE_DIR` | Cache/runtime dir (default: `$XDG_RUNTIME_DIR/opencode-advance`) | |
| 143 | + |
| 144 | +At v1.0 release time, the user runs `oca migrate from-open-chad` which performs a one-shot read of the current `open-chad`-managed state, emits a `stack.toml` reflecting it, and then `oca install` applies it to production. |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## What goes where (file ownership matrix) |
| 149 | + |
| 150 | +| File / dir | Owner | Notes | |
| 151 | +| ------------------------------------------- | ------------- | -------------------------------------------------- | |
| 152 | +| `stack.toml` | **user** | Source of truth. User edits. `oca` reads. | |
| 153 | +| `~/.config/opencode/opencode.json` | **oca** | Rendered from stack.toml + plugin-provided fragments | |
| 154 | +| `~/.config/opencode/agents/build.md` | **oca** | Environment-level agent | |
| 155 | +| `~/.config/opencode/agents/explore.md` | **oca** | Environment-level agent | |
| 156 | +| `~/.config/opencode/agents/librarian.md` | **oca** | Environment-level agent | |
| 157 | +| `~/.config/opencode/agents/general.md` | **oca** | Environment-level agent | |
| 158 | +| `~/.config/opencode/agents/mechanic.md` | **oca** | Environment-level agent | |
| 159 | +| `~/.config/opencode/agents/plan.md` | **Advance** | ADV agent (via sync-global.sh) | |
| 160 | +| `~/.config/opencode/agents/scout.md` | **Advance** | ADV agent | |
| 161 | +| `~/.config/opencode/agents/refine.md` | **Advance** | ADV agent | |
| 162 | +| `~/.config/opencode/agents/adv-researcher.md` | **Advance** | ADV agent | |
| 163 | +| `~/.config/opencode/agents/tron.md` | **Advance** | ADV agent | |
| 164 | +| `~/.config/opencode/command/adv-*.md` | **Advance** | ADV slash commands | |
| 165 | +| `~/.config/opencode/command/oca-*.md` | **oca** | OpenCode Advance slash commands (if any) | |
| 166 | +| `~/.config/opencode/skills/adv-*/` | **Advance** | ADV methodology skills | |
| 167 | +| `~/.config/opencode/skills/lgrep/` | **oca** | Tool selection skills | |
| 168 | +| `~/.config/opencode/skills/morph/` | **oca** | Tool selection skills | |
| 169 | +| `~/.config/opencode/skills/prioritizer/` | **oca** | Shared methodology skill | |
| 170 | +| `~/.config/opencode/skills/worktree/` | **oca** | Shared methodology skill | |
| 171 | +| `~/.config/opencode/skills/mcp-selection/` | **oca** | Tool selection skill | |
| 172 | +| `~/.config/opencode/instructions/identity.md` | **oca** | Environment-level instruction | |
| 173 | +| `~/.config/opencode/instructions/rules.yaml` | **oca** | Environment-level instruction | |
| 174 | +| `~/.config/opencode/instructions/ADV_*.md` | **Advance** | Advance instruction (path referenced) | |
| 175 | +| `~/.config/vision/servers.yaml` | **oca** | Rendered from stack.toml | |
| 176 | +| `~/.tmux.conf` (OCA block only) | **oca** | Managed block, rest is user-owned | |
| 177 | +| `~/.zshrc` / `~/.bashrc` (OCA block only) | **oca** | Managed block, rest is user-owned | |
| 178 | + |
| 179 | +Any file not in the "oca" or "Advance" column is user-owned and MUST NOT be touched by `oca apply`. |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## Commit style |
| 184 | + |
| 185 | +- Conventional commits: `feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`, `style:` |
| 186 | +- Scope when relevant: `feat(config): add stack.toml schema validation` |
| 187 | +- Atomic commits — one logical change per commit |
| 188 | +- Never commit secrets or user-specific paths |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## CI/Release (Phase 1+) |
| 193 | + |
| 194 | +To be populated in `.github/workflows/`: |
| 195 | + |
| 196 | +- `ci.yml` — on every PR and push to trunk: `go test ./...`, `go vet ./...`, `gofmt -d .` |
| 197 | +- `release.yml` — on version tags (`v*`): goreleaser builds cross-platform binaries, publishes to GitHub Releases |
0 commit comments