harnessed 4.20.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 +473 -118
- 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 +7 -2
- package/workflows/auto/SKILL.zh-Hans.md +7 -2
- package/workflows/discuss/auto/SKILL.md +5 -1
- package/workflows/discuss/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/role-prompts.yaml +5 -3
- package/workflows/role-prompts.zh-Hans.yaml +5 -3
- 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 +5 -1
- package/workflows/task/code/SKILL.zh-Hans.md +5 -1
- 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
|
}
|
|
@@ -2495,13 +2617,17 @@ function buildInteractiveBody(name, prompt) {
|
|
|
2495
2617
|
``,
|
|
2496
2618
|
`Clarification requires real user dialogue. Spawned subagents cannot ask the user questions, so run this stage directly in this session \u2014 do NOT spawn it.`,
|
|
2497
2619
|
``,
|
|
2620
|
+
// v4.21.0 (KidsTetris dogfood) — bootstrap step + GSD-standard phase-dir
|
|
2621
|
+
// convention: the loose \`.planning/\` wording let agents invent their own
|
|
2622
|
+
// layout (phase-0-discuss/ etc.) on fresh projects with no ROADMAP.
|
|
2623
|
+
`0. New-project bootstrap \u2014 if \`.planning/ROADMAP.md\` does not exist: invoke \`/gsd-new-project\` when available; otherwise create a minimal \`ROADMAP.md\` (one table row per phase), \`STATE.md\` (digest, <100 lines), and \`REQUIREMENTS.md\` (numbered acceptance criteria) before continuing.`,
|
|
2498
2624
|
`1. Evaluate the clarification criteria for "$ARGUMENTS":`,
|
|
2499
2625
|
` - Strategic layer: new feature / new milestone / unclear business scope \u2192 run gstack \`/office-hours\` + \`/plan-ceo-review\``,
|
|
2500
2626
|
` - Phase layer: \u22652 open implementation decisions / unclear cross-phase API contract \u2192 run GSD \`/gsd-discuss-phase\``,
|
|
2501
2627
|
` - Subtask layer: \u22652 distinct approaches / core algorithm / API contract design / high error cost \u2192 run superpowers brainstorming`,
|
|
2502
2628
|
`2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions). Lock every open decision.`,
|
|
2503
2629
|
`3. Skip layers that don't fire \u2014 state which were skipped and why (transparent skip).`,
|
|
2504
|
-
`4. Persist locked decisions to \`.planning
|
|
2630
|
+
`4. Persist locked decisions to \`.planning/phases/<NN>-<slug>/\` via planning-with-files (\`findings.md\` / \`task_plan.md\`; NN = two-digit, one above the highest existing phase dir; slug = kebab-case short name).`,
|
|
2505
2631
|
``,
|
|
2506
2632
|
`Output: a locked spec the execution stages can consume without further user input. Then run \`/plan\` \u2192 \`/task\` \u2192 \`/verify\` with that spec.`,
|
|
2507
2633
|
``,
|
|
@@ -2534,12 +2660,21 @@ function buildOrchestratorBody(name, prompt) {
|
|
|
2534
2660
|
``,
|
|
2535
2661
|
`## How to run (orchestrator \u2014 clarify in THIS session, then drive native subagent spawns)`,
|
|
2536
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
|
+
``,
|
|
2537
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.`,
|
|
2538
2673
|
``,
|
|
2539
2674
|
`Drive this exact sequence (it is the state machine \u2014 follow the file, don't improvise from memory):`,
|
|
2540
2675
|
``,
|
|
2541
2676
|
...autoDiscussStep,
|
|
2542
|
-
`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)." : ""}`,
|
|
2543
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.`,
|
|
2544
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.`,
|
|
2545
2680
|
`5. Otherwise, for each fired sub in \`order\` (serial subs sequentially, parallel subs concurrently via parallel Task calls):`,
|
|
@@ -2572,6 +2707,13 @@ function buildExecutionBody(name, prompt) {
|
|
|
2572
2707
|
``,
|
|
2573
2708
|
`## How to run (execution \u2014 native subagent spawn)`,
|
|
2574
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
|
+
``,
|
|
2575
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).`,
|
|
2576
2718
|
``,
|
|
2577
2719
|
...spawnLoopSteps("").map(
|
|
@@ -2623,7 +2765,7 @@ function nameToYamlHintPath(name) {
|
|
|
2623
2765
|
function shouldOverwriteFile(content) {
|
|
2624
2766
|
return HARNESSED_MARKER_RX.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
|
|
2625
2767
|
}
|
|
2626
|
-
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")) {
|
|
2627
2769
|
const results = [];
|
|
2628
2770
|
const aggregatedWarnings = /* @__PURE__ */ new Set();
|
|
2629
2771
|
for (const name of slashNames) {
|
|
@@ -2642,7 +2784,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
|
|
|
2642
2784
|
if (fileExists2(path)) {
|
|
2643
2785
|
let existing = "";
|
|
2644
2786
|
try {
|
|
2645
|
-
existing =
|
|
2787
|
+
existing = readFileSync16(path);
|
|
2646
2788
|
} catch {
|
|
2647
2789
|
existing = "";
|
|
2648
2790
|
}
|
|
@@ -3848,87 +3990,6 @@ This applies to: strategic-layer review skip / phase-layer clarification skip /
|
|
|
3848
3990
|
};
|
|
3849
3991
|
}
|
|
3850
3992
|
});
|
|
3851
|
-
function getPackageRoot() {
|
|
3852
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
3853
|
-
const thisDir = dirname(thisFile);
|
|
3854
|
-
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
3855
|
-
return resolve(thisDir, "..");
|
|
3856
|
-
}
|
|
3857
|
-
return resolve(thisDir, "..", "..", "..");
|
|
3858
|
-
}
|
|
3859
|
-
var init_packagePath = __esm({
|
|
3860
|
-
"src/cli/lib/packagePath.ts"() {
|
|
3861
|
-
}
|
|
3862
|
-
});
|
|
3863
|
-
|
|
3864
|
-
// src/cli/lib/assetsRoot.ts
|
|
3865
|
-
var assetsRoot_exports = {};
|
|
3866
|
-
__export(assetsRoot_exports, {
|
|
3867
|
-
compiledAssetsDir: () => compiledAssetsDir,
|
|
3868
|
-
computeAssetsRoot: () => computeAssetsRoot,
|
|
3869
|
-
getAssetsRoot: () => getAssetsRoot,
|
|
3870
|
-
isCompiledModuleUrl: () => isCompiledModuleUrl
|
|
3871
|
-
});
|
|
3872
|
-
function isCompiledModuleUrl(url) {
|
|
3873
|
-
let s = url;
|
|
3874
|
-
try {
|
|
3875
|
-
s = decodeURIComponent(url);
|
|
3876
|
-
} catch {
|
|
3877
|
-
}
|
|
3878
|
-
const normalized = s.replace(/\\/g, "/").toLowerCase();
|
|
3879
|
-
return BUNFS_MARKERS.some((m) => normalized.includes(m));
|
|
3880
|
-
}
|
|
3881
|
-
function computeAssetsRoot(d) {
|
|
3882
|
-
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
3883
|
-
if (override && override.trim().length > 0) {
|
|
3884
|
-
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
3885
|
-
}
|
|
3886
|
-
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
3887
|
-
const root = join(d.stateRoot(), "assets", d.version);
|
|
3888
|
-
const present = d.exists(join(root, "workflows"));
|
|
3889
|
-
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
3890
|
-
}
|
|
3891
|
-
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
3892
|
-
}
|
|
3893
|
-
function compiledAssetsDir(version) {
|
|
3894
|
-
return join(detectPlatform().stateRoot, "assets", version);
|
|
3895
|
-
}
|
|
3896
|
-
function realDeps() {
|
|
3897
|
-
return {
|
|
3898
|
-
env: process.env,
|
|
3899
|
-
moduleUrl: import.meta.url,
|
|
3900
|
-
exists: (p7) => {
|
|
3901
|
-
try {
|
|
3902
|
-
return existsSync(p7);
|
|
3903
|
-
} catch {
|
|
3904
|
-
return false;
|
|
3905
|
-
}
|
|
3906
|
-
},
|
|
3907
|
-
stateRoot: () => detectPlatform().stateRoot,
|
|
3908
|
-
packageRoot: getPackageRoot(),
|
|
3909
|
-
version: package_default.version
|
|
3910
|
-
};
|
|
3911
|
-
}
|
|
3912
|
-
function getAssetsRoot() {
|
|
3913
|
-
const r = computeAssetsRoot(realDeps());
|
|
3914
|
-
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
3915
|
-
warnedMissing = true;
|
|
3916
|
-
console.error(
|
|
3917
|
-
`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)`
|
|
3918
|
-
);
|
|
3919
|
-
}
|
|
3920
|
-
return r.root;
|
|
3921
|
-
}
|
|
3922
|
-
var BUNFS_MARKERS, warnedMissing;
|
|
3923
|
-
var init_assetsRoot = __esm({
|
|
3924
|
-
"src/cli/lib/assetsRoot.ts"() {
|
|
3925
|
-
init_package();
|
|
3926
|
-
init_platform();
|
|
3927
|
-
init_packagePath();
|
|
3928
|
-
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
3929
|
-
warnedMissing = false;
|
|
3930
|
-
}
|
|
3931
|
-
});
|
|
3932
3993
|
async function loadUserOverrides(packageRoot) {
|
|
3933
3994
|
const yamlPath = resolve(packageRoot, "workflows", "judgments", "user-overrides.yaml");
|
|
3934
3995
|
let raw;
|
|
@@ -4652,7 +4713,7 @@ function compute(d) {
|
|
|
4652
4713
|
const gitFirst = d.where("git")[0];
|
|
4653
4714
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4654
4715
|
const root = dirname8(dirname8(gitFirst));
|
|
4655
|
-
for (const cand of [
|
|
4716
|
+
for (const cand of [join19(root, "bin", "bash.exe"), join19(root, "usr", "bin", "bash.exe")]) {
|
|
4656
4717
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4657
4718
|
}
|
|
4658
4719
|
}
|
|
@@ -4660,13 +4721,13 @@ function compute(d) {
|
|
|
4660
4721
|
d.env.ProgramFiles,
|
|
4661
4722
|
d.env.ProgramW6432,
|
|
4662
4723
|
d.env["ProgramFiles(x86)"],
|
|
4663
|
-
d.env.LOCALAPPDATA ?
|
|
4724
|
+
d.env.LOCALAPPDATA ? join19(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4664
4725
|
];
|
|
4665
4726
|
for (const base of bases) {
|
|
4666
4727
|
if (!base) continue;
|
|
4667
4728
|
for (const cand of [
|
|
4668
|
-
|
|
4669
|
-
|
|
4729
|
+
join19(base, "Git", "bin", "bash.exe"),
|
|
4730
|
+
join19(base, "Git", "usr", "bin", "bash.exe")
|
|
4670
4731
|
]) {
|
|
4671
4732
|
if (d.exists(cand) && usable(cand))
|
|
4672
4733
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4679,10 +4740,10 @@ function compute(d) {
|
|
|
4679
4740
|
}
|
|
4680
4741
|
return { path: "bash", source: "path-fallback" };
|
|
4681
4742
|
}
|
|
4682
|
-
var dirname8,
|
|
4743
|
+
var dirname8, join19, WSL_STUB_RE, cache2;
|
|
4683
4744
|
var init_resolveBash = __esm({
|
|
4684
4745
|
"src/installers/lib/resolveBash.ts"() {
|
|
4685
|
-
({ dirname: dirname8, join:
|
|
4746
|
+
({ dirname: dirname8, join: join19 } = win32);
|
|
4686
4747
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4687
4748
|
cache2 = null;
|
|
4688
4749
|
}
|
|
@@ -5455,14 +5516,14 @@ __export(version_check_exports, {
|
|
|
5455
5516
|
compareVersions: () => compareVersions,
|
|
5456
5517
|
fetchLatestVersion: () => fetchLatestVersion
|
|
5457
5518
|
});
|
|
5458
|
-
function
|
|
5519
|
+
function parse3(v) {
|
|
5459
5520
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(v.trim());
|
|
5460
5521
|
if (!m) return null;
|
|
5461
5522
|
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
5462
5523
|
}
|
|
5463
5524
|
function compareVersions(installed, latest) {
|
|
5464
|
-
const a =
|
|
5465
|
-
const b =
|
|
5525
|
+
const a = parse3(installed);
|
|
5526
|
+
const b = parse3(latest);
|
|
5466
5527
|
if (!a || !b) return "unknown";
|
|
5467
5528
|
for (let i = 0; i < 3; i++) {
|
|
5468
5529
|
const ai = a.nums[i] ?? 0;
|
|
@@ -5690,7 +5751,7 @@ function resolveHookCommand(raw, deps) {
|
|
|
5690
5751
|
root = root ?? deps.assetsRoot();
|
|
5691
5752
|
const abs = join(root, bare2);
|
|
5692
5753
|
if (!deps.exists(abs)) return token;
|
|
5693
|
-
return abs.
|
|
5754
|
+
return `"${abs.replace(/\\/g, "/")}"`;
|
|
5694
5755
|
});
|
|
5695
5756
|
return out.join(" ");
|
|
5696
5757
|
}
|
|
@@ -6073,6 +6134,29 @@ var init_nativeTest = __esm({
|
|
|
6073
6134
|
UNSAFE_PATH_RE = /[|&;<>()*?"'`$={}[\]]/;
|
|
6074
6135
|
}
|
|
6075
6136
|
});
|
|
6137
|
+
function getMcpSpawnCwd() {
|
|
6138
|
+
return homedir();
|
|
6139
|
+
}
|
|
6140
|
+
function getNeutralSpawnCwd() {
|
|
6141
|
+
const override = process.env.HARNESSED_SPAWN_CWD;
|
|
6142
|
+
if (override !== void 0 && override.trim().length > 0) return override.trim();
|
|
6143
|
+
try {
|
|
6144
|
+
const dir = join(detectPlatform().stateRoot, ".spawn");
|
|
6145
|
+
mkdirSync(dir, { recursive: true });
|
|
6146
|
+
const sentinel = join(dir, "package.json");
|
|
6147
|
+
if (!existsSync(sentinel)) writeFileSync(sentinel, NEUTRAL_SENTINEL, "utf8");
|
|
6148
|
+
return dir;
|
|
6149
|
+
} catch {
|
|
6150
|
+
return null;
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
6153
|
+
var NEUTRAL_SENTINEL;
|
|
6154
|
+
var init_safeCwd = __esm({
|
|
6155
|
+
"src/installers/lib/safeCwd.ts"() {
|
|
6156
|
+
init_platform();
|
|
6157
|
+
NEUTRAL_SENTINEL = '{\n "name": "harnessed-neutral-spawn",\n "private": true\n}\n';
|
|
6158
|
+
}
|
|
6159
|
+
});
|
|
6076
6160
|
function expandTildeForWindows(cmd) {
|
|
6077
6161
|
const home = homedir().replace(/\\/g, "/");
|
|
6078
6162
|
return cmd.replace(/(^|[\s"'`(])~\//g, `$1${home}/`);
|
|
@@ -6106,7 +6190,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
6106
6190
|
const installCfg = ctx.manifest.spec.install;
|
|
6107
6191
|
const effectiveTimeoutMs = timeoutMs ?? DEFAULT_INSTALL_TIMEOUT_MS;
|
|
6108
6192
|
const env = { ...process.env, ...installCfg.env ?? {} };
|
|
6109
|
-
const cwd = installCfg.cwd ?? ctx.cwd;
|
|
6193
|
+
const cwd = installCfg.cwd ?? (opts?.neutralCwd ? getNeutralSpawnCwd() ?? ctx.cwd : ctx.cwd);
|
|
6110
6194
|
let child;
|
|
6111
6195
|
let triedBash = false;
|
|
6112
6196
|
const stdio = ["ignore", "pipe", "pipe"];
|
|
@@ -6199,6 +6283,7 @@ var init_spawn = __esm({
|
|
|
6199
6283
|
init_security();
|
|
6200
6284
|
init_nativeTest();
|
|
6201
6285
|
init_resolveBash();
|
|
6286
|
+
init_safeCwd();
|
|
6202
6287
|
init_verifyMessage();
|
|
6203
6288
|
POSIX_SYNTAX_RE = /[|;<>`$~[\]{}()*?!]|&&/;
|
|
6204
6289
|
POSIX_FIRST_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -6424,13 +6509,6 @@ var init_runClaudeArgs = __esm({
|
|
|
6424
6509
|
"src/installers/lib/runClaudeArgs.ts"() {
|
|
6425
6510
|
}
|
|
6426
6511
|
});
|
|
6427
|
-
function getMcpSpawnCwd() {
|
|
6428
|
-
return homedir();
|
|
6429
|
-
}
|
|
6430
|
-
var init_safeCwd = __esm({
|
|
6431
|
-
"src/installers/lib/safeCwd.ts"() {
|
|
6432
|
-
}
|
|
6433
|
-
});
|
|
6434
6512
|
|
|
6435
6513
|
// src/installers/ccPluginMarketplace.ts
|
|
6436
6514
|
function parseCmd(cmd) {
|
|
@@ -7260,7 +7338,7 @@ var init_npmCli2 = __esm({
|
|
|
7260
7338
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
7261
7339
|
const bk = await backup(plan, ctx);
|
|
7262
7340
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
7263
|
-
const sp = await spawnCmd(ctx, cmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
|
|
7341
|
+
const sp = await spawnCmd(ctx, cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
|
|
7264
7342
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7265
7343
|
if (sp.exitCode !== 0) {
|
|
7266
7344
|
return {
|
|
@@ -7278,7 +7356,8 @@ var init_npmCli2 = __esm({
|
|
|
7278
7356
|
}
|
|
7279
7357
|
const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
|
|
7280
7358
|
const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
|
|
7281
|
-
posixShell: true
|
|
7359
|
+
posixShell: true,
|
|
7360
|
+
neutralCwd: true
|
|
7282
7361
|
});
|
|
7283
7362
|
if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
|
|
7284
7363
|
const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
|
|
@@ -7387,11 +7466,11 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
7387
7466
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
7388
7467
|
const bk = await backup(plan, ctx);
|
|
7389
7468
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
7390
|
-
let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
|
|
7469
|
+
let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
|
|
7391
7470
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7392
7471
|
if (HARD_CRASH_EXITS.has(sp.exitCode)) {
|
|
7393
7472
|
await new Promise((r) => setTimeout(r, HARD_CRASH_RETRY_DELAY_MS));
|
|
7394
|
-
sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
|
|
7473
|
+
sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
|
|
7395
7474
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7396
7475
|
}
|
|
7397
7476
|
if (sp.exitCode !== 0) {
|
|
@@ -7427,7 +7506,8 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
7427
7506
|
}
|
|
7428
7507
|
const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
|
|
7429
7508
|
const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
|
|
7430
|
-
posixShell: true
|
|
7509
|
+
posixShell: true,
|
|
7510
|
+
neutralCwd: true
|
|
7431
7511
|
});
|
|
7432
7512
|
if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
|
|
7433
7513
|
const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
|
|
@@ -7689,6 +7769,196 @@ var init_nextStep = __esm({
|
|
|
7689
7769
|
}
|
|
7690
7770
|
});
|
|
7691
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
|
+
|
|
7692
7962
|
// src/cli/lib/release-preflight.ts
|
|
7693
7963
|
var release_preflight_exports = {};
|
|
7694
7964
|
__export(release_preflight_exports, {
|
|
@@ -8122,7 +8392,12 @@ async function runAutoInstall(opts) {
|
|
|
8122
8392
|
// Windows needs shell for `.cmd` / `.bat` exes (npx.cmd / claude.cmd
|
|
8123
8393
|
// shims); Unix is fine either way. Pass-through to OS shell handles
|
|
8124
8394
|
// PATH resolution + extension lookup.
|
|
8125
|
-
shell: true
|
|
8395
|
+
shell: true,
|
|
8396
|
+
// v4.20.1 — neutral cwd: install commands are global-semantics; the
|
|
8397
|
+
// user's shell cwd may carry an ambient devEngines package.json that
|
|
8398
|
+
// kills every npx-based command (EBADDEVENGINES dogfood). Fail-open to
|
|
8399
|
+
// inherited cwd when neutral resolution is unavailable.
|
|
8400
|
+
cwd: getNeutralSpawnCwd() ?? void 0
|
|
8126
8401
|
});
|
|
8127
8402
|
if (r.status !== 0) {
|
|
8128
8403
|
const reason = r.error !== void 0 ? `spawn error on \`${cmd}\`: ${r.error.message}` : `exit ${r.status ?? "<unknown>"} on \`${cmd}\``;
|
|
@@ -8157,6 +8432,7 @@ Auto-install summary: ${out.installed.length} installed / ${out.skipped.length}
|
|
|
8157
8432
|
}
|
|
8158
8433
|
var init_auto_install = __esm({
|
|
8159
8434
|
"src/cli/lib/auto-install.ts"() {
|
|
8435
|
+
init_safeCwd();
|
|
8160
8436
|
init_doctor_registry();
|
|
8161
8437
|
}
|
|
8162
8438
|
});
|
|
@@ -8534,7 +8810,7 @@ function registerBackupList(program2) {
|
|
|
8534
8810
|
// src/cli/checkpoint.ts
|
|
8535
8811
|
init_path_guard();
|
|
8536
8812
|
init_ledger();
|
|
8537
|
-
var ACTIONS = ["start", "complete", "fail"];
|
|
8813
|
+
var ACTIONS = ["start", "complete", "fail", "intent"];
|
|
8538
8814
|
function isAction(a) {
|
|
8539
8815
|
return ACTIONS.includes(a);
|
|
8540
8816
|
}
|
|
@@ -8561,9 +8837,24 @@ async function parsePlan(raw) {
|
|
|
8561
8837
|
}
|
|
8562
8838
|
return plan;
|
|
8563
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
|
+
}
|
|
8564
8855
|
function registerCheckpoint(program2) {
|
|
8565
8856
|
program2.command("checkpoint <action> <sub>").description(
|
|
8566
|
-
"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/)"
|
|
8567
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(
|
|
8568
8859
|
"--force",
|
|
8569
8860
|
"complete only \u2014 override a missing-artifact evidence block (records overridden)"
|
|
@@ -8579,6 +8870,30 @@ function registerCheckpoint(program2) {
|
|
|
8579
8870
|
process.exit(1);
|
|
8580
8871
|
return;
|
|
8581
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
|
+
}
|
|
8582
8897
|
try {
|
|
8583
8898
|
checkPathSafe(sub);
|
|
8584
8899
|
} catch {
|
|
@@ -8595,6 +8910,18 @@ function registerCheckpoint(program2) {
|
|
|
8595
8910
|
const { mutateSubProgress: mutateSubProgress3 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8596
8911
|
await mutateSubProgress3(() => seedLedger2(plan));
|
|
8597
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
|
+
}
|
|
8598
8925
|
console.log(`[harnessed] checkpoint started: ${sub} \u2192 ${checkpointPath}`);
|
|
8599
8926
|
process.exit(0);
|
|
8600
8927
|
return;
|
|
@@ -8624,6 +8951,7 @@ function registerCheckpoint(program2) {
|
|
|
8624
8951
|
else evidenceStatus = "none_declared";
|
|
8625
8952
|
const markOpts = evidenceStatus === "none_declared" ? { evidence_status: evidenceStatus } : { evidence: result.found, evidence_status: evidenceStatus };
|
|
8626
8953
|
await mutateSubProgress3((e) => markIfSeeded(e, sub, "done", markOpts));
|
|
8954
|
+
await absorbIntentFor(sub);
|
|
8627
8955
|
const { collectScaleMetrics: collectScaleMetrics2, assessScale: assessScale2 } = await Promise.resolve().then(() => (init_scale(), scale_exports));
|
|
8628
8956
|
const { readCurrentWorkflow: readCurrentWorkflow3, writeCurrentWorkflow: writeCurrentWorkflow2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8629
8957
|
const afterMark = await readCurrentWorkflow3();
|
|
@@ -8690,6 +9018,7 @@ function registerCheckpoint(program2) {
|
|
|
8690
9018
|
}
|
|
8691
9019
|
const { mutateSubProgress: mutateSubProgress2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
8692
9020
|
await mutateSubProgress2((e) => markIfSeeded(e, sub, "failed"));
|
|
9021
|
+
await absorbIntentFor(sub);
|
|
8693
9022
|
await completePhase2({
|
|
8694
9023
|
phaseId: sub,
|
|
8695
9024
|
status: "complete",
|
|
@@ -8779,7 +9108,12 @@ function resolveMasterYamlPath2(master, packageRoot) {
|
|
|
8779
9108
|
function registerGates(program2) {
|
|
8780
9109
|
program2.command("gates").description(
|
|
8781
9110
|
"Evaluate which sub-workflows fire for a master orchestrator (JSON plan, no spawn)."
|
|
8782
|
-
).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) => {
|
|
8783
9117
|
if (!VALID_MASTERS.has(master)) {
|
|
8784
9118
|
console.error(
|
|
8785
9119
|
`error: unknown master '${master}'. Expected one of: auto, discuss, plan, task, verify.`
|
|
@@ -8838,7 +9172,7 @@ function registerGates(program2) {
|
|
|
8838
9172
|
}
|
|
8839
9173
|
}
|
|
8840
9174
|
const skipSubs = new Set(
|
|
8841
|
-
|
|
9175
|
+
(Array.isArray(raw.skipSub) ? raw.skipSub : []).flatMap((v) => v.split(",")).map((s) => s.trim()).filter((s) => s.length > 0)
|
|
8842
9176
|
);
|
|
8843
9177
|
ctx.skip_subs = [...skipSubs];
|
|
8844
9178
|
const fire = [];
|
|
@@ -9126,8 +9460,14 @@ function evidenceLabel(entry) {
|
|
|
9126
9460
|
return "evidence: none_declared";
|
|
9127
9461
|
}
|
|
9128
9462
|
}
|
|
9129
|
-
async function buildRecoverLines(workflow, ledger) {
|
|
9463
|
+
async function buildRecoverLines(workflow, ledger, intent) {
|
|
9130
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
|
+
}
|
|
9131
9471
|
if (!workflow || ledger.length === 0) {
|
|
9132
9472
|
lines.push("no ledger \u2014 run gates + start");
|
|
9133
9473
|
return lines;
|
|
@@ -9165,7 +9505,22 @@ function registerStatus(program2) {
|
|
|
9165
9505
|
if (opts.recover) {
|
|
9166
9506
|
const wf = await readCurrentWorkflow();
|
|
9167
9507
|
const ledger = wf?.sub_progress ?? [];
|
|
9168
|
-
|
|
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);
|
|
9169
9524
|
for (const l of lines) console.log(l);
|
|
9170
9525
|
return;
|
|
9171
9526
|
}
|