opencode-dispatcher 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/README.md +19 -9
- package/docs/agents.md +107 -0
- package/docs/configuration.md +215 -0
- package/docs/development.md +74 -0
- package/docs/workflow.md +100 -0
- package/package.json +9 -3
- package/workflow/agents/documentation.md +3 -1
- package/workflow/agents/implementer.md +3 -3
- package/workflow/agents/orchestrator.md +31 -3
- package/workflow/agents/shipper.md +1 -1
- package/workflow/agents/task-planner.md +77 -35
- package/workflow/agents/test-writer.md +1 -1
- package/workflow/agents/validator.md +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [v0.4.0]
|
|
6
|
+
|
|
7
|
+
- **Stronger Handoff Contract**: Orchestrator now delegates to task-planner with a rich structured handoff (conversation context, user preferences, corrections, rejected options, rationale) instead of a lossy brief summary, preventing context loss and overconfident under-contextualized specs.
|
|
8
|
+
- **Parallel Planning**: Orchestrator now owns high-level decomposition (single-unit vs multi-unit classification, unit boundaries, dependencies, parallelizability) and can spawn multiple task-planner agents in parallel with assigned output paths for faster multi-unit workflows.
|
|
9
|
+
- **Docs-First Routing**: Orchestrator routes to the documentation agent before task-planner when correctness depends on cross-cutting durable context (UX, product, domain, architecture, API, security decisions), ensuring task-planner has an approved source artifact to cite.
|
|
10
|
+
- **Documentation Owns Durable Artifacts**: The documentation agent now explicitly owns durable source artifact types (UX briefs, product briefs, ADRs, API contracts, domain models, etc.) and reports when user approval is needed before task-planning.
|
|
11
|
+
- **Validator Cites Source Artifacts**: The validator now checks cited source artifacts alongside the task spec when the task spec references them, ensuring implementations stay faithful to approved durable context.
|
|
12
|
+
- **Orchestrator Prompt Slimmed**: Orchestrator prompt cleaned up with clearer responsibility split — orchestrator owns routing and coordination while task-planner owns detailed planning mechanics, field-level handoff definitions, path algorithms, and parent/child manifest formatting.
|
|
13
|
+
|
|
14
|
+
## [v0.3.3]
|
|
15
|
+
|
|
16
|
+
- **Workflow Fix**: Agents now use direct reads/directory listings for `.ai/` files instead of `glob`, preventing missed `.ai/context.md` checks.
|
|
17
|
+
|
|
18
|
+
## [v0.3.2]
|
|
19
|
+
|
|
20
|
+
- **Model-Config Consent Fix**: The `model-config` agent no longer silently accepts default model selections without explicit user consent — it now requires the user to confirm before applying default models.
|
|
21
|
+
|
|
22
|
+
## [v0.3.1]
|
|
23
|
+
|
|
24
|
+
- **Shipper Inspection & Release-Boundary Fixes**: Tightened shipper bash permission whitelist to eliminate pre-commit inspection prompts and fixed release-boundary routing so the shipper only commits and pushes explicitly intended changes.
|
|
25
|
+
|
|
26
|
+
## [v0.3.0]
|
|
27
|
+
|
|
28
|
+
- **Model-Config Groups**: Replaced per-agent model selection with two-tier group-based workflow (MED/LOW), excluding orchestrator and task-planner.
|
|
29
|
+
|
|
30
|
+
## [v0.2.11]
|
|
31
|
+
|
|
32
|
+
- **Routing Clarity**: Clarified executor routing as exact, mechanical, low-risk edits rather than file-count-based; clarified planner auto-proceed behavior when no user-facing decisions are introduced.
|
|
33
|
+
- **Shipper Boundary**: Tightened shipper routing so it only commits and pushes existing intended changes.
|
|
34
|
+
- **CI Update**: Updated publish workflow to Node 24-compatible GitHub Actions (`actions/checkout@v6`, `actions/setup-node@v6`, `node-version: 24`).
|
|
35
|
+
|
|
36
|
+
## [v0.2.10]
|
|
37
|
+
|
|
38
|
+
- **Agent Context**: Shipper agent now reads `.ai/context.md` for project-specific conventions (commit format, version bump patterns, auto-publish). Added `read` permission to shipper. Updated `.ai/context.md` with publication and auto-publish conventions. Added CI workflow (`.github/workflows/publish.yml`) to auto-publish on version bump commits.
|
|
39
|
+
|
|
40
|
+
## [v0.2.8]
|
|
41
|
+
|
|
42
|
+
- **Agent Clarity**: Updated `init` and `orchestrator` agents to accurately describe `agy` as an Antigravity CLI integration for splitting quota across models. Removed "file count" from the orchestrator's executor and task-planner routing rules — routing decisions now key on risk, complexity, and clarity instead.
|
|
43
|
+
|
|
44
|
+
## [v0.2.7]
|
|
45
|
+
|
|
46
|
+
- **Agent Fixes**: Fixed the `model-config` agent so it writes valid JSON(C) (not YAML) into `opencode.jsonc`, added `find`/`echo`/`sort`/`git config`/`ls` bash permissions to the `shipper` agent to eliminate pre-commit inspection permission prompts, and updated `model-config` to skip the orchestrator when presenting agents for model selection (the orchestrator's model is chosen directly by the user).
|
|
47
|
+
|
|
48
|
+
## [v0.2.6]
|
|
49
|
+
|
|
50
|
+
- **Agent Improvements**: Added `agy` integration awareness to the `init` and `orchestrator` agents. Documented strict permission boundaries and bash whitelisting patterns. Added common request routing patterns to the orchestrator. Removed unnecessary `.ai` edit denials from the executor agent.
|
|
51
|
+
|
|
52
|
+
## [v0.2.5]
|
|
53
|
+
|
|
54
|
+
- **Model Configuration**: Added the `model-config` agent to seamlessly assign specific models to different agents in the project's `opencode.jsonc`.
|
|
55
|
+
- **Workflow Standardization**: Enforced sequential, zero-padded numeric prefixes for all task directories (e.g., `001-feature-name`) across all agents to ensure proper sorting and tracking.
|
|
56
|
+
- **Usability Fixes**: Granted `bash` execution allowances to `implementer` and `validator` agents to reduce excessive permission prompts during test and build cycles.
|
|
57
|
+
- **Artifact Improvements**: Split the task spec template into *Testable Acceptance Criteria* (with explicit test file path hints) and *Inspectable Acceptance Criteria* to better guide the `test-writer` and `validator`.
|
|
58
|
+
|
|
59
|
+
## [v0.2.4]
|
|
60
|
+
|
|
61
|
+
- Hardened security boundaries by applying explicit read-only bash whitelists to the `orchestrator` and sealing `edit: deny` escape hatches.
|
|
62
|
+
|
|
63
|
+
## [v0.2.1]
|
|
64
|
+
|
|
65
|
+
- Minor permission fixes to allow the orchestrator to cleanly delegate to the `executor` fast-path agent.
|
|
66
|
+
|
|
67
|
+
## [v0.2.0]
|
|
68
|
+
|
|
69
|
+
- **Major Overhaul**: Replaced the general conversational agents with a durable, stateful task workflow.
|
|
70
|
+
- Introduced the central `orchestrator` as a user-facing router.
|
|
71
|
+
- Shifted to explicit `.ai/tasks/` artifacts (task specs, implementation reports, validation reports) to make agent work inspectable, resumable, and git-trackable.
|
|
72
|
+
- Consolidated legacy roles into specialized agents (`task-planner`, `implementer`, `validator`, `test-writer`).
|
package/README.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# OpenCode Dispatcher
|
|
2
2
|
|
|
3
|
-
OpenCode Dispatcher is a workflow pack for OpenCode that adds specialist development agents coordinated through file-based task artifacts. It is designed for substantial coding work where you want the agent workflow to be easier to inspect, resume, and validate.
|
|
3
|
+
OpenCode Dispatcher is a workflow pack for OpenCode that adds specialist development agents coordinated through file-based task artifacts. It is designed for substantial coding work where you want the agent workflow to be easier to inspect, resume, and validate. This package is for developers using OpenCode who want structured, auditable workflows for complex coding sessions.
|
|
4
4
|
|
|
5
5
|
Instead of relying on long chat history, Dispatcher keeps durable task state in your project under `.ai/tasks/` (task specs, implementation reports, validation reports, documentation reports). For tiny one-off edits or quick questions, plain OpenCode is often enough.
|
|
6
6
|
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- **OpenCode** — Dispatcher is a workflow add-on for OpenCode. You must have OpenCode installed and configured before using Dispatcher.
|
|
10
|
+
- **Node.js >= 18** — Required for running the installer.
|
|
11
|
+
|
|
7
12
|
## Installation
|
|
8
13
|
|
|
9
14
|
Install from the npm registry:
|
|
@@ -19,12 +24,12 @@ npm run check
|
|
|
19
24
|
npm run install:local
|
|
20
25
|
```
|
|
21
26
|
|
|
22
|
-
After installing, restart OpenCode so it reloads your global configuration.
|
|
27
|
+
After installing, restart OpenCode so it reloads your global configuration. For details on what the installer copies, backup behavior, and uninstall, see [Configuration](docs/configuration.md).
|
|
23
28
|
|
|
24
29
|
## First Use
|
|
25
30
|
|
|
26
31
|
1. Install Dispatcher and restart OpenCode.
|
|
27
|
-
2. Open your project and
|
|
32
|
+
2. Open your project and ask the orchestrator to initialize `.ai/context.md`. For example: *"Set up my project context."*
|
|
28
33
|
3. For substantial work, ask the orchestrator to create a task spec:
|
|
29
34
|
|
|
30
35
|
```text
|
|
@@ -53,12 +58,17 @@ After installing, restart OpenCode so it reloads your global configuration.
|
|
|
53
58
|
|
|
54
59
|
## Further Reading
|
|
55
60
|
|
|
56
|
-
- [CHANGELOG.md](CHANGELOG.md) — version history
|
|
57
|
-
- [docs/workflow.md](docs/workflow.md) — orchestrator/subagent flow and task artifacts
|
|
58
|
-
- [docs/agents.md](docs/agents.md) — subagent reference and permission model
|
|
59
|
-
- [docs/configuration.md](docs/configuration.md) — model config, agy, opencode config, install details
|
|
60
|
-
- [docs/development.md](docs/development.md) — validation, conventions, releases, publishing
|
|
61
|
+
- [CHANGELOG.md](https://github.com/louisemalvin/opencode-dispatcher/blob/master/CHANGELOG.md) — version history
|
|
62
|
+
- [docs/workflow.md](https://github.com/louisemalvin/opencode-dispatcher/blob/master/docs/workflow.md) — orchestrator/subagent flow and task artifacts
|
|
63
|
+
- [docs/agents.md](https://github.com/louisemalvin/opencode-dispatcher/blob/master/docs/agents.md) — subagent reference and permission model
|
|
64
|
+
- [docs/configuration.md](https://github.com/louisemalvin/opencode-dispatcher/blob/master/docs/configuration.md) — model config, agy, opencode config, install details
|
|
65
|
+
- [docs/development.md](https://github.com/louisemalvin/opencode-dispatcher/blob/master/docs/development.md) — validation, conventions, releases, publishing
|
|
66
|
+
|
|
67
|
+
## Version History
|
|
68
|
+
|
|
69
|
+
- **v0.4.0** — Workflow improvements: stronger orchestrator-task-planner handoff, parallel planning, docs-first routing, documentation owns durable artifacts, validator checks cited source artifacts.
|
|
70
|
+
- **v0.3.3** — Workflow fix: agents now use direct reads/directory listings for `.ai/` files instead of `glob`, preventing missed `.ai/context.md` checks.
|
|
61
71
|
|
|
62
72
|
## License
|
|
63
73
|
|
|
64
|
-
MIT. See [LICENSE](LICENSE) for details.
|
|
74
|
+
MIT. See [LICENSE](https://github.com/louisemalvin/opencode-dispatcher/blob/master/LICENSE) for details.
|
package/docs/agents.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Agents
|
|
2
|
+
|
|
3
|
+
This document is the agent reference for OpenCode Dispatcher. It lists every installed agent, describes its role and mode, and explains the permission philosophy that governs how agents interact with your project.
|
|
4
|
+
|
|
5
|
+
For the end-to-end workflow routing and lifecycle, see [`docs/workflow.md`](workflow.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Agent Reference
|
|
10
|
+
|
|
11
|
+
Dispatcher installs 11 agents. The **orchestrator** is the primary, user-facing coordinator. All other agents are **subagents** — they are invoked by the orchestrator for specific scoped work and are typically hidden from agent selection UIs.
|
|
12
|
+
|
|
13
|
+
| Agent | Mode | Role Summary |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| Orchestrator | primary | User-facing coordinator and state-machine router; clarifies requests, applies docs-first routing to documentation when durable context is needed, owns high-level task decomposition, provides a structured handoff to task-planner, delegates to subagents, and synthesizes results |
|
|
16
|
+
| Executor | subagent | Performs exact, mechanical, single-file atomic edits that do not need a task spec, tests, or validation |
|
|
17
|
+
| Task Planner | subagent | Creates auditable task specs under `.ai/tasks/` from an orchestrator handoff; owns path allocation, required spec sections, parent/child manifest mechanics, and planning-blocked behavior; formalizes plans without inventing missing strategic decisions; accepts assigned output paths for unit-level planning |
|
|
18
|
+
| Implementer | subagent | Edits source code according to an approved task spec and writes an implementation report |
|
|
19
|
+
| Validator | subagent | Validates completed work against a task spec and any cited durable source artifacts, runs tests from acceptance criteria, audits test quality, and writes a validation report |
|
|
20
|
+
| Test Writer | subagent | Writes tests that encode testable acceptance criteria from an approved task spec; never writes implementation code |
|
|
21
|
+
| Documentation | subagent | Creates durable source artifacts (UX briefs, ADRs, domain models, API contracts, etc.) for cross-cutting context; writes documentation, project context updates, decision notes, and task documentation reports; reports when user approval is needed before task-planning |
|
|
22
|
+
| Research | subagent | Gathers external facts, official documentation, comparisons, and source-backed evidence before planning decisions |
|
|
23
|
+
| Shipper | subagent | Handles git commit and push only when explicitly requested; no edits, deployment, or general development |
|
|
24
|
+
| Init | subagent | Bootstraps `.ai/context.md` for new projects by interviewing the user about conventions and test setup |
|
|
25
|
+
| Model Config | subagent | Assigns models to agents in the project's `opencode.jsonc` configuration |
|
|
26
|
+
|
|
27
|
+
For optional agy integration (Antigravity CLI for splitting quota across models), see [Configuration > Agy Integration](configuration.md#agy-integration).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Permission Philosophy
|
|
32
|
+
|
|
33
|
+
Dispatcher enforces strict boundaries through OpenCode's permission model. Every agent's permissions are declared in its YAML frontmatter (in `workflow/agents/*.md`) and are designed so that no agent can silently cross role boundaries.
|
|
34
|
+
|
|
35
|
+
### Deny-by-Default
|
|
36
|
+
|
|
37
|
+
Permissions start locked down. Each agent is granted only the specific capabilities its role requires:
|
|
38
|
+
|
|
39
|
+
- **Orchestrator**: `edit: deny` — the orchestrator cannot write to any file. Its `bash` permission is a strict whitelist limited to read-only informational commands (`ls`, `pwd`, `which`, `env`, `echo`, `uname`, `file`, `wc`, `git status`, `git diff`, `git log`, `git branch`, `git remote`, `git rev-parse`, `git show`, `git config`, `git stash list`, `git ls-files`). All other shell commands (`*`) are denied. Git write commands (`git commit*`, `git push*`) are explicitly denied.
|
|
40
|
+
- **Research**: `edit: deny`, with `webfetch: allow` only. It cannot write files or run arbitrary shell commands.
|
|
41
|
+
- **Shipper**: `edit: deny`, `read: allow`, with a strict `bash` whitelist of specific `git` commands (`git status`, `git diff`, `git log`, `git branch`, `git remote`, `git rev-parse`, `git add *`, `git commit *`, `git push*`) and inspection utilities (`find`, `echo`, `sort`, `ls`, `grep`, `head`, `tail`, `cat`, `wc`, `file`, `node -p`). Destructive operations (`git reset*`, `git rebase*`, `git clean*`, `git tag*`, `git commit -a*`, `git commit --amend*`, `gh pr*`, and any deploy commands) are explicitly denied.
|
|
42
|
+
- **Task Planner**: `edit` is denied everywhere except `.ai/tasks/**` and `.ai/decisions/**`.
|
|
43
|
+
- **Validator**: `edit` is denied everywhere except `.ai/tasks/*/validation-report.md`.
|
|
44
|
+
- **Test Writer**: `edit` is denied everywhere except test file patterns (`**/*.test.*`, `**/test_*`, `**/*_test.*`, `**/__tests__/**`, `**/tests/**`, `**/spec/**`). It has no `task` permission.
|
|
45
|
+
- **Documentation**: `edit` is denied everywhere except `docs/**`, `README.md`, `README.*`, `CHANGELOG.md`, `.ai/tasks/*/documentation-report.md`, and `.ai/decisions/**`. Configuration files (`.opencode/**`, `opencode.json`, `opencode.jsonc`, `package.json`, `package-lock.json`, lock files) are explicitly denied.
|
|
46
|
+
- **Init**: `edit` is denied everywhere except `.ai/context.md`. It has `question: allow` to interview the user.
|
|
47
|
+
- **Model Config**: `edit` is denied everywhere except `opencode.jsonc` or `.opencode/opencode.jsonc`. It has no `task` permission.
|
|
48
|
+
|
|
49
|
+
### Role Boundaries
|
|
50
|
+
|
|
51
|
+
Each agent owns a specific layer of the workflow. No agent is allowed to cross roles:
|
|
52
|
+
|
|
53
|
+
- **Orchestrator** coordinates, routes (including docs-first routing), and decomposes but never implements, documents, or validates.
|
|
54
|
+
- **Task Planner** plans and decomposes, owns path allocation and planning mechanics, but never edits source code or project docs outside `.ai/`.
|
|
55
|
+
- **Implementer** edits source code but cannot write tests (that is the Test Writer's role) or fix validation issues (the Validator reports them; only a new task can fix them).
|
|
56
|
+
- **Validator** reads and reports (against task spec AND cited source artifacts) but never fixes issues or edits code.
|
|
57
|
+
- **Test Writer** writes tests but never writes implementation code.
|
|
58
|
+
- **Documentation** creates durable source artifacts where needed, writes docs and context, but never edits source code or configuration.
|
|
59
|
+
- **Research** gathers evidence but never implements or edits.
|
|
60
|
+
- **Shipper** commits and pushes but never edits files, runs tests, or deploys.
|
|
61
|
+
- **Init** bootstraps context but never edits source code or task artifacts.
|
|
62
|
+
- **Model Config** configures model assignments but never edits code, docs, or `.ai/` artifacts.
|
|
63
|
+
|
|
64
|
+
### Escape Hatch Sealing
|
|
65
|
+
|
|
66
|
+
A secure permission model must ensure that restricted capabilities cannot be bypassed through allowed tools. Dispatcher seals the two common escape hatches:
|
|
67
|
+
|
|
68
|
+
1. **`edit: deny` must not be subverted through shell commands.** The orchestrator has `edit: deny` and a read-only `bash` whitelist. Commands that could write files (e.g., `echo > file`, `cat > file`, `tee`, `redirects` in shell) are not in the whitelist; the `*: deny` fallback catches everything else. No shell-based file write is possible.
|
|
69
|
+
|
|
70
|
+
2. **`bash` whitelists must not contain write-capable commands.** The orchestrator's whitelist is limited to read-only queries. The shipper's whitelist allows specific `git` operations but denies `git reset`, `git rebase`, `git clean`, `git tag`, `git commit -a`, `git commit --amend`, and force-push variants. The validator has broad `bash: allow` but `edit: deny` (except its own report), so destructive shell commands are blocked by the edit layer.
|
|
71
|
+
|
|
72
|
+
### Practical Allowances
|
|
73
|
+
|
|
74
|
+
Some agents have intentionally broad permissions to avoid excessive prompting during normal development cycles:
|
|
75
|
+
|
|
76
|
+
- **Implementer**: `bash: * allow` so it can seamlessly run test, build, and dev commands without permission prompts. Its `edit` scope prevents it from touching `.ai/tasks/**` (except its own `implementation-report.md`), `.ai/context.md`, and `.ai/decisions/**` — it can edit source code freely but cannot alter task artifacts.
|
|
77
|
+
- **Validator**: `bash: * allow` for the same reason — running test suites and build commands should not require repeated approval. Its `edit` scope is tightly restricted (only `validation-report.md`).
|
|
78
|
+
- **Executor**: Both `bash: * allow` and `edit: * allow` because it handles exact, mechanical, low-risk edits where the overhead of restricted permissions would add friction without safety benefit. If an edit exceeds this scope, the executor escalates back to the orchestrator.
|
|
79
|
+
|
|
80
|
+
### Task Gating
|
|
81
|
+
|
|
82
|
+
The orchestrator's `task` permission is explicitly scoped to named agents — no wildcard task permission exists:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
task:
|
|
86
|
+
"*": deny
|
|
87
|
+
task-planner: allow
|
|
88
|
+
implementer: allow
|
|
89
|
+
documentation: allow
|
|
90
|
+
validator: allow
|
|
91
|
+
research: allow
|
|
92
|
+
shipper: allow
|
|
93
|
+
test-writer: allow
|
|
94
|
+
init: allow
|
|
95
|
+
model-config: allow
|
|
96
|
+
executor: allow
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This means the orchestrator can only delegate to the 10 explicitly listed subagents. It cannot delegate to an arbitrary or unknown agent, which prevents privilege escalation through delegation.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Summary
|
|
104
|
+
|
|
105
|
+
Dispatcher's permission model follows a simple principle: **an agent can do everything its role requires and nothing its role does not**. Permissions are layered — `edit`, `bash`, and `task` are each scoped independently — and the deny-by-default baseline ensures that every allowance is intentional and auditable through the agent's YAML frontmatter.
|
|
106
|
+
|
|
107
|
+
For workflow-level routing and the execution lifecycle, see [`docs/workflow.md`](workflow.md).
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
## Model Configuration
|
|
4
|
+
|
|
5
|
+
Dispatcher supports per-agent model assignment through a two-tier group system managed by the **model-config** agent.
|
|
6
|
+
|
|
7
|
+
### Group System
|
|
8
|
+
|
|
9
|
+
The configurable subagents are divided into two recommendation tiers:
|
|
10
|
+
|
|
11
|
+
| Group | Agents | Recommended Model Class |
|
|
12
|
+
|-------|--------|------------------------|
|
|
13
|
+
| **MED** | `validator`, `test-writer`, `documentation`, `init` | Medium reasoning model |
|
|
14
|
+
| **LOW** | `implementer`, `research`, `executor`, `shipper`, `model-config` | Cheaper / lower reasoning model |
|
|
15
|
+
|
|
16
|
+
The **orchestrator** and **task-planner** are excluded from group assignment — their models are chosen directly by the user in OpenCode itself. The task-planner is intended to use the same model as the orchestrator.
|
|
17
|
+
|
|
18
|
+
These are recommendation tiers, not hardcoded assignments — you choose the actual model for each group through the model-config agent. The `opencode.jsonc` file included in this repository is the maintainer's preset: a ready-to-use starting point that you can override with your own model choices.
|
|
19
|
+
|
|
20
|
+
### Configuration Flow
|
|
21
|
+
|
|
22
|
+
1. The orchestrator delegates model configuration to the **model-config** agent.
|
|
23
|
+
2. The model-config agent runs `opencode models --verbose` to discover available models and their variants on the system.
|
|
24
|
+
3. It checks for an existing opencode config at `opencode.jsonc` or `.opencode/opencode.jsonc` (in that order of preference).
|
|
25
|
+
4. It presents both groups to the user with their intended model tiers and asks the user to pick one model (and optionally a variant) for each group — not per-agent.
|
|
26
|
+
5. For the chosen model, if it has variants (non-empty `variants` object in verbose output), the user is prompted to select one or skip. Models with no variants (`{}`) skip the variant prompt silently.
|
|
27
|
+
6. The model-config agent writes `agent.<name>.model` (and optionally `agent.<name>.variant`) entries for every agent in each group into the project's opencode config, preserving all existing content.
|
|
28
|
+
|
|
29
|
+
### Config File Format
|
|
30
|
+
|
|
31
|
+
The model assignments are written to `opencode.jsonc` or `.opencode/opencode.jsonc`:
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
{
|
|
35
|
+
"agent": {
|
|
36
|
+
"orchestrator": {
|
|
37
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
38
|
+
"variant": "medium"
|
|
39
|
+
},
|
|
40
|
+
"implementer": {
|
|
41
|
+
"model": "opencode-go/deepseek-v4-flash"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If no opencode config exists, the model-config agent creates one with only the agent entries.
|
|
48
|
+
|
|
49
|
+
## Agy Integration
|
|
50
|
+
|
|
51
|
+
**Agy** (Antigravity CLI integration) is an optional mechanism that offloads implementer work to a separate CLI tool called `agy`, allowing quota usage to be split across different models.
|
|
52
|
+
|
|
53
|
+
### How It Works
|
|
54
|
+
|
|
55
|
+
- The implementer agent reads `.ai/context.md` and checks for an `agy: enabled` flag under the `## Workflow` section.
|
|
56
|
+
- If `agy` is enabled and available (verified via `which agy`), the implementer constructs a prompt containing:
|
|
57
|
+
- Its full persona (the agent definition file contents)
|
|
58
|
+
- The complete task spec
|
|
59
|
+
- The contents of all relevant files listed in the task spec
|
|
60
|
+
- It runs `agy --dangerously-skip-permissions --print "<prompt>"` which executes the edits directly.
|
|
61
|
+
- After agy finishes, the implementer verifies the changes, runs validation, writes the implementation report, and reports back to the orchestrator.
|
|
62
|
+
|
|
63
|
+
### Enabling Agy
|
|
64
|
+
|
|
65
|
+
Add the following flag to `.ai/context.md` under `## Workflow`:
|
|
66
|
+
|
|
67
|
+
```markdown
|
|
68
|
+
## Workflow
|
|
69
|
+
|
|
70
|
+
- **agy**: enabled
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The flag is **user-owned** — agents never modify it. During project initialization, the **init** agent asks the user whether they want to enable agy integration.
|
|
74
|
+
|
|
75
|
+
### Fallback
|
|
76
|
+
|
|
77
|
+
If agy is not enabled (`agy: enabled` missing or set to a falsy value) or the `agy` binary is not available, the implementer proceeds with manual implementation steps.
|
|
78
|
+
|
|
79
|
+
## OpenCode Config Locations
|
|
80
|
+
|
|
81
|
+
Dispatcher's configuration spans two levels:
|
|
82
|
+
|
|
83
|
+
### Project-Level Config
|
|
84
|
+
|
|
85
|
+
OpenCode reads project configuration from the following locations, in order of preference:
|
|
86
|
+
|
|
87
|
+
1. **`opencode.jsonc`** (preferred) — in the project root
|
|
88
|
+
2. **`.opencode/opencode.jsonc`** — in the `.opencode/` subdirectory
|
|
89
|
+
|
|
90
|
+
The model-config agent writes per-agent model assignments to whichever file exists, preferring `opencode.jsonc` if both are present. If neither exists, it creates `opencode.jsonc`.
|
|
91
|
+
|
|
92
|
+
### Global / User-Level Config
|
|
93
|
+
|
|
94
|
+
OpenCode's global configuration lives at:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
~/.config/opencode/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This directory contains:
|
|
101
|
+
|
|
102
|
+
| Directory / File | Description |
|
|
103
|
+
|-----------------|-------------|
|
|
104
|
+
| `agents/` | Installed agent definitions (managed by Dispatcher) |
|
|
105
|
+
| `skills/` | OpenCode skills (not managed by Dispatcher) |
|
|
106
|
+
| `templates/` | Prompt templates (not managed by Dispatcher) |
|
|
107
|
+
| `AGENTS.md` | User-owned agent documentation — never touched by Dispatcher |
|
|
108
|
+
|
|
109
|
+
Dispatcher installs managed payloads into `~/.config/opencode/agents/`. The `skills/`, `templates/`, and `AGENTS.md` under `~/.config/opencode/` are **user-owned** and never modified, backed up, or removed by Dispatcher.
|
|
110
|
+
|
|
111
|
+
## Install Locations and Payloads
|
|
112
|
+
|
|
113
|
+
### What the Installer Copies
|
|
114
|
+
|
|
115
|
+
The installer (`bin/install.js`) copies Dispatcher's managed payloads into:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
~/.config/opencode/agents/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Current payloads include agent definitions for:
|
|
122
|
+
- Orchestration
|
|
123
|
+
- Initialization
|
|
124
|
+
- Task planning
|
|
125
|
+
- Test writing
|
|
126
|
+
- Implementation
|
|
127
|
+
- Documentation
|
|
128
|
+
- Validation
|
|
129
|
+
- Research
|
|
130
|
+
- Shipping
|
|
131
|
+
- Exact mechanical edits (executor)
|
|
132
|
+
- Model configuration
|
|
133
|
+
|
|
134
|
+
### What the Installer Does NOT Manage
|
|
135
|
+
|
|
136
|
+
The installer does **not** install or manage:
|
|
137
|
+
|
|
138
|
+
- Provider configuration
|
|
139
|
+
- Model settings
|
|
140
|
+
- Secrets (API keys, tokens)
|
|
141
|
+
- Project dependencies (`node_modules`)
|
|
142
|
+
- Git configuration
|
|
143
|
+
- `opencode.jsonc` (project-level config is user-managed)
|
|
144
|
+
- Global skills under `~/.config/opencode/skills/`
|
|
145
|
+
- Prompt templates under `~/.config/opencode/templates/`
|
|
146
|
+
- `~/.config/opencode/AGENTS.md`
|
|
147
|
+
|
|
148
|
+
For agent role descriptions, see [docs/agents.md](agents.md). For development and release processes, see [docs/development.md](development.md).
|
|
149
|
+
|
|
150
|
+
## Install Safety
|
|
151
|
+
|
|
152
|
+
Before overwriting a managed path, the installer backs up the existing path beside it using a timestamped `.bak-*` suffix.
|
|
153
|
+
|
|
154
|
+
Example backup:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
~/.config/opencode/agents.bak-2026-06-07T12-34-56-789Z
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The installer then overlays the Dispatcher payload into the managed path.
|
|
161
|
+
|
|
162
|
+
### Backup Semantics
|
|
163
|
+
|
|
164
|
+
- **Same-named files** may be overwritten in the managed path.
|
|
165
|
+
- **Unrelated pre-existing files** in the managed path may remain.
|
|
166
|
+
- **Backups are kept beside the managed path** and are not modified by subsequent installs.
|
|
167
|
+
- **`~/.config/opencode/AGENTS.md`** is never backed up, overwritten, or touched in any way — it is fully user-owned.
|
|
168
|
+
|
|
169
|
+
This is an overlay, not a merge. The installer does not attempt to diff or merge files.
|
|
170
|
+
|
|
171
|
+
## Restore and Uninstall
|
|
172
|
+
|
|
173
|
+
### Restoring a Backup
|
|
174
|
+
|
|
175
|
+
To restore a previously backed-up managed path:
|
|
176
|
+
|
|
177
|
+
1. **Stop OpenCode** so global config is reloaded afterward.
|
|
178
|
+
2. Remove or rename the current managed path:
|
|
179
|
+
```bash
|
|
180
|
+
mv ~/.config/opencode/agents ~/.config/opencode/agents.dispatcher
|
|
181
|
+
```
|
|
182
|
+
3. Move the matching `.bak-*` path back to its original name:
|
|
183
|
+
```bash
|
|
184
|
+
mv ~/.config/opencode/agents.bak-<timestamp> ~/.config/opencode/agents
|
|
185
|
+
```
|
|
186
|
+
4. **Restart OpenCode** so it reloads the global configuration.
|
|
187
|
+
|
|
188
|
+
### Uninstalling Dispatcher
|
|
189
|
+
|
|
190
|
+
- **If you had pre-existing global agents** before installing Dispatcher: restore your backups first (see above).
|
|
191
|
+
- **If you do not need any current contents** (including files that may have existed before Dispatcher was installed): remove the managed paths outright:
|
|
192
|
+
```bash
|
|
193
|
+
rm -rf ~/.config/opencode/agents
|
|
194
|
+
```
|
|
195
|
+
- **`~/.config/opencode/AGENTS.md`** is never removed or modified — it remains even after uninstall.
|
|
196
|
+
|
|
197
|
+
After any restore or uninstall, restart OpenCode so it reloads `~/.config/opencode/`.
|
|
198
|
+
|
|
199
|
+
## Package Commands
|
|
200
|
+
|
|
201
|
+
The following commands are available from `package.json`:
|
|
202
|
+
|
|
203
|
+
| Command | Equivalent | Description |
|
|
204
|
+
|---------|-----------|-------------|
|
|
205
|
+
| `npm run check` | `npx opencode-dispatcher check` | Validates agent frontmatter integrity and orchestrator cross-references |
|
|
206
|
+
| `npm run install:local` | `npx opencode-dispatcher install` | Installs Dispatcher payloads into `~/.config/opencode/` |
|
|
207
|
+
| `npx opencode-dispatcher` (no args) | `npx opencode-dispatcher install` | Defaults to install |
|
|
208
|
+
|
|
209
|
+
Invalid commands print usage and exit with a non-zero status.
|
|
210
|
+
|
|
211
|
+
The package is published on the npm registry as `opencode-dispatcher`:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npx opencode-dispatcher install
|
|
215
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
This document covers repository maintenance, validation, release conventions, and publishing for the OpenCode Dispatcher package.
|
|
4
|
+
|
|
5
|
+
## Validation
|
|
6
|
+
|
|
7
|
+
The project uses a single check command as its validation gate:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This is equivalent to:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
node ./bin/install.js check
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The check validates the following:
|
|
20
|
+
|
|
21
|
+
- **Agent frontmatter completeness** — Every agent markdown file in `workflow/agents/` must contain YAML frontmatter (delimited by `---`) with required fields:
|
|
22
|
+
- `description` — A summary of the agent's role.
|
|
23
|
+
- `mode` — One of `primary`, `subagent`, or `all`.
|
|
24
|
+
- `permission` — Permission blocks that define what the agent may read, edit, or execute.
|
|
25
|
+
- **Cross-reference integrity** — Every agent that the orchestrator permits (via its `permission.task` block) must have a corresponding `.md` file in `workflow/agents/`, and every agent file (except the orchestrator itself) must be listed in the orchestrator's permitted set.
|
|
26
|
+
|
|
27
|
+
The check also verifies that `workflow/skills/` and `workflow/templates/` are empty or absent, since workflow behavior has been consolidated into agent definitions.
|
|
28
|
+
|
|
29
|
+
`npm run check` must pass before any release.
|
|
30
|
+
|
|
31
|
+
For a full list of package commands, see [Configuration](configuration.md).
|
|
32
|
+
|
|
33
|
+
## Repository Structure
|
|
34
|
+
|
|
35
|
+
| Path | Purpose |
|
|
36
|
+
|------|---------|
|
|
37
|
+
| `bin/install.js` | CLI installer and checker — supports `install` and `check` commands |
|
|
38
|
+
| `workflow/agents/` | Agent markdown definitions with YAML frontmatter |
|
|
39
|
+
| `workflow/skills/` | Skill definitions (currently unused; must remain empty) |
|
|
40
|
+
| `workflow/templates/` | Task artifact templates (currently unused; must remain empty) |
|
|
41
|
+
| `.ai/` | Project-level task artifacts and project context (git-tracked) |
|
|
42
|
+
| `.github/workflows/publish.yml` | CI auto-publish workflow |
|
|
43
|
+
|
|
44
|
+
## Conventions
|
|
45
|
+
|
|
46
|
+
The project follows these conventions, defined in `.ai/context.md`:
|
|
47
|
+
|
|
48
|
+
| Aspect | Convention |
|
|
49
|
+
|--------|------------|
|
|
50
|
+
| **Language** | Node.js (ESM — `"type": "module"` in `package.json`) |
|
|
51
|
+
| **JS style** | StandardJS / Prettier defaults (semicolons, double quotes, trailing commas) |
|
|
52
|
+
| **Naming** | kebab-case for files; camelCase for JavaScript identifiers and functions |
|
|
53
|
+
| **File layout** | Flat structure — CLI scripts live in `bin/`; no `src/` directory |
|
|
54
|
+
| **Commit messages** | [Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) format |
|
|
55
|
+
| **Version bumps** | `chore(release): bump to vX.Y.Z` |
|
|
56
|
+
|
|
57
|
+
## Release Workflow
|
|
58
|
+
|
|
59
|
+
The end-to-end release process follows these steps:
|
|
60
|
+
|
|
61
|
+
1. **Prepare metadata** — Bump the version number in `package.json` following semver.
|
|
62
|
+
2. **Prepare documentation** — Update the Version History section in `README.md` with a description of the changes included in the release. Any changelog updates should also be prepared at this stage.
|
|
63
|
+
3. **Invoke the shipper agent** — The shipper handles the git commit and push. All metadata and documentation changes must be ready before the shipper is invoked.
|
|
64
|
+
4. **Commit format** — The shipper uses the commit message `chore(release): bump to vX.Y.Z`, which matches the CI auto-publish trigger pattern.
|
|
65
|
+
|
|
66
|
+
Per the [project conventions](#conventions), version bump preparation (metadata and README changes) must be completed by the responsible agent (implementer, executor, or documentation) before the shipper is called.
|
|
67
|
+
|
|
68
|
+
## CI Auto-Publish
|
|
69
|
+
|
|
70
|
+
Publishing is automated via `.github/workflows/publish.yml`. On push to `master` with `bump to v` in the commit message, the workflow runs the validation gate and publishes to npm. See the workflow file for the exact steps and authentication details.
|
|
71
|
+
|
|
72
|
+
## Project Context
|
|
73
|
+
|
|
74
|
+
See [Workflow > Project Context](workflow.md#project-context) for details on `.ai/context.md`.
|
package/docs/workflow.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Workflow
|
|
2
|
+
|
|
3
|
+
This document describes the high-level OpenCode Dispatcher workflow: how the orchestrator routes requests, how task artifacts are laid out, and how agents coordinate.
|
|
4
|
+
|
|
5
|
+
For a complete agent reference, see [docs/agents.md](agents.md).
|
|
6
|
+
|
|
7
|
+
## Role Split
|
|
8
|
+
|
|
9
|
+
Dispatcher uses five core agents with distinct responsibilities:
|
|
10
|
+
|
|
11
|
+
- **Orchestrator**: Conversation/context router, high-level decomposition coordinator, user-facing owner. Routes to the right agent, owns the state machine, and provides a structured handoff for non-trivial work.
|
|
12
|
+
- **Documentation**: Durable source artifact author for cross-cutting/reusable context (UX briefs, ADRs, domain models, API contracts, etc.). Reports when user approval is needed before task-planning.
|
|
13
|
+
- **Task Planner**: Task artifact author and planning mechanics owner. Owns path allocation, parent/child manifest format, required spec sections, and self-directed fallback decomposition.
|
|
14
|
+
- **Implementer**: Executes approved task specs by editing source code.
|
|
15
|
+
- **Validator**: Checks completed work against the task spec and any cited durable source artifacts.
|
|
16
|
+
|
|
17
|
+
Docs-first routing: When correctness depends on cross-cutting/reusable context not yet captured in durable form, the orchestrator routes to documentation BEFORE task-planner so task-planner has an approved source artifact to cite.
|
|
18
|
+
|
|
19
|
+
## Orchestrator State Machine
|
|
20
|
+
|
|
21
|
+
The orchestrator operates as a six-state state machine. Not every request passes through every state — the orchestrator always chooses the smallest safe workflow for the task.
|
|
22
|
+
|
|
23
|
+
- **INTAKE**: Classify the incoming request. Determine whether it is a question, idea exploration, simple edit, non-trivial implementation, research-backed decision, documentation task, validation or review, or a commit/push request.
|
|
24
|
+
- **CLARIFY**: Talk with the user until the request is solid enough to route. A request is solid when the desired outcome, affected files, rough scope, important non-goals, risk level, and expected verification are all understood. The orchestrator asks one focused question only when the missing answer would change scope, safety, or routing.
|
|
25
|
+
- **ROUTE**: Choose the smallest safe path. The orchestrator decides which agent or direct answer best fits the request, applying docs-first routing when durable context is needed.
|
|
26
|
+
- **DELEGATE**: Dispatch the work to the appropriate specialist agent. After the subagent completes, control always returns to the orchestrator.
|
|
27
|
+
- **REVIEW**: After non-trivial implementation or documentation work, validate the result against the task spec. If validation fails, allow one fix cycle. If issues remain, escalate to the user.
|
|
28
|
+
- **DONE**: Summarise the outcome, changed files or artifacts, verification results, and any open issues.
|
|
29
|
+
|
|
30
|
+
## Routing Logic
|
|
31
|
+
|
|
32
|
+
The orchestrator selects the smallest safe workflow based on the nature of the request:
|
|
33
|
+
|
|
34
|
+
- **Direct answer** — When no file changes are needed. Used for explanations, reviews, comparisons, and planning advice.
|
|
35
|
+
- **Docs-first routing** — When correctness depends on cross-cutting/reusable context not yet in durable form, route to documentation first, then to task-planner citing that artifact.
|
|
36
|
+
- **Executor (fast path)** — When the requested edit is exact, mechanical, low-risk, and does not need task planning or acceptance criteria.
|
|
37
|
+
- **Task-planner** — When the work is behaviour-changing, risky, unclear, needs acceptance criteria, or benefits from a written plan before implementation. The orchestrator provides a rich structured handoff (see [Rich Handoff Concept](#rich-handoff-concept)).
|
|
38
|
+
- **Research** — When a decision depends on external facts such as official documentation, vendor behaviour, pricing, APIs, or current best practices.
|
|
39
|
+
- **Shipper** — Only for explicit git commit or push requests after the intended file changes already exist.
|
|
40
|
+
- **Documentation** — When the task involves README updates, project context updates, decision notes, changelog entries, or documentation reports.
|
|
41
|
+
- **Model-config** — When the user wants to configure per-agent models for this project.
|
|
42
|
+
|
|
43
|
+
## Task Artifact Layout
|
|
44
|
+
|
|
45
|
+
Dispatcher stores durable task state under `.ai/tasks/`. Each task gets a zero-padded numeric prefix and a short slug:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
.ai/tasks/<NNN>-<task-id>/
|
|
49
|
+
task-spec.md
|
|
50
|
+
implementation-report.md
|
|
51
|
+
validation-report.md
|
|
52
|
+
documentation-report.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| File | Purpose | Written by |
|
|
56
|
+
|------|---------|-----------|
|
|
57
|
+
| `task-spec.md` | Approved scope, acceptance criteria, constraints, relevant files, and validation plan. Includes an `## Execution` section listing the agent pipeline. | Task-planner |
|
|
58
|
+
| `implementation-report.md` | What files were changed, what approach was taken, and any open questions. | Implementer |
|
|
59
|
+
| `validation-report.md` | Verification results against the task spec's acceptance criteria and cited source artifacts. | Validator |
|
|
60
|
+
| `documentation-report.md` | Outcome, files changed, context or decisions updated, verification, and follow-ups. | Documentation |
|
|
61
|
+
|
|
62
|
+
The `## Execution` section in `task-spec.md` drives the agent pipeline: test-writer, implementer, and/or documentation, in that order. The orchestrator reads this section, spawns agents sequentially, and always runs the validator last.
|
|
63
|
+
|
|
64
|
+
## Project Context
|
|
65
|
+
|
|
66
|
+
`.ai/context.md` captures durable project truth that persists across tasks and sessions. It stores shared language, architecture facts, conventions, test framework, stable decisions, and workflow flags. The orchestrator checks for it on first interaction; if missing, delegates to the init agent. Specialist agents read it using the `read` tool before acting.
|
|
67
|
+
|
|
68
|
+
## Common Routes
|
|
69
|
+
|
|
70
|
+
### Ask a Question, Tiny Edit
|
|
71
|
+
|
|
72
|
+
These are unchanged from the current workflow: direct answer for questions, executor for exact mechanical edits.
|
|
73
|
+
|
|
74
|
+
### Substantial Feature or Fix
|
|
75
|
+
|
|
76
|
+
The orchestrator applies docs-first routing: if durable/cross-cutting context is needed, routes to documentation first. Then routes to task-planner for a task spec. After user approval, reads the spec's `## Execution` section, spawns agents sequentially (implementer, validator), and summarises the outcome.
|
|
77
|
+
|
|
78
|
+
### Research-Backed Change
|
|
79
|
+
|
|
80
|
+
The orchestrator routes to research first, then applies the substantial feature or fix route with the research findings as source context.
|
|
81
|
+
|
|
82
|
+
### Documentation Task, Commit/Push
|
|
83
|
+
|
|
84
|
+
These routes are unchanged.
|
|
85
|
+
|
|
86
|
+
## Rich Handoff Concept
|
|
87
|
+
|
|
88
|
+
When delegating non-trivial work to the task-planner, the orchestrator provides a **rich structured handoff** that preserves conversation-derived context. This prevents context loss in the orchestrator→task-planner delegation.
|
|
89
|
+
|
|
90
|
+
The handoff fields are: User Intent, Conversation-Derived Context, Source Artifacts / Source Context, Proposed Task Shape, Assigned Output Path(s), Scope and Non-Goals, Constraints, Acceptance Signals, Authority Boundary, Open Questions / Stop Conditions. Each field is filled; empty fields use "None."
|
|
91
|
+
|
|
92
|
+
Detailed field definitions and mechanics live in the orchestrator and task-planner agent prompts. The orchestrator owns filling this handoff for every non-trivial planning invocation.
|
|
93
|
+
|
|
94
|
+
## Decomposition Ownership
|
|
95
|
+
|
|
96
|
+
The orchestrator owns single-unit vs multi-unit classification and high-level decomposition. The task-planner formalizes from the orchestrator's handoff. Task-planner performs self-directed decomposition only as a fallback when the orchestrator has not provided a unit split.
|
|
97
|
+
|
|
98
|
+
## Planning Mechanics (Owned by Task-Planner)
|
|
99
|
+
|
|
100
|
+
Detailed task artifact mechanics — path allocation (computing the next `<NNN>`), parent/child manifest format, required spec sections, self-directed fallback decomposition, and planning-blocked behavior — are owned by the task-planner agent. See `workflow/agents/task-planner.md` for the full specification.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-dispatcher",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "OpenCode add-on providing structured multi-agent workflows, durable task artifacts, and an orchestrator agent for complex AI coding sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"opencode-dispatcher": "bin/install.js"
|
|
@@ -13,8 +13,14 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin/",
|
|
15
15
|
"workflow/",
|
|
16
|
-
"README.md"
|
|
16
|
+
"README.md",
|
|
17
|
+
"docs/",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"LICENSE"
|
|
17
20
|
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
18
24
|
"keywords": [
|
|
19
25
|
"opencode",
|
|
20
26
|
"ai-agents",
|
|
@@ -24,10 +24,12 @@ You are the Documentation Agent.
|
|
|
24
24
|
|
|
25
25
|
Own documentation, project context, decision notes, and documentation reports when delegated by orchestrator.
|
|
26
26
|
|
|
27
|
+
Own durable source artifacts for cross-cutting and reusable context. Types of durable artifacts you create include: UX design brief, product brief, interaction model, feature behavior spec, ADR, domain model, business rules doc, API contract, integration spec, migration plan, runbook, testing strategy, convention guide. If an artifact introduces meaningful decisions, report that user approval is needed before task-planning.
|
|
28
|
+
|
|
27
29
|
Responsibilities:
|
|
28
30
|
|
|
29
31
|
- Update `.ai/context.md` when delegated. Do not create `.ai/context.md` from scratch — that is owned by the init agent. Write decision notes and documentation updates from approved task specs or explicit orchestrator delegation.
|
|
30
|
-
- Read existing docs, `.ai/context.md
|
|
32
|
+
- Read existing docs, `.ai/context.md` (use the `read` tool — `glob` is unreliable for `.ai/` paths), task specs, and relevant source files before writing.
|
|
31
33
|
- Write decision notes under `.ai/decisions/` for stable, non-obvious decisions when delegated.
|
|
32
34
|
- Write `.ai/tasks/<NNN>-<task-id>/documentation-report.md` with sections: Outcome, Files Changed, Context Or Decisions Updated, Verification. Include Follow-Ups only if there are any.
|
|
33
35
|
- Keep docs concise, accurate, and grounded in source files or approved decisions.
|
|
@@ -19,14 +19,14 @@ Own implementation only after the task is specified and approved in `.ai/tasks/<
|
|
|
19
19
|
|
|
20
20
|
Responsibilities:
|
|
21
21
|
|
|
22
|
-
- Agy integration (optional): After reading `.ai/context.md
|
|
23
|
-
- Read `.ai/context.md` and the task spec before editing.
|
|
22
|
+
- Agy integration (optional): After reading `.ai/context.md` (use the `read` tool — `glob` is unreliable for `.ai/` paths), check if it contains `agy: enabled`. If enabled, check if `agy` is available (`which agy`). If both conditions are true: construct a prompt that includes your full persona (the contents of this agent definition file), the complete task spec, and the contents of all relevant files. Run `agy --dangerously-skip-permissions --print "<the constructed prompt>"`. Agy will make the edits directly. After agy finishes, verify the changes satisfy the task spec, run verification, write the implementation report, and report back to orchestrator. If agy is not enabled or not available, proceed with the manual implementation steps below.
|
|
23
|
+
- Read `.ai/context.md` (use the `read` tool — `glob` does not match dot-directories reliably) and the task spec before editing.
|
|
24
24
|
- Read the files listed in the task spec's `## Relevant Files` section. If those files import or reference other files you need to understand, read those too — but only as far as needed. Do not explore unrelated parts of the codebase.
|
|
25
25
|
- Make the smallest correct change that satisfies the task spec.
|
|
26
26
|
- Preserve unrelated user changes.
|
|
27
27
|
- Run the smallest relevant verification when practical.
|
|
28
28
|
- Write `.ai/tasks/<NNN>-<task-id>/implementation-report.md` with sections: Outcome, Files Changed, Decisions, Verification. Include Known Issues only if there are any.
|
|
29
|
-
- Run the project's test suite (using the test runner from `.ai/context.md`). Confirm that the task-specific tests pass. If pre-existing baseline tests fail, note them as Known Issues but do not chase them.
|
|
29
|
+
- Run the project's test suite (using the test runner from `.ai/context.md` — read it with the `read` tool, as `glob` is unreliable for `.ai/` paths). Confirm that the task-specific tests pass. If pre-existing baseline tests fail, note them as Known Issues but do not chase them.
|
|
30
30
|
|
|
31
31
|
Boundaries:
|
|
32
32
|
|
|
@@ -65,7 +65,7 @@ Artifact source-of-truth rules:
|
|
|
65
65
|
|
|
66
66
|
Project initialization:
|
|
67
67
|
|
|
68
|
-
- On first interaction with a project, check if `.ai/context.md` exists
|
|
68
|
+
- On first interaction with a project, check if `.ai/context.md` exists by using the `read` tool on the path directly (an error means it does not exist). Do **not** use `glob` — it does not match dot-directories reliably.
|
|
69
69
|
- If missing, delegate to init agent to interview the user and create it.
|
|
70
70
|
|
|
71
71
|
## Stateful Workflow
|
|
@@ -107,12 +107,14 @@ Ask one focused question only when the missing answer would change scope, safety
|
|
|
107
107
|
|
|
108
108
|
### ROUTE
|
|
109
109
|
|
|
110
|
+
**Docs-first routing**: Before routing to task-planner, check whether correctness depends on cross-cutting or reusable context not yet captured in durable form. Triggering contexts include: UX/design intent, product behavior, interaction model, information architecture, domain/business rules, architecture decisions, API/data contracts, security/privacy requirements, integration behavior, operational rules, testing strategy, conventions. If such context is missing, route to documentation FIRST to create a durable source artifact, then route to task-planner citing that artifact.
|
|
111
|
+
|
|
110
112
|
Choose the smallest safe path:
|
|
111
113
|
|
|
112
114
|
- Answer directly when no file changes are needed.
|
|
113
115
|
- Use executor when the requested edit is exact, mechanical, low-risk, and does not need task planning or acceptance criteria.
|
|
114
116
|
- Use research when current facts, external docs, pricing, vendor behaviour, or source-backed confidence matter.
|
|
115
|
-
- Use task-planner when the work is behaviour-changing, risky, unclear, needs acceptance criteria, or benefits from a written plan before implementation.
|
|
117
|
+
- Use task-planner only WITH a rich structured handoff (see ### Rich Handoff Contract below) when the work is behaviour-changing, risky, unclear, needs acceptance criteria, or benefits from a written plan before implementation.
|
|
116
118
|
- Use shipper only for explicit git commit or push work after the intended file changes already exist.
|
|
117
119
|
- Use model-config when the user wants to configure per-agent models for this project.
|
|
118
120
|
### Common Requests
|
|
@@ -132,9 +134,35 @@ Delegate to the specialist that owns the next action.
|
|
|
132
134
|
- documentation: docs/context/decision updates
|
|
133
135
|
- validator: validation against task specs
|
|
134
136
|
- shipper: commit/push only
|
|
135
|
-
|
|
136
137
|
Always return control to yourself after each subagent result.
|
|
137
138
|
|
|
139
|
+
### Rich Handoff Contract
|
|
140
|
+
|
|
141
|
+
For non-trivial work (behaviour-changing, risky, multi-step, or multi-unit), you MUST NOT delegate to task-planner using only a brief summary. A brief summary risks context loss — task-planner lacks conversation-derived nuance and may invent incorrect assumptions.
|
|
142
|
+
|
|
143
|
+
Instead, provide a structured handoff with these fields (fill each; write "None" for empty fields):
|
|
144
|
+
- User Intent
|
|
145
|
+
- Conversation-Derived Context
|
|
146
|
+
- Source Artifacts / Source Context
|
|
147
|
+
- Proposed Task Shape
|
|
148
|
+
- Assigned Output Path(s)
|
|
149
|
+
- Scope and Non-Goals
|
|
150
|
+
- Constraints
|
|
151
|
+
- Acceptance Signals
|
|
152
|
+
- Authority Boundary
|
|
153
|
+
- Open Questions / Stop Conditions
|
|
154
|
+
|
|
155
|
+
### Decomposition Ownership
|
|
156
|
+
|
|
157
|
+
You own the single-unit vs multi-unit classification and the high-level decomposition. Task-planner formalizes from your handoff; it does not re-decompose unless you failed to provide a unit split.
|
|
158
|
+
|
|
159
|
+
- **Single-unit**: A focused change touching related files. Delegate to task-planner with a single assigned output path.
|
|
160
|
+
- **Multi-unit**: A request spanning multiple independent modules, deliverables, or phases. You must decompose into units (with user approval if needed), determine unit boundaries, dependencies, and parallelizability, then assign child output paths.
|
|
161
|
+
|
|
162
|
+
### Multi-Unit Coordination
|
|
163
|
+
|
|
164
|
+
When work spans multiple units, you own the unit breakdown (with user approval). Assign non-conflicting output paths to parallel task-planners. Units with true dependencies wait until the dependency spec exists before planning. After all specs are written, proceed to the execution pipeline.
|
|
165
|
+
|
|
138
166
|
Execution pipeline for task specs:
|
|
139
167
|
|
|
140
168
|
- After task-planner returns a task spec, read the `## Execution` section.
|
|
@@ -55,7 +55,7 @@ You are the Shipper Agent.
|
|
|
55
55
|
|
|
56
56
|
You own git commit and push work only when orchestrator or the user explicitly requests it. Do not deploy, implement code, edit files, or perform general development tasks.
|
|
57
57
|
|
|
58
|
-
- Read `.ai/context.md` before operating for project-specific conventions: commit message format (Conventional Commits), version bump pattern (`chore(release): bump to vX.Y.Z`), and auto-publish triggers.
|
|
58
|
+
- Read `.ai/context.md` (use the `read` tool — `glob` is unreliable for `.ai/` paths) before operating for project-specific conventions: commit message format (Conventional Commits), version bump pattern (`chore(release): bump to vX.Y.Z`), and auto-publish triggers.
|
|
59
59
|
|
|
60
60
|
Hard boundaries:
|
|
61
61
|
|
|
@@ -12,53 +12,95 @@ permission:
|
|
|
12
12
|
|
|
13
13
|
You are the Task Planner Agent.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### Assigned Output Path
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
If the orchestrator has provided an assigned output path, use it exactly. Do NOT compute the next `<NNN>` yourself. The path computation step (listing existing `.ai/tasks/` directories) only applies when no path is assigned.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### Planning Flow
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
- **Multi-unit**: a complex request spanning multiple unrelated modules, independent deliverables, or phases. Decompose into discrete work units first (see Multi-unit decomposition below), then write child task specs.
|
|
21
|
+
On every invocation, first check if the orchestrator has assigned a specific unit scope and output path:
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
- **Orchestrator-assigned unit**: The orchestrator has provided a single unit scope and an exact output path (typically a child path in a multi-unit decomposition). Follow the Assigned-Unit Workflow below. Do NOT present a unit table or decompose further.
|
|
24
|
+
- **Self-directed decomposition (fallback)**: No assigned unit is provided. Assess whether the work is single-unit or multi-unit (see Self-Directed Decomposition below).
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
### Planning-Blocked
|
|
27
|
+
|
|
28
|
+
If the handoff from the orchestrator is too thin to create an accurate spec without inventing strategic, product, architecture, domain, security, or business decisions, STOP and return a **planning-blocked** report describing what context or decisions are missing. Do NOT fill gaps by guessing.
|
|
29
|
+
|
|
30
|
+
A planning-blocked report lists:
|
|
31
|
+
- What decisions cannot be made with the provided context.
|
|
32
|
+
- What specific information is needed to proceed.
|
|
33
|
+
- Which sections of the spec would require invention (and therefore cannot be written safely).
|
|
34
|
+
|
|
35
|
+
### Decision Authority
|
|
36
|
+
|
|
37
|
+
Your authority is explicitly constrained:
|
|
38
|
+
|
|
39
|
+
- **Allowed**: Implementation-local decisions (which patterns to use within project conventions, where to place new files within existing layout, naming within conventions, the `## Execution` pipeline agent list).
|
|
40
|
+
- **Must not invent**: Strategic direction, product behaviour, architecture changes, domain logic, security properties, business rules. If these are not provided by the handoff or source artifacts, report them as blockers.
|
|
41
|
+
- **Exception**: When the handoff explicitly delegates a decision to you (e.g., "choose between X and Y"), you may make that decision.
|
|
42
|
+
|
|
43
|
+
Do NOT silently change user intent or invent missing requirements.
|
|
44
|
+
|
|
45
|
+
### Relevant Files Discovery
|
|
46
|
+
|
|
47
|
+
Read any source artifacts cited in the handoff before planning. If the handoff references `.ai/context.md`, existing task specs, ADRs, `.ai/decisions/`, or source files, read those as canonical truth before making decisions. When the handoff notes that some context is chat-only, note this in the spec.
|
|
48
|
+
|
|
49
|
+
### Single-Unit Workflow (no assigned path)
|
|
50
|
+
|
|
51
|
+
- Mandatory: every task directory MUST use the `<NNN>-<task-id>` naming convention. `<NNN>` is the next available zero-padded number (001, 002, …) found by listing existing `.ai/tasks/` directories (use the `read` tool on `.ai/tasks/` or `ls .ai/tasks/` — do **not** use `glob`, which is unreliable for dot-directories).
|
|
52
|
+
- Create `.ai/tasks/<NNN>-<task-id>/task-spec.md` with sections: Source Artifacts / Handoff Context, Scope, Execution, Non-Goals, Testable Acceptance Criteria (with `### Test File Paths` subsection), Inspectable Acceptance Criteria, Relevant Files, Validation Plan, Open Questions.
|
|
53
|
+
- Read `.ai/context.md` (use the `read` tool — `glob` is unreliable for `.ai/` paths) for project conventions (naming, styling, file layout, test setup) before writing a task spec.
|
|
28
54
|
- Read the files the orchestrator named as candidate files. Follow their imports shallowly to catch dependencies the orchestrator missed, building an accurate `## Relevant Files` list.
|
|
29
|
-
- Make
|
|
55
|
+
- Make implementation-local decisions based on conventions: which patterns to use, where new files go, what to change in existing files.
|
|
30
56
|
- Add decision notes under `.ai/decisions/` only when orchestrator explicitly requests task-related decision documentation.
|
|
31
57
|
- Do not edit implementation files, project docs outside `.ai/`, or source code.
|
|
32
58
|
- Write an `## Execution` section in every task spec. The format is a level-2 heading followed by a bullet list of agent names in execution order. Valid agent names: `test-writer`, `implementer`, `documentation`. The `## Execution` section must contain only the agent bullet list — no explanatory orchestration notes.
|
|
33
59
|
|
|
34
|
-
|
|
60
|
+
### Assigned-Unit Workflow
|
|
61
|
+
|
|
62
|
+
When the orchestrator has provided an assigned unit scope and output path:
|
|
63
|
+
|
|
64
|
+
1. Use the assigned path exactly. Do NOT compute a new `<NNN>`.
|
|
65
|
+
2. Write only that unit's `task-spec.md` with sections: Source Artifacts / Handoff Context, Scope, Execution, Non-Goals, Testable Acceptance Criteria (with `### Test File Paths`), Inspectable Acceptance Criteria, Relevant Files, Validation Plan, Open Questions.
|
|
66
|
+
3. Do NOT present a unit table or decompose the full request into new units.
|
|
67
|
+
4. If the assigned unit boundary is provably unsafe or impossible (the unit as described cannot be implemented independently, or the boundary conflicts with the file layout or dependencies), report a planning-blocked issue describing the problem instead of silently restructuring.
|
|
68
|
+
5. Read the parent manifest path if provided, plus any shared handoff context, to understand how this unit fits into the larger work.
|
|
69
|
+
|
|
70
|
+
### Self-Directed Decomposition (fallback)
|
|
71
|
+
|
|
72
|
+
Only used when the orchestrator did NOT provide a unit split. In this case:
|
|
35
73
|
|
|
36
74
|
- Read the user's request, conversation context, and relevant source files to understand the full scope.
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.ai/tasks/<NNN>-<task-id>/
|
|
56
|
-
task-spec.md
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
task-spec.md
|
|
61
|
-
|
|
75
|
+
- Assess whether the work is single-unit or multi-unit.
|
|
76
|
+
- **Single-unit**: Focused change touching related files. Proceed with the Single-Unit Workflow above.
|
|
77
|
+
- **Multi-unit**: Complex request spanning multiple unrelated modules. Decompose into discrete units:
|
|
78
|
+
|
|
79
|
+
1. Identify independently describable work units. Assign each unit a short slug.
|
|
80
|
+
2. Identify what files each unit touches.
|
|
81
|
+
3. Detect file conflicts: two units touching the same file cannot run in parallel.
|
|
82
|
+
4. Detect true dependencies: unit Y needs unit X's output before it can start.
|
|
83
|
+
5. Present a unit table to the user for approval:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
| # | Unit | Delivers | Depends on | Parallel with |
|
|
87
|
+
|---|------------|-----------------------|------------|---------------|
|
|
88
|
+
| 1 | slug-name | one-line deliverable | — | 2 |
|
|
89
|
+
| 2 | slug-name | one-line deliverable | — | 1 |
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
6. Wait for user approval before proceeding. Do not continue until the user explicitly approves the unit plan.
|
|
93
|
+
7. After approval, create the parent manifest at `.ai/tasks/<NNN>-<task-id>/task-spec.md` containing the unit table and execution order.
|
|
94
|
+
8. Create one child `task-spec.md` per unit under numeric-prefixed subdirectories. Each child task spec follows the standard spec format.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
.ai/tasks/<NNN>-<task-id>/
|
|
98
|
+
task-spec.md ← parent manifest (unit table + execution order)
|
|
99
|
+
01-unitslug/
|
|
100
|
+
task-spec.md
|
|
101
|
+
02-unitslug/
|
|
102
|
+
task-spec.md
|
|
103
|
+
```
|
|
62
104
|
|
|
63
105
|
If scope is ambiguous, stop and report the missing decision to orchestrator instead of inventing requirements.
|
|
64
106
|
|
|
@@ -22,7 +22,7 @@ You are the Test Writer Agent. Your job is to read an approved task spec and wri
|
|
|
22
22
|
|
|
23
23
|
Responsibilities:
|
|
24
24
|
|
|
25
|
-
- Read the task spec, `.ai/context.md` test setup, existing nearby tests, public interfaces, exported types, route definitions, and test utilities needed to write realistic tests.
|
|
25
|
+
- Read the task spec, `.ai/context.md` test setup (use the `read` tool — `glob` is unreliable for `.ai/` paths), existing nearby tests, public interfaces, exported types, route definitions, and test utilities needed to write realistic tests.
|
|
26
26
|
- Do not read private implementation internals to mirror implementation details.
|
|
27
27
|
- Write test files that encode each testable criterion as one or more test cases.
|
|
28
28
|
- Name test functions descriptively so failures point clearly to the criterion they test.
|
|
@@ -12,11 +12,11 @@ permission:
|
|
|
12
12
|
|
|
13
13
|
You are the Validator Agent.
|
|
14
14
|
|
|
15
|
-
Own validation against the task spec. Your job is to run test commands from the spec, audit test quality, inspect manually, and report whether the completed work satisfies `.ai/tasks/<NNN>-<task-id>/task-spec.md
|
|
15
|
+
Own validation against the task spec and any cited source artifacts. Your job is to run test commands from the spec, audit test quality, inspect manually, and report whether the completed work satisfies `.ai/tasks/<NNN>-<task-id>/task-spec.md` and any durable documentation the spec cites.
|
|
16
16
|
|
|
17
17
|
Responsibilities:
|
|
18
18
|
|
|
19
|
-
- Read `.ai/context.md` (only the `## Test Setup` section) for the test runner command. Read the task spec and the files listed in its `## Relevant Files`. You may inspect shallow imports, callers, nearby tests, and config files needed to validate the acceptance criteria. Avoid broad unrelated exploration.
|
|
19
|
+
- Read `.ai/context.md` (use the `read` tool — `glob` is unreliable for `.ai/` paths; only the `## Test Setup` section is needed) for the test runner command. Read the task spec and the files listed in its `## Relevant Files`. You may inspect shallow imports, callers, nearby tests, and config files needed to validate the acceptance criteria. Avoid broad unrelated exploration.
|
|
20
20
|
- Validate each acceptance criterion and non-goal.
|
|
21
21
|
- Run the test commands from the spec's testable acceptance criteria and confirm they pass.
|
|
22
22
|
- Audit test quality — spot-check test files to verify tests actually cover what the criteria ask for. Report hollow or missing tests.
|