cclaw-cli 0.51.30 → 1.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.
Files changed (160) hide show
  1. package/README.md +24 -18
  2. package/dist/artifact-linter/brainstorm.d.ts +2 -0
  3. package/dist/artifact-linter/brainstorm.js +289 -0
  4. package/dist/artifact-linter/design.d.ts +2 -0
  5. package/dist/artifact-linter/design.js +354 -0
  6. package/dist/artifact-linter/plan.d.ts +2 -0
  7. package/dist/artifact-linter/plan.js +183 -0
  8. package/dist/artifact-linter/review-army.d.ts +24 -0
  9. package/dist/artifact-linter/review-army.js +365 -0
  10. package/dist/artifact-linter/review.d.ts +2 -0
  11. package/dist/artifact-linter/review.js +99 -0
  12. package/dist/artifact-linter/scope.d.ts +2 -0
  13. package/dist/artifact-linter/scope.js +125 -0
  14. package/dist/artifact-linter/shared.d.ts +247 -0
  15. package/dist/artifact-linter/shared.js +1517 -0
  16. package/dist/artifact-linter/ship.d.ts +2 -0
  17. package/dist/artifact-linter/ship.js +82 -0
  18. package/dist/artifact-linter/spec.d.ts +2 -0
  19. package/dist/artifact-linter/spec.js +130 -0
  20. package/dist/artifact-linter/tdd.d.ts +2 -0
  21. package/dist/artifact-linter/tdd.js +198 -0
  22. package/dist/artifact-linter.d.ts +4 -76
  23. package/dist/artifact-linter.js +56 -2949
  24. package/dist/cli.d.ts +1 -6
  25. package/dist/cli.js +4 -159
  26. package/dist/codex-feature-flag.d.ts +1 -1
  27. package/dist/codex-feature-flag.js +1 -1
  28. package/dist/config.d.ts +3 -2
  29. package/dist/config.js +67 -3
  30. package/dist/constants.d.ts +1 -7
  31. package/dist/constants.js +10 -15
  32. package/dist/content/cancel-command.js +2 -2
  33. package/dist/content/closeout-guidance.d.ts +1 -1
  34. package/dist/content/closeout-guidance.js +15 -13
  35. package/dist/content/core-agents.d.ts +46 -29
  36. package/dist/content/core-agents.js +216 -82
  37. package/dist/content/decision-protocol.d.ts +1 -1
  38. package/dist/content/decision-protocol.js +1 -1
  39. package/dist/content/diff-command.js +1 -1
  40. package/dist/content/examples.d.ts +0 -3
  41. package/dist/content/examples.js +197 -752
  42. package/dist/content/harness-doc.js +20 -2
  43. package/dist/content/hook-manifest.d.ts +2 -2
  44. package/dist/content/hook-manifest.js +2 -2
  45. package/dist/content/hooks.d.ts +1 -0
  46. package/dist/content/hooks.js +32 -137
  47. package/dist/content/idea.d.ts +60 -0
  48. package/dist/content/idea.js +404 -0
  49. package/dist/content/iron-laws.d.ts +0 -1
  50. package/dist/content/iron-laws.js +31 -16
  51. package/dist/content/learnings.d.ts +2 -4
  52. package/dist/content/learnings.js +11 -27
  53. package/dist/content/meta-skill.js +7 -7
  54. package/dist/content/node-hooks.d.ts +10 -0
  55. package/dist/content/node-hooks.js +163 -95
  56. package/dist/content/opencode-plugin.js +15 -29
  57. package/dist/content/reference-patterns.js +2 -2
  58. package/dist/content/runtime-shared-snippets.d.ts +8 -0
  59. package/dist/content/runtime-shared-snippets.js +80 -0
  60. package/dist/content/session-hooks.js +1 -1
  61. package/dist/content/skills.d.ts +1 -0
  62. package/dist/content/skills.js +69 -7
  63. package/dist/content/stage-schema.js +147 -61
  64. package/dist/content/stages/_lint-metadata/index.js +26 -2
  65. package/dist/content/stages/brainstorm.js +13 -7
  66. package/dist/content/stages/design.js +16 -11
  67. package/dist/content/stages/plan.js +7 -4
  68. package/dist/content/stages/review.js +12 -12
  69. package/dist/content/stages/schema-types.d.ts +2 -2
  70. package/dist/content/stages/scope.js +15 -12
  71. package/dist/content/stages/ship.js +3 -3
  72. package/dist/content/stages/spec.js +9 -3
  73. package/dist/content/stages/tdd.js +14 -4
  74. package/dist/content/start-command.js +11 -10
  75. package/dist/content/status-command.js +5 -5
  76. package/dist/content/subagent-context-skills.js +156 -1
  77. package/dist/content/subagents.d.ts +0 -5
  78. package/dist/content/subagents.js +65 -81
  79. package/dist/content/templates.d.ts +1 -1
  80. package/dist/content/templates.js +187 -154
  81. package/dist/content/tree-command.js +2 -2
  82. package/dist/content/utility-skills.d.ts +2 -2
  83. package/dist/content/utility-skills.js +28 -99
  84. package/dist/content/view-command.js +4 -2
  85. package/dist/delegation.d.ts +2 -0
  86. package/dist/delegation.js +2 -1
  87. package/dist/early-loop.d.ts +66 -0
  88. package/dist/early-loop.js +275 -0
  89. package/dist/flow-state.d.ts +5 -6
  90. package/dist/flow-state.js +4 -6
  91. package/dist/gate-evidence.d.ts +0 -23
  92. package/dist/gate-evidence.js +111 -153
  93. package/dist/harness-adapters.d.ts +2 -2
  94. package/dist/harness-adapters.js +48 -19
  95. package/dist/install.js +190 -32
  96. package/dist/internal/advance-stage/advance.d.ts +50 -0
  97. package/dist/internal/advance-stage/advance.js +479 -0
  98. package/dist/internal/advance-stage/cancel-run.d.ts +8 -0
  99. package/dist/internal/advance-stage/cancel-run.js +19 -0
  100. package/dist/internal/advance-stage/flow-state-coercion.d.ts +3 -0
  101. package/dist/internal/advance-stage/flow-state-coercion.js +81 -0
  102. package/dist/internal/advance-stage/helpers.d.ts +14 -0
  103. package/dist/internal/advance-stage/helpers.js +145 -0
  104. package/dist/internal/advance-stage/hook.d.ts +8 -0
  105. package/dist/internal/advance-stage/hook.js +40 -0
  106. package/dist/internal/advance-stage/parsers.d.ts +54 -0
  107. package/dist/internal/advance-stage/parsers.js +307 -0
  108. package/dist/internal/advance-stage/review-loop.d.ts +7 -0
  109. package/dist/internal/advance-stage/review-loop.js +161 -0
  110. package/dist/internal/advance-stage/rewind.d.ts +14 -0
  111. package/dist/internal/advance-stage/rewind.js +108 -0
  112. package/dist/internal/advance-stage/start-flow.d.ts +11 -0
  113. package/dist/internal/advance-stage/start-flow.js +136 -0
  114. package/dist/internal/advance-stage/verify.d.ts +29 -0
  115. package/dist/internal/advance-stage/verify.js +225 -0
  116. package/dist/internal/advance-stage.js +21 -1470
  117. package/dist/internal/compound-readiness.d.ts +1 -1
  118. package/dist/internal/compound-readiness.js +2 -2
  119. package/dist/internal/early-loop-status.d.ts +7 -0
  120. package/dist/internal/early-loop-status.js +90 -0
  121. package/dist/internal/runtime-integrity.d.ts +7 -0
  122. package/dist/internal/runtime-integrity.js +288 -0
  123. package/dist/internal/tdd-red-evidence.js +1 -1
  124. package/dist/knowledge-store.d.ts +5 -28
  125. package/dist/knowledge-store.js +57 -84
  126. package/dist/managed-resources.js +24 -2
  127. package/dist/policy.js +7 -9
  128. package/dist/retro-gate.js +8 -90
  129. package/dist/run-archive.d.ts +1 -1
  130. package/dist/run-archive.js +13 -16
  131. package/dist/run-persistence.js +20 -15
  132. package/dist/runtime/run-hook.entry.d.ts +3 -0
  133. package/dist/runtime/run-hook.entry.js +5 -0
  134. package/dist/runtime/run-hook.mjs +9477 -0
  135. package/dist/tdd-cycle.d.ts +3 -3
  136. package/dist/tdd-cycle.js +1 -1
  137. package/dist/types.d.ts +18 -10
  138. package/package.json +4 -2
  139. package/dist/content/hook-inline-snippets.d.ts +0 -83
  140. package/dist/content/hook-inline-snippets.js +0 -302
  141. package/dist/content/ideate-command.d.ts +0 -8
  142. package/dist/content/ideate-command.js +0 -315
  143. package/dist/content/ideate-frames.d.ts +0 -31
  144. package/dist/content/ideate-frames.js +0 -140
  145. package/dist/content/ideate-ranking.d.ts +0 -25
  146. package/dist/content/ideate-ranking.js +0 -65
  147. package/dist/content/next-command.d.ts +0 -20
  148. package/dist/content/next-command.js +0 -298
  149. package/dist/content/seed-shelf.d.ts +0 -36
  150. package/dist/content/seed-shelf.js +0 -301
  151. package/dist/content/stage-common-guidance.d.ts +0 -1
  152. package/dist/content/stage-common-guidance.js +0 -106
  153. package/dist/doctor-registry.d.ts +0 -10
  154. package/dist/doctor-registry.js +0 -186
  155. package/dist/doctor.d.ts +0 -17
  156. package/dist/doctor.js +0 -2201
  157. package/dist/internal/hook-manifest.d.ts +0 -16
  158. package/dist/internal/hook-manifest.js +0 -77
  159. package/dist/trace-matrix.d.ts +0 -27
  160. package/dist/trace-matrix.js +0 -226
