harnessed 4.22.2 → 4.23.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 +29 -8
- package/dist/cli.mjs +788 -401
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/schemas/index.mjs +15 -3
- package/dist/schemas/index.mjs.map +1 -1
- package/manifests/skill-packs/design-taste-frontend.yaml +3 -0
- package/manifests/skill-packs/gsd.yaml +4 -0
- package/manifests/skill-packs/gstack.yaml +52 -0
- package/manifests/skill-packs/mattpocock-skills.yaml +25 -0
- package/manifests/skill-packs/ui-ux-pro-max.yaml +3 -0
- package/manifests/tools/playwright-test.yaml +3 -0
- package/package.json +1 -1
- package/schemas/manifest.v1.schema.json +42 -0
- package/workflows/research/SKILL.md +1 -1
- package/workflows/research/SKILL.zh-Hans.md +1 -1
- package/workflows/role-prompts.yaml +3 -2
- package/workflows/role-prompts.zh-Hans.yaml +3 -2
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdir
|
|
|
3
3
|
import { homedir } from 'os';
|
|
4
4
|
import { join, resolve, dirname, sep, win32, relative } from 'path';
|
|
5
5
|
import { Type } from '@sinclair/typebox';
|
|
6
|
-
import { readFile, readdir, unlink, writeFile, stat, rm, cp, mkdir,
|
|
6
|
+
import { readFile, readdir, unlink, writeFile, stat, rm, cp, mkdir, access, rename, appendFile } from 'fs/promises';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
8
8
|
import lockfile from 'proper-lockfile';
|
|
9
9
|
import { parse, LineCounter, parseDocument, isSeq, isScalar } from 'yaml';
|
|
@@ -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.23.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -1204,7 +1204,11 @@ var init_gitCloneWithSetup = __esm({
|
|
|
1204
1204
|
env: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1205
1205
|
args: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
1206
1206
|
git_ref: Type.String({ minLength: 1, pattern: GIT_REF_PATTERN2 }),
|
|
1207
|
-
idempotent_check: Type.String({ minLength: 1 })
|
|
1207
|
+
idempotent_check: Type.String({ minLength: 1 }),
|
|
1208
|
+
// 4.23.0 (issue #3 req 5) — skill names this pack copies into the flat
|
|
1209
|
+
// ~/.claude/skills namespace; enables pre-install collision warnings against
|
|
1210
|
+
// shipped workflow names + post-install undeclared-name drift detection.
|
|
1211
|
+
installs_skills: Type.Optional(Type.Array(Type.String({ minLength: 1 })))
|
|
1208
1212
|
},
|
|
1209
1213
|
{ additionalProperties: false }
|
|
1210
1214
|
);
|
|
@@ -1255,7 +1259,11 @@ var init_npmCli = __esm({
|
|
|
1255
1259
|
env: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1256
1260
|
args: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
1257
1261
|
npm_version: Type.String({ minLength: 1 }),
|
|
1258
|
-
idempotent_check: Type.String({ minLength: 1 })
|
|
1262
|
+
idempotent_check: Type.String({ minLength: 1 }),
|
|
1263
|
+
// 4.23.0 (issue #3 req 5) — skill names this pack copies into the flat
|
|
1264
|
+
// ~/.claude/skills namespace; enables pre-install collision warnings against
|
|
1265
|
+
// shipped workflow names + post-install undeclared-name drift detection.
|
|
1266
|
+
installs_skills: Type.Optional(Type.Array(Type.String({ minLength: 1 })))
|
|
1259
1267
|
},
|
|
1260
1268
|
{ additionalProperties: false }
|
|
1261
1269
|
);
|
|
@@ -1272,7 +1280,11 @@ var init_npxSkillInstaller = __esm({
|
|
|
1272
1280
|
env: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1273
1281
|
args: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
1274
1282
|
npm_version: Type.String({ minLength: 1 }),
|
|
1275
|
-
idempotent_check: Type.String({ minLength: 1 })
|
|
1283
|
+
idempotent_check: Type.String({ minLength: 1 }),
|
|
1284
|
+
// 4.23.0 (issue #3 req 5) — skill names this pack copies into the flat
|
|
1285
|
+
// ~/.claude/skills namespace; enables pre-install collision warnings against
|
|
1286
|
+
// shipped workflow names + post-install undeclared-name drift detection.
|
|
1287
|
+
installs_skills: Type.Optional(Type.Array(Type.String({ minLength: 1 })))
|
|
1276
1288
|
},
|
|
1277
1289
|
{ additionalProperties: false }
|
|
1278
1290
|
);
|
|
@@ -2365,64 +2377,57 @@ var init_readClaudeConfig = __esm({
|
|
|
2365
2377
|
init_platform();
|
|
2366
2378
|
}
|
|
2367
2379
|
});
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
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 {
|
|
2380
|
+
async function mergeSettingsEnvKey(key, value, opts = {}) {
|
|
2381
|
+
const path = getSettingsPath();
|
|
2382
|
+
let raw;
|
|
2383
|
+
try {
|
|
2384
|
+
raw = await readFile(path, "utf8");
|
|
2385
|
+
} catch (err2) {
|
|
2386
|
+
const code = err2.code;
|
|
2387
|
+
if (code !== "ENOENT") {
|
|
2388
|
+
return { outcome: "warn", message: `read ${path} failed: ${err2.message}` };
|
|
2398
2389
|
}
|
|
2390
|
+
return createFresh(path, key, value);
|
|
2399
2391
|
}
|
|
2400
|
-
|
|
2392
|
+
let data;
|
|
2393
|
+
try {
|
|
2394
|
+
const parsed = JSON.parse(raw);
|
|
2395
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2396
|
+
return { outcome: "warn", message: `${path} is not a JSON object` };
|
|
2397
|
+
}
|
|
2398
|
+
data = parsed;
|
|
2399
|
+
} catch (err2) {
|
|
2400
|
+
return { outcome: "warn", message: `${path} malformed JSON: ${err2.message}` };
|
|
2401
|
+
}
|
|
2402
|
+
const env = data.env ?? {};
|
|
2403
|
+
const existing = env[key];
|
|
2404
|
+
if (typeof existing === "string" && existing.length > 0 && opts.skipIfPresent?.(existing) === true) {
|
|
2405
|
+
return { outcome: "already", path, existing };
|
|
2406
|
+
}
|
|
2407
|
+
const backup2 = await backupOriginal(raw);
|
|
2408
|
+
if (backup2.status === "warn") return { outcome: "warn", message: backup2.message };
|
|
2409
|
+
data.env = { ...env, [key]: value };
|
|
2410
|
+
const writeErr = await atomicWrite(path, `${JSON.stringify(data, null, 2)}
|
|
2411
|
+
`);
|
|
2412
|
+
if (writeErr) return { outcome: "warn", message: writeErr };
|
|
2413
|
+
return { outcome: "merged", path, backupPath: backup2.path };
|
|
2401
2414
|
}
|
|
2402
|
-
function
|
|
2403
|
-
const
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
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
|
-
};
|
|
2415
|
+
async function createFresh(path, key, value) {
|
|
2416
|
+
const data = { env: { [key]: value } };
|
|
2417
|
+
try {
|
|
2418
|
+
await mkdir(dirname(path), { recursive: true });
|
|
2419
|
+
} catch (err2) {
|
|
2420
|
+
return { outcome: "warn", message: `mkdir ~/.claude failed: ${err2.message}` };
|
|
2421
|
+
}
|
|
2422
|
+
const writeErr = await atomicWrite(path, `${JSON.stringify(data, null, 2)}
|
|
2423
|
+
`);
|
|
2424
|
+
if (writeErr) return { outcome: "warn", message: writeErr };
|
|
2425
|
+
return { outcome: "created", path };
|
|
2421
2426
|
}
|
|
2422
|
-
async function
|
|
2427
|
+
async function backupOriginal(raw) {
|
|
2423
2428
|
const backupRoot = harnessedSubdir("backups");
|
|
2424
2429
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-");
|
|
2425
|
-
const backupPath = join(backupRoot, `
|
|
2430
|
+
const backupPath = join(backupRoot, `settings.json.${ts}.bak`);
|
|
2426
2431
|
try {
|
|
2427
2432
|
await mkdir(backupRoot, { recursive: true });
|
|
2428
2433
|
await writeFile(backupPath, raw, "utf8");
|
|
@@ -2431,38 +2436,107 @@ async function defaultBackup(raw) {
|
|
|
2431
2436
|
return { status: "warn", message: `backup ${backupPath} failed: ${err2.message}` };
|
|
2432
2437
|
}
|
|
2433
2438
|
}
|
|
2434
|
-
async function
|
|
2435
|
-
const
|
|
2436
|
-
|
|
2437
|
-
|
|
2439
|
+
async function atomicWrite(path, content) {
|
|
2440
|
+
const tmpPath = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
2441
|
+
try {
|
|
2442
|
+
await writeFile(tmpPath, content, "utf8");
|
|
2443
|
+
await rename(tmpPath, path);
|
|
2444
|
+
return void 0;
|
|
2445
|
+
} catch (err2) {
|
|
2446
|
+
return `write ${path} failed: ${err2.message}`;
|
|
2447
|
+
}
|
|
2438
2448
|
}
|
|
2439
|
-
|
|
2449
|
+
var init_settingsWriter = __esm({
|
|
2450
|
+
"src/cli/lib/settingsWriter.ts"() {
|
|
2451
|
+
init_harnessedRoot();
|
|
2452
|
+
init_platform();
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2455
|
+
|
|
2456
|
+
// src/cli/lib/guard-exemption.ts
|
|
2457
|
+
var guard_exemption_exports = {};
|
|
2458
|
+
__export(guard_exemption_exports, {
|
|
2459
|
+
ECC_UPGRADE_CMD: () => ECC_UPGRADE_CMD,
|
|
2460
|
+
EXEMPT_ENV_KEY: () => EXEMPT_ENV_KEY,
|
|
2461
|
+
MANUAL_FIX_CMD: () => MANUAL_FIX_CMD,
|
|
2462
|
+
PLANNING_GLOB: () => PLANNING_GLOB,
|
|
2463
|
+
applyEnvExemption: () => applyEnvExemption,
|
|
2464
|
+
planEnvExemption: () => planEnvExemption,
|
|
2465
|
+
previewLines: () => previewLines,
|
|
2466
|
+
probeExemptCapability: () => probeExemptCapability,
|
|
2467
|
+
readCurrentEnvValue: () => readCurrentEnvValue,
|
|
2468
|
+
refusalLines: () => refusalLines,
|
|
2469
|
+
runExemptionFlow: () => runExemptionFlow,
|
|
2470
|
+
splitGlobs: () => splitGlobs,
|
|
2471
|
+
upgradeAdviceLines: () => upgradeAdviceLines
|
|
2472
|
+
});
|
|
2473
|
+
function defaultProbeDeps() {
|
|
2440
2474
|
return {
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
backup: defaultBackup
|
|
2475
|
+
registryPath: () => getPluginsRegistry(),
|
|
2476
|
+
readFile: (p7) => readFile(p7, "utf8")
|
|
2444
2477
|
};
|
|
2445
2478
|
}
|
|
2446
|
-
async function
|
|
2447
|
-
const d = { ...
|
|
2479
|
+
async function probeExemptCapability(deps = {}) {
|
|
2480
|
+
const d = { ...defaultProbeDeps(), ...deps };
|
|
2448
2481
|
try {
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
const
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2482
|
+
const registry = d.registryPath();
|
|
2483
|
+
if (registry === null) return "legacy";
|
|
2484
|
+
const parsed = JSON.parse(await d.readFile(registry));
|
|
2485
|
+
const plugins = parsed.plugins ?? {};
|
|
2486
|
+
for (const key of Object.keys(plugins)) {
|
|
2487
|
+
if (key.split("@")[0] !== "ecc") continue;
|
|
2488
|
+
for (const entry of plugins[key] ?? []) {
|
|
2489
|
+
if (!entry.installPath) continue;
|
|
2490
|
+
const hook = join(entry.installPath, "scripts", "hooks", "gateguard-fact-force.js");
|
|
2491
|
+
try {
|
|
2492
|
+
if ((await d.readFile(hook)).includes(EXEMPT_ENV_KEY)) return "env-supported";
|
|
2493
|
+
} catch {
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
return "legacy";
|
|
2498
|
+
} catch {
|
|
2499
|
+
return "legacy";
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
function splitGlobs(value) {
|
|
2503
|
+
return (value ?? "").split(",").map((t2) => t2.trim()).filter((t2) => t2.length > 0);
|
|
2504
|
+
}
|
|
2505
|
+
function planEnvExemption(existing) {
|
|
2506
|
+
const globs = splitGlobs(existing);
|
|
2507
|
+
if (globs.includes(PLANNING_GLOB)) return { action: "skip" };
|
|
2508
|
+
return { action: "set", value: [...globs, PLANNING_GLOB].join(",") };
|
|
2509
|
+
}
|
|
2510
|
+
async function readCurrentEnvValue(deps = {}) {
|
|
2511
|
+
const readSettings = deps.readSettings ?? (async () => {
|
|
2512
|
+
try {
|
|
2513
|
+
return await readFile(getSettingsPath(), "utf8");
|
|
2514
|
+
} catch {
|
|
2515
|
+
return null;
|
|
2516
|
+
}
|
|
2517
|
+
});
|
|
2518
|
+
try {
|
|
2519
|
+
const raw = await readSettings();
|
|
2520
|
+
if (raw === null) return void 0;
|
|
2521
|
+
const parsed = JSON.parse(raw);
|
|
2522
|
+
const v = parsed.env?.[EXEMPT_ENV_KEY];
|
|
2523
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2524
|
+
} catch {
|
|
2525
|
+
return void 0;
|
|
2458
2526
|
}
|
|
2459
2527
|
}
|
|
2460
|
-
function
|
|
2528
|
+
async function applyEnvExemption(value) {
|
|
2529
|
+
return mergeSettingsEnvKey(EXEMPT_ENV_KEY, value, {
|
|
2530
|
+
skipIfPresent: (existing) => splitGlobs(existing).includes(PLANNING_GLOB)
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
function previewLines(existing, newValue) {
|
|
2534
|
+
const change = existing === void 0 ? ` + env.${EXEMPT_ENV_KEY} = "${newValue}"` : ` ~ env.${EXEMPT_ENV_KEY}: "${existing}" \u2192 "${newValue}"`;
|
|
2461
2535
|
return [
|
|
2462
2536
|
`[harnessed] GateGuard \u2194 evidence-guard conflict \u2014 sanctioned fix available:`,
|
|
2463
|
-
` file: ${
|
|
2464
|
-
|
|
2465
|
-
` backup:
|
|
2537
|
+
` file: ${getSettingsPath()}`,
|
|
2538
|
+
change,
|
|
2539
|
+
` backup: settings.json.<timestamp>.bak under the harnessed backups dir (written first)`
|
|
2466
2540
|
];
|
|
2467
2541
|
}
|
|
2468
2542
|
function refusalLines() {
|
|
@@ -2473,25 +2547,40 @@ function refusalLines() {
|
|
|
2473
2547
|
" paranoid-review-report.md, multispec-review-report.md) will be blocked at Write",
|
|
2474
2548
|
" \u2022 subagents have no fact-retry channel \u2014 they will rename artifacts and every",
|
|
2475
2549
|
" `checkpoint complete` will fail-closed block on the missing contract names",
|
|
2476
|
-
` \u2022 fix anytime: \`${MANUAL_FIX_CMD}\` (or
|
|
2550
|
+
` \u2022 fix anytime: \`${MANUAL_FIX_CMD}\` (or set ${EXEMPT_ENV_KEY}="${PLANNING_GLOB}" in your`,
|
|
2551
|
+
" harness settings env yourself)",
|
|
2477
2552
|
" harnessed doctor will keep warning until this is resolved.",
|
|
2478
2553
|
""
|
|
2479
2554
|
];
|
|
2480
2555
|
}
|
|
2556
|
+
function upgradeAdviceLines() {
|
|
2557
|
+
return [
|
|
2558
|
+
`[harnessed] your installed ecc GateGuard predates ${EXEMPT_ENV_KEY} exemption support.`,
|
|
2559
|
+
` upgrade first: \`${ECC_UPGRADE_CMD}\` (restart required), then re-run \`${MANUAL_FIX_CMD}\`.`,
|
|
2560
|
+
" interim: set ECC_GATEGUARD=off for harnessed-orchestrated sessions."
|
|
2561
|
+
];
|
|
2562
|
+
}
|
|
2481
2563
|
async function runExemptionFlow(deps = {}) {
|
|
2482
2564
|
const d = {
|
|
2483
|
-
|
|
2484
|
-
|
|
2565
|
+
probe: () => probeExemptCapability(),
|
|
2566
|
+
readEnvValue: () => readCurrentEnvValue(),
|
|
2567
|
+
merge: (value) => applyEnvExemption(value),
|
|
2568
|
+
supportsEnvWrite: () => detectPlatform().supportsEnvKeyWrite,
|
|
2485
2569
|
print: (line) => console.error(line),
|
|
2486
2570
|
...deps
|
|
2487
2571
|
};
|
|
2488
2572
|
try {
|
|
2489
|
-
|
|
2490
|
-
if (!
|
|
2491
|
-
|
|
2492
|
-
|
|
2573
|
+
if (await d.probe() !== "env-supported") return "not-capable";
|
|
2574
|
+
if (!d.supportsEnvWrite()) {
|
|
2575
|
+
d.print(
|
|
2576
|
+
`[harnessed] this platform's config is not JSON-env writable \u2014 export ${EXEMPT_ENV_KEY}="${PLANNING_GLOB}" in your shell environment instead.`
|
|
2577
|
+
);
|
|
2578
|
+
return "unsupported-platform";
|
|
2579
|
+
}
|
|
2580
|
+
const existing = await d.readEnvValue();
|
|
2581
|
+
const plan = planEnvExemption(existing);
|
|
2493
2582
|
if (plan.action === "skip") return "already";
|
|
2494
|
-
for (const line of previewLines(
|
|
2583
|
+
for (const line of previewLines(existing, plan.value ?? "")) d.print(line);
|
|
2495
2584
|
if (!d.confirm) {
|
|
2496
2585
|
d.print(` non-interactive session \u2014 run \`${MANUAL_FIX_CMD}\` to apply this fix.`);
|
|
2497
2586
|
return "advised";
|
|
@@ -2501,12 +2590,15 @@ async function runExemptionFlow(deps = {}) {
|
|
|
2501
2590
|
for (const line of refusalLines()) d.print(line);
|
|
2502
2591
|
return "declined";
|
|
2503
2592
|
}
|
|
2504
|
-
const r = await
|
|
2505
|
-
if (r.
|
|
2506
|
-
|
|
2593
|
+
const r = await d.merge(plan.value ?? "");
|
|
2594
|
+
if (r.outcome === "created" || r.outcome === "merged") {
|
|
2595
|
+
const backup2 = r.outcome === "merged" ? ` (backup: ${r.backupPath})` : "";
|
|
2596
|
+
d.print(
|
|
2597
|
+
`\u2713 [harnessed] set ${EXEMPT_ENV_KEY}="${plan.value}" in ${r.path}${backup2} \u2014 restart the harness session to pick it up.`
|
|
2598
|
+
);
|
|
2507
2599
|
return "applied";
|
|
2508
2600
|
}
|
|
2509
|
-
if (r.
|
|
2601
|
+
if (r.outcome === "already") return "already";
|
|
2510
2602
|
d.print(`\u26A0\uFE0F [harnessed] exemption failed: ${r.message} \u2014 apply manually: \`${MANUAL_FIX_CMD}\``);
|
|
2511
2603
|
return "error";
|
|
2512
2604
|
} catch (err2) {
|
|
@@ -2514,12 +2606,15 @@ async function runExemptionFlow(deps = {}) {
|
|
|
2514
2606
|
return "error";
|
|
2515
2607
|
}
|
|
2516
2608
|
}
|
|
2517
|
-
var PLANNING_GLOB, MANUAL_FIX_CMD;
|
|
2609
|
+
var PLANNING_GLOB, MANUAL_FIX_CMD, EXEMPT_ENV_KEY, ECC_UPGRADE_CMD;
|
|
2518
2610
|
var init_guard_exemption = __esm({
|
|
2519
2611
|
"src/cli/lib/guard-exemption.ts"() {
|
|
2520
|
-
|
|
2612
|
+
init_platform();
|
|
2613
|
+
init_settingsWriter();
|
|
2521
2614
|
PLANNING_GLOB = ".planning/**";
|
|
2522
2615
|
MANUAL_FIX_CMD = "harnessed exempt-gateguard";
|
|
2616
|
+
EXEMPT_ENV_KEY = "GATEGUARD_EXEMPT_GLOBS";
|
|
2617
|
+
ECC_UPGRADE_CMD = "claude plugin update ecc";
|
|
2523
2618
|
}
|
|
2524
2619
|
});
|
|
2525
2620
|
|
|
@@ -2567,13 +2662,14 @@ async function detectGateGuardActive(deps = {}) {
|
|
|
2567
2662
|
}
|
|
2568
2663
|
}
|
|
2569
2664
|
async function defaultExemptionProbe() {
|
|
2570
|
-
const {
|
|
2665
|
+
const { probeExemptCapability: probeExemptCapability2, readCurrentEnvValue: readCurrentEnvValue2 } = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
2571
2666
|
return {
|
|
2572
|
-
|
|
2573
|
-
|
|
2667
|
+
capability: () => probeExemptCapability2(),
|
|
2668
|
+
currentValue: () => readCurrentEnvValue2()
|
|
2574
2669
|
};
|
|
2575
2670
|
}
|
|
2576
2671
|
async function checkGuardConflict(deps = {}, exemption) {
|
|
2672
|
+
const d = { ...defaultDeps(), ...deps };
|
|
2577
2673
|
const det = await detectGateGuardActive(deps);
|
|
2578
2674
|
if (!det.active) {
|
|
2579
2675
|
return {
|
|
@@ -2584,21 +2680,21 @@ async function checkGuardConflict(deps = {}, exemption) {
|
|
|
2584
2680
|
}
|
|
2585
2681
|
try {
|
|
2586
2682
|
const probe = exemption ?? await defaultExemptionProbe();
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2683
|
+
const { PLANNING_GLOB: PLANNING_GLOB2, splitGlobs: splitGlobs2 } = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
2684
|
+
const persisted = await probe.currentValue();
|
|
2685
|
+
const live = d.env.GATEGUARD_EXEMPT_GLOBS;
|
|
2686
|
+
if (splitGlobs2(persisted).includes(PLANNING_GLOB2) || splitGlobs2(live).includes(PLANNING_GLOB2)) {
|
|
2687
|
+
return {
|
|
2688
|
+
name: "guard conflict (GateGuard)",
|
|
2689
|
+
status: "pass",
|
|
2690
|
+
message: "GateGuard active but .planning/** is exempted via GATEGUARD_EXEMPT_GLOBS \u2014 conflict resolved"
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
if (await probe.capability() === "env-supported") {
|
|
2598
2694
|
return {
|
|
2599
2695
|
name: "guard conflict (GateGuard)",
|
|
2600
2696
|
status: "warn",
|
|
2601
|
-
message: `ECC GateGuard appears active (via ${det.source})
|
|
2697
|
+
message: `ECC GateGuard appears active (via ${det.source}) \u2014 its fact-forcing policy collides with harnessed evidence-guard artifact names (findings.md, *-report.md); a sanctioned env exemption is available (GATEGUARD_EXEMPT_GLOBS)`,
|
|
2602
2698
|
fix: GUARD_CONFLICT_ADVICE,
|
|
2603
2699
|
install_commands: ["harnessed exempt-gateguard"]
|
|
2604
2700
|
};
|
|
@@ -2608,8 +2704,8 @@ async function checkGuardConflict(deps = {}, exemption) {
|
|
|
2608
2704
|
return {
|
|
2609
2705
|
name: "guard conflict (GateGuard)",
|
|
2610
2706
|
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);
|
|
2612
|
-
fix:
|
|
2707
|
+
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); this ecc version predates the GATEGUARD_EXEMPT_GLOBS exemption surface`,
|
|
2708
|
+
fix: "upgrade ecc first: `claude plugin update ecc` (restart required), then run `harnessed exempt-gateguard` to persist the .planning/** exemption; interim: set ECC_GATEGUARD=off for harnessed-orchestrated sessions; do NOT blanket `checkpoint complete --force` \u2014 that silently voids the evidence guard."
|
|
2613
2709
|
};
|
|
2614
2710
|
}
|
|
2615
2711
|
var DISABLE_VALUES, GUARD_CONFLICT_ADVICE;
|
|
@@ -2618,7 +2714,7 @@ var init_check_guard_conflict = __esm({
|
|
|
2618
2714
|
init_platform();
|
|
2619
2715
|
init_readClaudeConfig();
|
|
2620
2716
|
DISABLE_VALUES = /* @__PURE__ */ new Set(["off", "0", "false", "disabled"]);
|
|
2621
|
-
GUARD_CONFLICT_ADVICE =
|
|
2717
|
+
GUARD_CONFLICT_ADVICE = 'options (best first): (1) run `harnessed exempt-gateguard` \u2014 persists GATEGUARD_EXEMPT_GLOBS=".planning/**" into the harness settings env (backed up first; planning dirs are the legitimate home of findings.md/*-report.md); (2) if your ecc predates GATEGUARD_EXEMPT_GLOBS support, upgrade first: `claude plugin update ecc`; (3) interim: set ECC_GATEGUARD=off for harnessed-orchestrated sessions; do NOT blanket `checkpoint complete --force` \u2014 that silently voids the evidence guard.';
|
|
2622
2718
|
}
|
|
2623
2719
|
});
|
|
2624
2720
|
|
|
@@ -5071,7 +5167,7 @@ function compute(d) {
|
|
|
5071
5167
|
const gitFirst = d.where("git")[0];
|
|
5072
5168
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
5073
5169
|
const root = dirname9(dirname9(gitFirst));
|
|
5074
|
-
for (const cand of [
|
|
5170
|
+
for (const cand of [join21(root, "bin", "bash.exe"), join21(root, "usr", "bin", "bash.exe")]) {
|
|
5075
5171
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
5076
5172
|
}
|
|
5077
5173
|
}
|
|
@@ -5079,13 +5175,13 @@ function compute(d) {
|
|
|
5079
5175
|
d.env.ProgramFiles,
|
|
5080
5176
|
d.env.ProgramW6432,
|
|
5081
5177
|
d.env["ProgramFiles(x86)"],
|
|
5082
|
-
d.env.LOCALAPPDATA ?
|
|
5178
|
+
d.env.LOCALAPPDATA ? join21(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
5083
5179
|
];
|
|
5084
5180
|
for (const base of bases) {
|
|
5085
5181
|
if (!base) continue;
|
|
5086
5182
|
for (const cand of [
|
|
5087
|
-
|
|
5088
|
-
|
|
5183
|
+
join21(base, "Git", "bin", "bash.exe"),
|
|
5184
|
+
join21(base, "Git", "usr", "bin", "bash.exe")
|
|
5089
5185
|
]) {
|
|
5090
5186
|
if (d.exists(cand) && usable(cand))
|
|
5091
5187
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -5098,10 +5194,10 @@ function compute(d) {
|
|
|
5098
5194
|
}
|
|
5099
5195
|
return { path: "bash", source: "path-fallback" };
|
|
5100
5196
|
}
|
|
5101
|
-
var dirname9,
|
|
5197
|
+
var dirname9, join21, WSL_STUB_RE, cache2;
|
|
5102
5198
|
var init_resolveBash = __esm({
|
|
5103
5199
|
"src/installers/lib/resolveBash.ts"() {
|
|
5104
|
-
({ dirname: dirname9, join:
|
|
5200
|
+
({ dirname: dirname9, join: join21 } = win32);
|
|
5105
5201
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
5106
5202
|
cache2 = null;
|
|
5107
5203
|
}
|
|
@@ -5792,74 +5888,332 @@ var init_check_bun = __esm({
|
|
|
5792
5888
|
"src/cli/lib/check-bun.ts"() {
|
|
5793
5889
|
}
|
|
5794
5890
|
});
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
if (
|
|
5815
|
-
|
|
5891
|
+
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
5892
|
+
const workflows = [];
|
|
5893
|
+
for (const entry of entries.sort()) {
|
|
5894
|
+
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
5895
|
+
const src = join(workflowsDir, entry);
|
|
5896
|
+
let s;
|
|
5897
|
+
try {
|
|
5898
|
+
s = await stat(src);
|
|
5899
|
+
} catch {
|
|
5900
|
+
continue;
|
|
5901
|
+
}
|
|
5902
|
+
if (!s.isDirectory()) continue;
|
|
5903
|
+
let hasFlatSkill = false;
|
|
5904
|
+
try {
|
|
5905
|
+
await stat(join(src, "SKILL.md"));
|
|
5906
|
+
hasFlatSkill = true;
|
|
5907
|
+
} catch {
|
|
5908
|
+
hasFlatSkill = false;
|
|
5909
|
+
}
|
|
5910
|
+
if (hasFlatSkill) {
|
|
5911
|
+
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
5912
|
+
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
5913
|
+
continue;
|
|
5914
|
+
}
|
|
5915
|
+
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
5916
|
+
continue;
|
|
5917
|
+
}
|
|
5918
|
+
let subEntries;
|
|
5919
|
+
try {
|
|
5920
|
+
subEntries = await readdir(src);
|
|
5921
|
+
} catch {
|
|
5922
|
+
continue;
|
|
5923
|
+
}
|
|
5924
|
+
for (const sub of subEntries.sort()) {
|
|
5925
|
+
const subDir = join(src, sub);
|
|
5926
|
+
let ss;
|
|
5927
|
+
try {
|
|
5928
|
+
ss = await stat(subDir);
|
|
5929
|
+
} catch {
|
|
5930
|
+
continue;
|
|
5931
|
+
}
|
|
5932
|
+
if (!ss.isDirectory()) continue;
|
|
5933
|
+
try {
|
|
5934
|
+
await stat(join(subDir, "SKILL.md"));
|
|
5935
|
+
} catch {
|
|
5936
|
+
continue;
|
|
5937
|
+
}
|
|
5938
|
+
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
5939
|
+
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
5940
|
+
}
|
|
5816
5941
|
}
|
|
5817
|
-
|
|
5818
|
-
if (!a.pre && b.pre) return "ahead";
|
|
5819
|
-
if (a.pre && b.pre && a.pre !== b.pre) return a.pre < b.pre ? "behind" : "ahead";
|
|
5820
|
-
return "current";
|
|
5942
|
+
return { workflows };
|
|
5821
5943
|
}
|
|
5822
|
-
|
|
5823
|
-
|
|
5944
|
+
var FLAT_LEGACY_KEEP, FLAT_TOP_LEVEL_MASTERS, NON_WORKFLOW_DIRS;
|
|
5945
|
+
var init_scan_nested = __esm({
|
|
5946
|
+
"src/cli/lib/scan-nested.ts"() {
|
|
5947
|
+
FLAT_LEGACY_KEEP = /* @__PURE__ */ new Set(["research", "retro", "auto"]);
|
|
5948
|
+
FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
5949
|
+
NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
5950
|
+
}
|
|
5951
|
+
});
|
|
5952
|
+
|
|
5953
|
+
// src/cli/lib/skillIntegrity.ts
|
|
5954
|
+
var skillIntegrity_exports = {};
|
|
5955
|
+
__export(skillIntegrity_exports, {
|
|
5956
|
+
attachCulprits: () => attachCulprits,
|
|
5957
|
+
auditInstalledSkills: () => auditInstalledSkills,
|
|
5958
|
+
buildCulpritIndex: () => buildCulpritIndex,
|
|
5959
|
+
integrityReportLines: () => integrityReportLines,
|
|
5960
|
+
ledgerPath: () => ledgerPath,
|
|
5961
|
+
readHashLedger: () => readHashLedger,
|
|
5962
|
+
recordSkillHashes: () => recordSkillHashes,
|
|
5963
|
+
sha256Of: () => sha256Of
|
|
5964
|
+
});
|
|
5965
|
+
function ledgerPath() {
|
|
5966
|
+
return harnessedFile("skill-hashes.json");
|
|
5824
5967
|
}
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
timeout: 8e3,
|
|
5828
|
-
windowsHide: true
|
|
5829
|
-
});
|
|
5830
|
-
return stdout2;
|
|
5968
|
+
function sha256Of(text) {
|
|
5969
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
5831
5970
|
}
|
|
5832
|
-
async function
|
|
5971
|
+
async function readHashLedger(path = ledgerPath()) {
|
|
5833
5972
|
try {
|
|
5834
|
-
const
|
|
5835
|
-
|
|
5973
|
+
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
5974
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
5975
|
+
return parsed;
|
|
5836
5976
|
} catch {
|
|
5837
5977
|
return null;
|
|
5838
5978
|
}
|
|
5839
5979
|
}
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5980
|
+
async function recordSkillHashes(names, skillsBase, path = ledgerPath(), version = package_default.version) {
|
|
5981
|
+
try {
|
|
5982
|
+
const ledger = await readHashLedger(path) ?? {};
|
|
5983
|
+
const rendered_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
5984
|
+
for (const name of names) {
|
|
5985
|
+
try {
|
|
5986
|
+
const text = await readFile(join(skillsBase, name, "SKILL.md"), "utf8");
|
|
5987
|
+
if (typeof text !== "string") continue;
|
|
5988
|
+
ledger[name] = { sha256: sha256Of(text), version, rendered_at };
|
|
5989
|
+
} catch {
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
5993
|
+
await writeFile(tmp, `${JSON.stringify(ledger, null, 2)}
|
|
5994
|
+
`, "utf8");
|
|
5995
|
+
await rename(tmp, path);
|
|
5996
|
+
} catch {
|
|
5844
5997
|
}
|
|
5845
|
-
}
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
const latest = await fetch();
|
|
5854
|
-
if (!latest) {
|
|
5855
|
-
return { name: "update", status: "pass", message: "update check skipped (npm unreachable)" };
|
|
5998
|
+
}
|
|
5999
|
+
function versionLt(a, b) {
|
|
6000
|
+
const pa = a.split(".").map(Number);
|
|
6001
|
+
const pb = b.split(".").map(Number);
|
|
6002
|
+
for (let i = 0; i < 3; i++) {
|
|
6003
|
+
const x = pa[i] ?? 0;
|
|
6004
|
+
const y = pb[i] ?? 0;
|
|
6005
|
+
if (x !== y) return x < y;
|
|
5856
6006
|
}
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
6007
|
+
return false;
|
|
6008
|
+
}
|
|
6009
|
+
async function auditInstalledSkills(workflows, skillsBase, workflowsDir, opts = {}) {
|
|
6010
|
+
const ledger = opts.ledger !== void 0 ? opts.ledger : await readHashLedger();
|
|
6011
|
+
const out = [];
|
|
6012
|
+
for (const wf of workflows) {
|
|
6013
|
+
let src;
|
|
6014
|
+
try {
|
|
6015
|
+
src = await readFile(join(workflowsDir, wf.relPath, "SKILL.md"), "utf8");
|
|
6016
|
+
} catch {
|
|
6017
|
+
continue;
|
|
6018
|
+
}
|
|
6019
|
+
const srcMarker = typeof src === "string" ? HARNESSED_MARKER_RX2.exec(src) : null;
|
|
6020
|
+
if (!srcMarker) continue;
|
|
6021
|
+
const srcVersion = srcMarker[1] ?? "0.0.0";
|
|
6022
|
+
let installed;
|
|
6023
|
+
try {
|
|
6024
|
+
installed = await readFile(join(skillsBase, wf.name, "SKILL.md"), "utf8");
|
|
6025
|
+
} catch {
|
|
6026
|
+
installed = null;
|
|
6027
|
+
}
|
|
6028
|
+
if (installed === null || typeof installed !== "string") {
|
|
6029
|
+
out.push({ name: wf.name, status: "missing" });
|
|
6030
|
+
continue;
|
|
6031
|
+
}
|
|
6032
|
+
const marker = HARNESSED_MARKER_RX2.exec(installed);
|
|
6033
|
+
if (!marker) {
|
|
6034
|
+
out.push({ name: wf.name, status: "foreign" });
|
|
6035
|
+
continue;
|
|
6036
|
+
}
|
|
6037
|
+
const markerVersion = marker[1] ?? "0.0.0";
|
|
6038
|
+
if (versionLt(markerVersion, srcVersion)) {
|
|
6039
|
+
out.push({ name: wf.name, status: "stale" });
|
|
6040
|
+
continue;
|
|
6041
|
+
}
|
|
6042
|
+
const record = ledger?.[wf.name];
|
|
6043
|
+
if (!record) {
|
|
6044
|
+
out.push({ name: wf.name, status: "stale" });
|
|
6045
|
+
continue;
|
|
6046
|
+
}
|
|
6047
|
+
out.push({
|
|
6048
|
+
name: wf.name,
|
|
6049
|
+
status: sha256Of(installed) === record.sha256 ? "ok" : "tampered"
|
|
6050
|
+
});
|
|
6051
|
+
}
|
|
6052
|
+
return out;
|
|
6053
|
+
}
|
|
6054
|
+
async function buildCulpritIndex(manifestPaths) {
|
|
6055
|
+
const index = /* @__PURE__ */ new Map();
|
|
6056
|
+
for (const p7 of manifestPaths) {
|
|
6057
|
+
try {
|
|
6058
|
+
const parsed = parse(await readFile(p7, "utf8"));
|
|
6059
|
+
const pack = parsed?.metadata?.name;
|
|
6060
|
+
const skills = parsed?.spec?.install?.installs_skills;
|
|
6061
|
+
if (typeof pack !== "string" || !Array.isArray(skills)) continue;
|
|
6062
|
+
for (const s of skills) {
|
|
6063
|
+
if (typeof s === "string" && s.length > 0 && !index.has(s)) index.set(s, pack);
|
|
6064
|
+
}
|
|
6065
|
+
} catch {
|
|
6066
|
+
}
|
|
6067
|
+
}
|
|
6068
|
+
return index;
|
|
6069
|
+
}
|
|
6070
|
+
function attachCulprits(entries, culpritIndex) {
|
|
6071
|
+
return entries.map(
|
|
6072
|
+
(e) => e.status === "foreign" ? { ...e, culprit: culpritIndex.get(e.name) ?? e.culprit } : e
|
|
6073
|
+
);
|
|
6074
|
+
}
|
|
6075
|
+
function integrityReportLines(entries) {
|
|
6076
|
+
const bad = entries.filter((e) => e.status !== "ok");
|
|
6077
|
+
if (bad.length === 0) return [];
|
|
6078
|
+
const lines = [
|
|
6079
|
+
`\u26A0 ${bad.length} harnessed workflow skill(s) are not the shipped version \u2014 the slash command exists but may NOT enter the engine (no intent, no ledger, no evidence guard):`
|
|
6080
|
+
];
|
|
6081
|
+
for (const e of bad) {
|
|
6082
|
+
const why = e.status === "foreign" ? "installed SKILL.md is not harnessed-generated" : e.status === "tampered" ? "modified since install (marker kept, content diverged from the install-time hash)" : e.status === "stale" ? "older install / no install-time hash recorded \u2014 re-run `harnessed setup` to refresh" : "missing";
|
|
6083
|
+
const culprit = e.culprit ? ` \u2014 likely overwritten by pack '${e.culprit}'` : "";
|
|
6084
|
+
lines.push(` ${e.name}: ${why}${culprit}`);
|
|
6085
|
+
}
|
|
6086
|
+
return lines;
|
|
6087
|
+
}
|
|
6088
|
+
var HARNESSED_MARKER_RX2;
|
|
6089
|
+
var init_skillIntegrity = __esm({
|
|
6090
|
+
"src/cli/lib/skillIntegrity.ts"() {
|
|
6091
|
+
init_package();
|
|
6092
|
+
init_harnessedRoot();
|
|
6093
|
+
HARNESSED_MARKER_RX2 = /<!--\s*harnessed-generated:v(\d+\.\d+\.\d+)\s*-->/;
|
|
6094
|
+
}
|
|
6095
|
+
});
|
|
6096
|
+
|
|
6097
|
+
// src/cli/lib/check-skill-integrity.ts
|
|
6098
|
+
var check_skill_integrity_exports = {};
|
|
6099
|
+
__export(check_skill_integrity_exports, {
|
|
6100
|
+
checkSkillIntegrity: () => checkSkillIntegrity
|
|
6101
|
+
});
|
|
6102
|
+
async function checkSkillIntegrity() {
|
|
6103
|
+
const name = "workflow skill integrity";
|
|
6104
|
+
try {
|
|
6105
|
+
const assetsRoot = getAssetsRoot();
|
|
6106
|
+
const workflowsDir = resolve(assetsRoot, "workflows");
|
|
6107
|
+
const entries = await readdir(workflowsDir);
|
|
6108
|
+
const { workflows } = await scanWorkflowsNested(workflowsDir, entries);
|
|
6109
|
+
if (workflows.length === 0) {
|
|
6110
|
+
return { name, status: "pass", message: "no shipped workflows to audit" };
|
|
6111
|
+
}
|
|
6112
|
+
const packsDir = resolve(assetsRoot, "manifests", "skill-packs");
|
|
6113
|
+
let manifestPaths = [];
|
|
6114
|
+
try {
|
|
6115
|
+
manifestPaths = (await readdir(packsDir)).filter((f) => f.endsWith(".yaml")).map((f) => resolve(packsDir, f));
|
|
6116
|
+
} catch {
|
|
6117
|
+
}
|
|
6118
|
+
const audit = attachCulprits(
|
|
6119
|
+
await auditInstalledSkills(workflows, getSkillsDir(), workflowsDir),
|
|
6120
|
+
await buildCulpritIndex(manifestPaths)
|
|
6121
|
+
);
|
|
6122
|
+
const bad = audit.filter((e) => e.status !== "ok");
|
|
6123
|
+
if (bad.length === 0) {
|
|
6124
|
+
return {
|
|
6125
|
+
name,
|
|
6126
|
+
status: "pass",
|
|
6127
|
+
message: `${audit.length} installed workflow skill(s) match their install-time hash ledger`
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
const detail = bad.map((e) => `${e.name} (${e.status}${e.culprit ? `, likely pack '${e.culprit}'` : ""})`).join(", ");
|
|
6131
|
+
return {
|
|
6132
|
+
name,
|
|
6133
|
+
status: "warn",
|
|
6134
|
+
message: `${bad.length} workflow skill(s) diverged from the install-time state (foreign/tampered/stale/missing) \u2014 the slash command may NOT enter the engine: ${detail}`,
|
|
6135
|
+
fix: "re-run `harnessed setup` (its end-of-run integrity pass restores + re-pins the shipped versions)"
|
|
6136
|
+
};
|
|
6137
|
+
} catch {
|
|
6138
|
+
return { name, status: "pass", message: "skipped (environment not auditable)" };
|
|
6139
|
+
}
|
|
6140
|
+
}
|
|
6141
|
+
var init_check_skill_integrity = __esm({
|
|
6142
|
+
"src/cli/lib/check-skill-integrity.ts"() {
|
|
6143
|
+
init_platform();
|
|
6144
|
+
init_assetsRoot();
|
|
6145
|
+
init_scan_nested();
|
|
6146
|
+
init_skillIntegrity();
|
|
6147
|
+
}
|
|
6148
|
+
});
|
|
6149
|
+
|
|
6150
|
+
// src/cli/lib/version-check.ts
|
|
6151
|
+
var version_check_exports = {};
|
|
6152
|
+
__export(version_check_exports, {
|
|
6153
|
+
compareVersions: () => compareVersions,
|
|
6154
|
+
fetchLatestVersion: () => fetchLatestVersion
|
|
6155
|
+
});
|
|
6156
|
+
function parse3(v) {
|
|
6157
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(v.trim());
|
|
6158
|
+
if (!m) return null;
|
|
6159
|
+
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
6160
|
+
}
|
|
6161
|
+
function compareVersions(installed, latest) {
|
|
6162
|
+
const a = parse3(installed);
|
|
6163
|
+
const b = parse3(latest);
|
|
6164
|
+
if (!a || !b) return "unknown";
|
|
6165
|
+
for (let i = 0; i < 3; i++) {
|
|
6166
|
+
const ai = a.nums[i] ?? 0;
|
|
6167
|
+
const bi = b.nums[i] ?? 0;
|
|
6168
|
+
if (ai < bi) return "behind";
|
|
6169
|
+
if (ai > bi) return "ahead";
|
|
6170
|
+
}
|
|
6171
|
+
if (a.pre && !b.pre) return "behind";
|
|
6172
|
+
if (!a.pre && b.pre) return "ahead";
|
|
6173
|
+
if (a.pre && b.pre && a.pre !== b.pre) return a.pre < b.pre ? "behind" : "ahead";
|
|
6174
|
+
return "current";
|
|
6175
|
+
}
|
|
6176
|
+
function npmExecutable() {
|
|
6177
|
+
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
6178
|
+
}
|
|
6179
|
+
async function defaultRunner() {
|
|
6180
|
+
const { stdout: stdout2 } = await execFileAsync(npmExecutable(), ["view", "harnessed", "version"], {
|
|
6181
|
+
timeout: 8e3,
|
|
6182
|
+
windowsHide: true
|
|
6183
|
+
});
|
|
6184
|
+
return stdout2;
|
|
6185
|
+
}
|
|
6186
|
+
async function fetchLatestVersion(runner = defaultRunner) {
|
|
6187
|
+
try {
|
|
6188
|
+
const out = (await runner()).trim();
|
|
6189
|
+
return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(out) ? out : null;
|
|
6190
|
+
} catch {
|
|
6191
|
+
return null;
|
|
6192
|
+
}
|
|
6193
|
+
}
|
|
6194
|
+
var execFileAsync;
|
|
6195
|
+
var init_version_check = __esm({
|
|
6196
|
+
"src/cli/lib/version-check.ts"() {
|
|
6197
|
+
execFileAsync = promisify(execFile);
|
|
6198
|
+
}
|
|
6199
|
+
});
|
|
6200
|
+
|
|
6201
|
+
// src/cli/lib/check-update.ts
|
|
6202
|
+
var check_update_exports = {};
|
|
6203
|
+
__export(check_update_exports, {
|
|
6204
|
+
checkUpdate: () => checkUpdate
|
|
6205
|
+
});
|
|
6206
|
+
async function checkUpdate(installed = package_default.version, fetch = fetchLatestVersion) {
|
|
6207
|
+
const latest = await fetch();
|
|
6208
|
+
if (!latest) {
|
|
6209
|
+
return { name: "update", status: "pass", message: "update check skipped (npm unreachable)" };
|
|
6210
|
+
}
|
|
6211
|
+
if (compareVersions(installed, latest) === "behind") {
|
|
6212
|
+
return {
|
|
6213
|
+
name: "update",
|
|
6214
|
+
status: "warn",
|
|
6215
|
+
message: `update available: ${installed} \u2192 ${latest}`,
|
|
6216
|
+
fix: "run `harnessed update`"
|
|
5863
6217
|
};
|
|
5864
6218
|
}
|
|
5865
6219
|
return { name: "update", status: "pass", message: `up to date (${installed})` };
|
|
@@ -5906,6 +6260,9 @@ var init_doctor_registry = __esm({
|
|
|
5906
6260
|
// 4.22.1 T4 — dual-guard conflict (warn-only): ECC GateGuard's filename policy
|
|
5907
6261
|
// vs evidence-guard artifact contract names (subagents cannot fact-retry).
|
|
5908
6262
|
async () => (await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports))).checkGuardConflict(),
|
|
6263
|
+
// 4.23.0 (issue #3) — installed workflow-skill integrity (warn-only): flat
|
|
6264
|
+
// ~/.claude/skills packs can silently shadow shipped workflows; setup self-heals.
|
|
6265
|
+
async () => (await Promise.resolve().then(() => (init_check_skill_integrity(), check_skill_integrity_exports))).checkSkillIntegrity(),
|
|
5909
6266
|
// Phase 20 — "update available" version check ('warn' only when behind; 'pass'
|
|
5910
6267
|
// when current/ahead/npm-unreachable — fail-soft, never flips the summary).
|
|
5911
6268
|
async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate()
|
|
@@ -6520,10 +6877,10 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
6520
6877
|
child.stderr?.setEncoding("utf8").on("data", (chunk) => {
|
|
6521
6878
|
stderr += chunk;
|
|
6522
6879
|
});
|
|
6523
|
-
return await new Promise((
|
|
6880
|
+
return await new Promise((resolve19) => {
|
|
6524
6881
|
const timer = setTimeout(() => {
|
|
6525
6882
|
child.kill("SIGKILL");
|
|
6526
|
-
|
|
6883
|
+
resolve19({
|
|
6527
6884
|
ok: false,
|
|
6528
6885
|
phase: "spawn",
|
|
6529
6886
|
error: {
|
|
@@ -6544,7 +6901,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
6544
6901
|
child.on("error", (err2) => {
|
|
6545
6902
|
clearTimeout(timer);
|
|
6546
6903
|
const bashMissing = triedBash && err2.code === "ENOENT";
|
|
6547
|
-
|
|
6904
|
+
resolve19({
|
|
6548
6905
|
ok: false,
|
|
6549
6906
|
phase: "spawn",
|
|
6550
6907
|
error: {
|
|
@@ -6559,7 +6916,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
6559
6916
|
});
|
|
6560
6917
|
child.on("close", (code) => {
|
|
6561
6918
|
clearTimeout(timer);
|
|
6562
|
-
|
|
6919
|
+
resolve19({ ok: true, exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
6563
6920
|
});
|
|
6564
6921
|
});
|
|
6565
6922
|
}
|
|
@@ -6760,7 +7117,7 @@ var init_idempotent = __esm({
|
|
|
6760
7117
|
}
|
|
6761
7118
|
});
|
|
6762
7119
|
function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
6763
|
-
return new Promise((
|
|
7120
|
+
return new Promise((resolve19) => {
|
|
6764
7121
|
const isWin = process.platform === "win32";
|
|
6765
7122
|
const stdio = ["ignore", "pipe", "pipe"];
|
|
6766
7123
|
const child = isWin ? spawn("cmd.exe", ["/c", bin, ...args], { cwd, windowsHide: true, stdio }) : spawn(bin, args, { cwd, shell: false, stdio });
|
|
@@ -6774,17 +7131,17 @@ function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
|
6774
7131
|
});
|
|
6775
7132
|
const timer = setTimeout(() => {
|
|
6776
7133
|
child.kill("SIGKILL");
|
|
6777
|
-
|
|
7134
|
+
resolve19({ exitCode: -1, stdout: stdout2, stderr: `${stderr}[timeout after ${timeoutMs}ms]` });
|
|
6778
7135
|
}, timeoutMs);
|
|
6779
7136
|
child.on("error", (e) => {
|
|
6780
7137
|
clearTimeout(timer);
|
|
6781
7138
|
const enoent = e.code === "ENOENT";
|
|
6782
7139
|
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;
|
|
6783
|
-
|
|
7140
|
+
resolve19({ exitCode: -1, stdout: stdout2, stderr: `${stderr}${msg}` });
|
|
6784
7141
|
});
|
|
6785
7142
|
child.on("close", (code) => {
|
|
6786
7143
|
clearTimeout(timer);
|
|
6787
|
-
|
|
7144
|
+
resolve19({ exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
6788
7145
|
});
|
|
6789
7146
|
});
|
|
6790
7147
|
}
|
|
@@ -6970,8 +7327,77 @@ ${newEntry}
|
|
|
6970
7327
|
};
|
|
6971
7328
|
}
|
|
6972
7329
|
});
|
|
7330
|
+
async function snapshotSkillNames(skillsDir = getSkillsDir()) {
|
|
7331
|
+
try {
|
|
7332
|
+
const entries = await readdir(skillsDir, { withFileTypes: true });
|
|
7333
|
+
return new Set(entries.filter((e) => e.isDirectory()).map((e) => e.name));
|
|
7334
|
+
} catch {
|
|
7335
|
+
return /* @__PURE__ */ new Set();
|
|
7336
|
+
}
|
|
7337
|
+
}
|
|
7338
|
+
async function shippedWorkflowNames() {
|
|
7339
|
+
if (workflowNamesCache) return workflowNamesCache;
|
|
7340
|
+
try {
|
|
7341
|
+
const workflowsDir = resolve(getAssetsRoot(), "workflows");
|
|
7342
|
+
const entries = await readdir(workflowsDir);
|
|
7343
|
+
const { workflows } = await scanWorkflowsNested(workflowsDir, entries);
|
|
7344
|
+
workflowNamesCache = new Set(workflows.map((w) => w.name));
|
|
7345
|
+
} catch {
|
|
7346
|
+
workflowNamesCache = /* @__PURE__ */ new Set();
|
|
7347
|
+
}
|
|
7348
|
+
return workflowNamesCache;
|
|
7349
|
+
}
|
|
7350
|
+
function declaredSkills(ctx) {
|
|
7351
|
+
const declared = ctx.manifest.spec.install.installs_skills;
|
|
7352
|
+
return Array.isArray(declared) ? declared.filter((s) => typeof s === "string") : [];
|
|
7353
|
+
}
|
|
7354
|
+
async function warnDeclaredCollisions(ctx) {
|
|
7355
|
+
try {
|
|
7356
|
+
const declared = declaredSkills(ctx);
|
|
7357
|
+
if (declared.length === 0) return;
|
|
7358
|
+
const workflows = await shippedWorkflowNames();
|
|
7359
|
+
const collisions = declared.filter((s) => workflows.has(s));
|
|
7360
|
+
if (collisions.length === 0) return;
|
|
7361
|
+
console.warn(
|
|
7362
|
+
`\u26A0 [${ctx.manifest.metadata.name}] declares skill name(s) colliding with harnessed workflows: ${collisions.join(", ")} \u2014 the pack copy would shadow the engine workflow. Setup's integrity pass will restore the harnessed version; the pack's same-named skill will not be reachable.`
|
|
7363
|
+
);
|
|
7364
|
+
} catch {
|
|
7365
|
+
}
|
|
7366
|
+
}
|
|
7367
|
+
async function auditPostInstall(ctx, before, skillsDir = getSkillsDir()) {
|
|
7368
|
+
try {
|
|
7369
|
+
const after = await snapshotSkillNames(skillsDir);
|
|
7370
|
+
const added = [...after].filter((n) => !before.has(n));
|
|
7371
|
+
if (added.length === 0) return;
|
|
7372
|
+
const declared = new Set(declaredSkills(ctx));
|
|
7373
|
+
const pack = ctx.manifest.metadata.name;
|
|
7374
|
+
const undeclared = added.filter((n) => !declared.has(n));
|
|
7375
|
+
if (declared.size > 0 && undeclared.length > 0) {
|
|
7376
|
+
console.warn(
|
|
7377
|
+
`\u26A0 [${pack}] installed skill name(s) not declared in installs_skills: ${undeclared.join(", ")} \u2014 upstream added skills; update the manifest declaration so collisions stay detectable.`
|
|
7378
|
+
);
|
|
7379
|
+
}
|
|
7380
|
+
const workflows = await shippedWorkflowNames();
|
|
7381
|
+
const collisions = added.filter((n) => workflows.has(n));
|
|
7382
|
+
if (collisions.length > 0) {
|
|
7383
|
+
console.warn(
|
|
7384
|
+
`\u26A0 [${pack}] overwrote harnessed workflow skill(s): ${collisions.join(", ")} \u2014 the engine workflow at that name is now shadowed. Setup's end-of-run integrity pass restores it; re-run \`harnessed setup\` if you installed this pack standalone.`
|
|
7385
|
+
);
|
|
7386
|
+
}
|
|
7387
|
+
} catch {
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7390
|
+
var workflowNamesCache;
|
|
7391
|
+
var init_packSkillAudit = __esm({
|
|
7392
|
+
"src/installers/lib/packSkillAudit.ts"() {
|
|
7393
|
+
init_assetsRoot();
|
|
7394
|
+
init_scan_nested();
|
|
7395
|
+
init_platform();
|
|
7396
|
+
workflowNamesCache = null;
|
|
7397
|
+
}
|
|
7398
|
+
});
|
|
6973
7399
|
function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
6974
|
-
return new Promise((
|
|
7400
|
+
return new Promise((resolve19) => {
|
|
6975
7401
|
const isWin = process.platform === "win32";
|
|
6976
7402
|
const child = isWin ? spawn("cmd.exe", ["/c", "git", "rev-parse", "HEAD"], { cwd, windowsHide: true }) : spawn("git", ["rev-parse", "HEAD"], { cwd, shell: false });
|
|
6977
7403
|
let stdout2 = "";
|
|
@@ -6980,15 +7406,15 @@ function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
|
6980
7406
|
});
|
|
6981
7407
|
const timer = setTimeout(() => {
|
|
6982
7408
|
child.kill("SIGKILL");
|
|
6983
|
-
|
|
7409
|
+
resolve19({ sha: "", exit: -1 });
|
|
6984
7410
|
}, timeoutMs);
|
|
6985
7411
|
child.on("error", () => {
|
|
6986
7412
|
clearTimeout(timer);
|
|
6987
|
-
|
|
7413
|
+
resolve19({ sha: "", exit: -1 });
|
|
6988
7414
|
});
|
|
6989
7415
|
child.on("close", (code) => {
|
|
6990
7416
|
clearTimeout(timer);
|
|
6991
|
-
|
|
7417
|
+
resolve19({ sha: stdout2.trim(), exit: code ?? -1 });
|
|
6992
7418
|
});
|
|
6993
7419
|
});
|
|
6994
7420
|
}
|
|
@@ -7044,6 +7470,7 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
7044
7470
|
init_diff();
|
|
7045
7471
|
init_err();
|
|
7046
7472
|
init_idempotent();
|
|
7473
|
+
init_packSkillAudit();
|
|
7047
7474
|
init_preflight();
|
|
7048
7475
|
init_spawn();
|
|
7049
7476
|
init_state2();
|
|
@@ -7125,6 +7552,8 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
7125
7552
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
7126
7553
|
const bk = await backup(plan, ctx);
|
|
7127
7554
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
7555
|
+
await warnDeclaredCollisions(ctx);
|
|
7556
|
+
const packSnapshot = await snapshotSkillNames();
|
|
7128
7557
|
const sp = await spawnCmd(ctx, install.cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { posixShell: true });
|
|
7129
7558
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7130
7559
|
if (sp.exitCode !== 0) {
|
|
@@ -7141,6 +7570,7 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
7141
7570
|
)
|
|
7142
7571
|
};
|
|
7143
7572
|
}
|
|
7573
|
+
await auditPostInstall(ctx, packSnapshot);
|
|
7144
7574
|
const rp = isSelfCleaningCloneCmd(install.cmd) ? null : await gitRevParseHead(cloneTarget);
|
|
7145
7575
|
if (rp === null) ; else if (rp.exit !== 0 || !rp.sha) {
|
|
7146
7576
|
console.warn(
|
|
@@ -7562,6 +7992,7 @@ var init_npmCli2 = __esm({
|
|
|
7562
7992
|
init_diff();
|
|
7563
7993
|
init_err();
|
|
7564
7994
|
init_idempotent();
|
|
7995
|
+
init_packSkillAudit();
|
|
7565
7996
|
init_preflight();
|
|
7566
7997
|
init_spawn();
|
|
7567
7998
|
init_state2();
|
|
@@ -7624,6 +8055,8 @@ var init_npmCli2 = __esm({
|
|
|
7624
8055
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
7625
8056
|
const bk = await backup(plan, ctx);
|
|
7626
8057
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
8058
|
+
await warnDeclaredCollisions(ctx);
|
|
8059
|
+
const packSnapshot = await snapshotSkillNames();
|
|
7627
8060
|
const sp = await spawnCmd(ctx, cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
|
|
7628
8061
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7629
8062
|
if (sp.exitCode !== 0) {
|
|
@@ -7640,6 +8073,7 @@ var init_npmCli2 = __esm({
|
|
|
7640
8073
|
)
|
|
7641
8074
|
};
|
|
7642
8075
|
}
|
|
8076
|
+
await auditPostInstall(ctx, packSnapshot);
|
|
7643
8077
|
const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
|
|
7644
8078
|
const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
|
|
7645
8079
|
posixShell: true,
|
|
@@ -7674,6 +8108,7 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
7674
8108
|
init_diff();
|
|
7675
8109
|
init_err();
|
|
7676
8110
|
init_idempotent();
|
|
8111
|
+
init_packSkillAudit();
|
|
7677
8112
|
init_platform();
|
|
7678
8113
|
init_preflight();
|
|
7679
8114
|
init_spawn();
|
|
@@ -7752,6 +8187,8 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
7752
8187
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
7753
8188
|
const bk = await backup(plan, ctx);
|
|
7754
8189
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
8190
|
+
await warnDeclaredCollisions(ctx);
|
|
8191
|
+
const packSnapshot = await snapshotSkillNames();
|
|
7755
8192
|
let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
|
|
7756
8193
|
if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
|
|
7757
8194
|
if (HARD_CRASH_EXITS.has(sp.exitCode)) {
|
|
@@ -7773,6 +8210,7 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
7773
8210
|
)
|
|
7774
8211
|
};
|
|
7775
8212
|
}
|
|
8213
|
+
await auditPostInstall(ctx, packSnapshot);
|
|
7776
8214
|
const present = await detectSkillPresence(install.cmd, name);
|
|
7777
8215
|
if (!present) {
|
|
7778
8216
|
return {
|
|
@@ -8060,6 +8498,7 @@ var injectState_exports = {};
|
|
|
8060
8498
|
__export(injectState_exports, {
|
|
8061
8499
|
DEFAULT_INJECT_BUDGET: () => DEFAULT_INJECT_BUDGET,
|
|
8062
8500
|
INTENT_TTL_MS: () => INTENT_TTL_MS,
|
|
8501
|
+
STALE_LEDGER_MS: () => STALE_LEDGER_MS,
|
|
8063
8502
|
buildInjection: () => buildInjection,
|
|
8064
8503
|
buildIntentBlock: () => buildIntentBlock,
|
|
8065
8504
|
buildProjectContextBlock: () => buildProjectContextBlock,
|
|
@@ -8098,7 +8537,7 @@ function buildIntentBlock(intent, nowMs) {
|
|
|
8098
8537
|
"</workflow-intent>"
|
|
8099
8538
|
].join("\n");
|
|
8100
8539
|
}
|
|
8101
|
-
function buildWorkflowStateBlock(wf, forward) {
|
|
8540
|
+
function buildWorkflowStateBlock(wf, forward, ledgerAgeMs) {
|
|
8102
8541
|
if (!wf) return "";
|
|
8103
8542
|
const ledger = wf.sub_progress ?? [];
|
|
8104
8543
|
const next = nextPending(ledger);
|
|
@@ -8109,7 +8548,12 @@ function buildWorkflowStateBlock(wf, forward) {
|
|
|
8109
8548
|
`status: ${wf.status}`,
|
|
8110
8549
|
next ? `next: ${next}` : "next: (none \u2014 all subs resolved)"
|
|
8111
8550
|
];
|
|
8112
|
-
if (next) {
|
|
8551
|
+
if (next && typeof ledgerAgeMs === "number" && ledgerAgeMs > STALE_LEDGER_MS) {
|
|
8552
|
+
const days = Math.floor(ledgerAgeMs / (24 * 60 * 60 * 1e3));
|
|
8553
|
+
lines.push(
|
|
8554
|
+
`ENGINE: STALE state machine \u2014 sub '${next}' has been pending with NO checkpoint activity for >${days}d. This ledger may belong to an abandoned/bypassed run (issue #3 class). Run \`harnessed status --recover\` to re-orient, then either resume the sub or close it out with \`harnessed checkpoint fail ${next} --summary "<why>"\`.`
|
|
8555
|
+
);
|
|
8556
|
+
} else if (next) {
|
|
8113
8557
|
lines.push(
|
|
8114
8558
|
`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.`
|
|
8115
8559
|
);
|
|
@@ -8231,7 +8675,7 @@ function forwardPointer(repoRoot, wf) {
|
|
|
8231
8675
|
if (unit.kind !== "phase" && unit.kind !== "task") return null;
|
|
8232
8676
|
return { unit, remainingPhases: snapshot.phases.filter((p7) => !p7.complete).length };
|
|
8233
8677
|
}
|
|
8234
|
-
var INTENT_TTL_MS, DEFAULT_INJECT_BUDGET, tok;
|
|
8678
|
+
var INTENT_TTL_MS, STALE_LEDGER_MS, DEFAULT_INJECT_BUDGET, tok;
|
|
8235
8679
|
var init_injectState = __esm({
|
|
8236
8680
|
"src/checkpoint/injectState.ts"() {
|
|
8237
8681
|
init_breakLoop();
|
|
@@ -8240,6 +8684,7 @@ var init_injectState = __esm({
|
|
|
8240
8684
|
init_ledger();
|
|
8241
8685
|
init_planningScan();
|
|
8242
8686
|
INTENT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
8687
|
+
STALE_LEDGER_MS = 24 * 60 * 60 * 1e3;
|
|
8243
8688
|
DEFAULT_INJECT_BUDGET = 1500;
|
|
8244
8689
|
tok = (s) => Math.ceil(Buffer.byteLength(s, "utf8") / 4);
|
|
8245
8690
|
}
|
|
@@ -8983,7 +9428,7 @@ function renderHumanTable(records) {
|
|
|
8983
9428
|
}
|
|
8984
9429
|
}
|
|
8985
9430
|
function pipeToJq(filterExpr, lines) {
|
|
8986
|
-
return new Promise((
|
|
9431
|
+
return new Promise((resolve19, reject) => {
|
|
8987
9432
|
const child = spawn("jq", [filterExpr], {
|
|
8988
9433
|
stdio: ["pipe", "inherit", "inherit"],
|
|
8989
9434
|
windowsHide: true
|
|
@@ -8992,12 +9437,12 @@ function pipeToJq(filterExpr, lines) {
|
|
|
8992
9437
|
const e = err2;
|
|
8993
9438
|
if (e.code === "ENOENT") {
|
|
8994
9439
|
console.error(t("audit_log.jq_missing"));
|
|
8995
|
-
|
|
9440
|
+
resolve19(1);
|
|
8996
9441
|
} else {
|
|
8997
9442
|
reject(err2);
|
|
8998
9443
|
}
|
|
8999
9444
|
});
|
|
9000
|
-
child.on("close", (code) =>
|
|
9445
|
+
child.on("close", (code) => resolve19(code ?? 0));
|
|
9001
9446
|
child.stdin.write(lines.join("\n"));
|
|
9002
9447
|
child.stdin.end();
|
|
9003
9448
|
});
|
|
@@ -9212,16 +9657,18 @@ function registerCheckpoint(program2) {
|
|
|
9212
9657
|
const { detectGateGuardActive: detectGateGuardActive2, GUARD_CONFLICT_ADVICE: GUARD_CONFLICT_ADVICE2 } = await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports));
|
|
9213
9658
|
const det = await detectGateGuardActive2();
|
|
9214
9659
|
if (det.active) {
|
|
9215
|
-
const
|
|
9660
|
+
const ge = await Promise.resolve().then(() => (init_guard_exemption(), guard_exemption_exports));
|
|
9216
9661
|
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
9217
|
-
const flowResult = await
|
|
9218
|
-
|
|
9662
|
+
const flowResult = await ge.runExemptionFlow({
|
|
9663
|
+
probe: () => ge.probeExemptCapability(),
|
|
9664
|
+
readEnvValue: () => ge.readCurrentEnvValue(),
|
|
9665
|
+
merge: (value) => ge.applyEnvExemption(value),
|
|
9219
9666
|
print: (line) => console.error(line),
|
|
9220
9667
|
...isTty ? {
|
|
9221
9668
|
confirm: async () => {
|
|
9222
9669
|
const p7 = await import('@clack/prompts');
|
|
9223
9670
|
const ans = await p7.confirm({
|
|
9224
|
-
message: 'Apply the GateGuard exemption now? (
|
|
9671
|
+
message: 'Apply the GateGuard exemption now? (persists GATEGUARD_EXEMPT_GLOBS=".planning/**" into settings env \u2014 backed up first)',
|
|
9225
9672
|
initialValue: true
|
|
9226
9673
|
// D1 — default YES
|
|
9227
9674
|
});
|
|
@@ -9229,7 +9676,7 @@ function registerCheckpoint(program2) {
|
|
|
9229
9676
|
}
|
|
9230
9677
|
} : {}
|
|
9231
9678
|
});
|
|
9232
|
-
if (flowResult === "
|
|
9679
|
+
if (flowResult === "not-capable") {
|
|
9233
9680
|
console.error(
|
|
9234
9681
|
`\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
9682
|
);
|
|
@@ -9432,22 +9879,23 @@ function registerDoctor(program2) {
|
|
|
9432
9879
|
init_guard_exemption();
|
|
9433
9880
|
function registerExemptGateguard(program2) {
|
|
9434
9881
|
program2.command("exempt-gateguard").description(
|
|
9435
|
-
|
|
9882
|
+
'Persist GATEGUARD_EXEMPT_GLOBS=".planning/**" into the harness settings env \u2014 resolves the dual-guard conflict with the harnessed evidence guard (backup-first, atomic write)'
|
|
9436
9883
|
).action(async () => {
|
|
9437
9884
|
const result = await runExemptionFlow({
|
|
9885
|
+
probe: () => probeExemptCapability(),
|
|
9886
|
+
readEnvValue: () => readCurrentEnvValue(),
|
|
9887
|
+
merge: (value) => applyEnvExemption(value),
|
|
9438
9888
|
print: (line) => console.log(line),
|
|
9439
9889
|
confirm: async () => true
|
|
9440
9890
|
// consent = invocation (see header)
|
|
9441
9891
|
});
|
|
9442
9892
|
if (result === "already") {
|
|
9443
9893
|
console.log(
|
|
9444
|
-
"\u2713 [harnessed] .planning/** is already
|
|
9894
|
+
"\u2713 [harnessed] .planning/** is already listed in GATEGUARD_EXEMPT_GLOBS \u2014 nothing to do."
|
|
9445
9895
|
);
|
|
9446
9896
|
}
|
|
9447
|
-
if (result === "
|
|
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
|
-
);
|
|
9897
|
+
if (result === "not-capable") {
|
|
9898
|
+
for (const line of upgradeAdviceLines()) console.log(line);
|
|
9451
9899
|
}
|
|
9452
9900
|
process.exit(result === "error" ? 1 : 0);
|
|
9453
9901
|
});
|
|
@@ -9879,6 +10327,15 @@ function registerStatus(program2) {
|
|
|
9879
10327
|
} catch {
|
|
9880
10328
|
}
|
|
9881
10329
|
}
|
|
10330
|
+
try {
|
|
10331
|
+
const { checkSkillIntegrity: checkSkillIntegrity2 } = await Promise.resolve().then(() => (init_check_skill_integrity(), check_skill_integrity_exports));
|
|
10332
|
+
const integ = await checkSkillIntegrity2();
|
|
10333
|
+
if (integ.status === "warn") {
|
|
10334
|
+
console.warn(`\u26A0 ${integ.message}`);
|
|
10335
|
+
if (integ.fix) console.warn(` fix: ${integ.fix}`);
|
|
10336
|
+
}
|
|
10337
|
+
} catch {
|
|
10338
|
+
}
|
|
9882
10339
|
const lines = await buildRecoverLines(wf, ledger, intent);
|
|
9883
10340
|
for (const l of lines) console.log(l);
|
|
9884
10341
|
return;
|
|
@@ -10566,81 +11023,7 @@ function renderSkillBody(body, capabilities, installedPlugins, installedUserSkil
|
|
|
10566
11023
|
|
|
10567
11024
|
// src/cli/lib/enableAgentTeamsInSettings.ts
|
|
10568
11025
|
init_platform();
|
|
10569
|
-
|
|
10570
|
-
// src/cli/lib/settingsWriter.ts
|
|
10571
|
-
init_harnessedRoot();
|
|
10572
|
-
init_platform();
|
|
10573
|
-
async function mergeSettingsEnvKey(key, value, opts = {}) {
|
|
10574
|
-
const path = getSettingsPath();
|
|
10575
|
-
let raw;
|
|
10576
|
-
try {
|
|
10577
|
-
raw = await readFile(path, "utf8");
|
|
10578
|
-
} catch (err2) {
|
|
10579
|
-
const code = err2.code;
|
|
10580
|
-
if (code !== "ENOENT") {
|
|
10581
|
-
return { outcome: "warn", message: `read ${path} failed: ${err2.message}` };
|
|
10582
|
-
}
|
|
10583
|
-
return createFresh(path, key, value);
|
|
10584
|
-
}
|
|
10585
|
-
let data;
|
|
10586
|
-
try {
|
|
10587
|
-
const parsed = JSON.parse(raw);
|
|
10588
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
10589
|
-
return { outcome: "warn", message: `${path} is not a JSON object` };
|
|
10590
|
-
}
|
|
10591
|
-
data = parsed;
|
|
10592
|
-
} catch (err2) {
|
|
10593
|
-
return { outcome: "warn", message: `${path} malformed JSON: ${err2.message}` };
|
|
10594
|
-
}
|
|
10595
|
-
const env = data.env ?? {};
|
|
10596
|
-
const existing = env[key];
|
|
10597
|
-
if (typeof existing === "string" && existing.length > 0 && opts.skipIfPresent?.(existing) === true) {
|
|
10598
|
-
return { outcome: "already", path, existing };
|
|
10599
|
-
}
|
|
10600
|
-
const backup2 = await backupOriginal(raw);
|
|
10601
|
-
if (backup2.status === "warn") return { outcome: "warn", message: backup2.message };
|
|
10602
|
-
data.env = { ...env, [key]: value };
|
|
10603
|
-
const writeErr = await atomicWrite(path, `${JSON.stringify(data, null, 2)}
|
|
10604
|
-
`);
|
|
10605
|
-
if (writeErr) return { outcome: "warn", message: writeErr };
|
|
10606
|
-
return { outcome: "merged", path, backupPath: backup2.path };
|
|
10607
|
-
}
|
|
10608
|
-
async function createFresh(path, key, value) {
|
|
10609
|
-
const data = { env: { [key]: value } };
|
|
10610
|
-
try {
|
|
10611
|
-
await mkdir(dirname(path), { recursive: true });
|
|
10612
|
-
} catch (err2) {
|
|
10613
|
-
return { outcome: "warn", message: `mkdir ~/.claude failed: ${err2.message}` };
|
|
10614
|
-
}
|
|
10615
|
-
const writeErr = await atomicWrite(path, `${JSON.stringify(data, null, 2)}
|
|
10616
|
-
`);
|
|
10617
|
-
if (writeErr) return { outcome: "warn", message: writeErr };
|
|
10618
|
-
return { outcome: "created", path };
|
|
10619
|
-
}
|
|
10620
|
-
async function backupOriginal(raw) {
|
|
10621
|
-
const backupRoot = harnessedSubdir("backups");
|
|
10622
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-");
|
|
10623
|
-
const backupPath = join(backupRoot, `settings.json.${ts}.bak`);
|
|
10624
|
-
try {
|
|
10625
|
-
await mkdir(backupRoot, { recursive: true });
|
|
10626
|
-
await writeFile(backupPath, raw, "utf8");
|
|
10627
|
-
return { status: "ok", path: backupPath };
|
|
10628
|
-
} catch (err2) {
|
|
10629
|
-
return { status: "warn", message: `backup ${backupPath} failed: ${err2.message}` };
|
|
10630
|
-
}
|
|
10631
|
-
}
|
|
10632
|
-
async function atomicWrite(path, content) {
|
|
10633
|
-
const tmpPath = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
10634
|
-
try {
|
|
10635
|
-
await writeFile(tmpPath, content, "utf8");
|
|
10636
|
-
await rename(tmpPath, path);
|
|
10637
|
-
return void 0;
|
|
10638
|
-
} catch (err2) {
|
|
10639
|
-
return `write ${path} failed: ${err2.message}`;
|
|
10640
|
-
}
|
|
10641
|
-
}
|
|
10642
|
-
|
|
10643
|
-
// src/cli/lib/enableAgentTeamsInSettings.ts
|
|
11026
|
+
init_settingsWriter();
|
|
10644
11027
|
var ENV_KEY = "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS";
|
|
10645
11028
|
async function enableAgentTeamsInSettings() {
|
|
10646
11029
|
const platform = detectPlatform();
|
|
@@ -10667,6 +11050,7 @@ async function enableAgentTeamsInSettings() {
|
|
|
10667
11050
|
|
|
10668
11051
|
// src/cli/lib/enableUserLangInSettings.ts
|
|
10669
11052
|
init_platform();
|
|
11053
|
+
init_settingsWriter();
|
|
10670
11054
|
var ENV_KEY2 = "HARNESSED_USER_LANG";
|
|
10671
11055
|
function detectUserLang(override) {
|
|
10672
11056
|
if (override) {
|
|
@@ -10825,64 +11209,7 @@ init_idempotent();
|
|
|
10825
11209
|
init_platform();
|
|
10826
11210
|
init_validate();
|
|
10827
11211
|
init_checkAgentTeams();
|
|
10828
|
-
|
|
10829
|
-
var FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
10830
|
-
var NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
10831
|
-
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
10832
|
-
const workflows = [];
|
|
10833
|
-
for (const entry of entries.sort()) {
|
|
10834
|
-
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
10835
|
-
const src = join(workflowsDir, entry);
|
|
10836
|
-
let s;
|
|
10837
|
-
try {
|
|
10838
|
-
s = await stat(src);
|
|
10839
|
-
} catch {
|
|
10840
|
-
continue;
|
|
10841
|
-
}
|
|
10842
|
-
if (!s.isDirectory()) continue;
|
|
10843
|
-
let hasFlatSkill = false;
|
|
10844
|
-
try {
|
|
10845
|
-
await stat(join(src, "SKILL.md"));
|
|
10846
|
-
hasFlatSkill = true;
|
|
10847
|
-
} catch {
|
|
10848
|
-
hasFlatSkill = false;
|
|
10849
|
-
}
|
|
10850
|
-
if (hasFlatSkill) {
|
|
10851
|
-
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
10852
|
-
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
10853
|
-
continue;
|
|
10854
|
-
}
|
|
10855
|
-
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
10856
|
-
continue;
|
|
10857
|
-
}
|
|
10858
|
-
let subEntries;
|
|
10859
|
-
try {
|
|
10860
|
-
subEntries = await readdir(src);
|
|
10861
|
-
} catch {
|
|
10862
|
-
continue;
|
|
10863
|
-
}
|
|
10864
|
-
for (const sub of subEntries.sort()) {
|
|
10865
|
-
const subDir = join(src, sub);
|
|
10866
|
-
let ss;
|
|
10867
|
-
try {
|
|
10868
|
-
ss = await stat(subDir);
|
|
10869
|
-
} catch {
|
|
10870
|
-
continue;
|
|
10871
|
-
}
|
|
10872
|
-
if (!ss.isDirectory()) continue;
|
|
10873
|
-
try {
|
|
10874
|
-
await stat(join(subDir, "SKILL.md"));
|
|
10875
|
-
} catch {
|
|
10876
|
-
continue;
|
|
10877
|
-
}
|
|
10878
|
-
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
10879
|
-
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
10880
|
-
}
|
|
10881
|
-
}
|
|
10882
|
-
return { workflows };
|
|
10883
|
-
}
|
|
10884
|
-
|
|
10885
|
-
// src/cli/lib/setup-helpers.ts
|
|
11212
|
+
init_scan_nested();
|
|
10886
11213
|
async function warnIfAgentTeamsMissing() {
|
|
10887
11214
|
if (detectPlatform().id !== "claude") return;
|
|
10888
11215
|
const r = await checkAgentTeams();
|
|
@@ -11217,6 +11544,66 @@ function registerSetup(program2) {
|
|
|
11217
11544
|
console.log(t("setup.dry_run.run_hint"));
|
|
11218
11545
|
process.exit(0);
|
|
11219
11546
|
}
|
|
11547
|
+
const manifestPaths = await listBaseManifests2(pkgRoot);
|
|
11548
|
+
const forceFirstPass = raw.updateInstalled === true;
|
|
11549
|
+
const progressPrinter = (ev) => {
|
|
11550
|
+
console.log(` [${ev.done}/${ev.total}] ${ev.status} ${ev.name}`);
|
|
11551
|
+
};
|
|
11552
|
+
console.log(
|
|
11553
|
+
`
|
|
11554
|
+
installing ${manifestPaths.length} upstream components (MCP serialized, rest parallel)...`
|
|
11555
|
+
);
|
|
11556
|
+
const b = await runStepBInstall(manifestPaths, {
|
|
11557
|
+
updateInstalled: forceFirstPass,
|
|
11558
|
+
quiet: true,
|
|
11559
|
+
onProgress: progressPrinter
|
|
11560
|
+
});
|
|
11561
|
+
const stepBMs = (b.elapsedMs / 1e3).toFixed(1);
|
|
11562
|
+
console.log(
|
|
11563
|
+
t("setup.step_b_complete", {
|
|
11564
|
+
installed: b.installed.length,
|
|
11565
|
+
already: b.alreadyInstalled.length,
|
|
11566
|
+
skipped: b.skipped.length,
|
|
11567
|
+
failed: b.failed.length,
|
|
11568
|
+
seconds: stepBMs
|
|
11569
|
+
})
|
|
11570
|
+
);
|
|
11571
|
+
printGrouped(b);
|
|
11572
|
+
if (!forceFirstPass && !dryRun && raw.nonInteractive !== true && b.alreadyInstalled.length > 0) {
|
|
11573
|
+
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
11574
|
+
if (isTty) {
|
|
11575
|
+
const { confirm: confirm5, isCancel: isCancel7 } = await import('@clack/prompts');
|
|
11576
|
+
const ans = await confirm5({
|
|
11577
|
+
message: `Update ${b.alreadyInstalled.length} already-installed plugin(s) listed above? (MCP servers excluded \u2014 they ignore force-update)`,
|
|
11578
|
+
initialValue: false
|
|
11579
|
+
});
|
|
11580
|
+
if (!isCancel7(ans) && ans === true) {
|
|
11581
|
+
console.log(`
|
|
11582
|
+
force-updating ${b.alreadyInstalled.length} plugin(s)...`);
|
|
11583
|
+
const b2 = await runStepBInstall(manifestPaths, {
|
|
11584
|
+
updateInstalled: true,
|
|
11585
|
+
quiet: true,
|
|
11586
|
+
onProgress: progressPrinter
|
|
11587
|
+
});
|
|
11588
|
+
const probe = await makeIdempotentProbe(manifestPaths);
|
|
11589
|
+
const reclass = await reclassifyForceUpdateFailures(b, b2, probe);
|
|
11590
|
+
b2.failed = reclass.failed;
|
|
11591
|
+
b2.keptExisting = reclass.keptExisting;
|
|
11592
|
+
const stepB2Ms = (b2.elapsedMs / 1e3).toFixed(1);
|
|
11593
|
+
console.log(
|
|
11594
|
+
`
|
|
11595
|
+
Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting.length} kept-existing / ${b2.alreadyInstalled.length} still-already-installed (MCP) / ${b2.skipped.length} skipped / ${b2.failed.length} failed [parallel ${stepB2Ms}s]`
|
|
11596
|
+
);
|
|
11597
|
+
printGrouped(b2, "[force-update] ");
|
|
11598
|
+
if (b2.keptExisting.length > 0) {
|
|
11599
|
+
console.warn(
|
|
11600
|
+
`
|
|
11601
|
+
${b2.keptExisting.length} plugin(s) kept their existing version \u2014 refresh failed but the prior install is still usable. Re-run \`harnessed setup\` later to retry the update.`
|
|
11602
|
+
);
|
|
11603
|
+
}
|
|
11604
|
+
}
|
|
11605
|
+
}
|
|
11606
|
+
}
|
|
11220
11607
|
let skillsInstalled = 0;
|
|
11221
11608
|
for (const wf of toInstall) {
|
|
11222
11609
|
const src = join(workflowsDir, wf.relPath);
|
|
@@ -11244,6 +11631,11 @@ function registerSetup(program2) {
|
|
|
11244
11631
|
console.warn(` - ${w}`);
|
|
11245
11632
|
}
|
|
11246
11633
|
}
|
|
11634
|
+
try {
|
|
11635
|
+
const { recordSkillHashes: recordSkillHashes2 } = await Promise.resolve().then(() => (init_skillIntegrity(), skillIntegrity_exports));
|
|
11636
|
+
await recordSkillHashes2(skillNames, skillsBase);
|
|
11637
|
+
} catch {
|
|
11638
|
+
}
|
|
11247
11639
|
const commandsBase = getCommandsDir();
|
|
11248
11640
|
try {
|
|
11249
11641
|
await mkdir(commandsBase, { recursive: true });
|
|
@@ -11279,66 +11671,6 @@ function registerSetup(program2) {
|
|
|
11279
11671
|
}
|
|
11280
11672
|
await enableAgentTeamsInSettings();
|
|
11281
11673
|
await enableUserLangInSettings(raw.userLang);
|
|
11282
|
-
const manifestPaths = await listBaseManifests2(pkgRoot);
|
|
11283
|
-
const forceFirstPass = raw.updateInstalled === true;
|
|
11284
|
-
const progressPrinter = (ev) => {
|
|
11285
|
-
console.log(` [${ev.done}/${ev.total}] ${ev.status} ${ev.name}`);
|
|
11286
|
-
};
|
|
11287
|
-
console.log(
|
|
11288
|
-
`
|
|
11289
|
-
installing ${manifestPaths.length} upstream components (MCP serialized, rest parallel)...`
|
|
11290
|
-
);
|
|
11291
|
-
const b = await runStepBInstall(manifestPaths, {
|
|
11292
|
-
updateInstalled: forceFirstPass,
|
|
11293
|
-
quiet: true,
|
|
11294
|
-
onProgress: progressPrinter
|
|
11295
|
-
});
|
|
11296
|
-
const stepBMs = (b.elapsedMs / 1e3).toFixed(1);
|
|
11297
|
-
console.log(
|
|
11298
|
-
t("setup.step_b_complete", {
|
|
11299
|
-
installed: b.installed.length,
|
|
11300
|
-
already: b.alreadyInstalled.length,
|
|
11301
|
-
skipped: b.skipped.length,
|
|
11302
|
-
failed: b.failed.length,
|
|
11303
|
-
seconds: stepBMs
|
|
11304
|
-
})
|
|
11305
|
-
);
|
|
11306
|
-
printGrouped(b);
|
|
11307
|
-
if (!forceFirstPass && !dryRun && raw.nonInteractive !== true && b.alreadyInstalled.length > 0) {
|
|
11308
|
-
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
11309
|
-
if (isTty) {
|
|
11310
|
-
const { confirm: confirm5, isCancel: isCancel7 } = await import('@clack/prompts');
|
|
11311
|
-
const ans = await confirm5({
|
|
11312
|
-
message: `Update ${b.alreadyInstalled.length} already-installed plugin(s) listed above? (MCP servers excluded \u2014 they ignore force-update)`,
|
|
11313
|
-
initialValue: false
|
|
11314
|
-
});
|
|
11315
|
-
if (!isCancel7(ans) && ans === true) {
|
|
11316
|
-
console.log(`
|
|
11317
|
-
force-updating ${b.alreadyInstalled.length} plugin(s)...`);
|
|
11318
|
-
const b2 = await runStepBInstall(manifestPaths, {
|
|
11319
|
-
updateInstalled: true,
|
|
11320
|
-
quiet: true,
|
|
11321
|
-
onProgress: progressPrinter
|
|
11322
|
-
});
|
|
11323
|
-
const probe = await makeIdempotentProbe(manifestPaths);
|
|
11324
|
-
const reclass = await reclassifyForceUpdateFailures(b, b2, probe);
|
|
11325
|
-
b2.failed = reclass.failed;
|
|
11326
|
-
b2.keptExisting = reclass.keptExisting;
|
|
11327
|
-
const stepB2Ms = (b2.elapsedMs / 1e3).toFixed(1);
|
|
11328
|
-
console.log(
|
|
11329
|
-
`
|
|
11330
|
-
Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting.length} kept-existing / ${b2.alreadyInstalled.length} still-already-installed (MCP) / ${b2.skipped.length} skipped / ${b2.failed.length} failed [parallel ${stepB2Ms}s]`
|
|
11331
|
-
);
|
|
11332
|
-
printGrouped(b2, "[force-update] ");
|
|
11333
|
-
if (b2.keptExisting.length > 0) {
|
|
11334
|
-
console.warn(
|
|
11335
|
-
`
|
|
11336
|
-
${b2.keptExisting.length} plugin(s) kept their existing version \u2014 refresh failed but the prior install is still usable. Re-run \`harnessed setup\` later to retry the update.`
|
|
11337
|
-
);
|
|
11338
|
-
}
|
|
11339
|
-
}
|
|
11340
|
-
}
|
|
11341
|
-
}
|
|
11342
11674
|
if (!dryRun && raw.nonInteractive !== true && b.skipped.some((s) => s.reason === "level-flag-missing")) {
|
|
11343
11675
|
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
11344
11676
|
if (isTty) {
|
|
@@ -11380,6 +11712,60 @@ ${b.failed.length} component(s) failed \u2014 see the notes in the tables above;
|
|
|
11380
11712
|
// commander default = true; --no-auto-install flips
|
|
11381
11713
|
});
|
|
11382
11714
|
}
|
|
11715
|
+
try {
|
|
11716
|
+
const {
|
|
11717
|
+
attachCulprits: attachCulprits2,
|
|
11718
|
+
auditInstalledSkills: auditInstalledSkills2,
|
|
11719
|
+
buildCulpritIndex: buildCulpritIndex2,
|
|
11720
|
+
integrityReportLines: integrityReportLines2,
|
|
11721
|
+
recordSkillHashes: recordSkillHashes2
|
|
11722
|
+
} = await Promise.resolve().then(() => (init_skillIntegrity(), skillIntegrity_exports));
|
|
11723
|
+
const audit = attachCulprits2(
|
|
11724
|
+
await auditInstalledSkills2(toInstall, skillsBase, workflowsDir),
|
|
11725
|
+
await buildCulpritIndex2(manifestPaths)
|
|
11726
|
+
);
|
|
11727
|
+
const bad = audit.filter((e) => e.status !== "ok");
|
|
11728
|
+
if (bad.length > 0) {
|
|
11729
|
+
for (const line of integrityReportLines2(audit)) console.warn(line);
|
|
11730
|
+
let healed = 0;
|
|
11731
|
+
const healedNames = [];
|
|
11732
|
+
for (const e of bad) {
|
|
11733
|
+
const wf = toInstall.find((w) => w.name === e.name);
|
|
11734
|
+
if (!wf) continue;
|
|
11735
|
+
try {
|
|
11736
|
+
await cp(join(workflowsDir, wf.relPath), join(skillsBase, wf.name), {
|
|
11737
|
+
recursive: true,
|
|
11738
|
+
force: true
|
|
11739
|
+
});
|
|
11740
|
+
healed++;
|
|
11741
|
+
healedNames.push(e.name);
|
|
11742
|
+
} catch {
|
|
11743
|
+
console.warn(` \u2717 could not restore '${e.name}' \u2014 re-run \`harnessed setup\``);
|
|
11744
|
+
}
|
|
11745
|
+
}
|
|
11746
|
+
if (healed > 0) {
|
|
11747
|
+
try {
|
|
11748
|
+
await renderAllSkills(healedNames, skillsBase, workflowsDir, void 0, getLocale());
|
|
11749
|
+
} catch {
|
|
11750
|
+
}
|
|
11751
|
+
await recordSkillHashes2(healedNames, skillsBase);
|
|
11752
|
+
console.warn(
|
|
11753
|
+
` \u2713 restored ${healed} harnessed workflow skill(s) from the bundle (packs keep their other skills; the colliding name belongs to the engine)`
|
|
11754
|
+
);
|
|
11755
|
+
}
|
|
11756
|
+
}
|
|
11757
|
+
} catch {
|
|
11758
|
+
}
|
|
11759
|
+
try {
|
|
11760
|
+
const { checkGuardConflict: checkGuardConflict2 } = await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports));
|
|
11761
|
+
const guard = await checkGuardConflict2();
|
|
11762
|
+
if (guard.status === "warn") {
|
|
11763
|
+
console.warn(`
|
|
11764
|
+
\u26A0 ${guard.name} \u2014 ${guard.message}`);
|
|
11765
|
+
if (guard.fix) console.warn(` fix: ${guard.fix}`);
|
|
11766
|
+
}
|
|
11767
|
+
} catch {
|
|
11768
|
+
}
|
|
11383
11769
|
process.exit(0);
|
|
11384
11770
|
});
|
|
11385
11771
|
}
|
|
@@ -11595,7 +11981,7 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
11595
11981
|
const m = install.cmd.match(/npm\s+(?:install|i)\s+(?:-g\s+)?(\S+)/);
|
|
11596
11982
|
const pkg = m?.[1] ?? ctx.manifest.metadata.upstream.source;
|
|
11597
11983
|
const isWin = process.platform === "win32";
|
|
11598
|
-
const result = await new Promise((
|
|
11984
|
+
const result = await new Promise((resolve19) => {
|
|
11599
11985
|
const child = isWin ? spawn("cmd.exe", ["/c", "npm", "uninstall", "-g", pkg], { windowsHide: true }) : spawn("npm", ["uninstall", "-g", pkg], { shell: false });
|
|
11600
11986
|
let stderr = "";
|
|
11601
11987
|
child.stderr?.setEncoding("utf8").on("data", (c) => {
|
|
@@ -11603,15 +11989,15 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
11603
11989
|
});
|
|
11604
11990
|
const timer = setTimeout(() => {
|
|
11605
11991
|
child.kill("SIGKILL");
|
|
11606
|
-
|
|
11992
|
+
resolve19({ exitCode: -1, stderr: `${stderr}[timeout]` });
|
|
11607
11993
|
}, 3e4);
|
|
11608
11994
|
child.on("error", (e) => {
|
|
11609
11995
|
clearTimeout(timer);
|
|
11610
|
-
|
|
11996
|
+
resolve19({ exitCode: -1, stderr: e.message });
|
|
11611
11997
|
});
|
|
11612
11998
|
child.on("close", (code) => {
|
|
11613
11999
|
clearTimeout(timer);
|
|
11614
|
-
|
|
12000
|
+
resolve19({ exitCode: code ?? -1, stderr });
|
|
11615
12001
|
});
|
|
11616
12002
|
});
|
|
11617
12003
|
if (result.exitCode !== 0) {
|
|
@@ -11659,6 +12045,7 @@ async function runUninstall(manifest, opts) {
|
|
|
11659
12045
|
// src/cli/uninstall.ts
|
|
11660
12046
|
init_assetsRoot();
|
|
11661
12047
|
init_generateCommands();
|
|
12048
|
+
init_scan_nested();
|
|
11662
12049
|
async function discoverCommandFiles(commandsDir) {
|
|
11663
12050
|
const owned = [];
|
|
11664
12051
|
let entries;
|