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
package/dist/logger.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let stdout = process.stdout;
|
|
2
|
+
let stderr = process.stderr;
|
|
3
|
+
export function configureLogger(out, err) {
|
|
4
|
+
stdout = out;
|
|
5
|
+
stderr = err;
|
|
3
6
|
}
|
|
4
|
-
export function
|
|
5
|
-
|
|
7
|
+
export function info(message) {
|
|
8
|
+
stdout.write(`${message}\n`);
|
|
9
|
+
}
|
|
10
|
+
export function warn(message) {
|
|
11
|
+
stderr.write(`${message}\n`);
|
|
12
|
+
}
|
|
13
|
+
export function error(message) {
|
|
14
|
+
stderr.write(`${message}\n`);
|
|
6
15
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ArtifactFrontmatter } from "./artifact-frontmatter.js";
|
|
2
|
+
import type { RoutingClass } from "./types.js";
|
|
3
|
+
export interface ExistingPlanMatch {
|
|
4
|
+
slug: string;
|
|
5
|
+
origin: "active" | "shipped" | "cancelled";
|
|
6
|
+
filePath: string;
|
|
7
|
+
score: number;
|
|
8
|
+
frontmatter?: ArtifactFrontmatter;
|
|
9
|
+
acProgress?: {
|
|
10
|
+
committed: number;
|
|
11
|
+
pending: number;
|
|
12
|
+
total: number;
|
|
13
|
+
};
|
|
14
|
+
lastSpecialist?: ArtifactFrontmatter["last_specialist"];
|
|
15
|
+
refines?: string | null;
|
|
16
|
+
securityFlag?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface RoutingClassification {
|
|
19
|
+
class: RoutingClass;
|
|
20
|
+
signals: string[];
|
|
21
|
+
notes: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function classifyRouting(task: string): RoutingClassification;
|
|
24
|
+
export declare function findMatchingPlans(projectRoot: string, task: string): Promise<ExistingPlanMatch[]>;
|
|
25
|
+
export interface RoutingProposal {
|
|
26
|
+
classification: RoutingClassification;
|
|
27
|
+
matches: ExistingPlanMatch[];
|
|
28
|
+
}
|
|
29
|
+
export declare function proposeRouting(projectRoot: string, task: string): Promise<RoutingProposal>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { slugifyArtifactTopic } from "./artifact-paths.js";
|
|
4
|
+
import { exists, listSubdirs } from "./fs-utils.js";
|
|
5
|
+
import { CANCELLED_DIR_REL_PATH, FLOWS_ROOT, SHIPPED_DIR_REL_PATH } from "./constants.js";
|
|
6
|
+
import { parseArtifact } from "./artifact-frontmatter.js";
|
|
7
|
+
const STOP_WORDS = new Set([
|
|
8
|
+
"the", "a", "an", "to", "of", "in", "on", "for", "and", "or", "is", "are",
|
|
9
|
+
"with", "from", "this", "that", "it", "i", "we", "you", "be", "will",
|
|
10
|
+
"make", "do", "have", "has", "should", "could", "would", "can", "let", "let's"
|
|
11
|
+
]);
|
|
12
|
+
const TRIVIAL_SIGNALS = /(?:typo|rename file|rename function|reformat|format only|fix indent|copy edit|copy-edit|wording|comment fix|wording in)/iu;
|
|
13
|
+
const LARGE_SIGNALS = /(?:refactor|migration|architecture|architectur(?:al|y)|multi[- ]component|across (?:the |multiple )|whole (?:project|app|service|backend|frontend)|across services|saga|distributed|threat model|security[- ]critical|payment|auth(?:entication)?|authoriz(?:ation|ation)|gdpr|pci|sso|sensitive data)/iu;
|
|
14
|
+
export function classifyRouting(task) {
|
|
15
|
+
const text = task.trim();
|
|
16
|
+
const signals = [];
|
|
17
|
+
const notes = [];
|
|
18
|
+
if (LARGE_SIGNALS.test(text))
|
|
19
|
+
signals.push("large-keyword");
|
|
20
|
+
if (TRIVIAL_SIGNALS.test(text) && text.length < 200)
|
|
21
|
+
signals.push("trivial-keyword");
|
|
22
|
+
if (text.split(/\s+/u).length > 60)
|
|
23
|
+
signals.push("long-prompt");
|
|
24
|
+
if (/(\band\b.*){3,}/iu.test(text))
|
|
25
|
+
signals.push("multi-and");
|
|
26
|
+
if (signals.includes("large-keyword"))
|
|
27
|
+
notes.push("matched architectural / sensitive keyword");
|
|
28
|
+
if (signals.includes("multi-and"))
|
|
29
|
+
notes.push("multiple `and` connectors suggest >1 task");
|
|
30
|
+
if (signals.includes("long-prompt"))
|
|
31
|
+
notes.push("prompt longer than 60 words");
|
|
32
|
+
if (signals.includes("trivial-keyword"))
|
|
33
|
+
notes.push("matched trivial keyword");
|
|
34
|
+
if (signals.includes("large-keyword") || signals.includes("multi-and") || signals.includes("long-prompt")) {
|
|
35
|
+
return { class: "large-risky", signals, notes };
|
|
36
|
+
}
|
|
37
|
+
if (signals.includes("trivial-keyword")) {
|
|
38
|
+
return { class: "trivial", signals, notes };
|
|
39
|
+
}
|
|
40
|
+
return { class: "small-medium", signals, notes };
|
|
41
|
+
}
|
|
42
|
+
function tokenize(value, limit = 4096) {
|
|
43
|
+
return new Set(value
|
|
44
|
+
.slice(0, limit)
|
|
45
|
+
.toLowerCase()
|
|
46
|
+
.replace(/[^a-z0-9\s-]/gu, " ")
|
|
47
|
+
.split(/\s+/u)
|
|
48
|
+
.map((part) => part.trim())
|
|
49
|
+
.filter((part) => part.length > 2 && !STOP_WORDS.has(part)));
|
|
50
|
+
}
|
|
51
|
+
function jaccard(left, right) {
|
|
52
|
+
if (left.size === 0 || right.size === 0)
|
|
53
|
+
return 0;
|
|
54
|
+
let intersection = 0;
|
|
55
|
+
for (const value of left)
|
|
56
|
+
if (right.has(value))
|
|
57
|
+
intersection += 1;
|
|
58
|
+
const union = left.size + right.size - intersection;
|
|
59
|
+
return union === 0 ? 0 : intersection / union;
|
|
60
|
+
}
|
|
61
|
+
async function readBody(filePath) {
|
|
62
|
+
try {
|
|
63
|
+
return await fs.readFile(filePath, "utf8");
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function summariseAc(ac) {
|
|
70
|
+
if (!Array.isArray(ac))
|
|
71
|
+
return { committed: 0, pending: 0, total: 0 };
|
|
72
|
+
const committed = ac.filter((item) => item.status === "committed").length;
|
|
73
|
+
return { committed, pending: ac.length - committed, total: ac.length };
|
|
74
|
+
}
|
|
75
|
+
async function tryParseFrontmatter(filePath) {
|
|
76
|
+
const raw = await readBody(filePath);
|
|
77
|
+
if (!raw)
|
|
78
|
+
return null;
|
|
79
|
+
try {
|
|
80
|
+
return parseArtifact(raw, filePath).frontmatter;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function buildMatch(filePath, origin, taskSlugTokens, taskWords) {
|
|
87
|
+
const slug = path.basename(path.dirname(filePath));
|
|
88
|
+
const slugScore = jaccard(taskSlugTokens, new Set(slug.split("-")));
|
|
89
|
+
const body = await readBody(filePath);
|
|
90
|
+
const bodyScore = jaccard(taskWords, tokenize(body));
|
|
91
|
+
const score = Math.max(slugScore, bodyScore);
|
|
92
|
+
const threshold = origin === "active" ? 0.15 : 0.16;
|
|
93
|
+
if (score < threshold)
|
|
94
|
+
return null;
|
|
95
|
+
const frontmatter = (await tryParseFrontmatter(filePath)) ?? undefined;
|
|
96
|
+
return {
|
|
97
|
+
slug,
|
|
98
|
+
origin,
|
|
99
|
+
filePath,
|
|
100
|
+
score,
|
|
101
|
+
frontmatter,
|
|
102
|
+
acProgress: frontmatter ? summariseAc(frontmatter.ac) : undefined,
|
|
103
|
+
lastSpecialist: frontmatter?.last_specialist ?? null,
|
|
104
|
+
refines: frontmatter?.refines ?? null,
|
|
105
|
+
securityFlag: frontmatter?.security_flag === true
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const RESERVED_FLOW_DIRS = new Set(["shipped", "cancelled"]);
|
|
109
|
+
export async function findMatchingPlans(projectRoot, task) {
|
|
110
|
+
const taskWords = tokenize(task);
|
|
111
|
+
const slugFromTask = slugifyArtifactTopic(task);
|
|
112
|
+
const taskSlugTokens = new Set(slugFromTask.split("-"));
|
|
113
|
+
const matches = [];
|
|
114
|
+
const flowsRoot = path.join(projectRoot, FLOWS_ROOT);
|
|
115
|
+
if (await exists(flowsRoot)) {
|
|
116
|
+
for (const dir of await listSubdirs(flowsRoot)) {
|
|
117
|
+
const dirName = path.basename(dir);
|
|
118
|
+
if (RESERVED_FLOW_DIRS.has(dirName))
|
|
119
|
+
continue;
|
|
120
|
+
const planPath = path.join(dir, "plan.md");
|
|
121
|
+
if (!(await exists(planPath)))
|
|
122
|
+
continue;
|
|
123
|
+
const match = await buildMatch(planPath, "active", taskSlugTokens, taskWords);
|
|
124
|
+
if (match)
|
|
125
|
+
matches.push(match);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const shippedRoot = path.join(projectRoot, SHIPPED_DIR_REL_PATH);
|
|
129
|
+
if (await exists(shippedRoot)) {
|
|
130
|
+
for (const dir of await listSubdirs(shippedRoot)) {
|
|
131
|
+
const planPath = path.join(dir, "plan.md");
|
|
132
|
+
if (!(await exists(planPath)))
|
|
133
|
+
continue;
|
|
134
|
+
const match = await buildMatch(planPath, "shipped", taskSlugTokens, taskWords);
|
|
135
|
+
if (match)
|
|
136
|
+
matches.push(match);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const cancelledRoot = path.join(projectRoot, CANCELLED_DIR_REL_PATH);
|
|
140
|
+
if (await exists(cancelledRoot)) {
|
|
141
|
+
for (const dir of await listSubdirs(cancelledRoot)) {
|
|
142
|
+
const planPath = path.join(dir, "plan.md");
|
|
143
|
+
if (!(await exists(planPath)))
|
|
144
|
+
continue;
|
|
145
|
+
const match = await buildMatch(planPath, "cancelled", taskSlugTokens, taskWords);
|
|
146
|
+
if (match)
|
|
147
|
+
matches.push(match);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return matches.sort((a, b) => b.score - a.score);
|
|
151
|
+
}
|
|
152
|
+
export async function proposeRouting(projectRoot, task) {
|
|
153
|
+
const classification = classifyRouting(task);
|
|
154
|
+
const matches = await findMatchingPlans(projectRoot, task);
|
|
155
|
+
return { classification, matches };
|
|
156
|
+
}
|
|
@@ -1,118 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface WriteFlowStateOptions {
|
|
9
|
-
/**
|
|
10
|
-
* When true, skip prior-state validation. Used for run archival, initial
|
|
11
|
-
* bootstrap, or explicit recovery; never set from normal stage handlers.
|
|
12
|
-
*/
|
|
13
|
-
allowReset?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* When true, skip the internal directory-lock acquisition. The caller
|
|
16
|
-
* MUST already hold `flowStateLockPath(projectRoot)` for the duration
|
|
17
|
-
* of this call. Used by run-archive to keep the full archive +
|
|
18
|
-
* flow-state reset inside one atomic lock window.
|
|
19
|
-
*/
|
|
20
|
-
skipLock?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Free-form writer identifier persisted in the `.flow-state.guard.json`
|
|
23
|
-
* sidecar. Helps operators trace which subsystem wrote a given state
|
|
24
|
-
* (e.g. `advance-stage`, `start-flow`, `run-archive`). Defaults to
|
|
25
|
-
* `cclaw-cli` when omitted.
|
|
26
|
-
*/
|
|
27
|
-
writerSubsystem?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface ReadFlowStateOptions {
|
|
30
|
-
/**
|
|
31
|
-
* Reserved compatibility switch from older runtimes. The repair layer was removed,
|
|
32
|
-
* so this flag is now a no-op and only preserved for API stability.
|
|
33
|
-
*/
|
|
34
|
-
repairFeatureSystem?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface FlowStateGuardSidecar {
|
|
37
|
-
sha256: string;
|
|
38
|
-
writtenAt: string;
|
|
39
|
-
writerSubsystem: string;
|
|
40
|
-
runId: string;
|
|
41
|
-
}
|
|
42
|
-
export interface FlowStateGuardMismatchDetails {
|
|
43
|
-
expectedSha: string;
|
|
44
|
-
actualSha: string;
|
|
45
|
-
lastWriter: string;
|
|
46
|
-
writtenAt: string;
|
|
47
|
-
runId: string;
|
|
48
|
-
statePath: string;
|
|
49
|
-
guardPath: string;
|
|
50
|
-
repairCommand: string;
|
|
51
|
-
}
|
|
52
|
-
export declare class FlowStateGuardMismatchError extends Error {
|
|
53
|
-
readonly expectedSha: string;
|
|
54
|
-
readonly actualSha: string;
|
|
55
|
-
readonly lastWriter: string;
|
|
56
|
-
readonly writtenAt: string;
|
|
57
|
-
readonly runId: string;
|
|
58
|
-
readonly statePath: string;
|
|
59
|
-
readonly guardPath: string;
|
|
60
|
-
readonly repairCommand: string;
|
|
61
|
-
constructor(details: FlowStateGuardMismatchDetails);
|
|
62
|
-
}
|
|
63
|
-
export declare class CorruptFlowStateError extends Error {
|
|
64
|
-
readonly statePath: string;
|
|
65
|
-
readonly quarantinedPath: string;
|
|
66
|
-
constructor(statePath: string, quarantinedPath: string, cause: unknown);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Verify the on-disk flow-state against the sha256 sidecar. Throws
|
|
70
|
-
* `FlowStateGuardMismatchError` when manual editing is detected. Safe to
|
|
71
|
-
* call on projects that have never written a sidecar: a missing sidecar is
|
|
72
|
-
* treated as "legacy runtime" and the check silently succeeds.
|
|
73
|
-
*/
|
|
74
|
-
export declare function verifyFlowStateGuard(projectRoot: string): Promise<void>;
|
|
75
|
-
export declare function readFlowState(projectRoot: string, options?: ReadFlowStateOptions): Promise<FlowState>;
|
|
76
|
-
/**
|
|
77
|
-
* Guarded read wrapper used by runtime hook scripts and the repair CLI.
|
|
78
|
-
* Unlike `readFlowState`, it enforces the sha256 sidecar before returning:
|
|
79
|
-
* a manual edit to flow-state.json fails fast with
|
|
80
|
-
* `FlowStateGuardMismatchError`.
|
|
81
|
-
*/
|
|
82
|
-
export declare function readFlowStateGuarded(projectRoot: string, options?: ReadFlowStateOptions): Promise<FlowState>;
|
|
83
|
-
export declare function writeFlowState(projectRoot: string, state: FlowState, options?: WriteFlowStateOptions): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Named entry point for the write-guard workstream. Equivalent to
|
|
86
|
-
* `writeFlowState`: the write always produces the sha256 sidecar via
|
|
87
|
-
* the internal implementation so every existing writer inherits the
|
|
88
|
-
* guard without rewriting callsites.
|
|
89
|
-
*/
|
|
90
|
-
export declare function writeFlowStateGuarded(projectRoot: string, state: FlowState, options?: WriteFlowStateOptions): Promise<void>;
|
|
91
|
-
export interface FlowStateRepairResult {
|
|
92
|
-
sidecar: FlowStateGuardSidecar;
|
|
93
|
-
repairLogPath: string;
|
|
94
|
-
guardPath: string;
|
|
95
|
-
/** Stages that were retro-backfilled into completedStageMeta during repair. */
|
|
96
|
-
completedStageMetaBackfilled: FlowStage[];
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Recompute the write-guard sidecar from the current on-disk flow-state
|
|
100
|
-
* contents and append an audit entry to `.cclaw/.flow-state-repair.log`.
|
|
101
|
-
* The reason is required so no repair happens without an operator-visible
|
|
102
|
-
* rationale. Intended to be called only from the explicit
|
|
103
|
-
* `cclaw-cli internal flow-state-repair` subcommand.
|
|
104
|
-
*/
|
|
105
|
-
export declare function repairFlowStateGuard(projectRoot: string, reason: string): Promise<FlowStateRepairResult>;
|
|
106
|
-
export declare function flowStateGuardSidecarPathFor(projectRoot: string): string;
|
|
107
|
-
export declare function flowStateRepairLogPathFor(projectRoot: string): string;
|
|
108
|
-
/**
|
|
109
|
-
* Exposed path helper so callers that need to serialize a multi-step
|
|
110
|
-
* state operation with flow-state writes (e.g. run archival) can
|
|
111
|
-
* acquire the SAME lock directory used internally by `writeFlowState`.
|
|
112
|
-
*/
|
|
113
|
-
export declare function flowStateLockPathFor(projectRoot: string): string;
|
|
114
|
-
interface EnsureRunSystemOptions {
|
|
115
|
-
createIfMissing?: boolean;
|
|
116
|
-
}
|
|
117
|
-
export declare function ensureRunSystem(projectRoot: string, options?: EnsureRunSystemOptions): Promise<FlowState>;
|
|
118
|
-
export {};
|
|
1
|
+
import { type FlowStateV8 } from "./flow-state.js";
|
|
2
|
+
export declare function flowStatePath(projectRoot: string): string;
|
|
3
|
+
export declare function ensureRunSystem(projectRoot: string): Promise<void>;
|
|
4
|
+
export declare function readFlowState(projectRoot: string): Promise<FlowStateV8>;
|
|
5
|
+
export declare function writeFlowState(projectRoot: string, state: FlowStateV8): Promise<void>;
|
|
6
|
+
export declare function resetFlowState(projectRoot: string): Promise<void>;
|
|
7
|
+
export declare function patchFlowState(projectRoot: string, patch: Partial<FlowStateV8>): Promise<FlowStateV8>;
|