cclaw-cli 0.11.0 → 0.12.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 +4 -3
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +297 -9
- package/dist/content/core-agents.d.ts +44 -0
- package/dist/content/core-agents.js +225 -0
- package/dist/content/doctor-references.d.ts +2 -0
- package/dist/content/doctor-references.js +144 -0
- package/dist/content/examples.js +1 -1
- package/dist/content/harnesses-doc.d.ts +1 -0
- package/dist/content/harnesses-doc.js +95 -0
- package/dist/content/hook-events.d.ts +4 -0
- package/dist/content/hook-events.js +42 -0
- package/dist/content/protocols.js +34 -6
- package/dist/content/research-playbooks.d.ts +8 -0
- package/dist/content/research-playbooks.js +135 -0
- package/dist/content/skills.js +20 -0
- package/dist/content/stage-schema.d.ts +3 -1
- package/dist/content/stage-schema.js +20 -51
- package/dist/content/subagents.d.ts +1 -1
- package/dist/content/subagents.js +23 -38
- package/dist/content/templates.d.ts +1 -1
- package/dist/content/templates.js +49 -11
- package/dist/delegation.d.ts +1 -0
- package/dist/delegation.js +27 -1
- package/dist/doctor-registry.d.ts +8 -0
- package/dist/doctor-registry.js +127 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.js +112 -4
- package/dist/harness-adapters.d.ts +7 -0
- package/dist/harness-adapters.js +53 -9
- package/dist/init-detect.d.ts +2 -0
- package/dist/init-detect.js +45 -0
- package/dist/install.js +63 -1
- package/dist/policy.js +5 -0
- package/package.json +2 -1
- package/dist/content/agents.d.ts +0 -48
- package/dist/content/agents.js +0 -411
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { RUNTIME_ROOT } from "../constants.js";
|
|
2
|
+
export const DOCTOR_REFERENCE_DIR = `${RUNTIME_ROOT}/references/doctor`;
|
|
3
|
+
export const DOCTOR_REFERENCE_MARKDOWN = {
|
|
4
|
+
"README.md": `# Doctor Reference Index
|
|
5
|
+
|
|
6
|
+
Reference docs for \`cclaw doctor\` checks.
|
|
7
|
+
|
|
8
|
+
## Categories
|
|
9
|
+
|
|
10
|
+
- \`runtime-layout.md\` - runtime directories, generated commands, and skill files
|
|
11
|
+
- \`hooks-and-lifecycle.md\` - hook wiring and harness lifecycle integration
|
|
12
|
+
- \`harness-and-routing.md\` - harness shims, AGENTS/CLAUDE routing blocks, cursor rule
|
|
13
|
+
- \`state-and-gates.md\` - flow-state integrity and gate evidence contracts
|
|
14
|
+
- \`delegation-and-preamble.md\` - mandatory delegations and preamble budget controls
|
|
15
|
+
- \`traceability.md\` - spec/plan/tdd trace matrix expectations
|
|
16
|
+
- \`tooling-capabilities.md\` - local runtime prerequisites (bash/node/python/jq)
|
|
17
|
+
- \`config-and-policy.md\` - config schema, rules policy, and validation references
|
|
18
|
+
`,
|
|
19
|
+
"runtime-layout.md": `# Runtime Layout
|
|
20
|
+
|
|
21
|
+
## Expected surfaces
|
|
22
|
+
|
|
23
|
+
- \`.cclaw/\` root and generated subdirectories
|
|
24
|
+
- stage command contracts under \`.cclaw/commands/\`
|
|
25
|
+
- stage skills under \`.cclaw/skills/\`
|
|
26
|
+
- utility command contracts (\`start\`, \`next\`, \`learn\`, \`status\`)
|
|
27
|
+
- state files under \`.cclaw/state/\`
|
|
28
|
+
|
|
29
|
+
## Typical fixes
|
|
30
|
+
|
|
31
|
+
1. Run \`cclaw sync\` to re-materialize generated assets.
|
|
32
|
+
2. If runtime is severely drifted, run \`cclaw upgrade\`.
|
|
33
|
+
3. Avoid manual edits under generated runtime paths unless explicitly supported.
|
|
34
|
+
`,
|
|
35
|
+
"hooks-and-lifecycle.md": `# Hooks And Lifecycle
|
|
36
|
+
|
|
37
|
+
## Expected behavior
|
|
38
|
+
|
|
39
|
+
- session start rehydrates flow + knowledge digest
|
|
40
|
+
- pre-tool hooks run prompt/workflow guards
|
|
41
|
+
- post-tool hooks run context monitor
|
|
42
|
+
- stop hooks checkpoint progress
|
|
43
|
+
- OpenCode uses plugin-based lifecycle integration
|
|
44
|
+
|
|
45
|
+
## Typical fixes
|
|
46
|
+
|
|
47
|
+
1. Re-run \`cclaw sync\` after harness config changes.
|
|
48
|
+
2. Ensure harness is enabled in \`.cclaw/config.yaml\`.
|
|
49
|
+
3. Validate hook JSON shape and remove malformed manual edits.
|
|
50
|
+
`,
|
|
51
|
+
"harness-and-routing.md": `# Harness And Routing
|
|
52
|
+
|
|
53
|
+
## Expected behavior
|
|
54
|
+
|
|
55
|
+
- command shims exist for every enabled harness
|
|
56
|
+
- managed routing block is present in \`AGENTS.md\` (and \`CLAUDE.md\` when applicable)
|
|
57
|
+
- cursor rule mirrors workflow activation guidance
|
|
58
|
+
- opencode plugin path is registered in opencode config
|
|
59
|
+
|
|
60
|
+
## Typical fixes
|
|
61
|
+
|
|
62
|
+
1. Confirm \`harnesses\` list in \`.cclaw/config.yaml\`.
|
|
63
|
+
2. Run \`cclaw sync\` to re-generate shims/routing files.
|
|
64
|
+
3. Remove stale harness artifacts for disabled harnesses via \`cclaw sync\`.
|
|
65
|
+
`,
|
|
66
|
+
"state-and-gates.md": `# State And Gates
|
|
67
|
+
|
|
68
|
+
## Expected behavior
|
|
69
|
+
|
|
70
|
+
- \`flow-state.json\` has activeRunId, current stage, and consistent track/skippedStages
|
|
71
|
+
- current-stage gate evidence is internally consistent
|
|
72
|
+
- completed stages only include passed required gates
|
|
73
|
+
|
|
74
|
+
## Typical fixes
|
|
75
|
+
|
|
76
|
+
1. Run \`cclaw doctor --reconcile-gates\` to refresh current-stage gate catalog.
|
|
77
|
+
2. Repair inconsistent stage artifacts, then re-run doctor.
|
|
78
|
+
3. Do not manually mutate gate arrays without matching artifact evidence.
|
|
79
|
+
`,
|
|
80
|
+
"delegation-and-preamble.md": `# Delegation And Preamble
|
|
81
|
+
|
|
82
|
+
## Delegation contract
|
|
83
|
+
|
|
84
|
+
- mandatory delegations for the current stage must be completed or waived
|
|
85
|
+
- waivers should include an explicit reason
|
|
86
|
+
- stale entries from previous runs are ignored by current-run checks
|
|
87
|
+
|
|
88
|
+
## Preamble budget contract
|
|
89
|
+
|
|
90
|
+
- preamble events are logged to \`.cclaw/state/preamble-log.jsonl\`
|
|
91
|
+
- repeated entries inside cooldown windows indicate noisy preamble behavior
|
|
92
|
+
- in TDD wave mode, emit once per wave unless plan materially changes
|
|
93
|
+
|
|
94
|
+
## Typical fixes
|
|
95
|
+
|
|
96
|
+
1. Append missing delegation records with \`completed\` or \`waived\` status.
|
|
97
|
+
2. Record harness-limitation waivers when native delegation is unavailable.
|
|
98
|
+
3. Reduce repeated preamble emissions and keep logs structured (\`ts/stage/trigger/hash\`).
|
|
99
|
+
`,
|
|
100
|
+
"traceability.md": `# Traceability
|
|
101
|
+
|
|
102
|
+
## Expected behavior
|
|
103
|
+
|
|
104
|
+
- spec criteria map to plan tasks
|
|
105
|
+
- plan tasks map to tdd slices/tests
|
|
106
|
+
- no orphaned criteria/tasks/tests when downstream artifacts exist
|
|
107
|
+
|
|
108
|
+
## Typical fixes
|
|
109
|
+
|
|
110
|
+
1. Add stable IDs to spec/plan/tdd sections.
|
|
111
|
+
2. Ensure mapping tables include every active criterion/task/slice.
|
|
112
|
+
3. Re-run \`cclaw doctor\` after artifact updates.
|
|
113
|
+
`,
|
|
114
|
+
"tooling-capabilities.md": `# Tooling Capabilities
|
|
115
|
+
|
|
116
|
+
## Required
|
|
117
|
+
|
|
118
|
+
- \`bash\` for runtime hook scripts
|
|
119
|
+
- \`node\` for generated runtime scripts/plugins
|
|
120
|
+
|
|
121
|
+
## Optional fallback
|
|
122
|
+
|
|
123
|
+
- at least one of \`python3\` or \`jq\` for JSON parsing fallback paths
|
|
124
|
+
|
|
125
|
+
## Typical fixes
|
|
126
|
+
|
|
127
|
+
1. Install missing runtime tools.
|
|
128
|
+
2. Keep at least one JSON fallback parser available (\`python3\` or \`jq\`).
|
|
129
|
+
`,
|
|
130
|
+
"config-and-policy.md": `# Config And Policy
|
|
131
|
+
|
|
132
|
+
## Expected behavior
|
|
133
|
+
|
|
134
|
+
- \`.cclaw/config.yaml\` parses and uses supported keys/values
|
|
135
|
+
- \`.cclaw/rules/rules.json\` matches generated policy schema
|
|
136
|
+
- policy needles and required sections remain present in generated contracts
|
|
137
|
+
|
|
138
|
+
## Typical fixes
|
|
139
|
+
|
|
140
|
+
1. Repair invalid config values and run \`cclaw sync\`.
|
|
141
|
+
2. Re-generate policy files via \`cclaw sync\` if drift is detected.
|
|
142
|
+
3. Keep generated contracts aligned with stage schemas and policy needles.
|
|
143
|
+
`
|
|
144
|
+
};
|
package/dist/content/examples.js
CHANGED
|
@@ -379,7 +379,7 @@ Execution rule: complete and verify each wave before starting the next wave.
|
|
|
379
379
|
## Review Army Contract
|
|
380
380
|
|
|
381
381
|
- See \`07-review-army.json\`
|
|
382
|
-
- Reconciliation summary: 1 duplicate collapsed (R-1 reported by
|
|
382
|
+
- Reconciliation summary: 1 duplicate collapsed (R-1 reported by reviewer and security-reviewer), 0 conflicts
|
|
383
383
|
|
|
384
384
|
## Review Readiness Dashboard
|
|
385
385
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function harnessIntegrationDocMarkdown(): string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { HARNESS_ADAPTERS, harnessTier } from "../harness-adapters.js";
|
|
2
|
+
import { HOOK_EVENTS_BY_HARNESS, HOOK_SEMANTIC_EVENTS } from "./hook-events.js";
|
|
3
|
+
function harnessTitle(harness) {
|
|
4
|
+
switch (harness) {
|
|
5
|
+
case "claude":
|
|
6
|
+
return "Claude Code";
|
|
7
|
+
case "cursor":
|
|
8
|
+
return "Cursor";
|
|
9
|
+
case "opencode":
|
|
10
|
+
return "OpenCode";
|
|
11
|
+
case "codex":
|
|
12
|
+
return "OpenAI Codex";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function tierDescription(tier) {
|
|
16
|
+
if (tier === "tier1")
|
|
17
|
+
return "full native automation";
|
|
18
|
+
if (tier === "tier2")
|
|
19
|
+
return "partial automation with waivers";
|
|
20
|
+
return "manual fallback only";
|
|
21
|
+
}
|
|
22
|
+
export function harnessIntegrationDocMarkdown() {
|
|
23
|
+
const harnesses = Object.keys(HARNESS_ADAPTERS);
|
|
24
|
+
const capabilityRows = harnesses
|
|
25
|
+
.map((harness) => {
|
|
26
|
+
const adapter = HARNESS_ADAPTERS[harness];
|
|
27
|
+
const tier = harnessTier(harness);
|
|
28
|
+
return `| ${harnessTitle(harness)} | \`${harness}\` | \`${tier}\` (${tierDescription(tier)}) | ${adapter.capabilities.nativeSubagentDispatch} | ${adapter.capabilities.hookSurface} | ${adapter.capabilities.structuredAsk} |`;
|
|
29
|
+
})
|
|
30
|
+
.join("\n");
|
|
31
|
+
const hookRows = HOOK_SEMANTIC_EVENTS.map((eventName) => {
|
|
32
|
+
const columns = harnesses
|
|
33
|
+
.map((harness) => {
|
|
34
|
+
const mapping = HOOK_EVENTS_BY_HARNESS[harness][eventName];
|
|
35
|
+
return mapping ?? "missing";
|
|
36
|
+
})
|
|
37
|
+
.join(" | ");
|
|
38
|
+
return `| \`${eventName}\` | ${columns} |`;
|
|
39
|
+
}).join("\n");
|
|
40
|
+
return `# Harness Integration Matrix
|
|
41
|
+
|
|
42
|
+
Generated from \`src/harness-adapters.ts\` capabilities and hook event mappings.
|
|
43
|
+
|
|
44
|
+
## Capability tiers
|
|
45
|
+
|
|
46
|
+
| Harness | ID | Tier | Native subagent dispatch | Hook surface | Structured ask |
|
|
47
|
+
|---|---|---|---|---|---|
|
|
48
|
+
${capabilityRows}
|
|
49
|
+
|
|
50
|
+
## Semantic hook event coverage
|
|
51
|
+
|
|
52
|
+
| Event | Claude | Cursor | OpenCode | Codex |
|
|
53
|
+
|---|---|---|---|---|
|
|
54
|
+
${hookRows}
|
|
55
|
+
|
|
56
|
+
## Interpretation
|
|
57
|
+
|
|
58
|
+
- \`tier1\`: full native delegation + structured asks + full hook surface.
|
|
59
|
+
- \`tier2\`: usable flow with capability gaps; mandatory delegation can require waivers.
|
|
60
|
+
- \`tier3\`: manual-only fallback; no native automation guarantees.
|
|
61
|
+
|
|
62
|
+
## Shared command contract
|
|
63
|
+
|
|
64
|
+
All harnesses receive the same utility commands:
|
|
65
|
+
|
|
66
|
+
- \`/cc\` - flow entry and resume
|
|
67
|
+
- \`/cc-next\` - stage progression
|
|
68
|
+
- \`/cc-learn\` - knowledge capture/lookup
|
|
69
|
+
|
|
70
|
+
Stage order remains canonical:
|
|
71
|
+
\`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
|
|
72
|
+
|
|
73
|
+
## Install surfaces
|
|
74
|
+
|
|
75
|
+
Always generated:
|
|
76
|
+
|
|
77
|
+
- \`.cclaw/commands/*.md\`
|
|
78
|
+
- \`.cclaw/skills/*/SKILL.md\`
|
|
79
|
+
- \`.cclaw/references/**\`
|
|
80
|
+
- \`.cclaw/state/*.json|*.jsonl\`
|
|
81
|
+
- \`AGENTS.md\` managed block
|
|
82
|
+
|
|
83
|
+
Harness-specific additions:
|
|
84
|
+
|
|
85
|
+
- \`claude\`: \`.claude/commands/cc*.md\`, \`.claude/hooks/hooks.json\`
|
|
86
|
+
- \`cursor\`: \`.cursor/commands/cc*.md\`, \`.cursor/hooks.json\`, \`.cursor/rules/cclaw-workflow.mdc\`
|
|
87
|
+
- \`opencode\`: \`.opencode/commands/cc*.md\`, \`.opencode/plugins/cclaw-plugin.mjs\`, opencode plugin registration
|
|
88
|
+
- \`codex\`: \`.codex/commands/cc*.md\`, \`.codex/hooks.json\`
|
|
89
|
+
|
|
90
|
+
## Runtime observability
|
|
91
|
+
|
|
92
|
+
- \`.cclaw/state/harness-gaps.json\` captures per-harness capability gaps for the active config.
|
|
93
|
+
- \`cclaw doctor\` validates shim, hook, and lifecycle surfaces against this capability model.
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HarnessId } from "../types.js";
|
|
2
|
+
export declare const HOOK_SEMANTIC_EVENTS: readonly ["session_rehydrate", "pre_tool_prompt_guard", "pre_tool_workflow_guard", "post_tool_context_monitor", "stop_checkpoint", "precompact_digest"];
|
|
3
|
+
export type HookSemanticEvent = (typeof HOOK_SEMANTIC_EVENTS)[number];
|
|
4
|
+
export declare const HOOK_EVENTS_BY_HARNESS: Record<HarnessId, Partial<Record<HookSemanticEvent, string>>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const HOOK_SEMANTIC_EVENTS = [
|
|
2
|
+
"session_rehydrate",
|
|
3
|
+
"pre_tool_prompt_guard",
|
|
4
|
+
"pre_tool_workflow_guard",
|
|
5
|
+
"post_tool_context_monitor",
|
|
6
|
+
"stop_checkpoint",
|
|
7
|
+
"precompact_digest"
|
|
8
|
+
];
|
|
9
|
+
export const HOOK_EVENTS_BY_HARNESS = {
|
|
10
|
+
claude: {
|
|
11
|
+
session_rehydrate: "SessionStart matcher startup|resume|clear|compact",
|
|
12
|
+
pre_tool_prompt_guard: "PreToolUse -> prompt-guard.sh",
|
|
13
|
+
pre_tool_workflow_guard: "PreToolUse -> workflow-guard.sh",
|
|
14
|
+
post_tool_context_monitor: "PostToolUse -> context-monitor.sh",
|
|
15
|
+
stop_checkpoint: "Stop -> stop-checkpoint.sh",
|
|
16
|
+
precompact_digest: "PreCompact -> pre-compact.sh"
|
|
17
|
+
},
|
|
18
|
+
cursor: {
|
|
19
|
+
session_rehydrate: "sessionStart/sessionResume/sessionClear/sessionCompact",
|
|
20
|
+
pre_tool_prompt_guard: "preToolUse -> prompt-guard.sh",
|
|
21
|
+
pre_tool_workflow_guard: "preToolUse -> workflow-guard.sh",
|
|
22
|
+
post_tool_context_monitor: "postToolUse -> context-monitor.sh",
|
|
23
|
+
stop_checkpoint: "stop -> stop-checkpoint.sh",
|
|
24
|
+
precompact_digest: "sessionCompact -> pre-compact.sh"
|
|
25
|
+
},
|
|
26
|
+
opencode: {
|
|
27
|
+
session_rehydrate: "plugin event handlers + transform rehydration",
|
|
28
|
+
pre_tool_prompt_guard: "plugin tool.execute.before -> prompt-guard.sh",
|
|
29
|
+
pre_tool_workflow_guard: "plugin tool.execute.before -> workflow-guard.sh",
|
|
30
|
+
post_tool_context_monitor: "plugin tool.execute.after -> context-monitor.sh",
|
|
31
|
+
stop_checkpoint: "plugin session.idle -> stop-checkpoint.sh",
|
|
32
|
+
precompact_digest: "plugin session.cleared/session.resumed hooks"
|
|
33
|
+
},
|
|
34
|
+
codex: {
|
|
35
|
+
session_rehydrate: "SessionStart matcher startup|resume|clear|compact",
|
|
36
|
+
pre_tool_prompt_guard: "PreToolUse -> prompt-guard.sh",
|
|
37
|
+
pre_tool_workflow_guard: "PreToolUse -> workflow-guard.sh",
|
|
38
|
+
post_tool_context_monitor: "PostToolUse -> context-monitor.sh",
|
|
39
|
+
stop_checkpoint: "Stop -> stop-checkpoint.sh",
|
|
40
|
+
precompact_digest: "PreCompact -> pre-compact.sh"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -78,14 +78,42 @@ Before adding new code/templates/rules:
|
|
|
78
78
|
- Evidence beats volume.
|
|
79
79
|
- Keep stage output concrete and testable.
|
|
80
80
|
|
|
81
|
-
## Preamble
|
|
81
|
+
## Preamble budget
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- stage transition,
|
|
86
|
-
- or multi-step operation where drift risk is real.
|
|
83
|
+
This section is the single source of truth for preamble behavior.
|
|
84
|
+
Do not duplicate preamble rules in AGENTS.md, harness adapters, or stage-local docs.
|
|
87
85
|
|
|
88
|
-
|
|
86
|
+
### Emit when
|
|
87
|
+
|
|
88
|
+
| Trigger | Machine-verifiable condition |
|
|
89
|
+
|---|---|
|
|
90
|
+
| Stage transition | \`flow-state.currentStage\` changes in this turn |
|
|
91
|
+
| Non-trivial implementation turn | agent is about to run source-editing tools outside \`.cclaw/\` |
|
|
92
|
+
| Multi-step risky operation | planned sequence contains 2+ commands with rollback/risk potential |
|
|
93
|
+
|
|
94
|
+
### Skip when
|
|
95
|
+
|
|
96
|
+
| Skip reason | Condition |
|
|
97
|
+
|---|---|
|
|
98
|
+
| Pure Q&A | no filesystem or runtime mutation planned |
|
|
99
|
+
| Trivial change | single low-risk edit with no stage or plan drift |
|
|
100
|
+
| Subagent dispatch payload | prompt is for spawned agent/tool call only |
|
|
101
|
+
| Cooldown hit | same stage + same trigger emitted within cooldown window |
|
|
102
|
+
|
|
103
|
+
### Form contract (max 4 lines)
|
|
104
|
+
|
|
105
|
+
1. \`Stage:\` current stage id
|
|
106
|
+
2. \`Goal:\` concrete objective for this turn
|
|
107
|
+
3. \`Plan:\` next 1-3 actions
|
|
108
|
+
4. \`Guardrails:\` key constraints / non-goals
|
|
109
|
+
|
|
110
|
+
### Cooldown
|
|
111
|
+
|
|
112
|
+
- Record each emitted preamble in \`.cclaw/state/preamble-log.jsonl\` as JSON line:
|
|
113
|
+
\`{"ts","stage","runId","trigger","hash"}\`.
|
|
114
|
+
- Default cooldown: 15 minutes for identical \`stage + trigger + hash\`.
|
|
115
|
+
- TDD wave mode uses stricter dedupe: one preamble per wave unless scope changes.
|
|
116
|
+
- If the plan changes materially, a new preamble is allowed inside cooldown.
|
|
89
117
|
|
|
90
118
|
## Operational learning
|
|
91
119
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-thread research playbooks.
|
|
3
|
+
*
|
|
4
|
+
* These files intentionally have no YAML frontmatter and are not standalone
|
|
5
|
+
* delegated personas. The primary agent loads and executes them directly.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RESEARCH_PLAYBOOKS: Record<string, string>;
|
|
8
|
+
export declare const RESEARCH_PLAYBOOK_FILES: string[];
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-thread research playbooks.
|
|
3
|
+
*
|
|
4
|
+
* These files intentionally have no YAML frontmatter and are not standalone
|
|
5
|
+
* delegated personas. The primary agent loads and executes them directly.
|
|
6
|
+
*/
|
|
7
|
+
export const RESEARCH_PLAYBOOKS = {
|
|
8
|
+
"repo-scan.md": `# Repo Scan Playbook
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Build a grounded map of existing modules and reuse candidates before design lock.
|
|
13
|
+
|
|
14
|
+
## Steps
|
|
15
|
+
|
|
16
|
+
1. Identify 3-8 task keywords (feature nouns + action verbs).
|
|
17
|
+
2. Search for likely modules with \`rg\` and \`Glob\` patterns.
|
|
18
|
+
3. List existing implementations or close analogs with file citations.
|
|
19
|
+
4. Flag duplication risk and obvious extension points.
|
|
20
|
+
|
|
21
|
+
## Output Contract
|
|
22
|
+
|
|
23
|
+
- Relevant modules: \`path - purpose\`
|
|
24
|
+
- Reuse candidates: \`file:line - why reusable\`
|
|
25
|
+
- Gaps: capabilities not currently present
|
|
26
|
+
|
|
27
|
+
## Guardrails
|
|
28
|
+
|
|
29
|
+
- Read-only procedure.
|
|
30
|
+
- Never invent paths or ownership.
|
|
31
|
+
- If scope is too broad, return bounded partial coverage explicitly.
|
|
32
|
+
`,
|
|
33
|
+
"learnings-lookup.md": `# Learnings Lookup Playbook
|
|
34
|
+
|
|
35
|
+
## Purpose
|
|
36
|
+
|
|
37
|
+
Reuse prior project knowledge before choosing a direction.
|
|
38
|
+
|
|
39
|
+
## Steps
|
|
40
|
+
|
|
41
|
+
1. Read \`.cclaw/knowledge.jsonl\`.
|
|
42
|
+
2. Match by stage/domain keywords from the current task.
|
|
43
|
+
3. Rank matches by confidence and recency.
|
|
44
|
+
4. Return the top entries verbatim.
|
|
45
|
+
|
|
46
|
+
## Output Contract
|
|
47
|
+
|
|
48
|
+
- Matched rules
|
|
49
|
+
- Matched patterns
|
|
50
|
+
- Matched lessons
|
|
51
|
+
- Matched compounds
|
|
52
|
+
- Explicit no-match note when empty
|
|
53
|
+
|
|
54
|
+
## Guardrails
|
|
55
|
+
|
|
56
|
+
- Append-only store: do not rewrite history entries.
|
|
57
|
+
- Prefer exact quote over paraphrase.
|
|
58
|
+
`,
|
|
59
|
+
"framework-docs-lookup.md": `# Framework Docs Lookup Playbook
|
|
60
|
+
|
|
61
|
+
## Purpose
|
|
62
|
+
|
|
63
|
+
Anchor design decisions to version-accurate framework/library docs.
|
|
64
|
+
|
|
65
|
+
## Steps
|
|
66
|
+
|
|
67
|
+
1. Resolve the actual dependency version from lockfiles/manifests.
|
|
68
|
+
2. Fetch official docs for that version (context7 when available).
|
|
69
|
+
3. Extract APIs used by the task and any migration or deprecation notes.
|
|
70
|
+
|
|
71
|
+
## Output Contract
|
|
72
|
+
|
|
73
|
+
- Library + version
|
|
74
|
+
- APIs/signatures touched
|
|
75
|
+
- Relevant breaking changes or gotchas
|
|
76
|
+
- Source links/references
|
|
77
|
+
|
|
78
|
+
## Guardrails
|
|
79
|
+
|
|
80
|
+
- No speculative APIs.
|
|
81
|
+
- If docs conflict or are unclear, mark UNKNOWN and escalate.
|
|
82
|
+
`,
|
|
83
|
+
"best-practices-lookup.md": `# Best Practices Lookup Playbook
|
|
84
|
+
|
|
85
|
+
## Purpose
|
|
86
|
+
|
|
87
|
+
Summarize citable domain practices for a narrow design decision.
|
|
88
|
+
|
|
89
|
+
## Steps
|
|
90
|
+
|
|
91
|
+
1. Narrow the domain to one concrete sub-problem.
|
|
92
|
+
2. Gather 3-5 authoritative sources.
|
|
93
|
+
3. Produce short practice and anti-pattern lists tied to sources.
|
|
94
|
+
|
|
95
|
+
## Output Contract
|
|
96
|
+
|
|
97
|
+
- Recommended practices (\`practice - rationale - source\`)
|
|
98
|
+
- Common traps (\`trap - why it fails - source\`)
|
|
99
|
+
- Decision hooks (1-3 questions to resolve before proceeding)
|
|
100
|
+
|
|
101
|
+
## Guardrails
|
|
102
|
+
|
|
103
|
+
- Cite authoritative sources (official docs/standards).
|
|
104
|
+
- State uncertainty explicitly when consensus is weak.
|
|
105
|
+
`,
|
|
106
|
+
"git-history.md": `# Git History Playbook
|
|
107
|
+
|
|
108
|
+
## Purpose
|
|
109
|
+
|
|
110
|
+
Detect churn, regressions, and ownership signals before locking scope/design.
|
|
111
|
+
|
|
112
|
+
## Steps
|
|
113
|
+
|
|
114
|
+
1. For impacted paths, inspect recent history and themes:
|
|
115
|
+
- \`git log --follow -n 20 -- <path>\`
|
|
116
|
+
2. Check ownership hotspots:
|
|
117
|
+
- \`git blame <path>\`
|
|
118
|
+
- \`git log --since="<window>" --format="%an" -- <path>\`
|
|
119
|
+
3. Search for regression signals:
|
|
120
|
+
- \`git log --since="<window>" --grep="revert|regression" -- <path>\`
|
|
121
|
+
|
|
122
|
+
## Output Contract
|
|
123
|
+
|
|
124
|
+
- Recent themes
|
|
125
|
+
- Revert/regression signals (with SHAs)
|
|
126
|
+
- Ownership hints
|
|
127
|
+
- Collision risks with ongoing refactors
|
|
128
|
+
|
|
129
|
+
## Guardrails
|
|
130
|
+
|
|
131
|
+
- Read-only git usage.
|
|
132
|
+
- If there is no history, say so explicitly.
|
|
133
|
+
`
|
|
134
|
+
};
|
|
135
|
+
export const RESEARCH_PLAYBOOK_FILES = Object.keys(RESEARCH_PLAYBOOKS).sort();
|
package/dist/content/skills.js
CHANGED
|
@@ -54,6 +54,22 @@ Mandatory delegations for this stage: ${mandatoryList}.
|
|
|
54
54
|
Record completion/waiver in \`${delegationLogRel}\` before stage completion.
|
|
55
55
|
`;
|
|
56
56
|
}
|
|
57
|
+
function researchPlaybooksBlock(stage) {
|
|
58
|
+
const playbooks = stageSchema(stage).researchPlaybooks ?? [];
|
|
59
|
+
if (playbooks.length === 0)
|
|
60
|
+
return "";
|
|
61
|
+
const rows = playbooks
|
|
62
|
+
.map((playbook) => `- \`${RUNTIME_ROOT}/skills/${playbook}\``)
|
|
63
|
+
.join("\n");
|
|
64
|
+
return `## Research Playbooks
|
|
65
|
+
|
|
66
|
+
Use these in-thread research procedures before locking this stage. They are
|
|
67
|
+
playbooks (not delegated personas), so execute them in the primary agent context
|
|
68
|
+
and record outcomes in the stage artifact when relevant.
|
|
69
|
+
|
|
70
|
+
${rows}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
57
73
|
function reviewSectionsBlock(stage) {
|
|
58
74
|
const schema = stageSchema(stage);
|
|
59
75
|
if (schema.reviewSections.length === 0)
|
|
@@ -92,6 +108,9 @@ function waveExecutionModeBlock(stage) {
|
|
|
92
108
|
|
|
93
109
|
Execute the current dependency wave task-by-task (RED -> GREEN -> REFACTOR).
|
|
94
110
|
Stop on BLOCKED status or when user input is required.
|
|
111
|
+
Apply preamble budget discipline: one preamble per wave, then continue without
|
|
112
|
+
repeating it for each task. Re-emit only when the wave boundary changes or the
|
|
113
|
+
plan changes materially.
|
|
95
114
|
|
|
96
115
|
Detailed walkthrough:
|
|
97
116
|
\`.cclaw/${STAGE_EXAMPLES_REFERENCE_DIR}/tdd-wave-walkthrough.md\`
|
|
@@ -313,6 +332,7 @@ ${schema.requiredContext.length > 0 ? schema.requiredContext.map((item) => `- ${
|
|
|
313
332
|
|
|
314
333
|
${contextLoadingBlock(stage)}
|
|
315
334
|
${autoSubagentDispatchBlock(stage)}
|
|
335
|
+
${researchPlaybooksBlock(stage)}
|
|
316
336
|
|
|
317
337
|
## Outputs
|
|
318
338
|
${schema.outputs.map((item) => `- ${item}`).join("\n")}
|
|
@@ -33,7 +33,7 @@ export interface ArtifactValidation {
|
|
|
33
33
|
validationRule: string;
|
|
34
34
|
}
|
|
35
35
|
export interface StageAutoSubagentDispatch {
|
|
36
|
-
agent: "planner" | "
|
|
36
|
+
agent: "planner" | "reviewer" | "security-reviewer" | "test-author" | "doc-updater";
|
|
37
37
|
/**
|
|
38
38
|
* - `mandatory` — must be dispatched (or explicitly waived) before stage transition.
|
|
39
39
|
* - `proactive` — should be dispatched automatically when context matches `when`.
|
|
@@ -81,6 +81,8 @@ export interface StageSchema {
|
|
|
81
81
|
requiredEvidence: string[];
|
|
82
82
|
inputs: string[];
|
|
83
83
|
requiredContext: string[];
|
|
84
|
+
/** In-thread research procedures for this stage (`.cclaw/skills/research/*.md`). */
|
|
85
|
+
researchPlaybooks?: string[];
|
|
84
86
|
outputs: string[];
|
|
85
87
|
blockers: string[];
|
|
86
88
|
exitCriteria: string[];
|