harnessed 4.36.0 → 4.38.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 +22 -2
- package/dist/cli.mjs +466 -95
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/manifests/optional/perturn-inject-invalidate.yaml +57 -0
- package/package.json +1 -1
- package/workflows/capabilities.yaml +6 -1
- package/workflows/judgments/web-testing-routing.yaml +14 -5
- package/workflows/task/test/SKILL.md +30 -0
- package/workflows/task/test/SKILL.zh-Hans.md +26 -0
- package/workflows/verify/auto/SKILL.md +11 -0
- package/workflows/verify/auto/SKILL.zh-Hans.md +11 -0
- package/workflows/verify/qa/SKILL.md +14 -3
- package/workflows/verify/qa/SKILL.zh-Hans.md +14 -3
- package/workflows/verify/qa/workflow.yaml +8 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, utimesSync, rmSync, statSync } from 'fs';
|
|
2
|
+
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, utimesSync, rmSync, statSync, appendFileSync } from 'fs';
|
|
3
3
|
import { homedir, tmpdir } from 'os';
|
|
4
4
|
import { join, resolve, dirname, basename, sep, isAbsolute, win32, posix, relative } from 'path';
|
|
5
5
|
import { Type } from '@sinclair/typebox';
|
|
@@ -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.38.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -881,6 +881,7 @@ __export(ledger_exports, {
|
|
|
881
881
|
findSerialBlockers: () => findSerialBlockers,
|
|
882
882
|
markSub: () => markSub,
|
|
883
883
|
nextPending: () => nextPending,
|
|
884
|
+
reopenSub: () => reopenSub,
|
|
884
885
|
seedLedger: () => seedLedger
|
|
885
886
|
});
|
|
886
887
|
function seedLedger(plan) {
|
|
@@ -928,6 +929,27 @@ function markSub(entries, sub, status, opts) {
|
|
|
928
929
|
next[idx] = updated;
|
|
929
930
|
return next;
|
|
930
931
|
}
|
|
932
|
+
function reopenSub(entries, sub, reason) {
|
|
933
|
+
const idx = entries.findIndex((e) => e.sub === sub);
|
|
934
|
+
if (idx === -1) {
|
|
935
|
+
throw new Error(
|
|
936
|
+
`reopenSub: sub '${sub}' not found in ledger (${entries.length} entries). It must be seeded before it can be reopened.`
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
const current = entries[idx];
|
|
940
|
+
if (current.status === "pending") {
|
|
941
|
+
throw new Error(`reopenSub: sub '${sub}' is already pending \u2014 nothing to send back.`);
|
|
942
|
+
}
|
|
943
|
+
const { evidence, evidence_status, completion_claim, ...rest } = current;
|
|
944
|
+
const next = entries.slice();
|
|
945
|
+
next[idx] = {
|
|
946
|
+
...rest,
|
|
947
|
+
status: "pending",
|
|
948
|
+
fail_count: (current.fail_count ?? 0) + 1,
|
|
949
|
+
reason
|
|
950
|
+
};
|
|
951
|
+
return next;
|
|
952
|
+
}
|
|
931
953
|
function nextPending(entries) {
|
|
932
954
|
return entries.find((e) => e.status === "pending")?.sub ?? null;
|
|
933
955
|
}
|
|
@@ -3125,11 +3147,11 @@ function isComplete(output) {
|
|
|
3125
3147
|
if (succeeded) return true;
|
|
3126
3148
|
return extractPromise(env.text ?? env.result ?? "") === "COMPLETE";
|
|
3127
3149
|
}
|
|
3128
|
-
async function ralphLoopWrap(
|
|
3150
|
+
async function ralphLoopWrap(spawn7, maxIter) {
|
|
3129
3151
|
let last = "";
|
|
3130
3152
|
let sessionId;
|
|
3131
3153
|
for (let i = 0; i < maxIter; i++) {
|
|
3132
|
-
last = await
|
|
3154
|
+
last = await spawn7(sessionId, (id) => {
|
|
3133
3155
|
sessionId = id;
|
|
3134
3156
|
});
|
|
3135
3157
|
if (isComplete(last)) return last;
|
|
@@ -3220,6 +3242,164 @@ var init_scale = __esm({
|
|
|
3220
3242
|
execp = promisify(exec);
|
|
3221
3243
|
}
|
|
3222
3244
|
});
|
|
3245
|
+
function extractVerifyBinary(verifyCmd, fallback) {
|
|
3246
|
+
const token = verifyCmd?.trim().split(/\s+/)[0];
|
|
3247
|
+
if (token && BARE_BIN_RE.test(token) && !NON_COMPONENT_TOKENS.has(token)) return token;
|
|
3248
|
+
if (BARE_BIN_RE.test(fallback) && !NON_COMPONENT_TOKENS.has(fallback)) return fallback;
|
|
3249
|
+
return null;
|
|
3250
|
+
}
|
|
3251
|
+
function realRun(finder, bin) {
|
|
3252
|
+
try {
|
|
3253
|
+
if (typeof spawnSync !== "function") return null;
|
|
3254
|
+
const r = spawnSync(finder, [bin], { encoding: "utf8" });
|
|
3255
|
+
if (!r || r.error) return null;
|
|
3256
|
+
return { status: r.status, stdout: r.stdout ?? "" };
|
|
3257
|
+
} catch {
|
|
3258
|
+
return null;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function binaryOnPath(bin, deps) {
|
|
3262
|
+
const platform = process.platform;
|
|
3263
|
+
const run = realRun;
|
|
3264
|
+
const finder = platform === "win32" ? "where" : "which";
|
|
3265
|
+
const r = run(finder, bin);
|
|
3266
|
+
if (!r || r.status !== 0) return false;
|
|
3267
|
+
return r.stdout.trim().length > 0;
|
|
3268
|
+
}
|
|
3269
|
+
var NON_COMPONENT_TOKENS, BARE_BIN_RE;
|
|
3270
|
+
var init_binaryProbe = __esm({
|
|
3271
|
+
"src/installers/lib/binaryProbe.ts"() {
|
|
3272
|
+
NON_COMPONENT_TOKENS = /* @__PURE__ */ new Set([
|
|
3273
|
+
"test",
|
|
3274
|
+
"grep",
|
|
3275
|
+
"ls",
|
|
3276
|
+
"cat",
|
|
3277
|
+
"echo",
|
|
3278
|
+
"command",
|
|
3279
|
+
"sh",
|
|
3280
|
+
"bash",
|
|
3281
|
+
"[",
|
|
3282
|
+
"npx",
|
|
3283
|
+
"npm",
|
|
3284
|
+
"node",
|
|
3285
|
+
"corepack",
|
|
3286
|
+
"pnpm",
|
|
3287
|
+
"yarn",
|
|
3288
|
+
"bun",
|
|
3289
|
+
"git",
|
|
3290
|
+
"claude",
|
|
3291
|
+
"codex"
|
|
3292
|
+
]);
|
|
3293
|
+
BARE_BIN_RE = /^[A-Za-z0-9][\w.@-]*$/;
|
|
3294
|
+
}
|
|
3295
|
+
});
|
|
3296
|
+
|
|
3297
|
+
// src/checkpoint/codegraphInit.ts
|
|
3298
|
+
var codegraphInit_exports = {};
|
|
3299
|
+
__export(codegraphInit_exports, {
|
|
3300
|
+
ensureCodegraphIgnored: () => ensureCodegraphIgnored,
|
|
3301
|
+
maybeInitCodeGraph: () => maybeInitCodeGraph
|
|
3302
|
+
});
|
|
3303
|
+
function claimPath(cwd) {
|
|
3304
|
+
const key = createHash("sha1").update(resolve(cwd)).digest("hex").slice(0, 16);
|
|
3305
|
+
return join(harnessedSubdir("codegraph-init"), `${key}.claim`);
|
|
3306
|
+
}
|
|
3307
|
+
function realClaim(cwd) {
|
|
3308
|
+
const path = claimPath(cwd);
|
|
3309
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3310
|
+
try {
|
|
3311
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
3312
|
+
} catch {
|
|
3313
|
+
return false;
|
|
3314
|
+
}
|
|
3315
|
+
try {
|
|
3316
|
+
writeFileSync(path, stamp, { flag: "wx" });
|
|
3317
|
+
return true;
|
|
3318
|
+
} catch {
|
|
3319
|
+
try {
|
|
3320
|
+
if (Date.now() - statSync(path).mtimeMs < STALE_CLAIM_MS) return false;
|
|
3321
|
+
writeFileSync(path, stamp);
|
|
3322
|
+
return true;
|
|
3323
|
+
} catch {
|
|
3324
|
+
return false;
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
function realLaunch(cwd) {
|
|
3329
|
+
if (typeof spawn !== "function") return;
|
|
3330
|
+
const win = process.platform === "win32";
|
|
3331
|
+
const child = win ? spawn("cmd.exe", ["/d", "/s", "/c", "codegraph", "init"], {
|
|
3332
|
+
cwd,
|
|
3333
|
+
stdio: "ignore",
|
|
3334
|
+
windowsHide: true
|
|
3335
|
+
}) : spawn("codegraph", ["init"], { cwd, stdio: "ignore", detached: true });
|
|
3336
|
+
child.on("error", () => {
|
|
3337
|
+
});
|
|
3338
|
+
child.unref();
|
|
3339
|
+
}
|
|
3340
|
+
function ignoresCodegraph(body) {
|
|
3341
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
3342
|
+
const line = raw.trim();
|
|
3343
|
+
if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
|
|
3344
|
+
if (line.replace(/^\//, "").replace(/\/$/, "") === ".codegraph") return true;
|
|
3345
|
+
}
|
|
3346
|
+
return false;
|
|
3347
|
+
}
|
|
3348
|
+
function ensureCodegraphIgnored(cwd) {
|
|
3349
|
+
const path = join(cwd, ".gitignore");
|
|
3350
|
+
try {
|
|
3351
|
+
if (!existsSync(path)) {
|
|
3352
|
+
writeFileSync(path, `${IGNORE_LINE}
|
|
3353
|
+
`);
|
|
3354
|
+
return "created";
|
|
3355
|
+
}
|
|
3356
|
+
const body = readFileSync(path, "utf8");
|
|
3357
|
+
if (ignoresCodegraph(body)) return "already";
|
|
3358
|
+
appendFileSync(path, `${body.endsWith("\n") || body === "" ? "" : "\n"}${IGNORE_LINE}
|
|
3359
|
+
`);
|
|
3360
|
+
return "appended";
|
|
3361
|
+
} catch {
|
|
3362
|
+
return "error";
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
function maybeInitCodeGraph(overrides = {}) {
|
|
3366
|
+
const cwd = overrides.cwd ?? process.cwd();
|
|
3367
|
+
const hasIndex = overrides.hasIndex ?? ((c) => existsSync(join(c, ".codegraph")));
|
|
3368
|
+
const hasBinary = overrides.hasBinary ?? (() => binaryOnPath("codegraph"));
|
|
3369
|
+
const claim = overrides.claim ?? realClaim;
|
|
3370
|
+
const launch = overrides.launch ?? realLaunch;
|
|
3371
|
+
const note2 = overrides.note ?? ((m) => {
|
|
3372
|
+
console.error(m);
|
|
3373
|
+
});
|
|
3374
|
+
if (hasIndex(cwd)) return "index-present";
|
|
3375
|
+
if (!hasBinary()) return "no-binary";
|
|
3376
|
+
if (!claim(cwd)) return "already-claimed";
|
|
3377
|
+
try {
|
|
3378
|
+
launch(cwd);
|
|
3379
|
+
} catch (e) {
|
|
3380
|
+
note2(`[harnessed] codegraph init could not be started (ignored): ${e.message}`);
|
|
3381
|
+
return "launch-failed";
|
|
3382
|
+
}
|
|
3383
|
+
note2(
|
|
3384
|
+
`[harnessed] codegraph init started in the background for ${cwd} \u2014 the next task gets a semantic index (first-time only; upstream's watcher keeps it fresh).`
|
|
3385
|
+
);
|
|
3386
|
+
const ignored = ensureCodegraphIgnored(cwd);
|
|
3387
|
+
if (ignored === "appended" || ignored === "created") {
|
|
3388
|
+
note2(
|
|
3389
|
+
`[harnessed] appended \`${IGNORE_LINE}\` to ${join(cwd, ".gitignore")} \u2014 the index is a SQLite DB, and an unignored one gets swept into the next \`git add -A\`.`
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
return "launched";
|
|
3393
|
+
}
|
|
3394
|
+
var STALE_CLAIM_MS, IGNORE_LINE;
|
|
3395
|
+
var init_codegraphInit = __esm({
|
|
3396
|
+
"src/checkpoint/codegraphInit.ts"() {
|
|
3397
|
+
init_binaryProbe();
|
|
3398
|
+
init_harnessedRoot();
|
|
3399
|
+
STALE_CLAIM_MS = 30 * 6e4;
|
|
3400
|
+
IGNORE_LINE = ".codegraph/";
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3223
3403
|
|
|
3224
3404
|
// src/checkpoint/learnings.ts
|
|
3225
3405
|
var learnings_exports = {};
|
|
@@ -3585,6 +3765,7 @@ __export(checkpoint_exports, {
|
|
|
3585
3765
|
registerCheckpoint: () => registerCheckpoint,
|
|
3586
3766
|
runCheckpointComplete: () => runCheckpointComplete,
|
|
3587
3767
|
runCheckpointFail: () => runCheckpointFail,
|
|
3768
|
+
runCheckpointReopen: () => runCheckpointReopen,
|
|
3588
3769
|
runCheckpointStart: () => runCheckpointStart
|
|
3589
3770
|
});
|
|
3590
3771
|
function isAction(a) {
|
|
@@ -3802,6 +3983,13 @@ async function runCheckpointComplete(sub, opts, deps = defaultRunDeps) {
|
|
|
3802
3983
|
lastTask: opts.summary ?? `phase ${sub} complete`,
|
|
3803
3984
|
transitionWorkflowComplete: allResolved
|
|
3804
3985
|
});
|
|
3986
|
+
if (allResolved && afterMark?.phase === "task") {
|
|
3987
|
+
try {
|
|
3988
|
+
const { maybeInitCodeGraph: maybeInitCodeGraph2 } = await Promise.resolve().then(() => (init_codegraphInit(), codegraphInit_exports));
|
|
3989
|
+
maybeInitCodeGraph2({ note: (m) => deps.error(m) });
|
|
3990
|
+
} catch {
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3805
3993
|
if (allResolved && afterMark) {
|
|
3806
3994
|
const { captureWorkflowLearnings: captureWorkflowLearnings2 } = await Promise.resolve().then(() => (init_learnings(), learnings_exports));
|
|
3807
3995
|
const captured = await captureWorkflowLearnings2(afterMark.sub_progress ?? [], sub);
|
|
@@ -3916,9 +4104,62 @@ async function runCheckpointFail(sub, opts, deps = defaultRunDeps) {
|
|
|
3916
4104
|
deps.exit(1);
|
|
3917
4105
|
return;
|
|
3918
4106
|
}
|
|
4107
|
+
async function runCheckpointReopen(sub, opts, deps = defaultRunDeps) {
|
|
4108
|
+
const reason = opts.reason?.trim();
|
|
4109
|
+
if (!reason) {
|
|
4110
|
+
deps.error(
|
|
4111
|
+
"[harnessed] checkpoint reopen: --reason <text> is required (why is it coming back?)"
|
|
4112
|
+
);
|
|
4113
|
+
deps.exit(1);
|
|
4114
|
+
return;
|
|
4115
|
+
}
|
|
4116
|
+
const { readCurrentWorkflow: readCurrentWorkflow2, mutateSubProgress: mutateSubProgress2, writeCurrentWorkflow: writeCurrentWorkflow2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
4117
|
+
const wf = await readCurrentWorkflow2();
|
|
4118
|
+
if (!wf) {
|
|
4119
|
+
deps.error("[harnessed] checkpoint reopen: no active workflow \u2014 nothing to send back.");
|
|
4120
|
+
deps.exit(1);
|
|
4121
|
+
return;
|
|
4122
|
+
}
|
|
4123
|
+
const entries = wf.sub_progress ?? [];
|
|
4124
|
+
const { reopenSub: reopenSub2 } = await Promise.resolve().then(() => (init_ledger(), ledger_exports));
|
|
4125
|
+
try {
|
|
4126
|
+
reopenSub2(entries, sub, reason);
|
|
4127
|
+
} catch (e) {
|
|
4128
|
+
deps.error(`[harnessed] checkpoint reopen: ${e.message}`);
|
|
4129
|
+
deps.exit(1);
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
await mutateSubProgress2((e) => reopenSub2(e, sub, reason));
|
|
4133
|
+
if (wf.status === "complete") {
|
|
4134
|
+
await writeCurrentWorkflow2({ ...wf, status: "active" });
|
|
4135
|
+
}
|
|
4136
|
+
const latest = await readCurrentWorkflow2();
|
|
4137
|
+
const entry = latest?.sub_progress?.find((e) => e.sub === sub);
|
|
4138
|
+
const attempts = entry?.fail_count ?? 0;
|
|
4139
|
+
const budget = entry?.attempt_budget;
|
|
4140
|
+
if (budget !== void 0) {
|
|
4141
|
+
const { isBudgetExhausted: isBudgetExhausted2 } = await Promise.resolve().then(() => (init_budget(), budget_exports));
|
|
4142
|
+
if (isBudgetExhausted2(attempts, budget)) {
|
|
4143
|
+
deps.error(
|
|
4144
|
+
`[harnessed] BUDGET-EXHAUSTED: sub '${sub}' has spent ${attempts}/${budget} attempts (workflows/defaults.yaml ralph_max_iterations). Do not spawn it again \u2014 re-scope the subtask, fix the blocker, or escalate to the user.`
|
|
4145
|
+
);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
const { detectLoop: detectLoop2, LOOP_THRESHOLD: LOOP_THRESHOLD2 } = await Promise.resolve().then(() => (init_breakLoop(), breakLoop_exports));
|
|
4149
|
+
const looped = detectLoop2(latest?.sub_progress ?? []).find((l) => l.sub === sub);
|
|
4150
|
+
if (looped) {
|
|
4151
|
+
deps.error(
|
|
4152
|
+
`[harnessed] BREAK-LOOP: sub '${sub}' has been sent back / failed ${looped.count}x (>= ${LOOP_THRESHOLD2}). Stop retrying \u2014 run the break-loop skill for root-cause analysis and capture the lesson to .planning/.`
|
|
4153
|
+
);
|
|
4154
|
+
}
|
|
4155
|
+
deps.log(
|
|
4156
|
+
`[harnessed] checkpoint reopen: ${sub} \u2192 pending (attempt ${attempts}${budget !== void 0 ? `/${budget}` : ""}) \u2014 ${reason}`
|
|
4157
|
+
);
|
|
4158
|
+
deps.exit(0);
|
|
4159
|
+
}
|
|
3919
4160
|
function registerCheckpoint(program2) {
|
|
3920
4161
|
program2.command("checkpoint <action> <sub>").description(
|
|
3921
|
-
"Record workflow progress: intent | start | complete | fail <sub-workflow> (writes to ~/.claude/harnessed/checkpoints/)"
|
|
4162
|
+
"Record workflow progress: intent | start | complete | fail | reopen <sub-workflow> (writes to ~/.claude/harnessed/checkpoints/)"
|
|
3922
4163
|
).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(
|
|
3923
4164
|
"--force",
|
|
3924
4165
|
"complete/fail \u2014 override a fail-closed guard: the missing-artifact evidence block (complete; records overridden) or the serial-order guard"
|
|
@@ -3931,6 +4172,9 @@ function registerCheckpoint(program2) {
|
|
|
3931
4172
|
).option(
|
|
3932
4173
|
"--result-file <path>",
|
|
3933
4174
|
"complete only \u2014 same as --result but read from a file (quoting-safe on Windows); wins over --result"
|
|
4175
|
+
).option(
|
|
4176
|
+
"--reason <text>",
|
|
4177
|
+
"reopen only \u2014 why the sub is coming back (required); recorded on the ledger entry and surfaced by the per-turn injector"
|
|
3934
4178
|
).option(
|
|
3935
4179
|
"--failing-tests <n>",
|
|
3936
4180
|
"fail only \u2014 number of tests still failing after this attempt; drives the no-progress circuit breaker (falls back to the evidence-artifact digest when omitted)"
|
|
@@ -3982,6 +4226,10 @@ function registerCheckpoint(program2) {
|
|
|
3982
4226
|
await runCheckpointComplete(sub, opts);
|
|
3983
4227
|
return;
|
|
3984
4228
|
}
|
|
4229
|
+
if (action === "reopen") {
|
|
4230
|
+
await runCheckpointReopen(sub, opts);
|
|
4231
|
+
return;
|
|
4232
|
+
}
|
|
3985
4233
|
await runCheckpointFail(sub, opts);
|
|
3986
4234
|
}
|
|
3987
4235
|
);
|
|
@@ -3992,7 +4240,7 @@ var init_checkpoint = __esm({
|
|
|
3992
4240
|
init_path_guard();
|
|
3993
4241
|
init_runDeps();
|
|
3994
4242
|
init_ledger();
|
|
3995
|
-
ACTIONS = ["start", "complete", "fail", "intent"];
|
|
4243
|
+
ACTIONS = ["start", "complete", "fail", "reopen", "intent"];
|
|
3996
4244
|
}
|
|
3997
4245
|
});
|
|
3998
4246
|
function realProbe(p7) {
|
|
@@ -4053,8 +4301,8 @@ function compute(d) {
|
|
|
4053
4301
|
}
|
|
4054
4302
|
const gitFirst = d.where("git")[0];
|
|
4055
4303
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4056
|
-
const root =
|
|
4057
|
-
for (const cand of [
|
|
4304
|
+
const root = dirname9(dirname9(gitFirst));
|
|
4305
|
+
for (const cand of [join20(root, "bin", "bash.exe"), join20(root, "usr", "bin", "bash.exe")]) {
|
|
4058
4306
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4059
4307
|
}
|
|
4060
4308
|
}
|
|
@@ -4062,13 +4310,13 @@ function compute(d) {
|
|
|
4062
4310
|
d.env.ProgramFiles,
|
|
4063
4311
|
d.env.ProgramW6432,
|
|
4064
4312
|
d.env["ProgramFiles(x86)"],
|
|
4065
|
-
d.env.LOCALAPPDATA ?
|
|
4313
|
+
d.env.LOCALAPPDATA ? join20(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4066
4314
|
];
|
|
4067
4315
|
for (const base of bases) {
|
|
4068
4316
|
if (!base) continue;
|
|
4069
4317
|
for (const cand of [
|
|
4070
|
-
|
|
4071
|
-
|
|
4318
|
+
join20(base, "Git", "bin", "bash.exe"),
|
|
4319
|
+
join20(base, "Git", "usr", "bin", "bash.exe")
|
|
4072
4320
|
]) {
|
|
4073
4321
|
if (d.exists(cand) && usable(cand))
|
|
4074
4322
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4081,10 +4329,10 @@ function compute(d) {
|
|
|
4081
4329
|
}
|
|
4082
4330
|
return { path: "bash", source: "path-fallback" };
|
|
4083
4331
|
}
|
|
4084
|
-
var
|
|
4332
|
+
var dirname9, join20, WSL_STUB_RE, cache2;
|
|
4085
4333
|
var init_resolveBash = __esm({
|
|
4086
4334
|
"src/installers/lib/resolveBash.ts"() {
|
|
4087
|
-
({ dirname:
|
|
4335
|
+
({ dirname: dirname9, join: join20 } = win32);
|
|
4088
4336
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4089
4337
|
cache2 = null;
|
|
4090
4338
|
}
|
|
@@ -4802,7 +5050,7 @@ var check_bun_exports = {};
|
|
|
4802
5050
|
__export(check_bun_exports, {
|
|
4803
5051
|
checkBun: () => checkBun
|
|
4804
5052
|
});
|
|
4805
|
-
function
|
|
5053
|
+
function realRun2(finder) {
|
|
4806
5054
|
try {
|
|
4807
5055
|
if (typeof spawnSync !== "function") return null;
|
|
4808
5056
|
const r = spawnSync(finder, ["bun"], { encoding: "utf8" });
|
|
@@ -4814,7 +5062,7 @@ function realRun(finder) {
|
|
|
4814
5062
|
}
|
|
4815
5063
|
function checkBun(deps) {
|
|
4816
5064
|
const platform = deps?.platform ?? process.platform;
|
|
4817
|
-
const run = deps?.run ??
|
|
5065
|
+
const run = deps?.run ?? realRun2;
|
|
4818
5066
|
const finder = platform === "win32" ? "where" : "which";
|
|
4819
5067
|
const r = run(finder);
|
|
4820
5068
|
if (r && r.status === 0 && r.stdout.trim().length > 0) {
|
|
@@ -5630,6 +5878,62 @@ var init_check_stale_hooks = __esm({
|
|
|
5630
5878
|
}
|
|
5631
5879
|
});
|
|
5632
5880
|
|
|
5881
|
+
// src/cli/lib/probe-chrome-devtools.ts
|
|
5882
|
+
async function probeOne2(fn, onFault) {
|
|
5883
|
+
try {
|
|
5884
|
+
return await fn();
|
|
5885
|
+
} catch {
|
|
5886
|
+
onFault();
|
|
5887
|
+
return false;
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
async function probeChromeDevtools(deps = {}) {
|
|
5891
|
+
const d = { ...DEFAULT_DEPS, ...deps };
|
|
5892
|
+
let unknown = false;
|
|
5893
|
+
const fault = () => {
|
|
5894
|
+
unknown = true;
|
|
5895
|
+
};
|
|
5896
|
+
const ecc = await probeOne2(() => d.pluginRegistered(ECC_PLUGIN_NAME), fault);
|
|
5897
|
+
const standalonePlugin = await probeOne2(() => d.pluginRegistered(CHROME_DEVTOOLS_MCP_NAME), fault);
|
|
5898
|
+
const standaloneStdio = await probeOne2(
|
|
5899
|
+
() => d.mcpServerRegistered(CHROME_DEVTOOLS_MCP_NAME),
|
|
5900
|
+
fault
|
|
5901
|
+
);
|
|
5902
|
+
const providers = [];
|
|
5903
|
+
if (ecc) providers.push("ecc plugin");
|
|
5904
|
+
if (standalonePlugin) providers.push(`${CHROME_DEVTOOLS_MCP_NAME}@claude-plugins-official plugin`);
|
|
5905
|
+
if (standaloneStdio) providers.push(`${CHROME_DEVTOOLS_MCP_NAME} stdio MCP server`);
|
|
5906
|
+
return { ecc, standalonePlugin, standaloneStdio, unknown, providers };
|
|
5907
|
+
}
|
|
5908
|
+
function chromeDevtoolsAvailable(p7) {
|
|
5909
|
+
return p7.providers.length > 0 || p7.unknown;
|
|
5910
|
+
}
|
|
5911
|
+
async function isChromeDevtoolsAvailable(deps) {
|
|
5912
|
+
return chromeDevtoolsAvailable(await probeChromeDevtools(deps));
|
|
5913
|
+
}
|
|
5914
|
+
function chromeDevtoolsFactSource(p7) {
|
|
5915
|
+
if (p7.providers.length > 0) {
|
|
5916
|
+
return `chrome-devtools provider registered: ${p7.providers.join(" + ")}`;
|
|
5917
|
+
}
|
|
5918
|
+
if (p7.unknown) {
|
|
5919
|
+
return `chrome-devtools provider probe FAULTED (unreadable plugin registry / MCP config) \u2014 availability unknown, reported true so the perf / a11y / memory diagnostic lane is never silently deleted (ADR-0029 fail-soft). To make it definite, ${CHROME_DEVTOOLS_ENABLE_PATHS}`;
|
|
5920
|
+
}
|
|
5921
|
+
return `NO chrome-devtools provider registered \u2014 the verify-qa \`05-perf-a11y-diagnostic\` lane (perf / a11y / memory, judgments.web-testing-routing.chrome-devtools-mcp-diagnostic.fires) will NOT run. To turn it on, ${CHROME_DEVTOOLS_ENABLE_PATHS}`;
|
|
5922
|
+
}
|
|
5923
|
+
var CHROME_DEVTOOLS_MCP_NAME, ECC_PLUGIN_NAME, CHROME_DEVTOOLS_ENABLE_PATHS, DEFAULT_DEPS;
|
|
5924
|
+
var init_probe_chrome_devtools = __esm({
|
|
5925
|
+
"src/cli/lib/probe-chrome-devtools.ts"() {
|
|
5926
|
+
init_readClaudeConfig();
|
|
5927
|
+
CHROME_DEVTOOLS_MCP_NAME = "chrome-devtools-mcp";
|
|
5928
|
+
ECC_PLUGIN_NAME = "ecc";
|
|
5929
|
+
CHROME_DEVTOOLS_ENABLE_PATHS = "enable EITHER provider: (1) install the ecc plugin (`harnessed install ecc` \u2014 chrome-devtools is its only default MCP connector), OR (2) self-install the standalone server (`claude mcp add chrome-devtools-mcp`, manifests/optional/chrome-devtools-mcp.yaml). Install exactly ONE \u2014 both at once creates same-name dual-prefix tool-call ambiguity (the doctor `ecc` check warns on the leftover).";
|
|
5930
|
+
DEFAULT_DEPS = {
|
|
5931
|
+
pluginRegistered: isPluginRegistered,
|
|
5932
|
+
mcpServerRegistered: isMcpServerRegistered
|
|
5933
|
+
};
|
|
5934
|
+
}
|
|
5935
|
+
});
|
|
5936
|
+
|
|
5633
5937
|
// src/cli/lib/check-ecc.ts
|
|
5634
5938
|
var check_ecc_exports = {};
|
|
5635
5939
|
__export(check_ecc_exports, {
|
|
@@ -5644,7 +5948,8 @@ async function pathExists(p7) {
|
|
|
5644
5948
|
}
|
|
5645
5949
|
}
|
|
5646
5950
|
async function checkEcc() {
|
|
5647
|
-
const
|
|
5951
|
+
const cdt = await probeChromeDevtools();
|
|
5952
|
+
const ccInstalled = cdt.ecc;
|
|
5648
5953
|
const codexHome = join(homedir(), ".codex");
|
|
5649
5954
|
const codexPresent = await pathExists(join(codexHome, "config.toml"));
|
|
5650
5955
|
const codexInstalled = codexPresent && await pathExists(join(codexHome, ".cache", "ecc", ".git"));
|
|
@@ -5653,11 +5958,11 @@ async function checkEcc() {
|
|
|
5653
5958
|
if (ccInstalled) {
|
|
5654
5959
|
const leftovers = [];
|
|
5655
5960
|
const fixes = [];
|
|
5656
|
-
if (
|
|
5961
|
+
if (cdt.standalonePlugin) {
|
|
5657
5962
|
leftovers.push("official chrome-devtools-mcp@claude-plugins-official plugin still enabled");
|
|
5658
5963
|
fixes.push("`claude plugin uninstall chrome-devtools-mcp@claude-plugins-official`");
|
|
5659
5964
|
}
|
|
5660
|
-
if (
|
|
5965
|
+
if (cdt.standaloneStdio) {
|
|
5661
5966
|
leftovers.push("chrome-devtools-mcp stdio entry still registered in mcpServers");
|
|
5662
5967
|
fixes.push("`claude mcp remove chrome-devtools-mcp`");
|
|
5663
5968
|
}
|
|
@@ -5671,10 +5976,11 @@ async function checkEcc() {
|
|
|
5671
5976
|
}
|
|
5672
5977
|
}
|
|
5673
5978
|
if (!ccInstalled && !codexInstalled) {
|
|
5979
|
+
const cdtPart = cdt.unknown ? " Separately, the chrome-devtools provider probe FAULTED (unreadable plugin registry / MCP config) \u2014 availability unknown, so the perf / a11y / memory diagnostic lane is left ON (fail-soft)." : cdt.providers.length > 0 ? ` chrome-devtools is still covered by the standalone provider (${cdt.providers.join(" + ")}).` : ` NOTE: chrome-devtools now has ZERO providers, so the perf / a11y / memory diagnostic lane (verify-qa \`05-perf-a11y-diagnostic\`) will not run \u2014 ${CHROME_DEVTOOLS_ENABLE_PATHS}`;
|
|
5674
5980
|
return {
|
|
5675
5981
|
name: NAME2,
|
|
5676
5982
|
status: "pass",
|
|
5677
|
-
message: `not installed (${ccPart}; ${codexPart}) \u2014 optional enhancement: \`harnessed install ecc\` unlocks finer-grained orchestration (per-language review/build expert routing etc.) at a ~20k+ tokens/session static-listing cost (ECC-side scale, not harnessed)`
|
|
5983
|
+
message: `not installed (${ccPart}; ${codexPart}) \u2014 optional enhancement: \`harnessed install ecc\` unlocks finer-grained orchestration (per-language review/build expert routing etc.) at a ~20k+ tokens/session static-listing cost (ECC-side scale, not harnessed).${cdtPart}`
|
|
5678
5984
|
};
|
|
5679
5985
|
}
|
|
5680
5986
|
return {
|
|
@@ -5686,11 +5992,66 @@ async function checkEcc() {
|
|
|
5686
5992
|
var NAME2;
|
|
5687
5993
|
var init_check_ecc = __esm({
|
|
5688
5994
|
"src/cli/lib/check-ecc.ts"() {
|
|
5689
|
-
|
|
5995
|
+
init_probe_chrome_devtools();
|
|
5690
5996
|
NAME2 = "ecc";
|
|
5691
5997
|
}
|
|
5692
5998
|
});
|
|
5693
5999
|
|
|
6000
|
+
// src/cli/lib/check-inject-invalidate.ts
|
|
6001
|
+
var check_inject_invalidate_exports = {};
|
|
6002
|
+
__export(check_inject_invalidate_exports, {
|
|
6003
|
+
checkInjectInvalidate: () => checkInjectInvalidate
|
|
6004
|
+
});
|
|
6005
|
+
function commandsFor(hooks, event) {
|
|
6006
|
+
const arr = hooks?.[event];
|
|
6007
|
+
if (!Array.isArray(arr)) return [];
|
|
6008
|
+
return arr.flatMap((e) => entryCommands(e));
|
|
6009
|
+
}
|
|
6010
|
+
function checkInjectInvalidate(deps) {
|
|
6011
|
+
const settingsPath = deps?.settingsPath ?? getSettingsPath();
|
|
6012
|
+
const readText = deps?.readText ?? ((p7) => {
|
|
6013
|
+
try {
|
|
6014
|
+
return readFileSync(p7, "utf8");
|
|
6015
|
+
} catch {
|
|
6016
|
+
return null;
|
|
6017
|
+
}
|
|
6018
|
+
});
|
|
6019
|
+
const raw = readText(settingsPath);
|
|
6020
|
+
if (raw === null) return { name: NAME3, status: "pass", message: "no settings.json" };
|
|
6021
|
+
let hooks;
|
|
6022
|
+
try {
|
|
6023
|
+
const data = JSON.parse(raw);
|
|
6024
|
+
hooks = data.hooks && typeof data.hooks === "object" ? data.hooks : void 0;
|
|
6025
|
+
} catch {
|
|
6026
|
+
return { name: NAME3, status: "pass", message: "settings.json unreadable \u2014 skipped" };
|
|
6027
|
+
}
|
|
6028
|
+
const isInject = (c) => c.includes("inject-state");
|
|
6029
|
+
const perTurn = commandsFor(hooks, "UserPromptSubmit").some(isInject);
|
|
6030
|
+
if (!perTurn) {
|
|
6031
|
+
return { name: NAME3, status: "pass", message: "per-turn injection not installed" };
|
|
6032
|
+
}
|
|
6033
|
+
const paired = commandsFor(hooks, "SessionStart").some(
|
|
6034
|
+
(c) => isInject(c) && c.includes("--invalidate")
|
|
6035
|
+
);
|
|
6036
|
+
if (paired) {
|
|
6037
|
+
return { name: NAME3, status: "pass", message: "per-turn injection + SessionStart invalidation" };
|
|
6038
|
+
}
|
|
6039
|
+
return {
|
|
6040
|
+
name: NAME3,
|
|
6041
|
+
status: "warn",
|
|
6042
|
+
message: "perturn-inject is installed without its SessionStart invalidation half \u2014 after a compact/clear the delta cache keeps skipping <project-context> for up to HARNESSED_INJECT_REFRESH_TURNS turns",
|
|
6043
|
+
fix: "harnessed install perturn-inject-invalidate"
|
|
6044
|
+
};
|
|
6045
|
+
}
|
|
6046
|
+
var NAME3;
|
|
6047
|
+
var init_check_inject_invalidate = __esm({
|
|
6048
|
+
"src/cli/lib/check-inject-invalidate.ts"() {
|
|
6049
|
+
init_hookEntry();
|
|
6050
|
+
init_platform();
|
|
6051
|
+
NAME3 = "per-turn inject pairing";
|
|
6052
|
+
}
|
|
6053
|
+
});
|
|
6054
|
+
|
|
5694
6055
|
// src/cli/lib/doctor-registry.ts
|
|
5695
6056
|
var CHECKS;
|
|
5696
6057
|
var init_doctor_registry = __esm({
|
|
@@ -5742,7 +6103,11 @@ var init_doctor_registry = __esm({
|
|
|
5742
6103
|
// 4.32.22 — ECC per-harness detect (optional; pass unless CC-side ecc overlaps
|
|
5743
6104
|
// the official chrome-devtools-mcp plugin → warn). CC plugin registry + codex
|
|
5744
6105
|
// sync-clone probed independently.
|
|
5745
|
-
async () => (await Promise.resolve().then(() => (init_check_ecc(), check_ecc_exports))).checkEcc()
|
|
6106
|
+
async () => (await Promise.resolve().then(() => (init_check_ecc(), check_ecc_exports))).checkEcc(),
|
|
6107
|
+
// 4.38.0 — half-installed per-turn injection (warn-only): perturn-inject
|
|
6108
|
+
// without perturn-inject-invalidate keeps skipping <project-context> after a
|
|
6109
|
+
// compact/clear has already dropped the copy it is skipping on behalf of.
|
|
6110
|
+
async () => (await Promise.resolve().then(() => (init_check_inject_invalidate(), check_inject_invalidate_exports))).checkInjectInvalidate()
|
|
5746
6111
|
];
|
|
5747
6112
|
}
|
|
5748
6113
|
});
|
|
@@ -6002,6 +6367,21 @@ function buildDefaultGateContext(task, stage) {
|
|
|
6002
6367
|
// extraction → eval threw undefined-variable → ADR 0029 fail-soft fired the
|
|
6003
6368
|
// 4-specialist multispec team on EVERY verify. Opt-in via --context.
|
|
6004
6369
|
is_critical_release: false,
|
|
6370
|
+
// chrome-devtools MCP provider availability — the BARE identifier read by
|
|
6371
|
+
// judgments.web-testing-routing.chrome-devtools-mcp-diagnostic.fires, so it
|
|
6372
|
+
// MUST be declared here (an absent bare variable throws → ADR-0038
|
|
6373
|
+
// fail-closed would delete the lane on a machine that HAS a provider).
|
|
6374
|
+
//
|
|
6375
|
+
// Seeded TRUE = "unknown", not "measured". This builder is synchronous and
|
|
6376
|
+
// the real answer needs async fs probes (~/.claude/plugins/installed_plugins.json
|
|
6377
|
+
// + the harness mcpServers config), so the honest default is the fail-soft
|
|
6378
|
+
// direction documented in src/cli/lib/probe-chrome-devtools.ts: a value we
|
|
6379
|
+
// could not measure must never silently REMOVE a declared capability
|
|
6380
|
+
// (src/workflow/skipGate.ts invariant). The measured value arrives through
|
|
6381
|
+
// `harnessed facts <master>` (deterministically derived, auto-filled) →
|
|
6382
|
+
// `harnessed gates --context-file`, and through `harnessed run`'s awaited
|
|
6383
|
+
// probe overlay.
|
|
6384
|
+
chrome_devtools_available: true,
|
|
6005
6385
|
phase: {
|
|
6006
6386
|
stage,
|
|
6007
6387
|
// T2.1 OQ2(c) — withdrawn: gated stage-routing.verify-paranoid-critical,
|
|
@@ -6798,57 +7178,6 @@ var init_ccHookAdd2 = __esm({
|
|
|
6798
7178
|
};
|
|
6799
7179
|
}
|
|
6800
7180
|
});
|
|
6801
|
-
function extractVerifyBinary(verifyCmd, fallback) {
|
|
6802
|
-
const token = verifyCmd?.trim().split(/\s+/)[0];
|
|
6803
|
-
if (token && BARE_BIN_RE.test(token) && !NON_COMPONENT_TOKENS.has(token)) return token;
|
|
6804
|
-
if (BARE_BIN_RE.test(fallback) && !NON_COMPONENT_TOKENS.has(fallback)) return fallback;
|
|
6805
|
-
return null;
|
|
6806
|
-
}
|
|
6807
|
-
function realRun2(finder, bin) {
|
|
6808
|
-
try {
|
|
6809
|
-
if (typeof spawnSync !== "function") return null;
|
|
6810
|
-
const r = spawnSync(finder, [bin], { encoding: "utf8" });
|
|
6811
|
-
if (!r || r.error) return null;
|
|
6812
|
-
return { status: r.status, stdout: r.stdout ?? "" };
|
|
6813
|
-
} catch {
|
|
6814
|
-
return null;
|
|
6815
|
-
}
|
|
6816
|
-
}
|
|
6817
|
-
function binaryOnPath(bin, deps) {
|
|
6818
|
-
const platform = process.platform;
|
|
6819
|
-
const run = realRun2;
|
|
6820
|
-
const finder = platform === "win32" ? "where" : "which";
|
|
6821
|
-
const r = run(finder, bin);
|
|
6822
|
-
if (!r || r.status !== 0) return false;
|
|
6823
|
-
return r.stdout.trim().length > 0;
|
|
6824
|
-
}
|
|
6825
|
-
var NON_COMPONENT_TOKENS, BARE_BIN_RE;
|
|
6826
|
-
var init_binaryProbe = __esm({
|
|
6827
|
-
"src/installers/lib/binaryProbe.ts"() {
|
|
6828
|
-
NON_COMPONENT_TOKENS = /* @__PURE__ */ new Set([
|
|
6829
|
-
"test",
|
|
6830
|
-
"grep",
|
|
6831
|
-
"ls",
|
|
6832
|
-
"cat",
|
|
6833
|
-
"echo",
|
|
6834
|
-
"command",
|
|
6835
|
-
"sh",
|
|
6836
|
-
"bash",
|
|
6837
|
-
"[",
|
|
6838
|
-
"npx",
|
|
6839
|
-
"npm",
|
|
6840
|
-
"node",
|
|
6841
|
-
"corepack",
|
|
6842
|
-
"pnpm",
|
|
6843
|
-
"yarn",
|
|
6844
|
-
"bun",
|
|
6845
|
-
"git",
|
|
6846
|
-
"claude",
|
|
6847
|
-
"codex"
|
|
6848
|
-
]);
|
|
6849
|
-
BARE_BIN_RE = /^[A-Za-z0-9][\w.@-]*$/;
|
|
6850
|
-
}
|
|
6851
|
-
});
|
|
6852
7181
|
function evalClause(clause, home) {
|
|
6853
7182
|
const m = clause.match(CLAUSE_RE);
|
|
6854
7183
|
if (!m?.[1] || !m[2]) return null;
|
|
@@ -6999,10 +7328,10 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
6999
7328
|
child.stderr?.setEncoding("utf8").on("data", (chunk) => {
|
|
7000
7329
|
stderr += chunk;
|
|
7001
7330
|
});
|
|
7002
|
-
return await new Promise((
|
|
7331
|
+
return await new Promise((resolve24) => {
|
|
7003
7332
|
const timer = setTimeout(() => {
|
|
7004
7333
|
child.kill("SIGKILL");
|
|
7005
|
-
|
|
7334
|
+
resolve24({
|
|
7006
7335
|
ok: false,
|
|
7007
7336
|
phase: "spawn",
|
|
7008
7337
|
error: {
|
|
@@ -7023,7 +7352,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
7023
7352
|
child.on("error", (err2) => {
|
|
7024
7353
|
clearTimeout(timer);
|
|
7025
7354
|
const bashMissing = triedBash && err2.code === "ENOENT";
|
|
7026
|
-
|
|
7355
|
+
resolve24({
|
|
7027
7356
|
ok: false,
|
|
7028
7357
|
phase: "spawn",
|
|
7029
7358
|
error: {
|
|
@@ -7038,7 +7367,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
7038
7367
|
});
|
|
7039
7368
|
child.on("close", (code) => {
|
|
7040
7369
|
clearTimeout(timer);
|
|
7041
|
-
|
|
7370
|
+
resolve24({ ok: true, exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
7042
7371
|
});
|
|
7043
7372
|
});
|
|
7044
7373
|
}
|
|
@@ -7239,7 +7568,7 @@ var init_idempotent = __esm({
|
|
|
7239
7568
|
}
|
|
7240
7569
|
});
|
|
7241
7570
|
function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
7242
|
-
return new Promise((
|
|
7571
|
+
return new Promise((resolve24) => {
|
|
7243
7572
|
const isWin = process.platform === "win32";
|
|
7244
7573
|
const stdio = ["ignore", "pipe", "pipe"];
|
|
7245
7574
|
const child = isWin ? spawn("cmd.exe", ["/c", bin, ...args], { cwd, windowsHide: true, stdio }) : spawn(bin, args, { cwd, shell: false, stdio });
|
|
@@ -7253,17 +7582,17 @@ function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
|
7253
7582
|
});
|
|
7254
7583
|
const timer = setTimeout(() => {
|
|
7255
7584
|
child.kill("SIGKILL");
|
|
7256
|
-
|
|
7585
|
+
resolve24({ exitCode: -1, stdout: stdout2, stderr: `${stderr}[timeout after ${timeoutMs}ms]` });
|
|
7257
7586
|
}, timeoutMs);
|
|
7258
7587
|
child.on("error", (e) => {
|
|
7259
7588
|
clearTimeout(timer);
|
|
7260
7589
|
const enoent = e.code === "ENOENT";
|
|
7261
7590
|
const msg = enoent && bin === "codex" ? "codex CLI not found on PATH \u2014 install Codex CLI or re-run setup on the claude platform" : e.message;
|
|
7262
|
-
|
|
7591
|
+
resolve24({ exitCode: -1, stdout: stdout2, stderr: `${stderr}${msg}` });
|
|
7263
7592
|
});
|
|
7264
7593
|
child.on("close", (code) => {
|
|
7265
7594
|
clearTimeout(timer);
|
|
7266
|
-
|
|
7595
|
+
resolve24({ exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
7267
7596
|
});
|
|
7268
7597
|
});
|
|
7269
7598
|
}
|
|
@@ -7519,7 +7848,7 @@ var init_packSkillAudit = __esm({
|
|
|
7519
7848
|
}
|
|
7520
7849
|
});
|
|
7521
7850
|
function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
7522
|
-
return new Promise((
|
|
7851
|
+
return new Promise((resolve24) => {
|
|
7523
7852
|
const isWin = process.platform === "win32";
|
|
7524
7853
|
const child = isWin ? spawn("cmd.exe", ["/c", "git", "rev-parse", "HEAD"], { cwd, windowsHide: true }) : spawn("git", ["rev-parse", "HEAD"], { cwd, shell: false });
|
|
7525
7854
|
let stdout2 = "";
|
|
@@ -7528,15 +7857,15 @@ function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
|
7528
7857
|
});
|
|
7529
7858
|
const timer = setTimeout(() => {
|
|
7530
7859
|
child.kill("SIGKILL");
|
|
7531
|
-
|
|
7860
|
+
resolve24({ sha: "", exit: -1 });
|
|
7532
7861
|
}, timeoutMs);
|
|
7533
7862
|
child.on("error", () => {
|
|
7534
7863
|
clearTimeout(timer);
|
|
7535
|
-
|
|
7864
|
+
resolve24({ sha: "", exit: -1 });
|
|
7536
7865
|
});
|
|
7537
7866
|
child.on("close", (code) => {
|
|
7538
7867
|
clearTimeout(timer);
|
|
7539
|
-
|
|
7868
|
+
resolve24({ sha: stdout2.trim(), exit: code ?? -1 });
|
|
7540
7869
|
});
|
|
7541
7870
|
});
|
|
7542
7871
|
}
|
|
@@ -8680,6 +9009,12 @@ function buildWorkflowStateBlock(wf, forward, ledgerAgeMs) {
|
|
|
8680
9009
|
`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.`
|
|
8681
9010
|
);
|
|
8682
9011
|
}
|
|
9012
|
+
const nextEntry = next ? ledger.find((e) => e.sub === next) : void 0;
|
|
9013
|
+
if (nextEntry?.reason && (nextEntry.fail_count ?? 0) > 0) {
|
|
9014
|
+
lines.push(
|
|
9015
|
+
`REOPENED: sub '${next}' was sent back (attempt ${nextEntry.fail_count}${nextEntry.attempt_budget !== void 0 ? `/${nextEntry.attempt_budget}` : ""}) \u2014 ${nextEntry.reason}. Address THAT before re-running it; a repeat of the same attempt burns the budget.`
|
|
9016
|
+
);
|
|
9017
|
+
}
|
|
8683
9018
|
if (!next && forward && (forward.unit.kind === "phase" || forward.unit.kind === "task")) {
|
|
8684
9019
|
const n = forward.remainingPhases;
|
|
8685
9020
|
lines.push(
|
|
@@ -10044,7 +10379,7 @@ function renderHumanTable(records) {
|
|
|
10044
10379
|
}
|
|
10045
10380
|
}
|
|
10046
10381
|
function pipeToJq(filterExpr, lines) {
|
|
10047
|
-
return new Promise((
|
|
10382
|
+
return new Promise((resolve24, reject) => {
|
|
10048
10383
|
const child = spawn("jq", [filterExpr], {
|
|
10049
10384
|
stdio: ["pipe", "inherit", "inherit"],
|
|
10050
10385
|
windowsHide: true
|
|
@@ -10053,12 +10388,12 @@ function pipeToJq(filterExpr, lines) {
|
|
|
10053
10388
|
const e = err2;
|
|
10054
10389
|
if (e.code === "ENOENT") {
|
|
10055
10390
|
console.error(t("audit_log.jq_missing"));
|
|
10056
|
-
|
|
10391
|
+
resolve24(1);
|
|
10057
10392
|
} else {
|
|
10058
10393
|
reject(err2);
|
|
10059
10394
|
}
|
|
10060
10395
|
});
|
|
10061
|
-
child.on("close", (code) =>
|
|
10396
|
+
child.on("close", (code) => resolve24(code ?? 0));
|
|
10062
10397
|
child.stdin.write(lines.join("\n"));
|
|
10063
10398
|
child.stdin.end();
|
|
10064
10399
|
});
|
|
@@ -11012,6 +11347,7 @@ init_runDeps();
|
|
|
11012
11347
|
init_exprBuilder();
|
|
11013
11348
|
init_judgmentResolver();
|
|
11014
11349
|
init_gates();
|
|
11350
|
+
init_probe_chrome_devtools();
|
|
11015
11351
|
var VALID_MASTERS2 = new Set(GATE_MASTERS);
|
|
11016
11352
|
function deriveGitFacts(run) {
|
|
11017
11353
|
let lines = 0;
|
|
@@ -11155,7 +11491,7 @@ function buildFactsEnvelope(master, gatedNames, derived) {
|
|
|
11155
11491
|
usage: `Fill every null in \`facts\` with your honest judgement (leave a fact null to accept harnessed's default), write that object to a file, then run: harnessed gates ${master} --task "<locked spec>" --context-file <path>. The output of this command can be passed back verbatim \u2014 the envelope is unwrapped automatically.`
|
|
11156
11492
|
};
|
|
11157
11493
|
}
|
|
11158
|
-
async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = defaultGitRun) {
|
|
11494
|
+
async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = defaultGitRun, probeCdt = () => probeChromeDevtools()) {
|
|
11159
11495
|
if (!VALID_MASTERS2.has(master)) {
|
|
11160
11496
|
deps.error(
|
|
11161
11497
|
`error: unknown master '${master}'. Expected one of: ${[...GATE_MASTERS].join(", ")}.`
|
|
@@ -11182,6 +11518,7 @@ async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = default
|
|
|
11182
11518
|
return;
|
|
11183
11519
|
}
|
|
11184
11520
|
const git = deriveGitFacts(gitRun);
|
|
11521
|
+
const cdt = await probeCdt();
|
|
11185
11522
|
const derived = {
|
|
11186
11523
|
// `harnessed gates` seeds phase.stage from the master argument, so facts MUST
|
|
11187
11524
|
// report the same thing: deriving a stage from the ledger instead could hand
|
|
@@ -11198,6 +11535,13 @@ async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = default
|
|
|
11198
11535
|
"phase.files_touched": {
|
|
11199
11536
|
value: git.files_touched,
|
|
11200
11537
|
source: "git diff --name-only + --cached --name-only (unique paths; null when no repo / clean tree)"
|
|
11538
|
+
},
|
|
11539
|
+
// Root-flat (bare identifier), sister src/workflow/schema/phaseFactContext.ts.
|
|
11540
|
+
// `source` doubles as the SKIP REASON: when no provider is registered it
|
|
11541
|
+
// names BOTH enable paths, so losing the diagnostic lane is never silent.
|
|
11542
|
+
chrome_devtools_available: {
|
|
11543
|
+
value: chromeDevtoolsAvailable(cdt),
|
|
11544
|
+
source: chromeDevtoolsFactSource(cdt)
|
|
11201
11545
|
}
|
|
11202
11546
|
};
|
|
11203
11547
|
const envelope = buildFactsEnvelope(master, gated, derived);
|
|
@@ -11230,7 +11574,7 @@ init_gc();
|
|
|
11230
11574
|
// src/cli/injectStateCmd.ts
|
|
11231
11575
|
init_assetsRoot();
|
|
11232
11576
|
function registerInjectState(program2) {
|
|
11233
|
-
program2.command("inject-state").description("(internal) per-turn <workflow-state> hook output \u2014 used by the perturn hook").action(async () => {
|
|
11577
|
+
program2.command("inject-state").description("(internal) per-turn <workflow-state> hook output \u2014 used by the perturn hook").option("--invalidate", "(internal) drop the per-session <project-context> delta cache").action(async () => {
|
|
11234
11578
|
try {
|
|
11235
11579
|
const mjs = join(getAssetsRoot(), "bin", "harnessed-inject-state.mjs");
|
|
11236
11580
|
if (!existsSync(mjs)) return;
|
|
@@ -13304,6 +13648,7 @@ function extractMatchedTriggers(userText, overrides) {
|
|
|
13304
13648
|
|
|
13305
13649
|
// src/cli/run.ts
|
|
13306
13650
|
init_gateContext();
|
|
13651
|
+
init_probe_chrome_devtools();
|
|
13307
13652
|
var PACKAGE_ROOT2 = getAssetsRoot();
|
|
13308
13653
|
var WORKFLOWS_DIR2 = join(PACKAGE_ROOT2, "workflows");
|
|
13309
13654
|
var _autoChainCache = null;
|
|
@@ -13361,6 +13706,12 @@ function registerRun(program2) {
|
|
|
13361
13706
|
const stage = name.includes("-") ? name.split("-")[0] ?? "" : name;
|
|
13362
13707
|
const gateContext = {
|
|
13363
13708
|
...buildDefaultGateContext(task, stage),
|
|
13709
|
+
// buildDefaultGateContext is synchronous and can only seed the fail-soft
|
|
13710
|
+
// "unknown = available" default for chrome_devtools_available. This is the
|
|
13711
|
+
// runtime path that actually evaluates the verify/qa phase-05 gate, so
|
|
13712
|
+
// overlay the MEASURED value (never throws; unknown still resolves true —
|
|
13713
|
+
// see src/cli/lib/probe-chrome-devtools.ts).
|
|
13714
|
+
chrome_devtools_available: await isChromeDevtoolsAvailable(),
|
|
13364
13715
|
...raw.model ? { modelOverride: raw.model } : {},
|
|
13365
13716
|
...raw.maxIterations ? { maxIterations: raw.maxIterations } : {},
|
|
13366
13717
|
...raw.staged ? { staged: true } : {},
|
|
@@ -13862,7 +14213,7 @@ var V3_4_3_SIGNATURE_MASTER_RX = /\*\*Preferred path\*\*[\s\S]*dispatch to the p
|
|
|
13862
14213
|
function shouldOverwriteFile(content) {
|
|
13863
14214
|
return HARNESSED_MARKER_RX2.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
|
|
13864
14215
|
}
|
|
13865
|
-
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync,
|
|
14216
|
+
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync23 = (p7) => readFileSync(p7, "utf8")) {
|
|
13866
14217
|
const results = [];
|
|
13867
14218
|
const aggregatedWarnings = /* @__PURE__ */ new Set();
|
|
13868
14219
|
for (const name of slashNames) {
|
|
@@ -13881,7 +14232,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
|
|
|
13881
14232
|
if (fileExists2(path)) {
|
|
13882
14233
|
let existing = "";
|
|
13883
14234
|
try {
|
|
13884
|
-
existing =
|
|
14235
|
+
existing = readFileSync23(path);
|
|
13885
14236
|
} catch {
|
|
13886
14237
|
existing = "";
|
|
13887
14238
|
}
|
|
@@ -14842,6 +15193,19 @@ function extractCloneTarget2(cmd) {
|
|
|
14842
15193
|
}
|
|
14843
15194
|
return dest;
|
|
14844
15195
|
}
|
|
15196
|
+
function hasUncommittedWork(dir) {
|
|
15197
|
+
if (!existsSync(join(dir, ".git"))) return null;
|
|
15198
|
+
try {
|
|
15199
|
+
const status = execFileSync("git", ["status", "--porcelain"], {
|
|
15200
|
+
cwd: dir,
|
|
15201
|
+
encoding: "utf8",
|
|
15202
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
15203
|
+
});
|
|
15204
|
+
return status.trim().length > 0;
|
|
15205
|
+
} catch {
|
|
15206
|
+
return null;
|
|
15207
|
+
}
|
|
15208
|
+
}
|
|
14845
15209
|
var uninstallGitCloneWithSetup = async (ctx) => {
|
|
14846
15210
|
const install = ctx.manifest.spec.install;
|
|
14847
15211
|
if (install.method !== "git-clone-with-setup") {
|
|
@@ -14857,6 +15221,13 @@ var uninstallGitCloneWithSetup = async (ctx) => {
|
|
|
14857
15221
|
error: `git-clone-with-setup cmd missing parseable 'git clone <url> <dest>': '${install.cmd.slice(0, 80)}'`
|
|
14858
15222
|
};
|
|
14859
15223
|
}
|
|
15224
|
+
if (process.env.HARNESSED_FORCE_UNINSTALL !== "1" && hasUncommittedWork(cloneTarget) === true) {
|
|
15225
|
+
return {
|
|
15226
|
+
ok: false,
|
|
15227
|
+
phase: "preflight",
|
|
15228
|
+
error: `'${cloneTarget}' has uncommitted changes \u2014 refusing to delete it. Commit or copy the work out first, then re-run; set HARNESSED_FORCE_UNINSTALL=1 to delete it anyway.`
|
|
15229
|
+
};
|
|
15230
|
+
}
|
|
14860
15231
|
await rm(cloneTarget, { recursive: true, force: true, maxRetries: 3 });
|
|
14861
15232
|
return { ok: true, removedPaths: [cloneTarget] };
|
|
14862
15233
|
};
|
|
@@ -14994,7 +15365,7 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
14994
15365
|
const m = install.cmd.match(/npm\s+(?:install|i)\s+(?:-g\s+)?(\S+)/);
|
|
14995
15366
|
const pkg = m?.[1] ?? ctx.manifest.metadata.upstream.source;
|
|
14996
15367
|
const isWin = process.platform === "win32";
|
|
14997
|
-
const result = await new Promise((
|
|
15368
|
+
const result = await new Promise((resolve24) => {
|
|
14998
15369
|
const child = isWin ? spawn("cmd.exe", ["/c", "npm", "uninstall", "-g", pkg], { windowsHide: true }) : spawn("npm", ["uninstall", "-g", pkg], { shell: false });
|
|
14999
15370
|
let stderr = "";
|
|
15000
15371
|
child.stderr?.setEncoding("utf8").on("data", (c) => {
|
|
@@ -15002,15 +15373,15 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
15002
15373
|
});
|
|
15003
15374
|
const timer = setTimeout(() => {
|
|
15004
15375
|
child.kill("SIGKILL");
|
|
15005
|
-
|
|
15376
|
+
resolve24({ exitCode: -1, stderr: `${stderr}[timeout]` });
|
|
15006
15377
|
}, 3e4);
|
|
15007
15378
|
child.on("error", (e) => {
|
|
15008
15379
|
clearTimeout(timer);
|
|
15009
|
-
|
|
15380
|
+
resolve24({ exitCode: -1, stderr: e.message });
|
|
15010
15381
|
});
|
|
15011
15382
|
child.on("close", (code) => {
|
|
15012
15383
|
clearTimeout(timer);
|
|
15013
|
-
|
|
15384
|
+
resolve24({ exitCode: code ?? -1, stderr });
|
|
15014
15385
|
});
|
|
15015
15386
|
});
|
|
15016
15387
|
if (result.exitCode !== 0) {
|