agentxchain 0.8.7 → 2.1.1

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.
Files changed (94) hide show
  1. package/README.md +123 -154
  2. package/bin/agentxchain.js +240 -8
  3. package/dashboard/app.js +305 -0
  4. package/dashboard/components/blocked.js +145 -0
  5. package/dashboard/components/cross-repo.js +126 -0
  6. package/dashboard/components/gate.js +311 -0
  7. package/dashboard/components/hooks.js +177 -0
  8. package/dashboard/components/initiative.js +147 -0
  9. package/dashboard/components/ledger.js +165 -0
  10. package/dashboard/components/timeline.js +222 -0
  11. package/dashboard/index.html +352 -0
  12. package/package.json +16 -7
  13. package/scripts/agentxchain-autonudge.applescript +32 -5
  14. package/scripts/live-api-proxy-preflight-smoke.sh +531 -0
  15. package/scripts/publish-from-tag.sh +88 -0
  16. package/scripts/release-postflight.sh +231 -0
  17. package/scripts/release-preflight.sh +167 -0
  18. package/scripts/run-autonudge.sh +1 -1
  19. package/src/adapters/claude-code.js +7 -14
  20. package/src/adapters/cursor-local.js +17 -16
  21. package/src/commands/accept-turn.js +160 -0
  22. package/src/commands/approve-completion.js +80 -0
  23. package/src/commands/approve-transition.js +85 -0
  24. package/src/commands/branch.js +2 -2
  25. package/src/commands/claim.js +84 -9
  26. package/src/commands/config.js +16 -0
  27. package/src/commands/dashboard.js +70 -0
  28. package/src/commands/doctor.js +9 -1
  29. package/src/commands/init.js +540 -5
  30. package/src/commands/migrate.js +348 -0
  31. package/src/commands/multi.js +549 -0
  32. package/src/commands/plugin.js +157 -0
  33. package/src/commands/reject-turn.js +204 -0
  34. package/src/commands/resume.js +389 -0
  35. package/src/commands/status.js +196 -3
  36. package/src/commands/step.js +947 -0
  37. package/src/commands/stop.js +65 -33
  38. package/src/commands/template-list.js +33 -0
  39. package/src/commands/template-set.js +279 -0
  40. package/src/commands/update.js +24 -3
  41. package/src/commands/validate.js +20 -11
  42. package/src/commands/verify.js +71 -0
  43. package/src/commands/watch.js +112 -25
  44. package/src/lib/adapters/api-proxy-adapter.js +1076 -0
  45. package/src/lib/adapters/local-cli-adapter.js +337 -0
  46. package/src/lib/adapters/manual-adapter.js +169 -0
  47. package/src/lib/blocked-state.js +94 -0
  48. package/src/lib/config.js +143 -12
  49. package/src/lib/context-compressor.js +121 -0
  50. package/src/lib/context-section-parser.js +220 -0
  51. package/src/lib/coordinator-acceptance.js +428 -0
  52. package/src/lib/coordinator-config.js +461 -0
  53. package/src/lib/coordinator-dispatch.js +276 -0
  54. package/src/lib/coordinator-gates.js +487 -0
  55. package/src/lib/coordinator-hooks.js +239 -0
  56. package/src/lib/coordinator-recovery.js +523 -0
  57. package/src/lib/coordinator-state.js +365 -0
  58. package/src/lib/cross-repo-context.js +247 -0
  59. package/src/lib/dashboard/bridge-server.js +284 -0
  60. package/src/lib/dashboard/file-watcher.js +93 -0
  61. package/src/lib/dashboard/state-reader.js +96 -0
  62. package/src/lib/dispatch-bundle.js +568 -0
  63. package/src/lib/dispatch-manifest.js +252 -0
  64. package/src/lib/filter-agents.js +12 -0
  65. package/src/lib/gate-evaluator.js +285 -0
  66. package/src/lib/generate-vscode.js +158 -68
  67. package/src/lib/governed-state.js +2139 -0
  68. package/src/lib/governed-templates.js +145 -0
  69. package/src/lib/hook-runner.js +788 -0
  70. package/src/lib/next-owner.js +61 -6
  71. package/src/lib/normalized-config.js +539 -0
  72. package/src/lib/notify.js +14 -12
  73. package/src/lib/plugin-config-schema.js +192 -0
  74. package/src/lib/plugins.js +692 -0
  75. package/src/lib/prompt-core.js +108 -0
  76. package/src/lib/protocol-conformance.js +291 -0
  77. package/src/lib/reference-conformance-adapter.js +717 -0
  78. package/src/lib/repo-observer.js +597 -0
  79. package/src/lib/repo.js +0 -31
  80. package/src/lib/safe-write.js +44 -0
  81. package/src/lib/schema.js +189 -0
  82. package/src/lib/schemas/turn-result.schema.json +205 -0
  83. package/src/lib/seed-prompt-polling.js +15 -73
  84. package/src/lib/seed-prompt.js +17 -63
  85. package/src/lib/token-budget.js +206 -0
  86. package/src/lib/token-counter.js +27 -0
  87. package/src/lib/turn-paths.js +67 -0
  88. package/src/lib/turn-result-validator.js +496 -0
  89. package/src/lib/validation.js +167 -19
  90. package/src/lib/verify-command.js +72 -0
  91. package/src/templates/governed/api-service.json +31 -0
  92. package/src/templates/governed/cli-tool.json +30 -0
  93. package/src/templates/governed/generic.json +10 -0
  94. package/src/templates/governed/web-app.json +30 -0
