cclaw-cli 7.7.1 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -134
- package/dist/artifact-frontmatter.d.ts +51 -0
- package/dist/artifact-frontmatter.js +131 -0
- package/dist/artifact-paths.d.ts +7 -27
- package/dist/artifact-paths.js +20 -249
- package/dist/cancel.d.ts +16 -0
- package/dist/cancel.js +66 -0
- package/dist/cli.d.ts +2 -27
- package/dist/cli.js +107 -511
- package/dist/compound.d.ts +26 -0
- package/dist/compound.js +96 -0
- package/dist/config.d.ts +14 -51
- package/dist/config.js +23 -359
- package/dist/constants.d.ts +11 -18
- package/dist/constants.js +19 -106
- package/dist/content/antipatterns.d.ts +1 -0
- package/dist/content/antipatterns.js +109 -0
- package/dist/content/artifact-templates.d.ts +10 -0
- package/dist/content/artifact-templates.js +550 -0
- package/dist/content/cancel-command.d.ts +2 -2
- package/dist/content/cancel-command.js +25 -17
- package/dist/content/core-agents.d.ts +9 -233
- package/dist/content/core-agents.js +39 -768
- package/dist/content/decision-protocol.d.ts +1 -12
- package/dist/content/decision-protocol.js +27 -20
- package/dist/content/examples.d.ts +8 -42
- package/dist/content/examples.js +293 -425
- package/dist/content/idea-command.d.ts +2 -0
- package/dist/content/idea-command.js +38 -0
- package/dist/content/iron-laws.d.ts +4 -138
- package/dist/content/iron-laws.js +18 -197
- package/dist/content/meta-skill.d.ts +1 -3
- package/dist/content/meta-skill.js +57 -134
- package/dist/content/node-hooks.d.ts +12 -8
- package/dist/content/node-hooks.js +188 -838
- package/dist/content/recovery.d.ts +8 -0
- package/dist/content/recovery.js +179 -0
- package/dist/content/reference-patterns.d.ts +4 -13
- package/dist/content/reference-patterns.js +260 -389
- package/dist/content/research-playbooks.d.ts +8 -8
- package/dist/content/research-playbooks.js +108 -121
- package/dist/content/review-loop.d.ts +6 -192
- package/dist/content/review-loop.js +29 -731
- package/dist/content/skills.d.ts +8 -38
- package/dist/content/skills.js +681 -732
- package/dist/content/specialist-prompts/architect.d.ts +1 -0
- package/dist/content/specialist-prompts/architect.js +225 -0
- package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
- package/dist/content/specialist-prompts/brainstormer.js +168 -0
- package/dist/content/specialist-prompts/index.d.ts +2 -0
- package/dist/content/specialist-prompts/index.js +14 -0
- package/dist/content/specialist-prompts/planner.d.ts +1 -0
- package/dist/content/specialist-prompts/planner.js +182 -0
- package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/reviewer.js +193 -0
- package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/security-reviewer.js +133 -0
- package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
- package/dist/content/specialist-prompts/slice-builder.js +232 -0
- package/dist/content/stage-playbooks.d.ts +8 -0
- package/dist/content/stage-playbooks.js +404 -0
- package/dist/content/start-command.d.ts +2 -12
- package/dist/content/start-command.js +221 -207
- package/dist/flow-state.d.ts +21 -178
- package/dist/flow-state.js +67 -170
- package/dist/fs-utils.d.ts +6 -26
- package/dist/fs-utils.js +29 -162
- package/dist/gitignore.d.ts +2 -1
- package/dist/gitignore.js +51 -34
- package/dist/harness-detect.d.ts +10 -0
- package/dist/harness-detect.js +29 -0
- package/dist/harness-prompt.d.ts +26 -0
- package/dist/harness-prompt.js +142 -0
- package/dist/install.d.ts +35 -15
- package/dist/install.js +238 -1347
- package/dist/knowledge-store.d.ts +19 -163
- package/dist/knowledge-store.js +56 -590
- package/dist/logger.d.ts +8 -3
- package/dist/logger.js +13 -4
- package/dist/orchestrator-routing.d.ts +29 -0
- package/dist/orchestrator-routing.js +156 -0
- package/dist/run-persistence.d.ts +7 -118
- package/dist/run-persistence.js +29 -845
- package/dist/runtime/run-hook.entry.d.ts +1 -3
- package/dist/runtime/run-hook.entry.js +19 -4
- package/dist/runtime/run-hook.mjs +13 -1024
- package/dist/types.d.ts +25 -261
- package/dist/types.js +8 -36
- package/package.json +6 -3
- package/dist/artifact-linter/brainstorm.d.ts +0 -2
- package/dist/artifact-linter/brainstorm.js +0 -353
- package/dist/artifact-linter/design.d.ts +0 -18
- package/dist/artifact-linter/design.js +0 -444
- package/dist/artifact-linter/findings-dedup.d.ts +0 -56
- package/dist/artifact-linter/findings-dedup.js +0 -232
- package/dist/artifact-linter/plan.d.ts +0 -2
- package/dist/artifact-linter/plan.js +0 -826
- package/dist/artifact-linter/review-army.d.ts +0 -49
- package/dist/artifact-linter/review-army.js +0 -520
- package/dist/artifact-linter/review.d.ts +0 -2
- package/dist/artifact-linter/review.js +0 -113
- package/dist/artifact-linter/scope.d.ts +0 -2
- package/dist/artifact-linter/scope.js +0 -158
- package/dist/artifact-linter/shared.d.ts +0 -637
- package/dist/artifact-linter/shared.js +0 -2163
- package/dist/artifact-linter/ship.d.ts +0 -2
- package/dist/artifact-linter/ship.js +0 -250
- package/dist/artifact-linter/spec.d.ts +0 -2
- package/dist/artifact-linter/spec.js +0 -176
- package/dist/artifact-linter/tdd.d.ts +0 -118
- package/dist/artifact-linter/tdd.js +0 -1404
- package/dist/artifact-linter.d.ts +0 -15
- package/dist/artifact-linter.js +0 -517
- package/dist/codex-feature-flag.d.ts +0 -58
- package/dist/codex-feature-flag.js +0 -193
- package/dist/content/closeout-guidance.d.ts +0 -14
- package/dist/content/closeout-guidance.js +0 -44
- package/dist/content/diff-command.d.ts +0 -1
- package/dist/content/diff-command.js +0 -43
- package/dist/content/harness-doc.d.ts +0 -1
- package/dist/content/harness-doc.js +0 -65
- package/dist/content/hook-events.d.ts +0 -9
- package/dist/content/hook-events.js +0 -23
- package/dist/content/hook-manifest.d.ts +0 -81
- package/dist/content/hook-manifest.js +0 -156
- package/dist/content/hooks.d.ts +0 -11
- package/dist/content/hooks.js +0 -1972
- package/dist/content/idea.d.ts +0 -60
- package/dist/content/idea.js +0 -416
- package/dist/content/language-policy.d.ts +0 -2
- package/dist/content/language-policy.js +0 -13
- package/dist/content/learnings.d.ts +0 -6
- package/dist/content/learnings.js +0 -141
- package/dist/content/observe.d.ts +0 -19
- package/dist/content/observe.js +0 -86
- package/dist/content/opencode-plugin.d.ts +0 -1
- package/dist/content/opencode-plugin.js +0 -635
- package/dist/content/review-prompts.d.ts +0 -1
- package/dist/content/review-prompts.js +0 -104
- package/dist/content/runtime-shared-snippets.d.ts +0 -8
- package/dist/content/runtime-shared-snippets.js +0 -80
- package/dist/content/session-hooks.d.ts +0 -7
- package/dist/content/session-hooks.js +0 -107
- package/dist/content/skills-elicitation.d.ts +0 -1
- package/dist/content/skills-elicitation.js +0 -167
- package/dist/content/stage-command.d.ts +0 -2
- package/dist/content/stage-command.js +0 -17
- package/dist/content/stage-schema.d.ts +0 -117
- package/dist/content/stage-schema.js +0 -955
- package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
- package/dist/content/stages/_lint-metadata/index.js +0 -97
- package/dist/content/stages/brainstorm.d.ts +0 -2
- package/dist/content/stages/brainstorm.js +0 -184
- package/dist/content/stages/design.d.ts +0 -2
- package/dist/content/stages/design.js +0 -288
- package/dist/content/stages/index.d.ts +0 -8
- package/dist/content/stages/index.js +0 -11
- package/dist/content/stages/plan.d.ts +0 -2
- package/dist/content/stages/plan.js +0 -191
- package/dist/content/stages/review.d.ts +0 -2
- package/dist/content/stages/review.js +0 -240
- package/dist/content/stages/schema-types.d.ts +0 -203
- package/dist/content/stages/schema-types.js +0 -1
- package/dist/content/stages/scope.d.ts +0 -2
- package/dist/content/stages/scope.js +0 -254
- package/dist/content/stages/ship.d.ts +0 -2
- package/dist/content/stages/ship.js +0 -159
- package/dist/content/stages/spec.d.ts +0 -2
- package/dist/content/stages/spec.js +0 -170
- package/dist/content/stages/tdd.d.ts +0 -4
- package/dist/content/stages/tdd.js +0 -273
- package/dist/content/state-contracts.d.ts +0 -1
- package/dist/content/state-contracts.js +0 -63
- package/dist/content/status-command.d.ts +0 -4
- package/dist/content/status-command.js +0 -109
- package/dist/content/subagent-context-skills.d.ts +0 -4
- package/dist/content/subagent-context-skills.js +0 -279
- package/dist/content/subagents.d.ts +0 -3
- package/dist/content/subagents.js +0 -997
- package/dist/content/templates.d.ts +0 -26
- package/dist/content/templates.js +0 -1692
- package/dist/content/track-render-context.d.ts +0 -18
- package/dist/content/track-render-context.js +0 -53
- package/dist/content/tree-command.d.ts +0 -1
- package/dist/content/tree-command.js +0 -64
- package/dist/content/utility-skills.d.ts +0 -30
- package/dist/content/utility-skills.js +0 -160
- package/dist/content/view-command.d.ts +0 -2
- package/dist/content/view-command.js +0 -92
- package/dist/delegation.d.ts +0 -649
- package/dist/delegation.js +0 -1539
- package/dist/early-loop.d.ts +0 -70
- package/dist/early-loop.js +0 -302
- package/dist/execution-topology.d.ts +0 -44
- package/dist/execution-topology.js +0 -95
- package/dist/gate-evidence.d.ts +0 -85
- package/dist/gate-evidence.js +0 -631
- package/dist/harness-adapters.d.ts +0 -151
- package/dist/harness-adapters.js +0 -756
- package/dist/harness-selection.d.ts +0 -31
- package/dist/harness-selection.js +0 -214
- package/dist/hook-schema.d.ts +0 -6
- package/dist/hook-schema.js +0 -114
- package/dist/hook-schemas/claude-hooks.v1.json +0 -10
- package/dist/hook-schemas/codex-hooks.v1.json +0 -10
- package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
- package/dist/init-detect.d.ts +0 -2
- package/dist/init-detect.js +0 -50
- package/dist/internal/advance-stage/advance.d.ts +0 -89
- package/dist/internal/advance-stage/advance.js +0 -655
- package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
- package/dist/internal/advance-stage/cancel-run.js +0 -19
- package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
- package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
- package/dist/internal/advance-stage/helpers.d.ts +0 -14
- package/dist/internal/advance-stage/helpers.js +0 -145
- package/dist/internal/advance-stage/hook.d.ts +0 -8
- package/dist/internal/advance-stage/hook.js +0 -40
- package/dist/internal/advance-stage/parsers.d.ts +0 -72
- package/dist/internal/advance-stage/parsers.js +0 -357
- package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
- package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
- package/dist/internal/advance-stage/review-loop.d.ts +0 -16
- package/dist/internal/advance-stage/review-loop.js +0 -199
- package/dist/internal/advance-stage/rewind.d.ts +0 -14
- package/dist/internal/advance-stage/rewind.js +0 -108
- package/dist/internal/advance-stage/start-flow.d.ts +0 -13
- package/dist/internal/advance-stage/start-flow.js +0 -241
- package/dist/internal/advance-stage/verify.d.ts +0 -21
- package/dist/internal/advance-stage/verify.js +0 -185
- package/dist/internal/advance-stage.d.ts +0 -7
- package/dist/internal/advance-stage.js +0 -138
- package/dist/internal/cohesion-contract-stub.d.ts +0 -24
- package/dist/internal/cohesion-contract-stub.js +0 -148
- package/dist/internal/compound-readiness.d.ts +0 -23
- package/dist/internal/compound-readiness.js +0 -102
- package/dist/internal/detect-public-api-changes.d.ts +0 -5
- package/dist/internal/detect-public-api-changes.js +0 -45
- package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
- package/dist/internal/detect-supply-chain-changes.js +0 -138
- package/dist/internal/early-loop-status.d.ts +0 -7
- package/dist/internal/early-loop-status.js +0 -93
- package/dist/internal/envelope-validate.d.ts +0 -7
- package/dist/internal/envelope-validate.js +0 -66
- package/dist/internal/flow-state-repair.d.ts +0 -20
- package/dist/internal/flow-state-repair.js +0 -104
- package/dist/internal/plan-split-waves.d.ts +0 -190
- package/dist/internal/plan-split-waves.js +0 -764
- package/dist/internal/runtime-integrity.d.ts +0 -7
- package/dist/internal/runtime-integrity.js +0 -268
- package/dist/internal/slice-commit.d.ts +0 -7
- package/dist/internal/slice-commit.js +0 -619
- package/dist/internal/tdd-loop-status.d.ts +0 -14
- package/dist/internal/tdd-loop-status.js +0 -68
- package/dist/internal/tdd-red-evidence.d.ts +0 -7
- package/dist/internal/tdd-red-evidence.js +0 -153
- package/dist/internal/waiver-grant.d.ts +0 -62
- package/dist/internal/waiver-grant.js +0 -294
- package/dist/internal/wave-status.d.ts +0 -74
- package/dist/internal/wave-status.js +0 -506
- package/dist/managed-resources.d.ts +0 -53
- package/dist/managed-resources.js +0 -313
- package/dist/policy.d.ts +0 -10
- package/dist/policy.js +0 -167
- package/dist/retro-gate.d.ts +0 -9
- package/dist/retro-gate.js +0 -47
- package/dist/run-archive.d.ts +0 -61
- package/dist/run-archive.js +0 -391
- package/dist/runs.d.ts +0 -2
- package/dist/runs.js +0 -2
- package/dist/stack-detection.d.ts +0 -116
- package/dist/stack-detection.js +0 -489
- package/dist/streaming/event-stream.d.ts +0 -31
- package/dist/streaming/event-stream.js +0 -114
- package/dist/tdd-cycle.d.ts +0 -107
- package/dist/tdd-cycle.js +0 -289
- package/dist/tdd-verification-evidence.d.ts +0 -17
- package/dist/tdd-verification-evidence.js +0 -122
- package/dist/track-heuristics.d.ts +0 -27
- package/dist/track-heuristics.js +0 -154
- package/dist/util/slice-id.d.ts +0 -58
- package/dist/util/slice-id.js +0 -89
- package/dist/worktree-manager.d.ts +0 -20
- package/dist/worktree-manager.js +0 -108
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { RUNTIME_ROOT } from "../constants.js";
|
|
4
|
-
import { readDelegationEvents, readDelegationLedger } from "../delegation.js";
|
|
5
|
-
import { readFlowState } from "../runs.js";
|
|
6
|
-
import { DEFAULT_SLICE_STREAM_REL_PATH, readEventStreamFile } from "../streaming/event-stream.js";
|
|
7
|
-
import { readConfig, resolveExecutionStrictness, resolveExecutionTopology, resolveMaxBuilders } from "../config.js";
|
|
8
|
-
import { routeExecutionTopology } from "../execution-topology.js";
|
|
9
|
-
import { mergeParallelWaveDefinitions, parseParallelExecutionPlanWaves, parseWavePlanDirectory } from "./plan-split-waves.js";
|
|
10
|
-
import { compareSliceIds, parseSliceId } from "../util/slice-id.js";
|
|
11
|
-
const PARALLEL_EXEC_MANAGED_START = "<!-- parallel-exec-managed-start -->";
|
|
12
|
-
const PARALLEL_EXEC_MANAGED_END = "<!-- parallel-exec-managed-end -->";
|
|
13
|
-
function parseArgs(tokens) {
|
|
14
|
-
const args = { format: "json", streamMode: "auto" };
|
|
15
|
-
for (const token of tokens) {
|
|
16
|
-
if (token === "--json")
|
|
17
|
-
args.format = "json";
|
|
18
|
-
else if (token === "--human" || token === "--text")
|
|
19
|
-
args.format = "human";
|
|
20
|
-
else if (token === "--live")
|
|
21
|
-
args.streamMode = "live";
|
|
22
|
-
else if (token === "--file-only")
|
|
23
|
-
args.streamMode = "file";
|
|
24
|
-
else if (token.startsWith("--format=")) {
|
|
25
|
-
const raw = token.slice("--format=".length).trim();
|
|
26
|
-
if (raw === "json" || raw === "human")
|
|
27
|
-
args.format = raw;
|
|
28
|
-
else
|
|
29
|
-
throw new Error(`Unknown wave-status --format value: ${raw}`);
|
|
30
|
-
}
|
|
31
|
-
else if (token.startsWith("--stream-mode=")) {
|
|
32
|
-
const raw = token.slice("--stream-mode=".length).trim();
|
|
33
|
-
if (raw === "auto" || raw === "live" || raw === "file")
|
|
34
|
-
args.streamMode = raw;
|
|
35
|
-
else
|
|
36
|
-
throw new Error(`Unknown wave-status --stream-mode value: ${raw}`);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error(`Unknown wave-status flag: ${token}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return args;
|
|
43
|
-
}
|
|
44
|
-
function classifyWaveStatus(total, closedCount) {
|
|
45
|
-
if (total === 0)
|
|
46
|
-
return "empty";
|
|
47
|
-
if (closedCount === 0)
|
|
48
|
-
return "open";
|
|
49
|
-
if (closedCount >= total)
|
|
50
|
-
return "closed";
|
|
51
|
-
return "partial";
|
|
52
|
-
}
|
|
53
|
-
function parsePipeRow(trimmedLine) {
|
|
54
|
-
const inner = trimmedLine.replace(/^\|/u, "").replace(/\|\s*$/u, "");
|
|
55
|
-
return inner.split("|").map((cell) => cell.trim());
|
|
56
|
-
}
|
|
57
|
-
function normalizePathToken(raw) {
|
|
58
|
-
return raw.trim().replace(/^`|`$/gu, "").replace(/^\.\/+/u, "");
|
|
59
|
-
}
|
|
60
|
-
function parseManagedWaveSliceMeta(planMarkdown) {
|
|
61
|
-
const out = new Map();
|
|
62
|
-
const startIdx = planMarkdown.indexOf(PARALLEL_EXEC_MANAGED_START);
|
|
63
|
-
const endIdx = planMarkdown.indexOf(PARALLEL_EXEC_MANAGED_END);
|
|
64
|
-
if (startIdx < 0 || endIdx <= startIdx)
|
|
65
|
-
return out;
|
|
66
|
-
const body = planMarkdown.slice(startIdx + PARALLEL_EXEC_MANAGED_START.length, endIdx);
|
|
67
|
-
const lines = body.split(/\r?\n/u);
|
|
68
|
-
let currentWaveId = null;
|
|
69
|
-
let headerIdx = new Map();
|
|
70
|
-
for (const rawLine of lines) {
|
|
71
|
-
const trimmed = rawLine.trim();
|
|
72
|
-
const waveMatch = /^###\s+Wave\s+(?:W-)?(\d+)\b/iu.exec(trimmed);
|
|
73
|
-
if (waveMatch) {
|
|
74
|
-
currentWaveId = `W-${waveMatch[1].padStart(2, "0")}`;
|
|
75
|
-
if (!out.has(currentWaveId)) {
|
|
76
|
-
out.set(currentWaveId, new Map());
|
|
77
|
-
}
|
|
78
|
-
headerIdx = new Map();
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (!currentWaveId || !trimmed.startsWith("|"))
|
|
82
|
-
continue;
|
|
83
|
-
const cells = parsePipeRow(trimmed);
|
|
84
|
-
if (cells.length === 0)
|
|
85
|
-
continue;
|
|
86
|
-
const first = cells[0].toLowerCase();
|
|
87
|
-
if (first === "sliceid" ||
|
|
88
|
-
first === "slice id" ||
|
|
89
|
-
first === "unitid" ||
|
|
90
|
-
first === "unit id" ||
|
|
91
|
-
first === "unit") {
|
|
92
|
-
headerIdx = new Map();
|
|
93
|
-
for (let i = 0; i < cells.length; i += 1) {
|
|
94
|
-
const key = cells[i].toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
95
|
-
if (key.length > 0 && !headerIdx.has(key)) {
|
|
96
|
-
headerIdx.set(key, i);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (cells.every((cell) => /^:?-{3,}:?$/u.test(cell))) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const firstCell = (cells[0] ?? "").replace(/^`|`$/gu, "").trim();
|
|
105
|
-
const parsedSlice = parseSliceId(firstCell);
|
|
106
|
-
const parsedUnit = /^U-(\d+(?:[a-z][a-z0-9]*)?)$/iu.exec(firstCell);
|
|
107
|
-
if (!parsedSlice && !parsedUnit)
|
|
108
|
-
continue;
|
|
109
|
-
const sliceId = parsedSlice?.id ?? `S-${parsedUnit[1].toLowerCase()}`;
|
|
110
|
-
const pathsIdx = headerIdx.get("claimedpaths");
|
|
111
|
-
const rawPaths = pathsIdx !== undefined ? (cells[pathsIdx] ?? "") : "";
|
|
112
|
-
const claimedPaths = rawPaths.length === 0
|
|
113
|
-
? []
|
|
114
|
-
: rawPaths
|
|
115
|
-
.split(",")
|
|
116
|
-
.map((p) => normalizePathToken(p))
|
|
117
|
-
.filter((p) => p.length > 0);
|
|
118
|
-
const laneIdx = headerIdx.get("lane");
|
|
119
|
-
const rawLane = laneIdx !== undefined ? (cells[laneIdx] ?? "") : "";
|
|
120
|
-
const lane = rawLane.replace(/^`|`$/gu, "").trim().toLowerCase();
|
|
121
|
-
const riskIdx = headerIdx.get("risktier");
|
|
122
|
-
const rawRisk = riskIdx !== undefined ? (cells[riskIdx] ?? "") : "";
|
|
123
|
-
const riskTier = rawRisk.replace(/^`|`$/gu, "").trim().toLowerCase();
|
|
124
|
-
out.get(currentWaveId).set(sliceId, {
|
|
125
|
-
claimedPaths,
|
|
126
|
-
lane: lane.length > 0 ? lane : undefined,
|
|
127
|
-
riskTier: riskTier.length > 0 ? riskTier : undefined
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Backward-compatible projection: callers that only need claimed paths
|
|
134
|
-
* keep getting `Map<sliceId, paths[]>` shapes.
|
|
135
|
-
*/
|
|
136
|
-
function projectClaimedPaths(meta) {
|
|
137
|
-
const out = new Map();
|
|
138
|
-
for (const [sliceId, info] of meta) {
|
|
139
|
-
out.set(sliceId, info.claimedPaths);
|
|
140
|
-
}
|
|
141
|
-
return out;
|
|
142
|
-
}
|
|
143
|
-
const DISCOVERY_LANES = new Set(["scaffold", "docs"]);
|
|
144
|
-
/**
|
|
145
|
-
* 7.7.1 — count ready members whose lane is `scaffold` or `docs` and whose
|
|
146
|
-
* `riskTier` is not `high`. Members with no recorded lane fall back to
|
|
147
|
-
* non-discovery (so the controller never collapses substantive work into
|
|
148
|
-
* inline by accident).
|
|
149
|
-
*/
|
|
150
|
-
function countDiscoveryOnlyUnits(readySlices, meta) {
|
|
151
|
-
let count = 0;
|
|
152
|
-
for (const sliceId of readySlices) {
|
|
153
|
-
const info = meta.get(sliceId);
|
|
154
|
-
if (!info)
|
|
155
|
-
continue;
|
|
156
|
-
if (!info.lane || !DISCOVERY_LANES.has(info.lane))
|
|
157
|
-
continue;
|
|
158
|
-
if (info.riskTier === "high")
|
|
159
|
-
continue;
|
|
160
|
-
count += 1;
|
|
161
|
-
}
|
|
162
|
-
return count;
|
|
163
|
-
}
|
|
164
|
-
function detectPathConflicts(readySlices, bySlice) {
|
|
165
|
-
const conflicts = new Set();
|
|
166
|
-
const ordered = [...readySlices].sort(compareSliceIds);
|
|
167
|
-
for (let i = 0; i < ordered.length; i += 1) {
|
|
168
|
-
const leftSlice = ordered[i];
|
|
169
|
-
const leftPaths = bySlice.get(leftSlice) ?? [];
|
|
170
|
-
if (leftPaths.length === 0)
|
|
171
|
-
continue;
|
|
172
|
-
const leftSet = new Set(leftPaths);
|
|
173
|
-
for (let j = i + 1; j < ordered.length; j += 1) {
|
|
174
|
-
const rightSlice = ordered[j];
|
|
175
|
-
const rightPaths = bySlice.get(rightSlice) ?? [];
|
|
176
|
-
if (rightPaths.length === 0)
|
|
177
|
-
continue;
|
|
178
|
-
for (const pathToken of rightPaths) {
|
|
179
|
-
if (!leftSet.has(pathToken))
|
|
180
|
-
continue;
|
|
181
|
-
conflicts.add(`${leftSlice}:${pathToken}`);
|
|
182
|
-
conflicts.add(`${rightSlice}:${pathToken}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return [...conflicts].sort();
|
|
187
|
-
}
|
|
188
|
-
const TERMINAL_PHASES = new Set([
|
|
189
|
-
"refactor",
|
|
190
|
-
"refactor-deferred",
|
|
191
|
-
"resolve-conflict"
|
|
192
|
-
]);
|
|
193
|
-
/**
|
|
194
|
-
* Deterministic helper for the TDD controller. Reads the managed
|
|
195
|
-
* `<!-- parallel-exec-managed-start -->` block from
|
|
196
|
-
* `<artifacts-dir>/05-plan.md` plus the `wave-plans/` directory and
|
|
197
|
-
* reports waves + the next dispatchable members so the controller does
|
|
198
|
-
* NOT have to page through a long plan to find the active wave.
|
|
199
|
-
*
|
|
200
|
-
* Always exits 0 unless the plan is malformed (no managed block AND no
|
|
201
|
-
* wave-plans directory), in which case exit 2 with a structured error.
|
|
202
|
-
*/
|
|
203
|
-
export async function runWaveStatus(projectRoot, options = {}) {
|
|
204
|
-
const artifactsDir = options.artifactsDir ?? path.join(projectRoot, RUNTIME_ROOT, "artifacts");
|
|
205
|
-
const flowState = await readFlowState(projectRoot).catch(() => null);
|
|
206
|
-
const activeRunId = flowState?.activeRunId ?? "unknown-run";
|
|
207
|
-
const currentStage = flowState?.currentStage ?? "tdd";
|
|
208
|
-
let planRaw = "";
|
|
209
|
-
try {
|
|
210
|
-
planRaw = await fs.readFile(path.join(artifactsDir, "05-plan.md"), "utf8");
|
|
211
|
-
}
|
|
212
|
-
catch {
|
|
213
|
-
planRaw = "";
|
|
214
|
-
}
|
|
215
|
-
let primaryWaves = [];
|
|
216
|
-
try {
|
|
217
|
-
primaryWaves = parseParallelExecutionPlanWaves(planRaw);
|
|
218
|
-
}
|
|
219
|
-
catch (err) {
|
|
220
|
-
return {
|
|
221
|
-
activeRunId,
|
|
222
|
-
currentStage,
|
|
223
|
-
waves: [],
|
|
224
|
-
nextDispatch: {
|
|
225
|
-
waveId: null,
|
|
226
|
-
readyToDispatch: [],
|
|
227
|
-
pathConflicts: [],
|
|
228
|
-
mode: "none",
|
|
229
|
-
topology: "none",
|
|
230
|
-
topologyReason: "wave plan could not be parsed",
|
|
231
|
-
maxBuilders: 0
|
|
232
|
-
},
|
|
233
|
-
warnings: [
|
|
234
|
-
`wave_plan_parse_error: ${err instanceof Error ? err.message : String(err)}`
|
|
235
|
-
]
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
let secondaryWaves = [];
|
|
239
|
-
try {
|
|
240
|
-
secondaryWaves = await parseWavePlanDirectory(artifactsDir);
|
|
241
|
-
}
|
|
242
|
-
catch (err) {
|
|
243
|
-
secondaryWaves = [];
|
|
244
|
-
void err;
|
|
245
|
-
}
|
|
246
|
-
let merged = [];
|
|
247
|
-
try {
|
|
248
|
-
merged = mergeParallelWaveDefinitions(primaryWaves, secondaryWaves);
|
|
249
|
-
}
|
|
250
|
-
catch (err) {
|
|
251
|
-
return {
|
|
252
|
-
activeRunId,
|
|
253
|
-
currentStage,
|
|
254
|
-
waves: [],
|
|
255
|
-
nextDispatch: {
|
|
256
|
-
waveId: null,
|
|
257
|
-
readyToDispatch: [],
|
|
258
|
-
pathConflicts: [],
|
|
259
|
-
mode: "none",
|
|
260
|
-
topology: "none",
|
|
261
|
-
topologyReason: "wave plan sources conflict",
|
|
262
|
-
maxBuilders: 0
|
|
263
|
-
},
|
|
264
|
-
warnings: [
|
|
265
|
-
`wave_plan_merge_conflict: ${err instanceof Error ? err.message : String(err)}`
|
|
266
|
-
]
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
// Collect closed slice ids from the active run delegation ledger +
|
|
270
|
-
// events. A slice is "closed" once it carries a terminal phase
|
|
271
|
-
// (refactor, refactor-deferred, resolve-conflict) OR a phase=green
|
|
272
|
-
// event with `refactorOutcome` recorded inline. Anything else we treat
|
|
273
|
-
// as still open so the helper never falsely advances.
|
|
274
|
-
const closedSlices = new Set();
|
|
275
|
-
let ledgerEntries = [];
|
|
276
|
-
try {
|
|
277
|
-
const ledger = await readDelegationLedger(projectRoot);
|
|
278
|
-
ledgerEntries = ledger.entries.filter((entry) => entry.runId === ledger.runId && entry.stage === "tdd");
|
|
279
|
-
}
|
|
280
|
-
catch {
|
|
281
|
-
ledgerEntries = [];
|
|
282
|
-
}
|
|
283
|
-
for (const entry of ledgerEntries) {
|
|
284
|
-
if (entry.status !== "completed")
|
|
285
|
-
continue;
|
|
286
|
-
if (typeof entry.sliceId !== "string")
|
|
287
|
-
continue;
|
|
288
|
-
if (typeof entry.phase !== "string")
|
|
289
|
-
continue;
|
|
290
|
-
if (TERMINAL_PHASES.has(entry.phase)) {
|
|
291
|
-
closedSlices.add(entry.sliceId);
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
if (entry.phase === "green" && entry.refactorOutcome) {
|
|
295
|
-
const mode = entry.refactorOutcome.mode;
|
|
296
|
-
if (mode === "inline" || mode === "deferred") {
|
|
297
|
-
closedSlices.add(entry.sliceId);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
const warnings = [];
|
|
302
|
-
const streamMode = options.streamMode ?? "auto";
|
|
303
|
-
const streamPath = options.streamPath ?? path.join(projectRoot, DEFAULT_SLICE_STREAM_REL_PATH);
|
|
304
|
-
let shouldReadJsonlFallback = streamMode === "file";
|
|
305
|
-
// Prefer live stream events when requested/available.
|
|
306
|
-
if (streamMode !== "file") {
|
|
307
|
-
const streamResult = await readEventStreamFile(streamPath);
|
|
308
|
-
if (streamResult.droppedLines > 0) {
|
|
309
|
-
warnings.push(`wave_stream_dropped_lines: ${streamResult.droppedLines}`);
|
|
310
|
-
}
|
|
311
|
-
if (streamResult.events.length > 0) {
|
|
312
|
-
for (const ev of streamResult.events) {
|
|
313
|
-
if (ev.runId && ev.runId !== activeRunId)
|
|
314
|
-
continue;
|
|
315
|
-
if (ev.stage && ev.stage !== "tdd")
|
|
316
|
-
continue;
|
|
317
|
-
if (TERMINAL_PHASES.has(ev.phase)) {
|
|
318
|
-
closedSlices.add(ev.sliceId);
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
if (ev.phase === "green" && ev.refactorOutcome) {
|
|
322
|
-
const mode = ev.refactorOutcome.mode;
|
|
323
|
-
if (mode === "inline" || mode === "deferred") {
|
|
324
|
-
closedSlices.add(ev.sliceId);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
shouldReadJsonlFallback = false;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
shouldReadJsonlFallback = true;
|
|
332
|
-
if (streamMode === "auto" || streamMode === "live") {
|
|
333
|
-
warnings.push("wave_status_live_fallback_to_file: no parseable stream events");
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
// Fallback to JSONL events when live stream is absent or disabled.
|
|
338
|
-
if (shouldReadJsonlFallback) {
|
|
339
|
-
try {
|
|
340
|
-
const { events } = await readDelegationEvents(projectRoot);
|
|
341
|
-
for (const ev of events) {
|
|
342
|
-
if (ev.event !== "completed")
|
|
343
|
-
continue;
|
|
344
|
-
if (ev.runId !== activeRunId)
|
|
345
|
-
continue;
|
|
346
|
-
if (ev.stage !== "tdd")
|
|
347
|
-
continue;
|
|
348
|
-
if (typeof ev.sliceId !== "string")
|
|
349
|
-
continue;
|
|
350
|
-
if (typeof ev.phase !== "string")
|
|
351
|
-
continue;
|
|
352
|
-
if (TERMINAL_PHASES.has(ev.phase)) {
|
|
353
|
-
closedSlices.add(ev.sliceId);
|
|
354
|
-
continue;
|
|
355
|
-
}
|
|
356
|
-
if (ev.phase === "green" && ev.refactorOutcome) {
|
|
357
|
-
const mode = ev.refactorOutcome.mode;
|
|
358
|
-
if (mode === "inline" || mode === "deferred") {
|
|
359
|
-
closedSlices.add(ev.sliceId);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
catch {
|
|
365
|
-
// best-effort; ledger already covers the canonical case.
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
const waves = merged.map((wave) => {
|
|
369
|
-
const members = wave.members.map((m) => m.sliceId);
|
|
370
|
-
const closedMembers = members.filter((id) => closedSlices.has(id));
|
|
371
|
-
const openMembers = members.filter((id) => !closedSlices.has(id));
|
|
372
|
-
return {
|
|
373
|
-
waveId: wave.waveId,
|
|
374
|
-
members,
|
|
375
|
-
closedMembers,
|
|
376
|
-
openMembers,
|
|
377
|
-
readyMembers: openMembers,
|
|
378
|
-
blockedMembers: [],
|
|
379
|
-
status: classifyWaveStatus(members.length, closedMembers.length)
|
|
380
|
-
};
|
|
381
|
-
});
|
|
382
|
-
const firstOpenWave = waves.find((w) => w.status === "open" || w.status === "partial") ?? null;
|
|
383
|
-
if (merged.length === 0 && planRaw.length === 0) {
|
|
384
|
-
warnings.push("wave_plan_missing: 05-plan.md not found or empty under <artifacts-dir>.");
|
|
385
|
-
}
|
|
386
|
-
else if (merged.length === 0) {
|
|
387
|
-
warnings.push("wave_plan_managed_block_missing: <!-- parallel-exec-managed-start --> block not found in 05-plan.md and wave-plans/ has no parseable wave files.");
|
|
388
|
-
}
|
|
389
|
-
let nextDispatch;
|
|
390
|
-
const config = await readConfig(projectRoot).catch(() => null);
|
|
391
|
-
const configuredTopology = resolveExecutionTopology(config);
|
|
392
|
-
const strictness = resolveExecutionStrictness(config);
|
|
393
|
-
const maxBuilders = resolveMaxBuilders(config);
|
|
394
|
-
if (firstOpenWave === null) {
|
|
395
|
-
nextDispatch = {
|
|
396
|
-
waveId: null,
|
|
397
|
-
readyToDispatch: [],
|
|
398
|
-
pathConflicts: [],
|
|
399
|
-
mode: "none",
|
|
400
|
-
topology: "none",
|
|
401
|
-
topologyReason: "no open wave has ready units",
|
|
402
|
-
maxBuilders
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
const readyToDispatch = [...firstOpenWave.readyMembers].sort(compareSliceIds);
|
|
407
|
-
const sliceMetaByWave = parseManagedWaveSliceMeta(planRaw);
|
|
408
|
-
const sliceMeta = sliceMetaByWave.get(firstOpenWave.waveId) ?? new Map();
|
|
409
|
-
const conflicts = detectPathConflicts(readyToDispatch, projectClaimedPaths(sliceMeta));
|
|
410
|
-
const discoveryOnlyUnits = countDiscoveryOnlyUnits(readyToDispatch, sliceMeta);
|
|
411
|
-
const baseMode = conflicts.length > 0
|
|
412
|
-
? "blocked"
|
|
413
|
-
: readyToDispatch.length > 1
|
|
414
|
-
? "wave-fanout"
|
|
415
|
-
: readyToDispatch.length === 1
|
|
416
|
-
? "single-slice"
|
|
417
|
-
: "none";
|
|
418
|
-
const topologyDecision = baseMode === "none"
|
|
419
|
-
? null
|
|
420
|
-
: routeExecutionTopology({
|
|
421
|
-
configuredTopology,
|
|
422
|
-
strictness,
|
|
423
|
-
maxBuilders,
|
|
424
|
-
shape: {
|
|
425
|
-
unitCount: readyToDispatch.length,
|
|
426
|
-
independentUnitCount: conflicts.length > 0 ? 0 : readyToDispatch.length,
|
|
427
|
-
substantialUnitCount: readyToDispatch.length,
|
|
428
|
-
hasPathConflicts: conflicts.length > 0,
|
|
429
|
-
inlineSafe: false,
|
|
430
|
-
discoveryOnlyUnits
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
// 7.7.1 — when the router collapses a discovery-only ready set into
|
|
434
|
-
// `inline`, surface `controller-inline` mode + a controllerHint so the
|
|
435
|
-
// controller knows it must fulfil the slices this turn instead of
|
|
436
|
-
// dispatching slice-builder per file.
|
|
437
|
-
const mode = topologyDecision?.topology === "inline"
|
|
438
|
-
? "controller-inline"
|
|
439
|
-
: baseMode;
|
|
440
|
-
const controllerHint = topologyDecision?.topology === "inline"
|
|
441
|
-
? "Fulfill ready slices in this turn without dispatching slice-builder. Record delegation rows with role=controller (scheduled→completed) per slice."
|
|
442
|
-
: undefined;
|
|
443
|
-
nextDispatch = {
|
|
444
|
-
waveId: firstOpenWave.waveId,
|
|
445
|
-
readyToDispatch,
|
|
446
|
-
pathConflicts: conflicts,
|
|
447
|
-
mode,
|
|
448
|
-
topology: topologyDecision?.topology ?? "none",
|
|
449
|
-
topologyReason: topologyDecision?.reason ?? "no ready units",
|
|
450
|
-
maxBuilders: topologyDecision?.maxBuilders ?? maxBuilders,
|
|
451
|
-
...(controllerHint ? { controllerHint } : {})
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
return {
|
|
455
|
-
activeRunId,
|
|
456
|
-
currentStage,
|
|
457
|
-
waves,
|
|
458
|
-
nextDispatch,
|
|
459
|
-
warnings
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
function formatHumanReport(report) {
|
|
463
|
-
const lines = [];
|
|
464
|
-
lines.push(`activeRunId: ${report.activeRunId}`);
|
|
465
|
-
lines.push(`currentStage: ${report.currentStage}`);
|
|
466
|
-
lines.push("waves:");
|
|
467
|
-
if (report.waves.length === 0) {
|
|
468
|
-
lines.push(" (no waves discovered)");
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
for (const wave of report.waves) {
|
|
472
|
-
lines.push(` ${wave.waveId} [${wave.status}]: ` +
|
|
473
|
-
`closed=[${wave.closedMembers.join(",")}] ` +
|
|
474
|
-
`open=[${wave.openMembers.join(",")}]`);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
lines.push(`nextDispatch: wave=${report.nextDispatch.waveId ?? "(none)"} ` +
|
|
478
|
-
`mode=${report.nextDispatch.mode} ` +
|
|
479
|
-
`topology=${report.nextDispatch.topology} ` +
|
|
480
|
-
`ready=[${report.nextDispatch.readyToDispatch.join(",")}]`);
|
|
481
|
-
if (report.warnings.length > 0) {
|
|
482
|
-
lines.push("warnings:");
|
|
483
|
-
for (const warn of report.warnings) {
|
|
484
|
-
lines.push(` - ${warn}`);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return lines.join("\n") + "\n";
|
|
488
|
-
}
|
|
489
|
-
export async function runWaveStatusCommand(projectRoot, argv, io) {
|
|
490
|
-
let parsed;
|
|
491
|
-
try {
|
|
492
|
-
parsed = parseArgs(argv);
|
|
493
|
-
}
|
|
494
|
-
catch (err) {
|
|
495
|
-
io.stderr.write(`cclaw internal wave-status: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
496
|
-
return 1;
|
|
497
|
-
}
|
|
498
|
-
const report = await runWaveStatus(projectRoot, { streamMode: parsed.streamMode });
|
|
499
|
-
if (parsed.format === "json") {
|
|
500
|
-
io.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
io.stdout.write(formatHumanReport(report));
|
|
504
|
-
}
|
|
505
|
-
return 0;
|
|
506
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type HarnessId } from "./types.js";
|
|
2
|
-
import type { WriteFileSafeOptions } from "./fs-utils.js";
|
|
3
|
-
export declare const MANAGED_RESOURCE_MANIFEST_REL_PATH = ".cclaw/state/managed-resources.json";
|
|
4
|
-
export interface ManagedResourceEntry {
|
|
5
|
-
path: string;
|
|
6
|
-
sha256: string;
|
|
7
|
-
owner: "cclaw";
|
|
8
|
-
harness?: HarnessId | "core";
|
|
9
|
-
packageVersion: string;
|
|
10
|
-
prunable: boolean;
|
|
11
|
-
safeToOverwrite: boolean;
|
|
12
|
-
updatedAt: string;
|
|
13
|
-
lastBackupPath?: string;
|
|
14
|
-
previousSha256?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface ManagedResourceManifest {
|
|
17
|
-
version: 1;
|
|
18
|
-
generatedAt: string;
|
|
19
|
-
packageVersion: string;
|
|
20
|
-
resources: ManagedResourceEntry[];
|
|
21
|
-
}
|
|
22
|
-
interface ManagedResourceSessionOptions {
|
|
23
|
-
projectRoot: string;
|
|
24
|
-
operation: string;
|
|
25
|
-
}
|
|
26
|
-
export interface ManagedResourceValidationIssue {
|
|
27
|
-
index?: number;
|
|
28
|
-
path?: string;
|
|
29
|
-
field: string;
|
|
30
|
-
message: string;
|
|
31
|
-
}
|
|
32
|
-
export declare function isManagedGeneratedPath(relPath: string): boolean;
|
|
33
|
-
export declare function validateManagedResourceEntry(value: unknown, index?: number): ManagedResourceValidationIssue[];
|
|
34
|
-
export declare function validateManagedResourceManifest(value: unknown): ManagedResourceValidationIssue[];
|
|
35
|
-
export declare function isValidManagedResourceEntry(value: unknown): value is ManagedResourceEntry;
|
|
36
|
-
export declare function readManagedResourceManifest(projectRoot: string): Promise<ManagedResourceManifest | null>;
|
|
37
|
-
export declare class ManagedResourceSession {
|
|
38
|
-
private readonly projectRoot;
|
|
39
|
-
private readonly operation;
|
|
40
|
-
private readonly timestamp;
|
|
41
|
-
private readonly previous;
|
|
42
|
-
private readonly touched;
|
|
43
|
-
private constructor();
|
|
44
|
-
static create(options: ManagedResourceSessionOptions): Promise<ManagedResourceSession>;
|
|
45
|
-
shouldManage(filePath: string): boolean;
|
|
46
|
-
writeFileSafe(filePath: string, content: string, options?: WriteFileSafeOptions): Promise<void>;
|
|
47
|
-
commit(): Promise<ManagedResourceManifest>;
|
|
48
|
-
}
|
|
49
|
-
export declare function getActiveManagedResourceSession(): ManagedResourceSession | null;
|
|
50
|
-
export declare function setActiveManagedResourceSession(session: ManagedResourceSession | null): void;
|
|
51
|
-
export declare function isManagedResourcePath(projectRoot: string, filePath: string): boolean;
|
|
52
|
-
export declare function hashManagedResourceContent(content: string | Buffer): string;
|
|
53
|
-
export {};
|