harnessed 4.40.0 → 4.42.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 +76 -36
- package/bin/harnessed-stop-hook.mjs +49 -9
- package/dist/cli.mjs +750 -246
- 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 +9 -9
- package/dist/schemas/index.mjs.map +1 -1
- package/manifests/SCHEMA.md +0 -3
- package/manifests/skill-packs/gsd.yaml +0 -3
- package/manifests/tools/superpowers.yaml +11 -5
- package/package.json +1 -1
- package/schemas/manifest.v1.schema.json +0 -24
package/dist/cli.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync,
|
|
2
|
+
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, rmSync, utimesSync, statSync, appendFileSync } from 'fs';
|
|
3
3
|
import { homedir, tmpdir } from 'os';
|
|
4
|
-
import { join, resolve, dirname, basename, sep, isAbsolute, win32, posix
|
|
4
|
+
import { join, resolve, dirname, basename, sep, isAbsolute, relative, win32, posix } from 'path';
|
|
5
5
|
import { Type } from '@sinclair/typebox';
|
|
6
|
-
import { readFile, readdir,
|
|
6
|
+
import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod } from 'fs/promises';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
8
8
|
import lockfile from 'proper-lockfile';
|
|
9
9
|
import { LineCounter, parseDocument, parse, isSeq, isScalar, stringify } from 'yaml';
|
|
10
10
|
import { Ajv } from 'ajv';
|
|
11
11
|
import * as ajvFormatsNs from 'ajv-formats';
|
|
12
|
-
import { execFileSync, spawnSync, spawn,
|
|
12
|
+
import { execFileSync, spawnSync, spawn, execFile, exec } from 'child_process';
|
|
13
13
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
14
14
|
import { createHash, verify, createPublicKey } from 'crypto';
|
|
15
15
|
import { promisify } from 'util';
|
|
@@ -17,7 +17,7 @@ import { Parser } from 'expr-eval';
|
|
|
17
17
|
import * as p from '@clack/prompts';
|
|
18
18
|
import { createPatch } from 'diff';
|
|
19
19
|
import pc from 'picocolors';
|
|
20
|
-
import { Command } from 'commander';
|
|
20
|
+
import { Command, InvalidArgumentError } from 'commander';
|
|
21
21
|
import { stdout, stdin } from 'process';
|
|
22
22
|
import * as readline from 'readline/promises';
|
|
23
23
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
@@ -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.42.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -366,11 +366,18 @@ async function writeFileAtomic(path, data) {
|
|
|
366
366
|
await rename(tmp, path);
|
|
367
367
|
return;
|
|
368
368
|
} catch (e) {
|
|
369
|
-
if (i >= RENAME_RETRIES || !isTransient(e))
|
|
369
|
+
if (i >= RENAME_RETRIES || !isTransient(e)) {
|
|
370
|
+
await rm(tmp, { force: true }).catch(() => {
|
|
371
|
+
});
|
|
372
|
+
throw e;
|
|
373
|
+
}
|
|
370
374
|
await new Promise((r) => setTimeout(r, 10 * (i + 1)));
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
}
|
|
378
|
+
function sleepSync(ms) {
|
|
379
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
380
|
+
}
|
|
374
381
|
function writeFileSyncAtomic(path, data) {
|
|
375
382
|
const tmp = tmpName(path);
|
|
376
383
|
writeFileSync(tmp, data, "utf8");
|
|
@@ -379,7 +386,14 @@ function writeFileSyncAtomic(path, data) {
|
|
|
379
386
|
renameSync(tmp, path);
|
|
380
387
|
return;
|
|
381
388
|
} catch (e) {
|
|
382
|
-
if (i >= RENAME_RETRIES || !isTransient(e))
|
|
389
|
+
if (i >= RENAME_RETRIES || !isTransient(e)) {
|
|
390
|
+
try {
|
|
391
|
+
rmSync(tmp, { force: true });
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
394
|
+
throw e;
|
|
395
|
+
}
|
|
396
|
+
sleepSync(10 * (i + 1));
|
|
383
397
|
}
|
|
384
398
|
}
|
|
385
399
|
}
|
|
@@ -525,6 +539,12 @@ var init_currentWorkflow_v1 = __esm({
|
|
|
525
539
|
// G2 — when true the next-step contract reports NEXT:auto (skill auto-advances);
|
|
526
540
|
// when false NEXT:manual (pause for the operator). Precedence env > this > default.
|
|
527
541
|
auto_transition: Type.Optional(Type.Boolean()),
|
|
542
|
+
// Last write to THIS slot (stamped by writeCurrentWorkflowUnlocked). The STALE
|
|
543
|
+
// ledger breadcrumb used the mtime of the whole multi-repo workflows.json, which
|
|
544
|
+
// any repo's write refreshes, so an abandoned ledger in one repo never aged
|
|
545
|
+
// while another repo was active (external review L8). Additive-optional: old
|
|
546
|
+
// records without it fall back to the file mtime.
|
|
547
|
+
updated_at: Type.Optional(Type.String({ minLength: 1 })),
|
|
528
548
|
// Phase 14 — compaction digest: cumulative summary of resolved sub-progress
|
|
529
549
|
// entries evicted by `compact`. Additive-optional (NO schemaVersion bump; old
|
|
530
550
|
// files without it still Value.Check-pass). Keeps a readable trace after
|
|
@@ -682,6 +702,7 @@ __export(state_exports, {
|
|
|
682
702
|
complete: () => complete,
|
|
683
703
|
mutateStore: () => mutateStore,
|
|
684
704
|
mutateSubProgress: () => mutateSubProgress,
|
|
705
|
+
mutateWorkflow: () => mutateWorkflow,
|
|
685
706
|
pause: () => pause,
|
|
686
707
|
readCurrentWorkflow: () => readCurrentWorkflow,
|
|
687
708
|
writeCurrentWorkflow: () => writeCurrentWorkflow
|
|
@@ -719,7 +740,8 @@ async function readCurrentWorkflow() {
|
|
|
719
740
|
const store = await readStoreRaw();
|
|
720
741
|
return store.workflows[activeKey()] ?? store.workflows[repoKey()] ?? null;
|
|
721
742
|
}
|
|
722
|
-
async function writeCurrentWorkflowUnlocked(
|
|
743
|
+
async function writeCurrentWorkflowUnlocked(input) {
|
|
744
|
+
const s = { ...input, updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
723
745
|
if (!Value.Check(CurrentWorkflowV1, s)) {
|
|
724
746
|
const errs = [...Value.Errors(CurrentWorkflowV1, s)].map((e) => e.message).join("; ");
|
|
725
747
|
throw new WorkflowStateError(`current-workflow schema validation failed: ${errs}`);
|
|
@@ -740,6 +762,13 @@ async function mutateSubProgress(fn) {
|
|
|
740
762
|
await writeCurrentWorkflowUnlocked({ ...s, sub_progress: next });
|
|
741
763
|
});
|
|
742
764
|
}
|
|
765
|
+
async function mutateWorkflow(fn) {
|
|
766
|
+
await withLock(async () => {
|
|
767
|
+
const s = await readCurrentWorkflow();
|
|
768
|
+
if (!s) return;
|
|
769
|
+
await writeCurrentWorkflowUnlocked(fn(s));
|
|
770
|
+
});
|
|
771
|
+
}
|
|
743
772
|
async function mutateStore(fn) {
|
|
744
773
|
await withLock(async () => {
|
|
745
774
|
const store = await readStoreRaw();
|
|
@@ -756,14 +785,14 @@ async function activate(phase, checkpointPath = null) {
|
|
|
756
785
|
});
|
|
757
786
|
}
|
|
758
787
|
async function pause() {
|
|
759
|
-
|
|
760
|
-
if (!s) return;
|
|
761
|
-
await writeCurrentWorkflow({ ...s, status: "paused", paused_at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
788
|
+
await mutateWorkflow((s) => ({ ...s, status: "paused", paused_at: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
762
789
|
}
|
|
763
790
|
async function complete() {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
791
|
+
await mutateWorkflow((s) => ({
|
|
792
|
+
...s,
|
|
793
|
+
status: "complete",
|
|
794
|
+
completed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
795
|
+
}));
|
|
767
796
|
}
|
|
768
797
|
var WorkflowStateError, LockHeldError;
|
|
769
798
|
var init_state = __esm({
|
|
@@ -1411,7 +1440,7 @@ var init_installMethods = __esm({
|
|
|
1411
1440
|
Type.Union([...branches]);
|
|
1412
1441
|
}
|
|
1413
1442
|
});
|
|
1414
|
-
var TypeEnum, ComponentType, Verify, Uninstall, Stability, FallbackAction, UpstreamHealth, Platform, Signature,
|
|
1443
|
+
var TypeEnum, ComponentType, Verify, Uninstall, Stability, FallbackAction, UpstreamHealth, Platform, Signature, Category, InstallType, DecisionRules, Phase, Triggers, ProvidedUnit, HarnessOverride, HarnessOverrides, SpecSchema;
|
|
1415
1444
|
var init_spec = __esm({
|
|
1416
1445
|
"src/manifest/schema/spec.ts"() {
|
|
1417
1446
|
init_installMethods();
|
|
@@ -1472,13 +1501,6 @@ var init_spec = __esm({
|
|
|
1472
1501
|
{ sigstore_bundle: Type.String({ format: "uri" }) },
|
|
1473
1502
|
{ additionalProperties: false }
|
|
1474
1503
|
);
|
|
1475
|
-
TestedWithVersions = Type.Object(
|
|
1476
|
-
{
|
|
1477
|
-
cc_versions: Type.Optional(Type.Array(Type.String())),
|
|
1478
|
-
node_versions: Type.Optional(Type.Array(Type.String()))
|
|
1479
|
-
},
|
|
1480
|
-
{ additionalProperties: false }
|
|
1481
|
-
);
|
|
1482
1504
|
Category = Type.Union([
|
|
1483
1505
|
Type.Literal("meta"),
|
|
1484
1506
|
Type.Literal("engineering"),
|
|
@@ -1566,8 +1588,15 @@ var init_spec = __esm({
|
|
|
1566
1588
|
signed_by: Type.String({ pattern: "^[a-zA-Z0-9-]+$", minLength: 1 }),
|
|
1567
1589
|
signature: Type.Optional(Signature),
|
|
1568
1590
|
platforms: Type.Array(Platform, { minItems: 1, uniqueItems: true }),
|
|
1569
|
-
tested_with_versions
|
|
1570
|
-
mutually_exclusive_with
|
|
1591
|
+
// Phase 61 — `tested_with_versions` and `mutually_exclusive_with` removed;
|
|
1592
|
+
// both were evaluated by nothing. `mutually_exclusive_with` is the sharper
|
|
1593
|
+
// lesson: schema'd and documented as "v0.2+ 启用", never wired, ZERO manifests
|
|
1594
|
+
// ever declared it — and when a real mutual exclusion appeared (ECC's bundled
|
|
1595
|
+
// chrome-devtools connector vs the standalone chrome-devtools-mcp manifest) it
|
|
1596
|
+
// was solved imperatively by hand in src/cli/lib/check-ecc.ts, with nothing
|
|
1597
|
+
// noticing the declarative mechanism for that exact job was sitting dead.
|
|
1598
|
+
// Re-introduce it only when a second real case exists AND the same commit
|
|
1599
|
+
// wires it; scripts/check-schema-consumers.mjs now fails CI otherwise.
|
|
1571
1600
|
category: Category,
|
|
1572
1601
|
install_type: InstallType,
|
|
1573
1602
|
decision_rules: Type.Optional(DecisionRules),
|
|
@@ -1678,7 +1707,16 @@ function checkSecurityViolations(doc, filename, lineCounter) {
|
|
|
1678
1707
|
const cmdPaths = [
|
|
1679
1708
|
["spec", "install", "cmd"],
|
|
1680
1709
|
["spec", "verify", "cmd"],
|
|
1681
|
-
["spec", "uninstall", "cmd"]
|
|
1710
|
+
["spec", "uninstall", "cmd"],
|
|
1711
|
+
// `hook_command` is written verbatim into ~/.claude/settings.json and then
|
|
1712
|
+
// executed by Claude Code on EVERY matching lifecycle event — the most-run
|
|
1713
|
+
// command string a manifest can carry, and it was the one never screened:
|
|
1714
|
+
// `bash -c "$(curl …)"` validated clean.
|
|
1715
|
+
["spec", "install", "hook_command"],
|
|
1716
|
+
// harness_overrides replaces the install/verify block wholesale on codex, so
|
|
1717
|
+
// its commands run exactly like the base ones and need the same screen.
|
|
1718
|
+
["spec", "harness_overrides", "codex", "install", "cmd"],
|
|
1719
|
+
["spec", "harness_overrides", "codex", "verify", "cmd"]
|
|
1682
1720
|
];
|
|
1683
1721
|
for (const p7 of cmdPaths) {
|
|
1684
1722
|
const err2 = checkScalarCmd(doc, lineCounter, p7, filename);
|
|
@@ -1807,7 +1845,10 @@ var init_validate = __esm({
|
|
|
1807
1845
|
npm: ["npm-cli"],
|
|
1808
1846
|
mcp: ["mcp-stdio-add", "mcp-http-add"],
|
|
1809
1847
|
git: ["git-clone-with-setup"],
|
|
1810
|
-
skill: ["cc-plugin-marketplace", "npx-skill-installer"]
|
|
1848
|
+
skill: ["cc-plugin-marketplace", "npx-skill-installer"],
|
|
1849
|
+
// 5th install_type (Phase 2.4). Missing here meant `install_type: hook` accepted
|
|
1850
|
+
// ANY method: an unconstrained bucket, not a closed one (external review L10).
|
|
1851
|
+
hook: ["cc-hook-add"]
|
|
1811
1852
|
};
|
|
1812
1853
|
}
|
|
1813
1854
|
});
|
|
@@ -2109,15 +2150,22 @@ async function backup(plan, ctx) {
|
|
|
2109
2150
|
entries.push({
|
|
2110
2151
|
target: file.target,
|
|
2111
2152
|
backup: "",
|
|
2112
|
-
// sentinel: no backup written; rollback
|
|
2153
|
+
// sentinel: no backup written; rollback removes the target
|
|
2113
2154
|
sha1: "",
|
|
2114
|
-
eol: "lf"
|
|
2155
|
+
eol: "lf",
|
|
2115
2156
|
// moot for non-existent file; default to lf
|
|
2157
|
+
sentinel: "created"
|
|
2116
2158
|
});
|
|
2117
2159
|
continue;
|
|
2118
2160
|
}
|
|
2119
2161
|
if (code === "EISDIR") {
|
|
2120
|
-
entries.push({
|
|
2162
|
+
entries.push({
|
|
2163
|
+
target: file.target,
|
|
2164
|
+
backup: "",
|
|
2165
|
+
sha1: "",
|
|
2166
|
+
eol: "lf",
|
|
2167
|
+
sentinel: "preexisting-dir"
|
|
2168
|
+
});
|
|
2121
2169
|
continue;
|
|
2122
2170
|
}
|
|
2123
2171
|
return {
|
|
@@ -2186,7 +2234,24 @@ var init_backup = __esm({
|
|
|
2186
2234
|
}
|
|
2187
2235
|
});
|
|
2188
2236
|
|
|
2237
|
+
// src/platform/ablation.ts
|
|
2238
|
+
function isAblated(env = process.env) {
|
|
2239
|
+
return env.HARNESSED_OFF === "1";
|
|
2240
|
+
}
|
|
2241
|
+
var ABLATION_ENV;
|
|
2242
|
+
var init_ablation = __esm({
|
|
2243
|
+
"src/platform/ablation.ts"() {
|
|
2244
|
+
ABLATION_ENV = "HARNESSED_OFF";
|
|
2245
|
+
}
|
|
2246
|
+
});
|
|
2247
|
+
|
|
2189
2248
|
// src/manifest/lib/path-guard.ts
|
|
2249
|
+
function checkSafeSegment(input) {
|
|
2250
|
+
checkPathSafe(input);
|
|
2251
|
+
if (input === "" || input === "." || input === ".." || /[\\/]/.test(input)) {
|
|
2252
|
+
throw new PathTraversalError();
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2190
2255
|
function checkPathSafe(input) {
|
|
2191
2256
|
for (const re of PATH_TRAVERSAL_PATTERNS) {
|
|
2192
2257
|
if (re.test(input)) throw new PathTraversalError();
|
|
@@ -2398,7 +2463,22 @@ async function isMcpServerRegistered(name) {
|
|
|
2398
2463
|
if (!servers || typeof servers !== "object") return false;
|
|
2399
2464
|
return Object.hasOwn(servers, name);
|
|
2400
2465
|
}
|
|
2466
|
+
function isPluginInToml(raw, pluginName) {
|
|
2467
|
+
const esc = (v) => v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2468
|
+
const [plugin = "", market] = pluginName.split("@");
|
|
2469
|
+
const key = market ? `${esc(plugin)}@${esc(market)}` : `${esc(plugin)}(?:@[^"'\\]]+)?`;
|
|
2470
|
+
const re = new RegExp(`^\\s*\\[plugins\\.(?:"${key}"|'${key}')\\]`, "m");
|
|
2471
|
+
return re.test(raw);
|
|
2472
|
+
}
|
|
2401
2473
|
async function isPluginRegistered(pluginName) {
|
|
2474
|
+
const platform = detectPlatform();
|
|
2475
|
+
if (platform.id === "codex") {
|
|
2476
|
+
try {
|
|
2477
|
+
return isPluginInToml(await readFile(platform.mcpConfigPath, "utf8"), pluginName);
|
|
2478
|
+
} catch {
|
|
2479
|
+
return false;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2402
2482
|
const registryPath = getPluginsRegistry();
|
|
2403
2483
|
if (registryPath !== null) {
|
|
2404
2484
|
try {
|
|
@@ -3124,11 +3204,22 @@ Manual options:
|
|
|
3124
3204
|
Exit code: ${fallback.exit_code}
|
|
3125
3205
|
${yamlShort}`;
|
|
3126
3206
|
console.error(uxText);
|
|
3127
|
-
|
|
3128
|
-
|
|
3207
|
+
throw new WorkflowHaltError(
|
|
3208
|
+
`ralph-loop max-iterations exceeded (${err2.iterations}/${ctx.maxIterations}) for ${ctx.workflowName} / phase ${ctx.phaseId}`,
|
|
3209
|
+
fallback.exit_code
|
|
3210
|
+
);
|
|
3129
3211
|
}
|
|
3212
|
+
var WorkflowHaltError;
|
|
3130
3213
|
var init_fallbackHandlers = __esm({
|
|
3131
3214
|
"src/workflow/lib/fallbackHandlers.ts"() {
|
|
3215
|
+
WorkflowHaltError = class extends Error {
|
|
3216
|
+
constructor(message, exitCode) {
|
|
3217
|
+
super(message);
|
|
3218
|
+
this.exitCode = exitCode;
|
|
3219
|
+
this.name = "WorkflowHaltError";
|
|
3220
|
+
}
|
|
3221
|
+
exitCode;
|
|
3222
|
+
};
|
|
3132
3223
|
}
|
|
3133
3224
|
});
|
|
3134
3225
|
|
|
@@ -3522,20 +3613,25 @@ async function compactWorkflow() {
|
|
|
3522
3613
|
phase: "(none)"
|
|
3523
3614
|
};
|
|
3524
3615
|
}
|
|
3525
|
-
const
|
|
3526
|
-
if (
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3616
|
+
const probe = compactLedger(wf.sub_progress ?? []);
|
|
3617
|
+
if (probe.evicted === 0) return { ...probe, phase: wf.phase };
|
|
3618
|
+
let result = { ...probe, phase: wf.phase };
|
|
3619
|
+
await mutateWorkflow((cur) => {
|
|
3620
|
+
const r = compactLedger(cur.sub_progress ?? []);
|
|
3621
|
+
result = { ...r, phase: cur.phase };
|
|
3622
|
+
if (r.evicted === 0) return cur;
|
|
3623
|
+
const prev = cur.compacted_summary;
|
|
3624
|
+
return {
|
|
3625
|
+
...cur,
|
|
3530
3626
|
sub_progress: r.kept,
|
|
3531
3627
|
compacted_summary: {
|
|
3532
3628
|
evicted: (prev?.evicted ?? 0) + r.evicted,
|
|
3533
3629
|
by_status: mergeCounts(prev?.by_status, r.by_status),
|
|
3534
3630
|
last_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3535
3631
|
}
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
return
|
|
3632
|
+
};
|
|
3633
|
+
});
|
|
3634
|
+
return result;
|
|
3539
3635
|
}
|
|
3540
3636
|
var DEFAULT_THRESHOLD_PCT, DEFAULT_CONTEXT_WINDOW;
|
|
3541
3637
|
var init_compact = __esm({
|
|
@@ -3728,11 +3824,15 @@ var init_budget = __esm({
|
|
|
3728
3824
|
var breakLoop_exports = {};
|
|
3729
3825
|
__export(breakLoop_exports, {
|
|
3730
3826
|
LOOP_THRESHOLD: () => LOOP_THRESHOLD,
|
|
3731
|
-
detectLoop: () => detectLoop
|
|
3827
|
+
detectLoop: () => detectLoop,
|
|
3828
|
+
isSettled: () => isSettled
|
|
3732
3829
|
});
|
|
3733
3830
|
function detectLoop(ledger) {
|
|
3734
3831
|
return ledger.filter((e) => (e.fail_count ?? 0) >= LOOP_THRESHOLD).map((e) => ({ sub: e.sub, count: e.fail_count }));
|
|
3735
3832
|
}
|
|
3833
|
+
function isSettled(e) {
|
|
3834
|
+
return e.status === "done" || e.status === "skipped" || e.status === "rejected";
|
|
3835
|
+
}
|
|
3736
3836
|
var LOOP_THRESHOLD;
|
|
3737
3837
|
var init_breakLoop = __esm({
|
|
3738
3838
|
"src/checkpoint/breakLoop.ts"() {
|
|
@@ -3969,11 +4069,12 @@ async function runCheckpointComplete(sub, opts, deps = defaultRunDeps) {
|
|
|
3969
4069
|
await mutateSubProgress2((e) => markIfSeeded(e, sub, "done", markOpts));
|
|
3970
4070
|
await absorbIntentFor(sub);
|
|
3971
4071
|
const { collectScaleMetrics: collectScaleMetrics2, assessScale: assessScale2 } = await Promise.resolve().then(() => (init_scale(), scale_exports));
|
|
3972
|
-
const { readCurrentWorkflow: readCurrentWorkflow2,
|
|
4072
|
+
const { readCurrentWorkflow: readCurrentWorkflow2, mutateWorkflow: mutateWorkflow2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
3973
4073
|
const afterMark = await readCurrentWorkflow2();
|
|
3974
4074
|
if (afterMark) {
|
|
3975
4075
|
const metrics = await collectScaleMetrics2(process.cwd(), afterMark.sub_progress ?? []);
|
|
3976
|
-
|
|
4076
|
+
const verifyMode = assessScale2(metrics);
|
|
4077
|
+
await mutateWorkflow2((s) => ({ ...s, verify_mode: verifyMode }));
|
|
3977
4078
|
}
|
|
3978
4079
|
const { nextPending: nextPending2 } = await Promise.resolve().then(() => (init_ledger(), ledger_exports));
|
|
3979
4080
|
const allResolved = nextPending2(afterMark?.sub_progress ?? []) === null;
|
|
@@ -4010,7 +4111,7 @@ async function runCheckpointComplete(sub, opts, deps = defaultRunDeps) {
|
|
|
4010
4111
|
try {
|
|
4011
4112
|
const { defaultShipReady: defaultShipReady2 } = await Promise.resolve().then(() => (init_shipReady(), shipReady_exports));
|
|
4012
4113
|
const { incrementPhases: incrementPhases2, isRetroDue: isRetroDue2, retroThreshold: retroThreshold2 } = await Promise.resolve().then(() => (init_retroMeta(), retroMeta_exports));
|
|
4013
|
-
const { mutateStore: mutateStore2,
|
|
4114
|
+
const { mutateStore: mutateStore2, mutateWorkflow: mutateWorkflow3 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
4014
4115
|
const { repoKey: repoKey2 } = await Promise.resolve().then(() => (init_workflowStore(), workflowStore_exports));
|
|
4015
4116
|
const ship = defaultShipReady2(process.cwd());
|
|
4016
4117
|
const key = repoKey2();
|
|
@@ -4023,15 +4124,12 @@ async function runCheckpointComplete(sub, opts, deps = defaultRunDeps) {
|
|
|
4023
4124
|
retroDue = isRetroDue2(next.phases_since_retro, threshold);
|
|
4024
4125
|
return { ...store, retro_meta: meta };
|
|
4025
4126
|
});
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
retro_due: retroDue
|
|
4033
|
-
});
|
|
4034
|
-
}
|
|
4127
|
+
await mutateWorkflow3((s) => ({
|
|
4128
|
+
...s,
|
|
4129
|
+
ship_ready: ship.ready,
|
|
4130
|
+
ship_commits: ship.commits,
|
|
4131
|
+
retro_due: retroDue
|
|
4132
|
+
}));
|
|
4035
4133
|
} catch {
|
|
4036
4134
|
}
|
|
4037
4135
|
}
|
|
@@ -4113,7 +4211,7 @@ async function runCheckpointReopen(sub, opts, deps = defaultRunDeps) {
|
|
|
4113
4211
|
deps.exit(1);
|
|
4114
4212
|
return;
|
|
4115
4213
|
}
|
|
4116
|
-
const { readCurrentWorkflow: readCurrentWorkflow2,
|
|
4214
|
+
const { readCurrentWorkflow: readCurrentWorkflow2, mutateWorkflow: mutateWorkflow2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
4117
4215
|
const wf = await readCurrentWorkflow2();
|
|
4118
4216
|
if (!wf) {
|
|
4119
4217
|
deps.error("[harnessed] checkpoint reopen: no active workflow \u2014 nothing to send back.");
|
|
@@ -4129,10 +4227,11 @@ async function runCheckpointReopen(sub, opts, deps = defaultRunDeps) {
|
|
|
4129
4227
|
deps.exit(1);
|
|
4130
4228
|
return;
|
|
4131
4229
|
}
|
|
4132
|
-
await
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4230
|
+
await mutateWorkflow2((s) => ({
|
|
4231
|
+
...s,
|
|
4232
|
+
sub_progress: reopenSub2(s.sub_progress ?? [], sub, reason),
|
|
4233
|
+
status: s.status === "complete" ? "active" : s.status
|
|
4234
|
+
}));
|
|
4136
4235
|
const latest = await readCurrentWorkflow2();
|
|
4137
4236
|
const entry = latest?.sub_progress?.find((e) => e.sub === sub);
|
|
4138
4237
|
const attempts = entry?.fail_count ?? 0;
|
|
@@ -4580,8 +4679,8 @@ __export(aliases_exports, {
|
|
|
4580
4679
|
});
|
|
4581
4680
|
function loadAliases() {
|
|
4582
4681
|
if (_cached) return _cached;
|
|
4583
|
-
if (!existsSync(
|
|
4584
|
-
const raw = readFileSync(
|
|
4682
|
+
if (!existsSync(aliasesPath())) return null;
|
|
4683
|
+
const raw = readFileSync(aliasesPath(), "utf8");
|
|
4585
4684
|
const parsed = parse(raw);
|
|
4586
4685
|
if (!Value.Check(AliasesV1, parsed)) {
|
|
4587
4686
|
const errs = [...Value.Errors(AliasesV1, parsed)].slice(0, 3);
|
|
@@ -4600,12 +4699,13 @@ function listDeprecations() {
|
|
|
4600
4699
|
const a = loadAliases();
|
|
4601
4700
|
return a ? Object.entries(a.aliases).map(([old, entry]) => ({ old, entry })) : [];
|
|
4602
4701
|
}
|
|
4603
|
-
var
|
|
4702
|
+
var aliasesPath, _cached;
|
|
4604
4703
|
var init_aliases = __esm({
|
|
4605
4704
|
"src/manifest/aliases.ts"() {
|
|
4705
|
+
init_assetsRoot();
|
|
4606
4706
|
init_path_guard();
|
|
4607
4707
|
init_aliases_v1();
|
|
4608
|
-
|
|
4708
|
+
aliasesPath = () => join(getAssetsRoot(), "manifests", "aliases.yaml");
|
|
4609
4709
|
_cached = null;
|
|
4610
4710
|
}
|
|
4611
4711
|
});
|
|
@@ -5396,6 +5496,13 @@ function npmExecutable() {
|
|
|
5396
5496
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
5397
5497
|
}
|
|
5398
5498
|
async function defaultRunner() {
|
|
5499
|
+
if (process.platform === "win32") {
|
|
5500
|
+
const { stdout: stdout3 } = await execAsync("npm view harnessed version", {
|
|
5501
|
+
timeout: 8e3,
|
|
5502
|
+
windowsHide: true
|
|
5503
|
+
});
|
|
5504
|
+
return stdout3;
|
|
5505
|
+
}
|
|
5399
5506
|
const { stdout: stdout2 } = await execFileAsync(npmExecutable(), ["view", "harnessed", "version"], {
|
|
5400
5507
|
timeout: 8e3,
|
|
5401
5508
|
windowsHide: true
|
|
@@ -5410,10 +5517,11 @@ async function fetchLatestVersion(runner = defaultRunner) {
|
|
|
5410
5517
|
return null;
|
|
5411
5518
|
}
|
|
5412
5519
|
}
|
|
5413
|
-
var execFileAsync;
|
|
5520
|
+
var execFileAsync, execAsync;
|
|
5414
5521
|
var init_version_check = __esm({
|
|
5415
5522
|
"src/cli/lib/version-check.ts"() {
|
|
5416
5523
|
execFileAsync = promisify(execFile);
|
|
5524
|
+
execAsync = promisify(exec);
|
|
5417
5525
|
}
|
|
5418
5526
|
});
|
|
5419
5527
|
|
|
@@ -5554,7 +5662,12 @@ function joinFor(platform) {
|
|
|
5554
5662
|
function realNpmPrefix() {
|
|
5555
5663
|
try {
|
|
5556
5664
|
if (typeof spawnSync !== "function") return null;
|
|
5557
|
-
const r = spawnSync("npm
|
|
5665
|
+
const r = process.platform === "win32" ? spawnSync("npm prefix -g", {
|
|
5666
|
+
encoding: "utf8",
|
|
5667
|
+
timeout: 5e3,
|
|
5668
|
+
shell: true,
|
|
5669
|
+
windowsHide: true
|
|
5670
|
+
}) : spawnSync("npm", ["prefix", "-g"], { encoding: "utf8", timeout: 5e3 });
|
|
5558
5671
|
if (!r || r.error || r.status !== 0) return null;
|
|
5559
5672
|
const out = (r.stdout ?? "").trim();
|
|
5560
5673
|
return out.length > 0 ? out : null;
|
|
@@ -6200,6 +6313,30 @@ var init_check_plugin_staleness = __esm({
|
|
|
6200
6313
|
}
|
|
6201
6314
|
});
|
|
6202
6315
|
|
|
6316
|
+
// src/cli/lib/check-ablation.ts
|
|
6317
|
+
var check_ablation_exports = {};
|
|
6318
|
+
__export(check_ablation_exports, {
|
|
6319
|
+
checkAblation: () => checkAblation
|
|
6320
|
+
});
|
|
6321
|
+
function checkAblation(env = process.env) {
|
|
6322
|
+
if (!isAblated(env)) {
|
|
6323
|
+
return { name: NAME5, status: "pass", message: "active" };
|
|
6324
|
+
}
|
|
6325
|
+
return {
|
|
6326
|
+
name: NAME5,
|
|
6327
|
+
status: "warn",
|
|
6328
|
+
message: `${ABLATION_ENV}=1 \u2014 harnessed's always-on surface is OFF: every first-party hook no-ops (per-turn injection, SessionStart invalidation, Stop recovery, doc-discipline gate, dashboard autospawn). Nothing else is disabled, and no files were moved.`,
|
|
6329
|
+
fix: `unset ${ABLATION_ENV} (or set it to anything other than 1) and start a new session`
|
|
6330
|
+
};
|
|
6331
|
+
}
|
|
6332
|
+
var NAME5;
|
|
6333
|
+
var init_check_ablation = __esm({
|
|
6334
|
+
"src/cli/lib/check-ablation.ts"() {
|
|
6335
|
+
init_ablation();
|
|
6336
|
+
NAME5 = "ablation switch";
|
|
6337
|
+
}
|
|
6338
|
+
});
|
|
6339
|
+
|
|
6203
6340
|
// src/cli/lib/doctor-registry.ts
|
|
6204
6341
|
var CHECKS;
|
|
6205
6342
|
var init_doctor_registry = __esm({
|
|
@@ -6261,7 +6398,11 @@ var init_doctor_registry = __esm({
|
|
|
6261
6398
|
// the four cc-plugin-marketplace components drift behind without any signal.
|
|
6262
6399
|
// The only comparison in the codebase between a genuinely DETECTED version and
|
|
6263
6400
|
// a recorded one — see the header for why the installer-state layer cannot do it.
|
|
6264
|
-
async () => (await Promise.resolve().then(() => (init_check_plugin_staleness(), check_plugin_staleness_exports))).checkPluginStaleness()
|
|
6401
|
+
async () => (await Promise.resolve().then(() => (init_check_plugin_staleness(), check_plugin_staleness_exports))).checkPluginStaleness(),
|
|
6402
|
+
// Phase 60 — HARNESSED_OFF left on (warn-only): the kill switch silences every
|
|
6403
|
+
// first-party hook, so a machine that forgot to unset it looks exactly like a
|
|
6404
|
+
// broken install. doctor is where that gets said out loud.
|
|
6405
|
+
async () => (await Promise.resolve().then(() => (init_check_ablation(), check_ablation_exports))).checkAblation()
|
|
6265
6406
|
];
|
|
6266
6407
|
}
|
|
6267
6408
|
});
|
|
@@ -6854,6 +6995,13 @@ __export(gc_exports, {
|
|
|
6854
6995
|
gcCompiledArtifacts: () => gcCompiledArtifacts,
|
|
6855
6996
|
registerGc: () => registerGc
|
|
6856
6997
|
});
|
|
6998
|
+
function byVersion(a, b) {
|
|
6999
|
+
const c = compareVersions(a, b);
|
|
7000
|
+
if (c === "behind") return -1;
|
|
7001
|
+
if (c === "ahead") return 1;
|
|
7002
|
+
if (c === "current") return 0;
|
|
7003
|
+
return a.localeCompare(b);
|
|
7004
|
+
}
|
|
6857
7005
|
async function gcCompiledArtifacts(opts) {
|
|
6858
7006
|
const removed = [];
|
|
6859
7007
|
const kept = [];
|
|
@@ -6874,7 +7022,7 @@ async function gcCompiledArtifacts(opts) {
|
|
|
6874
7022
|
}
|
|
6875
7023
|
try {
|
|
6876
7024
|
const backupDir = join(opts.stateRoot, "bin-backup");
|
|
6877
|
-
const vers = (await readdir(backupDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
7025
|
+
const vers = (await readdir(backupDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort(byVersion);
|
|
6878
7026
|
for (const v of vers.slice(0, -1)) {
|
|
6879
7027
|
const p7 = join(backupDir, v);
|
|
6880
7028
|
removed.push(p7);
|
|
@@ -7009,6 +7157,7 @@ var init_gc = __esm({
|
|
|
7009
7157
|
init_package();
|
|
7010
7158
|
init_i18n();
|
|
7011
7159
|
init_backup();
|
|
7160
|
+
init_version_check();
|
|
7012
7161
|
DURATION_RE = /^(\d+)([dhmw])$/;
|
|
7013
7162
|
}
|
|
7014
7163
|
});
|
|
@@ -7210,6 +7359,20 @@ async function updateInstalled(cwd, name, version, manifestSha1) {
|
|
|
7210
7359
|
};
|
|
7211
7360
|
await writeState(cwd, state);
|
|
7212
7361
|
}
|
|
7362
|
+
async function recordObservedInstall(cwd, name, version, manifestSha1) {
|
|
7363
|
+
try {
|
|
7364
|
+
const state = await readState(cwd);
|
|
7365
|
+
const prev = state.installed[name];
|
|
7366
|
+
if (prev && prev.version === version && prev.manifestSha1 === manifestSha1) return;
|
|
7367
|
+
state.installed[name] = {
|
|
7368
|
+
version,
|
|
7369
|
+
installedAt: prev?.installedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
7370
|
+
manifestSha1
|
|
7371
|
+
};
|
|
7372
|
+
await writeState(cwd, state);
|
|
7373
|
+
} catch {
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7213
7376
|
var DEFAULT_STATE;
|
|
7214
7377
|
var init_state2 = __esm({
|
|
7215
7378
|
"src/installers/lib/state.ts"() {
|
|
@@ -7220,6 +7383,7 @@ var init_state2 = __esm({
|
|
|
7220
7383
|
var installCcHookAdd;
|
|
7221
7384
|
var init_ccHookAdd2 = __esm({
|
|
7222
7385
|
"src/installers/ccHookAdd.ts"() {
|
|
7386
|
+
init_security();
|
|
7223
7387
|
init_assetsRoot();
|
|
7224
7388
|
init_platform();
|
|
7225
7389
|
init_backup();
|
|
@@ -7272,10 +7436,35 @@ var init_ccHookAdd2 = __esm({
|
|
|
7272
7436
|
)
|
|
7273
7437
|
};
|
|
7274
7438
|
}
|
|
7439
|
+
if (settings === null || typeof settings !== "object" || Array.isArray(settings)) {
|
|
7440
|
+
return {
|
|
7441
|
+
ok: false,
|
|
7442
|
+
phase: "preflight",
|
|
7443
|
+
error: err(
|
|
7444
|
+
ctx,
|
|
7445
|
+
"/",
|
|
7446
|
+
`malformed settings.json: top-level value must be a JSON object, got ${settings === null ? "null" : Array.isArray(settings) ? "array" : typeof settings}`,
|
|
7447
|
+
"settings-json-malformed"
|
|
7448
|
+
)
|
|
7449
|
+
};
|
|
7450
|
+
}
|
|
7275
7451
|
settings.hooks = settings.hooks ?? {};
|
|
7276
7452
|
const ev = install.hook_event;
|
|
7277
7453
|
const matcher = install.hook_matcher;
|
|
7278
7454
|
const cmd = install.hook_command;
|
|
7455
|
+
const cmdViolation = checkCmdString(cmd);
|
|
7456
|
+
if (cmdViolation) {
|
|
7457
|
+
return {
|
|
7458
|
+
ok: false,
|
|
7459
|
+
phase: "preflight",
|
|
7460
|
+
error: err(
|
|
7461
|
+
ctx,
|
|
7462
|
+
"/spec/install/hook_command",
|
|
7463
|
+
`shell escape detected in hook_command: ${cmdViolation.label} (${cmdViolation.hint})`,
|
|
7464
|
+
"security-gate-bypass"
|
|
7465
|
+
)
|
|
7466
|
+
};
|
|
7467
|
+
}
|
|
7279
7468
|
const cmdDeps = {
|
|
7280
7469
|
assetsRoot: getAssetsRoot,
|
|
7281
7470
|
exists: existsSync,
|
|
@@ -7286,7 +7475,8 @@ var init_ccHookAdd2 = __esm({
|
|
|
7286
7475
|
const arr = settings.hooks[ev] ?? [];
|
|
7287
7476
|
const ours = arr.filter((e) => entryMatchesRegistration(e, cmd, resolvedCmd, marker));
|
|
7288
7477
|
if (ours.length === 1 && isDesiredHookEntry(ours[0] ?? {}, matcher, resolvedCmd)) {
|
|
7289
|
-
|
|
7478
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, "", "");
|
|
7479
|
+
return { ok: true, alreadyInstalled: true, backupId: "idempotent-skip" };
|
|
7290
7480
|
}
|
|
7291
7481
|
const others = arr.filter((e) => !entryMatchesRegistration(e, cmd, resolvedCmd, marker));
|
|
7292
7482
|
settings.hooks[ev] = [...others, desiredHookEntry(matcher, resolvedCmd)];
|
|
@@ -7339,6 +7529,130 @@ var init_ccHookAdd2 = __esm({
|
|
|
7339
7529
|
};
|
|
7340
7530
|
}
|
|
7341
7531
|
});
|
|
7532
|
+
|
|
7533
|
+
// src/installers/lib/gitCloneArgs.ts
|
|
7534
|
+
function parseGitCloneDest(cmd) {
|
|
7535
|
+
const idx = cmd.indexOf("git clone");
|
|
7536
|
+
if (idx < 0) return null;
|
|
7537
|
+
const tokens = cmd.slice(idx + "git clone".length).trim().split(/\s+/);
|
|
7538
|
+
let i = 0;
|
|
7539
|
+
while (i < tokens.length) {
|
|
7540
|
+
const t2 = tokens[i];
|
|
7541
|
+
if (t2 === "--") {
|
|
7542
|
+
i += 1;
|
|
7543
|
+
break;
|
|
7544
|
+
}
|
|
7545
|
+
if (!t2.startsWith("-")) break;
|
|
7546
|
+
if (t2.startsWith("--") && t2.includes("=")) i += 1;
|
|
7547
|
+
else if (VALUE_FLAGS.has(t2)) i += 2;
|
|
7548
|
+
else if (BARE_FLAGS.has(t2)) i += 1;
|
|
7549
|
+
else return null;
|
|
7550
|
+
}
|
|
7551
|
+
const url = tokens[i];
|
|
7552
|
+
const dest = tokens[i + 1];
|
|
7553
|
+
if (!url || CLAUSE_END.has(url)) return null;
|
|
7554
|
+
if (!dest || CLAUSE_END.has(dest)) return null;
|
|
7555
|
+
return { raw: dest, cloneIdx: idx };
|
|
7556
|
+
}
|
|
7557
|
+
var VALUE_FLAGS, BARE_FLAGS, CLAUSE_END;
|
|
7558
|
+
var init_gitCloneArgs = __esm({
|
|
7559
|
+
"src/installers/lib/gitCloneArgs.ts"() {
|
|
7560
|
+
VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
7561
|
+
"-b",
|
|
7562
|
+
"--branch",
|
|
7563
|
+
"--depth",
|
|
7564
|
+
"-o",
|
|
7565
|
+
"--origin",
|
|
7566
|
+
"-u",
|
|
7567
|
+
"--upload-pack",
|
|
7568
|
+
"--reference",
|
|
7569
|
+
"--reference-if-able",
|
|
7570
|
+
"--separate-git-dir",
|
|
7571
|
+
"-c",
|
|
7572
|
+
"--config",
|
|
7573
|
+
"--shallow-since",
|
|
7574
|
+
"--shallow-exclude",
|
|
7575
|
+
"-j",
|
|
7576
|
+
"--jobs",
|
|
7577
|
+
"--filter",
|
|
7578
|
+
"--template",
|
|
7579
|
+
"--server-option",
|
|
7580
|
+
"--bundle-uri",
|
|
7581
|
+
"--ref-format"
|
|
7582
|
+
]);
|
|
7583
|
+
BARE_FLAGS = /* @__PURE__ */ new Set([
|
|
7584
|
+
"-q",
|
|
7585
|
+
"--quiet",
|
|
7586
|
+
"-v",
|
|
7587
|
+
"--verbose",
|
|
7588
|
+
"--progress",
|
|
7589
|
+
"-n",
|
|
7590
|
+
"--no-checkout",
|
|
7591
|
+
"--bare",
|
|
7592
|
+
"--mirror",
|
|
7593
|
+
"-l",
|
|
7594
|
+
"--local",
|
|
7595
|
+
"--no-local",
|
|
7596
|
+
"--no-hardlinks",
|
|
7597
|
+
"-s",
|
|
7598
|
+
"--shared",
|
|
7599
|
+
"--single-branch",
|
|
7600
|
+
"--no-single-branch",
|
|
7601
|
+
"--tags",
|
|
7602
|
+
"--no-tags",
|
|
7603
|
+
"--recursive",
|
|
7604
|
+
"--recurse-submodules",
|
|
7605
|
+
"--shallow-submodules",
|
|
7606
|
+
"--no-shallow-submodules",
|
|
7607
|
+
"--remote-submodules",
|
|
7608
|
+
"--no-remote-submodules",
|
|
7609
|
+
"--sparse",
|
|
7610
|
+
"--reject-shallow",
|
|
7611
|
+
"--no-reject-shallow",
|
|
7612
|
+
"--also-filter-submodules"
|
|
7613
|
+
]);
|
|
7614
|
+
CLAUSE_END = /* @__PURE__ */ new Set(["&&", ";", "|", "||"]);
|
|
7615
|
+
}
|
|
7616
|
+
});
|
|
7617
|
+
function descendantsOf(pid) {
|
|
7618
|
+
const r = spawnSync("pgrep", ["-P", String(pid)], { encoding: "utf8", timeout: 2e3 });
|
|
7619
|
+
if (r.status !== 0 || typeof r.stdout !== "string") return [];
|
|
7620
|
+
const out = [];
|
|
7621
|
+
for (const tok2 of r.stdout.split(/\s+/)) {
|
|
7622
|
+
const child = Number(tok2);
|
|
7623
|
+
if (Number.isInteger(child) && child > 0) out.push(child, ...descendantsOf(child));
|
|
7624
|
+
}
|
|
7625
|
+
return out;
|
|
7626
|
+
}
|
|
7627
|
+
function killProcessTree(child) {
|
|
7628
|
+
const pid = child.pid;
|
|
7629
|
+
if (pid === void 0) {
|
|
7630
|
+
child.kill("SIGKILL");
|
|
7631
|
+
return;
|
|
7632
|
+
}
|
|
7633
|
+
if (process.platform === "win32") {
|
|
7634
|
+
const r = spawnSync("taskkill", ["/PID", String(pid), "/T", "/F"], {
|
|
7635
|
+
windowsHide: true,
|
|
7636
|
+
stdio: "ignore",
|
|
7637
|
+
timeout: 5e3
|
|
7638
|
+
});
|
|
7639
|
+
if (r.status === 0) return;
|
|
7640
|
+
child.kill("SIGKILL");
|
|
7641
|
+
return;
|
|
7642
|
+
}
|
|
7643
|
+
const tree = descendantsOf(pid);
|
|
7644
|
+
child.kill("SIGKILL");
|
|
7645
|
+
for (const d of tree) {
|
|
7646
|
+
try {
|
|
7647
|
+
process.kill(d, "SIGKILL");
|
|
7648
|
+
} catch {
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
var init_killTree = __esm({
|
|
7653
|
+
"src/installers/lib/killTree.ts"() {
|
|
7654
|
+
}
|
|
7655
|
+
});
|
|
7342
7656
|
function evalClause(clause, home) {
|
|
7343
7657
|
const m = clause.match(CLAUSE_RE);
|
|
7344
7658
|
if (!m?.[1] || !m[2]) return null;
|
|
@@ -7489,10 +7803,10 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
7489
7803
|
child.stderr?.setEncoding("utf8").on("data", (chunk) => {
|
|
7490
7804
|
stderr += chunk;
|
|
7491
7805
|
});
|
|
7492
|
-
return await new Promise((
|
|
7806
|
+
return await new Promise((resolve23) => {
|
|
7493
7807
|
const timer = setTimeout(() => {
|
|
7494
|
-
child
|
|
7495
|
-
|
|
7808
|
+
killProcessTree(child);
|
|
7809
|
+
resolve23({
|
|
7496
7810
|
ok: false,
|
|
7497
7811
|
phase: "spawn",
|
|
7498
7812
|
error: {
|
|
@@ -7513,7 +7827,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
7513
7827
|
child.on("error", (err2) => {
|
|
7514
7828
|
clearTimeout(timer);
|
|
7515
7829
|
const bashMissing = triedBash && err2.code === "ENOENT";
|
|
7516
|
-
|
|
7830
|
+
resolve23({
|
|
7517
7831
|
ok: false,
|
|
7518
7832
|
phase: "spawn",
|
|
7519
7833
|
error: {
|
|
@@ -7528,7 +7842,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
7528
7842
|
});
|
|
7529
7843
|
child.on("close", (code) => {
|
|
7530
7844
|
clearTimeout(timer);
|
|
7531
|
-
|
|
7845
|
+
resolve23({ ok: true, exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
7532
7846
|
});
|
|
7533
7847
|
});
|
|
7534
7848
|
}
|
|
@@ -7536,6 +7850,7 @@ var POSIX_SYNTAX_RE, POSIX_FIRST_TOKENS, DEFAULT_VERIFY_TIMEOUT_MS, DEFAULT_INST
|
|
|
7536
7850
|
var init_spawn = __esm({
|
|
7537
7851
|
"src/installers/lib/spawn.ts"() {
|
|
7538
7852
|
init_security();
|
|
7853
|
+
init_killTree();
|
|
7539
7854
|
init_nativeTest();
|
|
7540
7855
|
init_resolveBash();
|
|
7541
7856
|
init_safeCwd();
|
|
@@ -7578,16 +7893,8 @@ function extractSkillName(cmd, fallback) {
|
|
|
7578
7893
|
return seg[seg.length - 1] ?? fallback;
|
|
7579
7894
|
}
|
|
7580
7895
|
function extractGitCloneTarget(cmd) {
|
|
7581
|
-
const
|
|
7582
|
-
if (
|
|
7583
|
-
const tail = cmd.slice(idx + "git clone".length).trim();
|
|
7584
|
-
const tokens = tail.split(/\s+/);
|
|
7585
|
-
let i = 0;
|
|
7586
|
-
while (i < tokens.length && tokens[i]?.startsWith("-")) {
|
|
7587
|
-
i += tokens[i]?.includes("=") ? 1 : 2;
|
|
7588
|
-
}
|
|
7589
|
-
const dest = tokens[i + 1];
|
|
7590
|
-
if (!dest || dest === "&&" || dest === ";" || dest === "|") return null;
|
|
7896
|
+
const dest = parseGitCloneDest(cmd)?.raw;
|
|
7897
|
+
if (!dest) return null;
|
|
7591
7898
|
if (dest.startsWith("~/")) return join(homedir(), dest.slice(2));
|
|
7592
7899
|
if (dest.startsWith("/") || /^[A-Z]:[\\/]/i.test(dest)) return dest;
|
|
7593
7900
|
return null;
|
|
@@ -7630,7 +7937,7 @@ async function detectNative(ctx) {
|
|
|
7630
7937
|
}
|
|
7631
7938
|
}
|
|
7632
7939
|
if (method === "cc-plugin-marketplace") {
|
|
7633
|
-
const m = cmd.match(/
|
|
7940
|
+
const m = cmd.match(/plugin\s+(?:install|add)\s+(?!marketplaceb)(\S+)/i);
|
|
7634
7941
|
const pluginName = m?.[1]?.split("@")[0] ?? name;
|
|
7635
7942
|
try {
|
|
7636
7943
|
return await isPluginRegistered(pluginName);
|
|
@@ -7718,6 +8025,7 @@ var init_idempotent = __esm({
|
|
|
7718
8025
|
init_assetsRoot();
|
|
7719
8026
|
init_platform();
|
|
7720
8027
|
init_binaryProbe();
|
|
8028
|
+
init_gitCloneArgs();
|
|
7721
8029
|
init_hookEntry();
|
|
7722
8030
|
init_readClaudeConfig();
|
|
7723
8031
|
init_spawn();
|
|
@@ -7728,11 +8036,63 @@ var init_idempotent = __esm({
|
|
|
7728
8036
|
};
|
|
7729
8037
|
}
|
|
7730
8038
|
});
|
|
8039
|
+
function escapeCommand(cmd) {
|
|
8040
|
+
return cmd.replace(META, "^$1");
|
|
8041
|
+
}
|
|
8042
|
+
function escapeArgument(arg, doubleEscape) {
|
|
8043
|
+
let a = `${arg}`;
|
|
8044
|
+
a = a.replace(/(\\*)"/g, '$1$1\\"');
|
|
8045
|
+
a = a.replace(/(\\*)$/, "$1$1");
|
|
8046
|
+
a = `"${a}"`;
|
|
8047
|
+
a = a.replace(META, "^$1");
|
|
8048
|
+
a = a.replace(META, "^$1");
|
|
8049
|
+
return a;
|
|
8050
|
+
}
|
|
8051
|
+
function resolveWindowsBin(bin, env = process.env, isFile = (p7) => existsSync(p7) && statSync(p7).isFile()) {
|
|
8052
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(";").filter(Boolean);
|
|
8053
|
+
const exts = (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
8054
|
+
const candidates = extname(bin) ? [""] : exts;
|
|
8055
|
+
for (const dir of dirs) {
|
|
8056
|
+
for (const ext of candidates) {
|
|
8057
|
+
const p7 = join40(dir, `${bin}${ext}`);
|
|
8058
|
+
if (isFile(p7)) return p7;
|
|
8059
|
+
}
|
|
8060
|
+
}
|
|
8061
|
+
return null;
|
|
8062
|
+
}
|
|
8063
|
+
function planWindowsSpawn(bin, args, resolved) {
|
|
8064
|
+
if (!resolved) return { command: bin, args, verbatim: false };
|
|
8065
|
+
const ext = extname(resolved).toLowerCase();
|
|
8066
|
+
if (ext !== ".cmd" && ext !== ".bat") {
|
|
8067
|
+
return { command: resolved, args, verbatim: false };
|
|
8068
|
+
}
|
|
8069
|
+
const line = [escapeCommand(resolved), ...args.map((a) => escapeArgument(a))].join(" ");
|
|
8070
|
+
return { command: "cmd.exe", args: ["/d", "/s", "/c", `"${line}"`], verbatim: true };
|
|
8071
|
+
}
|
|
8072
|
+
var extname, join40, META;
|
|
8073
|
+
var init_winSpawn = __esm({
|
|
8074
|
+
"src/installers/lib/winSpawn.ts"() {
|
|
8075
|
+
({ extname, join: join40 } = win32);
|
|
8076
|
+
META = /([()\][%!^"`<>&|;, *?])/g;
|
|
8077
|
+
}
|
|
8078
|
+
});
|
|
7731
8079
|
function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
7732
|
-
return new Promise((
|
|
8080
|
+
return new Promise((resolve23) => {
|
|
7733
8081
|
const isWin = process.platform === "win32";
|
|
7734
8082
|
const stdio = ["ignore", "pipe", "pipe"];
|
|
7735
|
-
|
|
8083
|
+
let child;
|
|
8084
|
+
if (isWin) {
|
|
8085
|
+
const plan = planWindowsSpawn(bin, args, resolveWindowsBin(bin));
|
|
8086
|
+
child = spawn(plan.command, plan.args, {
|
|
8087
|
+
cwd,
|
|
8088
|
+
windowsHide: true,
|
|
8089
|
+
stdio,
|
|
8090
|
+
shell: false,
|
|
8091
|
+
windowsVerbatimArguments: plan.verbatim
|
|
8092
|
+
});
|
|
8093
|
+
} else {
|
|
8094
|
+
child = spawn(bin, args, { cwd, shell: false, stdio });
|
|
8095
|
+
}
|
|
7736
8096
|
let stdout2 = "";
|
|
7737
8097
|
let stderr = "";
|
|
7738
8098
|
child.stdout?.setEncoding("utf8").on("data", (c) => {
|
|
@@ -7742,18 +8102,18 @@ function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
|
|
|
7742
8102
|
stderr += c;
|
|
7743
8103
|
});
|
|
7744
8104
|
const timer = setTimeout(() => {
|
|
7745
|
-
child
|
|
7746
|
-
|
|
8105
|
+
killProcessTree(child);
|
|
8106
|
+
resolve23({ exitCode: -1, stdout: stdout2, stderr: `${stderr}[timeout after ${timeoutMs}ms]` });
|
|
7747
8107
|
}, timeoutMs);
|
|
7748
8108
|
child.on("error", (e) => {
|
|
7749
8109
|
clearTimeout(timer);
|
|
7750
8110
|
const enoent = e.code === "ENOENT";
|
|
7751
8111
|
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;
|
|
7752
|
-
|
|
8112
|
+
resolve23({ exitCode: -1, stdout: stdout2, stderr: `${stderr}${msg}` });
|
|
7753
8113
|
});
|
|
7754
8114
|
child.on("close", (code) => {
|
|
7755
8115
|
clearTimeout(timer);
|
|
7756
|
-
|
|
8116
|
+
resolve23({ exitCode: code ?? -1, stdout: stdout2, stderr });
|
|
7757
8117
|
});
|
|
7758
8118
|
});
|
|
7759
8119
|
}
|
|
@@ -7762,6 +8122,8 @@ function runArgs(claudeArgs, cwd, timeoutMs = 15e3) {
|
|
|
7762
8122
|
}
|
|
7763
8123
|
var init_runClaudeArgs = __esm({
|
|
7764
8124
|
"src/installers/lib/runClaudeArgs.ts"() {
|
|
8125
|
+
init_killTree();
|
|
8126
|
+
init_winSpawn();
|
|
7765
8127
|
}
|
|
7766
8128
|
});
|
|
7767
8129
|
|
|
@@ -7822,6 +8184,7 @@ var init_ccPluginMarketplace2 = __esm({
|
|
|
7822
8184
|
return { ok: false, phase: "preflight", error: e };
|
|
7823
8185
|
}
|
|
7824
8186
|
if (await isAlreadyInstalled(ctx)) {
|
|
8187
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
|
|
7825
8188
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
7826
8189
|
}
|
|
7827
8190
|
const parsed = parseCmd(install.cmd);
|
|
@@ -7841,10 +8204,12 @@ var init_ccPluginMarketplace2 = __esm({
|
|
|
7841
8204
|
};
|
|
7842
8205
|
}
|
|
7843
8206
|
const pluginName = parsed.pluginAtMkt.split("@")[0] ?? parsed.pluginAtMkt;
|
|
8207
|
+
const declaredRef = install.marketplace_source?.source === "github" ? install.marketplace_source.repo : null;
|
|
8208
|
+
const marketplaceRef = declaredRef ?? parsed.marketplaceRef;
|
|
7844
8209
|
const installArgs = bin === "codex" ? ["plugin", "add", parsed.pluginAtMkt] : ["plugin", "install", parsed.pluginAtMkt, "--scope", "user"];
|
|
7845
8210
|
const allArgs = [];
|
|
7846
|
-
if (
|
|
7847
|
-
allArgs.push(["plugin", "marketplace", "add",
|
|
8211
|
+
if (marketplaceRef !== null) {
|
|
8212
|
+
allArgs.push(["plugin", "marketplace", "add", marketplaceRef]);
|
|
7848
8213
|
}
|
|
7849
8214
|
allArgs.push(installArgs);
|
|
7850
8215
|
for (const argSet of allArgs) {
|
|
@@ -7890,12 +8255,8 @@ ${newEntry}
|
|
|
7890
8255
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
7891
8256
|
const spawnCwd = install.cwd ?? getMcpSpawnCwd();
|
|
7892
8257
|
let stepOneStderr = "";
|
|
7893
|
-
if (
|
|
7894
|
-
const r1 = await runHarnessArgs(
|
|
7895
|
-
bin,
|
|
7896
|
-
["plugin", "marketplace", "add", parsed.marketplaceRef],
|
|
7897
|
-
spawnCwd
|
|
7898
|
-
);
|
|
8258
|
+
if (marketplaceRef !== null) {
|
|
8259
|
+
const r1 = await runHarnessArgs(bin, ["plugin", "marketplace", "add", marketplaceRef], spawnCwd);
|
|
7899
8260
|
stepOneStderr = r1.stderr;
|
|
7900
8261
|
}
|
|
7901
8262
|
const r2 = await runHarnessArgs(bin, installArgs, spawnCwd, 6e4);
|
|
@@ -7913,13 +8274,7 @@ ${newEntry}
|
|
|
7913
8274
|
)
|
|
7914
8275
|
};
|
|
7915
8276
|
}
|
|
7916
|
-
|
|
7917
|
-
if (bin === "codex") {
|
|
7918
|
-
const vr = await runHarnessArgs("codex", ["plugin", "list"], spawnCwd, 15e3);
|
|
7919
|
-
registered = vr.exitCode === 0 && vr.stdout.includes(pluginName);
|
|
7920
|
-
} else {
|
|
7921
|
-
registered = await isPluginRegistered(pluginName);
|
|
7922
|
-
}
|
|
8277
|
+
const registered = await isPluginRegistered(pluginName);
|
|
7923
8278
|
if (!registered) {
|
|
7924
8279
|
const cfgLabel = bin === "codex" ? "`codex plugin list` output" : "enabledPlugins map of ~/.claude.json";
|
|
7925
8280
|
return {
|
|
@@ -8009,7 +8364,7 @@ var init_packSkillAudit = __esm({
|
|
|
8009
8364
|
}
|
|
8010
8365
|
});
|
|
8011
8366
|
function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
8012
|
-
return new Promise((
|
|
8367
|
+
return new Promise((resolve23) => {
|
|
8013
8368
|
const isWin = process.platform === "win32";
|
|
8014
8369
|
const child = isWin ? spawn("cmd.exe", ["/c", "git", "rev-parse", "HEAD"], { cwd, windowsHide: true }) : spawn("git", ["rev-parse", "HEAD"], { cwd, shell: false });
|
|
8015
8370
|
let stdout2 = "";
|
|
@@ -8017,39 +8372,21 @@ function gitRevParseHead(cwd, timeoutMs = 1e4) {
|
|
|
8017
8372
|
stdout2 += c;
|
|
8018
8373
|
});
|
|
8019
8374
|
const timer = setTimeout(() => {
|
|
8020
|
-
child
|
|
8021
|
-
|
|
8375
|
+
killProcessTree(child);
|
|
8376
|
+
resolve23({ sha: "", exit: -1 });
|
|
8022
8377
|
}, timeoutMs);
|
|
8023
8378
|
child.on("error", () => {
|
|
8024
8379
|
clearTimeout(timer);
|
|
8025
|
-
|
|
8380
|
+
resolve23({ sha: "", exit: -1 });
|
|
8026
8381
|
});
|
|
8027
8382
|
child.on("close", (code) => {
|
|
8028
8383
|
clearTimeout(timer);
|
|
8029
|
-
|
|
8384
|
+
resolve23({ sha: stdout2.trim(), exit: code ?? -1 });
|
|
8030
8385
|
});
|
|
8031
8386
|
});
|
|
8032
8387
|
}
|
|
8033
8388
|
function extractRawCloneDest(cmd) {
|
|
8034
|
-
|
|
8035
|
-
if (idx < 0) return null;
|
|
8036
|
-
const tail = cmd.slice(idx + "git clone".length).trim();
|
|
8037
|
-
const tokens = tail.split(/\s+/);
|
|
8038
|
-
let i = 0;
|
|
8039
|
-
while (i < tokens.length) {
|
|
8040
|
-
const t2 = tokens[i];
|
|
8041
|
-
if (t2 === void 0 || !t2.startsWith("-")) break;
|
|
8042
|
-
if (t2 === "--depth" || t2 === "--branch" || t2 === "-b") {
|
|
8043
|
-
i += 2;
|
|
8044
|
-
} else if (t2.includes("=")) {
|
|
8045
|
-
i += 1;
|
|
8046
|
-
} else {
|
|
8047
|
-
i += 2;
|
|
8048
|
-
}
|
|
8049
|
-
}
|
|
8050
|
-
const dest = tokens[i + 1];
|
|
8051
|
-
if (!dest || dest === "&&" || dest === ";" || dest === "|") return null;
|
|
8052
|
-
return { raw: dest, cloneIdx: idx };
|
|
8389
|
+
return parseGitCloneDest(cmd);
|
|
8053
8390
|
}
|
|
8054
8391
|
function extractCloneTarget(cmd) {
|
|
8055
8392
|
const parsed = extractRawCloneDest(cmd);
|
|
@@ -8081,7 +8418,9 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
8081
8418
|
init_confirm();
|
|
8082
8419
|
init_diff();
|
|
8083
8420
|
init_err();
|
|
8421
|
+
init_gitCloneArgs();
|
|
8084
8422
|
init_idempotent();
|
|
8423
|
+
init_killTree();
|
|
8085
8424
|
init_packSkillAudit();
|
|
8086
8425
|
init_preflight();
|
|
8087
8426
|
init_spawn();
|
|
@@ -8109,6 +8448,7 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
8109
8448
|
return { ok: false, phase: "preflight", error: e };
|
|
8110
8449
|
}
|
|
8111
8450
|
if (await isAlreadyInstalled(ctx)) {
|
|
8451
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
|
|
8112
8452
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8113
8453
|
}
|
|
8114
8454
|
if (!/^[a-f0-9]{7,40}$/.test(install.git_ref)) {
|
|
@@ -8305,6 +8645,7 @@ var init_mcpHttpAdd2 = __esm({
|
|
|
8305
8645
|
return { ok: false, phase: "preflight", error: e };
|
|
8306
8646
|
}
|
|
8307
8647
|
if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
|
|
8648
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8308
8649
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8309
8650
|
}
|
|
8310
8651
|
const name = ctx.manifest.metadata.name;
|
|
@@ -8409,6 +8750,7 @@ ${newEntry}
|
|
|
8409
8750
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
8410
8751
|
if (r.exitCode !== 0) {
|
|
8411
8752
|
if (r.stderr.includes("already exists")) {
|
|
8753
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8412
8754
|
return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
|
|
8413
8755
|
}
|
|
8414
8756
|
return {
|
|
@@ -8485,6 +8827,7 @@ var init_mcpStdioAdd2 = __esm({
|
|
|
8485
8827
|
return { ok: false, phase: "preflight", error: e };
|
|
8486
8828
|
}
|
|
8487
8829
|
if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
|
|
8830
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8488
8831
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8489
8832
|
}
|
|
8490
8833
|
const name = ctx.manifest.metadata.name;
|
|
@@ -8555,6 +8898,7 @@ ${newEntry}
|
|
|
8555
8898
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
8556
8899
|
if (r.exitCode !== 0) {
|
|
8557
8900
|
if (r.stderr.includes("already exists")) {
|
|
8901
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8558
8902
|
return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
|
|
8559
8903
|
}
|
|
8560
8904
|
return {
|
|
@@ -8631,6 +8975,7 @@ var init_npmCli2 = __esm({
|
|
|
8631
8975
|
return { ok: false, phase: "preflight", error: e };
|
|
8632
8976
|
}
|
|
8633
8977
|
if (await isAlreadyInstalled(ctx)) {
|
|
8978
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8634
8979
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8635
8980
|
}
|
|
8636
8981
|
let level = detectLevel(install.cmd);
|
|
@@ -8750,6 +9095,7 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
8750
9095
|
return { ok: false, phase: "preflight", error: e };
|
|
8751
9096
|
}
|
|
8752
9097
|
if (await isAlreadyInstalled(ctx)) {
|
|
9098
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8753
9099
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8754
9100
|
}
|
|
8755
9101
|
if (!/\B--copy\b/.test(install.cmd)) {
|
|
@@ -8901,11 +9247,32 @@ function resolveForHarness(manifest) {
|
|
|
8901
9247
|
return { manifest, gate: null };
|
|
8902
9248
|
}
|
|
8903
9249
|
async function runInstall(manifest, opts) {
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
9250
|
+
try {
|
|
9251
|
+
const resolved = resolveForHarness(manifest);
|
|
9252
|
+
if (resolved.gate) return resolved.gate;
|
|
9253
|
+
const effective = resolved.manifest;
|
|
9254
|
+
const installer = installers[effective.spec.install.method];
|
|
9255
|
+
return await installer({
|
|
9256
|
+
manifest: effective,
|
|
9257
|
+
opts,
|
|
9258
|
+
level: levelOf(effective),
|
|
9259
|
+
cwd: process.cwd()
|
|
9260
|
+
});
|
|
9261
|
+
} catch (e) {
|
|
9262
|
+
const code = e.code;
|
|
9263
|
+
return {
|
|
9264
|
+
ok: false,
|
|
9265
|
+
phase: "spawn",
|
|
9266
|
+
error: {
|
|
9267
|
+
file: manifest.metadata.name,
|
|
9268
|
+
path: "/spec/install",
|
|
9269
|
+
message: `installer threw unexpectedly${code ? ` (${code})` : ""}: ${e.message ?? String(e)}`,
|
|
9270
|
+
line: null,
|
|
9271
|
+
column: null,
|
|
9272
|
+
keyword: "installer-exception"
|
|
9273
|
+
}
|
|
9274
|
+
};
|
|
9275
|
+
}
|
|
8909
9276
|
}
|
|
8910
9277
|
var installers, CLAUDE_ONLY_METHODS;
|
|
8911
9278
|
var init_installers = __esm({
|
|
@@ -8992,8 +9359,9 @@ function getPinnedVersion(upstreamName, harnessedVer) {
|
|
|
8992
9359
|
var versionsDir, _cache;
|
|
8993
9360
|
var init_knownGood = __esm({
|
|
8994
9361
|
"src/manifest/knownGood.ts"() {
|
|
9362
|
+
init_assetsRoot();
|
|
8995
9363
|
init_known_good_v1();
|
|
8996
|
-
versionsDir = () => join(
|
|
9364
|
+
versionsDir = () => join(getAssetsRoot(), "versions");
|
|
8997
9365
|
_cache = /* @__PURE__ */ new Map();
|
|
8998
9366
|
}
|
|
8999
9367
|
});
|
|
@@ -9153,7 +9521,7 @@ function buildWorkflowStateBlock(wf, forward, ledgerAgeMs) {
|
|
|
9153
9521
|
if (!wf) return "";
|
|
9154
9522
|
const ledger = wf.sub_progress ?? [];
|
|
9155
9523
|
const next = nextPending(ledger);
|
|
9156
|
-
const loops = detectLoop(ledger);
|
|
9524
|
+
const loops = detectLoop(ledger.filter((e) => !isSettled(e)));
|
|
9157
9525
|
const lines = [
|
|
9158
9526
|
"<workflow-state>",
|
|
9159
9527
|
`phase: ${wf.phase}`,
|
|
@@ -9188,6 +9556,7 @@ function buildWorkflowStateBlock(wf, forward, ledgerAgeMs) {
|
|
|
9188
9556
|
);
|
|
9189
9557
|
}
|
|
9190
9558
|
for (const e of ledger) {
|
|
9559
|
+
if (isSettled(e)) continue;
|
|
9191
9560
|
const attempts = e.fail_count ?? 0;
|
|
9192
9561
|
if (e.attempt_budget !== void 0 && attempts >= e.attempt_budget) {
|
|
9193
9562
|
lines.push(
|
|
@@ -9265,9 +9634,11 @@ function findPhaseContextExcerpt(repoRoot, phase, budget) {
|
|
|
9265
9634
|
try {
|
|
9266
9635
|
const phasesDir = join(repoRoot, ".planning", "phases");
|
|
9267
9636
|
if (!existsSync(phasesDir)) return null;
|
|
9637
|
+
const phaseNum = /(\d+(?:\.\d+)?)/.exec(phase)?.[1];
|
|
9638
|
+
if (phaseNum === void 0) return null;
|
|
9268
9639
|
for (const dir of readdirSync(phasesDir)) {
|
|
9269
|
-
const num = /^(\d+)/.exec(dir)?.[1];
|
|
9270
|
-
if (
|
|
9640
|
+
const num = /^(\d+(?:\.\d+)?)/.exec(dir)?.[1];
|
|
9641
|
+
if (num === void 0 || Number(num) !== Number(phaseNum)) continue;
|
|
9271
9642
|
const ctxFile = join(phasesDir, dir, `${num}-CONTEXT.md`);
|
|
9272
9643
|
if (!existsSync(ctxFile)) continue;
|
|
9273
9644
|
const body = readFileSync(ctxFile, "utf8");
|
|
@@ -10540,7 +10911,7 @@ function renderHumanTable(records) {
|
|
|
10540
10911
|
}
|
|
10541
10912
|
}
|
|
10542
10913
|
function pipeToJq(filterExpr, lines) {
|
|
10543
|
-
return new Promise((
|
|
10914
|
+
return new Promise((resolve23, reject) => {
|
|
10544
10915
|
const child = spawn("jq", [filterExpr], {
|
|
10545
10916
|
stdio: ["pipe", "inherit", "inherit"],
|
|
10546
10917
|
windowsHide: true
|
|
@@ -10549,12 +10920,15 @@ function pipeToJq(filterExpr, lines) {
|
|
|
10549
10920
|
const e = err2;
|
|
10550
10921
|
if (e.code === "ENOENT") {
|
|
10551
10922
|
console.error(t("audit_log.jq_missing"));
|
|
10552
|
-
|
|
10923
|
+
resolve23(1);
|
|
10553
10924
|
} else {
|
|
10554
10925
|
reject(err2);
|
|
10555
10926
|
}
|
|
10556
10927
|
});
|
|
10557
|
-
child.on("close", (code) =>
|
|
10928
|
+
child.on("close", (code) => resolve23(code ?? 0));
|
|
10929
|
+
child.stdin.on("error", (err2) => {
|
|
10930
|
+
if (err2.code !== "EPIPE") reject(err2);
|
|
10931
|
+
});
|
|
10558
10932
|
child.stdin.write(lines.join("\n"));
|
|
10559
10933
|
child.stdin.end();
|
|
10560
10934
|
});
|
|
@@ -10652,6 +11026,7 @@ function registerBackupList(program2) {
|
|
|
10652
11026
|
|
|
10653
11027
|
// src/cli/checkDocs.ts
|
|
10654
11028
|
init_i18n();
|
|
11029
|
+
init_ablation();
|
|
10655
11030
|
var DEFAULT_MAX_STATE_LINES = 100;
|
|
10656
11031
|
var KEY_DECISIONS_SECTION_RE = /^##\s+.*关键决议\s*ship\s*总结/gm;
|
|
10657
11032
|
var KEY_DECISIONS_SECTION_LIMIT = 1;
|
|
@@ -10771,6 +11146,7 @@ function registerCheckDocs(program2) {
|
|
|
10771
11146
|
"Documentation-discipline gate over .planning/ (STATE digest limit + archive cadence + ROADMAP pointer-not-narrative). Exits 2 on a blocking violation, 1 on advisory-only."
|
|
10772
11147
|
).option("--json", "output JSON instead of human-readable").option("--cwd <dir>", "repo root holding .planning/ (default: current directory)").option("--max-state-lines <n>", `STATE.md digest ceiling (default ${DEFAULT_MAX_STATE_LINES})`).option("--hook", "PreToolUse mode: read the tool payload on stdin, gate only git commit").action(
|
|
10773
11148
|
async (opts) => {
|
|
11149
|
+
if (opts.hook && isAblated()) process.exit(0);
|
|
10774
11150
|
if (opts.hook && !shouldGateForHookPayload(await readStdin())) process.exit(0);
|
|
10775
11151
|
const parsed = Number(opts.maxStateLines);
|
|
10776
11152
|
const violations = collectDocViolations({
|
|
@@ -10972,7 +11348,13 @@ function recordScenario(from, opts = {}) {
|
|
|
10972
11348
|
|
|
10973
11349
|
// src/eval/runner.ts
|
|
10974
11350
|
init_runDeps();
|
|
10975
|
-
var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
11351
|
+
var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
11352
|
+
"started_at",
|
|
11353
|
+
"completed_at",
|
|
11354
|
+
"paused_at",
|
|
11355
|
+
"updated_at",
|
|
11356
|
+
"timestamp"
|
|
11357
|
+
]);
|
|
10976
11358
|
function normalizeString(s, roots) {
|
|
10977
11359
|
let out = s;
|
|
10978
11360
|
for (const root of roots) {
|
|
@@ -11134,6 +11516,10 @@ function composeContext(seed, step) {
|
|
|
11134
11516
|
async function execStep(scenario, step, repoDir) {
|
|
11135
11517
|
if ("file" in step) {
|
|
11136
11518
|
const target = resolve(repoDir, step.file.path);
|
|
11519
|
+
const rel = relative(repoDir, target);
|
|
11520
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) {
|
|
11521
|
+
throw new Error(`file step path escapes the scenario repo: ${step.file.path}`);
|
|
11522
|
+
}
|
|
11137
11523
|
mkdirSync(dirname(target), { recursive: true });
|
|
11138
11524
|
writeFileSync(target, step.file.content ?? "", "utf8");
|
|
11139
11525
|
if (step.file.mtime) {
|
|
@@ -11230,19 +11616,18 @@ async function runScenarioDir(dir, opts) {
|
|
|
11230
11616
|
const prevRoot = process.env.HARNESSED_ROOT_OVERRIDE;
|
|
11231
11617
|
const prevAssets = process.env.HARNESSED_ASSETS_OVERRIDE;
|
|
11232
11618
|
const prevCeiling = process.env.GIT_CEILING_DIRECTORIES;
|
|
11233
|
-
process.env.GIT_CEILING_DIRECTORIES = tmpdir();
|
|
11234
|
-
process.env.HARNESSED_ROOT_OVERRIDE = stateRoot;
|
|
11235
|
-
if (scenario.assets_dir) {
|
|
11236
|
-
process.env.HARNESSED_ASSETS_OVERRIDE = isAbsolute(scenario.assets_dir) ? scenario.assets_dir : resolve(dir, scenario.assets_dir);
|
|
11237
|
-
}
|
|
11238
|
-
process.chdir(repoDir);
|
|
11239
|
-
const { _clearJudgmentCache: _clearJudgmentCache2 } = await Promise.resolve().then(() => (init_judgmentResolver(), judgmentResolver_exports));
|
|
11240
|
-
_clearJudgmentCache2();
|
|
11241
11619
|
const steps = [];
|
|
11242
11620
|
const evaluatedGateRefs = /* @__PURE__ */ new Set();
|
|
11243
11621
|
let engineError = null;
|
|
11244
11622
|
let workflow = null;
|
|
11245
11623
|
try {
|
|
11624
|
+
process.env.GIT_CEILING_DIRECTORIES = tmpdir();
|
|
11625
|
+
process.env.HARNESSED_ROOT_OVERRIDE = stateRoot;
|
|
11626
|
+
if (scenario.assets_dir) {
|
|
11627
|
+
process.env.HARNESSED_ASSETS_OVERRIDE = isAbsolute(scenario.assets_dir) ? scenario.assets_dir : resolve(dir, scenario.assets_dir);
|
|
11628
|
+
}
|
|
11629
|
+
process.chdir(repoDir);
|
|
11630
|
+
(await Promise.resolve().then(() => (init_judgmentResolver(), judgmentResolver_exports)))._clearJudgmentCache();
|
|
11246
11631
|
for (const step of scenario.steps) {
|
|
11247
11632
|
const rec = await execStep(scenario, step, repoDir);
|
|
11248
11633
|
steps.push(rec);
|
|
@@ -11268,7 +11653,11 @@ async function runScenarioDir(dir, opts) {
|
|
|
11268
11653
|
else process.env.HARNESSED_ASSETS_OVERRIDE = prevAssets;
|
|
11269
11654
|
if (prevCeiling === void 0) delete process.env.GIT_CEILING_DIRECTORIES;
|
|
11270
11655
|
else process.env.GIT_CEILING_DIRECTORIES = prevCeiling;
|
|
11271
|
-
|
|
11656
|
+
try {
|
|
11657
|
+
;
|
|
11658
|
+
(await Promise.resolve().then(() => (init_judgmentResolver(), judgmentResolver_exports)))._clearJudgmentCache();
|
|
11659
|
+
} catch {
|
|
11660
|
+
}
|
|
11272
11661
|
}
|
|
11273
11662
|
const cleanup = () => {
|
|
11274
11663
|
rmSync(stateRoot, { recursive: true, force: true });
|
|
@@ -11330,15 +11719,22 @@ async function runEvalSuite(suiteDir, opts) {
|
|
|
11330
11719
|
entries = [];
|
|
11331
11720
|
}
|
|
11332
11721
|
for (const dir of entries) {
|
|
11722
|
+
let raw;
|
|
11333
11723
|
try {
|
|
11334
|
-
readFileSync(join(dir, "scenario.yaml"));
|
|
11724
|
+
raw = readFileSync(join(dir, "scenario.yaml"), "utf8");
|
|
11335
11725
|
} catch {
|
|
11336
11726
|
continue;
|
|
11337
11727
|
}
|
|
11338
|
-
if (opts.filter && !dir.includes(opts.filter))
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11728
|
+
if (opts.filter && !dir.includes(opts.filter)) {
|
|
11729
|
+
let name = "";
|
|
11730
|
+
try {
|
|
11731
|
+
const doc = parse(raw);
|
|
11732
|
+
name = typeof doc?.name === "string" ? doc.name : "";
|
|
11733
|
+
} catch {
|
|
11734
|
+
}
|
|
11735
|
+
if (!name.includes(opts.filter)) continue;
|
|
11736
|
+
}
|
|
11737
|
+
results.push(await runScenarioDir(dir, opts));
|
|
11342
11738
|
}
|
|
11343
11739
|
const summary = {
|
|
11344
11740
|
pass: results.filter((r) => r.status === "PASS").length,
|
|
@@ -12120,6 +12516,7 @@ async function runHere(opts) {
|
|
|
12120
12516
|
|
|
12121
12517
|
// src/cli/manifest-add.ts
|
|
12122
12518
|
init_i18n();
|
|
12519
|
+
init_path_guard();
|
|
12123
12520
|
var QA = [
|
|
12124
12521
|
{ q: "\u2460 \u662F\u771F reusable surface \u8FD8\u662F\u4E34\u65F6 wrapper?", f: "q1_reusable_surface" },
|
|
12125
12522
|
{ q: "\u2461 \u4E0A\u6E38\u540D\u5B57 fit \u9879\u76EE shape \u5417? \u6709\u73B0\u6709\u547D\u540D\u51B2\u7A81\u5417?", f: "q2_name_fit" },
|
|
@@ -12136,6 +12533,14 @@ function registerManifestAdd(program2) {
|
|
|
12136
12533
|
).option("--category <cat>", "manifest category (skill-packs | tools)", "skill-packs").option("--name <name>", "short adapter name (defaults to <upstream> basename)").option("--dry-run", "preview only \u2014 do not write JSON (opt-in for advanced users)").option("--non-interactive", "CI/scripts \u2014 WARN-only dry-run").action(async (upstream, raw) => {
|
|
12137
12534
|
const name = raw.name ?? basename2(upstream);
|
|
12138
12535
|
const category = raw.category ?? "skill-packs";
|
|
12536
|
+
try {
|
|
12537
|
+
checkSafeSegment(category);
|
|
12538
|
+
checkSafeSegment(name);
|
|
12539
|
+
} catch {
|
|
12540
|
+
console.error("error: invalid --category / --name (path traversal rejected)");
|
|
12541
|
+
process.exit(2);
|
|
12542
|
+
return;
|
|
12543
|
+
}
|
|
12139
12544
|
const outPath = `manifests/${category}/${name}.ee5-answers.json`;
|
|
12140
12545
|
if (raw.nonInteractive) {
|
|
12141
12546
|
console.warn(t("manifest_add.non_interactive_warn"));
|
|
@@ -12217,6 +12622,7 @@ function resolveLocaleYaml(dir, baseName, locale = getLocale()) {
|
|
|
12217
12622
|
}
|
|
12218
12623
|
|
|
12219
12624
|
// src/cli/prompt.ts
|
|
12625
|
+
init_path_guard();
|
|
12220
12626
|
init_assetsRoot();
|
|
12221
12627
|
init_resolveYaml();
|
|
12222
12628
|
|
|
@@ -12339,44 +12745,6 @@ async function loadAllApplied(disciplines_applied, packageRoot) {
|
|
|
12339
12745
|
return out;
|
|
12340
12746
|
}
|
|
12341
12747
|
|
|
12342
|
-
// src/discipline/enforcement/before-commit.ts
|
|
12343
|
-
var TS_JS_RE = /\.(ts|tsx|js|mjs)$/;
|
|
12344
|
-
async function runBeforeCommitHook(ctx) {
|
|
12345
|
-
const d = await loadDiscipline("operational", ctx.packageRoot);
|
|
12346
|
-
if (ctx.changedFiles.some((f) => TS_JS_RE.test(f))) {
|
|
12347
|
-
const rule = d.rules.find((r) => r.id === "biome-preempt");
|
|
12348
|
-
if (rule?.auto_fix_cmd) {
|
|
12349
|
-
console.warn("\u26A0\uFE0F biome preempt \u2014 running auto-fix before commit");
|
|
12350
|
-
execSync(rule.auto_fix_cmd, { cwd: ctx.packageRoot, stdio: "inherit" });
|
|
12351
|
-
}
|
|
12352
|
-
}
|
|
12353
|
-
if (ctx.cmdArgs.includes("--no-verify")) {
|
|
12354
|
-
console.error("\u274C no-skip-hooks violated: --no-verify forbidden");
|
|
12355
|
-
process.exit(2);
|
|
12356
|
-
}
|
|
12357
|
-
if (ctx.changedFiles.some((f) => f.includes(".planning/STATE.md"))) {
|
|
12358
|
-
const docD = await loadDiscipline("doc-discipline", ctx.packageRoot);
|
|
12359
|
-
const rule = docD.rules.find((r) => r.id === "state-digest-line-limit");
|
|
12360
|
-
if (rule?.enforcement === "halt") {
|
|
12361
|
-
if (process.env.HARNESSED_ALLOW_LONG_STATE) {
|
|
12362
|
-
console.warn(
|
|
12363
|
-
"\u26A0\uFE0F doc-discipline: state-digest-line-limit override active (HARNESSED_ALLOW_LONG_STATE)"
|
|
12364
|
-
);
|
|
12365
|
-
} else {
|
|
12366
|
-
const content = readFileSync(resolve(ctx.packageRoot, ".planning/STATE.md"), "utf8");
|
|
12367
|
-
const lines = content.split(/\r?\n/);
|
|
12368
|
-
const lineCount = lines[lines.length - 1] === "" ? lines.length - 1 : lines.length;
|
|
12369
|
-
if (lineCount > 100) {
|
|
12370
|
-
console.error(
|
|
12371
|
-
`\u274C doc-discipline: STATE.md exceeds 100-line digest limit (current: ${lineCount} lines). Set HARNESSED_ALLOW_LONG_STATE=1 to override.`
|
|
12372
|
-
);
|
|
12373
|
-
process.exit(2);
|
|
12374
|
-
}
|
|
12375
|
-
}
|
|
12376
|
-
}
|
|
12377
|
-
}
|
|
12378
|
-
}
|
|
12379
|
-
|
|
12380
12748
|
// src/discipline/enforcement/before-phase-execute.ts
|
|
12381
12749
|
async function loadDisciplinesForPhase(disciplines_applied, packageRoot) {
|
|
12382
12750
|
return loadAllApplied(disciplines_applied, packageRoot);
|
|
@@ -12565,25 +12933,69 @@ var SpawnFailError = class extends Error {
|
|
|
12565
12933
|
}
|
|
12566
12934
|
lastMessage;
|
|
12567
12935
|
};
|
|
12936
|
+
var DEFAULT_SPAWN_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
12937
|
+
var SpawnTimeoutError = class extends Error {
|
|
12938
|
+
constructor(timeoutMs) {
|
|
12939
|
+
super(`sdkSpawn exceeded its ${timeoutMs}ms wall-clock timeout (HARNESSED_SPAWN_TIMEOUT_MS)`);
|
|
12940
|
+
this.timeoutMs = timeoutMs;
|
|
12941
|
+
this.name = "SpawnTimeoutError";
|
|
12942
|
+
}
|
|
12943
|
+
timeoutMs;
|
|
12944
|
+
};
|
|
12945
|
+
function envSpawnTimeoutMs() {
|
|
12946
|
+
const raw = Number.parseInt(process.env.HARNESSED_SPAWN_TIMEOUT_MS ?? "", 10);
|
|
12947
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_SPAWN_TIMEOUT_MS;
|
|
12948
|
+
}
|
|
12568
12949
|
async function sdkSpawn(def, opts) {
|
|
12569
12950
|
const sdkDef = toSdkAgentDefinition(def);
|
|
12570
|
-
const injectedPrompt = injectFactoryInternalFields(def, def.
|
|
12951
|
+
const injectedPrompt = injectFactoryInternalFields(def, def.prompt);
|
|
12571
12952
|
const queryOptions = {
|
|
12572
|
-
|
|
12953
|
+
// The prompt runs as the MAIN thread of this query, so the def's declared
|
|
12954
|
+
// limits must land on the query options; registering them only on the
|
|
12955
|
+
// `agents` entry (or rendering them into prompt text) enforces nothing.
|
|
12956
|
+
allowedTools: def.tools ?? ["Read", "Edit", "Write", "Grep", "Glob", "Bash", "Task"],
|
|
12957
|
+
...def.disallowedTools?.length ? { disallowedTools: def.disallowedTools } : {},
|
|
12958
|
+
...def.maxTurns ? { maxTurns: def.maxTurns } : {},
|
|
12959
|
+
// bypassPermissions additionally needs allowDangerouslySkipPermissions; a
|
|
12960
|
+
// manifest field must not be able to switch that on, so it is not forwarded.
|
|
12961
|
+
...def.permissionMode && def.permissionMode !== "bypassPermissions" ? { permissionMode: def.permissionMode } : {},
|
|
12573
12962
|
agents: { [opts.expertName]: sdkDef },
|
|
12574
12963
|
// PRIMARY signal (B-02 / B-07 SC3) — structured output via json_schema.
|
|
12575
12964
|
outputFormat: { type: "json_schema", schema: COMPLETION_SCHEMA }
|
|
12576
12965
|
};
|
|
12577
12966
|
if (opts.resumeSessionId) queryOptions.resume = opts.resumeSessionId;
|
|
12967
|
+
const timeoutMs = opts.timeoutMs ?? envSpawnTimeoutMs();
|
|
12968
|
+
const abortController = new AbortController();
|
|
12969
|
+
queryOptions.abortController = abortController;
|
|
12578
12970
|
const q = query({ prompt: injectedPrompt, options: queryOptions });
|
|
12579
12971
|
let result;
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12972
|
+
const consume = (async () => {
|
|
12973
|
+
for await (const msg of q) {
|
|
12974
|
+
if (msg.type === "system" && msg.subtype === "init") {
|
|
12975
|
+
opts.onSessionId?.(msg.session_id);
|
|
12976
|
+
}
|
|
12977
|
+
if (msg.type === "result") {
|
|
12978
|
+
result = msg;
|
|
12979
|
+
}
|
|
12583
12980
|
}
|
|
12584
|
-
|
|
12585
|
-
|
|
12981
|
+
})();
|
|
12982
|
+
let timer;
|
|
12983
|
+
try {
|
|
12984
|
+
if (timeoutMs > 0) {
|
|
12985
|
+
const timedOut = new Promise((_, reject) => {
|
|
12986
|
+
timer = setTimeout(() => {
|
|
12987
|
+
abortController.abort();
|
|
12988
|
+
reject(new SpawnTimeoutError(timeoutMs));
|
|
12989
|
+
}, timeoutMs);
|
|
12990
|
+
});
|
|
12991
|
+
consume.catch(() => {
|
|
12992
|
+
});
|
|
12993
|
+
await Promise.race([consume, timedOut]);
|
|
12994
|
+
} else {
|
|
12995
|
+
await consume;
|
|
12586
12996
|
}
|
|
12997
|
+
} finally {
|
|
12998
|
+
clearTimeout(timer);
|
|
12587
12999
|
}
|
|
12588
13000
|
if (!result) throw new SpawnFailError();
|
|
12589
13001
|
const structuredOutput = "structured_output" in result ? result.structured_output : void 0;
|
|
@@ -12864,6 +13276,7 @@ function loadPhases(yamlPath, vars) {
|
|
|
12864
13276
|
init_subAnchor();
|
|
12865
13277
|
init_exprBuilder();
|
|
12866
13278
|
init_judgmentResolver();
|
|
13279
|
+
init_fallbackHandlers();
|
|
12867
13280
|
init_skipGate();
|
|
12868
13281
|
init_skipSubs();
|
|
12869
13282
|
function resolveMasterYamlPath2(masterName, packageRoot) {
|
|
@@ -12880,7 +13293,15 @@ function resolveSubYamlPath(masterName, subName, packageRoot) {
|
|
|
12880
13293
|
}
|
|
12881
13294
|
var defaultSpawnDriver = async (masterName, subName, _context, packageRoot) => {
|
|
12882
13295
|
const subYamlPath = resolveSubYamlPath(masterName, subName, packageRoot);
|
|
12883
|
-
const result = await runWorkflow(
|
|
13296
|
+
const result = await runWorkflow(
|
|
13297
|
+
subYamlPath,
|
|
13298
|
+
{},
|
|
13299
|
+
{
|
|
13300
|
+
packageRoot,
|
|
13301
|
+
gateContext: _context,
|
|
13302
|
+
subOf: masterName
|
|
13303
|
+
}
|
|
13304
|
+
);
|
|
12884
13305
|
if (result.status === "failed") {
|
|
12885
13306
|
throw new Error(
|
|
12886
13307
|
`sub-workflow ${masterName}/${subName} failed` + (result.lastPhaseId ? ` at phase ${result.lastPhaseId}` : "")
|
|
@@ -13085,9 +13506,12 @@ async function runMasterOrchestrator(masterName, context, packageRoot, spawnDriv
|
|
|
13085
13506
|
).filter((x) => x !== null);
|
|
13086
13507
|
if (parallelFailures.length > 0) {
|
|
13087
13508
|
const detail = parallelFailures.map((f) => `${f.sub}: ${f.reason instanceof Error ? f.reason.message : String(f.reason)}`).join("; ");
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
)
|
|
13509
|
+
const message = `[${masterName} master] ${parallelFailures.length} parallel sub(s) failed \u2014 ${detail}`;
|
|
13510
|
+
const halts = parallelFailures.map((f) => f.reason).filter((r) => r instanceof WorkflowHaltError);
|
|
13511
|
+
if (halts.length > 0) {
|
|
13512
|
+
throw new WorkflowHaltError(message, Math.max(...halts.map((h) => h.exitCode)));
|
|
13513
|
+
}
|
|
13514
|
+
throw new Error(message);
|
|
13091
13515
|
}
|
|
13092
13516
|
for (const clause of serialTrailing) {
|
|
13093
13517
|
console.log(` \u2192 ${clause.sub} (serial order=${clause.order ?? 0})`);
|
|
@@ -13295,8 +13719,16 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13295
13719
|
}
|
|
13296
13720
|
const workflowName = parsed.workflow;
|
|
13297
13721
|
const isMaster = "delegates_to" in parsed && Array.isArray(parsed.delegates_to) && parsed.delegates_to.length > 0 && MASTER_NAMES.includes(workflowName);
|
|
13722
|
+
const ownsRecord = opts.subOf === void 0;
|
|
13298
13723
|
if (isMaster) {
|
|
13724
|
+
if (ownsRecord) await activatePhase(workflowName);
|
|
13299
13725
|
const r = await runMasterOrchestrator(workflowName, gateContext, packageRoot);
|
|
13726
|
+
if (ownsRecord) {
|
|
13727
|
+
await completePhase({
|
|
13728
|
+
phaseId: workflowName,
|
|
13729
|
+
lastTask: `master ${workflowName} complete: ${r.fired.length} sub(s) fired`
|
|
13730
|
+
});
|
|
13731
|
+
}
|
|
13300
13732
|
return {
|
|
13301
13733
|
status: "complete",
|
|
13302
13734
|
phasesRun: r.fired.length,
|
|
@@ -13313,11 +13745,18 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13313
13745
|
);
|
|
13314
13746
|
}
|
|
13315
13747
|
const skippedPhases = [];
|
|
13316
|
-
|
|
13748
|
+
if (!Array.isArray(parsed.phases) || parsed.phases.length === 0) {
|
|
13749
|
+
const hasDelegates = "delegates_to" in parsed && Array.isArray(parsed.delegates_to) && parsed.delegates_to.length > 0;
|
|
13750
|
+
throw new Error(
|
|
13751
|
+
hasDelegates ? `workflow '${workflowName}' declares delegates_to but is not a master workflow (${MASTER_NAMES.join(", ")}), and has no phases \u2014 its delegates would be ignored` : `workflow '${workflowName}' has neither phases nor delegates_to \u2014 nothing would run`
|
|
13752
|
+
);
|
|
13753
|
+
}
|
|
13754
|
+
const phases = parsed.phases;
|
|
13317
13755
|
for (let i = 0; i < phases.length; i++) {
|
|
13318
13756
|
const ph = phases[i];
|
|
13319
13757
|
if (!ph) continue;
|
|
13320
|
-
await activatePhase(ph.id);
|
|
13758
|
+
if (ownsRecord) await activatePhase(ph.id);
|
|
13759
|
+
const transitionWorkflowComplete = ownsRecord && i === phases.length - 1;
|
|
13321
13760
|
const invokesTools = "invokes_tools" in ph && Array.isArray(ph.invokes_tools) ? ph.invokes_tools : void 0;
|
|
13322
13761
|
if (invokesTools && invokesTools.length > 1) {
|
|
13323
13762
|
try {
|
|
@@ -13356,7 +13795,8 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13356
13795
|
skippedPhases.push(ph.id);
|
|
13357
13796
|
await completePhase({
|
|
13358
13797
|
phaseId: ph.id,
|
|
13359
|
-
lastTask: `phase ${ph.id} skipped: gate ${ph.gate} evaluated false
|
|
13798
|
+
lastTask: `phase ${ph.id} skipped: gate ${ph.gate} evaluated false`,
|
|
13799
|
+
transitionWorkflowComplete
|
|
13360
13800
|
});
|
|
13361
13801
|
continue;
|
|
13362
13802
|
}
|
|
@@ -13372,6 +13812,11 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13372
13812
|
...typeof gateContext.modelTierOverride === "string" ? { modelTierOverride: gateContext.modelTierOverride } : {}
|
|
13373
13813
|
});
|
|
13374
13814
|
if (r.status !== "ok") {
|
|
13815
|
+
await completePhase({
|
|
13816
|
+
phaseId: ph.id,
|
|
13817
|
+
lastTask: `FAILED: phase ${ph.id}: ${r.output}`,
|
|
13818
|
+
transitionWorkflowComplete: false
|
|
13819
|
+
});
|
|
13375
13820
|
return { status: "failed", phasesRun: i, lastPhaseId: ph.id };
|
|
13376
13821
|
}
|
|
13377
13822
|
if (r.needsTeamsEscalation === true) {
|
|
@@ -13380,24 +13825,10 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13380
13825
|
`\u26A0\uFE0F phase ${ph.id} suggests Agent Teams escalation \u2014 ${reason}. Consider forming a team in your main Claude Code session (spawn background teammates with the Agent tool) if continuing this work benefits from teammate coordination. See workflows/judgments/parallelism-gate.yaml for the 5 upgrade triggers.`
|
|
13381
13826
|
);
|
|
13382
13827
|
}
|
|
13383
|
-
if (r.triggers_commit === true) {
|
|
13384
|
-
try {
|
|
13385
|
-
await runBeforeCommitHook({
|
|
13386
|
-
changedFiles: [],
|
|
13387
|
-
cmdArgs: [],
|
|
13388
|
-
packageRoot,
|
|
13389
|
-
cmdType: "git-commit",
|
|
13390
|
-
hasUserApproval: false
|
|
13391
|
-
});
|
|
13392
|
-
} catch (err2) {
|
|
13393
|
-
console.warn(
|
|
13394
|
-
`\u26A0\uFE0F phase ${ph.id} before-commit hook failed (${err2.message}); proceeding (ADR 0029 fail-soft).`
|
|
13395
|
-
);
|
|
13396
|
-
}
|
|
13397
|
-
}
|
|
13398
13828
|
await completePhase({
|
|
13399
13829
|
phaseId: ph.id,
|
|
13400
|
-
lastTask: `phase ${ph.id} complete: ${r.output}
|
|
13830
|
+
lastTask: `phase ${ph.id} complete: ${r.output}`,
|
|
13831
|
+
transitionWorkflowComplete
|
|
13401
13832
|
});
|
|
13402
13833
|
}
|
|
13403
13834
|
return {
|
|
@@ -13565,6 +13996,13 @@ function registerPrompt(program2) {
|
|
|
13565
13996
|
program2.command("prompt").description(
|
|
13566
13997
|
"Print a spawn-ready prompt for a sub-workflow (role + checklist + protocols, no spawn)."
|
|
13567
13998
|
).argument("<sub>", "sub-workflow name (e.g. task-code, verify-paranoid)").option("--task <text>", "task description prepended as a ## Task section").option("--json", "emit JSON {prompt, max_iterations, model, specialist} instead of text").action(async (sub, raw) => {
|
|
13999
|
+
try {
|
|
14000
|
+
checkSafeSegment(sub);
|
|
14001
|
+
} catch {
|
|
14002
|
+
console.error("error: invalid workflow name (path traversal rejected)");
|
|
14003
|
+
process.exit(2);
|
|
14004
|
+
return;
|
|
14005
|
+
}
|
|
13568
14006
|
const packageRoot = getAssetsRoot();
|
|
13569
14007
|
const workflowsDir = resolve(packageRoot, "workflows");
|
|
13570
14008
|
const rolePrompts = await loadRolePrompts(workflowsDir);
|
|
@@ -13652,7 +14090,21 @@ function registerReleasePreflight(program2) {
|
|
|
13652
14090
|
// src/cli/research.ts
|
|
13653
14091
|
init_i18n();
|
|
13654
14092
|
init_assetsRoot();
|
|
14093
|
+
init_fallbackHandlers();
|
|
13655
14094
|
init_resolveYaml();
|
|
14095
|
+
|
|
14096
|
+
// src/cli/lib/nestedHarness.ts
|
|
14097
|
+
init_platform();
|
|
14098
|
+
function isNestedHarnessContext() {
|
|
14099
|
+
if (process.env.HARNESSED_ALLOW_NESTED === "1") return false;
|
|
14100
|
+
const sessEnv = detectPlatform().sessionIdEnv;
|
|
14101
|
+
if (!sessEnv) return false;
|
|
14102
|
+
const sid = process.env[sessEnv]?.trim();
|
|
14103
|
+
if (!sid) return false;
|
|
14104
|
+
return !process.stdin.isTTY;
|
|
14105
|
+
}
|
|
14106
|
+
|
|
14107
|
+
// src/cli/research.ts
|
|
13656
14108
|
var PACKAGE_ROOT = getAssetsRoot();
|
|
13657
14109
|
var WORKFLOWS_DIR = join(PACKAGE_ROOT, "workflows");
|
|
13658
14110
|
function registerResearch(program2) {
|
|
@@ -13678,10 +14130,21 @@ function registerResearch(program2) {
|
|
|
13678
14130
|
process.exit(0);
|
|
13679
14131
|
return;
|
|
13680
14132
|
}
|
|
14133
|
+
if (isNestedHarnessContext()) {
|
|
14134
|
+
console.error(
|
|
14135
|
+
"error: `harnessed research` is the CI/headless path (in-process SDK spawn) and hangs when invoked from inside a Claude Code session. Use the CC-native `/research` slash command instead. Set HARNESSED_ALLOW_NESTED=1 to override (CI / testing only)."
|
|
14136
|
+
);
|
|
14137
|
+
process.exit(1);
|
|
14138
|
+
return;
|
|
14139
|
+
}
|
|
13681
14140
|
let result;
|
|
13682
14141
|
try {
|
|
13683
14142
|
result = await runWorkflow(yamlPath, {}, { packageRoot: PACKAGE_ROOT, gateContext });
|
|
13684
14143
|
} catch (err2) {
|
|
14144
|
+
if (err2 instanceof WorkflowHaltError) {
|
|
14145
|
+
process.exit(err2.exitCode);
|
|
14146
|
+
return;
|
|
14147
|
+
}
|
|
13685
14148
|
console.error(`error: workflow runtime failed \u2014 ${err2.message}`);
|
|
13686
14149
|
process.exit(1);
|
|
13687
14150
|
return;
|
|
@@ -13760,12 +14223,20 @@ function registerRetro(program2) {
|
|
|
13760
14223
|
// src/cli/rollback.ts
|
|
13761
14224
|
init_i18n();
|
|
13762
14225
|
init_backup();
|
|
14226
|
+
init_path_guard();
|
|
13763
14227
|
function normalizeEol(buf, eol) {
|
|
13764
14228
|
const lf = buf.toString("utf8").replace(/\r\n/g, "\n");
|
|
13765
14229
|
return Buffer.from(eol === "crlf" ? lf.replace(/\n/g, "\r\n") : lf, "utf8");
|
|
13766
14230
|
}
|
|
13767
14231
|
function registerRollback(program2) {
|
|
13768
14232
|
program2.command("rollback <timestamp>").description("Restore files from a backup snapshot (preserves original LF/CRLF)").action(async (timestamp) => {
|
|
14233
|
+
try {
|
|
14234
|
+
checkSafeSegment(timestamp);
|
|
14235
|
+
} catch {
|
|
14236
|
+
console.error("error: invalid backup timestamp (path traversal rejected)");
|
|
14237
|
+
process.exit(2);
|
|
14238
|
+
return;
|
|
14239
|
+
}
|
|
13769
14240
|
const dir = join(getBackupRoot(), timestamp);
|
|
13770
14241
|
const metaPath = join(dir, "metadata.json");
|
|
13771
14242
|
let meta;
|
|
@@ -13783,7 +14254,28 @@ ${t("rollback.metadata_unreadable.fix")}`
|
|
|
13783
14254
|
const planned = [];
|
|
13784
14255
|
for (const entry of ordered) {
|
|
13785
14256
|
if (entry.backup === "") {
|
|
13786
|
-
|
|
14257
|
+
if (entry.sentinel === "created") {
|
|
14258
|
+
planned.push({ target: entry.target, action: "remove-created" });
|
|
14259
|
+
} else if (entry.sentinel === "preexisting-dir") {
|
|
14260
|
+
planned.push({
|
|
14261
|
+
target: entry.target,
|
|
14262
|
+
action: "keep",
|
|
14263
|
+
why: "existed before install and could not be byte-backed-up; left untouched"
|
|
14264
|
+
});
|
|
14265
|
+
} else {
|
|
14266
|
+
let isDir = false;
|
|
14267
|
+
try {
|
|
14268
|
+
isDir = (await stat(entry.target)).isDirectory();
|
|
14269
|
+
} catch {
|
|
14270
|
+
}
|
|
14271
|
+
planned.push(
|
|
14272
|
+
isDir ? {
|
|
14273
|
+
target: entry.target,
|
|
14274
|
+
action: "keep",
|
|
14275
|
+
why: "directory from pre-sentinel backup metadata; origin unknown, not deleting"
|
|
14276
|
+
} : { target: entry.target, action: "unlink" }
|
|
14277
|
+
);
|
|
14278
|
+
}
|
|
13787
14279
|
continue;
|
|
13788
14280
|
}
|
|
13789
14281
|
let buf;
|
|
@@ -13809,6 +14301,14 @@ ${t("rollback.metadata_unreadable.fix")}`
|
|
|
13809
14301
|
planned.push({ target: entry.target, action: "write", data: normalizeEol(buf, entry.eol) });
|
|
13810
14302
|
}
|
|
13811
14303
|
for (const op of planned) {
|
|
14304
|
+
if (op.action === "keep") {
|
|
14305
|
+
console.warn(`[harnessed] rollback: ${op.target} \u2014 ${op.why}`);
|
|
14306
|
+
continue;
|
|
14307
|
+
}
|
|
14308
|
+
if (op.action === "remove-created") {
|
|
14309
|
+
await rm(op.target, { recursive: true, force: true });
|
|
14310
|
+
continue;
|
|
14311
|
+
}
|
|
13812
14312
|
if (op.action === "unlink") {
|
|
13813
14313
|
try {
|
|
13814
14314
|
await unlink(op.target);
|
|
@@ -13831,7 +14331,7 @@ ${t("rollback.metadata_unreadable.fix")}`
|
|
|
13831
14331
|
// src/cli/run.ts
|
|
13832
14332
|
init_path_guard();
|
|
13833
14333
|
init_assetsRoot();
|
|
13834
|
-
|
|
14334
|
+
init_fallbackHandlers();
|
|
13835
14335
|
init_resolveYaml();
|
|
13836
14336
|
|
|
13837
14337
|
// src/cli/lib/extract-user-overrides.ts
|
|
@@ -13882,13 +14382,20 @@ var PACKAGE_ROOT2 = getAssetsRoot();
|
|
|
13882
14382
|
var WORKFLOWS_DIR2 = join(PACKAGE_ROOT2, "workflows");
|
|
13883
14383
|
var _autoChainCache = null;
|
|
13884
14384
|
var _autoChainLoadFailed = false;
|
|
14385
|
+
function parseMaxIterations(v) {
|
|
14386
|
+
const n = Number(v);
|
|
14387
|
+
if (!/^\s*\d+\s*$/.test(v) || !Number.isInteger(n) || n < 1 || n > 100) {
|
|
14388
|
+
throw new InvalidArgumentError(`expected an integer between 1 and 100, got '${v}'`);
|
|
14389
|
+
}
|
|
14390
|
+
return n;
|
|
14391
|
+
}
|
|
13885
14392
|
function registerRun(program2) {
|
|
13886
14393
|
program2.command("run").description(
|
|
13887
14394
|
"Run a harnessed workflow via in-process SDK spawn (CI/headless mode \u2014 blocks, no Agent Teams, no clarification round-trip). Slash commands use CC-native spawn via gates/prompt/checkpoint instead."
|
|
13888
14395
|
).argument("[name]", "workflow name (e.g. discuss, verify-paranoid, research, auto)").option("--task <text>", "task description (passed as workflow gateContext.task)").option("--task-stdin", "read task description from stdin until EOF (avoids shell-escape)").option(
|
|
13889
14396
|
"--max-iterations <n>",
|
|
13890
|
-
"SDK-path retry-loop max iter (default 20;
|
|
13891
|
-
|
|
14397
|
+
"SDK-path retry-loop max iter (default 20; integer 1-100)",
|
|
14398
|
+
parseMaxIterations
|
|
13892
14399
|
).option("--model <model>", "subagent model: 'haiku' | 'sonnet' | 'opus'").option(
|
|
13893
14400
|
"--dry-run",
|
|
13894
14401
|
"validate yaml load + walk runtime without spawning (Phase 1 default for verification)"
|
|
@@ -13970,6 +14477,10 @@ function registerRun(program2) {
|
|
|
13970
14477
|
try {
|
|
13971
14478
|
result = await runWorkflow(yamlPath, {}, { packageRoot: PACKAGE_ROOT2, gateContext });
|
|
13972
14479
|
} catch (err2) {
|
|
14480
|
+
if (err2 instanceof WorkflowHaltError) {
|
|
14481
|
+
process.exit(err2.exitCode);
|
|
14482
|
+
return;
|
|
14483
|
+
}
|
|
13973
14484
|
console.error(`error: workflow runtime failed \u2014 ${err2.message}`);
|
|
13974
14485
|
process.exit(1);
|
|
13975
14486
|
return;
|
|
@@ -13985,14 +14496,6 @@ function registerRun(program2) {
|
|
|
13985
14496
|
process.exit(result.status === "failed" ? 1 : 0);
|
|
13986
14497
|
});
|
|
13987
14498
|
}
|
|
13988
|
-
function isNestedHarnessContext() {
|
|
13989
|
-
if (process.env.HARNESSED_ALLOW_NESTED === "1") return false;
|
|
13990
|
-
const sessEnv = detectPlatform().sessionIdEnv;
|
|
13991
|
-
if (!sessEnv) return false;
|
|
13992
|
-
const sid = process.env[sessEnv]?.trim();
|
|
13993
|
-
if (!sid) return false;
|
|
13994
|
-
return !process.stdin.isTTY;
|
|
13995
|
-
}
|
|
13996
14499
|
async function listWorkflowNames(workflowsDir) {
|
|
13997
14500
|
const names = [];
|
|
13998
14501
|
const entries = await readdir(workflowsDir);
|
|
@@ -14447,7 +14950,7 @@ var V3_4_3_SIGNATURE_MASTER_RX = /\*\*Preferred path\*\*[\s\S]*dispatch to the p
|
|
|
14447
14950
|
function shouldOverwriteFile(content) {
|
|
14448
14951
|
return HARNESSED_MARKER_RX2.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
|
|
14449
14952
|
}
|
|
14450
|
-
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync,
|
|
14953
|
+
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync24 = (p7) => readFileSync(p7, "utf8")) {
|
|
14451
14954
|
const results = [];
|
|
14452
14955
|
const aggregatedWarnings = /* @__PURE__ */ new Set();
|
|
14453
14956
|
for (const name of slashNames) {
|
|
@@ -14466,7 +14969,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
|
|
|
14466
14969
|
if (fileExists2(path)) {
|
|
14467
14970
|
let existing = "";
|
|
14468
14971
|
try {
|
|
14469
|
-
existing =
|
|
14972
|
+
existing = readFileSync24(path);
|
|
14470
14973
|
} catch {
|
|
14471
14974
|
existing = "";
|
|
14472
14975
|
}
|
|
@@ -14840,7 +15343,7 @@ async function printSetupVersionBanner() {
|
|
|
14840
15343
|
|
|
14841
15344
|
// src/cli/setup.ts
|
|
14842
15345
|
var KNOWN_PLATFORMS = ["claude", "codex"];
|
|
14843
|
-
async function applyPlatformOption(platform) {
|
|
15346
|
+
async function applyPlatformOption(platform, persist) {
|
|
14844
15347
|
if (!KNOWN_PLATFORMS.includes(platform)) {
|
|
14845
15348
|
console.error(
|
|
14846
15349
|
`--platform: unknown id '${platform}' (expected one of: ${KNOWN_PLATFORMS.join(" | ")})`
|
|
@@ -14848,10 +15351,11 @@ async function applyPlatformOption(platform) {
|
|
|
14848
15351
|
process.exit(1);
|
|
14849
15352
|
}
|
|
14850
15353
|
process.env.HARNESSED_PLATFORM = platform;
|
|
14851
|
-
|
|
15354
|
+
if (!persist) return;
|
|
15355
|
+
const pinRoot = claudeDescriptor().stateRoot;
|
|
14852
15356
|
try {
|
|
14853
|
-
await mkdir(
|
|
14854
|
-
await writeFile(join(
|
|
15357
|
+
await mkdir(pinRoot, { recursive: true });
|
|
15358
|
+
await writeFile(join(pinRoot, ".platform"), platform, "utf8");
|
|
14855
15359
|
} catch (e) {
|
|
14856
15360
|
console.warn(` [--platform] could not persist .platform pin (${e.message})`);
|
|
14857
15361
|
}
|
|
@@ -14965,7 +15469,7 @@ function registerSetup(program2) {
|
|
|
14965
15469
|
).action(async (raw) => {
|
|
14966
15470
|
await printSetupVersionBanner();
|
|
14967
15471
|
const dryRun = raw.dryRun === true;
|
|
14968
|
-
if (raw.platform !== void 0) await applyPlatformOption(raw.platform);
|
|
15472
|
+
if (raw.platform !== void 0) await applyPlatformOption(raw.platform, !dryRun);
|
|
14969
15473
|
const pkgRoot = getAssetsRoot();
|
|
14970
15474
|
const workflowsDir = resolve(pkgRoot, "workflows");
|
|
14971
15475
|
const skillsBase = getSkillsDir();
|
|
@@ -15599,7 +16103,7 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
15599
16103
|
const m = install.cmd.match(/npm\s+(?:install|i)\s+(?:-g\s+)?(\S+)/);
|
|
15600
16104
|
const pkg = m?.[1] ?? ctx.manifest.metadata.upstream.source;
|
|
15601
16105
|
const isWin = process.platform === "win32";
|
|
15602
|
-
const result = await new Promise((
|
|
16106
|
+
const result = await new Promise((resolve23) => {
|
|
15603
16107
|
const child = isWin ? spawn("cmd.exe", ["/c", "npm", "uninstall", "-g", pkg], { windowsHide: true }) : spawn("npm", ["uninstall", "-g", pkg], { shell: false });
|
|
15604
16108
|
let stderr = "";
|
|
15605
16109
|
child.stderr?.setEncoding("utf8").on("data", (c) => {
|
|
@@ -15607,15 +16111,15 @@ var uninstallNpmCli = async (ctx) => {
|
|
|
15607
16111
|
});
|
|
15608
16112
|
const timer = setTimeout(() => {
|
|
15609
16113
|
child.kill("SIGKILL");
|
|
15610
|
-
|
|
16114
|
+
resolve23({ exitCode: -1, stderr: `${stderr}[timeout]` });
|
|
15611
16115
|
}, 3e4);
|
|
15612
16116
|
child.on("error", (e) => {
|
|
15613
16117
|
clearTimeout(timer);
|
|
15614
|
-
|
|
16118
|
+
resolve23({ exitCode: -1, stderr: e.message });
|
|
15615
16119
|
});
|
|
15616
16120
|
child.on("close", (code) => {
|
|
15617
16121
|
clearTimeout(timer);
|
|
15618
|
-
|
|
16122
|
+
resolve23({ exitCode: code ?? -1, stderr });
|
|
15619
16123
|
});
|
|
15620
16124
|
});
|
|
15621
16125
|
if (result.exitCode !== 0) {
|