cclaw-cli 7.7.1 → 8.1.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 (282) hide show
  1. package/README.md +210 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +90 -508
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -768
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -134
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/install.d.ts +27 -15
  73. package/dist/install.js +230 -1342
  74. package/dist/knowledge-store.d.ts +19 -163
  75. package/dist/knowledge-store.js +56 -590
  76. package/dist/logger.d.ts +8 -3
  77. package/dist/logger.js +13 -4
  78. package/dist/orchestrator-routing.d.ts +29 -0
  79. package/dist/orchestrator-routing.js +156 -0
  80. package/dist/run-persistence.d.ts +7 -118
  81. package/dist/run-persistence.js +29 -845
  82. package/dist/runtime/run-hook.entry.d.ts +1 -3
  83. package/dist/runtime/run-hook.entry.js +19 -4
  84. package/dist/runtime/run-hook.mjs +13 -1024
  85. package/dist/types.d.ts +25 -261
  86. package/dist/types.js +8 -36
  87. package/package.json +6 -3
  88. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  89. package/dist/artifact-linter/brainstorm.js +0 -353
  90. package/dist/artifact-linter/design.d.ts +0 -18
  91. package/dist/artifact-linter/design.js +0 -444
  92. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  93. package/dist/artifact-linter/findings-dedup.js +0 -232
  94. package/dist/artifact-linter/plan.d.ts +0 -2
  95. package/dist/artifact-linter/plan.js +0 -826
  96. package/dist/artifact-linter/review-army.d.ts +0 -49
  97. package/dist/artifact-linter/review-army.js +0 -520
  98. package/dist/artifact-linter/review.d.ts +0 -2
  99. package/dist/artifact-linter/review.js +0 -113
  100. package/dist/artifact-linter/scope.d.ts +0 -2
  101. package/dist/artifact-linter/scope.js +0 -158
  102. package/dist/artifact-linter/shared.d.ts +0 -637
  103. package/dist/artifact-linter/shared.js +0 -2163
  104. package/dist/artifact-linter/ship.d.ts +0 -2
  105. package/dist/artifact-linter/ship.js +0 -250
  106. package/dist/artifact-linter/spec.d.ts +0 -2
  107. package/dist/artifact-linter/spec.js +0 -176
  108. package/dist/artifact-linter/tdd.d.ts +0 -118
  109. package/dist/artifact-linter/tdd.js +0 -1404
  110. package/dist/artifact-linter.d.ts +0 -15
  111. package/dist/artifact-linter.js +0 -517
  112. package/dist/codex-feature-flag.d.ts +0 -58
  113. package/dist/codex-feature-flag.js +0 -193
  114. package/dist/content/closeout-guidance.d.ts +0 -14
  115. package/dist/content/closeout-guidance.js +0 -44
  116. package/dist/content/diff-command.d.ts +0 -1
  117. package/dist/content/diff-command.js +0 -43
  118. package/dist/content/harness-doc.d.ts +0 -1
  119. package/dist/content/harness-doc.js +0 -65
  120. package/dist/content/hook-events.d.ts +0 -9
  121. package/dist/content/hook-events.js +0 -23
  122. package/dist/content/hook-manifest.d.ts +0 -81
  123. package/dist/content/hook-manifest.js +0 -156
  124. package/dist/content/hooks.d.ts +0 -11
  125. package/dist/content/hooks.js +0 -1972
  126. package/dist/content/idea.d.ts +0 -60
  127. package/dist/content/idea.js +0 -416
  128. package/dist/content/language-policy.d.ts +0 -2
  129. package/dist/content/language-policy.js +0 -13
  130. package/dist/content/learnings.d.ts +0 -6
  131. package/dist/content/learnings.js +0 -141
  132. package/dist/content/observe.d.ts +0 -19
  133. package/dist/content/observe.js +0 -86
  134. package/dist/content/opencode-plugin.d.ts +0 -1
  135. package/dist/content/opencode-plugin.js +0 -635
  136. package/dist/content/review-prompts.d.ts +0 -1
  137. package/dist/content/review-prompts.js +0 -104
  138. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  139. package/dist/content/runtime-shared-snippets.js +0 -80
  140. package/dist/content/session-hooks.d.ts +0 -7
  141. package/dist/content/session-hooks.js +0 -107
  142. package/dist/content/skills-elicitation.d.ts +0 -1
  143. package/dist/content/skills-elicitation.js +0 -167
  144. package/dist/content/stage-command.d.ts +0 -2
  145. package/dist/content/stage-command.js +0 -17
  146. package/dist/content/stage-schema.d.ts +0 -117
  147. package/dist/content/stage-schema.js +0 -955
  148. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  149. package/dist/content/stages/_lint-metadata/index.js +0 -97
  150. package/dist/content/stages/brainstorm.d.ts +0 -2
  151. package/dist/content/stages/brainstorm.js +0 -184
  152. package/dist/content/stages/design.d.ts +0 -2
  153. package/dist/content/stages/design.js +0 -288
  154. package/dist/content/stages/index.d.ts +0 -8
  155. package/dist/content/stages/index.js +0 -11
  156. package/dist/content/stages/plan.d.ts +0 -2
  157. package/dist/content/stages/plan.js +0 -191
  158. package/dist/content/stages/review.d.ts +0 -2
  159. package/dist/content/stages/review.js +0 -240
  160. package/dist/content/stages/schema-types.d.ts +0 -203
  161. package/dist/content/stages/schema-types.js +0 -1
  162. package/dist/content/stages/scope.d.ts +0 -2
  163. package/dist/content/stages/scope.js +0 -254
  164. package/dist/content/stages/ship.d.ts +0 -2
  165. package/dist/content/stages/ship.js +0 -159
  166. package/dist/content/stages/spec.d.ts +0 -2
  167. package/dist/content/stages/spec.js +0 -170
  168. package/dist/content/stages/tdd.d.ts +0 -4
  169. package/dist/content/stages/tdd.js +0 -273
  170. package/dist/content/state-contracts.d.ts +0 -1
  171. package/dist/content/state-contracts.js +0 -63
  172. package/dist/content/status-command.d.ts +0 -4
  173. package/dist/content/status-command.js +0 -109
  174. package/dist/content/subagent-context-skills.d.ts +0 -4
  175. package/dist/content/subagent-context-skills.js +0 -279
  176. package/dist/content/subagents.d.ts +0 -3
  177. package/dist/content/subagents.js +0 -997
  178. package/dist/content/templates.d.ts +0 -26
  179. package/dist/content/templates.js +0 -1692
  180. package/dist/content/track-render-context.d.ts +0 -18
  181. package/dist/content/track-render-context.js +0 -53
  182. package/dist/content/tree-command.d.ts +0 -1
  183. package/dist/content/tree-command.js +0 -64
  184. package/dist/content/utility-skills.d.ts +0 -30
  185. package/dist/content/utility-skills.js +0 -160
  186. package/dist/content/view-command.d.ts +0 -2
  187. package/dist/content/view-command.js +0 -92
  188. package/dist/delegation.d.ts +0 -649
  189. package/dist/delegation.js +0 -1539
  190. package/dist/early-loop.d.ts +0 -70
  191. package/dist/early-loop.js +0 -302
  192. package/dist/execution-topology.d.ts +0 -44
  193. package/dist/execution-topology.js +0 -95
  194. package/dist/gate-evidence.d.ts +0 -85
  195. package/dist/gate-evidence.js +0 -631
  196. package/dist/harness-adapters.d.ts +0 -151
  197. package/dist/harness-adapters.js +0 -756
  198. package/dist/harness-selection.d.ts +0 -31
  199. package/dist/harness-selection.js +0 -214
  200. package/dist/hook-schema.d.ts +0 -6
  201. package/dist/hook-schema.js +0 -114
  202. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  203. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  204. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  205. package/dist/init-detect.d.ts +0 -2
  206. package/dist/init-detect.js +0 -50
  207. package/dist/internal/advance-stage/advance.d.ts +0 -89
  208. package/dist/internal/advance-stage/advance.js +0 -655
  209. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  210. package/dist/internal/advance-stage/cancel-run.js +0 -19
  211. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  212. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  213. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  214. package/dist/internal/advance-stage/helpers.js +0 -145
  215. package/dist/internal/advance-stage/hook.d.ts +0 -8
  216. package/dist/internal/advance-stage/hook.js +0 -40
  217. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  218. package/dist/internal/advance-stage/parsers.js +0 -357
  219. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  220. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  221. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  222. package/dist/internal/advance-stage/review-loop.js +0 -199
  223. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  224. package/dist/internal/advance-stage/rewind.js +0 -108
  225. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  226. package/dist/internal/advance-stage/start-flow.js +0 -241
  227. package/dist/internal/advance-stage/verify.d.ts +0 -21
  228. package/dist/internal/advance-stage/verify.js +0 -185
  229. package/dist/internal/advance-stage.d.ts +0 -7
  230. package/dist/internal/advance-stage.js +0 -138
  231. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  232. package/dist/internal/cohesion-contract-stub.js +0 -148
  233. package/dist/internal/compound-readiness.d.ts +0 -23
  234. package/dist/internal/compound-readiness.js +0 -102
  235. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  236. package/dist/internal/detect-public-api-changes.js +0 -45
  237. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  238. package/dist/internal/detect-supply-chain-changes.js +0 -138
  239. package/dist/internal/early-loop-status.d.ts +0 -7
  240. package/dist/internal/early-loop-status.js +0 -93
  241. package/dist/internal/envelope-validate.d.ts +0 -7
  242. package/dist/internal/envelope-validate.js +0 -66
  243. package/dist/internal/flow-state-repair.d.ts +0 -20
  244. package/dist/internal/flow-state-repair.js +0 -104
  245. package/dist/internal/plan-split-waves.d.ts +0 -190
  246. package/dist/internal/plan-split-waves.js +0 -764
  247. package/dist/internal/runtime-integrity.d.ts +0 -7
  248. package/dist/internal/runtime-integrity.js +0 -268
  249. package/dist/internal/slice-commit.d.ts +0 -7
  250. package/dist/internal/slice-commit.js +0 -619
  251. package/dist/internal/tdd-loop-status.d.ts +0 -14
  252. package/dist/internal/tdd-loop-status.js +0 -68
  253. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  254. package/dist/internal/tdd-red-evidence.js +0 -153
  255. package/dist/internal/waiver-grant.d.ts +0 -62
  256. package/dist/internal/waiver-grant.js +0 -294
  257. package/dist/internal/wave-status.d.ts +0 -74
  258. package/dist/internal/wave-status.js +0 -506
  259. package/dist/managed-resources.d.ts +0 -53
  260. package/dist/managed-resources.js +0 -313
  261. package/dist/policy.d.ts +0 -10
  262. package/dist/policy.js +0 -167
  263. package/dist/retro-gate.d.ts +0 -9
  264. package/dist/retro-gate.js +0 -47
  265. package/dist/run-archive.d.ts +0 -61
  266. package/dist/run-archive.js +0 -391
  267. package/dist/runs.d.ts +0 -2
  268. package/dist/runs.js +0 -2
  269. package/dist/stack-detection.d.ts +0 -116
  270. package/dist/stack-detection.js +0 -489
  271. package/dist/streaming/event-stream.d.ts +0 -31
  272. package/dist/streaming/event-stream.js +0 -114
  273. package/dist/tdd-cycle.d.ts +0 -107
  274. package/dist/tdd-cycle.js +0 -289
  275. package/dist/tdd-verification-evidence.d.ts +0 -17
  276. package/dist/tdd-verification-evidence.js +0 -122
  277. package/dist/track-heuristics.d.ts +0 -27
  278. package/dist/track-heuristics.js +0 -154
  279. package/dist/util/slice-id.d.ts +0 -58
  280. package/dist/util/slice-id.js +0 -89
  281. package/dist/worktree-manager.d.ts +0 -20
  282. package/dist/worktree-manager.js +0 -108