package/README.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # agentxchain
2
2
 
3
- CLI for multi-agent coordination in your IDE. Define a team of AI agents, let them take turns building your project — each in its own IDE window.
3
+ CLI for governed multi-agent software delivery.
4
+
5
+ The canonical mode is governed delivery: orchestrator-owned state, structured turn results, phase gates, mandatory challenge, and explicit human approvals where required.
6
+
7
+ Legacy IDE-window coordination is still shipped as a compatibility mode for teams that want lock-based handoff in Cursor, VS Code, or Claude Code.
8
+
9
+ ## Docs
10
+
11
+ - [Quickstart](https://agentxchain.dev/docs/quickstart.html)
12
+ - [CLI reference](https://agentxchain.dev/docs/cli.html)
13
+ - [Adapter reference](https://agentxchain.dev/docs/adapters.html)
14
+ - [Protocol spec (v6)](https://agentxchain.dev/docs/protocol.html)
15
+ - [Why governed multi-agent delivery matters](https://agentxchain.dev/why.html)
4
16
 
5
17
  ## Install
6
18
 
@@ -11,207 +23,164 @@ npm install -g agentxchain
11
23
  Or run without installing:
12
24
 
13
25
  ```bash
14
- npx agentxchain init
26
+ npx agentxchain init --governed -y
15
27
  ```
16
28
 
17
- ## Quick start
29
+ ## Quick Start
18
30
 
19
- ### Happy path: net-new project
31
+ ### Governed workflow
20
32
 
21
33
  ```bash
22
- agentxchain init
23
- cd my-project
24
- agentxchain kickoff
34
+ npx agentxchain init --governed -y
35
+ cd my-agentxchain-project
36
+ git init
37
+ git add -A
38
+ git commit -m "initial governed scaffold"
39
+ agentxchain status
40
+ agentxchain step --role pm
25
41
  ```
26
42
 
27
- ### Happy path: existing project
28
-
29
- Run these commands from inside your existing project folder:
43
+ If you want template-specific planning artifacts from day one:
30
44
 
31
45
  ```bash
32
- agentxchain doctor
33
- agentxchain generate
34
- agentxchain kickoff
46
+ npx agentxchain init --governed --template api-service -y
35
47
  ```
36
48
 
37
- Each agent runs in its own Cursor window for a single turn at a time. The referee loop (`watch` / `supervise --autonudge`) determines the next agent and wakes that specific session.
49
+ Built-in governed templates:
38
50
 
39
- Agents are now required to maintain `TALK.md` as the human-readable handoff log each turn.
51
+ - `generic`: baseline governed scaffold
52
+ - `api-service`: API contract, operational readiness, error budget
53
+ - `cli-tool`: command surface, platform support, distribution checklist
54
+ - `web-app`: user flows, UI acceptance, browser support
40
55
 
41
- ## Commands
42
-
43
- | Command | What it does |
44
- |---------|-------------|
45
- | `init` | Create project folder with agents, protocol files, and templates |
46
- | `kickoff` | Guided PM-first flow: PM kickoff, validate, launch remaining, release |
47
- | `start` | Open a Cursor window per agent + copy prompts to clipboard |
48
- | `supervise` | Run watcher and optional AppleScript auto-nudge together |
49
- | `generate` | Regenerate agent files from `agentxchain.json` |
50
- | `validate` | Enforce PM signoff + waves/phases + turn artifact schema |
51
- | `status` | Show lock holder, phase, turn number, agents |
52
- | `doctor` | Validate local setup (tools, trigger flow, accessibility checks) |
53
- | `claim` | Human takes control (agents stop claiming) |
54
- | `release` | Hand lock back to agents |
55
- | `stop` | Terminate running Claude Code agent sessions |
56
- | `watch` | Optional: TTL safety net + status logging |
57
- | `config` | View/edit config, add/remove agents, change rules |
58
- | `rebind` | Rebuild Cursor workspace/prompt bindings for agents |
59
- | `update` | Self-update CLI from npm |
60
-
61
- ### Full command list
56
+ `step` writes a turn-scoped bundle under `.agentxchain/dispatch/turns/<turn_id>/` and expects a staged result at `.agentxchain/staging/<turn_id>/turn-result.json`. Typical continuation:
62
57
 
63
58
  ```bash
64
- agentxchain init
65
- agentxchain status
66
- agentxchain start
67
- agentxchain kickoff
68
- agentxchain stop
69
- agentxchain config
70
- agentxchain rebind
71
- agentxchain generate
72
- agentxchain watch
73
- agentxchain supervise
74
- agentxchain claim
75
- agentxchain release
76
- agentxchain update
77
- agentxchain doctor
78
- agentxchain validate
59
+ agentxchain validate --mode turn
60
+ agentxchain accept-turn
61
+ agentxchain approve-transition
62
+ agentxchain step --role dev
63
+ agentxchain step --role qa
64
+ agentxchain approve-completion
79
65
  ```
80
66
 
81
- ### IDE options
67
+ Default governed scaffolding configures QA as `api_proxy` with `ANTHROPIC_API_KEY`. For a provider-free walkthrough, switch the QA runtime to `manual` before the QA step.
82
68
 
83
- ```bash
84
- agentxchain start # Cursor (default) — one window per agent
85
- agentxchain start --ide vscode # VS Code — uses .agent.md custom agents + hooks
86
- agentxchain start --ide claude-code # Claude Code — spawns CLI processes
87
- ```
88
-
89
- ### Additional flags
69
+ ### Migrate a legacy project
90
70
 
91
71
  ```bash
92
- agentxchain kickoff # guided first-run PM-first workflow
93
- agentxchain kickoff --ide vscode # guided flow for VS Code mode
94
- agentxchain kickoff --send # with Cursor auto-nudge auto-send enabled
95
- agentxchain kickoff --interval 2 # nudge poll interval override
96
- agentxchain kickoff --no-autonudge # skip auto-nudge prompt
97
-
98
- agentxchain start --agent pm # launch only one specific agent
99
- agentxchain start --remaining # launch all agents except PM (PM-first flow)
100
- agentxchain start --dry-run # preview agents without launching
101
- agentxchain validate --mode kickoff # required before --remaining
102
- agentxchain validate --mode turn --agent pm
103
- agentxchain validate --json # machine-readable validation output
104
- agentxchain watch --daemon # run watch in background
105
- agentxchain supervise --autonudge # run watch + AppleScript nudge loop
106
- agentxchain supervise --autonudge --send # auto-press Enter after paste
107
- agentxchain supervise --interval 2 # set auto-nudge poll interval
108
- agentxchain rebind # regenerate agent prompt/workspace bindings
109
- agentxchain rebind --open # regenerate and reopen all Cursor agent windows
110
- agentxchain rebind --agent pm # regenerate one agent binding only
111
- agentxchain claim --agent pm # guarded claim as agent turn owner
112
- agentxchain release --agent pm # guarded release as agent turn owner
113
- agentxchain release --force # force-release non-human holder lock
72
+ agentxchain migrate
73
+ agentxchain status
74
+ agentxchain step
114
75
  ```
115
76
 
116
- ## macOS auto-nudge (AppleScript)
77
+ ## Command Sets
117
78
 
118
- If you want the next agent chat to be nudged automatically when turn changes, use the built-in AppleScript helper.
79
+ ### Governed
119
80
 
120
- 1) Keep watcher running in your project:
81
+ | Command | What it does |
82
+ |---|---|
83
+ | `init --governed [--template <id>]` | Create a governed project, optionally with project-shape-specific planning artifacts |
84
+ | `migrate` | Convert a legacy v3 project to governed format |
85
+ | `status` | Show current run, template, phase, turn, and approval state |
86
+ | `resume` | Initialize or continue a governed run and assign the next turn |
87
+ | `step` | Run one governed turn end to end or resume an active turn |
88
+ | `accept-turn` | Accept the staged governed turn result |
89
+ | `reject-turn` | Reject the staged result, retry, or reassign |
90
+ | `approve-transition` | Approve a pending human-gated phase transition |
91
+ | `approve-completion` | Approve a pending human-gated run completion |
92
+ | `validate` | Validate governed kickoff wiring, a staged turn, or both |
93
+ | `dashboard` | Open the read-only governance dashboard in your browser for repo-local runs or multi-repo coordinator initiatives |
94
+ | `plugin install|list|remove` | Install, inspect, or remove governed hook plugins backed by `agentxchain-plugin.json` manifests |
95
+
96
+ ### Shared utilities
121
97
 
122
- ```bash
123
- agentxchain watch
124
- # or use the combined command:
125
- agentxchain supervise --autonudge
126
- ```
98
+ | Command | What it does |
99
+ |---|---|
100
+ | `config` | View or edit project configuration |
101
+ | `update` | Update the CLI from npm |
127
102
 
128
- 2) In another terminal (from `cli/`), start auto-nudge:
103
+ ### Legacy v3 compatibility
129
104
 
130
- ```bash
131
- bash scripts/run-autonudge.sh --project "/absolute/path/to/your-project"
105
+ | Command | What it does |
106
+ |---|---|
107
+ | `init` | Create a legacy project folder |
108
+ | `start` | Launch legacy agents in IDE sessions |
109
+ | `kickoff` | Guided PM-first legacy setup flow |
110
+ | `watch` | Referee loop for legacy lock-based handoff |
111
+ | `supervise` | Run `watch` plus optional macOS auto-nudge |
112
+ | `claim` / `release` | Human override of legacy lock ownership |
113
+ | `rebind` | Rebuild Cursor bindings |
114
+ | `generate` | Regenerate VS Code agent files |
115
+ | `branch` | Manage Cursor branch override for launches |
116
+ | `doctor` | Check local environment and setup |
117
+ | `stop` | Stop watch daemon and local sessions |
118
+
119
+ ## Governed Flow
120
+
121
+ 1. `agentxchain step` initializes or resumes the run if needed.
122
+ 2. It assigns the next role for the current phase.
123
+ 3. It writes `.agentxchain/dispatch/turns/<turn_id>/`.
124
+ 4. The assigned role writes `.agentxchain/staging/<turn_id>/turn-result.json`.
125
+ 5. The orchestrator validates and either accepts, rejects, advances phase, pauses for approval, or completes the run.
126
+
127
+ Important governed files:
128
+
129
+ ```text
130
+ agentxchain.json
131
+ .agentxchain/state.json
132
+ .agentxchain/history.jsonl
133
+ .agentxchain/decision-ledger.jsonl
134
+ .agentxchain/dispatch/turns/<turn_id>/
135
+ .agentxchain/staging/<turn_id>/turn-result.json
136
+ TALK.md
137
+ .planning/
132
138
  ```
133
139
 
134
- By default this is **paste-only** (safe mode): it opens chat and pastes the nudge message, but does not press Enter.
140
+ ### Runtime support today
135
141
 
136
- 3) Enable auto-send once confirmed:
142
+ - `manual`: implemented
143
+ - `local_cli`: implemented
144
+ - `api_proxy`: implemented for synchronous review-only turns and stages a provider-backed result during `step`
137
145
 
138
- ```bash
139
- bash scripts/run-autonudge.sh --project "/absolute/path/to/your-project" --send
140
- ```
146
+ ## Legacy IDE Mode
141
147
 
142
- Stop it anytime:
148
+ Legacy mode is still useful if you specifically want one IDE session per agent and lock-file coordination.
143
149
 
144
150
  ```bash
145
- bash scripts/stop-autonudge.sh
151
+ agentxchain start # Cursor (default)
152
+ agentxchain start --ide vscode
153
+ agentxchain start --ide claude-code
154
+ agentxchain kickoff
155
+ agentxchain supervise --autonudge
146
156
  ```
147
157
 
148
- Notes:
149
- - Requires macOS (`osascript`) and `jq` (`brew install jq`)
150
- - Grant Accessibility permissions to Terminal and Cursor
151
- - The script watches `.agentxchain-trigger.json`, which is written by `agentxchain watch`
152
- - `run-autonudge.sh` now requires watch to be running first
153
- - The script only nudges when it finds a unique matching agent window (no random fallback)
154
-
155
- ## How it works
156
-
157
- ### Cursor mode (default)
158
-
159
- 1. `agentxchain kickoff` launches PM first for human-product alignment
160
- 2. Each window gets a unique prompt copied to clipboard
161
- 3. Kickoff validates PM signoff and launches remaining agents
162
- 4. Agent prompts are single-turn: claim → work → validate → release → stop
163
- 5. Agents use the latest `Next owner:` in `TALK.md` to pick who goes next (fallback: config order)
164
- 6. Human can `claim` to pause and `release` to resume anytime
165
-
166
- ### VS Code mode
158
+ In this mode, agents hand off through `lock.json`, `state.json`, triggers, and `TALK.md`. For new projects, prefer governed mode unless IDE-window choreography is the goal.
167
159
 
168
- 1. `agentxchain init` generates `.github/agents/*.agent.md` (VS Code custom agents) and `.github/hooks/` (lifecycle hooks)
169
- 2. VS Code auto-discovers agents in the Chat dropdown
170
- 3. The `Stop` hook acts as referee — hands off to next agent automatically
160
+ ## macOS Auto-Nudge
171
161
 
172
- ### Turn ownership
173
-
174
- Agent turns are handoff-driven:
175
- - Each turn appends a `Next owner:` in `TALK.md` with a valid agent id
176
- - `watch`/`supervise` dispatches the next trigger from that handoff
177
- - `claim --agent <id>` enforces that expected owner (with guarded fallback)
178
-
179
- ## Key features
180
-
181
- - **One window per agent** — each agent has its own Cursor window and chat session
182
- - **Referee-driven coordination** — `watch`/`supervise` wakes the next correct agent each turn
183
- - **Works in Cursor, VS Code, Claude Code** — adapters for each IDE
184
- - **User-defined teams** — any number of agents, any roles
185
- - **No API keys or cloud required** — everything runs locally
186
- - **Human-in-the-loop** — claim/release to intervene anytime
187
- - **Team templates** — SaaS MVP, Landing Page, Bug Squad, API Builder, Refactor Team
188
- - **Lock TTL** — `watch` can force-release stale locks as a safety net
189
-
190
- ## VS Code extension (optional)
191
-
192
- For a richer UI in VS Code:
162
+ `supervise --autonudge` is legacy-only and macOS-only.
193
163
 
194
164
  ```bash
195
- code --install-extension cli/vscode-extension/agentxchain-0.1.0.vsix
165
+ agentxchain supervise --autonudge
166
+ agentxchain supervise --autonudge --send
196
167
  ```
197
168
 
198
- Adds: status bar (lock holder, turn, phase), sidebar dashboard, command palette integration.
199
-
200
- ## Publish updates (maintainers)
201
-
202
- ```bash
203
- cd cli
204
- bash scripts/publish-npm.sh # patch bump + publish
205
- bash scripts/publish-npm.sh minor # minor bump + publish
206
- ```
169
+ Requires:
207
170
 
208
- If `NPM_TOKEN` exists in `agentXchain.dev/.env` (project root), the script uses it automatically.
171
+ - `osascript`
172
+ - `jq`
173
+ - Accessibility permissions for Terminal and Cursor
209
174
 
210
175
  ## Links
211
176
 
212
177
  - [agentxchain.dev](https://agentxchain.dev)
178
+ - [Quickstart](https://agentxchain.dev/docs/quickstart.html)
179
+ - [CLI reference](https://agentxchain.dev/docs/cli.html)
180
+ - [Adapter reference](https://agentxchain.dev/docs/adapters.html)
181
+ - [Protocol spec (v6)](https://agentxchain.dev/docs/protocol.html)
213
182
  - [GitHub](https://github.com/shivamtiwari93/agentXchain.dev)
214
- - [Protocol v3 spec](https://github.com/shivamtiwari93/agentXchain.dev/blob/main/PROTOCOL-v3.md)
183
+ - [Legacy Protocol v3 spec](https://github.com/shivamtiwari93/agentXchain.dev/blob/main/PROTOCOL-v3.md)
215
184
 
216
185
  ## License
217
186
 
@@ -1,9 +1,52 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { readFileSync } from 'fs';
4
- import { join, dirname } from 'path';
3
+ import { readFileSync, existsSync } from 'fs';
4
+ import { join, dirname, parse as pathParse, resolve } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { Command } from 'commander';
7
+
8
+ // Load .env from AgentXchain project root when available, then cwd as fallback.
9
+ (function loadDotenv() {
10
+ const cwd = process.cwd();
11
+ const projectRoot = findNearestProjectRoot(cwd);
12
+ const envPaths = [];
13
+
14
+ if (projectRoot) {
15
+ envPaths.push(join(projectRoot, '.env'));
16
+ }
17
+ if (!projectRoot || projectRoot !== cwd) {
18
+ envPaths.push(join(cwd, '.env'));
19
+ }
20
+
21
+ for (const envPath of envPaths) {
22
+ if (!existsSync(envPath)) continue;
23
+ try {
24
+ const content = readFileSync(envPath, 'utf8');
25
+ for (const line of content.split(/\r?\n/)) {
26
+ const trimmed = line.trim();
27
+ if (!trimmed || trimmed.startsWith('#')) continue;
28
+ const eqIdx = trimmed.indexOf('=');
29
+ if (eqIdx === -1) continue;
30
+ const key = trimmed.slice(0, eqIdx).trim();
31
+ let val = trimmed.slice(eqIdx + 1).trim();
32
+ if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
33
+ val = val.slice(1, -1);
34
+ }
35
+ if (!process.env[key]) process.env[key] = val;
36
+ }
37
+ } catch {}
38
+ }
39
+ })();
40
+
41
+ function findNearestProjectRoot(startDir) {
42
+ let dir = resolve(startDir);
43
+ const { root: fsRoot } = pathParse(dir);
44
+ while (true) {
45
+ if (existsSync(join(dir, 'agentxchain.json'))) return dir;
46
+ if (dir === fsRoot) return null;
47
+ dir = join(dir, '..');
48
+ }
49
+ }
7
50
  import { initCommand } from '../src/commands/init.js';
8
51
  import { statusCommand } from '../src/commands/status.js';
9
52
  import { startCommand } from '../src/commands/start.js';
@@ -16,8 +59,33 @@ import { generateCommand } from '../src/commands/generate.js';
16
59
  import { doctorCommand } from '../src/commands/doctor.js';
17
60
  import { superviseCommand } from '../src/commands/supervise.js';
18
61
  import { validateCommand } from '../src/commands/validate.js';
62
+ import { verifyProtocolCommand } from '../src/commands/verify.js';
19
63
  import { kickoffCommand } from '../src/commands/kickoff.js';
20
64
  import { rebindCommand } from '../src/commands/rebind.js';
65
+ import { branchCommand } from '../src/commands/branch.js';
66
+ import { migrateCommand } from '../src/commands/migrate.js';
67
+ import { resumeCommand } from '../src/commands/resume.js';
68
+ import { acceptTurnCommand } from '../src/commands/accept-turn.js';
69
+ import { rejectTurnCommand } from '../src/commands/reject-turn.js';
70
+ import { stepCommand } from '../src/commands/step.js';
71
+ import { approveTransitionCommand } from '../src/commands/approve-transition.js';
72
+ import { approveCompletionCommand } from '../src/commands/approve-completion.js';
73
+ import { dashboardCommand } from '../src/commands/dashboard.js';
74
+ import {
75
+ pluginInstallCommand,
76
+ pluginListCommand,
77
+ pluginRemoveCommand,
78
+ pluginUpgradeCommand,
79
+ } from '../src/commands/plugin.js';
80
+ import { templateSetCommand } from '../src/commands/template-set.js';
81
+ import { templateListCommand } from '../src/commands/template-list.js';
82
+ import {
83
+ multiInitCommand,
84
+ multiStatusCommand,
85
+ multiStepCommand,
86
+ multiApproveGateCommand,
87
+ multiResyncCommand,
88
+ } from '../src/commands/multi.js';
21
89
 
22
90
  const __dirname = dirname(fileURLToPath(import.meta.url));
23
91
  const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
@@ -26,24 +94,27 @@ const program = new Command();
26
94
 
27
95
  program
28
96
  .name('agentxchain')
29
- .description('Multi-agent coordination in your IDE')
97
+ .description('Governed multi-agent software delivery orchestration')
30
98
  .version(pkg.version);
31
99
 
32
100
  program
33
101
  .command('init')
34
102
  .description('Create a new AgentXchain project folder')
35
103
  .option('-y, --yes', 'Skip prompts, use defaults')
104
+ .option('--governed', 'Create a governed project (orchestrator-owned state)')
105
+ .option('--template <id>', 'Governed scaffold template: generic, api-service, cli-tool, web-app')
106
+ .option('--schema-version <version>', 'Schema version (3 for legacy, or use --governed for current)')
36
107
  .action(initCommand);
37
108
 
38
109
  program
39
110
  .command('status')
40
- .description('Show lock status, phase, and agents')
111
+ .description('Show current run or lock status')
41
112
  .option('-j, --json', 'Output as JSON')
42
113
  .action(statusCommand);
43
114
 
44
115
  program
45
116
  .command('start')
46
- .description('Launch agents in your IDE')
117
+ .description('Launch legacy v3 agents in your IDE')
47
118
  .option('--ide <ide>', 'Target IDE: cursor, vscode, claude-code', 'cursor')
48
119
  .option('--agent <id>', 'Launch a specific agent only')
49
120
  .option('--remaining', 'Launch all remaining agents except PM (for PM-first flow)')
@@ -52,7 +123,7 @@ program
52
123
 
53
124
  program
54
125
  .command('kickoff')
55
- .description('Guided PM-first first-run workflow')
126
+ .description('Guided legacy PM-first first-run workflow')
56
127
  .option('--ide <ide>', 'Target IDE: cursor, vscode, claude-code', 'cursor')
57
128
  .option('--send', 'When using Cursor auto-nudge, auto-send nudges')
58
129
  .option('--interval <seconds>', 'Auto-nudge poll interval in seconds', '3')
@@ -61,7 +132,7 @@ program
61
132
 
62
133
  program
63
134
  .command('stop')
64
- .description('Stop all running agent sessions')
135
+ .description('Stop watch daemon and Claude Code sessions; close Cursor/VS Code chats manually')
65
136
  .action(stopCommand);
66
137
 
67
138
  program
@@ -73,6 +144,13 @@ program
73
144
  .option('-j, --json', 'Output config as JSON')
74
145
  .action(configCommand);
75
146
 
147
+ program
148
+ .command('branch [name]')
149
+ .description('Show or set the Cursor branch used for launches')
150
+ .option('--use-current', 'Set override to the current local git branch')
151
+ .option('--unset', 'Remove override and follow the active git branch automatically')
152
+ .action(branchCommand);
153
+
76
154
  program
77
155
  .command('generate')
78
156
  .description('Regenerate VS Code agent files (.agent.md, hooks) from agentxchain.json')
@@ -125,10 +203,164 @@ program
125
203
 
126
204
  program
127
205
  .command('validate')
128
- .description('Validate Get Shit Done docs and QA protocol artifacts')
206
+ .description('Validate project protocol artifacts')
129
207
  .option('--mode <mode>', 'Validation mode: kickoff, turn, full', 'full')
130
208
  .option('--agent <id>', 'Expected agent for last history entry (turn mode)')
131
209
  .option('-j, --json', 'Output as JSON')
132
210
  .action(validateCommand);
133
211
 
212
+ const verifyCmd = program
213
+ .command('verify')
214
+ .description('Verify protocol conformance targets');
215
+
216
+ verifyCmd
217
+ .command('protocol')
218
+ .description('Run the protocol conformance fixture suite against a target implementation')
219
+ .option('--tier <tier>', 'Conformance tier to verify (1, 2, or 3)', '1')
220
+ .option('--surface <surface>', 'Restrict verification to a single surface')
221
+ .option('--target <path>', 'Target root containing .agentxchain-conformance/capabilities.json', '.')
222
+ .option('--format <format>', 'Output format: text or json', 'text')
223
+ .action(verifyProtocolCommand);
224
+
225
+ program
226
+ .command('migrate')
227
+ .description('Migrate a legacy v3 project to governed format')
228
+ .option('-y, --yes', 'Skip confirmation prompts')
229
+ .option('-j, --json', 'Output migration report as JSON')
230
+ .action(migrateCommand);
231
+
232
+ program
233
+ .command('resume')
234
+ .description('Resume a governed project: initialize or continue a run and assign the next turn')
235
+ .option('--role <role>', 'Override the target role (default: phase entry role)')
236
+ .option('--turn <id>', 'Target a specific retained turn when multiple exist')
237
+ .action(resumeCommand);
238
+
239
+ program
240
+ .command('accept-turn')
241
+ .description('Accept the currently staged governed turn result')
242
+ .option('--turn <id>', 'Target a specific active turn when multiple turns exist')
243
+ .option('--resolution <mode>', 'Conflict resolution mode for conflicted turns (standard, human_merge)', 'standard')
244
+ .action(acceptTurnCommand);
245
+
246
+ program
247
+ .command('reject-turn')
248
+ .description('Reject the current governed turn result and retry or escalate')
249
+ .option('--turn <id>', 'Target a specific active turn when multiple turns exist')
250
+ .option('--reason <reason>', 'Operator reason for the rejection')
251
+ .option('--reassign', 'Immediately re-dispatch a conflicted turn with conflict context')
252
+ .action(rejectTurnCommand);
253
+
254
+ program
255
+ .command('step')
256
+ .description('Run a single governed turn: assign, dispatch, wait, validate, accept/reject')
257
+ .option('--role <role>', 'Override the target role (default: phase entry role)')
258
+ .option('--resume', 'Resume waiting for an already-active turn')
259
+ .option('--turn <id>', 'Target a specific active turn (required with --resume when multiple turns exist)')
260
+ .option('--poll <seconds>', 'Polling interval for manual adapter in seconds', '2')
261
+ .option('--verbose', 'Stream local_cli subprocess output while the turn is running')
262
+ .option('--auto-reject', 'Auto-reject and retry on validation failure')
263
+ .action(stepCommand);
264
+
265
+ program
266
+ .command('approve-transition')
267
+ .description('Approve a pending phase transition that requires human sign-off')
268
+ .action(approveTransitionCommand);
269
+
270
+ program
271
+ .command('approve-completion')
272
+ .description('Approve a pending run completion that requires human sign-off')
273
+ .action(approveCompletionCommand);
274
+
275
+ program
276
+ .command('dashboard')
277
+ .description('Open the read-only governance dashboard in your browser')
278
+ .option('--port <port>', 'Server port', '3847')
279
+ .option('--no-open', 'Do not auto-open the browser')
280
+ .action(dashboardCommand);
281
+
282
+ const pluginCmd = program
283
+ .command('plugin')
284
+ .description('Manage governed project plugins');
285
+
286
+ pluginCmd
287
+ .command('install <source>')
288
+ .description('Install a plugin from a local path, archive, or npm package spec')
289
+ .option('--config <json>', 'Inline JSON plugin config validated against config_schema')
290
+ .option('--config-file <path>', 'Read plugin config JSON from a file')
291
+ .option('-j, --json', 'Output as JSON')
292
+ .action(pluginInstallCommand);
293
+
294
+ pluginCmd
295
+ .command('list')
296
+ .description('List installed plugins')
297
+ .option('-j, --json', 'Output as JSON')
298
+ .action(pluginListCommand);
299
+
300
+ pluginCmd
301
+ .command('remove <name>')
302
+ .description('Remove an installed plugin')
303
+ .option('-j, --json', 'Output as JSON')
304
+ .action(pluginRemoveCommand);
305
+
306
+ pluginCmd
307
+ .command('upgrade <name> [source]')
308
+ .description('Upgrade an installed plugin atomically, rolling back on failure')
309
+ .option('--config <json>', 'Inline JSON plugin config validated against config_schema')
310
+ .option('--config-file <path>', 'Read plugin config JSON from a file')
311
+ .option('-j, --json', 'Output as JSON')
312
+ .action(pluginUpgradeCommand);
313
+
314
+ const templateCmd = program
315
+ .command('template')
316
+ .description('Manage governed project templates');
317
+
318
+ templateCmd
319
+ .command('set <id>')
320
+ .description('Set or change the governed template for this project')
321
+ .option('-y, --yes', 'Skip confirmation prompt')
322
+ .option('--dry-run', 'Print what would change without writing anything')
323
+ .action(templateSetCommand);
324
+
325
+ templateCmd
326
+ .command('list')
327
+ .description('List available governed templates')
328
+ .option('-j, --json', 'Output as JSON')
329
+ .action(templateListCommand);
330
+
331
+ const multiCmd = program
332
+ .command('multi')
333
+ .description('Multi-repo coordinator orchestration');
334
+
335
+ multiCmd
336
+ .command('init')
337
+ .description('Bootstrap a multi-repo coordinator run')
338
+ .option('-j, --json', 'Output as JSON')
339
+ .action(multiInitCommand);
340
+
341
+ multiCmd
342
+ .command('status')
343
+ .description('Show coordinator status and repo-run snapshots')
344
+ .option('-j, --json', 'Output as JSON')
345
+ .action(multiStatusCommand);
346
+
347
+ multiCmd
348
+ .command('step')
349
+ .description('Select the next workstream and dispatch a coordinator turn')
350
+ .option('-j, --json', 'Output as JSON')
351
+ .action(multiStepCommand);
352
+
353
+ multiCmd
354
+ .command('approve-gate')
355
+ .description('Approve a pending phase transition or completion gate')
356
+ .option('-j, --json', 'Output as JSON')
357
+ .action(multiApproveGateCommand);
358
+
359
+ multiCmd
360
+ .command('resync')
361
+ .description('Detect divergence and rebuild coordinator state from repo authority')
362
+ .option('-j, --json', 'Output as JSON')
363
+ .option('--dry-run', 'Detect divergence without resyncing')
364
+ .action(multiResyncCommand);
365
+
134
366
  program.parse();