cclaw-cli 1.0.0 → 2.0.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/dist/artifact-linter/brainstorm.js +15 -1
- package/dist/artifact-linter/design.js +14 -0
- package/dist/artifact-linter/scope.js +14 -0
- package/dist/artifact-linter/shared.d.ts +1 -0
- package/dist/artifact-linter/shared.js +32 -0
- package/dist/artifact-linter.js +11 -1
- package/dist/content/hook-events.js +1 -2
- package/dist/content/hook-manifest.d.ts +3 -4
- package/dist/content/hook-manifest.js +22 -25
- package/dist/content/hooks.js +54 -14
- package/dist/content/meta-skill.js +4 -3
- package/dist/content/node-hooks.js +259 -89
- package/dist/content/observe.js +3 -3
- package/dist/content/opencode-plugin.js +0 -6
- package/dist/content/skills-elicitation.d.ts +1 -0
- package/dist/content/skills-elicitation.js +123 -0
- package/dist/content/skills.js +6 -4
- package/dist/content/stages/brainstorm.js +7 -3
- package/dist/content/stages/design.js +4 -0
- package/dist/content/stages/scope.js +6 -2
- package/dist/content/start-command.js +4 -4
- package/dist/content/templates.js +21 -0
- package/dist/flow-state.d.ts +7 -0
- package/dist/flow-state.js +1 -0
- package/dist/hook-schemas/claude-hooks.v1.json +2 -3
- package/dist/hook-schemas/codex-hooks.v1.json +1 -1
- package/dist/hook-schemas/cursor-hooks.v1.json +1 -1
- package/dist/install.js +12 -3
- package/dist/internal/advance-stage/advance.js +22 -1
- package/dist/internal/advance-stage/parsers.d.ts +1 -0
- package/dist/internal/advance-stage/parsers.js +6 -0
- package/dist/run-persistence.d.ts +1 -1
- package/dist/run-persistence.js +29 -2
- package/dist/runtime/run-hook.mjs +259 -89
- package/dist/track-heuristics.d.ts +7 -1
- package/dist/track-heuristics.js +12 -0
- package/package.json +1 -1
package/dist/content/skills.js
CHANGED
|
@@ -148,11 +148,12 @@ function contextLoadingBlock(stage, trace, executionModel) {
|
|
|
148
148
|
|
|
149
149
|
Before execution:
|
|
150
150
|
1. Read \`.cclaw/state/flow-state.json\`.
|
|
151
|
+
- If the file is missing, do **not** invent an active run — this is normal for fresh init. Route to \`/cc <idea>\` first.
|
|
151
152
|
2. Load active artifacts from \`.cclaw/artifacts/\`.
|
|
152
153
|
3. Load upstream artifacts required by this stage:
|
|
153
154
|
${readLines}
|
|
154
155
|
4. Read the state contract from \`.cclaw/templates/state-contracts/<stage>.json\` for required fields, taxonomies, and derived markdown path.
|
|
155
|
-
5. Read the canonical artifact template at \`${artifactTemplatePath}\`
|
|
156
|
+
5. Read the canonical artifact template at \`${artifactTemplatePath}\` to preserve heading/per-row tables contracts (stable section names and column order) plus calibrated review block scaffolding. Preserve existing substantive bullets/rows already in the artifact; never overwrite the artifact wholesale from the template — patch only sections you author this turn.
|
|
156
157
|
6. Extract upstream decisions, constraints, and open questions into the current artifact's \`Upstream Handoff\` section when present.
|
|
157
158
|
7. Confirm context readiness: upstream artifact freshness, required context, canonical template shape, relevant in-repo/reference patterns, and unresolved blockers are known. If any item is missing, load it or stop before drafting.
|
|
158
159
|
8. Before doing stage work, give a compact user-facing drift preamble: "Carrying forward: <1-3 bullets>. Drift since upstream: None / <specific drift>. Recommendation: continue / re-scope."
|
|
@@ -376,7 +377,7 @@ function completionParametersBlock(schema, track) {
|
|
|
376
377
|
- \`delegation lifecycle proof\`: use the delegation helper recipe in this section with explicit lifecycle rows: \`--status=scheduled\` -> \`--status=launched\` -> \`--status=acknowledged\` -> \`--status=completed\` (completed isolated/generic requires prior ACK for the same span or \`--ack-ts=<iso>\`).
|
|
377
378
|
- Fill \`## Learnings\` before closeout: either \`- None this stage.\` or JSON bullets with required keys \`type\`, \`trigger\`, \`action\`, \`confidence\` (knowledge-schema compatible).
|
|
378
379
|
- Record mandatory delegation lifecycle in \`${RUNTIME_ROOT}/state/delegation-log.json\` and append proof events to \`${RUNTIME_ROOT}/state/delegation-events.jsonl\`; the ledger is current state, the event log is audit proof.${mandatoryAgents.length > 0 ? ` If a mandatory delegation cannot run in this harness, use \`--waive-delegation=${mandatoryAgents.join(",")} --waiver-reason="<why safe>"\` on the completion helper.` : ""} If proactive delegations were intentionally skipped, rerun only with \`--accept-proactive-waiver\` (optionally \`--accept-proactive-waiver-reason="<why safe>"\`) after explicit user approval.
|
|
379
|
-
- Never edit raw \`flow-state.json\` to complete a stage, even in advisory mode; that bypasses validation, gate evidence, and Learnings harvest. If
|
|
380
|
+
- Never edit raw \`flow-state.json\` to complete a stage, even in advisory mode; that bypasses validation, gate evidence, and Learnings harvest. If a helper fails, report a one-line human-readable failure plus fenced JSON diagnostics; never echo the invoking command line or apply a manual state workaround.
|
|
380
381
|
- Completion protocol: verify required gates, update the artifact, then use the completion helper with \`--evidence-json\` and \`--passed\` for every satisfied gate.
|
|
381
382
|
`;
|
|
382
383
|
}
|
|
@@ -636,10 +637,11 @@ CLI commands, using existing \`cclaw run resume\` and \`internal verify-current-
|
|
|
636
637
|
## Process
|
|
637
638
|
|
|
638
639
|
1. **Wave Start**: author wave plan as \`.cclaw/wave-plans/<wave-n>.md\` referencing previous wave's ship artifact.
|
|
639
|
-
2. **Carry-forward Audit**: at brainstorm of the next wave, re-read previous wave ship artifact and explicitly record:
|
|
640
|
-
- Carrying forward: <
|
|
640
|
+
2. **Carry-forward Audit**: at brainstorm of the next wave, re-read previous wave ship artifact and explicitly record in the existing \`## Wave Carry-forward\` section:
|
|
641
|
+
- Carrying forward: <scope LD# hash references still valid>
|
|
641
642
|
- Drift detected: <decisions no longer valid + reason>
|
|
642
643
|
- Re-scope needed: <yes/no>
|
|
644
|
+
- Never create a second \`## Locked Decisions\` heading in brainstorm; reference prior LD# hashes inline.
|
|
643
645
|
3. **Resume Path**: if a wave was interrupted mid-stage, \`cclaw run resume\` restores state. Run \`internal verify-current-state\` before continuing.
|
|
644
646
|
4. **Wave End**: at ship, architect cross-stage verification runs from dispatch matrix. If \`DRIFT_DETECTED\`, fix before ship.
|
|
645
647
|
5. **Next Wave Trigger**: launch new \`/cc <topic>\` for next wave and reference previous wave ship artifact in upstream handoff.
|
|
@@ -37,14 +37,16 @@ export const BRAINSTORM = {
|
|
|
37
37
|
executionModel: {
|
|
38
38
|
checklist: [
|
|
39
39
|
"**Explore project context** — inspect existing files/docs/recent activity before asking what to build; capture matching files/patterns/seeds in `Context > Discovered context` so downstream stages don't redo discovery.",
|
|
40
|
+
"**Adaptive elicitation loop (shared skill)** — load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question at a time via harness-native question tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until context is clear or user signals to proceed.",
|
|
41
|
+
"**Brainstorm forcing questions (must be covered or explicitly waived)** — what pain are we solving, what is the direct path, what happens if we do nothing, who is the first operator/user affected, and what no-go boundaries are non-negotiable.",
|
|
40
42
|
"**Classify stage depth** — choose `lite` for clear low-risk tasks, `standard` for normal engineering/product changes, or `deep` for ambiguity, architecture, external dependency, security/data risk, or explicit think-bigger requests.",
|
|
41
43
|
"**Write the Problem Decision Record** — pick a free-form `Frame type` label that names how this work is framed (examples: product, technical-maintenance, research-spike, ops-incident, infrastructure), then fill the universal Framing fields: affected user/role/operator, current state/failure mode/opportunity, desired observable outcome, evidence/signal, why now, do-nothing consequence, and non-goals.",
|
|
42
44
|
"**Premise check (one pass)** — answer the three gstack-style questions in the artifact body: *Right problem? Direct path? What if we do nothing?* Take a position; do not hedge.",
|
|
43
45
|
"**Reframe with How Might We** — write a single `How Might We …?` line that names the user/operator, the desired outcome, and the constraint. This is the altitude check before approaches.",
|
|
44
46
|
"**Run Clarity Gate** — record ambiguity score (0.00-1.00), decision boundaries, reaffirmed non-goals, and residual-risk handoff before locking recommendations. If ambiguity remains high (>0.40), ask one decision-changing question before recommending.",
|
|
45
47
|
"**Sharpening question discipline** — ask one decision-changing question at a time. Do not default to 3-5 batched questions; record only questions that changed the direction or a critical stop decision.",
|
|
46
|
-
"**Use compact discovery for low-risk asks** — for concrete bounded requests, do one context pass, compare one baseline and one challenger,
|
|
47
|
-
"**Early-exit concrete asks** — for unambiguous implementation-only requests, write a compact Problem Decision Record plus short-circuit handoff (context, approved intent, constraints, assumptions, next-stage risks) and
|
|
48
|
+
"**Use compact discovery for low-risk asks** — for concrete bounded requests, do one context pass, compare one baseline and one challenger, and move to draft once context is sufficient; do not drag the user through a full workshop.",
|
|
49
|
+
"**Early-exit concrete asks** — for unambiguous implementation-only requests, write a compact Problem Decision Record plus short-circuit handoff (context, approved intent, constraints, assumptions, next-stage risks) and request explicit approval when the draft is ready.",
|
|
48
50
|
"**Ask only decision-changing questions** — one at a time; if answers would not change approach and are non-critical preference/default assumptions, state the assumption and continue; STOP on scope, architecture, security, data loss, public API, migration, auth/pricing, or user approval uncertainty.",
|
|
49
51
|
"**Compare 2-3 distinct approaches with stable Role/Upside columns** — Role values are `baseline` | `challenger` | `wild-card`; Upside is `low` | `modest` | `high` | `higher`; include real trade-offs, reuse notes, and reference-pattern source/disposition when a known pattern influenced the option; include exactly one challenger with explicit `high` or `higher` upside.",
|
|
50
52
|
"**Collect reaction before recommending** — ask which option feels closest and what concern remains, then recommend based on that reaction.",
|
|
@@ -52,14 +54,16 @@ export const BRAINSTORM = {
|
|
|
52
54
|
"**Run early Ralph loop discipline** — after each producer iteration, append a `Critic Pass` JSONL row to `.cclaw/state/early-loop-log.jsonl`, refresh `.cclaw/state/early-loop.json`, and iterate until open concerns clear or convergence guard escalates.",
|
|
53
55
|
"**Embedded Grill (post-pick)** — after `Selected Direction` is named, run 3-5 sharp checks on hidden constraints, reversibility/rollback, scope boundaries, existing-pattern conformance, and domain-language fit; record each question with recommended answer and disposition (accept/refine/reject).",
|
|
54
56
|
"**Self-review before user approval** — re-read the artifact and patch contradictions, weak trade-offs, placeholders, ambiguity, and weak handoff language. Record the result in `Self-Review Notes` using the calibrated review format: `- Status: Approved` (or `Issues Found`), `- Patches applied:` with inline note or sub-bullets, `- Remaining concerns:` with inline note or sub-bullets. Use `Patches applied: None` and `Remaining concerns: None` when there is nothing to record.",
|
|
55
|
-
"**Request explicit approval** — state exactly what direction is being approved; do not advance without approval and artifact review.",
|
|
57
|
+
"**Request explicit approval to close the stage** — state exactly what direction is being approved after the adaptive elicitation loop converges; do not advance without approval and artifact review.",
|
|
56
58
|
"**Handoff packet** — only after approval, produce a scope handoff packet with selected direction, why rejected options were rejected, explicit non-goals, unresolved questions, risk hints, and explicit drift from the initial ask so scope starts from locked upstream decisions instead of rediscovering intent."
|
|
57
59
|
],
|
|
58
60
|
interactionProtocol: [
|
|
61
|
+
"\"If something is unclear, stop. Name what's confusing. Ask.\"",
|
|
59
62
|
"Start from observed project context; if the idea is vague, first narrow the project type with **one** structured question, then keep going.",
|
|
60
63
|
"Select depth explicitly: `lite`, `standard`, or `deep`; keep lite concise, but escalate when risk/ambiguity changes decisions.",
|
|
61
64
|
"Lead with the premise check (right problem / direct path / what if nothing) and the `How Might We` reframing before approaches; both go in the artifact, not just the chat.",
|
|
62
65
|
"Ask at most one question per turn, only when decision-changing; if using a structured question tool, send exactly one question object, not a multi-question form.",
|
|
66
|
+
"Run the shared adaptive elicitation cycle from `.cclaw/skills/adaptive-elicitation/SKILL.md`, including stop-signal handling (RU/EN/UA), smart-skip, conditional grilling triggers, and append-only `## Q&A Log` updates.",
|
|
63
67
|
"Only non-critical preference/default assumptions may continue inline. STOP and ask when uncertainty affects scope, architecture, security, data loss, public API, migration, auth/pricing, or user approval.",
|
|
64
68
|
"For simple low-risk greenfield work, present a compact A/B choice with one recommended path and one higher-upside challenger; keep the artifact concise but structurally complete (Context, Premise, How Might We, Sharpening Questions, Approaches, Reaction, Selected Direction, Not Doing).",
|
|
65
69
|
"Show approaches before the recommendation; include a higher-upside challenger and gather reaction first.",
|
|
@@ -40,6 +40,8 @@ export const DESIGN = {
|
|
|
40
40
|
},
|
|
41
41
|
executionModel: {
|
|
42
42
|
checklist: [
|
|
43
|
+
"**Adaptive elicitation loop (shared skill)** — load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question per turn via harness-native tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until architecture context is clear or user signals to proceed.",
|
|
44
|
+
"**Design forcing questions (must be covered or explicitly waived)** — what is the end-to-end data flow, where are seams/ownership boundaries, which invariants must hold, and what will explicitly NOT be refactored now.",
|
|
43
45
|
"Compact design lock — design does not decide what to build; it decides how the approved scope works. For simple slices, produce a tight lock: upstream handoff, existing fit, architecture boundary, one labeled diagram, data/state flow, critical path, failure/rescue, trust boundaries, test/perf expectations, rollout/rollback, rejected alternative, and spec handoff.",
|
|
44
46
|
"Trivial-Change Escape Hatch — for <=3 files, no new interfaces, and no cross-module data flow, produce a mini-design (rationale, changed files, one risk) and proceed to spec.",
|
|
45
47
|
"Tiered Research — for simple/medium work, do compact inline codebase/research synthesis in `Research Fleet Synthesis`; write `.cclaw/artifacts/02a-research.md` and run the full fleet only for deep/high-risk work or when external framework/architecture uncertainty exists.",
|
|
@@ -55,8 +57,10 @@ export const DESIGN = {
|
|
|
55
57
|
"Capture leftovers — seed high-upside deferred ideas, list unresolved decisions with defaults, document distribution for new artifact types, and cross-reference deferred items to scope or unresolved decisions."
|
|
56
58
|
],
|
|
57
59
|
interactionProtocol: [
|
|
60
|
+
"\"Constrain, don't micromanage - enforce invariants, separate the doer from the checker.\"",
|
|
58
61
|
"Review section-by-section: investigator first, critic second, then reconcile. For simple apps, collapse this into one compact design lock with explicit risks and a single approval stop.",
|
|
59
62
|
"Present each issue one at a time; do not batch issues or move sections until current issues are resolved.",
|
|
63
|
+
"Run the shared adaptive elicitation cycle from `.cclaw/skills/adaptive-elicitation/SKILL.md`, including stop-signal handling (RU/EN/UA), smart-skip, conditional grilling triggers, and append-only `## Q&A Log` updates.",
|
|
60
64
|
decisionProtocolInstruction("each issue", "describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High), and mark one as (recommended)", "recommend the option that closes the issue with the smallest blast radius and clearest verification path"),
|
|
61
65
|
"If a section has no issues, say 'No issues found' and move on.",
|
|
62
66
|
"Do not skip failure-mode mapping; use Method/Exception/Rescue/UserSees and treat silent user impact without rescue as critical.",
|
|
@@ -45,10 +45,12 @@ export const SCOPE = {
|
|
|
45
45
|
},
|
|
46
46
|
executionModel: {
|
|
47
47
|
checklist: [
|
|
48
|
+
"**Adaptive elicitation loop (shared skill)** — load `.cclaw/skills/adaptive-elicitation/SKILL.md` and run one decision-changing question per turn via harness-native tools. After each answer, append one row to `## Q&A Log` (`Turn | Question | User answer (1-line) | Decision impact`). Continue until scope clarity is sufficient or user signals to proceed.",
|
|
49
|
+
"**Scope forcing questions (must be covered or explicitly waived)** — what is definitely in/out, which upstream decisions are locked, and what rollback path protects users if scope assumptions fail.",
|
|
48
50
|
"**Scope contract first** — read brainstorm handoff, name upstream decisions used, explicit drift, confidence, unresolved questions, and next-stage risk hints; draft the in-scope/out-of-scope/deferred/discretion contract before any design choice.",
|
|
49
51
|
"**Premise and leverage check** — answer in the artifact: *Right problem? Direct path? What if nothing? Where can we leverage existing code? What is the reversibility cost?* Take a position; do not hedge.",
|
|
50
52
|
"**Conditional 10-star boundary** — for deep/high-risk/product-strategy work, show what would make the product meaningfully better, then explicitly choose what ships now, what is deferred, and what is excluded without vague `later/for now` placeholders. Skip this for straightforward repair work and record `not needed: compact scope`.",
|
|
51
|
-
"**Pick one operational mode with the user** — HOLD SCOPE preserves focus; SELECTIVE EXPANSION cherry-picks high-leverage reference ideas; SCOPE EXPANSION explores ambitious alternatives; SCOPE REDUCTION cuts to the essential wedge. Recommend one, state why and what signal would change it, then
|
|
53
|
+
"**Pick one operational mode with the user** — HOLD SCOPE preserves focus; SELECTIVE EXPANSION cherry-picks high-leverage reference ideas; SCOPE EXPANSION explores ambitious alternatives; SCOPE REDUCTION cuts to the essential wedge. Recommend one, state why and what signal would change it, then keep elicitation focused until the user either approves or asks to proceed with draft boundaries.",
|
|
52
54
|
"**Run mode-specific analysis only to needed depth** — lite keeps the selected-mode row compact; standard adds requirements/locked decisions/discretion; deep may add Landscape Check, Taste Calibration, Reference Pattern Registry, Reference Pull, Ambitious Alternatives, and Ruthless Minimum Slice evidence when mode/risk warrants it.",
|
|
53
55
|
"**Decision-driver contract** — list weighted decision drivers (value, risk, reversibility, effort, timeline) and score candidate scope moves so the selected mode and boundaries are evidence-backed, not preference-led.",
|
|
54
56
|
"**Compare implementation alternatives** — include minimum viable, product-grade, and ideal architecture options with effort (S/M/L/XL), risk (Low/Med/High), pros, cons, and reuses. Recommend one and tie it to mode.",
|
|
@@ -58,9 +60,11 @@ export const SCOPE = {
|
|
|
58
60
|
"**Write the scope contract after approval** — include selected mode, in scope, out of scope, requirements, locked decisions, discretion areas, deferred ideas, accepted/rejected reference ideas, success definition, design handoff, completion dashboard, and explicit approval evidence."
|
|
59
61
|
],
|
|
60
62
|
interactionProtocol: [
|
|
63
|
+
"\"Strong success criteria let you loop independently. Weak criteria require constant clarification.\"",
|
|
61
64
|
decisionProtocolInstruction("scope mode selection", "present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended)", "recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce"),
|
|
65
|
+
"Run the shared adaptive elicitation cycle from `.cclaw/skills/adaptive-elicitation/SKILL.md`, including stop-signal handling (RU/EN/UA), smart-skip, conditional grilling triggers, and append-only `## Q&A Log` updates.",
|
|
62
66
|
"Do not walk the full checklist by default. Lead with a proposed scope contract, selected depth (`lite`/`standard`/`deep`), and the one decision that matters most; label the mode as recommended, not selected, until the user answers.",
|
|
63
|
-
"For low-risk concrete asks, keep the proposal compact but still explicit: recommend (do not auto-select) one mode, show exact in/out/deferred boundaries, and
|
|
67
|
+
"For low-risk concrete asks, keep the proposal compact but still explicit: recommend (do not auto-select) one mode, show exact in/out/deferred boundaries, and request explicit approval before finalizing the artifact or completing the stage.",
|
|
64
68
|
"Challenge premise first, take a firm position, and name one concrete condition that would change it.",
|
|
65
69
|
"Push back on weak framing: vague scope needs a specific user/problem, platform vision needs a narrow wedge, social proof needs behavioral evidence.",
|
|
66
70
|
"Resolve one structural scope issue at a time. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope boundary, architecture commitment, security, data loss, public API, migration, auth/pricing, or required user approval.",
|
|
@@ -90,7 +90,7 @@ ${conversationLanguagePolicyMarkdown()}
|
|
|
90
90
|
If the harness's native ask tool is available (\`AskUserQuestion\` / \`AskQuestion\` / \`question\` / \`request_user_input\`), send exactly ONE question; on schema error, fall back to a plain-text lettered list.
|
|
91
91
|
10. Start the tracked flow only through the managed helper:
|
|
92
92
|
\`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`
|
|
93
|
-
If this helper fails, STOP and
|
|
93
|
+
If this helper fails, STOP. Report one human-readable failure line from the JSON \`error\` field, include the helper JSON payload in a fenced \`json\` block, and never echo the invoking command line. Do **not** manually edit \`${flowPath}\`.
|
|
94
94
|
11. The helper persists \`${flowPath}\`, computes \`skippedStages\`, sets the first stage for the track, resets the gate catalog, and writes \`.cclaw/artifacts/00-idea.md\`.
|
|
95
95
|
12. Load the **first-stage skill for the chosen track** and its command file:
|
|
96
96
|
- quick → \`.cclaw/skills/spec/SKILL.md\`
|
|
@@ -105,7 +105,7 @@ If during any stage the agent discovers evidence that contradicts the initial Ph
|
|
|
105
105
|
1. Surface the new evidence in plain text.
|
|
106
106
|
2. Propose the updated \`Class\` + \`Track\` with a one-line reason.
|
|
107
107
|
3. Use the Decision Protocol to let the user accept, override, or cancel.
|
|
108
|
-
4. On acceptance: run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --class=<new-class> --reason=<why>\`. The helper appends a \`Reclassification:\` entry to \`00-idea.md\` and updates flow state atomically. If it fails, STOP and report the
|
|
108
|
+
4. On acceptance: run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --class=<new-class> --reason=<why>\`. The helper appends a \`Reclassification:\` entry to \`00-idea.md\` and updates flow state atomically. If it fails, STOP and report one human-readable line plus the helper JSON payload in a fenced \`json\` block; never echo the invoking command line. Do NOT manually edit \`flow-state.json\`.
|
|
109
109
|
|
|
110
110
|
### Without prompt (\`/cc\`)
|
|
111
111
|
|
|
@@ -187,12 +187,12 @@ ${conversationLanguagePolicyMarkdown()}
|
|
|
187
187
|
|
|
188
188
|
- On conflict, prefer \`standard\` over \`medium\`, and \`medium\` over \`quick\`.
|
|
189
189
|
- Always state the recommendation as a one-line reason citing matched triggers and a high/medium/low track selection confidence. Clarify that the heuristic is advisory until the managed helper writes state; after that, \`/cc\` follows the selected track. Include override guidance: switch to standard when architecture, schema, migration, security, or unclear scope appears; switch to medium when product framing is needed but architecture is known.
|
|
190
|
-
8. Run the managed start helper: \`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`. The helper writes \`${flowPath}\`, computes \`skippedStages\`, resets the gate catalog, and writes \`${RUNTIME_ROOT}/artifacts/00-idea.md\`. If it fails, STOP and
|
|
190
|
+
8. Run the managed start helper: \`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`. The helper writes \`${flowPath}\`, computes \`skippedStages\`, resets the gate catalog, and writes \`${RUNTIME_ROOT}/artifacts/00-idea.md\`. If it fails, STOP, report one human-readable failure line from the JSON \`error\` field, and include the helper JSON payload in a fenced \`json\` block; do not echo the invoking command line, and do not manually edit flow state.
|
|
191
191
|
9. Load and execute the **first stage skill of the chosen track** (\`brainstorm\` for medium/standard, \`spec\` for quick) plus its matching command file.
|
|
192
192
|
|
|
193
193
|
### Reclassification on discovery
|
|
194
194
|
|
|
195
|
-
If mid-stage evidence contradicts the initial Class/Track decision (the "trivial" change needs a migration, the "quick" bug fix needs architecture work, an origin doc multiplies scope), STOP and re-classify using the Decision Protocol. On acceptance, run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --class=<new-class> --reason=<why>\`; the helper records \`Reclassification:\` in \`00-idea.md\` and updates state atomically.
|
|
195
|
+
If mid-stage evidence contradicts the initial Class/Track decision (the "trivial" change needs a migration, the "quick" bug fix needs architecture work, an origin doc multiplies scope), STOP and re-classify using the Decision Protocol. On acceptance, run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --class=<new-class> --reason=<why>\`; the helper records \`Reclassification:\` in \`00-idea.md\` and updates state atomically. If it fails, report one human-readable line plus the helper JSON payload in a fenced \`json\` block, never echo the invoking command line, and do not rewrite prior artifacts or manually edit flow-state.
|
|
196
196
|
|
|
197
197
|
### Path B: \`/cc\` (no arguments)
|
|
198
198
|
|
|
@@ -76,6 +76,13 @@ export const ARTIFACT_TEMPLATES = {
|
|
|
76
76
|
|---|---|---|---|
|
|
77
77
|
| 1 | | | |
|
|
78
78
|
|
|
79
|
+
## Q&A Log
|
|
80
|
+
| Turn | Question | User answer (1-line) | Decision impact |
|
|
81
|
+
|---|---|---|---|
|
|
82
|
+
| 1 | | | |
|
|
83
|
+
|
|
84
|
+
> Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
|
|
85
|
+
|
|
79
86
|
## Approach Tier
|
|
80
87
|
- Tier: lite | standard | deep
|
|
81
88
|
- Why this tier:
|
|
@@ -192,6 +199,13 @@ ${MARKDOWN_CODE_FENCE}
|
|
|
192
199
|
- Open questions:
|
|
193
200
|
- Drift from upstream (or \`None\`):
|
|
194
201
|
|
|
202
|
+
## Q&A Log
|
|
203
|
+
| Turn | Question | User answer (1-line) | Decision impact |
|
|
204
|
+
|---|---|---|---|
|
|
205
|
+
| 1 | | | |
|
|
206
|
+
|
|
207
|
+
> Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
|
|
208
|
+
|
|
195
209
|
## Pre-Scope System Audit
|
|
196
210
|
| Check | Command | Findings |
|
|
197
211
|
|---|---|---|
|
|
@@ -427,6 +441,13 @@ ${MARKDOWN_CODE_FENCE}
|
|
|
427
441
|
- Open questions:
|
|
428
442
|
- Drift from upstream (or \`None\`):
|
|
429
443
|
|
|
444
|
+
## Q&A Log
|
|
445
|
+
| Turn | Question | User answer (1-line) | Decision impact |
|
|
446
|
+
|---|---|---|---|
|
|
447
|
+
| 1 | | | |
|
|
448
|
+
|
|
449
|
+
> Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
|
|
450
|
+
|
|
430
451
|
## Codebase Investigation
|
|
431
452
|
| File | Current responsibility | Patterns discovered | Existing fit / reuse candidate |
|
|
432
453
|
|---|---|---|---|
|
package/dist/flow-state.d.ts
CHANGED
|
@@ -82,11 +82,18 @@ export interface FlowState {
|
|
|
82
82
|
staleStages: Partial<Record<FlowStage, StaleStageMarker>>;
|
|
83
83
|
/** Chronological rewind operations for the active run. */
|
|
84
84
|
rewinds: RewindRecord[];
|
|
85
|
+
/** Optional per-stage interaction hints carried from prior stage transitions. */
|
|
86
|
+
interactionHints?: Partial<Record<FlowStage, StageInteractionHint>>;
|
|
85
87
|
/** Mandatory retrospective gate status before archive. */
|
|
86
88
|
retro: RetroState;
|
|
87
89
|
/** Ship → post_ship_review → archive substate for resumable closeout. */
|
|
88
90
|
closeout: CloseoutState;
|
|
89
91
|
}
|
|
92
|
+
export interface StageInteractionHint {
|
|
93
|
+
skipQuestions?: boolean;
|
|
94
|
+
sourceStage?: FlowStage;
|
|
95
|
+
recordedAt?: string;
|
|
96
|
+
}
|
|
90
97
|
export interface InitialFlowStateOptions {
|
|
91
98
|
activeRunId?: string;
|
|
92
99
|
track?: FlowTrack;
|
package/dist/flow-state.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "cclaw://hooks/claude/v1",
|
|
4
4
|
"harness": "claude",
|
|
5
|
-
"schemaVersion":
|
|
5
|
+
"schemaVersion": 2,
|
|
6
6
|
"requiredEvents": [
|
|
7
7
|
"SessionStart",
|
|
8
8
|
"PreToolUse",
|
|
9
9
|
"PostToolUse",
|
|
10
|
-
"Stop"
|
|
11
|
-
"PreCompact"
|
|
10
|
+
"Stop"
|
|
12
11
|
]
|
|
13
12
|
}
|
package/dist/install.js
CHANGED
|
@@ -20,6 +20,7 @@ import { ARTIFACT_TEMPLATES, CURSOR_WORKFLOW_RULE_MDC, RULEBOOK_MARKDOWN, buildR
|
|
|
20
20
|
import { STATE_CONTRACTS } from "./content/state-contracts.js";
|
|
21
21
|
import { REVIEW_PROMPTS } from "./content/review-prompts.js";
|
|
22
22
|
import { stageSkillFolder, stageSkillMarkdown, executingWavesSkillMarkdown } from "./content/skills.js";
|
|
23
|
+
import { adaptiveElicitationSkillMarkdown } from "./content/skills-elicitation.js";
|
|
23
24
|
import { LANGUAGE_RULE_PACK_DIR, LANGUAGE_RULE_PACK_FILES, LANGUAGE_RULE_PACK_GENERATORS, LEGACY_LANGUAGE_RULE_PACK_FOLDERS } from "./content/utility-skills.js";
|
|
24
25
|
import { RESEARCH_PLAYBOOKS } from "./content/research-playbooks.js";
|
|
25
26
|
import { SUBAGENT_CONTEXT_SKILLS } from "./content/subagent-context-skills.js";
|
|
@@ -490,6 +491,7 @@ async function writeSkills(projectRoot, config) {
|
|
|
490
491
|
await writeFileSafe(runtimePath(projectRoot, "skills", "session", "SKILL.md"), sessionHooksSkillMarkdown());
|
|
491
492
|
await writeFileSafe(runtimePath(projectRoot, "skills", "iron-laws", "SKILL.md"), ironLawsSkillMarkdown());
|
|
492
493
|
await writeFileSafe(runtimePath(projectRoot, "skills", "executing-waves", "SKILL.md"), executingWavesSkillMarkdown());
|
|
494
|
+
await writeFileSafe(runtimePath(projectRoot, "skills", "adaptive-elicitation", "SKILL.md"), adaptiveElicitationSkillMarkdown());
|
|
493
495
|
await writeFileSafe(runtimePath(projectRoot, "skills", META_SKILL_NAME, "SKILL.md"), usingCclawSkillMarkdown());
|
|
494
496
|
// In-thread research procedures (no YAML frontmatter, not delegated personas).
|
|
495
497
|
for (const [fileName, markdown] of Object.entries(RESEARCH_PLAYBOOKS)) {
|
|
@@ -1080,8 +1082,13 @@ async function syncDisabledHarnessArtifacts(projectRoot, harnesses) {
|
|
|
1080
1082
|
}
|
|
1081
1083
|
}
|
|
1082
1084
|
async function writeState(projectRoot, config, forceReset = false) {
|
|
1085
|
+
// Fresh init no longer materializes flow-state.json. The first managed
|
|
1086
|
+
// `/cc <idea>` start-flow call creates the state file.
|
|
1087
|
+
if (!forceReset) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1083
1090
|
const statePath = runtimePath(projectRoot, "state", "flow-state.json");
|
|
1084
|
-
if (
|
|
1091
|
+
if (await exists(statePath)) {
|
|
1085
1092
|
return;
|
|
1086
1093
|
}
|
|
1087
1094
|
const state = createInitialFlowState({ track: config.defaultTrack ?? "standard" });
|
|
@@ -1294,7 +1301,9 @@ export async function initCclaw(options) {
|
|
|
1294
1301
|
// and only appear in the on-disk file when the user sets them explicitly
|
|
1295
1302
|
// or a non-default value was detected (e.g. languageRulePacks).
|
|
1296
1303
|
await writeConfig(options.projectRoot, config, { mode: "minimal" });
|
|
1297
|
-
|
|
1304
|
+
// Init should scaffold runtime surfaces but leave flow-state creation to the
|
|
1305
|
+
// first managed start-flow invocation.
|
|
1306
|
+
await materializeRuntime(options.projectRoot, config, false, "init");
|
|
1298
1307
|
}
|
|
1299
1308
|
export async function syncCclaw(projectRoot, options = {}) {
|
|
1300
1309
|
if (options.harnesses !== undefined && options.harnesses.length === 0) {
|
|
@@ -1418,7 +1427,7 @@ function isManagedRuntimeHookCommand(command) {
|
|
|
1418
1427
|
// (e.g. `node .cclaw\hooks\run-hook.mjs ...`) still round-trip through
|
|
1419
1428
|
// sync without being duplicated alongside freshly generated entries.
|
|
1420
1429
|
const normalized = command.trim().replace(/\s+/gu, " ").replace(/\\/gu, "/");
|
|
1421
|
-
if (/(^|\s)(?:node\s+)?(?:"|')?(?:\.\/)?\.cclaw\/hooks\/run-hook\.(?:mjs|cmd)(?:"|')?\s+(?:session-start|stop-handoff|stop-checkpoint|pre-compact|prompt-guard|workflow-guard|context-monitor|verify-current-state)(?:\s|$)/u.test(normalized)) {
|
|
1430
|
+
if (/(^|\s)(?:node\s+)?(?:"|')?(?:\.\/)?\.cclaw\/hooks\/run-hook\.(?:mjs|cmd)(?:"|')?\s+(?:session-start|stop-handoff|stop-checkpoint|pre-compact|prompt-guard|workflow-guard|pre-tool-pipeline|prompt-pipeline|context-monitor|verify-current-state)(?:\s|$)/u.test(normalized)) {
|
|
1422
1431
|
return true;
|
|
1423
1432
|
}
|
|
1424
1433
|
// Codex UserPromptSubmit non-blocking state nudge.
|
|
@@ -40,6 +40,23 @@ function resolveSuccessorTransition(stage, track, transitionTargets, satisfiedGu
|
|
|
40
40
|
}
|
|
41
41
|
return natural;
|
|
42
42
|
}
|
|
43
|
+
function nextInteractionHints(flowState, args, successor) {
|
|
44
|
+
const hints = { ...(flowState.interactionHints ?? {}) };
|
|
45
|
+
delete hints[args.stage];
|
|
46
|
+
if (successor) {
|
|
47
|
+
if (args.skipQuestions) {
|
|
48
|
+
hints[successor] = {
|
|
49
|
+
skipQuestions: true,
|
|
50
|
+
sourceStage: args.stage,
|
|
51
|
+
recordedAt: new Date().toISOString()
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
delete hints[successor];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return hints;
|
|
59
|
+
}
|
|
43
60
|
export async function hydrateReviewLoopEvidenceFromArtifact(projectRoot, stage, track, selectedGateIds, evidenceByGate) {
|
|
44
61
|
const gateId = AUTO_REVIEW_LOOP_GATE_BY_STAGE[stage];
|
|
45
62
|
if (!gateId)
|
|
@@ -243,6 +260,7 @@ export async function runAdvanceStage(projectRoot, args, io) {
|
|
|
243
260
|
mode: "mandatory",
|
|
244
261
|
status: "waived",
|
|
245
262
|
waiverReason,
|
|
263
|
+
runId: flowState.activeRunId,
|
|
246
264
|
fulfillmentMode: "role-switch",
|
|
247
265
|
ts: new Date().toISOString()
|
|
248
266
|
});
|
|
@@ -452,10 +470,12 @@ export async function runAdvanceStage(projectRoot, args, io) {
|
|
|
452
470
|
: flowState.completedStages.includes(args.stage)
|
|
453
471
|
? [...flowState.completedStages]
|
|
454
472
|
: [...flowState.completedStages, args.stage];
|
|
473
|
+
const interactionHints = nextInteractionHints(flowState, args, successor);
|
|
455
474
|
const finalState = {
|
|
456
475
|
...candidateState,
|
|
457
476
|
completedStages,
|
|
458
|
-
currentStage: successor ?? args.stage
|
|
477
|
+
currentStage: successor ?? args.stage,
|
|
478
|
+
interactionHints
|
|
459
479
|
};
|
|
460
480
|
await writeFlowState(projectRoot, finalState);
|
|
461
481
|
if (!args.quiet) {
|
|
@@ -466,6 +486,7 @@ export async function runAdvanceStage(projectRoot, args, io) {
|
|
|
466
486
|
nextStage: successor,
|
|
467
487
|
currentStage: finalState.currentStage,
|
|
468
488
|
completedStages: finalState.completedStages,
|
|
489
|
+
skipQuestionsHint: args.skipQuestions,
|
|
469
490
|
learnings: {
|
|
470
491
|
parsed: learningsHarvest.parsedEntries,
|
|
471
492
|
appended: learningsHarvest.appendedEntries,
|
|
@@ -12,6 +12,7 @@ export function parseAdvanceStageArgs(tokens) {
|
|
|
12
12
|
let waiverReason;
|
|
13
13
|
let acceptProactiveWaiver = false;
|
|
14
14
|
let acceptProactiveWaiverReason;
|
|
15
|
+
let skipQuestions = false;
|
|
15
16
|
let quiet = false;
|
|
16
17
|
let json = false;
|
|
17
18
|
for (let i = 0; i < flagTokens.length; i += 1) {
|
|
@@ -80,6 +81,10 @@ export function parseAdvanceStageArgs(tokens) {
|
|
|
80
81
|
acceptProactiveWaiver = true;
|
|
81
82
|
continue;
|
|
82
83
|
}
|
|
84
|
+
if (token === "--skip-questions") {
|
|
85
|
+
skipQuestions = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
83
88
|
if (token === "--accept-proactive-waiver-reason") {
|
|
84
89
|
if (!nextToken || nextToken.startsWith("--")) {
|
|
85
90
|
throw new Error("--accept-proactive-waiver-reason requires a text value.");
|
|
@@ -102,6 +107,7 @@ export function parseAdvanceStageArgs(tokens) {
|
|
|
102
107
|
waiverReason,
|
|
103
108
|
acceptProactiveWaiver,
|
|
104
109
|
acceptProactiveWaiverReason,
|
|
110
|
+
skipQuestions,
|
|
105
111
|
quiet,
|
|
106
112
|
json
|
|
107
113
|
};
|
|
@@ -42,5 +42,5 @@ export declare function flowStateLockPathFor(projectRoot: string): string;
|
|
|
42
42
|
interface EnsureRunSystemOptions {
|
|
43
43
|
createIfMissing?: boolean;
|
|
44
44
|
}
|
|
45
|
-
export declare function ensureRunSystem(projectRoot: string,
|
|
45
|
+
export declare function ensureRunSystem(projectRoot: string, options?: EnsureRunSystemOptions): Promise<FlowState>;
|
|
46
46
|
export {};
|
package/dist/run-persistence.js
CHANGED
|
@@ -232,6 +232,31 @@ function sanitizeRewinds(value) {
|
|
|
232
232
|
}
|
|
233
233
|
return out;
|
|
234
234
|
}
|
|
235
|
+
function sanitizeInteractionHints(value) {
|
|
236
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
237
|
+
return {};
|
|
238
|
+
}
|
|
239
|
+
const out = {};
|
|
240
|
+
for (const [stage, raw] of Object.entries(value)) {
|
|
241
|
+
if (!isFlowStage(stage))
|
|
242
|
+
continue;
|
|
243
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
244
|
+
continue;
|
|
245
|
+
const typed = raw;
|
|
246
|
+
const skipQuestions = typed.skipQuestions === true ? true : undefined;
|
|
247
|
+
const sourceStage = isFlowStage(typed.sourceStage) ? typed.sourceStage : undefined;
|
|
248
|
+
const recordedAt = typeof typed.recordedAt === "string" ? typed.recordedAt : undefined;
|
|
249
|
+
if (skipQuestions !== true && !sourceStage && !recordedAt) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
out[stage] = {
|
|
253
|
+
...(skipQuestions ? { skipQuestions } : {}),
|
|
254
|
+
...(sourceStage ? { sourceStage } : {}),
|
|
255
|
+
...(recordedAt ? { recordedAt } : {})
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
235
260
|
function sanitizeRetroState(value) {
|
|
236
261
|
const fallback = {
|
|
237
262
|
required: false,
|
|
@@ -328,6 +353,7 @@ function coerceFlowState(parsed) {
|
|
|
328
353
|
skippedStages: sanitizeSkippedStages(parsed.skippedStages, track),
|
|
329
354
|
staleStages: sanitizeStaleStages(parsed.staleStages),
|
|
330
355
|
rewinds: sanitizeRewinds(parsed.rewinds),
|
|
356
|
+
interactionHints: sanitizeInteractionHints(parsed.interactionHints),
|
|
331
357
|
retro: sanitizeRetroState(parsed.retro),
|
|
332
358
|
closeout: sanitizeCloseoutState(parsed.closeout)
|
|
333
359
|
};
|
|
@@ -432,12 +458,13 @@ export async function writeFlowState(projectRoot, state, options = {}) {
|
|
|
432
458
|
export function flowStateLockPathFor(projectRoot) {
|
|
433
459
|
return flowStateLockPath(projectRoot);
|
|
434
460
|
}
|
|
435
|
-
export async function ensureRunSystem(projectRoot,
|
|
461
|
+
export async function ensureRunSystem(projectRoot, options = {}) {
|
|
436
462
|
await ensureDir(archiveRoot(projectRoot));
|
|
437
463
|
await ensureDir(activeArtifactsPath(projectRoot));
|
|
438
464
|
const statePath = flowStatePath(projectRoot);
|
|
439
465
|
const state = await readFlowState(projectRoot);
|
|
440
|
-
|
|
466
|
+
const createIfMissing = options.createIfMissing !== false;
|
|
467
|
+
if (createIfMissing && !(await exists(statePath))) {
|
|
441
468
|
await writeFlowState(projectRoot, state, { allowReset: true });
|
|
442
469
|
}
|
|
443
470
|
return state;
|