@@ -1,70 +0,0 @@
1
- export declare const EARLY_LOOP_STAGES: readonly ["brainstorm", "scope", "design"];
2
- export type EarlyLoopStage = (typeof EARLY_LOOP_STAGES)[number];
3
- export type EarlyLoopConcernSeverity = "critical" | "important" | "suggestion";
4
- export interface EarlyLoopConcern {
5
- id: string;
6
- severity: EarlyLoopConcernSeverity;
7
- locator: string;
8
- summary: string;
9
- firstSeenIteration: number;
10
- lastSeenIteration: number;
11
- resolvedAtIteration?: number;
12
- }
13
- export interface EarlyLoopStatus {
14
- schemaVersion: 1;
15
- stage: EarlyLoopStage;
16
- runId: string;
17
- iteration: number;
18
- maxIterations: number;
19
- openConcerns: EarlyLoopConcern[];
20
- resolvedConcerns: EarlyLoopConcern[];
21
- lastSeenConcernIds: string[];
22
- convergenceTripped: boolean;
23
- escalationReason?: string;
24
- lastUpdatedAt: string;
25
- }
26
- export declare function clampEarlyLoopStatusForWrite(status: EarlyLoopStatus): {
27
- status: EarlyLoopStatus;
28
- clampedFrom: number | null;
29
- };
30
- export interface EarlyLoopLogConcern {
31
- id: string;
32
- severity: EarlyLoopConcernSeverity;
33
- locator: string;
34
- summary: string;
35
- }
36
- export interface EarlyLoopLogEntry {
37
- ts: string;
38
- runId: string;
39
- stage: string;
40
- iteration?: number;
41
- concerns: EarlyLoopLogConcern[];
42
- resolvedConcernIds: string[];
43
- }
44
- export interface EarlyLoopParseIssue {
45
- lineNumber: number;
46
- reason: string;
47
- rawLine: string;
48
- }
49
- export interface ParseEarlyLoopLogOptions {
50
- issues?: EarlyLoopParseIssue[];
51
- strict?: boolean;
52
- }
53
- export interface DeriveEarlyLoopStatusOptions {
54
- stage: EarlyLoopStage;
55
- runId: string;
56
- maxIterations?: number;
57
- now?: Date;
58
- }
59
- export interface ComputeEarlyLoopStatusOptions {
60
- maxIterations?: number;
61
- now?: Date;
62
- parseIssues?: EarlyLoopParseIssue[];
63
- strictParse?: boolean;
64
- }
65
- export declare function isEarlyLoopStage(value: unknown): value is EarlyLoopStage;
66
- export declare function normalizeEarlyLoopMaxIterations(value: number | undefined): number;
67
- export declare function parseEarlyLoopLog(text: string, options?: ParseEarlyLoopLogOptions): EarlyLoopLogEntry[];
68
- export declare function deriveEarlyLoopStatus(entries: EarlyLoopLogEntry[], options: DeriveEarlyLoopStatusOptions): EarlyLoopStatus;
69
- export declare function computeEarlyLoopStatus(stage: EarlyLoopStage, runId: string, concernsLogPath: string, options?: ComputeEarlyLoopStatusOptions): Promise<EarlyLoopStatus>;
70
- export declare function formatEarlyLoopStatusLine(status: EarlyLoopStatus): string;
@@ -1,302 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import { DEFAULT_EARLY_LOOP_MAX_ITERATIONS } from "./config.js";
3
- export const EARLY_LOOP_STAGES = ["brainstorm", "scope", "design"];
4
- export function clampEarlyLoopStatusForWrite(status) {
5
- if (status.iteration <= status.maxIterations) {
6
- return { status, clampedFrom: null };
7
- }
8
- return {
9
- status: {
10
- ...status,
11
- iteration: status.maxIterations
12
- },
13
- clampedFrom: status.iteration
14
- };
15
- }
16
- const CONCERN_ID_PREFIX = "C-";
17
- function severityWeight(severity) {
18
- if (severity === "critical")
19
- return 3;
20
- if (severity === "important")
21
- return 2;
22
- return 1;
23
- }
24
- function normalizeSeverity(value) {
25
- if (value === "critical" || value === "important" || value === "suggestion") {
26
- return value;
27
- }
28
- return "important";
29
- }
30
- function normalizeText(value, fallback) {
31
- if (typeof value !== "string")
32
- return fallback;
33
- const trimmed = value.trim();
34
- return trimmed.length > 0 ? trimmed : fallback;
35
- }
36
- function stableConcernFallbackId(locator, summary) {
37
- const seed = `${locator}::${summary}`.trim().toLowerCase();
38
- let hash = 0;
39
- for (let index = 0; index < seed.length; index += 1) {
40
- hash = (Math.imul(31, hash) + seed.charCodeAt(index)) >>> 0;
41
- }
42
- return `${CONCERN_ID_PREFIX}${hash.toString(16).padStart(8, "0")}`;
43
- }
44
- function normalizeConcernId(id, locator, summary) {
45
- if (typeof id === "string") {
46
- const trimmed = id.trim();
47
- if (trimmed.length > 0) {
48
- return trimmed;
49
- }
50
- }
51
- return stableConcernFallbackId(locator, summary);
52
- }
53
- function normalizeConcerns(value) {
54
- if (!Array.isArray(value))
55
- return [];
56
- const concerns = [];
57
- for (const row of value) {
58
- if (!row || typeof row !== "object" || Array.isArray(row))
59
- continue;
60
- const typed = row;
61
- const locator = normalizeText(typed.locator, "unknown-location");
62
- const summary = normalizeText(typed.summary, "missing-summary");
63
- concerns.push({
64
- id: normalizeConcernId(typed.id, locator, summary),
65
- severity: normalizeSeverity(typed.severity),
66
- locator,
67
- summary
68
- });
69
- }
70
- return concerns;
71
- }
72
- function normalizeResolvedConcernIds(value) {
73
- if (!Array.isArray(value))
74
- return [];
75
- return value
76
- .filter((entry) => typeof entry === "string")
77
- .map((entry) => entry.trim())
78
- .filter((entry) => entry.length > 0);
79
- }
80
- export function isEarlyLoopStage(value) {
81
- return typeof value === "string" && EARLY_LOOP_STAGES.includes(value);
82
- }
83
- export function normalizeEarlyLoopMaxIterations(value) {
84
- if (typeof value === "number" && Number.isInteger(value) && value >= 1) {
85
- return value;
86
- }
87
- return DEFAULT_EARLY_LOOP_MAX_ITERATIONS;
88
- }
89
- export function parseEarlyLoopLog(text, options = {}) {
90
- const strict = options.strict === true;
91
- const issues = options.issues;
92
- const normalized = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
93
- const lines = normalized.split(/\r?\n/u);
94
- const entries = [];
95
- for (let index = 0; index < lines.length; index += 1) {
96
- const raw = lines[index] ?? "";
97
- const line = raw.trim();
98
- if (line.length === 0)
99
- continue;
100
- const lineNumber = index + 1;
101
- let parsed;
102
- try {
103
- parsed = JSON.parse(line);
104
- }
105
- catch (error) {
106
- issues?.push({
107
- lineNumber,
108
- reason: `json-parse-failed: ${error instanceof Error ? error.message : String(error)}`,
109
- rawLine: raw
110
- });
111
- continue;
112
- }
113
- const runId = normalizeText(parsed.runId, "");
114
- const stage = normalizeText(parsed.stage, "");
115
- const concerns = normalizeConcerns(parsed.concerns);
116
- const resolvedConcernIds = normalizeResolvedConcernIds(parsed.resolvedConcernIds);
117
- const iteration = typeof parsed.iteration === "number" &&
118
- Number.isInteger(parsed.iteration) &&
119
- parsed.iteration >= 1
120
- ? parsed.iteration
121
- : undefined;
122
- if (strict) {
123
- const missing = [];
124
- if (runId.length === 0)
125
- missing.push("runId");
126
- if (stage.length === 0)
127
- missing.push("stage");
128
- if (concerns.length === 0 && resolvedConcernIds.length === 0) {
129
- missing.push("concerns/resolvedConcernIds");
130
- }
131
- if (missing.length > 0) {
132
- issues?.push({
133
- lineNumber,
134
- reason: `missing-required-fields: ${missing.join(",")}`,
135
- rawLine: raw
136
- });
137
- continue;
138
- }
139
- }
140
- // schema repair: legacy logs may carry rows with no runId
141
- // (the prior parser silently coerced them to "active", which then
142
- // collided across runs). Surface a structured warning on read but
143
- // skip the row so derived status doesn't fold cross-run state.
144
- // Writers must always provide a runId (enforced upstream in the
145
- // CLI/hook surface).
146
- if (runId.length === 0) {
147
- issues?.push({
148
- lineNumber,
149
- reason: "missing-runId: legacy entry skipped to avoid cross-run pollution",
150
- rawLine: raw
151
- });
152
- continue;
153
- }
154
- entries.push({
155
- ts: normalizeText(parsed.ts, ""),
156
- runId,
157
- stage: stage.length > 0 ? stage : "brainstorm",
158
- iteration,
159
- concerns,
160
- resolvedConcernIds
161
- });
162
- }
163
- return entries;
164
- }
165
- function sortConcerns(a, b) {
166
- const severityDiff = severityWeight(b.severity) - severityWeight(a.severity);
167
- if (severityDiff !== 0)
168
- return severityDiff;
169
- if (a.firstSeenIteration !== b.firstSeenIteration) {
170
- return a.firstSeenIteration - b.firstSeenIteration;
171
- }
172
- if (a.lastSeenIteration !== b.lastSeenIteration) {
173
- return a.lastSeenIteration - b.lastSeenIteration;
174
- }
175
- return a.id.localeCompare(b.id, "en");
176
- }
177
- export function deriveEarlyLoopStatus(entries, options) {
178
- const maxIterations = normalizeEarlyLoopMaxIterations(options.maxIterations);
179
- const concerns = new Map();
180
- const filtered = entries.filter((entry) => entry.runId === options.runId && entry.stage === options.stage);
181
- let previousConcernSnapshotKey = "";
182
- let sameConcernStreak = 0;
183
- let convergenceTripped = false;
184
- let escalationReason;
185
- let currentIteration = 0;
186
- let lastSeenConcernIds = [];
187
- for (const entry of filtered) {
188
- currentIteration += 1;
189
- const iteration = entry.iteration ?? currentIteration;
190
- const seenThisIteration = new Set();
191
- for (const concern of entry.concerns) {
192
- seenThisIteration.add(concern.id);
193
- const existing = concerns.get(concern.id);
194
- if (!existing) {
195
- concerns.set(concern.id, {
196
- id: concern.id,
197
- severity: concern.severity,
198
- locator: concern.locator,
199
- summary: concern.summary,
200
- firstSeenIteration: iteration,
201
- lastSeenIteration: iteration
202
- });
203
- continue;
204
- }
205
- existing.lastSeenIteration = iteration;
206
- existing.locator = concern.locator;
207
- existing.summary = concern.summary;
208
- if (severityWeight(concern.severity) >= severityWeight(existing.severity)) {
209
- existing.severity = concern.severity;
210
- }
211
- delete existing.resolvedAtIteration;
212
- }
213
- for (const concernId of entry.resolvedConcernIds) {
214
- const existing = concerns.get(concernId);
215
- if (!existing)
216
- continue;
217
- if (seenThisIteration.has(concernId))
218
- continue;
219
- if (existing.resolvedAtIteration === undefined) {
220
- existing.resolvedAtIteration = iteration;
221
- }
222
- }
223
- for (const concern of concerns.values()) {
224
- if (concern.resolvedAtIteration !== undefined)
225
- continue;
226
- if (seenThisIteration.has(concern.id))
227
- continue;
228
- concern.resolvedAtIteration = iteration;
229
- }
230
- const openConcernIds = Array.from(concerns.values())
231
- .filter((concern) => concern.resolvedAtIteration === undefined)
232
- .map((concern) => concern.id)
233
- .sort((a, b) => a.localeCompare(b, "en"));
234
- lastSeenConcernIds = openConcernIds;
235
- const snapshotKey = openConcernIds.join("|");
236
- if (snapshotKey.length > 0 && snapshotKey === previousConcernSnapshotKey) {
237
- sameConcernStreak += 1;
238
- if (!convergenceTripped && sameConcernStreak >= 2) {
239
- convergenceTripped = true;
240
- escalationReason = `same concerns ${sameConcernStreak} iterations in a row`;
241
- }
242
- }
243
- else {
244
- sameConcernStreak = snapshotKey.length > 0 ? 1 : 0;
245
- }
246
- previousConcernSnapshotKey = snapshotKey;
247
- }
248
- const openConcerns = Array.from(concerns.values())
249
- .filter((concern) => concern.resolvedAtIteration === undefined)
250
- .sort(sortConcerns);
251
- const resolvedConcerns = Array.from(concerns.values())
252
- .filter((concern) => concern.resolvedAtIteration !== undefined)
253
- .sort((a, b) => {
254
- if (a.resolvedAtIteration !== b.resolvedAtIteration) {
255
- return a.resolvedAtIteration - b.resolvedAtIteration;
256
- }
257
- return sortConcerns(a, b);
258
- });
259
- if (!convergenceTripped && openConcerns.length > 0 && currentIteration >= maxIterations) {
260
- convergenceTripped = true;
261
- escalationReason = `max iterations ${maxIterations} reached with ${openConcerns.length} open concern(s)`;
262
- }
263
- const iteration = Math.min(currentIteration, maxIterations);
264
- return {
265
- schemaVersion: 1,
266
- stage: options.stage,
267
- runId: options.runId,
268
- iteration,
269
- maxIterations,
270
- openConcerns,
271
- resolvedConcerns,
272
- lastSeenConcernIds,
273
- convergenceTripped,
274
- ...(escalationReason ? { escalationReason } : {}),
275
- lastUpdatedAt: (options.now ?? new Date()).toISOString()
276
- };
277
- }
278
- export async function computeEarlyLoopStatus(stage, runId, concernsLogPath, options = {}) {
279
- let raw = "";
280
- try {
281
- raw = await fs.readFile(concernsLogPath, "utf8");
282
- }
283
- catch (error) {
284
- if (error.code !== "ENOENT") {
285
- throw error;
286
- }
287
- }
288
- const parsed = parseEarlyLoopLog(raw, {
289
- issues: options.parseIssues,
290
- strict: options.strictParse
291
- });
292
- return deriveEarlyLoopStatus(parsed, {
293
- stage,
294
- runId,
295
- maxIterations: options.maxIterations,
296
- now: options.now
297
- });
298
- }
299
- export function formatEarlyLoopStatusLine(status) {
300
- const convergence = status.convergenceTripped ? "tripped" : "clear";
301
- return `Early Loop: stage=${status.stage}, iter=${status.iteration}/${status.maxIterations}, open=${status.openConcerns.length}, convergence=${convergence}`;
302
- }
@@ -1,44 +0,0 @@
1
- import type { ExecutionStrictnessProfile, ExecutionTopology } from "./types.js";
2
- export interface ExecutionTopologyShape {
3
- /** Ready implementation units/slices the controller could execute now. */
4
- unitCount: number;
5
- /** Ready units with no declared dependency/path conflict against each other. */
6
- independentUnitCount?: number;
7
- /** Ready units large enough to justify isolated builder overhead. */
8
- substantialUnitCount?: number;
9
- /** True when same-wave path ownership overlaps or is unknown-dangerous. */
10
- hasPathConflicts?: boolean;
11
- /** True for migrations, public contracts, security, data loss, or broad API changes. */
12
- highRisk?: boolean;
13
- /** True when a plan or controller explicitly requests micro-slice discipline. */
14
- requiresStrictMicro?: boolean;
15
- /** True when the controller can safely execute the unit inline in the current harness. */
16
- inlineSafe?: boolean;
17
- /**
18
- * 7.7.1 — count of ready units classified as discovery-only/scaffold/docs
19
- * lanes that are not high-risk and have no path conflicts. When this equals
20
- * `unitCount`, the auto router collapses the wave into `inline` (small
21
- * batch) or `single-builder` (large batch) so trivial markdown spikes never
22
- * fan out into one slice-builder span per file.
23
- */
24
- discoveryOnlyUnits?: number;
25
- }
26
- export interface ExecutionTopologyDecision {
27
- topology: Exclude<ExecutionTopology, "auto">;
28
- maxBuilders: number;
29
- reason: string;
30
- }
31
- export interface RouteExecutionTopologyOptions {
32
- configuredTopology?: ExecutionTopology;
33
- strictness?: ExecutionStrictnessProfile;
34
- maxBuilders?: number;
35
- shape: ExecutionTopologyShape;
36
- }
37
- /**
38
- * Choose the cheapest safe execution topology for a ready TDD surface.
39
- *
40
- * Safety invariants are intentionally conservative: explicit strict-micro wins,
41
- * path conflicts prevent fan-out, and parallel builders require multiple
42
- * independent substantial units plus a builder cap above one.
43
- */
44
- export declare function routeExecutionTopology(options: RouteExecutionTopologyOptions): ExecutionTopologyDecision;
@@ -1,95 +0,0 @@
1
- const DEFAULT_MAX_BUILDERS = 5;
2
- function normalizeMaxBuilders(value) {
3
- return typeof value === "number" && Number.isInteger(value) && value >= 1
4
- ? value
5
- : DEFAULT_MAX_BUILDERS;
6
- }
7
- /**
8
- * Choose the cheapest safe execution topology for a ready TDD surface.
9
- *
10
- * Safety invariants are intentionally conservative: explicit strict-micro wins,
11
- * path conflicts prevent fan-out, and parallel builders require multiple
12
- * independent substantial units plus a builder cap above one.
13
- */
14
- export function routeExecutionTopology(options) {
15
- const configured = options.configuredTopology ?? "auto";
16
- const strictness = options.strictness ?? "balanced";
17
- const maxBuilders = normalizeMaxBuilders(options.maxBuilders);
18
- const shape = options.shape;
19
- if (configured !== "auto") {
20
- return {
21
- topology: configured,
22
- maxBuilders,
23
- reason: `configured execution.topology=${configured}`
24
- };
25
- }
26
- if (shape.requiresStrictMicro || strictness === "strict") {
27
- return {
28
- topology: "strict-micro",
29
- maxBuilders,
30
- reason: shape.requiresStrictMicro
31
- ? "plan requested strict micro-slice execution"
32
- : "strict execution profile selected"
33
- };
34
- }
35
- const unitCount = Math.max(0, shape.unitCount);
36
- if (unitCount === 0) {
37
- return {
38
- topology: "inline",
39
- maxBuilders,
40
- reason: "no ready units; controller can reconcile inline"
41
- };
42
- }
43
- if (shape.hasPathConflicts) {
44
- return {
45
- topology: "single-builder",
46
- maxBuilders,
47
- reason: "path conflicts require serialized execution"
48
- };
49
- }
50
- // 7.7.1 — lane-aware short-circuit. When every ready unit is a non-high-risk
51
- // discovery/scaffold/docs lane with no path conflicts, never fan out: the
52
- // controller should fulfil a small batch inline, or hand the whole wave to a
53
- // single builder when the batch is large enough that one inline turn would
54
- // bloat the controller transcript.
55
- const discoveryOnly = shape.discoveryOnlyUnits ?? 0;
56
- if (!shape.highRisk &&
57
- discoveryOnly === unitCount &&
58
- unitCount >= 1) {
59
- if (unitCount <= 3) {
60
- return {
61
- topology: "inline",
62
- maxBuilders,
63
- reason: "discovery-only ready set; controller can fulfill inline"
64
- };
65
- }
66
- return {
67
- topology: "single-builder",
68
- maxBuilders,
69
- reason: "discovery-only ready set is large; one builder owns the wave"
70
- };
71
- }
72
- const independent = shape.independentUnitCount ?? unitCount;
73
- const substantial = shape.substantialUnitCount ?? unitCount;
74
- if (maxBuilders > 1 && independent >= 2 && substantial >= 2) {
75
- return {
76
- topology: "parallel-builders",
77
- maxBuilders,
78
- reason: "multiple independent substantial units are ready"
79
- };
80
- }
81
- if (unitCount === 1 && shape.inlineSafe && !shape.highRisk) {
82
- return {
83
- topology: "inline",
84
- maxBuilders,
85
- reason: "single low-risk inline-safe unit"
86
- };
87
- }
88
- return {
89
- topology: "single-builder",
90
- maxBuilders,
91
- reason: unitCount === 1
92
- ? "single ready unit keeps builder evidence isolated"
93
- : "ready units are not safely parallelizable"
94
- };
95
- }
@@ -1,85 +0,0 @@
1
- import type { FlowState, StageGateState } from "./flow-state.js";
2
- import { type FlowStage } from "./types.js";
3
- /**
4
- * Structured signal for the harness UI describing the adaptive
5
- * elicitation Q&A floor for the current stage. Always present on
6
- * brainstorm/scope/design verifications; null on other stages.
7
- *
8
- * Mirrors the `evaluateQaLogFloor` linter helper. Harness can render
9
- * `count / min` progress, surface stop-signal/skip-questions hints, and
10
- * differentiate between blocking and advisory.
11
- */
12
- export interface QaLogFloorSignal {
13
- ok: boolean;
14
- count: number;
15
- /**
16
- * always 0. The convergence floor no longer enforces
17
- * a fixed count. Harness UIs may render `questionBudgetHint(track,
18
- * stage).recommended` separately as a soft hint.
19
- */
20
- min: number;
21
- hasStopSignal: boolean;
22
- /** Always false; see `min` note above. */
23
- liteShortCircuit: boolean;
24
- skipQuestionsAdvisory: boolean;
25
- blocking: boolean;
26
- /** Forcing-question topics deemed addressed in `## Q&A Log`. */
27
- forcingCovered: string[];
28
- /** Forcing-question topics still pending (no Q&A row matched). */
29
- forcingPending: string[];
30
- /** Ralph-Loop convergence detector verdict for the last 2 rows. */
31
- noNewDecisions: boolean;
32
- }
33
- export interface GateEvidenceCheckResult {
34
- ok: boolean;
35
- stage: FlowStage;
36
- issues: string[];
37
- requiredCount: number;
38
- recommendedCount: number;
39
- conditionalCount: number;
40
- triggeredConditionalCount: number;
41
- passedCount: number;
42
- blockedCount: number;
43
- /** True only when required + triggered conditional gates are passed and unblocked. */
44
- complete: boolean;
45
- /** Required gate ids that are neither passed nor blocked. */
46
- missingRequired: string[];
47
- /** Recommended gates not yet passed (does not block). */
48
- missingRecommended: string[];
49
- /** Triggered conditional gates that are not yet passed. */
50
- missingTriggeredConditional: string[];
51
- /** Q&A floor signal for adaptive elicitation stages, null otherwise. */
52
- qaLogFloor: QaLogFloorSignal | null;
53
- }
54
- export interface CompletedStagesClosureResult {
55
- ok: boolean;
56
- issues: string[];
57
- openStages: Array<{
58
- stage: FlowStage;
59
- missingRequired: string[];
60
- missingTriggeredConditional: string[];
61
- blocked: string[];
62
- }>;
63
- }
64
- export interface VerifyCurrentStageGateEvidenceOptions {
65
- /** Extra stage flags propagated from the in-flight CLI args (e.g. `--skip-questions`). */
66
- extraStageFlags?: string[];
67
- }
68
- export declare function verifyCurrentStageGateEvidence(projectRoot: string, flowState: FlowState, options?: VerifyCurrentStageGateEvidenceOptions): Promise<GateEvidenceCheckResult>;
69
- export declare function verifyCompletedStagesGateClosure(flowState: FlowState): CompletedStagesClosureResult;
70
- export interface GateReconciliationResult {
71
- stage: FlowStage;
72
- changed: boolean;
73
- before: StageGateState;
74
- after: StageGateState;
75
- demotedGateIds: string[];
76
- notes: string[];
77
- }
78
- export interface GateReconciliationWritebackResult extends GateReconciliationResult {
79
- wrote: boolean;
80
- }
81
- export declare function reconcileCurrentStageGateCatalog(flowState: FlowState): {
82
- nextState: FlowState;
83
- reconciliation: GateReconciliationResult;
84
- };
85
- export declare function reconcileAndWriteCurrentStageGateCatalog(projectRoot: string): Promise<GateReconciliationWritebackResult>;