cclaw-cli 0.5.3 → 0.5.5
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 +8 -11
- package/dist/artifact-linter.js +41 -13
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +12 -1
- package/dist/config.js +0 -19
- package/dist/content/contracts.js +7 -12
- package/dist/content/examples.js +42 -26
- package/dist/content/hooks.d.ts +4 -6
- package/dist/content/hooks.js +105 -435
- package/dist/content/learnings.js +55 -203
- package/dist/content/meta-skill.js +8 -11
- package/dist/content/next-command.js +3 -3
- package/dist/content/observe.d.ts +4 -7
- package/dist/content/observe.js +81 -55
- package/dist/content/session-hooks.js +8 -8
- package/dist/content/skills.js +9 -16
- package/dist/content/stage-schema.js +80 -97
- package/dist/content/templates.d.ts +1 -1
- package/dist/content/templates.js +27 -48
- package/dist/delegation.js +7 -7
- package/dist/doctor.js +17 -34
- package/dist/flow-state.js +1 -1
- package/dist/harness-adapters.js +1 -1
- package/dist/install.js +23 -49
- package/dist/policy.js +1 -4
- package/dist/runs.d.ts +13 -9
- package/dist/runs.js +108 -317
- package/dist/trace-matrix.js +8 -18
- package/dist/types.d.ts +0 -4
- package/package.json +1 -1
- package/dist/learnings-summarizer.d.ts +0 -25
- package/dist/learnings-summarizer.js +0 -201
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
|
-
//
|
|
3
|
-
// Cclaw emits instructions only; agents use shell tools against JSONL on disk.
|
|
2
|
+
// Knowledge store content for /cc-learn and stage self-improvement prompts.
|
|
4
3
|
// ---------------------------------------------------------------------------
|
|
5
|
-
const
|
|
4
|
+
const KNOWLEDGE_PATH = ".cclaw/knowledge.md";
|
|
6
5
|
const LEARN_SKILL_NAME = "learnings";
|
|
7
|
-
const LEARN_SKILL_DESCRIPTION = "Project-scoped
|
|
6
|
+
const LEARN_SKILL_DESCRIPTION = "Project-scoped knowledge store: review and append rule/pattern/lesson entries in .cclaw/knowledge.md.";
|
|
8
7
|
export function learnSkillMarkdown() {
|
|
9
8
|
return `---
|
|
10
9
|
name: ${LEARN_SKILL_NAME}
|
|
@@ -15,251 +14,104 @@ description: "${LEARN_SKILL_DESCRIPTION}"
|
|
|
15
14
|
|
|
16
15
|
## Overview
|
|
17
16
|
|
|
18
|
-
This skill
|
|
17
|
+
This skill manages the append-only project knowledge file at \`${KNOWLEDGE_PATH}\`.
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
Use it to keep durable knowledge that should survive sessions:
|
|
20
|
+
- **rule**: hard constraint to follow every time
|
|
21
|
+
- **pattern**: repeatable way that works well in this project
|
|
22
|
+
- **lesson**: non-obvious outcome from a failure or trade-off
|
|
21
23
|
|
|
22
24
|
## HARD-GATE
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
Under \`/cc-learn\`, only modify the knowledge store (\`${KNOWLEDGE_PATH}\`) or an explicitly user-approved summary file. Do not modify application code here.
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
- Forbidden: using learnings maintenance as a pretext to touch unrelated code paths.
|
|
28
|
+
## Entry format (append-only)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
| \`type\` | yes | One of: \`pattern\`, \`pitfall\`, \`preference\`, \`architecture\`, \`tool\`, \`operational\`. |
|
|
36
|
-
| \`key\` | yes | Stable **kebab-case** identifier for dedup and search (e.g. \`avoid-barrel-reexports-in-tests\`). |
|
|
37
|
-
| \`insight\` | yes | Single human-readable sentence (no multi-paragraph essays). |
|
|
38
|
-
| \`confidence\` | yes | Integer **1–10** (see scale in “Operational Self-Improvement” on stage skills). |
|
|
39
|
-
| \`source\` | yes | \`observed\` \| \`user-stated\` \| \`inferred\`. Drives decay rules. |
|
|
40
|
-
| \`files\` | no | \`string[]\` of repo-relative paths this insight touched (for staleness checks in prune). |
|
|
41
|
-
| \`branch\` | no | Branch name when recorded (optional context). |
|
|
42
|
-
| \`commit\` | no | Short SHA when recorded (optional context). |
|
|
43
|
-
|
|
44
|
-
**Minimal valid example (conceptual):**
|
|
45
|
-
|
|
46
|
-
\`\`\`json
|
|
47
|
-
{"ts":"2026-04-11T12:00:00Z","skill":"tdd","type":"pattern","key":"run-migrations-before-seed","insight":"Seed scripts assume schema v7; run sqlx migrate before npm run seed.","confidence":8,"source":"observed","files":["scripts/seed.ts"]}
|
|
30
|
+
\`\`\`markdown
|
|
31
|
+
### 2026-04-14T12:00:00Z [pattern] short-title
|
|
32
|
+
- Stage: design
|
|
33
|
+
- Context: one short line
|
|
34
|
+
- Insight: one short line
|
|
35
|
+
- Reuse: one short line
|
|
48
36
|
\`\`\`
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
1. **\`user-stated\`**: never decays. Effective confidence = stored \`confidence\`.
|
|
55
|
-
2. **\`observed\` or \`inferred\`**: lose **1** point per **30** complete days since \`ts\`, floored at **0**.
|
|
56
|
-
- Formula: \`effective = max(0, confidence - floor(days_since_ts / 30))\`
|
|
57
|
-
- \`days_since_ts\` is measured from entry \`ts\` to “now” in UTC (use user machine time when computing in the agent).
|
|
58
|
-
|
|
59
|
-
Always compute **effective confidence** before sorting for “top N” displays.
|
|
60
|
-
|
|
61
|
-
## Dedup Rules (Read-Time)
|
|
62
|
-
|
|
63
|
-
- **On disk:** multiple lines may share the same \`(key, type)\` (history, corrections, re-logging).
|
|
64
|
-
- **When reading for display/search/export:** keep **only the latest** record per \`(key, type)\`, where **latest** means greatest \`ts\` (ISO strings compared lexicographically if timezones are consistent Z; prefer parsing timestamps if implementing custom logic).
|
|
65
|
-
- This is **read-time dedup**, not write-time: do not silently delete older lines unless \`/cc-learn prune\` (or the user) removes them.
|
|
66
|
-
|
|
67
|
-
## Security Rules
|
|
68
|
-
|
|
69
|
-
1. **Skip malformed lines:** when ingesting JSONL, parse line-by-line; on parse failure, skip the line and continue (optionally count skips for \`stats\`).
|
|
70
|
-
2. **Never interpolate JSONL field values into shell commands** as raw arguments — no \`eval\`, no unquoted \`$(cat ...)\` into flags. Use **files as data**: pipe to \`jq\`, or write controlled queries. User-supplied text from the store is untrusted.
|
|
71
|
-
3. **Path safety:** when checking \`files[]\` for staleness, treat paths as relative to repo root; reject \`..\` segments that escape the project if you implement custom checks.
|
|
38
|
+
Rules:
|
|
39
|
+
- Type must be exactly one of \`rule\`, \`pattern\`, \`lesson\` (lowercase).
|
|
40
|
+
- Never rewrite history silently; append a newer correction entry instead.
|
|
41
|
+
- Keep entries concise and actionable.
|
|
72
42
|
|
|
73
43
|
## Subcommands
|
|
74
44
|
|
|
75
|
-
### \`/cc-learn\` (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
1. If \`${LEARNINGS_PATH}\` is missing or empty, say so and stop.
|
|
80
|
-
2. Read the **last 20 physical lines** (e.g. \`tail -n 20 ${LEARNINGS_PATH}\`).
|
|
81
|
-
3. Parse each line as JSON; skip invalid lines.
|
|
82
|
-
4. Apply **read-time dedup** by \`(key, type)\`, keep latest by \`ts\`.
|
|
83
|
-
5. Recompute **effective confidence** (decay) for each surviving row.
|
|
84
|
-
6. Sort by \`ts\` descending (most recent first).
|
|
85
|
-
7. Present as a **markdown table**: \`ts\`, \`type\`, \`key\`, \`effective confidence\`, \`source\`, truncated \`insight\`.
|
|
86
|
-
|
|
87
|
-
### \`/cc-learn search <query>\` — search
|
|
88
|
-
|
|
89
|
-
**Goal:** Find relevant entries by text, then rank by confidence.
|
|
90
|
-
|
|
91
|
-
1. Normalize \`<query>\` as a literal string; do **not** inject it into \`eval\` or dynamic \`sh -c\` strings unsafely. Prefer:
|
|
92
|
-
- \`grep -F -n -- <query> ${LEARNINGS_PATH}\` (fixed-string mode) to get candidate line numbers, **or**
|
|
93
|
-
- Load lines in-process (agent reads file) and filter in code.
|
|
94
|
-
2. For each matched line, parse JSON; skip invalid.
|
|
95
|
-
3. Apply read-time dedup (\`(key, type)\` → latest \`ts\`).
|
|
96
|
-
4. Filter where **case-insensitive** match hits any of: \`insight\`, \`key\`, \`type\` (and optionally \`skill\`).
|
|
97
|
-
5. Compute **effective confidence**; sort **descending** by effective confidence, then by \`ts\` desc as tiebreaker.
|
|
98
|
-
6. Show **top 20** as a table (same columns as “show recent”).
|
|
99
|
-
|
|
100
|
-
### \`/cc-learn add\` — manual add
|
|
101
|
-
|
|
102
|
-
**Goal:** Interactive append with explicit user input.
|
|
103
|
-
|
|
104
|
-
1. Ask the user (one prompt at a time is fine): \`type\`, \`key\` (enforce kebab-case), \`insight\` (one sentence), \`confidence\` (1–10).
|
|
105
|
-
2. Set \`source\` to **\`"user-stated"\`** always for this path.
|
|
106
|
-
3. Set \`skill\` to \`learnings\` (or the user’s stated originating context if they insist).
|
|
107
|
-
4. Obtain \`ts\` from shell UTC timestamp.
|
|
108
|
-
5. Build one JSON object on a **single line** (no pretty-printed multi-line JSON inside JSONL).
|
|
109
|
-
6. Append: e.g. \`printf '%s\\n' '<json-line>' >> ${LEARNINGS_PATH}\` from a **heredoc or file** the agent controls — avoid breaking quoting.
|
|
110
|
-
7. **Verification (required):** after append, read back the **last line** of the file, parse as JSON, confirm \`key\` and \`ts\` match what you wrote.
|
|
111
|
-
|
|
112
|
-
### \`/cc-learn prune\` — staleness & conflicts
|
|
113
|
-
|
|
114
|
-
**Goal:** Curate quality; never delete without user confirmation.
|
|
115
|
-
|
|
116
|
-
1. Load up to **100** recent lines (prefer tail-first read, then widen if needed).
|
|
117
|
-
2. Parse; skip malformed; apply read-time dedup to get canonical latest per \`(key, type)\`.
|
|
118
|
-
3. **Staleness:** if \`files\` is a non-empty array, check each path exists relative to repo root. If **any** path is missing, flag the entry **STALE** (file targets gone).
|
|
119
|
-
4. **Conflicts:** if the same \`key\` appears with **different** \`insight\` strings across retained history (or between latest and visible duplicates), flag **CONFLICT** and show the competing insights with their \`ts\` / \`source\`.
|
|
120
|
-
5. For each flagged item, ask the user: **Remove** / **Keep** / **Update** (update = rewrite insight or files list after confirmation).
|
|
121
|
-
6. If removing: prefer rewriting the file without those lines **only** when the user confirms; use a safe write pattern (write temp → replace) if the environment allows.
|
|
122
|
-
|
|
123
|
-
### \`/cc-learn export\` — high-signal markdown rollup
|
|
124
|
-
|
|
125
|
-
**Goal:** Summarize the best current knowledge for humans and \`AGENTS.md\`.
|
|
45
|
+
### \`/cc-learn\` (default)
|
|
46
|
+
- Show the last 30 lines from \`${KNOWLEDGE_PATH}\`.
|
|
47
|
+
- If file is missing or empty, report that clearly.
|
|
126
48
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
4. Emit markdown grouped under:
|
|
131
|
-
- \`## Patterns\` (\`type === "pattern"\`)
|
|
132
|
-
- \`## Pitfalls\` (\`pitfall\`)
|
|
133
|
-
- \`## Preferences\` (\`preference\`)
|
|
134
|
-
- \`## Architecture\` (\`architecture\`)
|
|
135
|
-
- \`## Tools\` (\`tool\` and optionally \`operational\` — put \`operational\` here if you want a single “tools & ops” bucket, or add \`## Operational\` if the user prefers separation)
|
|
136
|
-
5. Under each section, bullet format: **\`key\` (conf X):** insight.
|
|
137
|
-
6. Ask the user: **append to \`AGENTS.md\`** vs **save as a separate file** (e.g. \`.cclaw/learnings-summary.md\`). Do nothing destructive without explicit choice.
|
|
49
|
+
### \`/cc-learn search <query>\`
|
|
50
|
+
- Perform case-insensitive text search in \`${KNOWLEDGE_PATH}\`.
|
|
51
|
+
- Return matched headings and nearby lines.
|
|
138
52
|
|
|
139
|
-
### \`/cc-learn
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- **total** canonical entries
|
|
144
|
-
- **unique keys** count
|
|
145
|
-
- Breakdown counts by \`type\` and by \`source\`
|
|
146
|
-
- **Average confidence** (raw stored values) **and** optionally average **effective** confidence
|
|
147
|
-
3. Present as compact markdown (table + short narrative).
|
|
148
|
-
|
|
149
|
-
## Handoff
|
|
150
|
-
|
|
151
|
-
This skill **does not** hand off to any \`/cc-<stage>\` command. Return control to the user or the prior task context when finished.
|
|
152
|
-
|
|
153
|
-
## Verification (Writes)
|
|
154
|
-
|
|
155
|
-
After **any** write operation (\`add\`, \`prune\` removal, export append):
|
|
156
|
-
|
|
157
|
-
1. Read back the **last line** of \`${LEARNINGS_PATH}\` (or the written artifact if appending elsewhere).
|
|
158
|
-
2. Parse as JSON; if parse fails, treat the write as **failed** and report immediately.
|
|
159
|
-
3. For append, confirm the final object’s \`ts\` / \`key\` match the intended mutation.
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
**Primary location on disk (generated by Cclaw installer):** \`.cclaw/skills/${LEARN_SKILL_NAME}/SKILL.md\` (this content).
|
|
53
|
+
### \`/cc-learn add\`
|
|
54
|
+
- Ask for: \`type\`, \`short title\`, \`context\`, \`insight\`, \`reuse\`.
|
|
55
|
+
- Append one entry using current UTC timestamp.
|
|
56
|
+
- Re-read the file tail and confirm the entry was written.
|
|
164
57
|
`;
|
|
165
58
|
}
|
|
166
59
|
export function learnCommandContract() {
|
|
167
|
-
const skillMdPath = `.cclaw/skills/${LEARN_SKILL_NAME}/SKILL.md`;
|
|
168
60
|
return `# /cc-learn
|
|
169
61
|
|
|
170
62
|
## Purpose
|
|
171
63
|
|
|
172
|
-
Manage the project
|
|
64
|
+
Manage the project knowledge store at \`${KNOWLEDGE_PATH}\` (append-only markdown).
|
|
173
65
|
|
|
174
66
|
## HARD-GATE
|
|
175
67
|
|
|
176
|
-
|
|
68
|
+
Do not edit source code from this command. Only operate on \`${KNOWLEDGE_PATH}\` (or user-approved summary output).
|
|
177
69
|
|
|
178
70
|
## Subcommands
|
|
179
71
|
|
|
180
72
|
| subcommand | args | description |
|
|
181
73
|
|---|---|---|
|
|
182
|
-
| (default) | — | Show recent
|
|
183
|
-
| \`search\` | \`<query>\` |
|
|
184
|
-
| \`add\` | — |
|
|
185
|
-
| \`prune\` | — | Load ≤100 entries; flag **STALE** if \`files\` paths missing; flag **CONFLICT** if same \`key\` diverges in \`insight\`; user chooses Remove / Keep / Update per flag. |
|
|
186
|
-
| \`export\` | — | Dedup; top 50 by effective confidence; markdown sections (Patterns, Pitfalls, Preferences, Architecture, Tools); user picks append to \`AGENTS.md\` vs separate file. |
|
|
187
|
-
| \`stats\` | — | Totals, unique keys, breakdown by \`type\` and \`source\`, average confidence (+ optional effective average); report malformed line count. |
|
|
188
|
-
|
|
189
|
-
## Learning Entry Schema
|
|
190
|
-
|
|
191
|
-
| Field | Required | Description |
|
|
192
|
-
|---|---|---|
|
|
193
|
-
| \`ts\` | yes | ISO timestamp; auto on write. |
|
|
194
|
-
| \`skill\` | yes | Originating stage or context. |
|
|
195
|
-
| \`type\` | yes | \`pattern\` \| \`pitfall\` \| \`preference\` \| \`architecture\` \| \`tool\` \| \`operational\` |
|
|
196
|
-
| \`key\` | yes | Kebab-case stable id. |
|
|
197
|
-
| \`insight\` | yes | One-sentence insight. |
|
|
198
|
-
| \`confidence\` | yes | 1–10 |
|
|
199
|
-
| \`source\` | yes | \`observed\` \| \`user-stated\` \| \`inferred\` |
|
|
200
|
-
| \`files\` | no | \`string[]\` relative paths (optional). |
|
|
201
|
-
| \`branch\` / \`commit\` | no | Optional provenance. |
|
|
202
|
-
|
|
203
|
-
## Confidence Decay
|
|
204
|
-
|
|
205
|
-
- \`user-stated\`: **no decay**.
|
|
206
|
-
- \`observed\` / \`inferred\`: **−1** effective confidence per **30** days since \`ts\`, floor at **0**.
|
|
207
|
-
- Always apply decay **before sorting** for search / show / export rankings.
|
|
208
|
-
|
|
209
|
-
## Dedup Rules
|
|
210
|
-
|
|
211
|
-
Multiple JSONL lines may share the same \`(key, type)\`. When reading, keep **only the line with the latest \`ts\`** per pair. **Do not** assume uniqueness on disk.
|
|
212
|
-
|
|
213
|
-
## Security Rules
|
|
214
|
-
|
|
215
|
-
- Skip malformed JSONL lines; continue processing.
|
|
216
|
-
- **Never** splice stored field values into shell control flow; treat file contents as data (\`jq\`, controlled greps, agent-side parsing).
|
|
217
|
-
|
|
218
|
-
## Primary Skill (${skillMdPath})
|
|
219
|
-
|
|
220
|
-
Canonical instructions live at \`${skillMdPath}\` (generated by Cclaw).
|
|
74
|
+
| (default) | — | Show recent knowledge entries (tail view). |
|
|
75
|
+
| \`search\` | \`<query>\` | Search knowledge text for relevant prior rules/patterns/lessons. |
|
|
76
|
+
| \`add\` | — | Append a new entry with type \`rule\` / \`pattern\` / \`lesson\`. |
|
|
221
77
|
`;
|
|
222
78
|
}
|
|
223
79
|
export function selfImprovementBlock(stageName) {
|
|
224
|
-
const skill = JSON.stringify(stageName);
|
|
225
80
|
return `## Operational Self-Improvement
|
|
226
81
|
|
|
227
|
-
After
|
|
228
|
-
- Did
|
|
229
|
-
- Did
|
|
230
|
-
- Did you discover a project quirk (unusual config, naming convention, gotcha)?
|
|
82
|
+
After this stage, ask:
|
|
83
|
+
- Did I discover a non-obvious reusable **rule** or **pattern**?
|
|
84
|
+
- Did a failure reveal a reusable **lesson**?
|
|
231
85
|
|
|
232
|
-
If
|
|
86
|
+
If yes, append one concise entry to \`${KNOWLEDGE_PATH}\`:
|
|
233
87
|
|
|
234
88
|
\`\`\`bash
|
|
235
|
-
|
|
89
|
+
TS="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
90
|
+
cat >> ${KNOWLEDGE_PATH} <<EOF
|
|
91
|
+
### $TS [pattern] short-title
|
|
92
|
+
- Stage: ${stageName}
|
|
93
|
+
- Context: what situation triggered this
|
|
94
|
+
- Insight: what should be remembered
|
|
95
|
+
- Reuse: how to apply this next time
|
|
96
|
+
EOF
|
|
236
97
|
\`\`\`
|
|
237
98
|
|
|
238
|
-
|
|
239
|
-
- Skip transient errors (network blips, typos). Log structural insights only.
|
|
240
|
-
- Use consistent keys so future entries dedup correctly.
|
|
241
|
-
- **\`ts\` is required** on every line — the example uses \`date -u +%Y-%m-%dT%H:%M:%SZ\` (UTC). If nested quoting is awkward, build JSON in the agent and \`printf '%s\\n' '<one-line-json>'\` instead.
|
|
242
|
-
- Confidence 1-3: uncertain pattern. 4-6: likely pattern. 7-9: confirmed pattern. 10: absolute rule.
|
|
99
|
+
Type must be exactly one of: \`rule\`, \`pattern\`, \`lesson\`.
|
|
243
100
|
`;
|
|
244
101
|
}
|
|
245
102
|
export function learningsSearchPreamble(stage) {
|
|
246
|
-
return `## Prior
|
|
247
|
-
|
|
248
|
-
Before beginning this stage, search the project learnings store for relevant prior knowledge:
|
|
249
|
-
|
|
250
|
-
\`\`\`bash
|
|
251
|
-
grep -i "${stage}" ${LEARNINGS_PATH} 2>/dev/null | tail -n 5
|
|
252
|
-
\`\`\`
|
|
103
|
+
return `## Prior Knowledge (load at stage start)
|
|
253
104
|
|
|
254
|
-
|
|
105
|
+
Before stage work, search \`${KNOWLEDGE_PATH}\` for relevant entries (for example: \`${stage}\`, affected systems, key constraints) and apply them explicitly.
|
|
255
106
|
|
|
256
|
-
If the
|
|
107
|
+
If the file is empty, continue normally.
|
|
257
108
|
`;
|
|
258
109
|
}
|
|
259
110
|
export function learningsAgentsMdBlock() {
|
|
260
|
-
return `###
|
|
111
|
+
return `### Knowledge Store
|
|
261
112
|
|
|
262
|
-
\`${
|
|
263
|
-
|
|
113
|
+
\`${KNOWLEDGE_PATH}\` — append-only markdown memory with entry types \`rule\`, \`pattern\`, \`lesson\`.
|
|
114
|
+
At session start and stage transitions, load recent entries and apply relevant ones.
|
|
115
|
+
If a non-obvious reusable rule/pattern/lesson is discovered, append a new entry.
|
|
264
116
|
`;
|
|
265
117
|
}
|
|
@@ -26,7 +26,7 @@ Task arrives
|
|
|
26
26
|
|
|
|
27
27
|
+-- New idea / starting fresh? --> /cc <idea> (starts brainstorm)
|
|
28
28
|
+-- Resuming / continuing? --> /cc or /cc-next
|
|
29
|
-
+-- Want to check/add project
|
|
29
|
+
+-- Want to check/add project knowledge? --> /cc-learn
|
|
30
30
|
+-- No cclaw stage applies? --> Respond normally
|
|
31
31
|
\`\`\`
|
|
32
32
|
|
|
@@ -47,7 +47,7 @@ Before starting work, ALWAYS:
|
|
|
47
47
|
2. **Stages are workflows, not suggestions.** Follow the skill steps in order. Do not skip verification steps.
|
|
48
48
|
3. **One stage at a time.** Complete the current stage before advancing to the next.
|
|
49
49
|
4. **Gates must pass.** Every stage has required gates — the agent cannot claim completion without satisfying them.
|
|
50
|
-
5. **Artifacts are mandatory.** Each stage writes to \`.cclaw/artifacts/\`;
|
|
50
|
+
5. **Artifacts are mandatory.** Each stage writes to \`.cclaw/artifacts/\`; completed features are archived later with \`cclaw archive\`.
|
|
51
51
|
6. **When in doubt, use \`/cc\`.** If the task is non-trivial and there's no prior artifact, run \`/cc <idea>\` to start brainstorming.
|
|
52
52
|
|
|
53
53
|
## Stage Quick Reference
|
|
@@ -108,7 +108,7 @@ Use this loading order to keep context lean while preserving depth:
|
|
|
108
108
|
|
|
109
109
|
### See also
|
|
110
110
|
- \`.cclaw/skills/session/SKILL.md\` for session start/stop/resume behavior
|
|
111
|
-
- \`.cclaw/skills/learnings/SKILL.md\` for durable
|
|
111
|
+
- \`.cclaw/skills/learnings/SKILL.md\` for durable knowledge capture and reuse
|
|
112
112
|
## Decision Protocol
|
|
113
113
|
|
|
114
114
|
When a stage requires user input (approval, choice, direction), use this structured pattern:
|
|
@@ -138,15 +138,12 @@ Watch for these anti-patterns:
|
|
|
138
138
|
- **Hollow reviews** — "looks good" without checking spec compliance
|
|
139
139
|
- **Cargo-cult artifacts** — filling templates without real thought
|
|
140
140
|
|
|
141
|
-
##
|
|
141
|
+
## Knowledge Integration
|
|
142
142
|
|
|
143
|
-
At session start, check \`.cclaw/
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
- After each stage, reflect: did anything happen that would save 5+ minutes next time? If so, log it.
|
|
143
|
+
At session start and stage transitions, check \`.cclaw/knowledge.md\` for project-specific knowledge:
|
|
144
|
+
- Review recent entries and apply relevant rules/patterns to the current task
|
|
145
|
+
- If you discover a non-obvious reusable rule or pattern, append a new entry with type \`rule\`, \`pattern\`, or \`lesson\`
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
If tool observation is enabled, cclaw captures tool usage patterns (PreToolUse/PostToolUse) to \`.cclaw/observations.jsonl\`. At session stop, observations are analyzed and valuable patterns are promoted to learnings. This is automatic — you do not need to manage it.
|
|
147
|
+
Knowledge capture is append-only and should preserve historical context rather than rewriting prior entries.
|
|
151
148
|
`;
|
|
152
149
|
}
|
|
@@ -7,7 +7,7 @@ function flowStatePath() {
|
|
|
7
7
|
return `${RUNTIME_ROOT}/state/flow-state.json`;
|
|
8
8
|
}
|
|
9
9
|
function delegationLogPathLine() {
|
|
10
|
-
return `${RUNTIME_ROOT}/
|
|
10
|
+
return `${RUNTIME_ROOT}/state/delegation-log.json`;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Command contract for /cc-next — the primary progression command.
|
|
@@ -38,7 +38,7 @@ This is the only progression command the user needs to drive the entire flow. St
|
|
|
38
38
|
## Algorithm (mandatory)
|
|
39
39
|
|
|
40
40
|
1. Read **\`${flowPath}\`**. If missing → **BLOCKED** (state missing).
|
|
41
|
-
2. Parse JSON. Capture \`currentStage
|
|
41
|
+
2. Parse JSON. Capture \`currentStage\` and \`stageGateCatalog[currentStage]\`.
|
|
42
42
|
3. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema.
|
|
43
43
|
4. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state.
|
|
44
44
|
5. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
|
|
@@ -110,7 +110,7 @@ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (p
|
|
|
110
110
|
### Step 1: Read state
|
|
111
111
|
|
|
112
112
|
1. Open **\`${flowPath}\`**.
|
|
113
|
-
2. Record \`currentStage
|
|
113
|
+
2. Record \`currentStage\` and \`stageGateCatalog[currentStage]\`.
|
|
114
114
|
3. If the file is missing or invalid JSON → **BLOCKED** (report and stop).
|
|
115
115
|
|
|
116
116
|
### Step 2: Evaluate gates
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* to .cclaw/observations.jsonl for continuous learning.
|
|
2
|
+
* Hook helper scripts and harness hook JSON generators.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* summarize-observations.sh: run at session stop, reads recent observations,
|
|
9
|
-
* identifies patterns, and appends new learnings to .cclaw/learnings.jsonl.
|
|
4
|
+
* This module still provides prompt/workflow/context guard scripts and
|
|
5
|
+
* cross-harness hook wiring. Observation pipeline scripts are retained only
|
|
6
|
+
* for backward compatibility and are not wired by default runtime generation.
|
|
10
7
|
*/
|
|
11
8
|
export interface PromptGuardOptions {
|
|
12
9
|
strictMode?: boolean;
|