harnessed 4.21.0 → 4.22.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.
- package/bin/harnessed-inject-state.mjs +68 -8
- package/dist/cli.mjs +428 -102
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/workflows/auto/SKILL.md +5 -1
- package/workflows/auto/SKILL.zh-Hans.md +5 -1
- package/workflows/plan/architecture/SKILL.md +4 -0
- package/workflows/plan/architecture/SKILL.zh-Hans.md +4 -0
- package/workflows/plan/auto/SKILL.md +4 -0
- package/workflows/plan/auto/SKILL.zh-Hans.md +4 -0
- package/workflows/plan/phase/SKILL.md +4 -0
- package/workflows/plan/phase/SKILL.zh-Hans.md +4 -0
- package/workflows/research/SKILL.md +4 -0
- package/workflows/research/SKILL.zh-Hans.md +4 -0
- package/workflows/retro/SKILL.md +4 -0
- package/workflows/retro/SKILL.zh-Hans.md +4 -0
- package/workflows/ship/auto/SKILL.md +4 -0
- package/workflows/ship/auto/SKILL.zh-Hans.md +4 -0
- package/workflows/ship/preflight/SKILL.md +4 -0
- package/workflows/ship/preflight/SKILL.zh-Hans.md +4 -0
- package/workflows/task/auto/SKILL.md +4 -0
- package/workflows/task/auto/SKILL.zh-Hans.md +4 -0
- package/workflows/task/code/SKILL.md +4 -0
- package/workflows/task/code/SKILL.zh-Hans.md +4 -0
- package/workflows/task/deliver/SKILL.md +4 -0
- package/workflows/task/deliver/SKILL.zh-Hans.md +4 -0
- package/workflows/task/test/SKILL.md +4 -0
- package/workflows/task/test/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/auto/SKILL.md +4 -0
- package/workflows/verify/auto/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/code-review/SKILL.md +4 -0
- package/workflows/verify/code-review/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/design/SKILL.md +4 -0
- package/workflows/verify/design/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/eval-review/SKILL.md +4 -0
- package/workflows/verify/eval-review/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/multispec/SKILL.md +4 -0
- package/workflows/verify/multispec/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/paranoid/SKILL.md +4 -0
- package/workflows/verify/paranoid/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/progress/SKILL.md +4 -0
- package/workflows/verify/progress/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/qa/SKILL.md +4 -0
- package/workflows/verify/qa/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/security/SKILL.md +4 -0
- package/workflows/verify/security/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/simplify/SKILL.md +4 -0
- package/workflows/verify/simplify/SKILL.zh-Hans.md +4 -0
- package/workflows/verify/validate-phase/SKILL.md +4 -0
- package/workflows/verify/validate-phase/SKILL.zh-Hans.md +4 -0
package/dist/cli.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var init_package = __esm({
|
|
|
38
38
|
"package.json"() {
|
|
39
39
|
package_default = {
|
|
40
40
|
name: "harnessed",
|
|
41
|
-
version: "4.
|
|
41
|
+
version: "4.22.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -515,10 +515,12 @@ var init_schema = __esm({
|
|
|
515
515
|
// src/checkpoint/workflowStore.ts
|
|
516
516
|
var workflowStore_exports = {};
|
|
517
517
|
__export(workflowStore_exports, {
|
|
518
|
+
IntentEntry: () => IntentEntry,
|
|
518
519
|
RetroMetaEntry: () => RetroMetaEntry,
|
|
519
520
|
WorkflowStoreV1: () => WorkflowStoreV1,
|
|
520
521
|
activeKey: () => activeKey,
|
|
521
522
|
listWorkflows: () => listWorkflows,
|
|
523
|
+
readIntent: () => readIntent,
|
|
522
524
|
readStoreRaw: () => readStoreRaw,
|
|
523
525
|
repoKey: () => repoKey,
|
|
524
526
|
writeStoreRaw: () => writeStoreRaw
|
|
@@ -575,6 +577,10 @@ async function writeStoreRaw(store) {
|
|
|
575
577
|
await mkdir(dirname(p7), { recursive: true });
|
|
576
578
|
await writeFileAtomic(p7, JSON.stringify(store, null, 2));
|
|
577
579
|
}
|
|
580
|
+
async function readIntent(cwd = process.cwd()) {
|
|
581
|
+
const store = await readStoreRaw();
|
|
582
|
+
return store.intents?.[activeKey(cwd)] ?? store.intents?.[repoKey(cwd)] ?? null;
|
|
583
|
+
}
|
|
578
584
|
async function listWorkflows() {
|
|
579
585
|
const store = await readStoreRaw();
|
|
580
586
|
return Object.entries(store.workflows).map(([key, wf]) => ({
|
|
@@ -583,7 +589,7 @@ async function listWorkflows() {
|
|
|
583
589
|
status: wf.status
|
|
584
590
|
}));
|
|
585
591
|
}
|
|
586
|
-
var RetroMetaEntry, WorkflowStoreV1;
|
|
592
|
+
var RetroMetaEntry, IntentEntry, WorkflowStoreV1;
|
|
587
593
|
var init_workflowStore = __esm({
|
|
588
594
|
"src/checkpoint/workflowStore.ts"() {
|
|
589
595
|
init_harnessedRoot();
|
|
@@ -598,12 +604,28 @@ var init_workflowStore = __esm({
|
|
|
598
604
|
},
|
|
599
605
|
{ additionalProperties: false }
|
|
600
606
|
);
|
|
607
|
+
IntentEntry = Type.Object(
|
|
608
|
+
{
|
|
609
|
+
// Invoked command name (master OR leaf sub — field name kept for 765cbc9
|
|
610
|
+
// store back-compat; kind carries the distinction).
|
|
611
|
+
master: Type.String({ minLength: 1 }),
|
|
612
|
+
ts: Type.String({ minLength: 1 }),
|
|
613
|
+
// 4.22.0 T6 — additive-optional: absent = 'master' (765cbc9 only ever wrote
|
|
614
|
+
// master intents). 'leaf' switches banner/nag to the leaf SOP wording
|
|
615
|
+
// (prompt → spawn → checkpoint complete) and the absorb trigger to that
|
|
616
|
+
// sub's complete/fail instead of `checkpoint start`.
|
|
617
|
+
kind: Type.Optional(Type.Union([Type.Literal("master"), Type.Literal("leaf")]))
|
|
618
|
+
},
|
|
619
|
+
{ additionalProperties: false }
|
|
620
|
+
);
|
|
601
621
|
WorkflowStoreV1 = Type.Object(
|
|
602
622
|
{
|
|
603
623
|
schemaVersion: Type.Literal(SCHEMA_VERSIONS.workflowStore),
|
|
604
624
|
workflows: Type.Record(Type.String(), CurrentWorkflowV1),
|
|
605
625
|
// Additive-optional (no schemaVersion bump — old stores Value.Check-pass).
|
|
606
|
-
retro_meta: Type.Optional(Type.Record(Type.String(), RetroMetaEntry))
|
|
626
|
+
retro_meta: Type.Optional(Type.Record(Type.String(), RetroMetaEntry)),
|
|
627
|
+
// 4.22.0 — additive-optional, same rationale.
|
|
628
|
+
intents: Type.Optional(Type.Record(Type.String(), IntentEntry))
|
|
607
629
|
},
|
|
608
630
|
{ additionalProperties: false }
|
|
609
631
|
);
|
|
@@ -2077,6 +2099,106 @@ var init_path_guard = __esm({
|
|
|
2077
2099
|
};
|
|
2078
2100
|
}
|
|
2079
2101
|
});
|
|
2102
|
+
|
|
2103
|
+
// src/checkpoint/intentKind.ts
|
|
2104
|
+
var intentKind_exports = {};
|
|
2105
|
+
__export(intentKind_exports, {
|
|
2106
|
+
classifyIntentKind: () => classifyIntentKind
|
|
2107
|
+
});
|
|
2108
|
+
function classifyIntentKind(sub, assetsRoot) {
|
|
2109
|
+
try {
|
|
2110
|
+
const raw = readFileSync(join(assetsRoot, "workflows", "role-prompts.yaml"), "utf8");
|
|
2111
|
+
const doc = parse(raw);
|
|
2112
|
+
return doc?.prompts?.[sub]?.is_master === true ? "master" : "leaf";
|
|
2113
|
+
} catch {
|
|
2114
|
+
return "leaf";
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
var init_intentKind = __esm({
|
|
2118
|
+
"src/checkpoint/intentKind.ts"() {
|
|
2119
|
+
}
|
|
2120
|
+
});
|
|
2121
|
+
function getPackageRoot() {
|
|
2122
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
2123
|
+
const thisDir = dirname(thisFile);
|
|
2124
|
+
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
2125
|
+
return resolve(thisDir, "..");
|
|
2126
|
+
}
|
|
2127
|
+
return resolve(thisDir, "..", "..", "..");
|
|
2128
|
+
}
|
|
2129
|
+
var init_packagePath = __esm({
|
|
2130
|
+
"src/cli/lib/packagePath.ts"() {
|
|
2131
|
+
}
|
|
2132
|
+
});
|
|
2133
|
+
|
|
2134
|
+
// src/cli/lib/assetsRoot.ts
|
|
2135
|
+
var assetsRoot_exports = {};
|
|
2136
|
+
__export(assetsRoot_exports, {
|
|
2137
|
+
compiledAssetsDir: () => compiledAssetsDir,
|
|
2138
|
+
computeAssetsRoot: () => computeAssetsRoot,
|
|
2139
|
+
getAssetsRoot: () => getAssetsRoot,
|
|
2140
|
+
isCompiledModuleUrl: () => isCompiledModuleUrl
|
|
2141
|
+
});
|
|
2142
|
+
function isCompiledModuleUrl(url) {
|
|
2143
|
+
let s = url;
|
|
2144
|
+
try {
|
|
2145
|
+
s = decodeURIComponent(url);
|
|
2146
|
+
} catch {
|
|
2147
|
+
}
|
|
2148
|
+
const normalized = s.replace(/\\/g, "/").toLowerCase();
|
|
2149
|
+
return BUNFS_MARKERS.some((m) => normalized.includes(m));
|
|
2150
|
+
}
|
|
2151
|
+
function computeAssetsRoot(d) {
|
|
2152
|
+
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
2153
|
+
if (override && override.trim().length > 0) {
|
|
2154
|
+
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
2155
|
+
}
|
|
2156
|
+
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
2157
|
+
const root = join(d.stateRoot(), "assets", d.version);
|
|
2158
|
+
const present = d.exists(join(root, "workflows"));
|
|
2159
|
+
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
2160
|
+
}
|
|
2161
|
+
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
2162
|
+
}
|
|
2163
|
+
function compiledAssetsDir(version) {
|
|
2164
|
+
return join(detectPlatform().stateRoot, "assets", version);
|
|
2165
|
+
}
|
|
2166
|
+
function realDeps() {
|
|
2167
|
+
return {
|
|
2168
|
+
env: process.env,
|
|
2169
|
+
moduleUrl: import.meta.url,
|
|
2170
|
+
exists: (p7) => {
|
|
2171
|
+
try {
|
|
2172
|
+
return existsSync(p7);
|
|
2173
|
+
} catch {
|
|
2174
|
+
return false;
|
|
2175
|
+
}
|
|
2176
|
+
},
|
|
2177
|
+
stateRoot: () => detectPlatform().stateRoot,
|
|
2178
|
+
packageRoot: getPackageRoot(),
|
|
2179
|
+
version: package_default.version
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
function getAssetsRoot() {
|
|
2183
|
+
const r = computeAssetsRoot(realDeps());
|
|
2184
|
+
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
2185
|
+
warnedMissing = true;
|
|
2186
|
+
console.error(
|
|
2187
|
+
`warning: compiled harnessed binary but bundled assets are not unpacked at ${r.root} \u2014 asset-dependent commands (setup / run / prompt / install) will fail. Reinstall the binary, or use the npm distribution (npm i -g harnessed). (asset unpack pipeline lands in a later release \u2014 B1 seam)`
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2190
|
+
return r.root;
|
|
2191
|
+
}
|
|
2192
|
+
var BUNFS_MARKERS, warnedMissing;
|
|
2193
|
+
var init_assetsRoot = __esm({
|
|
2194
|
+
"src/cli/lib/assetsRoot.ts"() {
|
|
2195
|
+
init_package();
|
|
2196
|
+
init_platform();
|
|
2197
|
+
init_packagePath();
|
|
2198
|
+
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
2199
|
+
warnedMissing = false;
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2080
2202
|
function estimateTokens(s) {
|
|
2081
2203
|
return Math.ceil(Buffer.byteLength(s, "utf8") / 4);
|
|
2082
2204
|
}
|
|
@@ -2538,12 +2660,21 @@ function buildOrchestratorBody(name, prompt) {
|
|
|
2538
2660
|
``,
|
|
2539
2661
|
`## How to run (orchestrator \u2014 clarify in THIS session, then drive native subagent spawns)`,
|
|
2540
2662
|
``,
|
|
2663
|
+
// 4.22.0 (L1 anti-freestyle) — CC pre-executes this at prompt-assembly time
|
|
2664
|
+
// (before the model sees anything): registers the invocation intent so the
|
|
2665
|
+
// per-turn inject nags until steps 2-3 seed the ledger. The CLI is fail-soft
|
|
2666
|
+
// (silent exit 0 on any error) because CC's failing-pre-exec behavior is
|
|
2667
|
+
// undocumented.
|
|
2668
|
+
`!\`harnessed checkpoint intent ${name}\``,
|
|
2669
|
+
``,
|
|
2670
|
+
`> The banner above (when present) means this invocation is REGISTERED with the engine (an intent marker) \u2014 not yet compliant: steps 2-3 below seed the ledger, and a per-turn \`<workflow-intent>\` reminder persists until they run.`,
|
|
2671
|
+
``,
|
|
2541
2672
|
`harnessed is the orchestration brain: \`harnessed gates\` tells you which subs fire, \`harnessed prompt\` gives you each sub's spawn-ready prompt, and \`harnessed checkpoint\` records the per-sub state-machine ledger. YOU (the main session) do the spawning with CC-native Task / Agent tools \u2014 keeping the session responsive, enabling Agent Teams, and letting clarification round-trips reach the user.`,
|
|
2542
2673
|
``,
|
|
2543
2674
|
`Drive this exact sequence (it is the state machine \u2014 follow the file, don't improvise from memory):`,
|
|
2544
2675
|
``,
|
|
2545
2676
|
...autoDiscussStep,
|
|
2546
|
-
`2. Bash: \`harnessed gates ${name} --task "<locked spec>" --skip-sub clarify\` \u2192 parse the JSON \`{fire: [{sub, order, mode, is_master}], skip: [{sub, reason}], parallelism: {escalate_to_teams}}\`. This is the plan SoT (no spawn). Keep the verbatim JSON for the next step
|
|
2677
|
+
`2. Bash: \`harnessed gates ${name} --task "<locked spec>" --skip-sub clarify\` \u2192 parse the JSON \`{fire: [{sub, order, mode, is_master}], skip: [{sub, reason}], parallelism: {escalate_to_teams}}\`. This is the plan SoT (no spawn). Keep the verbatim JSON for the next step.${name === "auto" ? " For a small self-contained task (single-file / single-page class), the sanctioned lite path is adding `--skip-sub verify --skip-sub retro` (repeatable / comma-separated) \u2014 skipped subs are still recorded in the ledger with reasons; lite \u2260 freestyle (the ledger/evidence IS the difference)." : ""}`,
|
|
2547
2678
|
`3. Bash: \`harnessed checkpoint start ${name} --plan '<the verbatim gates JSON from step 2>'\` \u2192 seeds the sub-progress ledger in \`current-workflow.json\` (fired subs \u2192 \`pending\`, skipped subs \u2192 \`skipped\` + reason). This makes \`harnessed status --recover\` able to tell you where you are after compaction.`,
|
|
2548
2679
|
`4. If \`parallelism.escalate_to_teams === true\`: this stage needs multiple subagents to coordinate (SendMessage / shared contract). Read \`~/.claude/rules/agent-teams.md\`, then \`TeamCreate\` \u2192 \`Agent(name, team_name, ...)\` per fired sub (prompt from \`harnessed prompt <sub>\`) \u2192 coordinate via SendMessage \u2192 \`SendMessage shutdown_request\` + \`TeamDelete\`. Still checkpoint each sub (\`complete\` / \`fail\`) as below.`,
|
|
2549
2680
|
`5. Otherwise, for each fired sub in \`order\` (serial subs sequentially, parallel subs concurrently via parallel Task calls):`,
|
|
@@ -2576,6 +2707,13 @@ function buildExecutionBody(name, prompt) {
|
|
|
2576
2707
|
``,
|
|
2577
2708
|
`## How to run (execution \u2014 native subagent spawn)`,
|
|
2578
2709
|
``,
|
|
2710
|
+
// 4.22.0 T6 — same L1 anti-freestyle pre-exec as the orchestrator body:
|
|
2711
|
+
// registers a LEAF intent (absorbed by this sub's checkpoint complete/fail);
|
|
2712
|
+
// the per-turn inject nags while it is fresh and unresolved. Fail-soft CLI.
|
|
2713
|
+
`!\`harnessed checkpoint intent ${name}\``,
|
|
2714
|
+
``,
|
|
2715
|
+
`> The banner above (when present) means this invocation is REGISTERED with the engine (an intent marker) \u2014 not yet compliant: the steps below (prompt \u2192 spawn \u2192 checkpoint complete) resolve it, and a per-turn \`<workflow-intent>\` reminder persists until they run.`,
|
|
2716
|
+
``,
|
|
2579
2717
|
`harnessed gives you the spawn-ready prompt; YOU spawn the subagent with a CC-native Task / Agent tool (keeps the session responsive + lets clarification round-trips reach the user).`,
|
|
2580
2718
|
``,
|
|
2581
2719
|
...spawnLoopSteps("").map(
|
|
@@ -2627,7 +2765,7 @@ function nameToYamlHintPath(name) {
|
|
|
2627
2765
|
function shouldOverwriteFile(content) {
|
|
2628
2766
|
return HARNESSED_MARKER_RX.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
|
|
2629
2767
|
}
|
|
2630
|
-
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync,
|
|
2768
|
+
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync16 = (p7) => readFileSync(p7, "utf8")) {
|
|
2631
2769
|
const results = [];
|
|
2632
2770
|
const aggregatedWarnings = /* @__PURE__ */ new Set();
|
|
2633
2771
|
for (const name of slashNames) {
|
|
@@ -2646,7 +2784,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
|
|
|
2646
2784
|
if (fileExists2(path)) {
|
|
2647
2785
|
let existing = "";
|
|
2648
2786
|
try {
|
|
2649
|
-
existing =
|
|
2787
|
+
existing = readFileSync16(path);
|
|
2650
2788
|
} catch {
|
|
2651
2789
|
existing = "";
|
|
2652
2790
|
}
|
|
@@ -3852,87 +3990,6 @@ This applies to: strategic-layer review skip / phase-layer clarification skip /
|
|
|
3852
3990
|
};
|
|
3853
3991
|
}
|
|
3854
3992
|
});
|
|
3855
|
-
function getPackageRoot() {
|
|
3856
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
3857
|
-
const thisDir = dirname(thisFile);
|
|
3858
|
-
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
3859
|
-
return resolve(thisDir, "..");
|
|
3860
|
-
}
|
|
3861
|
-
return resolve(thisDir, "..", "..", "..");
|
|
3862
|
-
}
|
|
3863
|
-
var init_packagePath = __esm({
|
|
3864
|
-
"src/cli/lib/packagePath.ts"() {
|
|
3865
|
-
}
|
|
3866
|
-
});
|
|
3867
|
-
|
|
3868
|
-
// src/cli/lib/assetsRoot.ts
|
|
3869
|
-
var assetsRoot_exports = {};
|
|
3870
|
-
__export(assetsRoot_exports, {
|
|
3871
|
-
compiledAssetsDir: () => compiledAssetsDir,
|
|
3872
|
-
computeAssetsRoot: () => computeAssetsRoot,
|
|
3873
|
-
getAssetsRoot: () => getAssetsRoot,
|
|
3874
|
-
isCompiledModuleUrl: () => isCompiledModuleUrl
|
|
3875
|
-
});
|
|
3876
|
-
function isCompiledModuleUrl(url) {
|
|
3877
|
-
let s = url;
|
|
3878
|
-
try {
|
|
3879
|
-
s = decodeURIComponent(url);
|
|
3880
|
-
} catch {
|
|
3881
|
-
}
|
|
3882
|
-
const normalized = s.replace(/\\/g, "/").toLowerCase();
|
|
3883
|
-
return BUNFS_MARKERS.some((m) => normalized.includes(m));
|
|
3884
|
-
}
|
|
3885
|
-
function computeAssetsRoot(d) {
|
|
3886
|
-
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
3887
|
-
if (override && override.trim().length > 0) {
|
|
3888
|
-
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
3889
|
-
}
|
|
3890
|
-
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
3891
|
-
const root = join(d.stateRoot(), "assets", d.version);
|
|
3892
|
-
const present = d.exists(join(root, "workflows"));
|
|
3893
|
-
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
3894
|
-
}
|
|
3895
|
-
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
3896
|
-
}
|
|
3897
|
-
function compiledAssetsDir(version) {
|
|
3898
|
-
return join(detectPlatform().stateRoot, "assets", version);
|
|
3899
|
-
}
|
|
3900
|
-
function realDeps() {
|
|
3901
|
-
return {
|
|
3902
|
-
env: process.env,
|
|
3903
|
-
moduleUrl: import.meta.url,
|
|
3904
|
-
exists: (p7) => {
|
|
3905
|
-
try {
|
|
3906
|
-
return existsSync(p7);
|
|
3907
|
-
} catch {
|
|
3908
|
-
return false;
|
|
3909
|
-
}
|
|
3910
|
-
},
|
|
3911
|
-
stateRoot: () => detectPlatform().stateRoot,
|
|
3912
|
-
packageRoot: getPackageRoot(),
|
|
3913
|
-
version: package_default.version
|
|
3914
|
-
};
|
|
3915
|
-
}
|
|
3916
|
-
function getAssetsRoot() {
|
|
3917
|
-
const r = computeAssetsRoot(realDeps());
|
|
3918
|
-
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
3919
|
-
warnedMissing = true;
|
|
3920
|
-
console.error(
|
|
3921
|
-
`warning: compiled harnessed binary but bundled assets are not unpacked at ${r.root} \u2014 asset-dependent commands (setup / run / prompt / install) will fail. Reinstall the binary, or use the npm distribution (npm i -g harnessed). (asset unpack pipeline lands in a later release \u2014 B1 seam)`
|
|
3922
|
-
);
|
|
3923
|
-
}
|
|
3924
|
-
return r.root;
|
|
3925
|
-
}
|
|
3926
|
-
var BUNFS_MARKERS, warnedMissing;
|
|
3927
|
-
var init_assetsRoot = __esm({
|
|
3928
|
-
"src/cli/lib/assetsRoot.ts"() {
|
|
3929
|
-
init_package();
|
|
3930
|
-
init_platform();
|
|
3931
|
-
init_packagePath();
|
|
3932
|
-
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
3933
|
-
warnedMissing = false;
|
|
3934
|
-
}
|
|
3935
|
-
});
|
|
3936
3993
|
async function loadUserOverrides(packageRoot) {
|
|
3937
3994
|
const yamlPath = resolve(packageRoot, "workflows", "judgments", "user-overrides.yaml");
|
|
3938
3995
|
let raw;
|
|
@@ -4656,7 +4713,7 @@ function compute(d) {
|
|
|
4656
4713
|
const gitFirst = d.where("git")[0];
|
|
4657
4714
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4658
4715
|
const root = dirname8(dirname8(gitFirst));
|
|
4659
|
-
for (const cand of [
|
|
4716
|
+
for (const cand of [join19(root, "bin", "bash.exe"), join19(root, "usr", "bin", "bash.exe")]) {
|
|
4660
4717
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4661
4718
|
}
|
|
4662
4719
|
}
|
|
@@ -4664,13 +4721,13 @@ function compute(d) {
|
|
|
4664
4721
|
d.env.ProgramFiles,
|
|
4665
4722
|
d.env.ProgramW6432,
|
|
4666
4723
|
d.env["ProgramFiles(x86)"],
|
|
4667
|
-
d.env.LOCALAPPDATA ?
|
|
4724
|
+
d.env.LOCALAPPDATA ? join19(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4668
4725
|
];
|
|
4669
4726
|
for (const base of bases) {
|
|
4670
4727
|
if (!base) continue;
|
|
4671
4728
|
for (const cand of [
|
|
4672
|
-
|
|
4673
|
-
|
|
4729
|
+
join19(base, "Git", "bin", "bash.exe"),
|
|
4730
|
+
join19(base, "Git", "usr", "bin", "bash.exe")
|
|
4674
4731
|
]) {
|
|
4675
4732
|
if (d.exists(cand) && usable(cand))
|
|
4676
4733
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4683,10 +4740,10 @@ function compute(d) {
|
|
|
4683
4740
|
}
|
|
4684
4741
|
return { path: "bash", source: "path-fallback" };
|
|
4685
4742
|
}
|
|
4686
|
-
var dirname8,
|
|
4743
|
+
var dirname8, join19, WSL_STUB_RE, cache2;
|
|
4687
4744
|
var init_resolveBash = __esm({
|
|
4688
4745
|
"src/installers/lib/resolveBash.ts"() {
|
|
4689
|
-
({ dirname: dirname8, join:
|
|
4746
|
+
({ dirname: dirname8, join: join19 } = win32);
|
|
4690
4747
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4691
4748
|
cache2 = null;
|
|
4692
4749
|
}
|
|
@@ -5459,14 +5516,14 @@ __export(version_check_exports, {
|
|
|
5459
5516
|
compareVersions: () => compareVersions,
|
|
5460
5517
|
fetchLatestVersion: () => fetchLatestVersion
|
|
5461
5518
|
});
|
|
5462
|
-
function
|
|
5519
|
+
function parse3(v) {
|
|
5463
5520
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(v.trim());
|
|
5464
5521
|
if (!m) return null;
|
|
5465
5522
|
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
5466
5523
|
}
|
|
5467
5524
|
function compareVersions(installed, latest) {
|
|
5468
|
-
const a =
|
|
5469
|
-
const b =
|
|
5525
|
+
const a = parse3(installed);
|
|
5526
|
+
const b = parse3(latest);
|
|
5470
5527
|
if (!a || !b) return "unknown";
|
|
5471
5528
|
for (let i = 0; i < 3; i++) {
|
|
5472
5529
|
const ai = a.nums[i] ?? 0;
|
|
@@ -7712,6 +7769,196 @@ var init_nextStep = __esm({
|
|
|
7712
7769
|
}
|
|
7713
7770
|
});
|
|
7714
7771
|
|
|
7772
|
+
// src/checkpoint/injectState.ts
|
|
7773
|
+
var injectState_exports = {};
|
|
7774
|
+
__export(injectState_exports, {
|
|
7775
|
+
DEFAULT_INJECT_BUDGET: () => DEFAULT_INJECT_BUDGET,
|
|
7776
|
+
INTENT_TTL_MS: () => INTENT_TTL_MS,
|
|
7777
|
+
buildInjection: () => buildInjection,
|
|
7778
|
+
buildIntentBlock: () => buildIntentBlock,
|
|
7779
|
+
buildProjectContextBlock: () => buildProjectContextBlock,
|
|
7780
|
+
buildWorkflowStateBlock: () => buildWorkflowStateBlock,
|
|
7781
|
+
filterRelevantLearnings: () => filterRelevantLearnings,
|
|
7782
|
+
findPhaseContextExcerpt: () => findPhaseContextExcerpt,
|
|
7783
|
+
formatIntentAge: () => formatIntentAge,
|
|
7784
|
+
parseLearnings: () => parseLearnings,
|
|
7785
|
+
selectWithinBudget: () => selectWithinBudget
|
|
7786
|
+
});
|
|
7787
|
+
function formatIntentAge(ms) {
|
|
7788
|
+
const m = Math.floor(ms / 6e4);
|
|
7789
|
+
if (m < 1) return "<1m";
|
|
7790
|
+
if (m < 60) return `${m}m`;
|
|
7791
|
+
return `${Math.floor(m / 60)}h`;
|
|
7792
|
+
}
|
|
7793
|
+
function buildIntentBlock(intent, nowMs) {
|
|
7794
|
+
if (!intent) return "";
|
|
7795
|
+
const born = Date.parse(intent.ts);
|
|
7796
|
+
if (Number.isNaN(born)) return "";
|
|
7797
|
+
const age = nowMs - born;
|
|
7798
|
+
if (age < 0 || age > INTENT_TTL_MS) return "";
|
|
7799
|
+
const m = intent.master;
|
|
7800
|
+
if (intent.kind === "leaf") {
|
|
7801
|
+
return [
|
|
7802
|
+
"<workflow-intent>",
|
|
7803
|
+
`intent: /${m} invoked ${formatIntentAge(age)} ago \u2014 sub NOT checkpointed`,
|
|
7804
|
+
`ENGINE: /${m} is registered but not engaged \u2014 freestyle risk. Run: \`harnessed prompt ${m} --task "<spec>" --json\` \u2192 spawn per SOP \u2192 \`harnessed checkpoint complete ${m}\` (or \`harnessed checkpoint fail ${m}\`).`,
|
|
7805
|
+
"</workflow-intent>"
|
|
7806
|
+
].join("\n");
|
|
7807
|
+
}
|
|
7808
|
+
return [
|
|
7809
|
+
"<workflow-intent>",
|
|
7810
|
+
`intent: /${m} invoked ${formatIntentAge(age)} ago \u2014 ledger NOT seeded`,
|
|
7811
|
+
`ENGINE: /${m} is registered but not engaged \u2014 freestyle risk. Run: \`harnessed gates ${m} --task "<locked spec>"\` \u2192 \`harnessed checkpoint start ${m} --plan '<gates JSON>'\`; then drive each sub via \`harnessed prompt\` / \`harnessed checkpoint complete|fail\`.`,
|
|
7812
|
+
"</workflow-intent>"
|
|
7813
|
+
].join("\n");
|
|
7814
|
+
}
|
|
7815
|
+
function buildWorkflowStateBlock(wf, forward) {
|
|
7816
|
+
if (!wf) return "";
|
|
7817
|
+
const ledger = wf.sub_progress ?? [];
|
|
7818
|
+
const next = nextPending(ledger);
|
|
7819
|
+
const loops = detectLoop(ledger);
|
|
7820
|
+
const lines = [
|
|
7821
|
+
"<workflow-state>",
|
|
7822
|
+
`phase: ${wf.phase}`,
|
|
7823
|
+
`status: ${wf.status}`,
|
|
7824
|
+
next ? `next: ${next}` : "next: (none \u2014 all subs resolved)"
|
|
7825
|
+
];
|
|
7826
|
+
if (next) {
|
|
7827
|
+
lines.push(
|
|
7828
|
+
`ENGINE: mid state-machine \u2014 drive sub '${next}' via \`harnessed prompt ${next}\` \u2192 spawn \u2192 \`harnessed checkpoint complete/fail\`. Do NOT freestyle the orchestration or skip the ledger; run \`harnessed status --recover\` if unsure where you are.`
|
|
7829
|
+
);
|
|
7830
|
+
}
|
|
7831
|
+
if (!next && forward && (forward.unit.kind === "phase" || forward.unit.kind === "task")) {
|
|
7832
|
+
const n = forward.remainingPhases;
|
|
7833
|
+
lines.push(
|
|
7834
|
+
`NEXT-UNIT: current workflow complete \u2192 next is ${describeUnit(forward.unit)} (run /auto or \`harnessed advance\`); ${n} phase${n === 1 ? "" : "s"} remain`
|
|
7835
|
+
);
|
|
7836
|
+
}
|
|
7837
|
+
for (const l of loops) {
|
|
7838
|
+
lines.push(
|
|
7839
|
+
`BREAK-LOOP: sub '${l.sub}' failed ${l.count}x \u2014 stop retrying, run break-loop skill`
|
|
7840
|
+
);
|
|
7841
|
+
}
|
|
7842
|
+
if (wf.ship_ready) {
|
|
7843
|
+
lines.push(
|
|
7844
|
+
`SHIP-READY: ${wf.ship_commits ?? 0} commit(s) since the last release tag \u2014 consider shipping (harnessed release-preflight, then /ship)`
|
|
7845
|
+
);
|
|
7846
|
+
}
|
|
7847
|
+
if (wf.retro_due) {
|
|
7848
|
+
lines.push(
|
|
7849
|
+
"RETRO-DUE: enough phases completed since the last retro \u2014 run /retro, then `harnessed retro --done`"
|
|
7850
|
+
);
|
|
7851
|
+
}
|
|
7852
|
+
if (wf.verify_mode === "full") {
|
|
7853
|
+
lines.push(
|
|
7854
|
+
"VERIFY-MODE: full \u2014 run full verification (large/risky change: >5 files / >4 subs / >3 reqs)"
|
|
7855
|
+
);
|
|
7856
|
+
} else if (wf.verify_mode === "light") {
|
|
7857
|
+
lines.push("VERIFY-MODE: light \u2014 scope verification to the changed surface (small change)");
|
|
7858
|
+
}
|
|
7859
|
+
lines.push("</workflow-state>");
|
|
7860
|
+
return lines.join("\n");
|
|
7861
|
+
}
|
|
7862
|
+
function parseLearnings(md) {
|
|
7863
|
+
const blocks = md.split(/^### /m).slice(1);
|
|
7864
|
+
return blocks.map((b) => {
|
|
7865
|
+
const raw = `### ${b}`.trimEnd();
|
|
7866
|
+
const phase = /phase (\S+)/.exec(b)?.[1] ?? "";
|
|
7867
|
+
const subs = [];
|
|
7868
|
+
for (const m of b.matchAll(/^- (?:looped|rejected|failed): (\S+)/gm)) {
|
|
7869
|
+
if (m[1]) subs.push(m[1]);
|
|
7870
|
+
}
|
|
7871
|
+
return { raw, phase, subs };
|
|
7872
|
+
});
|
|
7873
|
+
}
|
|
7874
|
+
function filterRelevantLearnings(entries, ctx) {
|
|
7875
|
+
const rel = entries.filter(
|
|
7876
|
+
(e) => e.phase === ctx.phase || e.subs.some((s) => ctx.ledgerSubs.includes(s))
|
|
7877
|
+
);
|
|
7878
|
+
const ordered = [...rel].reverse();
|
|
7879
|
+
if (ordered.length === 0) {
|
|
7880
|
+
const last = entries[entries.length - 1];
|
|
7881
|
+
return last ? [last] : [];
|
|
7882
|
+
}
|
|
7883
|
+
return ordered;
|
|
7884
|
+
}
|
|
7885
|
+
function selectWithinBudget(entries, budget) {
|
|
7886
|
+
const out = [];
|
|
7887
|
+
let acc = 0;
|
|
7888
|
+
for (const e of entries) {
|
|
7889
|
+
const cost = tok(e.raw);
|
|
7890
|
+
if (acc + cost > budget) break;
|
|
7891
|
+
acc += cost;
|
|
7892
|
+
out.push(e);
|
|
7893
|
+
}
|
|
7894
|
+
return out;
|
|
7895
|
+
}
|
|
7896
|
+
function buildProjectContextBlock(input) {
|
|
7897
|
+
const parts = [];
|
|
7898
|
+
for (const l of input.learnings) parts.push(l.raw.trim());
|
|
7899
|
+
if (input.contextExcerpt) parts.push(input.contextExcerpt.trim());
|
|
7900
|
+
if (parts.length === 0) return "";
|
|
7901
|
+
return ["<project-context>", ...parts, "</project-context>"].join("\n");
|
|
7902
|
+
}
|
|
7903
|
+
function findPhaseContextExcerpt(repoRoot, phase, budget) {
|
|
7904
|
+
try {
|
|
7905
|
+
const phasesDir = join(repoRoot, ".planning", "phases");
|
|
7906
|
+
if (!existsSync(phasesDir)) return null;
|
|
7907
|
+
for (const dir of readdirSync(phasesDir)) {
|
|
7908
|
+
const num = /^(\d+)/.exec(dir)?.[1];
|
|
7909
|
+
if (!num || !phase.includes(num)) continue;
|
|
7910
|
+
const ctxFile = join(phasesDir, dir, `${num}-CONTEXT.md`);
|
|
7911
|
+
if (!existsSync(ctxFile)) continue;
|
|
7912
|
+
const body = readFileSync(ctxFile, "utf8");
|
|
7913
|
+
const goalIdx = body.indexOf("## Goal");
|
|
7914
|
+
const slice = goalIdx >= 0 ? body.slice(goalIdx) : body;
|
|
7915
|
+
const next = slice.indexOf("\n## ", 1);
|
|
7916
|
+
const excerpt = (next > 0 ? slice.slice(0, next) : slice).trim();
|
|
7917
|
+
return excerpt.length > budget * 4 ? excerpt.slice(0, budget * 4) : excerpt;
|
|
7918
|
+
}
|
|
7919
|
+
} catch {
|
|
7920
|
+
}
|
|
7921
|
+
return null;
|
|
7922
|
+
}
|
|
7923
|
+
function buildInjection(repoRoot, wf, learningsMd, budget = DEFAULT_INJECT_BUDGET, intent = null, nowMs = Date.now()) {
|
|
7924
|
+
const ledgerEmpty = (wf?.sub_progress ?? []).length === 0;
|
|
7925
|
+
const intentBlock = ledgerEmpty ? buildIntentBlock(intent, nowMs) : "";
|
|
7926
|
+
if (!wf) return intentBlock;
|
|
7927
|
+
const forward = nextPending(wf.sub_progress ?? []) === null ? forwardPointer(repoRoot, wf) : null;
|
|
7928
|
+
const ws = buildWorkflowStateBlock(wf, forward);
|
|
7929
|
+
const ledgerSubs = (wf.sub_progress ?? []).map((e) => e.sub);
|
|
7930
|
+
const rel = selectWithinBudget(
|
|
7931
|
+
filterRelevantLearnings(parseLearnings(learningsMd), { phase: wf.phase, ledgerSubs }),
|
|
7932
|
+
budget
|
|
7933
|
+
);
|
|
7934
|
+
const usedTokens = rel.reduce((a, e) => a + tok(e.raw), 0);
|
|
7935
|
+
const ctx = findPhaseContextExcerpt(repoRoot, wf.phase, Math.max(0, budget - usedTokens));
|
|
7936
|
+
const pc2 = buildProjectContextBlock({ learnings: rel, contextExcerpt: ctx ?? void 0 });
|
|
7937
|
+
const normal = pc2 ? `${ws}
|
|
7938
|
+
${pc2}` : ws;
|
|
7939
|
+
return intentBlock ? `${intentBlock}
|
|
7940
|
+
${normal}` : normal;
|
|
7941
|
+
}
|
|
7942
|
+
function forwardPointer(repoRoot, wf) {
|
|
7943
|
+
const snapshot = scanPlanning({ repoRoot, currentWorkflow: wf, includeTasks: false });
|
|
7944
|
+
const unit = deriveNext(snapshot);
|
|
7945
|
+
if (unit.kind !== "phase" && unit.kind !== "task") return null;
|
|
7946
|
+
return { unit, remainingPhases: snapshot.phases.filter((p7) => !p7.complete).length };
|
|
7947
|
+
}
|
|
7948
|
+
var INTENT_TTL_MS, DEFAULT_INJECT_BUDGET, tok;
|
|
7949
|
+
var init_injectState = __esm({
|
|
7950
|
+
"src/checkpoint/injectState.ts"() {
|
|
7951
|
+
init_breakLoop();
|
|
7952
|
+
init_deriveNext();
|
|
7953
|
+
init_forwardStep();
|
|
7954
|
+
init_ledger();
|
|
7955
|
+
init_planningScan();
|
|
7956
|
+
INTENT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
7957
|
+
DEFAULT_INJECT_BUDGET = 1500;
|
|
7958
|
+
tok = (s) => Math.ceil(Buffer.byteLength(s, "utf8") / 4);
|
|
7959
|
+
}
|
|
7960
|
+
});
|
|
7961
|
+
|
|
7715
7962
|
// src/cli/lib/release-preflight.ts
|
|
7716
7963
|
var release_preflight_exports = {};
|
|
7717
7964
|
__export(release_preflight_exports, {
|
|
@@ -8563,7 +8810,7 @@ function registerBackupList(program2) {
|
|
|
8563
8810
|
// src/cli/checkpoint.ts
|
|
8564
8811
|
init_path_guard();
|
|
8565
8812
|
init_ledger();
|
|
8566
|
-
var ACTIONS = ["start", "complete", "fail"];
|
|
8813
|
+
var ACTIONS = ["start", "complete", "fail", "intent"];
|
|
8567
8814
|
function isAction(a) {
|
|
8568
8815
|
return ACTIONS.includes(a);
|
|
8569
8816
|
}
|
|
@@ -8590,9 +8837,24 @@ async function parsePlan(raw) {
|
|
|
8590
8837
|
}
|
|
8591
8838
|
return plan;
|
|
8592
8839
|
}
|
|
8840
|
+
async function absorbIntentFor(sub) {
|
|
8841
|
+
try {
|
|
8842
|
+
const { mutateStore: mutateStore2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8843
|
+
const { activeKey: activeKey2, repoKey: repoKey2 } = await Promise.resolve().then(() => (init_workflowStore(), workflowStore_exports));
|
|
8844
|
+
await mutateStore2((store) => {
|
|
8845
|
+
if (!store.intents) return store;
|
|
8846
|
+
const intents = { ...store.intents };
|
|
8847
|
+
for (const k of [activeKey2(), repoKey2()]) {
|
|
8848
|
+
if (intents[k]?.master === sub) delete intents[k];
|
|
8849
|
+
}
|
|
8850
|
+
return { ...store, intents };
|
|
8851
|
+
});
|
|
8852
|
+
} catch {
|
|
8853
|
+
}
|
|
8854
|
+
}
|
|
8593
8855
|
function registerCheckpoint(program2) {
|
|
8594
8856
|
program2.command("checkpoint <action> <sub>").description(
|
|
8595
|
-
"Record workflow progress: start | complete | fail <sub-workflow> (writes to ~/.claude/harnessed/checkpoints/)"
|
|
8857
|
+
"Record workflow progress: intent | start | complete | fail <sub-workflow> (writes to ~/.claude/harnessed/checkpoints/)"
|
|
8596
8858
|
).option("--summary <text>", "short summary stored as the checkpoint lastTask").option("--plan <json>", "gates plan JSON (start only) \u2014 seeds the sub-progress ledger").option(
|
|
8597
8859
|
"--force",
|
|
8598
8860
|
"complete only \u2014 override a missing-artifact evidence block (records overridden)"
|
|
@@ -8608,6 +8870,30 @@ function registerCheckpoint(program2) {
|
|
|
8608
8870
|
process.exit(1);
|
|
8609
8871
|
return;
|
|
8610
8872
|
}
|
|
8873
|
+
if (action === "intent") {
|
|
8874
|
+
try {
|
|
8875
|
+
checkPathSafe(sub);
|
|
8876
|
+
const { mutateStore: mutateStore2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8877
|
+
const { activeKey: activeKey2 } = await Promise.resolve().then(() => (init_workflowStore(), workflowStore_exports));
|
|
8878
|
+
const { classifyIntentKind: classifyIntentKind2 } = await Promise.resolve().then(() => (init_intentKind(), intentKind_exports));
|
|
8879
|
+
const { getAssetsRoot: getAssetsRoot2 } = await Promise.resolve().then(() => (init_assetsRoot(), assetsRoot_exports));
|
|
8880
|
+
const kind = classifyIntentKind2(sub, getAssetsRoot2());
|
|
8881
|
+
const key = activeKey2();
|
|
8882
|
+
await mutateStore2((store) => ({
|
|
8883
|
+
...store,
|
|
8884
|
+
intents: {
|
|
8885
|
+
...store.intents ?? {},
|
|
8886
|
+
[key]: { master: sub, ts: (/* @__PURE__ */ new Date()).toISOString(), kind }
|
|
8887
|
+
}
|
|
8888
|
+
}));
|
|
8889
|
+
console.log(
|
|
8890
|
+
kind === "master" ? `[harnessed] engine engaged: /${sub} invoked \u2014 intent registered, ledger awaiting plan. Next: \`harnessed gates ${sub} --task "<locked spec>"\` \u2192 \`harnessed checkpoint start ${sub} --plan '<gates JSON>'\`. Freestyling past this point bypasses the ledger, evidence guard, and recovery.` : `[harnessed] engine engaged: /${sub} invoked \u2014 intent registered, sub not yet checkpointed. Next: \`harnessed prompt ${sub} --task "<spec>" --json\` \u2192 spawn per SOP \u2192 \`harnessed checkpoint complete ${sub}\` (or \`fail\`). Freestyling past this point bypasses the ledger, evidence guard, and recovery.`
|
|
8891
|
+
);
|
|
8892
|
+
} catch {
|
|
8893
|
+
}
|
|
8894
|
+
process.exit(0);
|
|
8895
|
+
return;
|
|
8896
|
+
}
|
|
8611
8897
|
try {
|
|
8612
8898
|
checkPathSafe(sub);
|
|
8613
8899
|
} catch {
|
|
@@ -8624,6 +8910,18 @@ function registerCheckpoint(program2) {
|
|
|
8624
8910
|
const { mutateSubProgress: mutateSubProgress3 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8625
8911
|
await mutateSubProgress3(() => seedLedger2(plan));
|
|
8626
8912
|
}
|
|
8913
|
+
try {
|
|
8914
|
+
const { mutateStore: mutateStore2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8915
|
+
const { activeKey: activeKey2, repoKey: repoKey2 } = await Promise.resolve().then(() => (init_workflowStore(), workflowStore_exports));
|
|
8916
|
+
await mutateStore2((store) => {
|
|
8917
|
+
if (!store.intents) return store;
|
|
8918
|
+
const intents = { ...store.intents };
|
|
8919
|
+
delete intents[activeKey2()];
|
|
8920
|
+
delete intents[repoKey2()];
|
|
8921
|
+
return { ...store, intents };
|
|
8922
|
+
});
|
|
8923
|
+
} catch {
|
|
8924
|
+
}
|
|
8627
8925
|
console.log(`[harnessed] checkpoint started: ${sub} \u2192 ${checkpointPath}`);
|
|
8628
8926
|
process.exit(0);
|
|
8629
8927
|
return;
|
|
@@ -8653,6 +8951,7 @@ function registerCheckpoint(program2) {
|
|
|
8653
8951
|
else evidenceStatus = "none_declared";
|
|
8654
8952
|
const markOpts = evidenceStatus === "none_declared" ? { evidence_status: evidenceStatus } : { evidence: result.found, evidence_status: evidenceStatus };
|
|
8655
8953
|
await mutateSubProgress3((e) => markIfSeeded(e, sub, "done", markOpts));
|
|
8954
|
+
await absorbIntentFor(sub);
|
|
8656
8955
|
const { collectScaleMetrics: collectScaleMetrics2, assessScale: assessScale2 } = await Promise.resolve().then(() => (init_scale(), scale_exports));
|
|
8657
8956
|
const { readCurrentWorkflow: readCurrentWorkflow3, writeCurrentWorkflow: writeCurrentWorkflow2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8658
8957
|
const afterMark = await readCurrentWorkflow3();
|
|
@@ -8719,6 +9018,7 @@ function registerCheckpoint(program2) {
|
|
|
8719
9018
|
}
|
|
8720
9019
|
const { mutateSubProgress: mutateSubProgress2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8721
9020
|
await mutateSubProgress2((e) => markIfSeeded(e, sub, "failed"));
|
|
9021
|
+
await absorbIntentFor(sub);
|
|
8722
9022
|
await completePhase2({
|
|
8723
9023
|
phaseId: sub,
|
|
8724
9024
|
status: "complete",
|
|
@@ -8808,7 +9108,12 @@ function resolveMasterYamlPath2(master, packageRoot) {
|
|
|
8808
9108
|
function registerGates(program2) {
|
|
8809
9109
|
program2.command("gates").description(
|
|
8810
9110
|
"Evaluate which sub-workflows fire for a master orchestrator (JSON plan, no spawn)."
|
|
8811
|
-
).argument("<master>", "master name: auto | discuss | plan | task | verify").option("--task <text>", "task description (injected as gateContext.task)").option(
|
|
9111
|
+
).argument("<master>", "master name: auto | discuss | plan | task | verify").option("--task <text>", "task description (injected as gateContext.task)").option(
|
|
9112
|
+
"--skip-sub <names>",
|
|
9113
|
+
"sub names to skip without gate eval (repeatable and/or comma-separated)",
|
|
9114
|
+
(v, prev) => [...prev, v],
|
|
9115
|
+
[]
|
|
9116
|
+
).option("--context <json>", "JSON object merged over the default gate context").action(async (master, raw) => {
|
|
8812
9117
|
if (!VALID_MASTERS.has(master)) {
|
|
8813
9118
|
console.error(
|
|
8814
9119
|
`error: unknown master '${master}'. Expected one of: auto, discuss, plan, task, verify.`
|
|
@@ -8867,7 +9172,7 @@ function registerGates(program2) {
|
|
|
8867
9172
|
}
|
|
8868
9173
|
}
|
|
8869
9174
|
const skipSubs = new Set(
|
|
8870
|
-
|
|
9175
|
+
(Array.isArray(raw.skipSub) ? raw.skipSub : []).flatMap((v) => v.split(",")).map((s) => s.trim()).filter((s) => s.length > 0)
|
|
8871
9176
|
);
|
|
8872
9177
|
ctx.skip_subs = [...skipSubs];
|
|
8873
9178
|
const fire = [];
|
|
@@ -9155,8 +9460,14 @@ function evidenceLabel(entry) {
|
|
|
9155
9460
|
return "evidence: none_declared";
|
|
9156
9461
|
}
|
|
9157
9462
|
}
|
|
9158
|
-
async function buildRecoverLines(workflow, ledger) {
|
|
9463
|
+
async function buildRecoverLines(workflow, ledger, intent) {
|
|
9159
9464
|
const lines = [];
|
|
9465
|
+
if (intent) {
|
|
9466
|
+
const { formatIntentAge: formatIntentAge2 } = await Promise.resolve().then(() => (init_injectState(), injectState_exports));
|
|
9467
|
+
lines.push(
|
|
9468
|
+
`\u26A0 intent pending: /${intent.master} invoked ${formatIntentAge2(intent.ageMs)} ago \u2014 ledger not seeded; run \`harnessed gates ${intent.master}\` \u2192 \`harnessed checkpoint start ${intent.master} --plan '<gates JSON>'\``
|
|
9469
|
+
);
|
|
9470
|
+
}
|
|
9160
9471
|
if (!workflow || ledger.length === 0) {
|
|
9161
9472
|
lines.push("no ledger \u2014 run gates + start");
|
|
9162
9473
|
return lines;
|
|
@@ -9194,7 +9505,22 @@ function registerStatus(program2) {
|
|
|
9194
9505
|
if (opts.recover) {
|
|
9195
9506
|
const wf = await readCurrentWorkflow();
|
|
9196
9507
|
const ledger = wf?.sub_progress ?? [];
|
|
9197
|
-
|
|
9508
|
+
let intent = null;
|
|
9509
|
+
if (ledger.length === 0) {
|
|
9510
|
+
try {
|
|
9511
|
+
const { readIntent: readIntent2 } = await Promise.resolve().then(() => (init_workflowStore(), workflowStore_exports));
|
|
9512
|
+
const { INTENT_TTL_MS: INTENT_TTL_MS2 } = await Promise.resolve().then(() => (init_injectState(), injectState_exports));
|
|
9513
|
+
const raw = await readIntent2();
|
|
9514
|
+
if (raw) {
|
|
9515
|
+
const age = Date.now() - Date.parse(raw.ts);
|
|
9516
|
+
if (!Number.isNaN(age) && age >= 0 && age <= INTENT_TTL_MS2) {
|
|
9517
|
+
intent = { master: raw.master, ageMs: age };
|
|
9518
|
+
}
|
|
9519
|
+
}
|
|
9520
|
+
} catch {
|
|
9521
|
+
}
|
|
9522
|
+
}
|
|
9523
|
+
const lines = await buildRecoverLines(wf, ledger, intent);
|
|
9198
9524
|
for (const l of lines) console.log(l);
|
|
9199
9525
|
return;
|
|
9200
9526
|
}
|