package/dist/cli.d.ts CHANGED
@@ -2,18 +2,13 @@
2
2
  import type { FlowTrack, HarnessId } from "./types.js";
3
3
  import type { ArchiveDisposition } from "./runs.js";
4
4
  export { parseHarnessSelectionAnswer } from "./harness-selection.js";
5
- type CommandName = "init" | "sync" | "doctor" | "upgrade" | "uninstall" | "archive" | "internal";
5
+ type CommandName = "init" | "sync" | "upgrade" | "uninstall" | "archive" | "internal";
6
6
  interface ParsedArgs {
7
7
  command?: CommandName;
8
8
  harnesses?: HarnessId[];
9
9
  track?: FlowTrack;
10
10
  dryRun?: boolean;
11
11
  interactive?: boolean;
12
- reconcileGates?: boolean;
13
- doctorJson?: boolean;
14
- doctorExplain?: boolean;
15
- doctorQuiet?: boolean;
16
- doctorOnly?: string[];
17
12
  archiveName?: string;
18
13
  archiveSkipRetro?: boolean;
19
14
  archiveSkipRetroReason?: string;
package/dist/cli.js CHANGED
@@ -4,7 +4,6 @@ import path from "node:path";
4
4
  import { existsSync, realpathSync } from "node:fs";
5
5
  import { createInterface } from "node:readline/promises";
6
6
  import { fileURLToPath } from "node:url";
7
- import { doctorChecks, doctorSucceeded } from "./doctor.js";
8
7
  import { initCclaw, syncCclaw, uninstallCclaw, upgradeCclaw } from "./install.js";
9
8
  import { error, info } from "./logger.js";
10
9
  import { FLOW_TRACKS, HARNESS_IDS } from "./types.js";
@@ -20,7 +19,6 @@ import { runInternalCommand } from "./internal/advance-stage.js";
20
19
  const INSTALLER_COMMANDS = [
21
20
  "init",
22
21
  "sync",
23
- "doctor",
24
22
  "upgrade",
25
23
  "uninstall",
26
24
  "archive",
@@ -42,12 +40,6 @@ Commands:
42
40
  sync Reconcile generated runtime files with the current config.
43
41
  Flags: --harnesses=<list> Update configured harnesses before syncing.
44
42
  --interactive Pick harnesses from a numbered TTY menu.
45
- doctor Check install/runtime wiring and print concrete fixes for failures.
46
- Flags: --explain Include docs pointers for every check.
47
- --json Emit machine-readable check results.
48
- --quiet Show only failing checks.
49
- --only=<filter> Limit displayed checks (error,warning,hook:,state:,...).
50
- --reconcile-gates Refresh derived gate status before checking; does not repair missing artifacts/tests.
51
43
  upgrade Refresh generated files in .cclaw. Preserves your config.yaml.
52
44
  archive Archive the active run and reset flow state for the next run.
53
45
  Flags: --name=<slug> Override archive folder suffix.
@@ -69,10 +61,9 @@ Examples:
69
61
  npx cclaw-cli archive --disposition=cancelled --reason="deprioritized"
70
62
  npx cclaw-cli upgrade
71
63
 
72
- Happy-path work happens inside your harness via /cc, /cc-ideate,
73
- and /cc-cancel. Doctor is an operator/support surface:
74
- it verifies install/runtime wiring, but a real harness smoke test is
75
- still needed to prove provider auth and model execution.
64
+ Happy-path work happens inside your harness via /cc, /cc-idea,
65
+ and /cc-cancel. Installer/support operations are init/sync/upgrade/uninstall
66
+ plus explicit archive actions.
76
67
 
77
68
  Docs: https://github.com/zuevrs/cclaw
78
69
  Local: README.md and generated .cclaw/skills/*.md
@@ -139,7 +130,7 @@ function buildInitSurfacePreview(harnesses) {
139
130
  ".cclaw/agents/*.md",
140
131
  ".cclaw/hooks/*",
141
132
  ".cclaw/rules/**",
142
- ".cclaw/runs/**",
133
+ ".cclaw/archive/**",
143
134
  ".cclaw/artifacts/**",
144
135
  ".cclaw/knowledge.jsonl",
145
136
  ".cclaw/state/*.json|*.jsonl",
@@ -316,98 +307,6 @@ async function resolveSyncInputs(parsed, ctx) {
316
307
  }, ctx, "Sync harness reconfiguration")
317
308
  };
318
309
  }
319
- function parseDoctorOnly(raw) {
320
- return raw
321
- .split(",")
322
- .map((item) => item.trim().toLowerCase())
323
- .filter((item) => item.length > 0);
324
- }
325
- function filterDoctorChecks(checks, filters) {
326
- if (!filters || filters.length === 0) {
327
- return checks;
328
- }
329
- return checks.filter((check) => {
330
- const name = check.name.toLowerCase();
331
- return filters.some((filter) => {
332
- if (filter === "error" || filter === "warning" || filter === "info") {
333
- return check.severity === filter;
334
- }
335
- return name.includes(filter);
336
- });
337
- });
338
- }
339
- function doctorCountsBySeverity(checks) {
340
- const result = {
341
- error: { total: 0, failing: 0 },
342
- warning: { total: 0, failing: 0 },
343
- info: { total: 0, failing: 0 }
344
- };
345
- for (const check of checks) {
346
- const bucket = result[check.severity];
347
- bucket.total += 1;
348
- if (!check.ok) {
349
- bucket.failing += 1;
350
- }
351
- }
352
- return result;
353
- }
354
- const DOCTOR_ACTION_GROUP_LABELS = {
355
- sync: "Can fix with cclaw sync",
356
- "user-action": "Requires user action",
357
- "stage-work": "Requires stage work",
358
- informational: "Informational warning"
359
- };
360
- function doctorActionGroupOrder(group) {
361
- return group === "sync" ? 0 : group === "user-action" ? 1 : group === "stage-work" ? 2 : 3;
362
- }
363
- function printDoctorText(ctx, checks, options) {
364
- const orderedSeverities = ["error", "warning", "info"];
365
- const view = options.quiet ? checks.filter((check) => !check.ok) : checks;
366
- const actionGroups = [...new Set(view.map((check) => check.actionGroup))]
367
- .sort((left, right) => doctorActionGroupOrder(left) - doctorActionGroupOrder(right));
368
- for (const actionGroup of actionGroups) {
369
- const groupChecks = view.filter((check) => check.actionGroup === actionGroup);
370
- const failingInGroup = groupChecks.filter((check) => !check.ok).length;
371
- ctx.stdout.write(`
372
- [${DOCTOR_ACTION_GROUP_LABELS[actionGroup]}] ${failingInGroup}/${groupChecks.length} failing
373
- `);
374
- for (const severity of orderedSeverities) {
375
- const inBucket = groupChecks.filter((check) => check.severity === severity);
376
- if (inBucket.length === 0)
377
- continue;
378
- ctx.stdout.write(` ${severity.toUpperCase()}
379
- `);
380
- for (const check of inBucket) {
381
- const status = check.ok ? "PASS" : "FAIL";
382
- ctx.stdout.write(` ${status} ${check.name} :: ${check.summary}
383
- `);
384
- if (!options.quiet) {
385
- ctx.stdout.write(` details: ${check.details}
386
- `);
387
- }
388
- if (!check.ok || options.explain) {
389
- ctx.stdout.write(` next action: ${check.fix}
390
- `);
391
- if (check.docRef) {
392
- ctx.stdout.write(` reference: ${check.docRef}
393
- `);
394
- }
395
- }
396
- }
397
- }
398
- }
399
- const counts = doctorCountsBySeverity(checks);
400
- const failingErrors = checks.filter((check) => check.severity === "error" && !check.ok).length;
401
- ctx.stdout.write(`\nTotals: error ${counts.error.failing}/${counts.error.total} failing, ` +
402
- `warning ${counts.warning.failing}/${counts.warning.total} failing, ` +
403
- `info ${counts.info.failing}/${counts.info.total} failing\n`);
404
- if (failingErrors > 0) {
405
- ctx.stdout.write(`Doctor status: BLOCKED (${failingErrors} failing error checks)\n`);
406
- }
407
- else {
408
- ctx.stdout.write("Doctor status: HEALTHY (no failing error checks)\n");
409
- }
410
- }
411
310
  function parseArgs(argv) {
412
311
  const parsed = {};
413
312
  const helpFlag = argv.find((arg) => arg === "--help" || arg === "-h");
@@ -439,13 +338,6 @@ function parseArgs(argv) {
439
338
  flag === "--no-interactive" ||
440
339
  (parsed.command === "init" && flag === "--dry-run");
441
340
  }
442
- if (parsed.command === "doctor") {
443
- return flag === "--reconcile-gates" ||
444
- flag === "--json" ||
445
- flag === "--explain" ||
446
- flag === "--quiet" ||
447
- flag.startsWith("--only=");
448
- }
449
341
  if (parsed.command === "archive") {
450
342
  return flag.startsWith("--name=") ||
451
343
  flag === "--skip-retro" ||
@@ -482,26 +374,6 @@ function parseArgs(argv) {
482
374
  parsed.dryRun = true;
483
375
  continue;
484
376
  }
485
- if (flag === "--reconcile-gates") {
486
- parsed.reconcileGates = true;
487
- continue;
488
- }
489
- if (flag === "--json") {
490
- parsed.doctorJson = true;
491
- continue;
492
- }
493
- if (flag === "--explain") {
494
- parsed.doctorExplain = true;
495
- continue;
496
- }
497
- if (flag === "--quiet") {
498
- parsed.doctorQuiet = true;
499
- continue;
500
- }
501
- if (flag.startsWith("--only=")) {
502
- parsed.doctorOnly = parseDoctorOnly(flag.replace("--only=", ""));
503
- continue;
504
- }
505
377
  if (flag.startsWith("--name=")) {
506
378
  parsed.archiveName = flag.replace("--name=", "").trim();
507
379
  continue;
@@ -587,33 +459,6 @@ async function runCommand(parsed, ctx) {
587
459
  info(ctx, `Synchronized harness shims from current .cclaw config${harnessNote}`);
588
460
  return 0;
589
461
  }
590
- if (command === "doctor") {
591
- const checks = await doctorChecks(ctx.cwd, {
592
- reconcileCurrentStageGates: parsed.reconcileGates === true
593
- });
594
- const filteredChecks = filterDoctorChecks(checks, parsed.doctorOnly);
595
- const explain = parsed.doctorExplain === true;
596
- const quiet = parsed.doctorQuiet === true;
597
- if (parsed.doctorJson === true) {
598
- const counts = doctorCountsBySeverity(filteredChecks);
599
- ctx.stdout.write(`${JSON.stringify({
600
- ok: doctorSucceeded(filteredChecks),
601
- globalOk: doctorSucceeded(checks),
602
- filters: parsed.doctorOnly ?? [],
603
- counts,
604
- checks: filteredChecks
605
- }, null, 2)}\n`);
606
- }
607
- else {
608
- if (filteredChecks.length === 0) {
609
- ctx.stdout.write("No checks matched the --only filter.\n");
610
- }
611
- else {
612
- printDoctorText(ctx, filteredChecks, { explain, quiet });
613
- }
614
- }
615
- return doctorSucceeded(filteredChecks) ? 0 : 2;
616
- }
617
462
  if (command === "upgrade") {
618
463
  await upgradeCclaw(ctx.cwd);
619
464
  info(ctx, "Upgraded .cclaw runtime and regenerated generated files");
@@ -11,7 +11,7 @@
11
11
  * ```
12
12
  *
13
13
  * in `$CODEX_HOME/config.toml` (default: `~/.codex/config.toml`).
14
- * cclaw init/sync can prompt the user to flip this flag for them; `cclaw doctor --explain` reports the concrete repair when it is missing;
14
+ * cclaw init/sync can prompt the user to flip this flag for them; sync/runtime diagnostics report the concrete repair when it is missing;
15
15
  * this module owns the detection / mutation code so the prompt logic in
16
16
  * `cli.ts` stays small and testable.
17
17
  *
@@ -11,7 +11,7 @@
11
11
  * ```
12
12
  *
13
13
  * in `$CODEX_HOME/config.toml` (default: `~/.codex/config.toml`).
14
- * cclaw init/sync can prompt the user to flip this flag for them; `cclaw doctor --explain` reports the concrete repair when it is missing;
14
+ * cclaw init/sync can prompt the user to flip this flag for them; sync/runtime diagnostics report the concrete repair when it is missing;
15
15
  * this module owns the detection / mutation code so the prompt logic in
16
16
  * `cli.ts` stays small and testable.
17
17
  *
package/dist/config.d.ts CHANGED
@@ -24,9 +24,10 @@ export declare const DEFAULT_TDD_TEST_PATH_PATTERNS: readonly string[];
24
24
  export declare const DEFAULT_TDD_TEST_GLOBS: readonly string[];
25
25
  export declare const DEFAULT_TDD_PRODUCTION_PATH_PATTERNS: readonly string[];
26
26
  export declare const DEFAULT_COMPOUND_RECURRENCE_THRESHOLD = 3;
27
+ export declare const DEFAULT_EARLY_LOOP_MAX_ITERATIONS = 3;
27
28
  /**
28
29
  * Populated runtime view of config values that downstream callers (install,
29
- * observe, doctor) consume. Always has the derived guard modes populated,
30
+ * observe, sync/runtime checks) consume. Always has the derived guard modes populated,
30
31
  * regardless of whether the user wrote `strictness`, the legacy keys, both,
31
32
  * or neither.
32
33
  */
@@ -49,7 +50,7 @@ export declare function readConfig(projectRoot: string, options?: ReadConfigOpti
49
50
  * the user set them explicitly. Keeps the default template small and honest:
50
51
  * only knobs a new user would meaningfully flip show up.
51
52
  */
52
- type AdvancedConfigKey = "vcs" | "tddTestGlobs" | "tdd" | "compound" | "defaultTrack" | "languageRulePacks" | "trackHeuristics" | "sliceReview" | "ironLaws" | "optInAudits" | "reviewLoop";
53
+ type AdvancedConfigKey = "vcs" | "tddTestGlobs" | "tdd" | "compound" | "earlyLoop" | "defaultTrack" | "languageRulePacks" | "trackHeuristics" | "sliceReview" | "ironLaws" | "optInAudits" | "reviewLoop";
53
54
  /**
54
55
  * Options controlling the serialisation shape of `config.yaml`.
55
56
  *
package/dist/config.js CHANGED
@@ -21,6 +21,8 @@ const ALLOWED_CONFIG_KEYS = new Set([
21
21
  "tddTestGlobs",
22
22
  "tdd",
23
23
  "compound",
24
+ "earlyLoop",
25
+ "early_loop",
24
26
  "gitHookGuards",
25
27
  "defaultTrack",
26
28
  "languageRulePacks",
@@ -131,9 +133,10 @@ export const DEFAULT_TDD_TEST_PATH_PATTERNS = [
131
133
  export const DEFAULT_TDD_TEST_GLOBS = [...DEFAULT_TDD_TEST_PATH_PATTERNS];
132
134
  export const DEFAULT_TDD_PRODUCTION_PATH_PATTERNS = [];
133
135
  export const DEFAULT_COMPOUND_RECURRENCE_THRESHOLD = 3;
136
+ export const DEFAULT_EARLY_LOOP_MAX_ITERATIONS = 3;
134
137
  /**
135
138
  * Populated runtime view of config values that downstream callers (install,
136
- * observe, doctor) consume. Always has the derived guard modes populated,
139
+ * observe, sync/runtime checks) consume. Always has the derived guard modes populated,
137
140
  * regardless of whether the user wrote `strictness`, the legacy keys, both,
138
141
  * or neither.
139
142
  */
@@ -155,11 +158,19 @@ export function createDefaultConfig(harnesses = DEFAULT_HARNESSES, defaultTrack
155
158
  compound: {
156
159
  recurrenceThreshold: DEFAULT_COMPOUND_RECURRENCE_THRESHOLD
157
160
  },
161
+ earlyLoop: {
162
+ enabled: true,
163
+ maxIterations: DEFAULT_EARLY_LOOP_MAX_ITERATIONS
164
+ },
158
165
  gitHookGuards: false,
159
166
  defaultTrack,
160
167
  languageRulePacks: [],
161
168
  ironLaws: {
162
169
  strictLaws: []
170
+ },
171
+ optInAudits: {
172
+ scopePreAudit: false,
173
+ staleDiagramAudit: true
163
174
  }
164
175
  };
165
176
  }
@@ -327,6 +338,46 @@ export async function readConfig(projectRoot, options = {}) {
327
338
  compoundRecurrenceThreshold = compoundRaw.recurrenceThreshold;
328
339
  }
329
340
  }
341
+ const hasEarlyLoopField = Object.prototype.hasOwnProperty.call(parsed, "earlyLoop");
342
+ const hasLegacyEarlyLoopField = Object.prototype.hasOwnProperty.call(parsed, "early_loop");
343
+ if (hasEarlyLoopField && hasLegacyEarlyLoopField) {
344
+ emitConfigWarningOnce(warningState, "CCLAW_CONFIG_EARLY_LOOP_ALIAS", `[cclaw] Both "earlyLoop" and legacy "early_loop" are set in ${fullPath}. Using "earlyLoop".`);
345
+ }
346
+ const earlyLoopRaw = hasEarlyLoopField
347
+ ? parsed.earlyLoop
348
+ : parsed.early_loop;
349
+ let earlyLoopEnabled = true;
350
+ let earlyLoopMaxIterations = DEFAULT_EARLY_LOOP_MAX_ITERATIONS;
351
+ if (hasEarlyLoopField || hasLegacyEarlyLoopField) {
352
+ if (!isRecord(earlyLoopRaw)) {
353
+ throw configValidationError(fullPath, `"${hasEarlyLoopField ? "earlyLoop" : "early_loop"}" must be an object`);
354
+ }
355
+ const unknownEarlyLoopKeys = Object.keys(earlyLoopRaw).filter((key) => key !== "enabled" && key !== "maxIterations" && key !== "max_iterations");
356
+ if (unknownEarlyLoopKeys.length > 0) {
357
+ throw configValidationError(fullPath, `"${hasEarlyLoopField ? "earlyLoop" : "early_loop"}" has unknown key(s): ${unknownEarlyLoopKeys.join(", ")}`);
358
+ }
359
+ if (earlyLoopRaw.enabled !== undefined && typeof earlyLoopRaw.enabled !== "boolean") {
360
+ throw configValidationError(fullPath, `"${hasEarlyLoopField ? "earlyLoop" : "early_loop"}.enabled" must be a boolean`);
361
+ }
362
+ if (earlyLoopRaw.maxIterations !== undefined &&
363
+ earlyLoopRaw.max_iterations !== undefined &&
364
+ earlyLoopRaw.maxIterations !== earlyLoopRaw.max_iterations) {
365
+ emitConfigWarningOnce(warningState, "CCLAW_CONFIG_EARLY_LOOP_MAX_ITERATIONS_ALIAS", `[cclaw] Both "${hasEarlyLoopField ? "earlyLoop.maxIterations" : "early_loop.maxIterations"}" and "${hasEarlyLoopField ? "earlyLoop.max_iterations" : "early_loop.max_iterations"}" are set in ${fullPath}. Using "maxIterations".`);
366
+ }
367
+ const rawMaxIterations = earlyLoopRaw.maxIterations ?? earlyLoopRaw.max_iterations;
368
+ if (rawMaxIterations !== undefined &&
369
+ (typeof rawMaxIterations !== "number" ||
370
+ !Number.isInteger(rawMaxIterations) ||
371
+ rawMaxIterations < 1)) {
372
+ throw configValidationError(fullPath, `"${hasEarlyLoopField ? "earlyLoop" : "early_loop"}.maxIterations" must be a positive integer`);
373
+ }
374
+ if (typeof earlyLoopRaw.enabled === "boolean") {
375
+ earlyLoopEnabled = earlyLoopRaw.enabled;
376
+ }
377
+ if (typeof rawMaxIterations === "number") {
378
+ earlyLoopMaxIterations = rawMaxIterations;
379
+ }
380
+ }
330
381
  const gitHookGuardsRaw = parsed.gitHookGuards;
331
382
  if (Object.prototype.hasOwnProperty.call(parsed, "gitHookGuards") &&
332
383
  typeof gitHookGuardsRaw !== "boolean") {
@@ -483,7 +534,13 @@ export async function readConfig(projectRoot, options = {}) {
483
534
  : false,
484
535
  staleDiagramAudit: typeof optInAuditsRaw.staleDiagramAudit === "boolean"
485
536
  ? optInAuditsRaw.staleDiagramAudit
486
- : false
537
+ : true
538
+ };
539
+ }
540
+ if (!optInAudits) {
541
+ optInAudits = {
542
+ scopePreAudit: false,
543
+ staleDiagramAudit: true
487
544
  };
488
545
  }
489
546
  const reviewLoopRaw = parsed.reviewLoop;
@@ -544,6 +601,10 @@ export async function readConfig(projectRoot, options = {}) {
544
601
  compound: {
545
602
  recurrenceThreshold: compoundRecurrenceThreshold
546
603
  },
604
+ earlyLoop: {
605
+ enabled: earlyLoopEnabled,
606
+ maxIterations: earlyLoopMaxIterations
607
+ },
547
608
  gitHookGuards,
548
609
  defaultTrack,
549
610
  languageRulePacks,
@@ -570,6 +631,7 @@ function buildSerializableConfig(config, options = {}) {
570
631
  "tddTestGlobs",
571
632
  "tdd",
572
633
  "compound",
634
+ "earlyLoop",
573
635
  "gitHookGuards",
574
636
  "defaultTrack",
575
637
  "languageRulePacks",
@@ -626,6 +688,7 @@ export async function detectAdvancedKeys(projectRoot) {
626
688
  "tddTestGlobs",
627
689
  "tdd",
628
690
  "compound",
691
+ "earlyLoop",
629
692
  "defaultTrack",
630
693
  "languageRulePacks",
631
694
  "trackHeuristics",
@@ -636,7 +699,8 @@ export async function detectAdvancedKeys(projectRoot) {
636
699
  ];
637
700
  const present = new Set();
638
701
  for (const key of advancedCandidates) {
639
- if (Object.prototype.hasOwnProperty.call(parsedUnknown, key)) {
702
+ if (Object.prototype.hasOwnProperty.call(parsedUnknown, key) ||
703
+ (key === "earlyLoop" && Object.prototype.hasOwnProperty.call(parsedUnknown, "early_loop"))) {
640
704
  present.add(key);
641
705
  }
642
706
  }
@@ -10,16 +10,10 @@ export declare const FLOW_VERSION = "1.0.0";
10
10
  export declare const SHIP_FINALIZATION_MODES: readonly ["FINALIZE_MERGE_LOCAL", "FINALIZE_OPEN_PR", "FINALIZE_KEEP_BRANCH", "FINALIZE_DISCARD_BRANCH", "FINALIZE_NO_VCS"];
11
11
  export type ShipFinalizationMode = (typeof SHIP_FINALIZATION_MODES)[number];
12
12
  export declare const DEFAULT_HARNESSES: HarnessId[];
13
- export declare const REQUIRED_DIRS: readonly [".cclaw", ".cclaw/commands", ".cclaw/skills", ".cclaw/templates", ".cclaw/templates/state-contracts", ".cclaw/artifacts", ".cclaw/state", ".cclaw/runs", ".cclaw/rules", ".cclaw/agents", ".cclaw/hooks", ".cclaw/skills/review-prompts"];
13
+ export declare const REQUIRED_DIRS: readonly [".cclaw", ".cclaw/commands", ".cclaw/skills", ".cclaw/templates", ".cclaw/templates/state-contracts", ".cclaw/artifacts", ".cclaw/wave-plans", ".cclaw/archive", ".cclaw/state", ".cclaw/rules", ".cclaw/agents", ".cclaw/hooks", ".cclaw/skills/review-prompts"];
14
14
  export declare const REQUIRED_GITIGNORE_PATTERNS: readonly ["# cclaw generated artifacts", ".cclaw/", ".claude/commands/cc-*.md", ".claude/commands/cc.md", ".cursor/commands/cc-*.md", ".cursor/commands/cc.md", ".opencode/commands/cc-*.md", ".opencode/commands/cc.md", ".agents/skills/cc/SKILL.md", ".agents/skills/cc-*/SKILL.md", ".claude/hooks/hooks.json", ".cursor/hooks.json", ".codex/hooks.json", ".opencode/plugins/cclaw-plugin.mjs", ".cursor/rules/cclaw-workflow.mdc"];
15
15
  /**
16
16
  * Canonical stage -> skill folder mapping.
17
- *
18
- * Intentional divergence from stage ids:
19
- * - stage ids stay short and flow-oriented (`spec`, `tdd`, `ship`)
20
- * - skill folders stay descriptive and user-facing for `.cclaw/skills/*`.
21
- *
22
- * Keep this map as the single source of truth for generated skill paths.
23
17
  */
24
18
  export declare const STAGE_TO_SKILL_FOLDER: Record<FlowStage, string>;
25
19
  export declare const SUBAGENT_SKILL_FOLDERS: readonly ["subagent-dev", "parallel-dispatch"];
package/dist/constants.js CHANGED
@@ -59,8 +59,9 @@ export const REQUIRED_DIRS = [
59
59
  `${RUNTIME_ROOT}/templates`,
60
60
  `${RUNTIME_ROOT}/templates/state-contracts`,
61
61
  `${RUNTIME_ROOT}/artifacts`,
62
+ `${RUNTIME_ROOT}/wave-plans`,
63
+ `${RUNTIME_ROOT}/archive`,
62
64
  `${RUNTIME_ROOT}/state`,
63
- `${RUNTIME_ROOT}/runs`,
64
65
  `${RUNTIME_ROOT}/rules`,
65
66
  `${RUNTIME_ROOT}/agents`,
66
67
  `${RUNTIME_ROOT}/hooks`,
@@ -89,22 +90,16 @@ export const REQUIRED_GITIGNORE_PATTERNS = [
89
90
  ];
90
91
  /**
91
92
  * Canonical stage -> skill folder mapping.
92
- *
93
- * Intentional divergence from stage ids:
94
- * - stage ids stay short and flow-oriented (`spec`, `tdd`, `ship`)
95
- * - skill folders stay descriptive and user-facing for `.cclaw/skills/*`.
96
- *
97
- * Keep this map as the single source of truth for generated skill paths.
98
93
  */
99
94
  export const STAGE_TO_SKILL_FOLDER = {
100
- brainstorm: "brainstorming",
101
- scope: "scope-shaping",
102
- design: "engineering-design-lock",
103
- spec: "specification-authoring",
104
- plan: "planning-and-task-breakdown",
105
- tdd: "test-driven-development",
106
- review: "two-layer-review",
107
- ship: "shipping-and-handoff"
95
+ brainstorm: "brainstorm",
96
+ scope: "scope",
97
+ design: "design",
98
+ spec: "spec",
99
+ plan: "plan",
100
+ tdd: "tdd",
101
+ review: "review",
102
+ ship: "ship"
108
103
  };
109
104
  export const SUBAGENT_SKILL_FOLDERS = [
110
105
  "subagent-dev",
@@ -6,7 +6,7 @@ Use this command when the user wants to stop the active run without claiming com
6
6
  ## Protocol
7
7
 
8
8
  1. Ask for a concise cancellation reason if the user has not already provided one.
9
- 2. Run \`cclaw archive --disposition=cancelled --reason=<reason>\` from the project root. Use \`--disposition=abandoned\` only when the user explicitly frames the run as abandoned rather than cancelled.
9
+ 2. Run \`node .cclaw/hooks/cancel-run.mjs --reason="<reason>"\` from the project root. Use \`--disposition=abandoned\` only when the user explicitly frames the run as abandoned rather than cancelled.
10
10
  3. Report the archive path and reset run id. Make clear that the archived run is not a completed ship.
11
11
 
12
12
  Cancelled and abandoned archives are allowed from any stage, but they require a required reason so future readers know why the run ended.
@@ -20,6 +20,6 @@ description: Cancel or abandon the active cclaw run with a required reason. Use
20
20
 
21
21
  # Cancel cclaw Run
22
22
 
23
- Load and follow \`.cclaw/commands/cancel.md\`. This is a non-completion path: require a reason and archive with cancelled or abandoned disposition.
23
+ Load and follow \`.cclaw/commands/cancel.md\`. This is a non-completion path: require a reason, run the generated cancel helper, and archive with cancelled or abandoned disposition.
24
24
  `;
25
25
  }
@@ -4,7 +4,7 @@
4
4
  * Keep closeout chain and ship substate language in one place across command
5
5
  * contracts, skills, and stage/docs surfaces.
6
6
  */
7
- export declare const CLOSEOUT_CHAIN = "retro -> compound -> archive";
7
+ export declare const CLOSEOUT_CHAIN = "post_ship_review -> archive";
8
8
  export declare const CLOSEOUT_SUBSTATE_KEY = "closeout.shipSubstate";
9
9
  export declare function closeoutChainInline(): string;
10
10
  export declare function closeoutSubstateInline(): string;
@@ -4,7 +4,7 @@
4
4
  * Keep closeout chain and ship substate language in one place across command
5
5
  * contracts, skills, and stage/docs surfaces.
6
6
  */
7
- export const CLOSEOUT_CHAIN = "retro -> compound -> archive";
7
+ export const CLOSEOUT_CHAIN = "post_ship_review -> archive";
8
8
  export const CLOSEOUT_SUBSTATE_KEY = "closeout.shipSubstate";
9
9
  export function closeoutChainInline() {
10
10
  return `\`${CLOSEOUT_CHAIN}\``;
@@ -17,26 +17,28 @@ export function closeoutNextCommandGuidance() {
17
17
  }
18
18
  export function closeoutSubstateProtocolBullets() {
19
19
  return `When \`currentStage === "ship"\`, route by **${closeoutSubstateInline()}**:
20
- - \`"idle"\` or missing -> set ${closeoutSubstateInline()} = \`"retro_review"\`, then
21
- execute the in-stage retro protocol (draft + one structured accept/edit/skip ask).
22
- - \`"retro_review"\` -> continue the retro protocol (re-ask the structured
23
- question; the draft already exists do not regenerate it).
24
- - \`"compound_review"\` -> execute the in-stage compound closeout scan (not \`ce:compound\`):
20
+ - \`"idle"\` or missing -> outcome: initialize closeout by setting
21
+ ${closeoutSubstateInline()} = \`"post_ship_review"\`, then continue \`/cc\`
22
+ into the in-stage retro protocol (draft + one structured accept/edit/skip ask).
23
+ - \`"post_ship_review"\` -> outcome: execute the unified post-ship closeout leg
24
+ (retro acceptance/edit/skip + in-stage compound scan, not \`ce:compound\`)
25
+ and advance toward archive readiness:
25
26
  read \`.cclaw/state/compound-readiness.json\` plus the relevant tail of
26
27
  \`.cclaw/knowledge.jsonl\`, assess overlap before adding duplicate knowledge,
27
28
  separate bug-track learnings (turn into rules/tests/remediation) from
28
- knowledge-track learnings (durable project/process guidance), and use
29
- lightweight \`supersedes\` / \`superseded_by\` fields when refreshing stale or
30
- partially replaced entries. Optionally ask whether to scan Cursor/Claude/Codex
29
+ knowledge-track learnings (durable project/process guidance), and refresh stale
30
+ guidance in place instead of introducing extra lineage metadata. Optionally ask
31
+ whether to scan Cursor/Claude/Codex
31
32
  session transcripts for matching historical learnings; only do it after opt-in.
32
33
  Ask **one** structured question (apply / skip) per candidate cluster or a
33
34
  single accept-all / skip choice, then advance substate.
34
- - \`"ready_to_archive"\` -> run \`npx cclaw-cli archive\` (or \`npx cclaw-cli archive --name=<slug>\`) and reset state.
35
- - \`"archived"\` (transient) -> report "run archived" and stop.`;
35
+ - \`"ready_to_archive"\` -> outcome: continue \`/cc\` so the runtime archive step
36
+ executes, snapshots, and resets active state.
37
+ - \`"archived"\` (transient) -> outcome: report "run archived" and stop (flow complete).`;
36
38
  }
37
39
  export function closeoutFlowMapSentence() {
38
- return `The first stage names are the critical path. \`retro\`, \`compound\`, and \`archive\` are post-ship closeout substates under ${closeoutSubstateInline()}, not separate stage schemas or commands. Continue them with \`/cc\`; do not route compound closeout through \`ce:compound\`.`;
40
+ return `The first stage names are the critical path. \`post_ship_review\` and \`archive\` are post-ship closeout substates under ${closeoutSubstateInline()}, not separate stage schemas or commands. Continue them with \`/cc\`; do not route compound closeout through \`ce:compound\`.`;
39
41
  }
40
42
  export function closeoutProtocolBehaviorSentence() {
41
- return `Keep decision, completion, and preamble discipline inline: ask only decision-changing questions, verify gates before advancing, and keep context compact. After \`ship\`, keep using \`/cc\` through ${closeoutChainInline()}; do not route normal closeout through \`ce:compound\` or a separate operations command. In compound closeout, assess overlap before appending knowledge: refresh recurring bug-track learnings as actionable rules/tests, keep knowledge-track learnings as durable process/project guidance, and mark outdated entries with lightweight \`supersedes\` / \`superseded_by\` fields instead of building a new doc system.`;
43
+ return `Keep decision, completion, and preamble discipline inline: ask only decision-changing questions, verify gates before advancing, and keep context compact. After \`ship\`, keep using \`/cc\` through ${closeoutChainInline()}; do not route normal closeout through \`ce:compound\` or a separate operations command. Inside \`post_ship_review\`, assess overlap before appending knowledge: refresh recurring bug-track learnings as actionable rules/tests and keep knowledge-track learnings as durable process/project guidance without extra lineage metadata.`;
42
44
  }