cclaw-cli 0.7.0 → 0.8.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/content/agents.d.ts +9 -0
- package/dist/content/agents.js +177 -6
- package/dist/content/contracts.js +1 -1
- package/dist/content/examples.d.ts +1 -0
- package/dist/content/examples.js +63 -0
- package/dist/content/hooks.js +6 -6
- package/dist/content/learnings.d.ts +5 -0
- package/dist/content/learnings.js +88 -104
- package/dist/content/meta-skill.js +155 -44
- package/dist/content/session-hooks.js +2 -2
- package/dist/content/skills.js +46 -11
- package/dist/content/stage-schema.js +36 -10
- package/dist/content/start-command.js +63 -17
- package/dist/content/status-command.js +2 -2
- package/dist/content/subagents.js +169 -0
- package/dist/content/templates.js +32 -4
- package/dist/content/utility-skills.d.ts +23 -5
- package/dist/content/utility-skills.js +204 -42
- package/dist/doctor.js +33 -9
- package/dist/harness-adapters.js +55 -16
- package/dist/install.js +21 -7
- package/dist/policy.js +3 -2
- package/dist/runs.d.ts +4 -5
- package/dist/runs.js +19 -11
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
package/dist/content/agents.d.ts
CHANGED
|
@@ -33,6 +33,15 @@ export declare function agentMarkdown(agent: AgentDefinition): string;
|
|
|
33
33
|
* Markdown table mapping Cclaw stage entry points to specialist agents.
|
|
34
34
|
*/
|
|
35
35
|
export declare function agentRoutingTable(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Cost tier routing: keep heavy reasoning on the \`deep\` tier (planner, a
|
|
38
|
+
* single post-review reconciliation), push read-only research and narrow
|
|
39
|
+
* machine-only checks to the \`fast\` tier, and default review to \`balanced\`.
|
|
40
|
+
* This table is emitted into AGENTS.md so harness users understand why
|
|
41
|
+
* certain specialists are automatically fan-out-able without blowing the
|
|
42
|
+
* context budget.
|
|
43
|
+
*/
|
|
44
|
+
export declare function agentCostTierTable(): string;
|
|
36
45
|
/**
|
|
37
46
|
* AGENTS.md-ready section describing Cclaw’s specialist delegation model.
|
|
38
47
|
*/
|
package/dist/content/agents.js
CHANGED
|
@@ -170,6 +170,157 @@ export const CCLAW_AGENTS = [
|
|
|
170
170
|
"**Scope control:** only update what needs updating — **do not rewrite** docs that remain correct.",
|
|
171
171
|
].join("\n"),
|
|
172
172
|
},
|
|
173
|
+
{
|
|
174
|
+
name: "repo-research-analyst",
|
|
175
|
+
description: "PROACTIVE at the start of brainstorm/scope/design: delegates deep codebase exploration — existing modules, ownership boundaries, duplication, and reuse candidates — so the primary agent can plan from a grounded map instead of guesses.",
|
|
176
|
+
tools: ["Read", "Grep", "Glob"],
|
|
177
|
+
model: "fast",
|
|
178
|
+
activation: "proactive",
|
|
179
|
+
relatedStages: ["brainstorm", "scope", "design"],
|
|
180
|
+
body: [
|
|
181
|
+
"You are a **repo research analyst**.",
|
|
182
|
+
"",
|
|
183
|
+
"Scan the codebase for existing modules, helpers, patterns, and ownership boundaries relevant to the current task. Deliver a grounded map the primary agent can plan against.",
|
|
184
|
+
"",
|
|
185
|
+
"**Process:**",
|
|
186
|
+
"",
|
|
187
|
+
"1. Identify the task domain keywords (nouns, verbs, known file/module names).",
|
|
188
|
+
"2. Glob for obvious homes (by convention: `src/**`, `packages/**`, `apps/**`, etc.).",
|
|
189
|
+
"3. Grep for existing implementations of the same capability.",
|
|
190
|
+
"4. Enumerate adjacent tests/fixtures that already cover the area.",
|
|
191
|
+
"5. Flag duplication, near-duplicates, and reuse candidates with file:line.",
|
|
192
|
+
"",
|
|
193
|
+
"**Output schema:**",
|
|
194
|
+
"",
|
|
195
|
+
"- `Relevant modules:` bulleted list with `path — 1-line purpose`.",
|
|
196
|
+
"- `Reuse candidates:` bulleted list with `file:line — why this could absorb the change`.",
|
|
197
|
+
"- `Ownership hints:` any CODEOWNERS / README / comment signals.",
|
|
198
|
+
"- `Gaps:` what does NOT yet exist that the task would need.",
|
|
199
|
+
"",
|
|
200
|
+
"**Role boundary:** read-only. Do NOT edit files. Cite `file:line` for every claim; never guess paths.",
|
|
201
|
+
].join("\n"),
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "learnings-researcher",
|
|
205
|
+
description: "PROACTIVE before every non-trivial stage: streams `.cclaw/knowledge.jsonl` and surfaces the entries (rules, patterns, lessons, compounds) most relevant to the current task before the primary agent commits to a direction.",
|
|
206
|
+
tools: ["Read", "Grep", "Glob"],
|
|
207
|
+
model: "fast",
|
|
208
|
+
activation: "proactive",
|
|
209
|
+
relatedStages: ["brainstorm", "scope", "design", "spec", "plan", "tdd", "review", "ship"],
|
|
210
|
+
body: [
|
|
211
|
+
"You are a **project learnings researcher**.",
|
|
212
|
+
"",
|
|
213
|
+
"Stream `.cclaw/knowledge.jsonl` and surface the entries most relevant to the current task. The goal is to prevent the primary agent from re-learning things the project already wrote down.",
|
|
214
|
+
"",
|
|
215
|
+
"**Process:**",
|
|
216
|
+
"",
|
|
217
|
+
"1. Parse `.cclaw/knowledge.jsonl` (one JSON object per line, strict schema).",
|
|
218
|
+
"2. Match entries by `domain`, `stage`, and substring overlap with the current task description.",
|
|
219
|
+
"3. Rank by `confidence` then recency (`created`).",
|
|
220
|
+
"4. Group by `type` (rule, pattern, lesson, compound).",
|
|
221
|
+
"5. Return the top 10 entries verbatim with a one-line reason each.",
|
|
222
|
+
"",
|
|
223
|
+
"**Output schema:**",
|
|
224
|
+
"",
|
|
225
|
+
"- `Matched rules:` list of `trigger → action (confidence)`.",
|
|
226
|
+
"- `Matched patterns:` list of `trigger → action (confidence)`.",
|
|
227
|
+
"- `Matched lessons:` list of `trigger → action (confidence)`.",
|
|
228
|
+
"- `Matched compounds:` list of `trigger → action (confidence)`.",
|
|
229
|
+
"- `No-match note:` if nothing relevant exists, say so explicitly.",
|
|
230
|
+
"",
|
|
231
|
+
"**Role boundary:** read-only. Never rewrite or delete entries — corrections are appended by the primary agent via `/cc-learn add`.",
|
|
232
|
+
].join("\n"),
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "framework-docs-researcher",
|
|
236
|
+
description: "PROACTIVE during design/spec/tdd for tasks that touch a specific framework, library, or SDK: fetches authoritative, version-aware documentation (via context7 when available) so implementation matches the live API, not training priors.",
|
|
237
|
+
tools: ["Read", "Grep", "Glob", "WebSearch", "WebFetch"],
|
|
238
|
+
model: "fast",
|
|
239
|
+
activation: "on-demand",
|
|
240
|
+
relatedStages: ["design", "spec", "tdd", "review"],
|
|
241
|
+
body: [
|
|
242
|
+
"You are a **framework documentation researcher**.",
|
|
243
|
+
"",
|
|
244
|
+
"Fetch authoritative, version-aware docs for any library/framework/SDK/CLI the current task depends on. The goal is to replace model priors with live API references.",
|
|
245
|
+
"",
|
|
246
|
+
"**Process:**",
|
|
247
|
+
"",
|
|
248
|
+
"1. Identify the exact library + version from the repo (package.json, pyproject, go.mod, etc.).",
|
|
249
|
+
"2. If context7 MCP is available, use it first — it returns docs keyed to the installed version.",
|
|
250
|
+
"3. Otherwise WebSearch / WebFetch for the official docs site or the tagged release changelog.",
|
|
251
|
+
"4. Capture: public API signatures, breaking changes since a major version back, migration notes, and any deprecated paths relevant to the task.",
|
|
252
|
+
"",
|
|
253
|
+
"**Output schema:**",
|
|
254
|
+
"",
|
|
255
|
+
"- `Library + version:` name and resolved version.",
|
|
256
|
+
"- `Key APIs:` bullet list of signatures the task will touch.",
|
|
257
|
+
"- `Breaking changes:` notable deltas relevant to the task.",
|
|
258
|
+
"- `Gotchas:` footguns, deprecated paths, version-gated flags.",
|
|
259
|
+
"- `Source:` URL(s) or MCP reference used.",
|
|
260
|
+
"",
|
|
261
|
+
"**Role boundary:** never invent APIs. If docs are unclear, say `UNKNOWN` and surface the gap instead of guessing.",
|
|
262
|
+
].join("\n"),
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "best-practices-researcher",
|
|
266
|
+
description: "PROACTIVE during design/spec when the task touches a well-known domain (auth, caching, rate limiting, observability, accessibility, etc.): delivers a short, opinionated best-practice summary grounded in citable sources.",
|
|
267
|
+
tools: ["Read", "Grep", "Glob", "WebSearch", "WebFetch"],
|
|
268
|
+
model: "fast",
|
|
269
|
+
activation: "on-demand",
|
|
270
|
+
relatedStages: ["brainstorm", "scope", "design", "spec", "review"],
|
|
271
|
+
body: [
|
|
272
|
+
"You are a **best-practices researcher**.",
|
|
273
|
+
"",
|
|
274
|
+
"For a named domain (auth, caching, rate limiting, observability, accessibility, etc.), deliver a short, opinionated best-practice summary that is citable and current.",
|
|
275
|
+
"",
|
|
276
|
+
"**Process:**",
|
|
277
|
+
"",
|
|
278
|
+
"1. Restate the domain + narrow it to the sub-problem the task is solving.",
|
|
279
|
+
"2. Gather 3–5 authoritative sources (official docs, IETF / W3C / OWASP references, well-known community standards).",
|
|
280
|
+
"3. Surface the 5–8 practices most relevant to the task, each with one-line rationale + source.",
|
|
281
|
+
"4. Flag practices that look common but are anti-patterns today.",
|
|
282
|
+
"",
|
|
283
|
+
"**Output schema:**",
|
|
284
|
+
"",
|
|
285
|
+
"- `Domain + sub-problem:` one sentence.",
|
|
286
|
+
"- `Recommended practices:` list of `practice — rationale — source`.",
|
|
287
|
+
"- `Common traps:` list of `trap — why it fails — source`.",
|
|
288
|
+
"- `Decision hooks:` 1–3 explicit questions the primary agent must answer before moving on.",
|
|
289
|
+
"",
|
|
290
|
+
"**Role boundary:** never prescribe a choice without citing a source. If the domain has no authoritative answer, say so.",
|
|
291
|
+
].join("\n"),
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "git-history-analyzer",
|
|
295
|
+
description: "PROACTIVE when a task touches an existing module: reads git log/blame/diff to surface prior changes, failed attempts, revert patterns, and code owners that bias the current plan.",
|
|
296
|
+
tools: ["Read", "Grep", "Glob", "Bash"],
|
|
297
|
+
model: "fast",
|
|
298
|
+
activation: "on-demand",
|
|
299
|
+
relatedStages: ["scope", "design", "plan", "review"],
|
|
300
|
+
body: [
|
|
301
|
+
"You are a **git history analyzer**.",
|
|
302
|
+
"",
|
|
303
|
+
"Read commit history, blame, and recent diffs for files the current task touches. The goal is to expose prior context (attempts, reverts, owners, flaky surfaces) the primary agent would otherwise miss.",
|
|
304
|
+
"",
|
|
305
|
+
"**Process:**",
|
|
306
|
+
"",
|
|
307
|
+
"1. For each impacted path: `git log --follow -n 20 -- <path>` and note the themes.",
|
|
308
|
+
"2. `git blame` the hot lines to surface current owners.",
|
|
309
|
+
"3. Look for `Revert ...`, `Reopen ...`, or repeated regressions in the last 90 days.",
|
|
310
|
+
"4. Check CODEOWNERS / committer frequency for ownership signal.",
|
|
311
|
+
"5. Flag any recent refactors or migrations in-flight that this task might collide with.",
|
|
312
|
+
"",
|
|
313
|
+
"**Output schema:**",
|
|
314
|
+
"",
|
|
315
|
+
"- `Impacted paths:` list.",
|
|
316
|
+
"- `Recent themes:` 3–5 bullets summarizing what changed lately in those paths.",
|
|
317
|
+
"- `Revert/regression signals:` list with commit SHAs.",
|
|
318
|
+
"- `Owners:` best-guess owners with supporting evidence.",
|
|
319
|
+
"- `Collision risks:` in-flight branches/migrations that overlap.",
|
|
320
|
+
"",
|
|
321
|
+
"**Role boundary:** read-only; never amend history, never `git push`. Use `git` commands only.",
|
|
322
|
+
].join("\n"),
|
|
323
|
+
},
|
|
173
324
|
];
|
|
174
325
|
import { enhancedAgentBody } from "./subagents.js";
|
|
175
326
|
/**
|
|
@@ -213,13 +364,29 @@ ${taskDelegation}
|
|
|
213
364
|
export function agentRoutingTable() {
|
|
214
365
|
return `| Stage Entry | Primary Agent | Supporting Agents |
|
|
215
366
|
|---|---|---|
|
|
216
|
-
| Brainstorm (start with \`/cc <idea>\`) | planner |
|
|
217
|
-
| Scope / Design / Spec / Plan (advance via \`/cc-next\`) | planner | security-reviewer on design, spec-reviewer on spec |
|
|
218
|
-
| TDD (via \`/cc-next\`) | test-author | doc-updater |
|
|
219
|
-
| Review (via \`/cc-next\`) | spec-reviewer, code-reviewer, security-reviewer |
|
|
367
|
+
| Brainstorm (start with \`/cc <idea>\`) | planner | repo-research-analyst, learnings-researcher, best-practices-researcher |
|
|
368
|
+
| Scope / Design / Spec / Plan (advance via \`/cc-next\`) | planner | security-reviewer on design, spec-reviewer on spec, framework-docs-researcher + git-history-analyzer on design/plan |
|
|
369
|
+
| TDD (via \`/cc-next\`) | test-author | doc-updater, framework-docs-researcher |
|
|
370
|
+
| Review (via \`/cc-next\`) | spec-reviewer, code-reviewer, security-reviewer | best-practices-researcher, git-history-analyzer |
|
|
220
371
|
| Ship (via \`/cc-next\`) | — | doc-updater |
|
|
221
372
|
`;
|
|
222
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Cost tier routing: keep heavy reasoning on the \`deep\` tier (planner, a
|
|
376
|
+
* single post-review reconciliation), push read-only research and narrow
|
|
377
|
+
* machine-only checks to the \`fast\` tier, and default review to \`balanced\`.
|
|
378
|
+
* This table is emitted into AGENTS.md so harness users understand why
|
|
379
|
+
* certain specialists are automatically fan-out-able without blowing the
|
|
380
|
+
* context budget.
|
|
381
|
+
*/
|
|
382
|
+
export function agentCostTierTable() {
|
|
383
|
+
return `| Tier | Use for | Example agents |
|
|
384
|
+
|---|---|---|
|
|
385
|
+
| \`deep\` | one heavy plan or one final reconciliation per stage | planner |
|
|
386
|
+
| \`balanced\` | spec compliance and code/security review with enough context | spec-reviewer, code-reviewer, security-reviewer, test-author |
|
|
387
|
+
| \`fast\` | read-only research / narrow machine checks / docs updates; safe to fan out 3-5× in parallel | repo-research-analyst, learnings-researcher, framework-docs-researcher, best-practices-researcher, git-history-analyzer, doc-updater |
|
|
388
|
+
`;
|
|
389
|
+
}
|
|
223
390
|
/**
|
|
224
391
|
* AGENTS.md-ready section describing Cclaw’s specialist delegation model.
|
|
225
392
|
*/
|
|
@@ -232,8 +399,12 @@ ${agentRoutingTable()}
|
|
|
232
399
|
|
|
233
400
|
**Activation modes:**
|
|
234
401
|
- **Mandatory:** MUST be used when the related stage runs (spec-reviewer, code-reviewer, and security-reviewer during review; planner during scope and design; test-author during tdd; doc-updater during ship). Even if a change has no trust-boundary impact, security-reviewer produces an explicit no-change attestation.
|
|
235
|
-
- **Proactive:** Should be used automatically when context matches (planner for complex features, security-reviewer escalations outside review, doc-updater on behavior changes)
|
|
236
|
-
- **On-demand:** Invoked only when explicitly requested
|
|
402
|
+
- **Proactive:** Should be used automatically when context matches (planner for complex features, repo-research-analyst / learnings-researcher at the start of brainstorm/scope/design, security-reviewer escalations outside review, doc-updater on behavior changes).
|
|
403
|
+
- **On-demand:** Invoked only when explicitly requested, but strongly suggested in the matching contexts (framework-docs-researcher when the task touches a specific library/SDK, best-practices-researcher when the task touches a well-known domain, git-history-analyzer when the task touches existing code).
|
|
404
|
+
|
|
405
|
+
### Cost-aware routing
|
|
406
|
+
|
|
407
|
+
${agentCostTierTable()}
|
|
237
408
|
|
|
238
409
|
**Agent files:** \`.cclaw/agents/{name}.md\` — each contains YAML frontmatter with tools and model tier.
|
|
239
410
|
`;
|
|
@@ -34,7 +34,7 @@ ${schema.hardGate}
|
|
|
34
34
|
2. Resolve active artifact root: \`.cclaw/artifacts/\`.
|
|
35
35
|
3. Load required upstream artifacts for this stage:
|
|
36
36
|
${hydrationLines}
|
|
37
|
-
4.
|
|
37
|
+
4. Stream \`.cclaw/knowledge.jsonl\` and apply relevant JSON-line entries (strict schema: type, trigger, action, confidence, domain, stage, created, project).
|
|
38
38
|
5. Write stage output to ${writeStepPaths}.
|
|
39
39
|
6. Do NOT copy artifacts into \`.cclaw/runs/\`; archival is handled only by \`cclaw archive\`.
|
|
40
40
|
|
package/dist/content/examples.js
CHANGED
|
@@ -432,6 +432,69 @@ Execution rule: complete and verify each wave before starting the next wave.
|
|
|
432
432
|
- Execution result: PR #42 created via \`gh pr create\`; CI passed; squash-merged to main.
|
|
433
433
|
- PR URL: https://github.com/example/repo/pull/42`,
|
|
434
434
|
};
|
|
435
|
+
const GOOD_BAD_EXAMPLES = {
|
|
436
|
+
brainstorm: {
|
|
437
|
+
good: "Problem: release checks are fragile and inconsistent between CI and local runs; invalid metadata sometimes reaches npm publish. Success: invalid release preconditions are caught before publish with explicit operator feedback, in both CI and local workflows. Constraints: no new runtime dependencies.",
|
|
438
|
+
bad: "Problem: releases are broken. Success: make them better. Constraints: be careful.",
|
|
439
|
+
lesson: "\"Make it better\" is not a success criterion — an agent cannot know when it is done. State the observable condition that proves success."
|
|
440
|
+
},
|
|
441
|
+
scope: {
|
|
442
|
+
good: "In scope: in-app notification feed, SSE delivery path, read/unread state, retry on transient failures. Out of scope: email/SMS/push providers, per-user preferences. Deferred: WebSocket channel, rich media, full-text search.",
|
|
443
|
+
bad: "In scope: notifications. Out of scope: stuff we are not doing. Deferred: v2.",
|
|
444
|
+
lesson: "Vague boundaries get relitigated in every subsequent stage. Enumerate concrete capabilities on each side — \"stuff we are not doing\" is not a decision."
|
|
445
|
+
},
|
|
446
|
+
design: {
|
|
447
|
+
good: "Failure: SSE connection drop. Trigger: network interruption. Detection: client heartbeat timeout (30s). Mitigation: auto-reconnect with exponential backoff + REST snapshot fallback. User impact: ≤10s delay, no data loss.",
|
|
448
|
+
bad: "Failure: network errors. Mitigation: retry and log. User impact: users may see issues sometimes.",
|
|
449
|
+
lesson: "A failure row without a detection signal and a bounded user impact is aspirational, not a design. Name the trigger, the detector, and the recovery behavior."
|
|
450
|
+
},
|
|
451
|
+
spec: {
|
|
452
|
+
good: "AC-1: Given a signed-in user with an active session, when the server publishes a new notification event for that user, the client feed shows the new item within 5 seconds without a full page reload.",
|
|
453
|
+
bad: "AC-1: Users should see their notifications quickly and reliably, with a good user experience.",
|
|
454
|
+
lesson: "Spec criteria must be observable, measurable, and falsifiable. \"Quickly\" is a feeling; \"within 5 seconds without a full page reload\" is a test."
|
|
455
|
+
},
|
|
456
|
+
plan: {
|
|
457
|
+
good: "T-2: Implement publisher + outbox write path. Acceptance: AC-1. Verification: `pnpm vitest run tests/integration/publisher.test.ts`. Depends on: T-1. Effort: M.",
|
|
458
|
+
bad: "T-2: Build the backend. Verify: manual testing. Effort: a few days.",
|
|
459
|
+
lesson: "A task without a single acceptance criterion and a reproducible verification command is a wish. If you cannot say how you will know it is done, you cannot ship it."
|
|
460
|
+
},
|
|
461
|
+
tdd: {
|
|
462
|
+
good: "RED: `pnpm vitest run tests/unit/dedupe-feed.test.ts` → `publishToOutbox is not a function`. GREEN (after minimal impl): same command, 47/47 pass, full suite. REFACTOR: extracted `mergeLatestByDedupeKey`; suite still 47/47.",
|
|
463
|
+
bad: "Wrote the publisher code. Tests pass now. Will add unit tests later when I have time.",
|
|
464
|
+
lesson: "Code written before a failing test is guessing validated after the fact. The RED failure IS the specification — without it, the GREEN pass proves nothing about the intended behavior."
|
|
465
|
+
},
|
|
466
|
+
review: {
|
|
467
|
+
good: "R-1 Critical: snapshot endpoint returns newest N rows but does not guarantee consistency with stream cursor — users can miss items between snapshot and subscribe. Evidence: integration test `notification-consistency.test.ts:22-58`. Status: open.",
|
|
468
|
+
bad: "Looks good overall. A few small things could be polished, maybe refactor the merge logic. LGTM.",
|
|
469
|
+
lesson: "\"LGTM\" is not a review — it is a signature on whatever the author shipped. Every finding needs a severity, a falsifiable description, evidence, and a status."
|
|
470
|
+
},
|
|
471
|
+
ship: {
|
|
472
|
+
good: "Rollback trigger: error rate on `/notifications/stream` >5% for 5 minutes, or p95 publish-to-visible lag >10s. Steps: `git revert <merge-sha> && git push origin main` then redeploy; run `2026_04_12_notifications_cursor_down.sql` before traffic. Verification: error rate returns to baseline within 10 minutes.",
|
|
473
|
+
bad: "Rollback plan: revert the commit if anything goes wrong.",
|
|
474
|
+
lesson: "\"Revert if anything goes wrong\" leaves the on-call engineer to invent the plan at 2 a.m. The rollback trigger is an operational contract: state the signal, the command, and the verification."
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
export function stageGoodBadExamples(stage) {
|
|
478
|
+
const sample = GOOD_BAD_EXAMPLES[stage];
|
|
479
|
+
if (!sample)
|
|
480
|
+
return "";
|
|
481
|
+
return [
|
|
482
|
+
"## Good vs Bad (at-a-glance)",
|
|
483
|
+
"",
|
|
484
|
+
"Contrasting samples to calibrate the quality bar for this stage. Read before writing the artifact — mirror the **Good** shape, avoid the **Bad** shape.",
|
|
485
|
+
"",
|
|
486
|
+
"**Good**",
|
|
487
|
+
"",
|
|
488
|
+
"> " + sample.good,
|
|
489
|
+
"",
|
|
490
|
+
"**Bad**",
|
|
491
|
+
"",
|
|
492
|
+
"> " + sample.bad,
|
|
493
|
+
"",
|
|
494
|
+
"**Why it matters:** " + sample.lesson,
|
|
495
|
+
""
|
|
496
|
+
].join("\n");
|
|
497
|
+
}
|
|
435
498
|
export function stageExamples(stage) {
|
|
436
499
|
const examples = STAGE_EXAMPLES[stage];
|
|
437
500
|
if (!examples)
|
package/dist/content/hooks.js
CHANGED
|
@@ -51,7 +51,7 @@ SUGGESTION_MEMORY_FILE="$ROOT/${RUNTIME_ROOT}/state/suggestion-memory.json"
|
|
|
51
51
|
CONTEXT_WARNINGS_FILE="$ROOT/${RUNTIME_ROOT}/state/context-warnings.jsonl"
|
|
52
52
|
CONTEXT_MODE_FILE="$ROOT/${RUNTIME_ROOT}/state/context-mode.json"
|
|
53
53
|
CONTEXTS_DIR="$ROOT/${RUNTIME_ROOT}/contexts"
|
|
54
|
-
KNOWLEDGE_FILE="$ROOT/${RUNTIME_ROOT}/knowledge.
|
|
54
|
+
KNOWLEDGE_FILE="$ROOT/${RUNTIME_ROOT}/knowledge.jsonl"
|
|
55
55
|
META_SKILL="$ROOT/${RUNTIME_ROOT}/skills/${META_SKILL_NAME}/SKILL.md"
|
|
56
56
|
|
|
57
57
|
# --- Read flow state ---
|
|
@@ -309,7 +309,7 @@ if [ -f "$META_SKILL" ]; then
|
|
|
309
309
|
META_CONTENT=$(cat "$META_SKILL" 2>/dev/null || echo "")
|
|
310
310
|
fi
|
|
311
311
|
|
|
312
|
-
# --- Load knowledge snapshot (
|
|
312
|
+
# --- Load knowledge snapshot (canonical JSONL tail) ---
|
|
313
313
|
KNOWLEDGE_SUMMARY=""
|
|
314
314
|
if [ -f "$KNOWLEDGE_FILE" ] && [ -s "$KNOWLEDGE_FILE" ]; then
|
|
315
315
|
KNOWLEDGE_SUMMARY=$(tail -n 30 "$KNOWLEDGE_FILE" 2>/dev/null || echo "")
|
|
@@ -593,7 +593,7 @@ RUN_SYNC_NOTE="Run metadata sync removed; active artifacts stay in ${RUNTIME_ROO
|
|
|
593
593
|
|
|
594
594
|
# --- Escape for JSON ---
|
|
595
595
|
${ESCAPE_FN}
|
|
596
|
-
MSG=$(escape_json "Cclaw: session ending (stage=$STAGE, run=$ACTIVE_RUN). $CHECKPOINT_NOTE $RUN_SYNC_NOTE Before stopping: (1) confirm flow-state reflects reality, (2) ensure artifact changes match current feature intent, (3) if you discovered a non-obvious rule/pattern, append
|
|
596
|
+
MSG=$(escape_json "Cclaw: session ending (stage=$STAGE, run=$ACTIVE_RUN). $CHECKPOINT_NOTE $RUN_SYNC_NOTE Before stopping: (1) confirm flow-state reflects reality, (2) ensure artifact changes match current feature intent, (3) if you discovered a non-obvious rule/pattern, append one strict-schema JSON line to ${RUNTIME_ROOT}/knowledge.jsonl, (4) commit or revert pending changes.")
|
|
597
597
|
|
|
598
598
|
# --- Output harness-specific JSON ---
|
|
599
599
|
case "$HARNESS" in
|
|
@@ -631,7 +631,7 @@ INPUT=$(cat 2>/dev/null || echo '{}')
|
|
|
631
631
|
STATE_DIR="$ROOT/${RUNTIME_ROOT}/state"
|
|
632
632
|
STATE_FILE="$STATE_DIR/flow-state.json"
|
|
633
633
|
DELEGATION_FILE="$STATE_DIR/delegation-log.json"
|
|
634
|
-
KNOWLEDGE_FILE="$ROOT/${RUNTIME_ROOT}/knowledge.
|
|
634
|
+
KNOWLEDGE_FILE="$ROOT/${RUNTIME_ROOT}/knowledge.jsonl"
|
|
635
635
|
DIGEST_FILE="$STATE_DIR/session-digest.md"
|
|
636
636
|
DIGEST_TMP="$STATE_DIR/session-digest.md.tmp.$$"
|
|
637
637
|
|
|
@@ -786,7 +786,7 @@ export default function cclawPlugin(ctx) {
|
|
|
786
786
|
const contextModePath = join(stateDir, "context-mode.json");
|
|
787
787
|
const contextsDir = join(runtimeDir, "contexts");
|
|
788
788
|
const sessionDigestPath = join(stateDir, "session-digest.md");
|
|
789
|
-
const knowledgePath = join(runtimeDir, "knowledge.
|
|
789
|
+
const knowledgePath = join(runtimeDir, "knowledge.jsonl");
|
|
790
790
|
const metaSkillPath = join(runtimeDir, "skills/${META_SKILL_NAME}/SKILL.md");
|
|
791
791
|
|
|
792
792
|
function ensureRuntimeDirs() {
|
|
@@ -923,7 +923,7 @@ export default function cclawPlugin(ctx) {
|
|
|
923
923
|
if (knowledge.length > 0) parts.push("Knowledge snapshot (latest entries):", ...knowledge);
|
|
924
924
|
|
|
925
925
|
parts.push(
|
|
926
|
-
"If you discover a non-obvious rule or pattern, append
|
|
926
|
+
"If you discover a non-obvious rule or pattern, append one strict-schema JSON line to .cclaw/knowledge.jsonl using type: rule, pattern, lesson, or compound."
|
|
927
927
|
);
|
|
928
928
|
|
|
929
929
|
const meta = readFileText(metaSkillPath).trim();
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSONL field order (matches the reference spec).
|
|
3
|
+
* Exported for tests and any programmatic writer that wants the exact shape.
|
|
4
|
+
*/
|
|
5
|
+
export declare const KNOWLEDGE_JSONL_FIELDS: readonly ["type", "trigger", "action", "confidence", "domain", "stage", "created", "project"];
|
|
1
6
|
export declare function learnSkillMarkdown(): string;
|
|
2
7
|
export declare function learnCommandContract(): string;
|
|
3
8
|
export declare function selfImprovementBlock(stageName: string): string;
|