harnessed 4.45.0 → 4.46.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/dist/cli.mjs +767 -140
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/messages/en.json +2 -0
- package/messages/zh-Hans.json +2 -0
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdir
|
|
|
3
3
|
import { homedir, tmpdir } from 'os';
|
|
4
4
|
import { join, resolve, dirname, basename, sep, isAbsolute, relative, win32, posix } from 'path';
|
|
5
5
|
import { Type } from '@sinclair/typebox';
|
|
6
|
-
import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod } from 'fs/promises';
|
|
6
|
+
import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod, mkdtemp } 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';
|
|
@@ -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.46.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -447,10 +447,52 @@ var init_checkpoint_v1 = __esm({
|
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
449
|
});
|
|
450
|
+
|
|
451
|
+
// src/workflow/lib/spawnFailure.ts
|
|
452
|
+
var spawnFailure_exports = {};
|
|
453
|
+
__export(spawnFailure_exports, {
|
|
454
|
+
SPAWN_FAILURES: () => SPAWN_FAILURES,
|
|
455
|
+
SpawnFailureError: () => SpawnFailureError,
|
|
456
|
+
classifySpawnError: () => classifySpawnError,
|
|
457
|
+
isRetryableSpawnFailure: () => isRetryableSpawnFailure,
|
|
458
|
+
isSpawnFailure: () => isSpawnFailure
|
|
459
|
+
});
|
|
460
|
+
function isSpawnFailure(v) {
|
|
461
|
+
return typeof v === "string" && SPAWN_FAILURES.includes(v);
|
|
462
|
+
}
|
|
463
|
+
function classifySpawnError(err2) {
|
|
464
|
+
if (!err2 || typeof err2 !== "object") return void 0;
|
|
465
|
+
const tag = err2.failure;
|
|
466
|
+
return isSpawnFailure(tag) ? tag : void 0;
|
|
467
|
+
}
|
|
468
|
+
function isRetryableSpawnFailure(failure) {
|
|
469
|
+
return failure === "SpawnTimeout";
|
|
470
|
+
}
|
|
471
|
+
var SPAWN_FAILURES, SpawnFailureError;
|
|
472
|
+
var init_spawnFailure = __esm({
|
|
473
|
+
"src/workflow/lib/spawnFailure.ts"() {
|
|
474
|
+
SPAWN_FAILURES = [
|
|
475
|
+
"SpawnTimeout",
|
|
476
|
+
"SpawnExitNonZero",
|
|
477
|
+
"SpawnOutputMalformed",
|
|
478
|
+
"SpawnAuthFailed",
|
|
479
|
+
"SpawnRefused"
|
|
480
|
+
];
|
|
481
|
+
SpawnFailureError = class extends Error {
|
|
482
|
+
constructor(failure, detail) {
|
|
483
|
+
super(detail);
|
|
484
|
+
this.failure = failure;
|
|
485
|
+
this.name = failure;
|
|
486
|
+
}
|
|
487
|
+
failure;
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
});
|
|
450
491
|
var WorkflowStatus, EvidenceRef, SubProgressEntry, CurrentWorkflowV1;
|
|
451
492
|
var init_currentWorkflow_v1 = __esm({
|
|
452
493
|
"src/checkpoint/schema/currentWorkflow.v1.ts"() {
|
|
453
494
|
init_schemaVersion();
|
|
495
|
+
init_spawnFailure();
|
|
454
496
|
WorkflowStatus = Type.Union([
|
|
455
497
|
Type.Literal("active"),
|
|
456
498
|
Type.Literal("paused"),
|
|
@@ -526,7 +568,22 @@ var init_currentWorkflow_v1 = __esm({
|
|
|
526
568
|
// attempt_budget — the sub's resolved `ralph_max_iterations` ceiling, persisted at
|
|
527
569
|
// the first failure so the PURE per-turn injector can compare it against
|
|
528
570
|
// fail_count without reading yaml (src/checkpoint/budget.ts resolves it).
|
|
529
|
-
attempt_budget: Type.Optional(Type.Integer({ minimum: 1 }))
|
|
571
|
+
attempt_budget: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
572
|
+
// ── v16.0 Phase 66 T4 — WHICH of the five named spawn failures ended the last
|
|
573
|
+
// attempt (src/workflow/lib/spawnFailure.ts). Before this the kind was flattened
|
|
574
|
+
// into a message string at src/workflow/run.ts's catch and lost for good, so the
|
|
575
|
+
// ledger recorded "failed" with no way to tell a wall-clock timeout (retryable)
|
|
576
|
+
// from a sandbox refusal or a logged-out harness (both deterministic).
|
|
577
|
+
//
|
|
578
|
+
// Additive-optional, and strictly so: an attempt that never supplied a kind must
|
|
579
|
+
// leave the key ABSENT, not null. 13 eval goldens compare the serialized ledger
|
|
580
|
+
// verbatim, and both writers (markSub / annotateSpawnFailure) only assign when
|
|
581
|
+
// the caller passed something. NO schemaVersion bump — old files Value.Check-pass.
|
|
582
|
+
//
|
|
583
|
+
// The enum, not a free string: an unrecognised kind is a wiring bug and should
|
|
584
|
+
// fail the write, which is also what `checkpoint fail --failure` enforces at the
|
|
585
|
+
// CLI boundary before anything is persisted.
|
|
586
|
+
spawn_failure: Type.Optional(Type.Union(SPAWN_FAILURES.map((f) => Type.Literal(f))))
|
|
530
587
|
},
|
|
531
588
|
{ additionalProperties: false }
|
|
532
589
|
);
|
|
@@ -917,6 +974,7 @@ var init_subAnchor = __esm({
|
|
|
917
974
|
// src/checkpoint/ledger.ts
|
|
918
975
|
var ledger_exports = {};
|
|
919
976
|
__export(ledger_exports, {
|
|
977
|
+
annotateSpawnFailure: () => annotateSpawnFailure,
|
|
920
978
|
findSerialBlockers: () => findSerialBlockers,
|
|
921
979
|
markSub: () => markSub,
|
|
922
980
|
nextPending: () => nextPending,
|
|
@@ -964,10 +1022,18 @@ function markSub(entries, sub, status, opts) {
|
|
|
964
1022
|
if (opts?.completion_claim !== void 0) updated.completion_claim = opts.completion_claim;
|
|
965
1023
|
if (opts?.progress !== void 0) updated.progress = opts.progress;
|
|
966
1024
|
if (opts?.attempt_budget !== void 0) updated.attempt_budget = opts.attempt_budget;
|
|
1025
|
+
if (opts?.spawn_failure !== void 0) updated.spawn_failure = opts.spawn_failure;
|
|
967
1026
|
const next = entries.slice();
|
|
968
1027
|
next[idx] = updated;
|
|
969
1028
|
return next;
|
|
970
1029
|
}
|
|
1030
|
+
function annotateSpawnFailure(entries, sub, failure) {
|
|
1031
|
+
const idx = entries.findIndex((e) => e.sub === sub);
|
|
1032
|
+
if (idx === -1) return entries;
|
|
1033
|
+
const next = entries.slice();
|
|
1034
|
+
next[idx] = { ...entries[idx], spawn_failure: failure };
|
|
1035
|
+
return next;
|
|
1036
|
+
}
|
|
971
1037
|
function reopenSub(entries, sub, reason) {
|
|
972
1038
|
const idx = entries.findIndex((e) => e.sub === sub);
|
|
973
1039
|
if (idx === -1) {
|
|
@@ -1994,6 +2060,8 @@ var init_en = __esm({
|
|
|
1994
2060
|
"doctor.summary.fail": "\nsome checks failed (see fix hints above)",
|
|
1995
2061
|
"doctor.summary.warn": "\nall checks ok (with warnings \u2014 see hints above)",
|
|
1996
2062
|
"doctor.summary.pass": "\nall checks passed",
|
|
2063
|
+
"doctor.host_scope": "host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n",
|
|
2064
|
+
"doctor.matrix.legend": "\nn/a = the check is not declared for that host in the registry, so it was not run",
|
|
1997
2065
|
"check_docs.clean": "documentation discipline: no violations",
|
|
1998
2066
|
"check_docs.state_line_limit": "STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)",
|
|
1999
2067
|
"check_docs.state_key_decisions": "{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
@@ -3550,8 +3618,8 @@ var init_scale = __esm({
|
|
|
3550
3618
|
}
|
|
3551
3619
|
});
|
|
3552
3620
|
function extractVerifyBinary(verifyCmd, fallback) {
|
|
3553
|
-
const
|
|
3554
|
-
if (
|
|
3621
|
+
const token2 = verifyCmd?.trim().split(/\s+/)[0];
|
|
3622
|
+
if (token2 && BARE_BIN_RE.test(token2) && !NON_COMPONENT_TOKENS.has(token2)) return token2;
|
|
3555
3623
|
if (BARE_BIN_RE.test(fallback) && !NON_COMPONENT_TOKENS.has(fallback)) return fallback;
|
|
3556
3624
|
return null;
|
|
3557
3625
|
}
|
|
@@ -4355,6 +4423,15 @@ async function runCheckpointComplete(sub, opts, deps = defaultRunDeps) {
|
|
|
4355
4423
|
}
|
|
4356
4424
|
async function runCheckpointFail(sub, opts, deps = defaultRunDeps) {
|
|
4357
4425
|
const { completePhase: completePhase2 } = await Promise.resolve().then(() => (init_engineHook(), engineHook_exports));
|
|
4426
|
+
const { isSpawnFailure: isSpawnFailure2, SPAWN_FAILURES: SPAWN_FAILURES2 } = await Promise.resolve().then(() => (init_spawnFailure(), spawnFailure_exports));
|
|
4427
|
+
if (opts.failure !== void 0 && !isSpawnFailure2(opts.failure)) {
|
|
4428
|
+
deps.error(
|
|
4429
|
+
`[harnessed] checkpoint fail: unknown --failure kind '${opts.failure}' \u2014 expected one of ${SPAWN_FAILURES2.join(", ")}`
|
|
4430
|
+
);
|
|
4431
|
+
deps.exit(1);
|
|
4432
|
+
return;
|
|
4433
|
+
}
|
|
4434
|
+
const spawnFailure = isSpawnFailure2(opts.failure) ? opts.failure : void 0;
|
|
4358
4435
|
const preLedger = await readLedgerSafe(deps);
|
|
4359
4436
|
if (!enforceSerialOrder("fail", sub, findSerialBlockers(preLedger, sub), opts.force, deps)) {
|
|
4360
4437
|
deps.exit(1);
|
|
@@ -4381,7 +4458,10 @@ async function runCheckpointFail(sub, opts, deps = defaultRunDeps) {
|
|
|
4381
4458
|
await mutateSubProgress2(
|
|
4382
4459
|
(e) => markIfSeeded(e, sub, "failed", {
|
|
4383
4460
|
attempt_budget: budget,
|
|
4384
|
-
...nextProgress ? { progress: nextProgress } : {}
|
|
4461
|
+
...nextProgress ? { progress: nextProgress } : {},
|
|
4462
|
+
// T4 — omitted when absent so an untagged failure leaves NO key on the entry
|
|
4463
|
+
// (13 eval goldens compare the serialized ledger verbatim).
|
|
4464
|
+
...spawnFailure ? { spawn_failure: spawnFailure } : {}
|
|
4385
4465
|
})
|
|
4386
4466
|
);
|
|
4387
4467
|
await absorbIntentFor(sub);
|
|
@@ -4493,6 +4573,9 @@ function registerCheckpoint(program2) {
|
|
|
4493
4573
|
).option(
|
|
4494
4574
|
"--failing-tests <n>",
|
|
4495
4575
|
"fail only \u2014 number of tests still failing after this attempt; drives the no-progress circuit breaker (falls back to the evidence-artifact digest when omitted)"
|
|
4576
|
+
).option(
|
|
4577
|
+
"--failure <kind>",
|
|
4578
|
+
"fail only \u2014 which named spawn failure ended the attempt: SpawnTimeout | SpawnExitNonZero | SpawnOutputMalformed | SpawnAuthFailed | SpawnRefused (recorded on the ledger entry; an unknown value is rejected)"
|
|
4496
4579
|
).action(
|
|
4497
4580
|
async (action, sub, opts) => {
|
|
4498
4581
|
if (!isAction(action)) {
|
|
@@ -4699,7 +4782,7 @@ async function checkMcpScope() {
|
|
|
4699
4782
|
if (detectPlatform().id !== "claude") {
|
|
4700
4783
|
return {
|
|
4701
4784
|
name: "mcp scope",
|
|
4702
|
-
status: "
|
|
4785
|
+
status: "skipped",
|
|
4703
4786
|
message: "skipped (claude-only check)"
|
|
4704
4787
|
};
|
|
4705
4788
|
}
|
|
@@ -5047,7 +5130,7 @@ async function checkAgentTeamsDoctor() {
|
|
|
5047
5130
|
if (detectPlatform().id !== "claude") {
|
|
5048
5131
|
return {
|
|
5049
5132
|
name: "Agent Teams env",
|
|
5050
|
-
status: "
|
|
5133
|
+
status: "skipped",
|
|
5051
5134
|
message: "skipped (claude-only check)"
|
|
5052
5135
|
};
|
|
5053
5136
|
}
|
|
@@ -5083,7 +5166,7 @@ async function checkPlanningWithFiles() {
|
|
|
5083
5166
|
if (getPluginsRegistry() === null) {
|
|
5084
5167
|
return {
|
|
5085
5168
|
name: "planning-with-files plugin",
|
|
5086
|
-
status: "
|
|
5169
|
+
status: "skipped",
|
|
5087
5170
|
message: "skipped (claude-only plugin-cache probe; no plugin registry on this platform)"
|
|
5088
5171
|
};
|
|
5089
5172
|
}
|
|
@@ -5956,24 +6039,24 @@ var init_check_install_channels = __esm({
|
|
|
5956
6039
|
init_assetsRoot();
|
|
5957
6040
|
}
|
|
5958
6041
|
});
|
|
5959
|
-
function isRelativeFileToken(
|
|
5960
|
-
if (!/[\\/]/.test(
|
|
5961
|
-
if (ABSOLUTE_RE.test(
|
|
5962
|
-
if (/[*?$`]/.test(
|
|
6042
|
+
function isRelativeFileToken(token2) {
|
|
6043
|
+
if (!/[\\/]/.test(token2)) return false;
|
|
6044
|
+
if (ABSOLUTE_RE.test(token2)) return false;
|
|
6045
|
+
if (/[*?$`]/.test(token2)) return false;
|
|
5963
6046
|
return true;
|
|
5964
6047
|
}
|
|
5965
|
-
function stripQuotes(
|
|
5966
|
-
const m =
|
|
6048
|
+
function stripQuotes(token2) {
|
|
6049
|
+
const m = token2.match(/^"(.*)"$/);
|
|
5967
6050
|
if (m?.[1] !== void 0) return { bare: m[1], quoted: true };
|
|
5968
|
-
return { bare:
|
|
6051
|
+
return { bare: token2, quoted: false };
|
|
5969
6052
|
}
|
|
5970
6053
|
function splitTokens(raw) {
|
|
5971
6054
|
return raw.split(/\s+/).filter((t2) => t2.length > 0);
|
|
5972
6055
|
}
|
|
5973
6056
|
function hookMarkerAt(raw) {
|
|
5974
6057
|
const tokens = splitTokens(raw);
|
|
5975
|
-
for (const [i,
|
|
5976
|
-
const { bare: bare2 } = stripQuotes(
|
|
6058
|
+
for (const [i, token2] of tokens.entries()) {
|
|
6059
|
+
const { bare: bare2 } = stripQuotes(token2);
|
|
5977
6060
|
if (!isRelativeFileToken(bare2)) continue;
|
|
5978
6061
|
const seg = bare2.split(/[\\/]/);
|
|
5979
6062
|
const base = seg[seg.length - 1];
|
|
@@ -5981,8 +6064,8 @@ function hookMarkerAt(raw) {
|
|
|
5981
6064
|
const id = COMPILED_HOOK_IDENTITIES.find((k) => base.includes(k));
|
|
5982
6065
|
return { marker: id ?? base, index: i };
|
|
5983
6066
|
}
|
|
5984
|
-
for (const [i,
|
|
5985
|
-
const { bare: bare2 } = stripQuotes(
|
|
6067
|
+
for (const [i, token2] of tokens.entries()) {
|
|
6068
|
+
const { bare: bare2 } = stripQuotes(token2);
|
|
5986
6069
|
if (COMPILED_HOOK_IDENTITIES.includes(bare2))
|
|
5987
6070
|
return { marker: bare2, index: i };
|
|
5988
6071
|
}
|
|
@@ -5999,12 +6082,12 @@ function resolveHookCommand(raw, deps) {
|
|
|
5999
6082
|
}
|
|
6000
6083
|
let root = null;
|
|
6001
6084
|
const tokens = splitTokens(raw);
|
|
6002
|
-
const out = tokens.map((
|
|
6003
|
-
const { bare: bare2 } = stripQuotes(
|
|
6004
|
-
if (!isRelativeFileToken(bare2)) return
|
|
6085
|
+
const out = tokens.map((token2) => {
|
|
6086
|
+
const { bare: bare2 } = stripQuotes(token2);
|
|
6087
|
+
if (!isRelativeFileToken(bare2)) return token2;
|
|
6005
6088
|
root = root ?? deps.assetsRoot();
|
|
6006
6089
|
const abs = join(root, bare2);
|
|
6007
|
-
if (!deps.exists(abs)) return
|
|
6090
|
+
if (!deps.exists(abs)) return token2;
|
|
6008
6091
|
return `"${abs.replace(/\\/g, "/")}"`;
|
|
6009
6092
|
});
|
|
6010
6093
|
return out.join(" ");
|
|
@@ -6173,7 +6256,7 @@ function checkStaleHooks(deps) {
|
|
|
6173
6256
|
if (settingsPath === null)
|
|
6174
6257
|
return {
|
|
6175
6258
|
name: NAME,
|
|
6176
|
-
status: "
|
|
6259
|
+
status: "skipped",
|
|
6177
6260
|
message: `no settings file on ${detectPlatform().id} \u2014 skipped`
|
|
6178
6261
|
};
|
|
6179
6262
|
const raw = readText(settingsPath);
|
|
@@ -6371,7 +6454,7 @@ function checkInjectInvalidate(deps) {
|
|
|
6371
6454
|
if (settingsPath === null)
|
|
6372
6455
|
return {
|
|
6373
6456
|
name: NAME3,
|
|
6374
|
-
status: "
|
|
6457
|
+
status: "skipped",
|
|
6375
6458
|
message: `no settings file on ${detectPlatform().id} \u2014 skipped`
|
|
6376
6459
|
};
|
|
6377
6460
|
const raw = readText(settingsPath);
|
|
@@ -6502,7 +6585,7 @@ function readInstalledVersions(deps, registryPath) {
|
|
|
6502
6585
|
function checkPluginStaleness(overrides) {
|
|
6503
6586
|
const deps = { ...defaultDeps3(), ...overrides };
|
|
6504
6587
|
if (deps.registryPath === null) {
|
|
6505
|
-
return { name: NAME4, status: "
|
|
6588
|
+
return { name: NAME4, status: "skipped", message: "no plugin registry on this harness" };
|
|
6506
6589
|
}
|
|
6507
6590
|
const installed = readInstalledVersions(deps, deps.registryPath);
|
|
6508
6591
|
if (installed === null) {
|
|
@@ -7391,7 +7474,7 @@ function chainProblem(d, pluginName, id) {
|
|
|
7391
7474
|
async function checkCodexHooks(deps) {
|
|
7392
7475
|
const d = { ...defaultDeps4(), ...deps };
|
|
7393
7476
|
if (d.platformId !== "codex")
|
|
7394
|
-
return { name: NAME6, status: "
|
|
7477
|
+
return { name: NAME6, status: "skipped", message: `not codex (${d.platformId}) \u2014 skipped` };
|
|
7395
7478
|
const plugins = await d.pluginDirs();
|
|
7396
7479
|
if (plugins.length === 0)
|
|
7397
7480
|
return { name: NAME6, status: "pass", message: "no harnessed codex hook plugins installed" };
|
|
@@ -7438,75 +7521,180 @@ var init_check_codex_hooks = __esm({
|
|
|
7438
7521
|
});
|
|
7439
7522
|
|
|
7440
7523
|
// src/cli/lib/doctor-registry.ts
|
|
7441
|
-
|
|
7524
|
+
function checksForHost(host) {
|
|
7525
|
+
return CHECKS.filter((c) => c.hosts.includes(host));
|
|
7526
|
+
}
|
|
7527
|
+
var ALL_HOSTS, BOTH, CHECKS;
|
|
7442
7528
|
var init_doctor_registry = __esm({
|
|
7443
7529
|
"src/cli/lib/doctor-registry.ts"() {
|
|
7444
7530
|
init_check_builtin();
|
|
7531
|
+
ALL_HOSTS = ["claude", "codex"];
|
|
7532
|
+
BOTH = ALL_HOSTS;
|
|
7445
7533
|
CHECKS = [
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7534
|
+
// Node runtime version — `process.versions.node`, no harness surface at all.
|
|
7535
|
+
{ name: "node \u2265 22", hosts: BOTH, fn: async () => checkNodeVersion() },
|
|
7536
|
+
// claude-only: check-builtin.ts checkMcpScope early-returns unless
|
|
7537
|
+
// detectPlatform().id === 'claude'; it reads ~/.claude.json + project .mcp.json.
|
|
7538
|
+
{ name: "mcp scope", hosts: ["claude"], fn: checkMcpScope },
|
|
7539
|
+
// PATH probe (`where`/`which jq`) — the install hint switches on OS, not host.
|
|
7540
|
+
{ name: "jq present", hosts: BOTH, fn: async () => checkJq() },
|
|
7541
|
+
// resolveBash() PATH inspection. Its early return is an OS gate (non-Windows),
|
|
7542
|
+
// NOT a host gate — both harnesses need a usable bash on Windows.
|
|
7543
|
+
{ name: "bash flavor (win)", hosts: BOTH, fn: async () => checkWinBash() },
|
|
7544
|
+
// git remote of the cwd — no harness surface.
|
|
7545
|
+
{
|
|
7546
|
+
name: "origin URL",
|
|
7547
|
+
hosts: BOTH,
|
|
7548
|
+
fn: async () => {
|
|
7549
|
+
const { checkOrigin: checkOrigin2 } = await Promise.resolve().then(() => (init_origin_check(), origin_check_exports));
|
|
7550
|
+
const r = checkOrigin2(process.cwd(), { allowFork: true });
|
|
7551
|
+
return { name: "origin URL", status: r.status, message: r.detail, fix: r.fix };
|
|
7552
|
+
}
|
|
7553
|
+
},
|
|
7554
|
+
// PATH probe + harnessSkillsDirs() (which spans BOTH harnesses' skills dirs).
|
|
7555
|
+
{
|
|
7556
|
+
name: "gstack prefix",
|
|
7557
|
+
hosts: BOTH,
|
|
7558
|
+
fn: async () => {
|
|
7559
|
+
const { probeGstackPrefix: probeGstackPrefix2 } = await Promise.resolve().then(() => (init_probe_gstack(), probe_gstack_exports));
|
|
7560
|
+
const r = probeGstackPrefix2();
|
|
7561
|
+
return { name: "gstack prefix", status: r.status, message: r.detail, fix: r.fix };
|
|
7562
|
+
}
|
|
7563
|
+
},
|
|
7564
|
+
// Reads the packaged manifests/aliases.yaml — harness-independent.
|
|
7565
|
+
{
|
|
7566
|
+
name: "deprecated manifests",
|
|
7567
|
+
hosts: BOTH,
|
|
7568
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_deprecations(), check_deprecations_exports))).checkDeprecations()
|
|
7569
|
+
},
|
|
7570
|
+
// getSkillsDir() — descriptor-resolved, so it audits whichever harness is active.
|
|
7571
|
+
{
|
|
7572
|
+
name: "token budget",
|
|
7573
|
+
hosts: BOTH,
|
|
7574
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_token_budget(), check_token_budget_exports))).checkTokenBudget()
|
|
7575
|
+
},
|
|
7576
|
+
// claude-only: Agent Teams is a Claude Code env key; the check early-returns
|
|
7577
|
+
// unless detectPlatform().id === 'claude'.
|
|
7578
|
+
{
|
|
7579
|
+
name: "Agent Teams env",
|
|
7580
|
+
hosts: ["claude"],
|
|
7581
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_agent_teams_doctor(), check_agent_teams_doctor_exports))).checkAgentTeamsDoctor()
|
|
7454
7582
|
},
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7583
|
+
// claude-only: probes the CC plugin CACHE and early-returns when
|
|
7584
|
+
// getPluginsRegistry() is null (codex has no installed_plugins.json).
|
|
7585
|
+
{
|
|
7586
|
+
name: "planning-with-files plugin",
|
|
7587
|
+
hosts: ["claude"],
|
|
7588
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_planning_with_files(), check_planning_with_files_exports))).checkPlanningWithFiles()
|
|
7589
|
+
},
|
|
7590
|
+
// Both: the plugin-cache probe is registry-gated but the skill probes span
|
|
7591
|
+
// harnessSkillsDirs(), and install_commands computes `--agent` per host.
|
|
7592
|
+
{
|
|
7593
|
+
name: "mattpocock-skills",
|
|
7594
|
+
hosts: BOTH,
|
|
7595
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_mattpocock_skills(), check_mattpocock_skills_exports))).checkMattpocockSkills()
|
|
7596
|
+
},
|
|
7597
|
+
// Both: isMcpServerRegistered branches on codex → `[mcp_servers.*]` in config.toml.
|
|
7598
|
+
{
|
|
7599
|
+
name: "MCP servers (tavily/exa)",
|
|
7600
|
+
hosts: BOTH,
|
|
7601
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_mcp_availability(), check_mcp_availability_exports))).checkMcpAvailability()
|
|
7459
7602
|
},
|
|
7460
|
-
async () => (await Promise.resolve().then(() => (init_check_deprecations(), check_deprecations_exports))).checkDeprecations(),
|
|
7461
|
-
async () => (await Promise.resolve().then(() => (init_check_token_budget(), check_token_budget_exports))).checkTokenBudget(),
|
|
7462
|
-
async () => (await Promise.resolve().then(() => (init_check_agent_teams_doctor(), check_agent_teams_doctor_exports))).checkAgentTeamsDoctor(),
|
|
7463
|
-
async () => (await Promise.resolve().then(() => (init_check_planning_with_files(), check_planning_with_files_exports))).checkPlanningWithFiles(),
|
|
7464
|
-
async () => (await Promise.resolve().then(() => (init_check_mattpocock_skills(), check_mattpocock_skills_exports))).checkMattpocockSkills(),
|
|
7465
|
-
async () => (await Promise.resolve().then(() => (init_check_mcp_availability(), check_mcp_availability_exports))).checkMcpAvailability(),
|
|
7466
7603
|
// Phase 18 — opt-in CodeGraph semantic-index detect (always 'pass'; absence of an
|
|
7467
|
-
// optional tool is not a health failure).
|
|
7468
|
-
|
|
7604
|
+
// optional tool is not a health failure). Project-local `.codegraph/` — no host surface.
|
|
7605
|
+
{
|
|
7606
|
+
name: "codegraph",
|
|
7607
|
+
hosts: BOTH,
|
|
7608
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_codegraph(), check_codegraph_exports))).checkCodeGraph(process.cwd())
|
|
7609
|
+
},
|
|
7469
7610
|
// v4.16.1 T3 — bun presence (warn-only): gstack's upstream setup hard-requires
|
|
7470
7611
|
// bun; missing bun is THE gstack refresh-failure cause on user dogfood machines.
|
|
7471
|
-
|
|
7612
|
+
// Pure PATH probe.
|
|
7613
|
+
{ name: "bun present", hosts: BOTH, fn: async () => (await Promise.resolve().then(() => (init_check_bun(), check_bun_exports))).checkBun() },
|
|
7472
7614
|
// 4.22.1 T4 — dual-guard conflict (warn-only): ECC GateGuard's filename policy
|
|
7473
7615
|
// vs evidence-guard artifact contract names (subagents cannot fact-retry).
|
|
7474
|
-
|
|
7616
|
+
// Both: only the settings.json signal degrades on codex — the ecc-plugin signal
|
|
7617
|
+
// goes through isPluginRegistered (which asks `codex plugin list` there) and the
|
|
7618
|
+
// env signal is host-free. ECC ships a codex channel, so the conflict is real there.
|
|
7619
|
+
{
|
|
7620
|
+
name: "guard conflict (GateGuard)",
|
|
7621
|
+
hosts: BOTH,
|
|
7622
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_guard_conflict(), check_guard_conflict_exports))).checkGuardConflict()
|
|
7623
|
+
},
|
|
7475
7624
|
// 4.23.0 (issue #3) — installed workflow-skill integrity (warn-only): flat
|
|
7476
7625
|
// ~/.claude/skills packs can silently shadow shipped workflows; setup self-heals.
|
|
7477
|
-
|
|
7626
|
+
// getSkillsDir() — per-host install dir, so it audits either harness.
|
|
7627
|
+
{
|
|
7628
|
+
name: "workflow skill integrity",
|
|
7629
|
+
hosts: BOTH,
|
|
7630
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_skill_integrity(), check_skill_integrity_exports))).checkSkillIntegrity()
|
|
7631
|
+
},
|
|
7478
7632
|
// Phase 20 — "update available" version check ('warn' only when behind; 'pass'
|
|
7479
7633
|
// when current/ahead/npm-unreachable — fail-soft, never flips the summary).
|
|
7480
|
-
|
|
7634
|
+
// Compares package.json against npm — no harness surface.
|
|
7635
|
+
{
|
|
7636
|
+
name: "update",
|
|
7637
|
+
hosts: BOTH,
|
|
7638
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate()
|
|
7639
|
+
},
|
|
7481
7640
|
// 4.32.4 — dual install-channel conflict (warn-only): npm-global + standalone
|
|
7482
|
-
// binary both present → ambiguous PATH resolution + stale-update trap.
|
|
7483
|
-
|
|
7641
|
+
// binary both present → ambiguous PATH resolution + stale-update trap. The
|
|
7642
|
+
// harnessed CLI's own install, independent of which harness drives it.
|
|
7643
|
+
{
|
|
7644
|
+
name: "install channel",
|
|
7645
|
+
hosts: BOTH,
|
|
7646
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_install_channels(), check_install_channels_exports))).checkInstallChannels()
|
|
7647
|
+
},
|
|
7484
7648
|
// issue #8 — orphaned harnessed Stop/UserPromptSubmit hooks (warn-only): a hook
|
|
7485
7649
|
// pointing at a deleted bin/*.mjs makes Claude Code error MODULE_NOT_FOUND every
|
|
7486
|
-
// prompt; `harnessed uninstall` now strips them.
|
|
7487
|
-
|
|
7650
|
+
// prompt; `harnessed uninstall` now strips them. claude-only: the whole check is
|
|
7651
|
+
// a settings.json read, and getSettingsPath() is null on codex.
|
|
7652
|
+
{
|
|
7653
|
+
name: "stale hooks",
|
|
7654
|
+
hosts: ["claude"],
|
|
7655
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_stale_hooks(), check_stale_hooks_exports))).checkStaleHooks()
|
|
7656
|
+
},
|
|
7488
7657
|
// 4.32.22 — ECC per-harness detect (optional; pass unless CC-side ecc overlaps
|
|
7489
7658
|
// the official chrome-devtools-mcp plugin → warn). CC plugin registry + codex
|
|
7490
|
-
// sync-clone probed independently.
|
|
7491
|
-
async () => (await Promise.resolve().then(() => (init_check_ecc(), check_ecc_exports))).checkEcc(),
|
|
7659
|
+
// sync-clone probed independently — by construction a both-hosts check.
|
|
7660
|
+
{ name: "ecc", hosts: BOTH, fn: async () => (await Promise.resolve().then(() => (init_check_ecc(), check_ecc_exports))).checkEcc() },
|
|
7492
7661
|
// 4.38.0 — half-installed per-turn injection (warn-only): perturn-inject
|
|
7493
7662
|
// without perturn-inject-invalidate keeps skipping <project-context> after a
|
|
7494
7663
|
// compact/clear has already dropped the copy it is skipping on behalf of.
|
|
7495
|
-
|
|
7664
|
+
// claude-only: pairs two settings.json hook registrations (null path on codex).
|
|
7665
|
+
{
|
|
7666
|
+
name: "per-turn inject pairing",
|
|
7667
|
+
hosts: ["claude"],
|
|
7668
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_inject_invalidate(), check_inject_invalidate_exports))).checkInjectInvalidate()
|
|
7669
|
+
},
|
|
7496
7670
|
// Phase 56 — silently stale marketplace plugins (warn-only): `claude plugin
|
|
7497
7671
|
// install` pins a version into a versioned cache dir and never re-resolves, so
|
|
7498
7672
|
// the four cc-plugin-marketplace components drift behind without any signal.
|
|
7499
7673
|
// The only comparison in the codebase between a genuinely DETECTED version and
|
|
7500
7674
|
// a recorded one — see the header for why the installer-state layer cannot do it.
|
|
7501
|
-
|
|
7675
|
+
// claude-only: needs the installed_plugins.json registry (null on codex).
|
|
7676
|
+
{
|
|
7677
|
+
name: "plugin install freshness",
|
|
7678
|
+
hosts: ["claude"],
|
|
7679
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_plugin_staleness(), check_plugin_staleness_exports))).checkPluginStaleness()
|
|
7680
|
+
},
|
|
7502
7681
|
// Phase 60 — HARNESSED_OFF left on (warn-only): the kill switch silences every
|
|
7503
7682
|
// first-party hook, so a machine that forgot to unset it looks exactly like a
|
|
7504
|
-
// broken install. doctor is where that gets said out loud.
|
|
7505
|
-
|
|
7683
|
+
// broken install. doctor is where that gets said out loud. Env var — and the
|
|
7684
|
+
// hooks it silences exist on both harnesses.
|
|
7685
|
+
{
|
|
7686
|
+
name: "ablation switch",
|
|
7687
|
+
hosts: BOTH,
|
|
7688
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_ablation(), check_ablation_exports))).checkAblation()
|
|
7689
|
+
},
|
|
7506
7690
|
// v16.0 Phase 64 (ADR 0041) — codex hook plugins (warn-only): codex silently
|
|
7507
|
-
// skips an untrusted / modified hook, so "installed" is not "running".
|
|
7508
|
-
//
|
|
7509
|
-
|
|
7691
|
+
// skips an untrusted / modified hook, so "installed" is not "running". codex-only:
|
|
7692
|
+
// the check early-returns unless the active platform id is `codex`.
|
|
7693
|
+
{
|
|
7694
|
+
name: "codex hook plugins",
|
|
7695
|
+
hosts: ["codex"],
|
|
7696
|
+
fn: async () => (await Promise.resolve().then(() => (init_check_codex_hooks(), check_codex_hooks_exports))).checkCodexHooks()
|
|
7697
|
+
}
|
|
7510
7698
|
];
|
|
7511
7699
|
}
|
|
7512
7700
|
});
|
|
@@ -8149,33 +8337,6 @@ var init_judgmentResolver = __esm({
|
|
|
8149
8337
|
}
|
|
8150
8338
|
});
|
|
8151
8339
|
|
|
8152
|
-
// src/workflow/lib/completionSchema.ts
|
|
8153
|
-
var COMPLETION_SCHEMA;
|
|
8154
|
-
var init_completionSchema = __esm({
|
|
8155
|
-
"src/workflow/lib/completionSchema.ts"() {
|
|
8156
|
-
COMPLETION_SCHEMA = {
|
|
8157
|
-
type: "object",
|
|
8158
|
-
properties: {
|
|
8159
|
-
status: { type: "string", enum: ["COMPLETE", "PARTIAL", "BLOCKED"] },
|
|
8160
|
-
phase: { type: "string" },
|
|
8161
|
-
summary: { type: "string" },
|
|
8162
|
-
blockers: { type: "array", items: { type: "string" } },
|
|
8163
|
-
// v3.5.0 Phase 2 — Option 1-Lite signal-driven Agent Teams escalation.
|
|
8164
|
-
// spawned subagent SHOULD set this when any of parallelism-gate.yaml 5
|
|
8165
|
-
// upgrade triggers fire. harnessed runtime propagates to stderr hint;
|
|
8166
|
-
// user opens the team in the main Claude Code session — a spawned subagent
|
|
8167
|
-
// cannot form one itself (originally because the SDK never exposed the create
|
|
8168
|
-
// tool; since CC v2.1.178 there IS no create tool at all — teams form
|
|
8169
|
-
// implicitly on the lead's first background teammate spawn, and teammates
|
|
8170
|
-
// cannot nest teammates. See PHASE-2-SPEC.md § Why for the original rationale).
|
|
8171
|
-
needs_teams_escalation: { type: "boolean" },
|
|
8172
|
-
escalation_reason: { type: "string" }
|
|
8173
|
-
},
|
|
8174
|
-
required: ["status"]
|
|
8175
|
-
};
|
|
8176
|
-
}
|
|
8177
|
-
});
|
|
8178
|
-
|
|
8179
8340
|
// src/workflow/lib/sdkReconcile.ts
|
|
8180
8341
|
function toSdkAgentDefinition(def) {
|
|
8181
8342
|
return {
|
|
@@ -8228,6 +8389,342 @@ var init_spawnTimeout = __esm({
|
|
|
8228
8389
|
DEFAULT_SPAWN_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
8229
8390
|
}
|
|
8230
8391
|
});
|
|
8392
|
+
function firstMatch(text, patterns) {
|
|
8393
|
+
return patterns.find((p8) => p8.test(text));
|
|
8394
|
+
}
|
|
8395
|
+
function hasDanglingItem(events) {
|
|
8396
|
+
const started = /* @__PURE__ */ new Set();
|
|
8397
|
+
for (const e of events) {
|
|
8398
|
+
const id = e.item?.id;
|
|
8399
|
+
if (!id) continue;
|
|
8400
|
+
if (e.type === "item.started") started.add(id);
|
|
8401
|
+
if (e.type === "item.completed") started.delete(id);
|
|
8402
|
+
}
|
|
8403
|
+
return started.size > 0;
|
|
8404
|
+
}
|
|
8405
|
+
function classifyCodexExec(o) {
|
|
8406
|
+
const corpus = [o.stderr, o.lastMessage ?? "", JSON.stringify(o.events)].join("\n");
|
|
8407
|
+
const auth = firstMatch(corpus, AUTH_PATTERNS);
|
|
8408
|
+
if (auth) {
|
|
8409
|
+
return {
|
|
8410
|
+
ok: false,
|
|
8411
|
+
failure: "SpawnAuthFailed",
|
|
8412
|
+
detail: `codex exec is not authenticated (matched ${auth.source}). Run \`codex login\`.`
|
|
8413
|
+
};
|
|
8414
|
+
}
|
|
8415
|
+
if (o.signal) {
|
|
8416
|
+
return { ok: false, failure: "SpawnExitNonZero", detail: `killed by signal ${o.signal}` };
|
|
8417
|
+
}
|
|
8418
|
+
if (o.exitCode !== 0) {
|
|
8419
|
+
return {
|
|
8420
|
+
ok: false,
|
|
8421
|
+
failure: "SpawnExitNonZero",
|
|
8422
|
+
detail: `codex exec exited ${o.exitCode}: ${o.stderr.trim().slice(0, 300)}`
|
|
8423
|
+
};
|
|
8424
|
+
}
|
|
8425
|
+
const refusal = firstMatch(corpus, REFUSAL_PATTERNS);
|
|
8426
|
+
if (refusal) {
|
|
8427
|
+
return {
|
|
8428
|
+
ok: false,
|
|
8429
|
+
failure: "SpawnRefused",
|
|
8430
|
+
detail: `codex exec refused the work (matched ${refusal.source}) \u2014 exit code was still 0`
|
|
8431
|
+
};
|
|
8432
|
+
}
|
|
8433
|
+
if (o.events.some((e) => e.type === "turn.failed")) {
|
|
8434
|
+
return { ok: false, failure: "SpawnRefused", detail: "codex reported turn.failed" };
|
|
8435
|
+
}
|
|
8436
|
+
if (hasDanglingItem(o.events)) {
|
|
8437
|
+
return {
|
|
8438
|
+
ok: false,
|
|
8439
|
+
failure: "SpawnRefused",
|
|
8440
|
+
detail: "an item.started never completed \u2014 the tool call was rejected (F8)"
|
|
8441
|
+
};
|
|
8442
|
+
}
|
|
8443
|
+
if (!o.events.some((e) => e.type === "turn.completed")) {
|
|
8444
|
+
return {
|
|
8445
|
+
ok: false,
|
|
8446
|
+
failure: "SpawnOutputMalformed",
|
|
8447
|
+
detail: o.events.length === 0 && o.garbageLines > 0 ? `stdout was not JSONL (${o.garbageLines} unparseable lines)` : "the JSONL stream never reached turn.completed"
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8450
|
+
if (o.lastMessage === null || o.lastMessage.trim() === "") {
|
|
8451
|
+
return {
|
|
8452
|
+
ok: false,
|
|
8453
|
+
failure: "SpawnOutputMalformed",
|
|
8454
|
+
detail: "the -o last-message file was never written"
|
|
8455
|
+
};
|
|
8456
|
+
}
|
|
8457
|
+
return { ok: true, value: o.lastMessage };
|
|
8458
|
+
}
|
|
8459
|
+
function promoteStructuredOutput(lastMessage) {
|
|
8460
|
+
const trimmed = lastMessage.trim();
|
|
8461
|
+
if (!trimmed.startsWith("{")) return void 0;
|
|
8462
|
+
let parsed;
|
|
8463
|
+
try {
|
|
8464
|
+
parsed = JSON.parse(trimmed);
|
|
8465
|
+
} catch {
|
|
8466
|
+
return void 0;
|
|
8467
|
+
}
|
|
8468
|
+
const status = parsed?.status;
|
|
8469
|
+
if (typeof status !== "string" || !COMPLETION_STATUSES.includes(status)) return void 0;
|
|
8470
|
+
return { status };
|
|
8471
|
+
}
|
|
8472
|
+
function buildArgs(outPath, prompt, opts) {
|
|
8473
|
+
return [
|
|
8474
|
+
"exec",
|
|
8475
|
+
"--ephemeral",
|
|
8476
|
+
"--json",
|
|
8477
|
+
"-o",
|
|
8478
|
+
outPath,
|
|
8479
|
+
"-s",
|
|
8480
|
+
opts.sandbox ?? DEFAULT_CODEX_SANDBOX,
|
|
8481
|
+
...opts.model ? ["-m", opts.model] : [],
|
|
8482
|
+
"--skip-git-repo-check",
|
|
8483
|
+
prompt
|
|
8484
|
+
];
|
|
8485
|
+
}
|
|
8486
|
+
function planRequest(args, opts) {
|
|
8487
|
+
const env = { ...process.env, ...opts.env ?? {} };
|
|
8488
|
+
if (process.platform === "win32") {
|
|
8489
|
+
const plan = planWindowsSpawn("codex", args, resolveWindowsBin("codex"));
|
|
8490
|
+
return {
|
|
8491
|
+
command: plan.command,
|
|
8492
|
+
args: plan.args,
|
|
8493
|
+
env,
|
|
8494
|
+
windowsVerbatimArguments: plan.verbatim,
|
|
8495
|
+
...opts.cwd ? { cwd: opts.cwd } : {}
|
|
8496
|
+
};
|
|
8497
|
+
}
|
|
8498
|
+
return {
|
|
8499
|
+
command: "codex",
|
|
8500
|
+
args,
|
|
8501
|
+
env,
|
|
8502
|
+
windowsVerbatimArguments: false,
|
|
8503
|
+
...opts.cwd ? { cwd: opts.cwd } : {}
|
|
8504
|
+
};
|
|
8505
|
+
}
|
|
8506
|
+
function realSpawn(req) {
|
|
8507
|
+
const child = spawn(req.command, req.args, {
|
|
8508
|
+
// `shell: false` is the default and must stay that way (F5 pitfall 1).
|
|
8509
|
+
windowsHide: true,
|
|
8510
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
8511
|
+
env: req.env,
|
|
8512
|
+
windowsVerbatimArguments: req.windowsVerbatimArguments,
|
|
8513
|
+
...req.cwd ? { cwd: req.cwd } : {}
|
|
8514
|
+
});
|
|
8515
|
+
return {
|
|
8516
|
+
stdout: child.stdout,
|
|
8517
|
+
stderr: child.stderr,
|
|
8518
|
+
kill: () => killProcessTree(child),
|
|
8519
|
+
on: ((event, fn) => child.on(event, fn))
|
|
8520
|
+
};
|
|
8521
|
+
}
|
|
8522
|
+
function runOnce(req, spawnFn, timeoutMs, onThreadId) {
|
|
8523
|
+
return new Promise((resolve23, reject) => {
|
|
8524
|
+
const events = [];
|
|
8525
|
+
let garbageLines = 0;
|
|
8526
|
+
let stderr = "";
|
|
8527
|
+
let stdoutBuf = "";
|
|
8528
|
+
let threadSeen = false;
|
|
8529
|
+
let settled = false;
|
|
8530
|
+
let exited;
|
|
8531
|
+
let openStreams = 2;
|
|
8532
|
+
let timer;
|
|
8533
|
+
let proc;
|
|
8534
|
+
try {
|
|
8535
|
+
proc = spawnFn(req);
|
|
8536
|
+
} catch (e) {
|
|
8537
|
+
reject(new SpawnFailureError("SpawnExitNonZero", `spawn error: ${e.message}`));
|
|
8538
|
+
return;
|
|
8539
|
+
}
|
|
8540
|
+
const finish = () => {
|
|
8541
|
+
if (settled || !exited || openStreams > 0) return;
|
|
8542
|
+
settled = true;
|
|
8543
|
+
clearTimeout(timer);
|
|
8544
|
+
resolve23({ exitCode: exited.code, signal: exited.signal, events, garbageLines, stderr });
|
|
8545
|
+
};
|
|
8546
|
+
const fail = (err2) => {
|
|
8547
|
+
if (settled) return;
|
|
8548
|
+
settled = true;
|
|
8549
|
+
clearTimeout(timer);
|
|
8550
|
+
try {
|
|
8551
|
+
proc.kill();
|
|
8552
|
+
} catch {
|
|
8553
|
+
}
|
|
8554
|
+
reject(err2);
|
|
8555
|
+
};
|
|
8556
|
+
proc.stdout.setEncoding("utf8");
|
|
8557
|
+
proc.stdout.on("data", (chunk) => {
|
|
8558
|
+
stdoutBuf += chunk;
|
|
8559
|
+
for (let i = stdoutBuf.indexOf("\n"); i >= 0; i = stdoutBuf.indexOf("\n")) {
|
|
8560
|
+
const line = stdoutBuf.slice(0, i).trim();
|
|
8561
|
+
stdoutBuf = stdoutBuf.slice(i + 1);
|
|
8562
|
+
if (!line) continue;
|
|
8563
|
+
let ev;
|
|
8564
|
+
try {
|
|
8565
|
+
ev = JSON.parse(line);
|
|
8566
|
+
} catch {
|
|
8567
|
+
garbageLines += 1;
|
|
8568
|
+
continue;
|
|
8569
|
+
}
|
|
8570
|
+
events.push(ev);
|
|
8571
|
+
if (!threadSeen && ev.type === "thread.started" && typeof ev.thread_id === "string") {
|
|
8572
|
+
threadSeen = true;
|
|
8573
|
+
onThreadId?.(ev.thread_id);
|
|
8574
|
+
}
|
|
8575
|
+
}
|
|
8576
|
+
});
|
|
8577
|
+
proc.stdout.on("end", () => {
|
|
8578
|
+
openStreams -= 1;
|
|
8579
|
+
finish();
|
|
8580
|
+
});
|
|
8581
|
+
proc.stderr.setEncoding("utf8");
|
|
8582
|
+
proc.stderr.on("data", (chunk) => {
|
|
8583
|
+
stderr += chunk;
|
|
8584
|
+
});
|
|
8585
|
+
proc.stderr.on("end", () => {
|
|
8586
|
+
openStreams -= 1;
|
|
8587
|
+
finish();
|
|
8588
|
+
});
|
|
8589
|
+
proc.on(
|
|
8590
|
+
"error",
|
|
8591
|
+
(e) => fail(new SpawnFailureError("SpawnExitNonZero", `spawn error: ${e.message}`))
|
|
8592
|
+
);
|
|
8593
|
+
proc.on("exit", (code2, signal) => {
|
|
8594
|
+
exited = { code: code2, signal };
|
|
8595
|
+
finish();
|
|
8596
|
+
});
|
|
8597
|
+
if (timeoutMs > 0) {
|
|
8598
|
+
timer = setTimeout(
|
|
8599
|
+
() => fail(
|
|
8600
|
+
new SpawnFailureError(
|
|
8601
|
+
"SpawnTimeout",
|
|
8602
|
+
`codex exec exceeded its ${timeoutMs}ms wall-clock timeout (HARNESSED_SPAWN_TIMEOUT_MS)`
|
|
8603
|
+
)
|
|
8604
|
+
),
|
|
8605
|
+
timeoutMs
|
|
8606
|
+
);
|
|
8607
|
+
}
|
|
8608
|
+
});
|
|
8609
|
+
}
|
|
8610
|
+
async function codexExecSpawn(def, opts, deps = {}) {
|
|
8611
|
+
const hostId = toHostId(detectPlatform().id);
|
|
8612
|
+
if (hostId !== "codex") throw new HostNotCodexError(hostId);
|
|
8613
|
+
const spawnFn = deps.spawn ?? realSpawn;
|
|
8614
|
+
const timeoutMs = opts.timeoutMs ?? envSpawnTimeoutMs();
|
|
8615
|
+
const prompt = injectFactoryInternalFields(def, def.prompt);
|
|
8616
|
+
const dir = await mkdtemp(join(tmpdir(), "harnessed-codex-exec-"));
|
|
8617
|
+
try {
|
|
8618
|
+
let last;
|
|
8619
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
8620
|
+
const outPath = join(dir, `last-message-${attempt}.txt`);
|
|
8621
|
+
const req = planRequest(buildArgs(outPath, prompt, opts), opts);
|
|
8622
|
+
let failure;
|
|
8623
|
+
let detail;
|
|
8624
|
+
try {
|
|
8625
|
+
const run = await runOnce(req, spawnFn, timeoutMs, opts.onThreadId);
|
|
8626
|
+
const verdict = classifyCodexExec({
|
|
8627
|
+
...run,
|
|
8628
|
+
lastMessage: await readIfPresent(outPath)
|
|
8629
|
+
});
|
|
8630
|
+
if (verdict.ok) return toEnvelope(verdict.value);
|
|
8631
|
+
failure = verdict.failure;
|
|
8632
|
+
detail = verdict.detail;
|
|
8633
|
+
} catch (e) {
|
|
8634
|
+
if (!(e instanceof SpawnFailureError)) throw e;
|
|
8635
|
+
failure = e.failure;
|
|
8636
|
+
detail = e.message;
|
|
8637
|
+
}
|
|
8638
|
+
last = new SpawnFailureError(failure, `${detail} [phase ${opts.expertName}]`);
|
|
8639
|
+
if (attempt === 2 || !isRetryableSpawnFailure(failure)) break;
|
|
8640
|
+
}
|
|
8641
|
+
throw last;
|
|
8642
|
+
} finally {
|
|
8643
|
+
await rm(dir, { recursive: true, force: true }).catch(() => {
|
|
8644
|
+
});
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8647
|
+
async function readIfPresent(path) {
|
|
8648
|
+
try {
|
|
8649
|
+
return await readFile(path, "utf8");
|
|
8650
|
+
} catch {
|
|
8651
|
+
return null;
|
|
8652
|
+
}
|
|
8653
|
+
}
|
|
8654
|
+
function toEnvelope(lastMessage) {
|
|
8655
|
+
const structured = promoteStructuredOutput(lastMessage);
|
|
8656
|
+
const envelope = {
|
|
8657
|
+
subtype: "success",
|
|
8658
|
+
...structured ? { structured_output: structured } : {},
|
|
8659
|
+
text: lastMessage,
|
|
8660
|
+
result: lastMessage
|
|
8661
|
+
};
|
|
8662
|
+
return JSON.stringify(envelope);
|
|
8663
|
+
}
|
|
8664
|
+
var DEFAULT_CODEX_SANDBOX, HostNotCodexError, AUTH_PATTERNS, REFUSAL_PATTERNS, COMPLETION_STATUSES;
|
|
8665
|
+
var init_codexExecSpawn = __esm({
|
|
8666
|
+
"src/workflow/lib/codexExecSpawn.ts"() {
|
|
8667
|
+
init_hostPrimitives();
|
|
8668
|
+
init_killTree();
|
|
8669
|
+
init_winSpawn();
|
|
8670
|
+
init_platform();
|
|
8671
|
+
init_sdkReconcile();
|
|
8672
|
+
init_spawnFailure();
|
|
8673
|
+
init_spawnTimeout();
|
|
8674
|
+
DEFAULT_CODEX_SANDBOX = "workspace-write";
|
|
8675
|
+
HostNotCodexError = class extends Error {
|
|
8676
|
+
constructor(hostId) {
|
|
8677
|
+
super(
|
|
8678
|
+
`codexExecSpawn is reachable only from a codex host (this process resolved to '${hostId}'). A claude host never launches codex on its own \u2014 that is the v16.0 outbound boundary.`
|
|
8679
|
+
);
|
|
8680
|
+
this.name = "HostNotCodexError";
|
|
8681
|
+
}
|
|
8682
|
+
};
|
|
8683
|
+
AUTH_PATTERNS = [
|
|
8684
|
+
/not logged in/i,
|
|
8685
|
+
/\bunauthorized\b/i,
|
|
8686
|
+
/\b401\b/,
|
|
8687
|
+
/authentication (?:failed|required)/i,
|
|
8688
|
+
/\bcodex login\b/i,
|
|
8689
|
+
/auth\.json/i,
|
|
8690
|
+
/no (?:valid )?credentials/i
|
|
8691
|
+
];
|
|
8692
|
+
REFUSAL_PATTERNS = [
|
|
8693
|
+
/Rejected\(/,
|
|
8694
|
+
/exec_command failed/i,
|
|
8695
|
+
/unknown agent_type/i,
|
|
8696
|
+
/sandbox (?:denied|rejected)/i
|
|
8697
|
+
];
|
|
8698
|
+
COMPLETION_STATUSES = ["COMPLETE", "PARTIAL", "BLOCKED"];
|
|
8699
|
+
}
|
|
8700
|
+
});
|
|
8701
|
+
|
|
8702
|
+
// src/workflow/lib/completionSchema.ts
|
|
8703
|
+
var COMPLETION_SCHEMA;
|
|
8704
|
+
var init_completionSchema = __esm({
|
|
8705
|
+
"src/workflow/lib/completionSchema.ts"() {
|
|
8706
|
+
COMPLETION_SCHEMA = {
|
|
8707
|
+
type: "object",
|
|
8708
|
+
properties: {
|
|
8709
|
+
status: { type: "string", enum: ["COMPLETE", "PARTIAL", "BLOCKED"] },
|
|
8710
|
+
phase: { type: "string" },
|
|
8711
|
+
summary: { type: "string" },
|
|
8712
|
+
blockers: { type: "array", items: { type: "string" } },
|
|
8713
|
+
// v3.5.0 Phase 2 — Option 1-Lite signal-driven Agent Teams escalation.
|
|
8714
|
+
// spawned subagent SHOULD set this when any of parallelism-gate.yaml 5
|
|
8715
|
+
// upgrade triggers fire. harnessed runtime propagates to stderr hint;
|
|
8716
|
+
// user opens the team in the main Claude Code session — a spawned subagent
|
|
8717
|
+
// cannot form one itself (originally because the SDK never exposed the create
|
|
8718
|
+
// tool; since CC v2.1.178 there IS no create tool at all — teams form
|
|
8719
|
+
// implicitly on the lead's first background teammate spawn, and teammates
|
|
8720
|
+
// cannot nest teammates. See PHASE-2-SPEC.md § Why for the original rationale).
|
|
8721
|
+
needs_teams_escalation: { type: "boolean" },
|
|
8722
|
+
escalation_reason: { type: "string" }
|
|
8723
|
+
},
|
|
8724
|
+
required: ["status"]
|
|
8725
|
+
};
|
|
8726
|
+
}
|
|
8727
|
+
});
|
|
8231
8728
|
async function sdkSpawn(def, opts) {
|
|
8232
8729
|
const sdkDef = toSdkAgentDefinition(def);
|
|
8233
8730
|
const injectedPrompt = injectFactoryInternalFields(def, def.prompt);
|
|
@@ -8322,25 +8819,23 @@ var init_sdkSpawn = __esm({
|
|
|
8322
8819
|
}
|
|
8323
8820
|
});
|
|
8324
8821
|
|
|
8325
|
-
// src/workflow/lib/
|
|
8326
|
-
function
|
|
8327
|
-
return
|
|
8822
|
+
// src/workflow/lib/spawnDispatch.ts
|
|
8823
|
+
function resolveSpawnHost() {
|
|
8824
|
+
return toHostId(detectPlatform().id);
|
|
8328
8825
|
}
|
|
8329
|
-
function
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8826
|
+
async function dispatchSpawn(def, opts, deps = {}) {
|
|
8827
|
+
const host = (deps.hostId ?? resolveSpawnHost)();
|
|
8828
|
+
if (host === "codex") {
|
|
8829
|
+
return (deps.codexExecSpawn ?? codexExecSpawn)(def, { expertName: opts.expertName });
|
|
8830
|
+
}
|
|
8831
|
+
return (deps.sdkSpawn ?? sdkSpawn)(def, opts);
|
|
8333
8832
|
}
|
|
8334
|
-
var
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
"SpawnOutputMalformed",
|
|
8341
|
-
"SpawnAuthFailed",
|
|
8342
|
-
"SpawnRefused"
|
|
8343
|
-
];
|
|
8833
|
+
var init_spawnDispatch = __esm({
|
|
8834
|
+
"src/workflow/lib/spawnDispatch.ts"() {
|
|
8835
|
+
init_hostPrimitives();
|
|
8836
|
+
init_platform();
|
|
8837
|
+
init_codexExecSpawn();
|
|
8838
|
+
init_sdkSpawn();
|
|
8344
8839
|
}
|
|
8345
8840
|
});
|
|
8346
8841
|
|
|
@@ -9126,6 +9621,18 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
9126
9621
|
...typeof gateContext.modelTierOverride === "string" ? { modelTierOverride: gateContext.modelTierOverride } : {}
|
|
9127
9622
|
});
|
|
9128
9623
|
if (r.status !== "ok") {
|
|
9624
|
+
if (r.failure) {
|
|
9625
|
+
try {
|
|
9626
|
+
const { mutateSubProgress: mutateSubProgress2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
9627
|
+
const { annotateSpawnFailure: annotateSpawnFailure2 } = await Promise.resolve().then(() => (init_ledger(), ledger_exports));
|
|
9628
|
+
const failure = r.failure;
|
|
9629
|
+
await mutateSubProgress2((entries) => annotateSpawnFailure2(entries, workflowName, failure));
|
|
9630
|
+
} catch (err2) {
|
|
9631
|
+
console.warn(
|
|
9632
|
+
`\u26A0\uFE0F could not record spawn failure '${r.failure}' for ${workflowName} on the ledger (${err2.message}); the terminal checkpoint below is unaffected.`
|
|
9633
|
+
);
|
|
9634
|
+
}
|
|
9635
|
+
}
|
|
9129
9636
|
await completePhase({
|
|
9130
9637
|
phaseId: ph.id,
|
|
9131
9638
|
lastTask: `FAILED: phase ${ph.id}: ${r.output}`,
|
|
@@ -9166,7 +9673,7 @@ var init_run = __esm({
|
|
|
9166
9673
|
init_governance2();
|
|
9167
9674
|
init_judgmentResolver();
|
|
9168
9675
|
init_ralphLoop();
|
|
9169
|
-
|
|
9676
|
+
init_spawnDispatch();
|
|
9170
9677
|
init_spawnFailure();
|
|
9171
9678
|
init_loadPhases();
|
|
9172
9679
|
init_masterOrchestrator();
|
|
@@ -9215,7 +9722,7 @@ This applies to: strategic-layer review skip / phase-layer clarification skip /
|
|
|
9215
9722
|
const optIn = isRalphLoopOptIn(phase);
|
|
9216
9723
|
const spawnOnce = async (resumeSessionId, onSessionId) => {
|
|
9217
9724
|
const injectsRules = phase && typeof phase === "object" && "injects_rules" in phase && Array.isArray(phase.injects_rules) ? phase.injects_rules : void 0;
|
|
9218
|
-
return
|
|
9725
|
+
return dispatchSpawn(
|
|
9219
9726
|
buildAgentDef(
|
|
9220
9727
|
skillName,
|
|
9221
9728
|
opts?.rolePrompts,
|
|
@@ -11449,7 +11956,7 @@ ${newEntry}
|
|
|
11449
11956
|
return { aborted: true, reason };
|
|
11450
11957
|
}
|
|
11451
11958
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
11452
|
-
const bk = await backup(plan, ctx);
|
|
11959
|
+
const bk = await backup(bin === "codex" ? { files: [] } : plan, ctx);
|
|
11453
11960
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
11454
11961
|
const spawnCwd = install.cwd ?? getMcpSpawnCwd();
|
|
11455
11962
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
@@ -11597,7 +12104,7 @@ ${newEntry}
|
|
|
11597
12104
|
return { aborted: true, reason };
|
|
11598
12105
|
}
|
|
11599
12106
|
if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
|
|
11600
|
-
const bk = await backup(plan, ctx);
|
|
12107
|
+
const bk = await backup(bin === "codex" ? { files: [] } : plan, ctx);
|
|
11601
12108
|
if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
|
|
11602
12109
|
const spawnCwd = install.cwd ?? getMcpSpawnCwd();
|
|
11603
12110
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
@@ -12981,7 +13488,7 @@ async function runAutoInstall(opts) {
|
|
|
12981
13488
|
if (!opts.autoInstall) {
|
|
12982
13489
|
return out;
|
|
12983
13490
|
}
|
|
12984
|
-
const results = await Promise.all(CHECKS.map((c) => c()));
|
|
13491
|
+
const results = await Promise.all(CHECKS.map((c) => c.fn()));
|
|
12985
13492
|
const installables = results.filter(
|
|
12986
13493
|
(r) => r.status === "warn" && Array.isArray(r.install_commands) && r.install_commands.length > 0
|
|
12987
13494
|
);
|
|
@@ -14058,41 +14565,161 @@ function registerCompact(program2) {
|
|
|
14058
14565
|
|
|
14059
14566
|
// src/cli/doctor.ts
|
|
14060
14567
|
init_i18n();
|
|
14568
|
+
|
|
14569
|
+
// src/cli/lib/doctor-matrix.ts
|
|
14570
|
+
var NOT_APPLICABLE = "n/a";
|
|
14571
|
+
var SUMMARY_ROW = "summary";
|
|
14572
|
+
var CHECK_COL = "check";
|
|
14573
|
+
var GUTTER = " ";
|
|
14574
|
+
function summarise(results) {
|
|
14575
|
+
if (results.some((r) => r.status === "fail")) return "fail";
|
|
14576
|
+
if (results.some((r) => r.status === "warn")) return "warn";
|
|
14577
|
+
return "pass";
|
|
14578
|
+
}
|
|
14579
|
+
function token(cell2) {
|
|
14580
|
+
return cell2 === null ? NOT_APPLICABLE : cell2.status;
|
|
14581
|
+
}
|
|
14582
|
+
function pad(text, width) {
|
|
14583
|
+
return text + " ".repeat(Math.max(0, width - text.length));
|
|
14584
|
+
}
|
|
14585
|
+
function renderMatrix(m, legend) {
|
|
14586
|
+
const nameW = Math.max(
|
|
14587
|
+
CHECK_COL.length,
|
|
14588
|
+
SUMMARY_ROW.length,
|
|
14589
|
+
...m.checks.map((c) => c.name.length)
|
|
14590
|
+
);
|
|
14591
|
+
const colW = m.hosts.map(
|
|
14592
|
+
(h) => Math.max(h.length, m.summary[h].length, ...m.checks.map((c) => token(c.cells[h]).length))
|
|
14593
|
+
);
|
|
14594
|
+
const line = (first, cells) => [pad(first, nameW), ...cells.map((c, i) => pad(c, colW[i] ?? c.length))].join(GUTTER).trimEnd();
|
|
14595
|
+
const rule = line(
|
|
14596
|
+
"-".repeat(nameW),
|
|
14597
|
+
colW.map((w) => "-".repeat(w))
|
|
14598
|
+
);
|
|
14599
|
+
return [
|
|
14600
|
+
line(
|
|
14601
|
+
CHECK_COL,
|
|
14602
|
+
m.hosts.map((h) => h)
|
|
14603
|
+
),
|
|
14604
|
+
rule,
|
|
14605
|
+
...m.checks.map(
|
|
14606
|
+
(c) => line(
|
|
14607
|
+
c.name,
|
|
14608
|
+
m.hosts.map((h) => token(c.cells[h]))
|
|
14609
|
+
)
|
|
14610
|
+
),
|
|
14611
|
+
rule,
|
|
14612
|
+
line(
|
|
14613
|
+
SUMMARY_ROW,
|
|
14614
|
+
m.hosts.map((h) => m.summary[h])
|
|
14615
|
+
),
|
|
14616
|
+
legend
|
|
14617
|
+
].join("\n");
|
|
14618
|
+
}
|
|
14619
|
+
|
|
14620
|
+
// src/cli/doctor.ts
|
|
14061
14621
|
init_doctor_registry();
|
|
14622
|
+
var MARKS = { pass: "\u2713", warn: "\u26A0", fail: "\u2717", skipped: "-" };
|
|
14623
|
+
async function runChecks(checks) {
|
|
14624
|
+
const settled = await Promise.allSettled(checks.map((c) => c.fn()));
|
|
14625
|
+
return settled.map(
|
|
14626
|
+
(s, i) => s.status === "fulfilled" ? s.value : {
|
|
14627
|
+
name: checks[i]?.name ?? `check #${i + 1}`,
|
|
14628
|
+
status: "warn",
|
|
14629
|
+
message: `check crashed: ${s.reason instanceof Error ? s.reason.message : String(s.reason)}`,
|
|
14630
|
+
fix: "this check was skipped; the other checks above are unaffected"
|
|
14631
|
+
}
|
|
14632
|
+
);
|
|
14633
|
+
}
|
|
14634
|
+
async function runAsHost(host, checks) {
|
|
14635
|
+
const prev = process.env.HARNESSED_PLATFORM;
|
|
14636
|
+
process.env.HARNESSED_PLATFORM = host;
|
|
14637
|
+
try {
|
|
14638
|
+
return await runChecks(checks);
|
|
14639
|
+
} finally {
|
|
14640
|
+
if (prev === void 0) delete process.env.HARNESSED_PLATFORM;
|
|
14641
|
+
else process.env.HARNESSED_PLATFORM = prev;
|
|
14642
|
+
}
|
|
14643
|
+
}
|
|
14644
|
+
async function buildMatrix() {
|
|
14645
|
+
const perHost = /* @__PURE__ */ new Map();
|
|
14646
|
+
const summary = {};
|
|
14647
|
+
for (const host of ALL_HOSTS) {
|
|
14648
|
+
const applicable = checksForHost(host);
|
|
14649
|
+
const results = await runAsHost(host, applicable);
|
|
14650
|
+
perHost.set(
|
|
14651
|
+
host,
|
|
14652
|
+
new Map(
|
|
14653
|
+
results.map((r, i) => [
|
|
14654
|
+
applicable[i]?.name ?? r.name,
|
|
14655
|
+
{ status: r.status, message: r.message, ...r.fix ? { fix: r.fix } : {} }
|
|
14656
|
+
])
|
|
14657
|
+
)
|
|
14658
|
+
);
|
|
14659
|
+
summary[host] = summarise(results);
|
|
14660
|
+
}
|
|
14661
|
+
return {
|
|
14662
|
+
hosts: ALL_HOSTS,
|
|
14663
|
+
checks: CHECKS.map((c) => ({
|
|
14664
|
+
name: c.name,
|
|
14665
|
+
hosts: c.hosts,
|
|
14666
|
+
cells: Object.fromEntries(
|
|
14667
|
+
ALL_HOSTS.map((h) => [h, perHost.get(h)?.get(c.name) ?? null])
|
|
14668
|
+
)
|
|
14669
|
+
})),
|
|
14670
|
+
summary
|
|
14671
|
+
};
|
|
14672
|
+
}
|
|
14673
|
+
function printList(results) {
|
|
14674
|
+
for (const r of results) {
|
|
14675
|
+
console.log(`${MARKS[r.status]} ${r.name} \u2014 ${r.message}`);
|
|
14676
|
+
if (r.status !== "pass" && r.status !== "skipped" && r.fix) console.log(` fix: ${r.fix}`);
|
|
14677
|
+
}
|
|
14678
|
+
}
|
|
14062
14679
|
function registerDoctor(program2) {
|
|
14063
14680
|
program2.command("doctor").description(
|
|
14064
|
-
"Preflight checks (Node / MCP scope / jq / Win bash / origin URL / gstack prefix / deprecations / token budget / Agent Teams / planning-with-files / mattpocock-skills / MCP availability / ECC / plugin freshness)"
|
|
14065
|
-
).option("--json", "output JSON instead of human-readable").
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14681
|
+
"Preflight checks (Node / MCP scope / jq / Win bash / origin URL / gstack prefix / deprecations / token budget / Agent Teams / planning-with-files / mattpocock-skills / MCP availability / ECC / plugin freshness / codex hooks)"
|
|
14682
|
+
).option("--json", "output JSON instead of human-readable").option(
|
|
14683
|
+
"--host <id>",
|
|
14684
|
+
`run only the checks that apply to one harness (${ALL_HOSTS.join(" | ")}), resolved as that harness`
|
|
14685
|
+
).option("--matrix", "report every check against every harness (check \xD7 host table)").action(async (opts) => {
|
|
14686
|
+
if (opts.matrix && opts.host !== void 0) {
|
|
14687
|
+
console.error("--matrix and --host are mutually exclusive (--matrix covers every host)");
|
|
14688
|
+
process.exit(2);
|
|
14689
|
+
}
|
|
14690
|
+
if (opts.matrix) {
|
|
14691
|
+
const matrix2 = await buildMatrix();
|
|
14692
|
+
if (opts.json) console.log(JSON.stringify({ matrix: matrix2 }, null, 2));
|
|
14693
|
+
else console.log(renderMatrix(matrix2, t("doctor.matrix.legend")));
|
|
14694
|
+
process.exit(ALL_HOSTS.some((h) => matrix2.summary[h] === "fail") ? 1 : 0);
|
|
14695
|
+
}
|
|
14696
|
+
let host = null;
|
|
14697
|
+
if (opts.host !== void 0) {
|
|
14698
|
+
if (!ALL_HOSTS.includes(opts.host)) {
|
|
14699
|
+
console.error(
|
|
14700
|
+
`--host: unknown id '${opts.host}' (expected one of: ${ALL_HOSTS.join(" | ")})`
|
|
14701
|
+
);
|
|
14702
|
+
process.exit(2);
|
|
14073
14703
|
}
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
const
|
|
14704
|
+
host = opts.host;
|
|
14705
|
+
}
|
|
14706
|
+
const checks = host === null ? CHECKS : checksForHost(host);
|
|
14707
|
+
const results = host === null ? await runChecks(checks) : await runAsHost(host, checks);
|
|
14708
|
+
const summary = summarise(results);
|
|
14077
14709
|
if (opts.json) {
|
|
14078
|
-
console.log(
|
|
14079
|
-
JSON.stringify(
|
|
14080
|
-
{ checks: results, summary: hasFail ? "fail" : hasWarn ? "warn" : "pass" },
|
|
14081
|
-
null,
|
|
14082
|
-
2
|
|
14083
|
-
)
|
|
14084
|
-
);
|
|
14710
|
+
console.log(JSON.stringify({ host, checks: results, summary }, null, 2));
|
|
14085
14711
|
} else {
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14712
|
+
if (host !== null) {
|
|
14713
|
+
console.log(
|
|
14714
|
+
t("doctor.host_scope", { host, applied: checks.length, total: CHECKS.length })
|
|
14715
|
+
);
|
|
14090
14716
|
}
|
|
14717
|
+
printList(results);
|
|
14091
14718
|
console.log(
|
|
14092
|
-
|
|
14719
|
+
summary === "fail" ? t("doctor.summary.fail") : summary === "warn" ? t("doctor.summary.warn") : t("doctor.summary.pass")
|
|
14093
14720
|
);
|
|
14094
14721
|
}
|
|
14095
|
-
process.exit(
|
|
14722
|
+
process.exit(summary === "fail" ? 1 : 0);
|
|
14096
14723
|
});
|
|
14097
14724
|
}
|
|
14098
14725
|
|