cclaw-cli 7.7.0 → 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 -766
  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 -132
  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 -36
  193. package/dist/execution-topology.js +0 -73
  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 -63
  258. package/dist/internal/wave-status.js +0 -450
  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,2 +0,0 @@
1
- import { type StageLintContext } from "./shared.js";
2
- export declare function lintShipStage(ctx: StageLintContext): Promise<void>;
@@ -1,250 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import { promisify } from "node:util";
5
- import { readDelegationLedger } from "../delegation.js";
6
- import { resolveArtifactPath as resolveStageArtifactPath } from "../artifact-paths.js";
7
- import { exists } from "../fs-utils.js";
8
- import { extractAcceptanceCriterionIdsFromMarkdown, extractH2Sections, sectionBodyByName } from "./shared.js";
9
- import { readFlowState } from "../run-persistence.js";
10
- const execFileAsync = promisify(execFile);
11
- function extractSliceCardClosedAcceptanceCriteria(content) {
12
- const ids = new Set();
13
- for (const match of content.matchAll(/^\s*(?:[-*]\s*)?closes\s*:\s*(.+)$/gimu)) {
14
- const tail = match[1] ?? "";
15
- for (const id of extractAcceptanceCriterionIdsFromMarkdown(tail)) {
16
- ids.add(id);
17
- }
18
- }
19
- return [...ids];
20
- }
21
- function escapeForRegex(value) {
22
- return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
23
- }
24
- function entryTimestamp(entry) {
25
- return entry.startTs ?? entry.ts ?? entry.launchedTs ?? entry.ackTs ?? entry.completedTs ?? entry.endTs ?? "";
26
- }
27
- async function readSpecAcceptanceCriteriaIds(projectRoot, track) {
28
- const specArtifact = await resolveStageArtifactPath("spec", {
29
- projectRoot,
30
- track,
31
- intent: "read"
32
- });
33
- if (!(await exists(specArtifact.absPath))) {
34
- return [];
35
- }
36
- try {
37
- const specRaw = await fs.readFile(specArtifact.absPath, "utf8");
38
- const sections = extractH2Sections(specRaw);
39
- const acceptanceBody = sectionBodyByName(sections, "Acceptance Criteria") ?? specRaw;
40
- return extractAcceptanceCriterionIdsFromMarkdown(acceptanceBody);
41
- }
42
- catch {
43
- return [];
44
- }
45
- }
46
- async function collectAcceptanceSlicesMap(tddSlicesDir) {
47
- const map = new Map();
48
- let names = [];
49
- try {
50
- names = await fs.readdir(tddSlicesDir);
51
- }
52
- catch {
53
- return map;
54
- }
55
- for (const name of names) {
56
- const match = /^(S-[A-Za-z0-9._-]+)\.md$/u.exec(name);
57
- if (!match)
58
- continue;
59
- const sliceId = match[1];
60
- let content = "";
61
- try {
62
- content = await fs.readFile(path.join(tddSlicesDir, name), "utf8");
63
- }
64
- catch {
65
- continue;
66
- }
67
- const acIds = extractSliceCardClosedAcceptanceCriteria(content);
68
- for (const acId of acIds) {
69
- const set = map.get(acId) ?? new Set();
70
- set.add(sliceId);
71
- map.set(acId, set);
72
- }
73
- }
74
- return map;
75
- }
76
- async function sliceHasManagedCommit(projectRoot, sliceId, sinceTs) {
77
- const grepPattern = `^${escapeForRegex(sliceId)}/`;
78
- const args = ["log", "--extended-regexp", "--grep", grepPattern, "--pretty=%H"];
79
- if (sinceTs && sinceTs.length > 0) {
80
- args.push(`--since=${sinceTs}`);
81
- }
82
- try {
83
- const { stdout } = await execFileAsync("git", args, { cwd: projectRoot });
84
- return stdout.trim().length > 0;
85
- }
86
- catch {
87
- return false;
88
- }
89
- }
90
- async function resolveActiveRunStartTs(projectRoot, runId) {
91
- const ledger = await readDelegationLedger(projectRoot).catch(() => null);
92
- const runRows = ledger
93
- ? ledger.entries.filter((entry) => entry.runId === runId)
94
- : [];
95
- const stamps = runRows
96
- .map((entry) => entryTimestamp(entry))
97
- .filter((value) => typeof value === "string" && value.length > 0)
98
- .sort();
99
- if (stamps.length > 0) {
100
- return stamps[0];
101
- }
102
- try {
103
- const state = await readFlowState(projectRoot);
104
- if (state.activeRunId === runId) {
105
- const completed = Object.values(state.completedStageMeta ?? {})
106
- .map((meta) => meta?.completedAt)
107
- .filter((value) => typeof value === "string" && value.length > 0)
108
- .sort();
109
- if (completed.length > 0) {
110
- return completed[0];
111
- }
112
- }
113
- }
114
- catch {
115
- // no-op fallback
116
- }
117
- return null;
118
- }
119
- export async function lintShipStage(ctx) {
120
- const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride } = ctx;
121
- // Universal Layer 2.8 structural checks (superpowers finishing-a-development-branch).
122
- const optionsBody = sectionBodyByName(sections, "Finalization Options");
123
- if (optionsBody !== null) {
124
- const required = ["MERGE_LOCAL", "OPEN_PR", "KEEP_BRANCH", "DISCARD"];
125
- const missing = required.filter((token) => !optionsBody.includes(token));
126
- findings.push({
127
- section: "Finalization Options Coverage",
128
- required: true,
129
- rule: "Finalization Options must surface all four canonical options (MERGE_LOCAL, OPEN_PR, KEEP_BRANCH, DISCARD).",
130
- found: missing.length === 0,
131
- details: missing.length === 0
132
- ? "All four finalization options surfaced."
133
- : `Finalization Options is missing token(s): ${missing.join(", ")}.`
134
- });
135
- }
136
- const prBody = sectionBodyByName(sections, "Structured PR Body");
137
- if (prBody !== null) {
138
- const required = ["## Summary", "## Test Plan", "## Commits Included"];
139
- const missing = required.filter((token) => !prBody.includes(token));
140
- findings.push({
141
- section: "Structured PR Body Shape",
142
- required: true,
143
- rule: "Structured PR Body must include `## Summary`, `## Test Plan`, and `## Commits Included` subsections.",
144
- found: missing.length === 0,
145
- details: missing.length === 0
146
- ? "Structured PR Body covers all required subsections."
147
- : `Structured PR Body is missing subsection(s): ${missing.join(", ")}.`
148
- });
149
- }
150
- const verifyBody = sectionBodyByName(sections, "Verify Tests Gate");
151
- if (verifyBody !== null) {
152
- const ok = /\bResult:\s*(PASS|FAIL)\b/iu.test(verifyBody);
153
- findings.push({
154
- section: "Verify Tests Gate Result",
155
- required: true,
156
- rule: "Verify Tests Gate must declare a Result of PASS or FAIL.",
157
- found: ok,
158
- details: ok
159
- ? "Verify Tests Gate result declared."
160
- : "Verify Tests Gate is missing a `Result: PASS|FAIL` line."
161
- });
162
- }
163
- const delegationLedger = await readDelegationLedger(projectRoot);
164
- const activeRunRows = delegationLedger.entries.filter((entry) => entry.stage === "ship" &&
165
- entry.runId === delegationLedger.runId &&
166
- entry.agent === "architect" &&
167
- entry.status === "completed");
168
- const hasCrossStageReferenceInArtifact = /\barchitect-cross-stage-verification\b/iu.test(raw) ||
169
- /\barchitect\b[\s\S]{0,180}\bcross[-\s]?stage\b/iu.test(raw) ||
170
- /\bCROSS_STAGE_VERIFIED\b/u.test(raw) ||
171
- /\bDRIFT_DETECTED\b/u.test(raw);
172
- findings.push({
173
- section: "ship.cross_stage_cohesion_missing",
174
- required: true,
175
- rule: "Ship artifact must include architect cross-stage verification reference (`architect-cross-stage-verification` / CROSS_STAGE_VERIFIED / DRIFT_DETECTED) before finalization.",
176
- found: hasCrossStageReferenceInArtifact,
177
- details: hasCrossStageReferenceInArtifact
178
- ? "Architect cross-stage verification reference is present in ship artifact."
179
- : activeRunRows.length > 0
180
- ? "Completed architect delegation exists in ledger, but ship artifact is missing explicit cross-stage verification reference."
181
- : "Ship artifact is missing architect cross-stage verification reference."
182
- });
183
- const driftDetectedInArtifact = /\bDRIFT_DETECTED\b/u.test(raw);
184
- const driftDetectedInDelegation = activeRunRows.some((row) => {
185
- const refs = Array.isArray(row.evidenceRefs) ? row.evidenceRefs.join(" ") : "";
186
- return /\bDRIFT_DETECTED\b/u.test(refs);
187
- });
188
- const driftDetected = driftDetectedInArtifact || driftDetectedInDelegation;
189
- findings.push({
190
- section: "ship.cross_stage_drift_detected",
191
- required: true,
192
- rule: "If architect cross-stage verification reports DRIFT_DETECTED, ship must be blocked until drift is resolved or explicitly waived.",
193
- found: !driftDetected,
194
- details: driftDetected
195
- ? "Architect cross-stage verification reported DRIFT_DETECTED; ship must not proceed."
196
- : "No DRIFT_DETECTED signal found in ship artifact or architect delegation evidence."
197
- });
198
- const specAcceptanceIds = await readSpecAcceptanceCriteriaIds(projectRoot, track);
199
- const tddSlicesDir = path.join(path.dirname(absFile), "tdd-slices");
200
- const acceptanceSlices = await collectAcceptanceSlicesMap(tddSlicesDir);
201
- const gitPresent = await exists(path.join(projectRoot, ".git"));
202
- const runStartTs = gitPresent
203
- ? await resolveActiveRunStartTs(projectRoot, delegationLedger.runId)
204
- : null;
205
- const uncoveredCriteria = [];
206
- if (specAcceptanceIds.length > 0 && gitPresent && runStartTs !== null) {
207
- for (const acId of specAcceptanceIds) {
208
- const slices = [...(acceptanceSlices.get(acId) ?? new Set())];
209
- let covered = false;
210
- if (slices.length > 0) {
211
- for (const sliceId of slices) {
212
- if (await sliceHasManagedCommit(projectRoot, sliceId, runStartTs)) {
213
- covered = true;
214
- break;
215
- }
216
- }
217
- }
218
- if (!covered) {
219
- const reason = slices.length === 0
220
- ? `${acId} has no \`Closes: ${acId}\` slice mapping`
221
- : `${acId} mapped slices ${slices.join(", ")} have no managed commit since run start`;
222
- uncoveredCriteria.push(reason);
223
- findings.push({
224
- section: `acceptance_criterion_${acId}_uncovered`,
225
- required: true,
226
- rule: "Every acceptance criterion must map to at least one slice card and at least one managed slice commit.",
227
- found: false,
228
- details: reason
229
- });
230
- }
231
- }
232
- }
233
- const allAcceptanceCovered = specAcceptanceIds.length === 0 ||
234
- ((!gitPresent || runStartTs !== null) && uncoveredCriteria.length === 0);
235
- findings.push({
236
- section: "ship_all_acceptance_criteria_have_commits",
237
- required: true,
238
- rule: "For every spec AC-N, at least one `tdd-slices/S-*.md` card must declare `Closes: AC-N` and at least one managed slice commit (`^S-<id>/`) must exist since run start.",
239
- found: allAcceptanceCovered,
240
- details: specAcceptanceIds.length === 0
241
- ? "Spec acceptance criteria list is empty or unreadable; AC commit coverage check is idle."
242
- : !gitPresent
243
- ? "No .git directory detected; AC-to-commit coverage check is skipped for no-VCS mode."
244
- : runStartTs === null
245
- ? "Unable to resolve active run start timestamp from delegation ledger/flow-state."
246
- : uncoveredCriteria.length > 0
247
- ? `Uncovered acceptance criteria: ${uncoveredCriteria.join(" | ")}.`
248
- : `All ${specAcceptanceIds.length} acceptance criteria map to slice cards and managed commits since ${runStartTs}.`
249
- });
250
- }
@@ -1,2 +0,0 @@
1
- import { type StageLintContext } from "./shared.js";
2
- export declare function lintSpecStage(ctx: StageLintContext): Promise<void>;
@@ -1,176 +0,0 @@
1
- import { getMarkdownTableRows, evaluateLayeredDocumentReviewStatus, extractAcceptanceCriterionIdsFromMarkdown, sectionBodyByName, SPEC_MAX_MODULES } from "./shared.js";
2
- import { CONFIDENCE_FINDING_REGEX_SOURCE } from "../content/skills.js";
3
- export async function lintSpecStage(ctx) {
4
- const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride } = ctx;
5
- // Universal Layer 2.4 structural checks (evanflow-prd + superpowers).
6
- // All checks fire only when the matching section is present so legacy
7
- // fixtures keep working while v3-template artifacts are validated.
8
- const synthesisBody = sectionBodyByName(sections, "Synthesis Sources");
9
- if (synthesisBody !== null) {
10
- const tableRows = synthesisBody
11
- .split("\n")
12
- .filter((line) => /^\|/u.test(line));
13
- const dataRows = tableRows.length >= 3 ? tableRows.slice(2) : [];
14
- const populatedRows = dataRows.filter((row) => row
15
- .split("|")
16
- .slice(1, -1)
17
- .some((cell) => cell.trim().length > 0));
18
- const hasRow = populatedRows.length >= 1;
19
- findings.push({
20
- section: "Synthesis Sources Coverage",
21
- required: true,
22
- rule: "Synthesis Sources must cite at least one source artifact (synthesize-not-interview).",
23
- found: hasRow,
24
- details: hasRow
25
- ? `Detected ${populatedRows.length} populated source row(s).`
26
- : "Synthesis Sources is empty; spec must cite at least one upstream artifact or context file."
27
- });
28
- }
29
- const behaviorBody = sectionBodyByName(sections, "Behavior Contract");
30
- if (behaviorBody !== null) {
31
- const optedOut = /(^|\n)\s*-\s*None\b/iu.test(behaviorBody);
32
- const userStoryRegex = /(^|\n)\s*-\s*as\s+a\b[\s\S]*?,\s*i\s+can\b[\s\S]*?,\s*so that\b/imu;
33
- const givenWhenThenRegex = /(^|\n)\s*-\s*given\b[\s\S]*?,\s*when\b[\s\S]*?,\s*then\b/imu;
34
- const matches = [
35
- ...behaviorBody.matchAll(/(^|\n)\s*-\s*as\s+a\b[\s\S]*?,\s*i\s+can\b[\s\S]*?,\s*so that\b/gimu),
36
- ...behaviorBody.matchAll(/(^|\n)\s*-\s*given\b[\s\S]*?,\s*when\b[\s\S]*?,\s*then\b/gimu)
37
- ];
38
- const ok = optedOut || matches.length >= 3;
39
- findings.push({
40
- section: "Behavior Contract Shape",
41
- required: true,
42
- rule: "Behavior Contract must list ≥3 behaviors in user-story (As a/I can/so that) or Given/When/Then form, or declare `- None.` for single-step specs.",
43
- found: ok,
44
- details: optedOut
45
- ? "Single-step spec; behaviors opted out via `- None.`."
46
- : ok
47
- ? `Detected ${matches.length} behavior(s) in canonical form.`
48
- : `Detected ${matches.length} behavior(s) in canonical form; need ≥3 (or `
49
- + "`- None.`).",
50
- });
51
- // Bonus: detect if at least one user-story OR given/when/then form is present
52
- // (mirrors existing helpers).
53
- void userStoryRegex;
54
- void givenWhenThenRegex;
55
- }
56
- const archModulesBody = sectionBodyByName(sections, "Architecture Modules");
57
- if (archModulesBody !== null) {
58
- const codeFenceCount = (archModulesBody.match(/```/gu) ?? []).length;
59
- const fnSignatureRegex = /\b(function|class|def|fn|method)\b\s+[A-Za-z_]/u;
60
- const noCode = codeFenceCount === 0 && !fnSignatureRegex.test(archModulesBody);
61
- findings.push({
62
- section: "Architecture Modules No-Code",
63
- required: true,
64
- rule: "Architecture Modules must not contain code blocks, function signatures, or class definitions — modules listed by responsibility only.",
65
- found: noCode,
66
- details: noCode
67
- ? "Architecture Modules is free of code blocks and function/class signatures."
68
- : "Architecture Modules contains a code fence or function/class signature; remove code-level details."
69
- });
70
- const tableRows = archModulesBody.split("\n").filter((line) => /^\|/u.test(line));
71
- const dataRows = tableRows.length >= 3 ? tableRows.slice(2) : [];
72
- const moduleNames = dataRows
73
- .map((row) => row.split("|").slice(1, -1)[0]?.trim() ?? "")
74
- .filter((name) => name.length > 0 && name !== "-" && !/^module$/iu.test(name));
75
- const uniqueModuleCount = new Set(moduleNames).size;
76
- findings.push({
77
- section: "Single-Subsystem Scope",
78
- required: false,
79
- rule: `Architecture Modules should stay within one coherent subsystem boundary (<= ${SPEC_MAX_MODULES} named modules).`,
80
- found: uniqueModuleCount <= SPEC_MAX_MODULES,
81
- details: uniqueModuleCount <= SPEC_MAX_MODULES
82
- ? `Module count (${uniqueModuleCount}) stays within single-subsystem guidance.`
83
- : `Architecture Modules lists ${uniqueModuleCount} modules (> ${SPEC_MAX_MODULES}); split into sub-specs or narrow scope before plan handoff.`
84
- });
85
- }
86
- const selfReviewBody = sectionBodyByName(sections, "Spec Self-Review");
87
- if (selfReviewBody === null) {
88
- findings.push({
89
- section: "Spec Self-Review Coverage",
90
- required: true,
91
- rule: "Spec Self-Review must cover placeholder/consistency/scope/ambiguity checks.",
92
- found: false,
93
- details: "No ## heading matching required section \"Spec Self-Review\"."
94
- });
95
- }
96
- else {
97
- const required = ["placeholder", "consistency", "scope", "ambiguity"];
98
- const missing = required.filter((token) => !new RegExp(token, "iu").test(selfReviewBody));
99
- findings.push({
100
- section: "Spec Self-Review Coverage",
101
- required: true,
102
- rule: "Spec Self-Review must cover placeholder/consistency/scope/ambiguity checks.",
103
- found: missing.length === 0,
104
- details: missing.length === 0
105
- ? "Spec Self-Review covers all required checks."
106
- : `Spec Self-Review is missing check(s): ${missing.join(", ")}.`
107
- });
108
- }
109
- const layeredDocumentReview = evaluateLayeredDocumentReviewStatus(sections, CONFIDENCE_FINDING_REGEX_SOURCE);
110
- if (layeredDocumentReview !== null) {
111
- findings.push({
112
- section: "Document Reviewer Structured Findings",
113
- required: true,
114
- rule: "When Layered review references coherence-reviewer/scope-guardian-reviewer/feasibility-reviewer, include explicit reviewer status plus calibrated finding lines.",
115
- found: layeredDocumentReview.missingStructured.length === 0,
116
- details: layeredDocumentReview.missingStructured.length === 0
117
- ? `Structured findings present for reviewers: ${layeredDocumentReview.triggeredReviewers.join(", ")}.`
118
- : `Missing status or calibrated findings for: ${layeredDocumentReview.missingStructured.join(", ")}.`
119
- });
120
- findings.push({
121
- section: "document-review.fail_without_waiver",
122
- required: true,
123
- rule: "[P1] document-review.fail_without_waiver — reviewer FAIL/PARTIAL requires fix evidence or explicit waiver.",
124
- found: layeredDocumentReview.failOrPartialWithoutWaiver.length === 0,
125
- details: layeredDocumentReview.failOrPartialWithoutWaiver.length === 0
126
- ? "No unwaived FAIL/PARTIAL reviewer statuses detected."
127
- : `Unwaived FAIL/PARTIAL statuses: ${layeredDocumentReview.failOrPartialWithoutWaiver.join(", ")}.`
128
- });
129
- }
130
- const acceptanceCriteriaBody = sectionBodyByName(sections, "Acceptance Criteria");
131
- if (acceptanceCriteriaBody === null) {
132
- findings.push({
133
- section: "spec_ac_ids_present",
134
- required: true,
135
- rule: "Acceptance Criteria must assign stable IDs in `AC-N` format for every criterion row.",
136
- found: false,
137
- details: "No ## heading matching required section \"Acceptance Criteria\"."
138
- });
139
- }
140
- else {
141
- const tableRows = getMarkdownTableRows(acceptanceCriteriaBody);
142
- const bulletRows = acceptanceCriteriaBody
143
- .split("\n")
144
- .map((line) => line.trim())
145
- .filter((line) => /^[-*]\s+/u.test(line));
146
- const candidateRows = tableRows.length > 0
147
- ? tableRows.map((row) => row.join(" | ").trim()).filter((row) => row.length > 0)
148
- : bulletRows;
149
- const missingIds = candidateRows.filter((row) => extractAcceptanceCriterionIdsFromMarkdown(row).length === 0);
150
- const found = candidateRows.length > 0 && missingIds.length === 0;
151
- findings.push({
152
- section: "spec_ac_ids_present",
153
- required: true,
154
- rule: "Acceptance Criteria must assign stable IDs in `AC-N` format for every criterion row.",
155
- found,
156
- details: candidateRows.length === 0
157
- ? "Acceptance Criteria has no populated criterion rows."
158
- : missingIds.length === 0
159
- ? `All ${candidateRows.length} acceptance criterion row(s) include AC-N identifiers.`
160
- : `${missingIds.length} acceptance criterion row(s) are missing AC-N identifiers.`
161
- });
162
- }
163
- if (acceptanceCriteriaBody !== null && /\|/u.test(acceptanceCriteriaBody)) {
164
- const hasParallel = /\bparallelSafe\b/iu.test(acceptanceCriteriaBody);
165
- const hasTouch = /\btouchSurface\b/iu.test(acceptanceCriteriaBody);
166
- findings.push({
167
- section: "spec_acs_not_sliceable",
168
- required: false,
169
- rule: "Acceptance criteria should declare `parallelSafe` and `touchSurface` per row so plan/TDD can schedule slices safely.",
170
- found: hasParallel && hasTouch,
171
- details: hasParallel && hasTouch
172
- ? "Acceptance Criteria mentions parallelSafe and touchSurface."
173
- : "Add columns or inline markers for parallelSafe (true|false) and touchSurface (short area description) for each AC."
174
- });
175
- }
176
- }
@@ -1,118 +0,0 @@
1
- import type { DelegationEntry, DelegationEvent } from "../delegation.js";
2
- import { type LintFinding, type StageLintContext } from "./shared.js";
3
- /**
4
- * TDD stage linter.
5
- *
6
- * Source-of-truth ladder, in order of precedence:
7
- *
8
- * 1. **Phase events** in `delegation-events.jsonl` for the active run
9
- * (`stage=tdd`, `sliceId=S-N`, `phase=red|green|refactor|refactor-deferred|doc`).
10
- * When at least one slice carries any phase event, the linter
11
- * auto-derives Watched-RED / Vertical Slice Cycle from the events
12
- * and writes a rendered summary block between auto-render markers
13
- * in `06-tdd.md`. Markdown table content is no longer required.
14
- * 2. **Hand-authored markdown tables** (Watched-RED Proof + Vertical
15
- * Slice Cycle) — used as a fallback when the events ledger has no
16
- * slice phase rows for the active run.
17
- * 3. **Sharded slice files** under `<artifacts-dir>/tdd-slices/S-*.md`.
18
- * Per-slice prose lives there. The main `06-tdd.md` is auto-indexed
19
- * via `## Slices Index`.
20
- */
21
- export declare function lintTddStage(ctx: StageLintContext): Promise<void>;
22
- interface SliceFileInfo {
23
- sliceId: string;
24
- absPath: string;
25
- }
26
- interface SliceNoOrphanChangesResult {
27
- ok: boolean;
28
- details: string;
29
- }
30
- export declare function evaluateSliceNoOrphanChanges(projectRoot: string, rows: DelegationEntry[]): Promise<SliceNoOrphanChangesResult>;
31
- interface ParsedSliceCycleResult {
32
- ok: boolean;
33
- details: string;
34
- }
35
- interface ExpandedSliceCycleResult extends ParsedSliceCycleResult {
36
- findings: LintFinding[];
37
- }
38
- export declare function evaluateEventsWatchedRed(slices: Map<string, DelegationEntry[]>): ParsedSliceCycleResult;
39
- export declare function evaluateEventsSliceCycle(slices: Map<string, DelegationEntry[]>): ExpandedSliceCycleResult;
40
- interface DocCoverageResult {
41
- missing: string[];
42
- }
43
- export declare function evaluateSliceDocCoverage(slices: Map<string, DelegationEntry[]>): DocCoverageResult;
44
- interface BuilderCoverageResult {
45
- missing: string[];
46
- }
47
- /**
48
- * `slice-builder` must own GREEN. For each slice that recorded a phase=red
49
- * event with non-empty evidenceRefs, require a phase=green whose agent is
50
- * `slice-builder`.
51
- */
52
- export declare function evaluateSliceBuilderCoverage(slices: Map<string, DelegationEntry[]>): BuilderCoverageResult;
53
- interface RedCheckpointResult {
54
- ok: boolean;
55
- details: string;
56
- }
57
- /**
58
- * Detect single-slice dispatch when the merged wave plan requires parallel
59
- * ready slice-builder fan-out.
60
- */
61
- export declare function evaluateWavePlanDispatchIgnored(params: {
62
- artifactsDir: string;
63
- planMarkdown: string;
64
- runEvents: DelegationEvent[];
65
- runId: string;
66
- slices: Map<string, DelegationEntry[]>;
67
- }): Promise<LintFinding | null>;
68
- /**
69
- * Global RED checkpoint enforcement (`global-red` mode).
70
- *
71
- * The wave protocol requires ALL Phase A REDs to land before ANY Phase B
72
- * GREEN starts. The rule is enforced on a per-wave basis, where a wave is
73
- * defined by the managed `## Parallel Execution Plan` block in
74
- * `05-plan.md` and/or `<artifacts-dir>/wave-plans/wave-NN.md` files. When
75
- * no wave manifest exists, the linter falls back to a conservative
76
- * implicit detection: a wave is a contiguous run of `phase=red` events
77
- * with no other-phase events between them; the rule fires only when the
78
- * implicit wave has 2+ members.
79
- *
80
- * Default mode is `per-slice` (see `evaluatePerSliceRedBeforeGreen`);
81
- * this checkpoint applies when a project explicitly opts into
82
- * `global-red`. Exported under both `evaluateGlobalRedCheckpoint`
83
- * (canonical name) and `evaluateRedCheckpoint` (back-compat alias for
84
- * existing tests/consumers).
85
- *
86
- * @param waveMembers Optional explicit wave manifest. Map key is wave
87
- * name (e.g. `"W-01"`); value is the set of slice ids in that wave.
88
- */
89
- export declare function evaluateGlobalRedCheckpoint(slices: Map<string, DelegationEntry[]>, waveMembers?: Map<string, Set<string>> | null): RedCheckpointResult;
90
- /**
91
- * Back-compat alias for `evaluateGlobalRedCheckpoint`. The default mode
92
- * uses `evaluatePerSliceRedBeforeGreen` instead.
93
- */
94
- export declare const evaluateRedCheckpoint: typeof evaluateGlobalRedCheckpoint;
95
- /**
96
- * Per-slice RED-before-GREEN enforcement (default mode).
97
- *
98
- * For each slice with both phase=red and phase=green completed events,
99
- * fail if any green completedTs precedes the slice's last red completedTs.
100
- * No global wave barrier — different slices may freely interleave their
101
- * RED/GREEN/REFACTOR phases.
102
- */
103
- export declare function evaluatePerSliceRedBeforeGreen(slices: Map<string, DelegationEntry[]>): RedCheckpointResult;
104
- export declare function parseVerticalSliceCycle(body: string): ParsedSliceCycleResult;
105
- interface VerificationLadderResult {
106
- ok: boolean;
107
- details: string;
108
- }
109
- export declare function evaluateVerificationLadder(body: string | null): VerificationLadderResult;
110
- interface RenderInput {
111
- mainArtifactPath: string;
112
- slicesByEvents: Map<string, DelegationEntry[]>;
113
- sliceFiles: SliceFileInfo[];
114
- renderSummary?: boolean;
115
- renderIndex?: boolean;
116
- }
117
- export declare function renderTddSliceSummary(input: RenderInput): Promise<void>;
118
- export {};