@yeison.restrepo.r/code-conductor 1.38.0 → 1.39.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/README.md
CHANGED
|
@@ -126,8 +126,9 @@ Four checks live in `tools/` as tracked repository infrastructure. Three of them
|
|
|
126
126
|
- **The role agents (`1.37.0`) are bounded by their tool masks, and Guard 7 bounds one thing beneath them: the shell.**
|
|
127
127
|
- `qa`'s test command is enforcement: Guard 5 keeps qa from writing, so qa only ever runs files it did not write. `code`'s identical allowance is process discipline, not a security boundary, because code writes the tests that command runs.
|
|
128
128
|
- The profiles are live in this repository, because the mirror convention puts them in `.claude/agents/`. The standing rule forbids starting an orchestrator run here; it does not forbid the files being present. A role dispatched by hand through `/agents` or `Agent` creates no band envelope, so Guard 5 allows every write its mask holds, which is `[ARCH-010]`'s no-envelope rule. Guard 7 still denies it the shell. This is named, not fixed.
|
|
129
|
-
- Installing or updating copies `.claude/agents/{spec,plan,code,audit,qa}.md` over the host project's files of the same names, as it does every shipped `.claude/` asset.
|
|
129
|
+
- Installing or updating copies `.claude/agents/{spec,plan,code,audit,qa,define-review}.md` over the host project's files of the same names, as it does every shipped `.claude/` asset.
|
|
130
130
|
- A gate certifies protocol position and the claim its role states, never the truth of the work beyond that claim.
|
|
131
|
+
- **The review loop (`1.39.0`) is process discipline.** The spec or plan envelope stays installed after its hand-back, so the role can revise. Outside a round, its writes are bounded by its tool mask, Guard 5's scope, the re-hash before `approve`, and your review. Gating Guard 5 on an open round is a follow-up candidate.
|
|
131
132
|
- **The `P7` false positive above**, still live.
|
|
132
133
|
- **A re-run against an untouched `project.md` prints a recovery hint it cannot prove is needed.** If you install, never write anything into `.claude/memory/project.md`, and install again, you get a line suggesting the file may have been overwritten by a pre-`1.30.0` re-run. It was not; it equals the stub because it was seeded and never edited. The check compares content and **cannot distinguish "seeded and untouched" from "clobbered"**, which is why the wording is hedged to "may have been" rather than "was". This residual is named and accepted in [`BUG-039`'s spec at `:129`](docs/superpowers/specs/2026-09-27-bug039-installer-host-owned-state-design.md), where the alternative (restoring from the host's own git history) was rejected as writing host files out of the host's history with new failure modes. A **fresh** install is silent, which the Quickstart shows.
|
|
133
134
|
- **Four open dossiers**, which are the evidence-collection pipeline working rather than a backlog: a session denial tally, one for interleaved-artifact reports, an intermittent commit-hook hang in the `snap-build` suite, and detect-stack failing whole on a non-string `package.json` script. A dossier holds specimens until a mechanism is characterized by probe; an id is minted only when the written condition is met. `[BUG-047]` is what that pipeline produces when it completes: an out-of-scope note, then a dossier, then four specimens across four sessions, then a mint, then a release.
|
|
@@ -234,7 +235,7 @@ All commands are tagged `(Conductor)` in the Claude Code command palette so they
|
|
|
234
235
|
| `/cc-plan` | Require an approved spec, map the codebase, and generate an ordered implementation plan with exact file paths, a test list, a commit order, and identified risks. Every generated task line carries a unique `[T-NNN]` ID (min 3 digits, unlimited suffix depth) using plain ASCII checkboxes — enforced at generation time. |
|
|
235
236
|
| `/cc-compact` | Phase-boundary command. Serializes the current phase's essential state (decisions, pending steps, files touched, constraints) into a single-line SNAP JSON snapshot at `.claude/memory/session-snapshot.json` — and, when Node `>= 22.5` is available, a git-hash-keyed row in the local `.conductor/cache.db` — then prompts you to run `/compact` to clear conversation history. Run at the end of every phase to prevent context overflow. |
|
|
236
237
|
| `/cc-implement` | Execute implementation tasks from an approved plan using a surgical 5-step ritual: Grep-locate pending tasks → single-line Read verify → pre-flip `[ ]` to `[>]` → execute → post-flip to `[X]` or `[!]`. Never reads or rewrites the full plan file. Includes dependency evaluation, drift detection, and a Step 6 hook that records each task's final state to a local SQLite cache (see below). |
|
|
237
|
-
| `/cc-orchestrate <ITEM> [--auto] [--ticket <N\|issue URL>]` | Route one backlog item through Define, Build and Verify. For each role it builds, validates (`snap-validate --to`) and installs a SNAP v3 band envelope, dispatches the agent named after the role, waits for its completion notice, and checks the one `SNAP_HANDBACK` line of its delivered hand-back before the next. It pauses before every dispatch unless `--auto`; the spec and plan approvals always pause. A failed validation halts the run, terminally in this version (recover with `end`, then `start`). It needs agent definitions named `spec`, `plan`, `code`, `audit` and `qa` in `.claude/agents/` or `~/.claude/agents/`, which ship from `1.37.0`; a root `package.json` with a `test` script, or a stack whose test command detect-stack names, since `start` records the one command `code` and `qa` may run and halts when none resolves; and plans in the writing-plans format (`### Task N` with a `**Files:**` block). Release stays human. `--ticket` binds the run to a GitHub issue: `start` fetches it once through `gh`, halts on a pull request, a closed issue, or an empty or over-65536-byte body, and writes the body into a fenced, hashed snapshot at `.conductor/ticket/<ITEM>.md`, which only the spec role reads, as untrusted requirement input. After release, the owner runs `node .claude/scripts/ticket.mjs writeback <ITEM> --version <v> --pr <N\|url> [--changelog <file>] [--close]`, which posts one outcome comment to the bound issue, never twice for the same version, and closes it only with `--close`. |
|
|
238
|
+
| `/cc-orchestrate <ITEM> [--auto] [--ticket <N\|issue URL>]` | Route one backlog item through Define, Build and Verify. For each role it builds, validates (`snap-validate --to`) and installs a SNAP v3 band envelope, dispatches the agent named after the role, waits for its completion notice, and checks the one `SNAP_HANDBACK` line of its delivered hand-back before the next. It pauses before every dispatch unless `--auto`; the spec and plan approvals always pause. Before each, a review loop checks the document with a fresh read-only `define-review` agent and sends open rows back to its author, at most three passes; it is advisory and fails open (see Review loop configurations). A failed validation halts the run, terminally in this version (recover with `end`, then `start`). It needs agent definitions named `spec`, `plan`, `code`, `audit` and `qa` in `.claude/agents/` or `~/.claude/agents/`, which ship from `1.37.0`; a root `package.json` with a `test` script, or a stack whose test command detect-stack names, since `start` records the one command `code` and `qa` may run and halts when none resolves; and plans in the writing-plans format (`### Task N` with a `**Files:**` block). Release stays human. `--ticket` binds the run to a GitHub issue: `start` fetches it once through `gh`, halts on a pull request, a closed issue, or an empty or over-65536-byte body, and writes the body into a fenced, hashed snapshot at `.conductor/ticket/<ITEM>.md`, which only the spec role reads, as untrusted requirement input. After release, the owner runs `node .claude/scripts/ticket.mjs writeback <ITEM> --version <v> --pr <N\|url> [--changelog <file>] [--close]`, which posts one outcome comment to the bound issue, never twice for the same version, and closes it only with `--close`. |
|
|
238
239
|
|
|
239
240
|
Each of `/cc-spec`, `/cc-plan`, and `/cc-implement` opens its phase with a **resume read** (`scripts/resume-read.mjs`): it restores any context stored for the current git commit, so work survives branch switches and rollbacks (see [Local State Cache & Session Persistence](#local-state-cache--session-persistence--v1220)).
|
|
240
241
|
| `/cc-review [file\|dir]` | Review code in three layers - Critical / Important / Suggestion - then deliver a verdict and offer to auto-fix. |
|
|
@@ -245,6 +246,18 @@ Each of `/cc-spec`, `/cc-plan`, and `/cc-implement` opens its phase with a **res
|
|
|
245
246
|
|
|
246
247
|
---
|
|
247
248
|
|
|
249
|
+
### Review loop configurations
|
|
250
|
+
|
|
251
|
+
Before each define approval, `/cc-orchestrate` runs a review loop (`[FEAT-041]`): a fresh read-only `define-review` agent checks the spec or plan against a declared checklist, and while rows stay open the orchestrator sends them back to the role that wrote the document, up to three reviewer passes and two revisions. It is advisory: it never gates, never halts the run, and never replaces your approval, which only a message you send gives. What a round costs depends on how you launched Claude Code, measured on `claude` 2.1.292:
|
|
252
|
+
|
|
253
|
+
| Configuration | Per round |
|
|
254
|
+
|---|---|
|
|
255
|
+
| Auto mode with the shipped exception: `claude --permission-mode auto --settings .claude/review-loop.settings.json` | 0 owner wakes, 0 prompts |
|
|
256
|
+
| Default (ask) permission mode | 0 wakes; one approval per revision write, plus the orchestrator's `review` calls and report writes |
|
|
257
|
+
| Plain auto mode | the auto mode classifier denies the first revision request; the loop closes `skipped:denied`, and you get round 1's findings, unrevised |
|
|
258
|
+
|
|
259
|
+
`.claude/review-loop.settings.json` holds one auto mode allow rule that names this protocol. The installer never writes `autoMode` into `~/.claude/settings.json`, and Claude Code ignores `autoMode` in project settings, so the rule applies only when you pass the file yourself. Read it before you pass it: a cloned repository could ship a different file under the same name.
|
|
260
|
+
|
|
248
261
|
## Skills
|
|
249
262
|
|
|
250
263
|
Skills extend agent behavior for cross-cutting concerns that apply regardless of stack.
|
|
@@ -426,7 +439,8 @@ code-conductor/
|
|
|
426
439
|
│ ├── gitignore Merged into the host project's .gitignore
|
|
427
440
|
│ └── .claude/
|
|
428
441
|
│ ├── settings.json Hooks wiring (pre-tool-use, post-compact)
|
|
429
|
-
│ ├──
|
|
442
|
+
│ ├── review-loop.settings.json Auto mode exception for the review loop (FEAT-041)
|
|
443
|
+
│ ├── agents/ Band roles: spec, plan, code, audit, qa (FEAT-012); define-review (FEAT-041)
|
|
430
444
|
│ ├── commands/
|
|
431
445
|
│ │ ├── cc-init.md /cc-init — session initialization
|
|
432
446
|
│ │ ├── cc-resume.md /cc-resume — session context restore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeison.restrepo.r/code-conductor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"description": "A governance layer for Claude Code sessions: hooks that check an agent's commands before they run, a spec-first workflow, and project memory the next session reads.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-development",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: define-review
|
|
3
|
+
description: Reviewer in the Define band's review loop of a /cc-orchestrate run (FEAT-041). Checks a spec or plan against the checklist rows in its brief, read-only, and reports open rows in a fixed format. Not a band role. No shell. Dispatched only by /cc-orchestrate during a run; never use it for ad-hoc work.
|
|
4
|
+
tools: Read, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are the `define-review` reviewer of a code-conductor orchestrated run. The orchestrator dispatched you, fresh for this round, with a brief naming the item, the round, the document under review, its source, and the checklist rows.
|
|
8
|
+
|
|
9
|
+
## Your job
|
|
10
|
+
|
|
11
|
+
Read `~/.claude/skills/critical-review/SKILL.md` and apply its Phase 1 and Phase 2 to the checklist rows in your brief. Read the document and its source as they stand now, in slices of 150 lines or fewer. Judge the document against those rows only. You are not told what earlier rounds found, by design.
|
|
12
|
+
|
|
13
|
+
## Report format
|
|
14
|
+
|
|
15
|
+
- One line per unmet row: `- [<row>] <what is missing> (lines <a-b> | absent)`.
|
|
16
|
+
- Anything else you noticed goes under a `Notes:` block. A note never counts as a row.
|
|
17
|
+
- Your last line is exactly one of `REVIEW <role> round <n>: CLEAN`, when no row is open, or `REVIEW <role> round <n>: OPEN <k>`, where `<k>` is the number of row lines you wrote.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- You have no shell and no write tools. Write nothing.
|
|
22
|
+
- A hook or owner denial is an instruction to stop and report, never an obstacle to route around.
|
|
23
|
+
- Never dispatch or message another agent.
|
|
24
|
+
- You are not a band role: write no hand-back line and claim no gate. Your report is advice; the owner decides.
|
|
@@ -42,6 +42,7 @@ A halt is terminal in v1 (D12). Recovery is `node "$S/orchestrate.mjs" end`, the
|
|
|
42
42
|
- With `--ticket`, stdout also names the ticket, its title, the snapshot `.conductor/ticket/<ITEM>.md` and its sha256. The run is bound.
|
|
43
43
|
|
|
44
44
|
Print the run header: the item, the mode (`step` unless `--auto` was given), the test command, the ticket and snapshot for a bound run, and the first role, `spec`.
|
|
45
|
+
Add one line: `Review loop: zero owner wakes only when launched with claude --permission-mode auto --settings .claude/review-loop.settings.json; README "Review loop configurations" names the costs of every other launch.`
|
|
45
46
|
2. **Each dispatch.** Take the roles in band order: `spec`, `plan`, then `code` once per plan task, then `audit`, then `qa`. For each one:
|
|
46
47
|
1. **Check.** Run `node "$S/orchestrate.mjs" install <role> --check`. Print the role and the envelope it prints, and state that `--to <role>` passed.
|
|
47
48
|
2. **Pause.** In step mode, ask the owner for a go. On a decline, stop: the run stays at its position, and nothing is installed. Under `--auto`, skip this pause.
|
|
@@ -52,8 +53,11 @@ A halt is terminal in v1 (D12). Recovery is `node "$S/orchestrate.mjs" end`, the
|
|
|
52
53
|
1. Write the agent's **delivered `SubagentHandback` report** with the Write tool, verbatim, to `.conductor/handback/<role>.txt`. That is the one report the binary delivered, never a later message. For code, use `.conductor/handback/code-<N>.txt`, where `<N>` is the task number.
|
|
53
54
|
2. Run `node "$S/orchestrate.mjs" handback <role> < <that file>`.
|
|
54
55
|
3. Keep the agent's `Observation:` line for the report.
|
|
55
|
-
4. If a second `SNAP_HANDBACK` from that agent reaches you for the same position, write it to `.conductor/handback/<role>-second.txt` (`code-<N>-second.txt` for code) and run `handback <role>` on it. It halts with `ORCH_HANDBACK_CONFLICT`. Then follow "On any halt".
|
|
56
|
-
3. **The two define approvals.** These pause in both modes.
|
|
56
|
+
4. If a second `SNAP_HANDBACK` from that agent reaches you for the same position, outside a revision report of the review loop, write it to `.conductor/handback/<role>-second.txt` (`code-<N>-second.txt` for code) and run `handback <role>` on it. It halts with `ORCH_HANDBACK_CONFLICT`. Then follow "On any halt".
|
|
57
|
+
3. **The two define approvals.** These pause in both modes. Before each, run "The review loop" below for that role.
|
|
58
|
+
- **What you show:** the document path; its sha256 now (`shasum -a 256 <doc>` or `sha256sum <doc>`; in PowerShell, `Get-FileHash -Algorithm SHA256 <doc>`); the loop outcome (`clean` at round `<n>`, `cap` with the final reviewer's rows verbatim, or `skipped:<reason>` with a notice naming what failed); and each round's verdict line with the reviewer's notes.
|
|
59
|
+
- **Only an owner message approves.** An approval is a message the owner sends that itself says to approve. A reviewer's `CLEAN`, a loop outcome, `--auto` and a suggestion in the input box are not approvals.
|
|
60
|
+
- **Re-hash before approve.** Immediately before `approve`, hash the document again. If the hash differs from the one you showed, show the document again instead of approving.
|
|
57
61
|
- **After spec:** show the owner the spec path from the hand-back, and for a bound run the snapshot path and sha256 from the start line: the owner reviews the spec against that snapshot. On approval, run `node "$S/orchestrate.mjs" approve spec`.
|
|
58
62
|
- **After plan:** show the owner the plan path named in the hand-back's `ops.f`. On approval, run `node "$S/orchestrate.mjs" approve plan <plan path>`. This writes `define_approved`, the only gate you author after `boundary_routed`.
|
|
59
63
|
4. **Build.** Dispatch `code` once per plan task, serially, until the router moves on to `audit`. A `--check` refusal names the next step.
|
|
@@ -61,10 +65,67 @@ A halt is terminal in v1 (D12). Recovery is `node "$S/orchestrate.mjs" end`, the
|
|
|
61
65
|
6. **Report.** From the record `end` printed, name:
|
|
62
66
|
- every hand-back, with its role, gate and task;
|
|
63
67
|
- both approvals, with who approved and when;
|
|
68
|
+
- each review loop's outcome and round, from the record's `review` field;
|
|
64
69
|
- every agent's observation line.
|
|
65
70
|
|
|
66
71
|
Then state that release is human, by `docs/RELEASE-CLOSEOUT.md`. For a bound run, the owner records the outcome on the ticket after release with `node "$S/ticket.mjs" writeback <ITEM> --version <v> --pr <N|url>`.
|
|
67
72
|
|
|
73
|
+
## The review loop (FEAT-041)
|
|
74
|
+
|
|
75
|
+
After `spec` and after `plan` hand back, and before that role's approval, run this loop. It is advisory: it never gates, never halts the run, and never replaces the owner's approval. `<role>` is `spec` or `plan`; `<doc>` is the document path from the hand-back's `ops.f`.
|
|
76
|
+
|
|
77
|
+
1. **Open a round.** Run `node "$S/orchestrate.mjs" review <role> --round`. It prints `review <role> round <n> of 3`.
|
|
78
|
+
2. **Review.** Dispatch a fresh `define-review` agent with the `Agent` tool and the reviewer brief below. Never revive an earlier reviewer, and never pass it an earlier round's findings. Wait for its completion notice.
|
|
79
|
+
3. **Record.** Write its report verbatim with the Write tool to `.conductor/review/<role>-<n>-review.txt`. Its last line is `REVIEW <role> round <n>: CLEAN` or `REVIEW <role> round <n>: OPEN <k>`.
|
|
80
|
+
4. **Clean.** On `CLEAN`, run `review <role> --close clean` and go to the approval.
|
|
81
|
+
5. **Open, a pass remaining.** On `OPEN <k>` below round 3, use `SendMessage` to the `<role>` agent you dispatched, by its agent id, with the revision brief below and the open rows verbatim. Wait for the first delivery on any channel (a message, a hand-back frame or a completion notice) whose last line is `REVISION <role> round <n>: done` or `REVISION <role> round <n>: blocked <reason>`. Ignore later copies of the same round's report. Write it verbatim to `.conductor/review/<role>-<n>-revision.txt`. On `done`, go back to 1.
|
|
82
|
+
6. **Open at the cap.** On `OPEN <k>` at round 3, run `review <role> --close cap`. No revision follows the third pass, so the document at the approval is always the one the last reviewer read.
|
|
83
|
+
|
|
84
|
+
A revision report is never passed to `handback`. If one carries a `SNAP_HANDBACK` line, run `review <role> --close skipped:snap-in-revision` and flag the report at the approval.
|
|
85
|
+
|
|
86
|
+
**Fail-open.** On any loop error, run `review <role> --close skipped:<reason>`, and carry on if that also fails. Do not retry, take no other route, and go to the approval with a notice naming what failed. The reasons:
|
|
87
|
+
- `dispatch`: the reviewer dispatch fails;
|
|
88
|
+
- `unparsed`: the reviewer's last line does not parse;
|
|
89
|
+
- `denied`: the `SendMessage` is denied (plain auto mode);
|
|
90
|
+
- `blocked`: a revision ends `blocked`;
|
|
91
|
+
- `snap-in-revision`: a revision report carries a `SNAP_HANDBACK` line;
|
|
92
|
+
- `verb`: the `review` verb refuses or errors.
|
|
93
|
+
|
|
94
|
+
A loop error never halts the run. If the owner sends any message during the loop, close it with `skipped:owner` and handle the message as the owner's word. You wait only on notifications the loop caused.
|
|
95
|
+
|
|
96
|
+
### The checklist
|
|
97
|
+
|
|
98
|
+
Only these rows keep the loop going. Anything else a reviewer reports goes in its `Notes:` and never triggers a revision.
|
|
99
|
+
|
|
100
|
+
| Row | Spec document | Plan document |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| AC | Every acceptance criterion in the source is addressed, citing the spec lines that address it. | Every acceptance criterion of the approved spec maps to at least one task, citing plan lines. |
|
|
103
|
+
| FMT | The `/cc-spec` sections are present: Problem, Solution, Behavior (Main path, Alternative paths, Error cases), Acceptance Criteria, Out of Scope, System Impact, Complexity Estimate. | Every task is a `### Task N` heading with a `**Files:**` block (`approve plan` halts with `ORCH_EMPTY_SCOPE` without them). |
|
|
104
|
+
| CR | critical-review Phase 1: the happy path, the failure points and the boundary conditions are each addressed in Behavior. | critical-review Phase 1 per task: its failure point and its verification step are named. |
|
|
105
|
+
|
|
106
|
+
### The reviewer brief
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
You are the define-review reviewer for <ITEM>, round <n> of 3, reviewing the <role> document.
|
|
110
|
+
Document: <doc>
|
|
111
|
+
Source: <spec: the ticket snapshot .conductor/ticket/<ITEM>.md for a bound run, otherwise the backlog entry for <ITEM>, found with Grep; plan: the approved spec>
|
|
112
|
+
Read ~/.claude/skills/critical-review/SKILL.md and apply its Phases 1 and 2 to these rows only:
|
|
113
|
+
<the role's AC, FMT and CR rows from the checklist, verbatim>
|
|
114
|
+
Report each unmet row as one line: - [<row>] <what is missing> (lines <a-b> | absent)
|
|
115
|
+
Put anything else under Notes:. Write nothing. Do not dispatch or message other agents.
|
|
116
|
+
End with exactly one line: REVIEW <role> round <n>: CLEAN, or REVIEW <role> round <n>: OPEN <k>, where <k> is the number of row lines.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### The revision brief
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Revision round <n> for <ITEM>. A reviewer found these open rows in your document <doc>:
|
|
123
|
+
<the reviewer's row lines, verbatim>
|
|
124
|
+
Revise <doc> with the Edit tool to address them. Guard 5 still holds your envelope's scope.
|
|
125
|
+
Report the revision as prose. Do not emit any SNAP_HANDBACK line: your hand-back is already recorded.
|
|
126
|
+
End with exactly one line: REVISION <role> round <n>: done, or REVISION <role> round <n>: blocked <reason>.
|
|
127
|
+
```
|
|
128
|
+
|
|
68
129
|
## The dispatch brief
|
|
69
130
|
|
|
70
131
|
Fill in each `<...>` from the run and the role.
|
|
@@ -75,7 +136,7 @@ Your band envelope is installed at .claude/memory/band-envelope.json: tk <tk>, s
|
|
|
75
136
|
Guard 5 denies any write outside that scope. Do not get around a denial or a missing tool, for
|
|
76
137
|
example with shell redirection. Report it instead.
|
|
77
138
|
Task: <the role's task, below>
|
|
78
|
-
Verify your work before you hand back
|
|
139
|
+
Verify your work before you hand back. Your hand-back is the run's only record. After it, the orchestrator may send you revision requests; answer them as prose, without a `SNAP_HANDBACK` line.
|
|
79
140
|
Do not dispatch or message other agents; Guard 6 denies it during a run.
|
|
80
141
|
Copy ops.scope verbatim from your envelope into the hand-back; if your envelope has no scope, leave the key out.
|
|
81
142
|
End your hand-back report with exactly these two lines, each on its own line:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"autoMode":{"allow":["$defaults","Orchestrator revision rounds (code-conductor FEAT-041): during a live /cc-orchestrate run, the main session may use SendMessage to a spec or plan band agent that has already handed back, asking it to revise its own document under docs/superpowers/specs/ or docs/superpowers/plans/ and to report the revision as prose without a SNAP_HANDBACK line. This is the project's reviewer-in-loop protocol, not an evasion of oversight: the agent's edits remain subject to the project's PreToolUse guards, and the owner's boundary approval still follows."]}}
|
package/scripts/orchestrate.mjs
CHANGED
|
@@ -21,6 +21,12 @@ export const WRITE_SURFACE = [RUN_FILE, ENVELOPE_FILE, '.claude/memory/session-s
|
|
|
21
21
|
// Where /cc-orchestrate writes each agent's final message for `handback` to read: inside
|
|
22
22
|
// the surface, and cleared with the run so file names never collide across runs.
|
|
23
23
|
export const HANDBACK_DIR = '.conductor/handback';
|
|
24
|
+
// FEAT-041: the Define review loop's reports, cleared with the run like the hand-backs.
|
|
25
|
+
export const REVIEW_DIR = '.conductor/review';
|
|
26
|
+
// Three reviewer passes, so at most two revisions, each re-reviewed (FEAT-041 (d)).
|
|
27
|
+
export const REVIEW_CAP = 3;
|
|
28
|
+
const REVIEW_OUTCOME = /^(clean|cap|skipped:[a-z][a-z0-9-]{0,39})$/;
|
|
29
|
+
const REVIEW_USAGE = 'usage: orchestrate.mjs review <spec|plan> --round | --close <clean|cap|skipped:<reason>>';
|
|
24
30
|
|
|
25
31
|
// D5: the reviewed role-artifact table. Code's scope comes from its plan task instead.
|
|
26
32
|
export const ROLE_ARTIFACTS = {
|
|
@@ -327,6 +333,34 @@ function approve(root, sessionId, what, planRel) {
|
|
|
327
333
|
return `plan approved: define_approved, ${tasks.length} task(s)`;
|
|
328
334
|
}
|
|
329
335
|
|
|
336
|
+
// FEAT-041 (e): the review loop's round counter. Advisory: approve never reads it, and the
|
|
337
|
+
// cap is a refusal, never a halt, so the loop can never freeze the run.
|
|
338
|
+
function review(root, sessionId, [role, flag, outcome, extra]) {
|
|
339
|
+
const run = liveRun(root, sessionId);
|
|
340
|
+
const wellFormed = extra === undefined && (flag === '--round' ? outcome === undefined : flag === '--close' && outcome !== undefined);
|
|
341
|
+
if (!wellFormed) throw new Refusal(REVIEW_USAGE);
|
|
342
|
+
const step = nextStep(run);
|
|
343
|
+
if (step.await !== role) throw new Refusal(`review ${role}: the next step is ${describeStep(step)}`);
|
|
344
|
+
const loops = isPlainObject(run.review) ? run.review : {};
|
|
345
|
+
const loop = isPlainObject(loops[role]) && Number.isInteger(loops[role].round) ? loops[role] : { round: 0, outcome: null };
|
|
346
|
+
if (loop.outcome) throw new Refusal(`review ${role}: the loop closed ${loop.outcome}; a closed loop does not reopen`);
|
|
347
|
+
const next = flag === '--round' ? openRound(role, loop) : closeLoop(role, loop, outcome);
|
|
348
|
+
saveRun(root, { ...run, review: { ...loops, [role]: next } });
|
|
349
|
+
return flag === '--round' ? `review ${role} round ${next.round} of ${REVIEW_CAP}` : `review ${role} closed ${next.outcome} at round ${next.round}`;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function openRound(role, loop) {
|
|
353
|
+
if (loop.round >= REVIEW_CAP) throw new Refusal(`ORCH_REVIEW_CAP: review ${role} has run ${REVIEW_CAP} rounds; close it with --close cap`);
|
|
354
|
+
return { round: loop.round + 1, outcome: null };
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function closeLoop(role, loop, outcome) {
|
|
358
|
+
if (!REVIEW_OUTCOME.test(outcome)) throw new Refusal(REVIEW_USAGE);
|
|
359
|
+
if (outcome === 'clean' && loop.round === 0) throw new Refusal(`review ${role}: clean needs a reviewer pass; none has run`);
|
|
360
|
+
if (outcome === 'cap' && loop.round < REVIEW_CAP) throw new Refusal(`review ${role}: cap needs round ${REVIEW_CAP}; the loop is at round ${loop.round}`);
|
|
361
|
+
return { round: loop.round, outcome };
|
|
362
|
+
}
|
|
363
|
+
|
|
330
364
|
const START_USAGE = 'usage: orchestrate.mjs start <ITEM> [--auto] [--ticket <N|issue URL>]';
|
|
331
365
|
|
|
332
366
|
// The item first, then --auto and --ticket <ref> in either order, each at most once. A
|
|
@@ -376,6 +410,7 @@ function start(root, sessionId, args) {
|
|
|
376
410
|
function clearRunFiles(root) {
|
|
377
411
|
rmSync(join(root, ENVELOPE_FILE), { force: true });
|
|
378
412
|
rmSync(join(root, HANDBACK_DIR), { recursive: true, force: true });
|
|
413
|
+
rmSync(join(root, REVIEW_DIR), { recursive: true, force: true });
|
|
379
414
|
}
|
|
380
415
|
|
|
381
416
|
// Prints the run it removes, so the closing report reads the record rather than memory.
|
|
@@ -403,10 +438,11 @@ export function cli(argv, env, cwd = process.cwd()) {
|
|
|
403
438
|
install: () => install(root, sid, a, b === '--check'),
|
|
404
439
|
handback: () => handback(root, sid, a, readFileSync(0, 'utf8')),
|
|
405
440
|
approve: () => approve(root, sid, a, b),
|
|
441
|
+
review: () => review(root, sid, argv.slice(1)),
|
|
406
442
|
end: () => end(root),
|
|
407
443
|
};
|
|
408
444
|
try {
|
|
409
|
-
if (!verbs[verb]) throw new Refusal('usage: orchestrate.mjs start|install|handback|approve|end');
|
|
445
|
+
if (!verbs[verb]) throw new Refusal('usage: orchestrate.mjs start|install|handback|approve|review|end');
|
|
410
446
|
process.stdout.write(verbs[verb]() + '\n');
|
|
411
447
|
return 0;
|
|
412
448
|
} catch (e) {
|