harnessed 4.22.0 → 4.22.2
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/dist/cli.mjs +455 -95
- 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/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.22.
|
|
41
|
+
version: "4.22.2",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -2290,6 +2290,337 @@ var init_engineHook = __esm({
|
|
|
2290
2290
|
init_template();
|
|
2291
2291
|
}
|
|
2292
2292
|
});
|
|
2293
|
+
function getUserClaudeJsonPath() {
|
|
2294
|
+
return getMcpConfigPath();
|
|
2295
|
+
}
|
|
2296
|
+
async function readUserClaudeJson() {
|
|
2297
|
+
const path = getUserClaudeJsonPath();
|
|
2298
|
+
let raw;
|
|
2299
|
+
try {
|
|
2300
|
+
raw = await readFile(path, "utf8");
|
|
2301
|
+
} catch (err2) {
|
|
2302
|
+
if (err2.code === "ENOENT") return {};
|
|
2303
|
+
throw err2;
|
|
2304
|
+
}
|
|
2305
|
+
try {
|
|
2306
|
+
const parsed = JSON.parse(raw);
|
|
2307
|
+
if (parsed === null || typeof parsed !== "object") return {};
|
|
2308
|
+
return parsed;
|
|
2309
|
+
} catch {
|
|
2310
|
+
return {};
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
function isMcpServerInToml(raw, name) {
|
|
2314
|
+
const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2315
|
+
const re = new RegExp(`^\\s*\\[mcp_servers\\.(?:${esc}|"${esc}"|'${esc}')(?:\\]|\\.)`, "m");
|
|
2316
|
+
return re.test(raw);
|
|
2317
|
+
}
|
|
2318
|
+
async function isMcpServerRegistered(name) {
|
|
2319
|
+
const platform = detectPlatform();
|
|
2320
|
+
if (platform.id === "codex") {
|
|
2321
|
+
let raw;
|
|
2322
|
+
try {
|
|
2323
|
+
raw = await readFile(platform.mcpConfigPath, "utf8");
|
|
2324
|
+
} catch (err2) {
|
|
2325
|
+
if (err2.code === "ENOENT") return false;
|
|
2326
|
+
throw err2;
|
|
2327
|
+
}
|
|
2328
|
+
return isMcpServerInToml(raw, name);
|
|
2329
|
+
}
|
|
2330
|
+
const config = await readUserClaudeJson();
|
|
2331
|
+
const servers = config.mcpServers;
|
|
2332
|
+
if (!servers || typeof servers !== "object") return false;
|
|
2333
|
+
return Object.hasOwn(servers, name);
|
|
2334
|
+
}
|
|
2335
|
+
async function isPluginRegistered(pluginName) {
|
|
2336
|
+
const registryPath = getPluginsRegistry();
|
|
2337
|
+
if (registryPath !== null) {
|
|
2338
|
+
try {
|
|
2339
|
+
const raw = await readFile(registryPath, "utf8");
|
|
2340
|
+
const parsed = JSON.parse(raw);
|
|
2341
|
+
const plugins = parsed.plugins;
|
|
2342
|
+
if (plugins && typeof plugins === "object") {
|
|
2343
|
+
if (Object.hasOwn(plugins, pluginName)) return true;
|
|
2344
|
+
if (Object.keys(plugins).some((k) => k.split("@")[0] === pluginName)) return true;
|
|
2345
|
+
}
|
|
2346
|
+
} catch {
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
for (const path of [getSettingsPath(), getMcpConfigPath()]) {
|
|
2350
|
+
try {
|
|
2351
|
+
const raw = await readFile(path, "utf8");
|
|
2352
|
+
const parsed = JSON.parse(raw);
|
|
2353
|
+
const plugins = parsed.enabledPlugins;
|
|
2354
|
+
if (plugins && typeof plugins === "object") {
|
|
2355
|
+
if (Object.hasOwn(plugins, pluginName)) return true;
|
|
2356
|
+
if (Object.keys(plugins).some((k) => k.split("@")[0] === pluginName)) return true;
|
|
2357
|
+
}
|
|
2358
|
+
} catch {
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
return false;
|
|
2362
|
+
}
|
|
2363
|
+
var init_readClaudeConfig = __esm({
|
|
2364
|
+
"src/installers/lib/readClaudeConfig.ts"() {
|
|
2365
|
+
init_platform();
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
|
|
2369
|
+
// src/cli/lib/guard-exemption.ts
|
|
2370
|
+
var guard_exemption_exports = {};
|
|
2371
|
+
__export(guard_exemption_exports, {
|
|
2372
|
+
MANUAL_FIX_CMD: () => MANUAL_FIX_CMD,
|
|
2373
|
+
PLANNING_GLOB: () => PLANNING_GLOB,
|
|
2374
|
+
applyExemption: () => applyExemption,
|
|
2375
|
+
findGateguardYml: () => findGateguardYml,
|
|
2376
|
+
planExemption: () => planExemption,
|
|
2377
|
+
previewLines: () => previewLines,
|
|
2378
|
+
refusalLines: () => refusalLines,
|
|
2379
|
+
runExemptionFlow: () => runExemptionFlow
|
|
2380
|
+
});
|
|
2381
|
+
function defaultFindDeps() {
|
|
2382
|
+
return {
|
|
2383
|
+
cwd: process.cwd(),
|
|
2384
|
+
home: homedir(),
|
|
2385
|
+
exists: async (p7) => readFile(p7, "utf8").then(
|
|
2386
|
+
() => true,
|
|
2387
|
+
() => false
|
|
2388
|
+
)
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
async function findGateguardYml(deps = {}) {
|
|
2392
|
+
const d = { ...defaultFindDeps(), ...deps };
|
|
2393
|
+
for (const base of [d.cwd, d.home]) {
|
|
2394
|
+
const candidate = join(base, ".gateguard.yml");
|
|
2395
|
+
try {
|
|
2396
|
+
if (await d.exists(candidate)) return candidate;
|
|
2397
|
+
} catch {
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
return null;
|
|
2401
|
+
}
|
|
2402
|
+
function planExemption(raw) {
|
|
2403
|
+
const entryBare = ` - "${PLANNING_GLOB}"`;
|
|
2404
|
+
if (raw.includes(PLANNING_GLOB)) return { action: "skip", insertedLines: [] };
|
|
2405
|
+
const eol = raw.includes("\r\n") ? "\r\n" : "\n";
|
|
2406
|
+
const headerRe = /^(ignore_paths[ \t]*:)[ \t]*$/m;
|
|
2407
|
+
const m = headerRe.exec(raw);
|
|
2408
|
+
if (m && m.index !== void 0) {
|
|
2409
|
+
const headerEnd = m.index + m[0].length;
|
|
2410
|
+
const afterHeader = raw.startsWith(eol, headerEnd) ? headerEnd + eol.length : headerEnd;
|
|
2411
|
+
const newText = raw.slice(0, afterHeader) + entryBare + eol + raw.slice(afterHeader);
|
|
2412
|
+
return { action: "append-entry", newText, insertedLines: [entryBare] };
|
|
2413
|
+
}
|
|
2414
|
+
const sep2 = raw.endsWith(eol) || raw.length === 0 ? "" : eol;
|
|
2415
|
+
const section = `${sep2}${eol}ignore_paths:${eol}${entryBare}${eol}`;
|
|
2416
|
+
return {
|
|
2417
|
+
action: "append-section",
|
|
2418
|
+
newText: raw + section,
|
|
2419
|
+
insertedLines: ["ignore_paths:", entryBare]
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
async function defaultBackup(raw) {
|
|
2423
|
+
const backupRoot = harnessedSubdir("backups");
|
|
2424
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-");
|
|
2425
|
+
const backupPath = join(backupRoot, `gateguard.yml.${ts}.bak`);
|
|
2426
|
+
try {
|
|
2427
|
+
await mkdir(backupRoot, { recursive: true });
|
|
2428
|
+
await writeFile(backupPath, raw, "utf8");
|
|
2429
|
+
return { status: "ok", path: backupPath };
|
|
2430
|
+
} catch (err2) {
|
|
2431
|
+
return { status: "warn", message: `backup ${backupPath} failed: ${err2.message}` };
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
async function defaultWrite(p7, text) {
|
|
2435
|
+
const tmp = join(dirname(p7), `.gateguard.yml.${process.pid}.tmp`);
|
|
2436
|
+
await writeFile(tmp, text, "utf8");
|
|
2437
|
+
await rename(tmp, p7);
|
|
2438
|
+
}
|
|
2439
|
+
function defaultApplyDeps() {
|
|
2440
|
+
return {
|
|
2441
|
+
readFile: (p7) => readFile(p7, "utf8"),
|
|
2442
|
+
writeFile: defaultWrite,
|
|
2443
|
+
backup: defaultBackup
|
|
2444
|
+
};
|
|
2445
|
+
}
|
|
2446
|
+
async function applyExemption(ymlPath, deps = {}) {
|
|
2447
|
+
const d = { ...defaultApplyDeps(), ...deps };
|
|
2448
|
+
try {
|
|
2449
|
+
const raw = await d.readFile(ymlPath);
|
|
2450
|
+
const plan = planExemption(raw);
|
|
2451
|
+
if (plan.action === "skip") return { status: "already" };
|
|
2452
|
+
const bk = await d.backup(raw);
|
|
2453
|
+
if (bk.status === "warn") return { status: "error", message: bk.message };
|
|
2454
|
+
await d.writeFile(ymlPath, plan.newText ?? raw);
|
|
2455
|
+
return { status: "applied", backupPath: bk.path, insertedLines: plan.insertedLines };
|
|
2456
|
+
} catch (err2) {
|
|
2457
|
+
return { status: "error", message: err2.message };
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
function previewLines(plan, ymlPath) {
|
|
2461
|
+
return [
|
|
2462
|
+
`[harnessed] GateGuard \u2194 evidence-guard conflict \u2014 sanctioned fix available:`,
|
|
2463
|
+
` file: ${ymlPath}`,
|
|
2464
|
+
...plan.insertedLines.map((l) => ` + ${l}`),
|
|
2465
|
+
` backup: ${join(harnessedSubdir("backups"), "gateguard.yml.<timestamp>.bak")} (written first)`
|
|
2466
|
+
];
|
|
2467
|
+
}
|
|
2468
|
+
function refusalLines() {
|
|
2469
|
+
return [
|
|
2470
|
+
"",
|
|
2471
|
+
"\u26A0\uFE0F GateGuard exemption NOT applied \u2014 the dual-guard conflict remains:",
|
|
2472
|
+
" \u2022 verify-stage artifacts (code-review-report.md, qa-report.md, security-audit-report.md,",
|
|
2473
|
+
" paranoid-review-report.md, multispec-review-report.md) will be blocked at Write",
|
|
2474
|
+
" \u2022 subagents have no fact-retry channel \u2014 they will rename artifacts and every",
|
|
2475
|
+
" `checkpoint complete` will fail-closed block on the missing contract names",
|
|
2476
|
+
` \u2022 fix anytime: \`${MANUAL_FIX_CMD}\` (or add ".planning/**" to ignore_paths in your GateGuard config)`,
|
|
2477
|
+
" harnessed doctor will keep warning until this is resolved.",
|
|
2478
|
+
""
|
|
2479
|
+
];
|
|
2480
|
+
}
|
|
2481
|
+
async function runExemptionFlow(deps = {}) {
|
|
2482
|
+
const d = {
|
|
2483
|
+
...defaultApplyDeps(),
|
|
2484
|
+
findYml: () => findGateguardYml(),
|
|
2485
|
+
print: (line) => console.error(line),
|
|
2486
|
+
...deps
|
|
2487
|
+
};
|
|
2488
|
+
try {
|
|
2489
|
+
const ymlPath = await d.findYml();
|
|
2490
|
+
if (!ymlPath) return "no-yml";
|
|
2491
|
+
const raw = await d.readFile(ymlPath);
|
|
2492
|
+
const plan = planExemption(raw);
|
|
2493
|
+
if (plan.action === "skip") return "already";
|
|
2494
|
+
for (const line of previewLines(plan, ymlPath)) d.print(line);
|
|
2495
|
+
if (!d.confirm) {
|
|
2496
|
+
d.print(` non-interactive session \u2014 run \`${MANUAL_FIX_CMD}\` to apply this fix.`);
|
|
2497
|
+
return "advised";
|
|
2498
|
+
}
|
|
2499
|
+
const yes = await d.confirm();
|
|
2500
|
+
if (!yes) {
|
|
2501
|
+
for (const line of refusalLines()) d.print(line);
|
|
2502
|
+
return "declined";
|
|
2503
|
+
}
|
|
2504
|
+
const r = await applyExemption(ymlPath, d);
|
|
2505
|
+
if (r.status === "applied") {
|
|
2506
|
+
d.print(`\u2713 [harnessed] exempted "${PLANNING_GLOB}" in ${ymlPath} (backup: ${r.backupPath})`);
|
|
2507
|
+
return "applied";
|
|
2508
|
+
}
|
|
2509
|
+
if (r.status === "already") return "already";
|
|
2510
|
+
d.print(`\u26A0\uFE0F [harnessed] exemption failed: ${r.message} \u2014 apply manually: \`${MANUAL_FIX_CMD}\``);
|
|
2511
|
+
return "error";
|
|
2512
|
+
} catch (err2) {
|
|
2513
|
+
d.print(`\u26A0\uFE0F [harnessed] exemption flow error: ${err2.message}`);
|
|
2514
|
+
return "error";
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
var PLANNING_GLOB, MANUAL_FIX_CMD;
|
|
2518
|
+
var init_guard_exemption = __esm({
|
|
2519
|
+
"src/cli/lib/guard-exemption.ts"() {
|
|
2520
|
+
init_harnessedRoot();
|
|
2521
|
+
PLANNING_GLOB = ".planning/**";
|
|
2522
|
+
MANUAL_FIX_CMD = "harnessed exempt-gateguard";
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2525
|
+
|
|
2526
|
+
// src/cli/lib/check-guard-conflict.ts
|
|
2527
|
+
var check_guard_conflict_exports = {};
|
|
2528
|
+
__export(check_guard_conflict_exports, {
|
|
2529
|
+
GUARD_CONFLICT_ADVICE: () => GUARD_CONFLICT_ADVICE,
|
|
2530
|
+
checkGuardConflict: () => checkGuardConflict,
|
|
2531
|
+
detectGateGuardActive: () => detectGateGuardActive
|
|
2532
|
+
});
|
|
2533
|
+
function defaultDeps() {
|
|
2534
|
+
return {
|
|
2535
|
+
env: process.env,
|
|
2536
|
+
readSettings: async () => {
|
|
2537
|
+
try {
|
|
2538
|
+
return await readFile(getSettingsPath(), "utf8");
|
|
2539
|
+
} catch {
|
|
2540
|
+
return null;
|
|
2541
|
+
}
|
|
2542
|
+
},
|
|
2543
|
+
eccPluginInstalled: async () => {
|
|
2544
|
+
try {
|
|
2545
|
+
return await isPluginRegistered("ecc");
|
|
2546
|
+
} catch {
|
|
2547
|
+
return false;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
async function detectGateGuardActive(deps = {}) {
|
|
2553
|
+
const d = { ...defaultDeps(), ...deps };
|
|
2554
|
+
try {
|
|
2555
|
+
const disabled = (d.env.GATEGUARD_DISABLED ?? "").trim() === "1";
|
|
2556
|
+
const eccEnv = (d.env.ECC_GATEGUARD ?? "").trim().toLowerCase();
|
|
2557
|
+
if (disabled || DISABLE_VALUES.has(eccEnv)) return { active: false, source: null };
|
|
2558
|
+
if (eccEnv.length > 0) return { active: true, source: "env" };
|
|
2559
|
+
const settings = await d.readSettings();
|
|
2560
|
+
if (settings !== null && /gateguard/i.test(settings)) {
|
|
2561
|
+
return { active: true, source: "settings-hooks" };
|
|
2562
|
+
}
|
|
2563
|
+
if (await d.eccPluginInstalled()) return { active: true, source: "ecc-plugin" };
|
|
2564
|
+
return { active: false, source: null };
|
|
2565
|
+
} catch {
|
|
2566
|
+
return { active: false, source: null };
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
async function defaultExemptionProbe() {
|
|
2570
|
+
const { findGateguardYml: findGateguardYml2 } = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
2571
|
+
return {
|
|
2572
|
+
findYml: () => findGateguardYml2(),
|
|
2573
|
+
readFile: (p7) => readFile(p7, "utf8")
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
async function checkGuardConflict(deps = {}, exemption) {
|
|
2577
|
+
const det = await detectGateGuardActive(deps);
|
|
2578
|
+
if (!det.active) {
|
|
2579
|
+
return {
|
|
2580
|
+
name: "guard conflict (GateGuard)",
|
|
2581
|
+
status: "pass",
|
|
2582
|
+
message: "ECC GateGuard not detected \u2014 no dual-guard filename conflict"
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
try {
|
|
2586
|
+
const probe = exemption ?? await defaultExemptionProbe();
|
|
2587
|
+
const ymlPath = await probe.findYml();
|
|
2588
|
+
if (ymlPath) {
|
|
2589
|
+
const { planExemption: planExemption2 } = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
2590
|
+
const plan = planExemption2(await probe.readFile(ymlPath));
|
|
2591
|
+
if (plan.action === "skip") {
|
|
2592
|
+
return {
|
|
2593
|
+
name: "guard conflict (GateGuard)",
|
|
2594
|
+
status: "pass",
|
|
2595
|
+
message: `GateGuard active but .planning/** is exempted in ${ymlPath} \u2014 conflict resolved`
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
return {
|
|
2599
|
+
name: "guard conflict (GateGuard)",
|
|
2600
|
+
status: "warn",
|
|
2601
|
+
message: `ECC GateGuard appears active (via ${det.source}) with ${ymlPath} \u2014 its filename policy collides with harnessed evidence-guard artifact names (findings.md, *-report.md); a sanctioned auto-fix is available`,
|
|
2602
|
+
fix: GUARD_CONFLICT_ADVICE,
|
|
2603
|
+
install_commands: ["harnessed exempt-gateguard"]
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
} catch {
|
|
2607
|
+
}
|
|
2608
|
+
return {
|
|
2609
|
+
name: "guard conflict (GateGuard)",
|
|
2610
|
+
status: "warn",
|
|
2611
|
+
message: `ECC GateGuard appears active (via ${det.source}) \u2014 its filename policy (blocks report/findings/summary/analysis Writes) collides with harnessed evidence-guard artifact names (findings.md, *-report.md); subagents have no fact-retry channel, so \`checkpoint complete\` will fail-closed block`,
|
|
2612
|
+
fix: GUARD_CONFLICT_ADVICE
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
var DISABLE_VALUES, GUARD_CONFLICT_ADVICE;
|
|
2616
|
+
var init_check_guard_conflict = __esm({
|
|
2617
|
+
"src/cli/lib/check-guard-conflict.ts"() {
|
|
2618
|
+
init_platform();
|
|
2619
|
+
init_readClaudeConfig();
|
|
2620
|
+
DISABLE_VALUES = /* @__PURE__ */ new Set(["off", "0", "false", "disabled"]);
|
|
2621
|
+
GUARD_CONFLICT_ADVICE = "options (best first): (1) exempt .planning/ paths in the GateGuard config \u2014 planning docs are the legitimate home of findings.md/*-report.md; (2) set ECC_GATEGUARD=off for harnessed-orchestrated sessions; do NOT blanket `checkpoint complete --force` \u2014 that silently voids the evidence guard.";
|
|
2622
|
+
}
|
|
2623
|
+
});
|
|
2293
2624
|
|
|
2294
2625
|
// src/workflow/interpolate.ts
|
|
2295
2626
|
function interpolate(template, vars) {
|
|
@@ -4336,13 +4667,40 @@ async function checkArtifacts(sub, packageRoot) {
|
|
|
4336
4667
|
const found = [];
|
|
4337
4668
|
const missing = [];
|
|
4338
4669
|
for (const rel of declared) {
|
|
4339
|
-
const abs =
|
|
4340
|
-
|
|
4341
|
-
if (present) found.push({ path: abs, sha256: await hashFile(abs) });
|
|
4670
|
+
const abs = await resolveDeclaredArtifact(cwd, rel);
|
|
4671
|
+
if (abs) found.push({ path: abs, sha256: await hashFile(abs) });
|
|
4342
4672
|
else missing.push(rel);
|
|
4343
4673
|
}
|
|
4344
4674
|
return { status: missing.length === 0 ? "verified" : "missing", found, missing };
|
|
4345
4675
|
}
|
|
4676
|
+
async function resolveDeclaredArtifact(cwd, rel) {
|
|
4677
|
+
const isFileAt = (p7) => stat(p7).then((s) => s.isFile()).catch(() => false);
|
|
4678
|
+
if (/[\\/]/.test(rel)) {
|
|
4679
|
+
const abs = resolve(cwd, rel);
|
|
4680
|
+
return await isFileAt(abs) ? abs : null;
|
|
4681
|
+
}
|
|
4682
|
+
const atRoot = resolve(cwd, rel);
|
|
4683
|
+
if (await isFileAt(atRoot)) return atRoot;
|
|
4684
|
+
for (const base of [resolve(cwd, ".planning", "phases"), resolve(cwd, ".planning")]) {
|
|
4685
|
+
let entries;
|
|
4686
|
+
try {
|
|
4687
|
+
entries = await readdir(base);
|
|
4688
|
+
} catch {
|
|
4689
|
+
continue;
|
|
4690
|
+
}
|
|
4691
|
+
let best = null;
|
|
4692
|
+
for (const entry of entries) {
|
|
4693
|
+
if (base.endsWith(".planning") && entry === "phases") continue;
|
|
4694
|
+
const cand = resolve(base, entry, rel);
|
|
4695
|
+
const st = await stat(cand).catch(() => null);
|
|
4696
|
+
if (st?.isFile() && (!best || st.mtimeMs > best.mtime)) {
|
|
4697
|
+
best = { abs: cand, mtime: st.mtimeMs };
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
if (best) return best.abs;
|
|
4701
|
+
}
|
|
4702
|
+
return null;
|
|
4703
|
+
}
|
|
4346
4704
|
async function checkPlanningSync(cwd, _workflowState) {
|
|
4347
4705
|
const planningDir = resolve(cwd, ".planning");
|
|
4348
4706
|
const hasPlanningDir = await stat(planningDir).then((s) => s.isDirectory()).catch(() => false);
|
|
@@ -4681,7 +5039,7 @@ function realExists(p7) {
|
|
|
4681
5039
|
return false;
|
|
4682
5040
|
}
|
|
4683
5041
|
}
|
|
4684
|
-
function
|
|
5042
|
+
function defaultDeps2() {
|
|
4685
5043
|
return {
|
|
4686
5044
|
platform: process.platform,
|
|
4687
5045
|
env: process.env,
|
|
@@ -4692,7 +5050,7 @@ function defaultDeps() {
|
|
|
4692
5050
|
}
|
|
4693
5051
|
function resolveBash(deps) {
|
|
4694
5052
|
if (cache2) return cache2;
|
|
4695
|
-
cache2 = compute({ ...
|
|
5053
|
+
cache2 = compute({ ...defaultDeps2(), ...deps });
|
|
4696
5054
|
return cache2;
|
|
4697
5055
|
}
|
|
4698
5056
|
function compute(d) {
|
|
@@ -4712,8 +5070,8 @@ function compute(d) {
|
|
|
4712
5070
|
}
|
|
4713
5071
|
const gitFirst = d.where("git")[0];
|
|
4714
5072
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4715
|
-
const root =
|
|
4716
|
-
for (const cand of [
|
|
5073
|
+
const root = dirname9(dirname9(gitFirst));
|
|
5074
|
+
for (const cand of [join20(root, "bin", "bash.exe"), join20(root, "usr", "bin", "bash.exe")]) {
|
|
4717
5075
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4718
5076
|
}
|
|
4719
5077
|
}
|
|
@@ -4721,13 +5079,13 @@ function compute(d) {
|
|
|
4721
5079
|
d.env.ProgramFiles,
|
|
4722
5080
|
d.env.ProgramW6432,
|
|
4723
5081
|
d.env["ProgramFiles(x86)"],
|
|
4724
|
-
d.env.LOCALAPPDATA ?
|
|
5082
|
+
d.env.LOCALAPPDATA ? join20(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4725
5083
|
];
|
|
4726
5084
|
for (const base of bases) {
|
|
4727
5085
|
if (!base) continue;
|
|
4728
5086
|
for (const cand of [
|
|
4729
|
-
|
|
4730
|
-
|
|
5087
|
+
join20(base, "Git", "bin", "bash.exe"),
|
|
5088
|
+
join20(base, "Git", "usr", "bin", "bash.exe")
|
|
4731
5089
|
]) {
|
|
4732
5090
|
if (d.exists(cand) && usable(cand))
|
|
4733
5091
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4740,10 +5098,10 @@ function compute(d) {
|
|
|
4740
5098
|
}
|
|
4741
5099
|
return { path: "bash", source: "path-fallback" };
|
|
4742
5100
|
}
|
|
4743
|
-
var
|
|
5101
|
+
var dirname9, join20, WSL_STUB_RE, cache2;
|
|
4744
5102
|
var init_resolveBash = __esm({
|
|
4745
5103
|
"src/installers/lib/resolveBash.ts"() {
|
|
4746
|
-
({ dirname:
|
|
5104
|
+
({ dirname: dirname9, join: join20 } = win32);
|
|
4747
5105
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4748
5106
|
cache2 = null;
|
|
4749
5107
|
}
|
|
@@ -5302,81 +5660,6 @@ var init_check_mattpocock_skills = __esm({
|
|
|
5302
5660
|
REMEDIATION2 = "install via `npx skills@latest add mattpocock/skills` (or git clone https://github.com/mattpocock/skills ~/.claude/skills/mattpocock-skills); methodology fallback already inline in role-prompts.yaml per v3.6.0 Phase 1 \u2014 install is optional but enables /grill-with-docs /tdd /diagnosing-bugs etc. SlashCommand acceleration";
|
|
5303
5661
|
}
|
|
5304
5662
|
});
|
|
5305
|
-
function getUserClaudeJsonPath() {
|
|
5306
|
-
return getMcpConfigPath();
|
|
5307
|
-
}
|
|
5308
|
-
async function readUserClaudeJson() {
|
|
5309
|
-
const path = getUserClaudeJsonPath();
|
|
5310
|
-
let raw;
|
|
5311
|
-
try {
|
|
5312
|
-
raw = await readFile(path, "utf8");
|
|
5313
|
-
} catch (err2) {
|
|
5314
|
-
if (err2.code === "ENOENT") return {};
|
|
5315
|
-
throw err2;
|
|
5316
|
-
}
|
|
5317
|
-
try {
|
|
5318
|
-
const parsed = JSON.parse(raw);
|
|
5319
|
-
if (parsed === null || typeof parsed !== "object") return {};
|
|
5320
|
-
return parsed;
|
|
5321
|
-
} catch {
|
|
5322
|
-
return {};
|
|
5323
|
-
}
|
|
5324
|
-
}
|
|
5325
|
-
function isMcpServerInToml(raw, name) {
|
|
5326
|
-
const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5327
|
-
const re = new RegExp(`^\\s*\\[mcp_servers\\.(?:${esc}|"${esc}"|'${esc}')(?:\\]|\\.)`, "m");
|
|
5328
|
-
return re.test(raw);
|
|
5329
|
-
}
|
|
5330
|
-
async function isMcpServerRegistered(name) {
|
|
5331
|
-
const platform = detectPlatform();
|
|
5332
|
-
if (platform.id === "codex") {
|
|
5333
|
-
let raw;
|
|
5334
|
-
try {
|
|
5335
|
-
raw = await readFile(platform.mcpConfigPath, "utf8");
|
|
5336
|
-
} catch (err2) {
|
|
5337
|
-
if (err2.code === "ENOENT") return false;
|
|
5338
|
-
throw err2;
|
|
5339
|
-
}
|
|
5340
|
-
return isMcpServerInToml(raw, name);
|
|
5341
|
-
}
|
|
5342
|
-
const config = await readUserClaudeJson();
|
|
5343
|
-
const servers = config.mcpServers;
|
|
5344
|
-
if (!servers || typeof servers !== "object") return false;
|
|
5345
|
-
return Object.hasOwn(servers, name);
|
|
5346
|
-
}
|
|
5347
|
-
async function isPluginRegistered(pluginName) {
|
|
5348
|
-
const registryPath = getPluginsRegistry();
|
|
5349
|
-
if (registryPath !== null) {
|
|
5350
|
-
try {
|
|
5351
|
-
const raw = await readFile(registryPath, "utf8");
|
|
5352
|
-
const parsed = JSON.parse(raw);
|
|
5353
|
-
const plugins = parsed.plugins;
|
|
5354
|
-
if (plugins && typeof plugins === "object") {
|
|
5355
|
-
if (Object.hasOwn(plugins, pluginName)) return true;
|
|
5356
|
-
if (Object.keys(plugins).some((k) => k.split("@")[0] === pluginName)) return true;
|
|
5357
|
-
}
|
|
5358
|
-
} catch {
|
|
5359
|
-
}
|
|
5360
|
-
}
|
|
5361
|
-
for (const path of [getSettingsPath(), getMcpConfigPath()]) {
|
|
5362
|
-
try {
|
|
5363
|
-
const raw = await readFile(path, "utf8");
|
|
5364
|
-
const parsed = JSON.parse(raw);
|
|
5365
|
-
const plugins = parsed.enabledPlugins;
|
|
5366
|
-
if (plugins && typeof plugins === "object") {
|
|
5367
|
-
if (Object.hasOwn(plugins, pluginName)) return true;
|
|
5368
|
-
if (Object.keys(plugins).some((k) => k.split("@")[0] === pluginName)) return true;
|
|
5369
|
-
}
|
|
5370
|
-
} catch {
|
|
5371
|
-
}
|
|
5372
|
-
}
|
|
5373
|
-
return false;
|
|
5374
|
-
}
|
|
5375
|
-
var init_readClaudeConfig = __esm({
|
|
5376
|
-
"src/installers/lib/readClaudeConfig.ts"() {
|
|
5377
|
-
init_platform();
|
|
5378
|
-
}
|
|
5379
|
-
});
|
|
5380
5663
|
|
|
5381
5664
|
// src/cli/lib/check-mcp-availability.ts
|
|
5382
5665
|
var check_mcp_availability_exports = {};
|
|
@@ -5620,6 +5903,9 @@ var init_doctor_registry = __esm({
|
|
|
5620
5903
|
// v4.16.1 T3 — bun presence (warn-only): gstack's upstream setup hard-requires
|
|
5621
5904
|
// bun; missing bun is THE gstack refresh-failure cause on user dogfood machines.
|
|
5622
5905
|
async () => (await Promise.resolve().then(() => (init_check_bun(), check_bun_exports))).checkBun(),
|
|
5906
|
+
// 4.22.1 T4 — dual-guard conflict (warn-only): ECC GateGuard's filename policy
|
|
5907
|
+
// vs evidence-guard artifact contract names (subagents cannot fact-retry).
|
|
5908
|
+
async () => (await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports))).checkGuardConflict(),
|
|
5623
5909
|
// Phase 20 — "update available" version check ('warn' only when behind; 'pass'
|
|
5624
5910
|
// when current/ahead/npm-unreachable — fail-soft, never flips the summary).
|
|
5625
5911
|
async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate()
|
|
@@ -7964,7 +8250,7 @@ var release_preflight_exports = {};
|
|
|
7964
8250
|
__export(release_preflight_exports, {
|
|
7965
8251
|
anyFailed: () => anyFailed,
|
|
7966
8252
|
collectPreflight: () => collectPreflight,
|
|
7967
|
-
defaultDeps: () =>
|
|
8253
|
+
defaultDeps: () => defaultDeps3
|
|
7968
8254
|
});
|
|
7969
8255
|
function unreleasedSection(changelog) {
|
|
7970
8256
|
const start = changelog.indexOf("## [Unreleased]");
|
|
@@ -8019,7 +8305,7 @@ function collectPreflight(deps) {
|
|
|
8019
8305
|
function anyFailed(checks) {
|
|
8020
8306
|
return checks.some((c) => c.status === "fail");
|
|
8021
8307
|
}
|
|
8022
|
-
function
|
|
8308
|
+
function defaultDeps3(cwd) {
|
|
8023
8309
|
let changelog = "";
|
|
8024
8310
|
let version = "";
|
|
8025
8311
|
try {
|
|
@@ -8903,6 +9189,54 @@ function registerCheckpoint(program2) {
|
|
|
8903
9189
|
}
|
|
8904
9190
|
const { activatePhase: activatePhase2, completePhase: completePhase2 } = await Promise.resolve().then(() => (init_engineHook(), engineHook_exports));
|
|
8905
9191
|
if (action === "start") {
|
|
9192
|
+
try {
|
|
9193
|
+
const { stat: statFs } = await import('fs/promises');
|
|
9194
|
+
const { resolve: resolvePath } = await import('path');
|
|
9195
|
+
const planningDir = resolvePath(process.cwd(), ".planning");
|
|
9196
|
+
const hasPlanning = await statFs(planningDir).then((s) => s.isDirectory()).catch(() => false);
|
|
9197
|
+
if (hasPlanning) {
|
|
9198
|
+
const missing = [];
|
|
9199
|
+
for (const f of ["STATE.md", "ROADMAP.md"]) {
|
|
9200
|
+
const ok = await statFs(resolvePath(planningDir, f)).then((s) => s.isFile()).catch(() => false);
|
|
9201
|
+
if (!ok) missing.push(`.planning/${f}`);
|
|
9202
|
+
}
|
|
9203
|
+
if (missing.length > 0) {
|
|
9204
|
+
console.error(
|
|
9205
|
+
`\u26A0\uFE0F [harnessed] step 0 skeleton missing (${missing.join(", ")}) \u2014 the evidence guard's planning-sync gate will block \`checkpoint complete\`. Create the skeleton first (see the /auto SKILL step 0).`
|
|
9206
|
+
);
|
|
9207
|
+
}
|
|
9208
|
+
}
|
|
9209
|
+
} catch {
|
|
9210
|
+
}
|
|
9211
|
+
try {
|
|
9212
|
+
const { detectGateGuardActive: detectGateGuardActive2, GUARD_CONFLICT_ADVICE: GUARD_CONFLICT_ADVICE2 } = await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports));
|
|
9213
|
+
const det = await detectGateGuardActive2();
|
|
9214
|
+
if (det.active) {
|
|
9215
|
+
const { findGateguardYml: findGateguardYml2, runExemptionFlow: runExemptionFlow2 } = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
9216
|
+
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
9217
|
+
const flowResult = await runExemptionFlow2({
|
|
9218
|
+
findYml: () => findGateguardYml2(),
|
|
9219
|
+
print: (line) => console.error(line),
|
|
9220
|
+
...isTty ? {
|
|
9221
|
+
confirm: async () => {
|
|
9222
|
+
const p7 = await import('@clack/prompts');
|
|
9223
|
+
const ans = await p7.confirm({
|
|
9224
|
+
message: 'Apply the GateGuard exemption now? (appends ".planning/**" to ignore_paths \u2014 backed up first)',
|
|
9225
|
+
initialValue: true
|
|
9226
|
+
// D1 — default YES
|
|
9227
|
+
});
|
|
9228
|
+
return !p7.isCancel(ans) && ans === true;
|
|
9229
|
+
}
|
|
9230
|
+
} : {}
|
|
9231
|
+
});
|
|
9232
|
+
if (flowResult === "no-yml") {
|
|
9233
|
+
console.error(
|
|
9234
|
+
`\u26A0\uFE0F [harnessed] ECC GateGuard appears active (via ${det.source}) \u2014 its filename policy (report/findings/summary/analysis) collides with the evidence-guard artifact names (findings.md, *-report.md); subagent Writes have no fact-retry channel and \`checkpoint complete\` will block. ` + GUARD_CONFLICT_ADVICE2
|
|
9235
|
+
);
|
|
9236
|
+
}
|
|
9237
|
+
}
|
|
9238
|
+
} catch {
|
|
9239
|
+
}
|
|
8906
9240
|
const { checkpointPath } = await activatePhase2(sub);
|
|
8907
9241
|
const plan = await parsePlan(opts.plan);
|
|
8908
9242
|
if (plan) {
|
|
@@ -9094,12 +9428,37 @@ function registerDoctor(program2) {
|
|
|
9094
9428
|
});
|
|
9095
9429
|
}
|
|
9096
9430
|
|
|
9431
|
+
// src/cli/exempt-gateguard.ts
|
|
9432
|
+
init_guard_exemption();
|
|
9433
|
+
function registerExemptGateguard(program2) {
|
|
9434
|
+
program2.command("exempt-gateguard").description(
|
|
9435
|
+
`Add ".planning/**" to GateGuard's ignore_paths (.gateguard.yml) \u2014 resolves the dual-guard filename conflict with the harnessed evidence guard (backup-first, append-only)`
|
|
9436
|
+
).action(async () => {
|
|
9437
|
+
const result = await runExemptionFlow({
|
|
9438
|
+
print: (line) => console.log(line),
|
|
9439
|
+
confirm: async () => true
|
|
9440
|
+
// consent = invocation (see header)
|
|
9441
|
+
});
|
|
9442
|
+
if (result === "already") {
|
|
9443
|
+
console.log(
|
|
9444
|
+
"\u2713 [harnessed] .planning/** is already exempted in .gateguard.yml \u2014 nothing to do."
|
|
9445
|
+
);
|
|
9446
|
+
}
|
|
9447
|
+
if (result === "no-yml") {
|
|
9448
|
+
console.log(
|
|
9449
|
+
"[harnessed] no .gateguard.yml found (project cwd or home). Your GateGuard variant is likely the bundled ecc fact-forcing hook (no filename policy / no config file) or a custom hookify rule. If subagent Writes are being blocked: have the MAIN session perform the artifact writes, or set ECC_GATEGUARD=off for harnessed-orchestrated sessions."
|
|
9450
|
+
);
|
|
9451
|
+
}
|
|
9452
|
+
process.exit(result === "error" ? 1 : 0);
|
|
9453
|
+
});
|
|
9454
|
+
}
|
|
9455
|
+
|
|
9097
9456
|
// src/cli/gates.ts
|
|
9098
9457
|
init_path_guard();
|
|
9099
9458
|
init_judgmentResolver();
|
|
9100
9459
|
init_assetsRoot();
|
|
9101
9460
|
init_gateContext();
|
|
9102
|
-
var VALID_MASTERS = /* @__PURE__ */ new Set(["auto", "discuss", "plan", "task", "verify"]);
|
|
9461
|
+
var VALID_MASTERS = /* @__PURE__ */ new Set(["auto", "discuss", "plan", "task", "verify", "ship"]);
|
|
9103
9462
|
var STAGE_MASTERS = /* @__PURE__ */ new Set(["discuss", "plan", "task", "verify"]);
|
|
9104
9463
|
var PARALLELISM_GATE = "judgments.parallelism-gate.agent-teams-upgrade.fires";
|
|
9105
9464
|
function resolveMasterYamlPath2(master, packageRoot) {
|
|
@@ -9108,7 +9467,7 @@ function resolveMasterYamlPath2(master, packageRoot) {
|
|
|
9108
9467
|
function registerGates(program2) {
|
|
9109
9468
|
program2.command("gates").description(
|
|
9110
9469
|
"Evaluate which sub-workflows fire for a master orchestrator (JSON plan, no spawn)."
|
|
9111
|
-
).argument("<master>", "master name: auto | discuss | plan | task | verify").option("--task <text>", "task description (injected as gateContext.task)").option(
|
|
9470
|
+
).argument("<master>", "master name: auto | discuss | plan | task | verify | ship").option("--task <text>", "task description (injected as gateContext.task)").option(
|
|
9112
9471
|
"--skip-sub <names>",
|
|
9113
9472
|
"sub names to skip without gate eval (repeatable and/or comma-separated)",
|
|
9114
9473
|
(v, prev) => [...prev, v],
|
|
@@ -9116,7 +9475,7 @@ function registerGates(program2) {
|
|
|
9116
9475
|
).option("--context <json>", "JSON object merged over the default gate context").action(async (master, raw) => {
|
|
9117
9476
|
if (!VALID_MASTERS.has(master)) {
|
|
9118
9477
|
console.error(
|
|
9119
|
-
`error: unknown master '${master}'. Expected one of: auto, discuss, plan, task, verify.`
|
|
9478
|
+
`error: unknown master '${master}'. Expected one of: auto, discuss, plan, task, verify, ship.`
|
|
9120
9479
|
);
|
|
9121
9480
|
process.exit(1);
|
|
9122
9481
|
return;
|
|
@@ -9896,8 +10255,8 @@ function registerReleasePreflight(program2) {
|
|
|
9896
10255
|
program2.command("release-preflight").description(
|
|
9897
10256
|
"Read-only release-readiness gate (CHANGELOG / version / git-clean / tag). Exits 1 if not ready."
|
|
9898
10257
|
).action(async () => {
|
|
9899
|
-
const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps:
|
|
9900
|
-
const checks = collectPreflight2(
|
|
10258
|
+
const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps: defaultDeps4 } = await Promise.resolve().then(() => (init_release_preflight(), release_preflight_exports));
|
|
10259
|
+
const checks = collectPreflight2(defaultDeps4(process.cwd()));
|
|
9901
10260
|
console.log("\n release preflight (read-only \u2014 nothing is pushed/published):\n");
|
|
9902
10261
|
for (const c of checks) {
|
|
9903
10262
|
const mark = c.status === "pass" ? "\u2713" : c.status === "warn" ? "\u26A0" : "\u2717";
|
|
@@ -11674,6 +12033,7 @@ registerAdvance(program);
|
|
|
11674
12033
|
registerReject(program);
|
|
11675
12034
|
registerCompact(program);
|
|
11676
12035
|
registerWorkflows(program);
|
|
12036
|
+
registerExemptGateguard(program);
|
|
11677
12037
|
registerLearn(program);
|
|
11678
12038
|
registerUpdate(program);
|
|
11679
12039
|
registerReleasePreflight(program);
|