harnessed 4.49.1 → 4.49.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, rmSync, utimesSync, statSync, appendFileSync } from 'fs';
2
+ import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, rmSync, utimesSync, statSync, appendFileSync, accessSync, constants } from 'fs';
3
3
  import { homedir, tmpdir } from 'os';
4
- import { join, resolve, dirname, basename, sep, isAbsolute, relative, win32, posix } from 'path';
4
+ import { join, resolve, dirname, basename, sep, isAbsolute, win32, relative, 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, mkdtemp } from 'fs/promises';
6
+ import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod, realpath, mkdtemp, lstat, symlink } from 'fs/promises';
7
7
  import { Value } from '@sinclair/typebox/value';
8
8
  import lockfile from 'proper-lockfile';
9
9
  import { createHash, verify, createPublicKey } from 'crypto';
@@ -38,7 +38,7 @@ var init_package = __esm({
38
38
  "package.json"() {
39
39
  package_default = {
40
40
  name: "harnessed",
41
- version: "4.49.1",
41
+ version: "4.49.2",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -1379,7 +1379,9 @@ var init_en = __esm({
1379
1379
  "setup.mcp_hint": "Run /mcp in Claude Code to verify MCP server connections.",
1380
1380
  "setup.mcp_hint_codex": "Run codex mcp list to verify MCP server connections.",
1381
1381
  "setup.search_key_hint.header": "\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:",
1382
+ "setup.search_key_hint.header_codex": "\n\u26A0 Search MCP API keys not visible to this check: Codex checks only process env. Verify the tools first; if authentication fails, set the key in your shell environment.",
1382
1383
  "setup.search_key_hint.line": ' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
1384
+ "setup.search_key_hint.line_codex": ' {{server}}: set {{envVar}} in your shell environment (export {{envVar}}="<your-key>")',
1383
1385
  "setup.optional_offer.ecc_note": " ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
1384
1386
  "setup.bundled_summary": "\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)",
1385
1387
  "setup.bundled_location": "",
@@ -1961,8 +1963,8 @@ function insertAgentsMdSection(body, section) {
1961
1963
  return `${base}${sep3}${section}`;
1962
1964
  }
1963
1965
  async function resolveCommandNames(workflowsDir) {
1964
- const { readdir: readdir20 } = await import('fs/promises');
1965
- const entries = await readdir20(workflowsDir);
1966
+ const { readdir: readdir21 } = await import('fs/promises');
1967
+ const entries = await readdir21(workflowsDir);
1966
1968
  const { workflows } = await scanWorkflowsNested(workflowsDir, entries);
1967
1969
  const prompts = await loadRolePrompts(workflowsDir);
1968
1970
  return workflows.map((w) => w.name).filter((n) => prompts[n] !== void 0).sort();
@@ -3160,7 +3162,7 @@ var init_winSpawn = __esm({
3160
3162
  }
3161
3163
  });
3162
3164
  function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
3163
- return new Promise((resolve23) => {
3165
+ return new Promise((resolve25) => {
3164
3166
  const isWin = process.platform === "win32";
3165
3167
  const stdio = ["ignore", "pipe", "pipe"];
3166
3168
  let child;
@@ -3186,17 +3188,17 @@ function runHarnessArgs(bin, args, cwd, timeoutMs = 15e3) {
3186
3188
  });
3187
3189
  const timer = setTimeout(() => {
3188
3190
  killProcessTree(child);
3189
- resolve23({ exitCode: -1, stdout: stdout2, stderr: `${stderr}[timeout after ${timeoutMs}ms]` });
3191
+ resolve25({ exitCode: -1, stdout: stdout2, stderr: `${stderr}[timeout after ${timeoutMs}ms]` });
3190
3192
  }, timeoutMs);
3191
3193
  child.on("error", (e) => {
3192
3194
  clearTimeout(timer);
3193
3195
  const enoent = e.code === "ENOENT";
3194
3196
  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;
3195
- resolve23({ exitCode: -1, stdout: stdout2, stderr: `${stderr}${msg}` });
3197
+ resolve25({ exitCode: -1, stdout: stdout2, stderr: `${stderr}${msg}` });
3196
3198
  });
3197
3199
  child.on("close", (code2) => {
3198
3200
  clearTimeout(timer);
3199
- resolve23({ exitCode: code2 ?? -1, stdout: stdout2, stderr });
3201
+ resolve25({ exitCode: code2 ?? -1, stdout: stdout2, stderr });
3200
3202
  });
3201
3203
  });
3202
3204
  }
@@ -3234,17 +3236,22 @@ var init_safeCwd = __esm({
3234
3236
  });
3235
3237
 
3236
3238
  // src/installers/lib/codexMcpServers.ts
3237
- function parseCodexMcpList(stdout2) {
3239
+ function parseCodexMcpMetadata(stdout2) {
3238
3240
  const text = stdout2.trim();
3239
3241
  if (!text.startsWith("[")) return null;
3240
3242
  try {
3241
3243
  const parsed = JSON.parse(text);
3242
3244
  if (!Array.isArray(parsed)) return null;
3243
- const names = /* @__PURE__ */ new Set();
3245
+ const servers = [];
3244
3246
  for (const entry of parsed) {
3245
- if (typeof entry?.name === "string" && entry.name !== "") names.add(entry.name);
3247
+ if (typeof entry?.name === "string" && entry.name !== "") {
3248
+ servers.push({
3249
+ name: entry.name,
3250
+ enabled: typeof entry.enabled === "boolean" ? entry.enabled : null
3251
+ });
3252
+ }
3246
3253
  }
3247
- return names;
3254
+ return servers;
3248
3255
  } catch {
3249
3256
  return null;
3250
3257
  }
@@ -3253,13 +3260,21 @@ function invalidateCodexMcpCache() {
3253
3260
  cache2 = null;
3254
3261
  }
3255
3262
  async function listOnce() {
3256
- const r = await runHarnessArgs("codex", ["mcp", "list", "--json"], getMcpSpawnCwd(), 3e4);
3257
- return r.exitCode === 0 ? parseCodexMcpList(r.stdout) : null;
3263
+ try {
3264
+ const r = await runHarnessArgs("codex", ["mcp", "list", "--json"], getMcpSpawnCwd(), 3e4);
3265
+ return r.exitCode === 0 ? parseCodexMcpMetadata(r.stdout) : null;
3266
+ } catch {
3267
+ return null;
3268
+ }
3258
3269
  }
3259
- function listCodexMcpServers() {
3270
+ function listCodexMcpServerMetadata() {
3260
3271
  cache2 = cache2 ?? listOnce();
3261
3272
  return cache2;
3262
3273
  }
3274
+ async function listCodexMcpServers() {
3275
+ const servers = await listCodexMcpServerMetadata();
3276
+ return servers === null ? null : new Set(servers.map((server) => server.name));
3277
+ }
3263
3278
  async function isCodexMcpServerRegistered(name) {
3264
3279
  const names = await listCodexMcpServers();
3265
3280
  return names ? names.has(name) : false;
@@ -3318,9 +3333,9 @@ async function isCodexPluginInstalled(name) {
3318
3333
  return false;
3319
3334
  }
3320
3335
  function withCodexPluginLock(fn) {
3321
- const run = lock.then(fn, fn);
3322
- lock = run.catch(() => void 0);
3323
- return run;
3336
+ const run2 = lock.then(fn, fn);
3337
+ lock = run2.catch(() => void 0);
3338
+ return run2;
3324
3339
  }
3325
3340
  var cache3, lock;
3326
3341
  var init_codexPlugins = __esm({
@@ -4157,9 +4172,9 @@ function realRun(finder, bin) {
4157
4172
  }
4158
4173
  function binaryOnPath(bin, deps) {
4159
4174
  const platform = process.platform;
4160
- const run = realRun;
4175
+ const run2 = realRun;
4161
4176
  const finder = platform === "win32" ? "where" : "which";
4162
- const r = run(finder, bin);
4177
+ const r = run2(finder, bin);
4163
4178
  if (!r || r.status !== 0) return false;
4164
4179
  return r.stdout.trim().length > 0;
4165
4180
  }
@@ -4167,6 +4182,43 @@ var NON_COMPONENT_TOKENS, BARE_BIN_RE;
4167
4182
  var init_binaryProbe = __esm({
4168
4183
  "src/installers/lib/binaryProbe.ts"() {
4169
4184
  NON_COMPONENT_TOKENS = /* @__PURE__ */ new Set([
4185
+ "set",
4186
+ "if",
4187
+ "then",
4188
+ "elif",
4189
+ "else",
4190
+ "fi",
4191
+ "for",
4192
+ "while",
4193
+ "until",
4194
+ "do",
4195
+ "done",
4196
+ "case",
4197
+ "esac",
4198
+ "in",
4199
+ "function",
4200
+ "select",
4201
+ "trap",
4202
+ "export",
4203
+ "unset",
4204
+ "readonly",
4205
+ "local",
4206
+ "declare",
4207
+ "typeset",
4208
+ "eval",
4209
+ "exec",
4210
+ "exit",
4211
+ "return",
4212
+ "break",
4213
+ "continue",
4214
+ "shift",
4215
+ "source",
4216
+ "cd",
4217
+ "read",
4218
+ "umask",
4219
+ "wait",
4220
+ "true",
4221
+ "false",
4170
4222
  "test",
4171
4223
  "grep",
4172
4224
  "ls",
@@ -5833,10 +5885,18 @@ function probeOne(cmd) {
5833
5885
  return r.status === 0 && (r.stdout?.trim().length ?? 0) > 0;
5834
5886
  }
5835
5887
  function gstackSkillsDirInstalled(exists) {
5836
- for (const dir of harnessSkillsDirs()) {
5888
+ const platform = detectPlatform();
5889
+ const dirs = platform.id === "codex" ? [join(process.env.CODEX_HOME || platform.homeDir, "skills"), getSkillsDir()] : harnessSkillsDirs();
5890
+ for (const dir of dirs) {
5837
5891
  const root = join(dir, "gstack");
5892
+ if (platform.id === "codex") {
5893
+ if (exists(join(dir, "gstack-office-hours", "SKILL.md")) && exists(join(root, "SKILL.md")) && exists(join(root, "bin", "gstack-browser-ensure"))) {
5894
+ return { root, prefix: "gstack-" };
5895
+ }
5896
+ continue;
5897
+ }
5838
5898
  if (exists(join(root, "office-hours", "SKILL.md")) || exists(join(root, "skills", "office-hours.md"))) {
5839
- return root;
5899
+ return { root, prefix: "" };
5840
5900
  }
5841
5901
  }
5842
5902
  return null;
@@ -5844,7 +5904,8 @@ function gstackSkillsDirInstalled(exists) {
5844
5904
  function probeGstackPrefix(deps) {
5845
5905
  const exists = deps?.exists ?? ((p8) => {
5846
5906
  try {
5847
- return existsSync(p8);
5907
+ accessSync(p8, constants.R_OK);
5908
+ return statSync(p8).isFile();
5848
5909
  } catch {
5849
5910
  return false;
5850
5911
  }
@@ -5852,10 +5913,18 @@ function probeGstackPrefix(deps) {
5852
5913
  const hasGstack = probeOne("gstack-office-hours");
5853
5914
  const hasBare = probeOne("office-hours");
5854
5915
  if (hasGstack && !hasBare) {
5855
- return { status: "pass", prefix: "gstack-", detail: "gstack-office-hours found" };
5916
+ return {
5917
+ status: "pass",
5918
+ prefix: "gstack-",
5919
+ detail: "gstack-office-hours found (command prefix only; browser not checked)"
5920
+ };
5856
5921
  }
5857
5922
  if (!hasGstack && hasBare) {
5858
- return { status: "pass", prefix: "", detail: "office-hours found (--no-prefix mode)" };
5923
+ return {
5924
+ status: "pass",
5925
+ prefix: "",
5926
+ detail: "office-hours found (--no-prefix mode; command prefix only; browser not checked)"
5927
+ };
5859
5928
  }
5860
5929
  if (hasGstack && hasBare) {
5861
5930
  return {
@@ -5868,14 +5937,14 @@ function probeGstackPrefix(deps) {
5868
5937
  if (skillsRoot !== null) {
5869
5938
  return {
5870
5939
  status: "pass",
5871
- prefix: "",
5872
- detail: `gstack skills dir found (${skillsRoot})`
5940
+ prefix: skillsRoot.prefix,
5941
+ detail: `gstack skills dir found (${skillsRoot.root}; content/prefix only; browser not checked)`
5873
5942
  };
5874
5943
  }
5875
5944
  return {
5876
5945
  status: "fail",
5877
5946
  detail: "neither gstack-office-hours nor office-hours found in PATH, and no gstack skills dir",
5878
- fix: "install gstack: run `harnessed setup` (git-clones gstack into ~/.claude/skills/gstack) \u2014 see https://github.com/garrytan/gstack"
5947
+ fix: "install gstack for the active host: run `harnessed setup` (browser readiness is checked separately by install verification)"
5879
5948
  };
5880
5949
  }
5881
5950
  var init_probe_gstack = __esm({
@@ -6105,12 +6174,31 @@ var check_planning_with_files_exports = {};
6105
6174
  __export(check_planning_with_files_exports, {
6106
6175
  checkPlanningWithFiles: () => checkPlanningWithFiles
6107
6176
  });
6177
+ async function readableContent(path) {
6178
+ try {
6179
+ return (await stat(path)).isFile() && (await readFile(path, "utf8")).trim().length > 0;
6180
+ } catch {
6181
+ return false;
6182
+ }
6183
+ }
6184
+ async function hasResourceContent(path) {
6185
+ try {
6186
+ for (const entry of await readdir(path, { withFileTypes: true })) {
6187
+ if (entry.isFile() && await readableContent(join(path, entry.name))) return true;
6188
+ }
6189
+ } catch {
6190
+ }
6191
+ return false;
6192
+ }
6193
+ async function hasPlanningContent(root) {
6194
+ return await readableContent(join(root, "SKILL.md")) && await hasResourceContent(join(root, "scripts")) && await hasResourceContent(join(root, "templates"));
6195
+ }
6108
6196
  async function checkPlanningWithFiles() {
6109
6197
  if (getPluginsRegistry() === null) {
6110
6198
  return {
6111
6199
  name: "planning-with-files plugin",
6112
6200
  status: "skipped",
6113
- message: "skipped (claude-only plugin-cache probe; no plugin registry on this platform)"
6201
+ message: "skipped (Claude-only plugin-cache probe; Codex installed skills, content and runtime are not verified)"
6114
6202
  };
6115
6203
  }
6116
6204
  const root = join(
@@ -6122,19 +6210,24 @@ async function checkPlanningWithFiles() {
6122
6210
  "planning-with-files"
6123
6211
  );
6124
6212
  try {
6125
- const entries = await readdir(root);
6126
- const versions = entries.filter((e) => /^\d+\.\d+/.test(e));
6127
- if (versions.length > 0) {
6128
- return {
6129
- name: "planning-with-files plugin",
6130
- status: "pass",
6131
- message: `installed (version ${versions.join(", ")})`
6132
- };
6213
+ const entries = await readdir(root, { withFileTypes: true });
6214
+ for (const version of entries) {
6215
+ if (!version.isDirectory() || !/^\d+\.\d+/.test(version.name)) continue;
6216
+ const versionRoot = join(root, version.name);
6217
+ for (const candidate of [join(versionRoot, "skills", "planning-with-files"), versionRoot]) {
6218
+ if (await hasPlanningContent(candidate)) {
6219
+ return {
6220
+ name: "planning-with-files plugin",
6221
+ status: "pass",
6222
+ message: `local planning-with-files content detected (version ${version.name}; SKILL.md, scripts and templates); runtime execution not verified`
6223
+ };
6224
+ }
6225
+ }
6133
6226
  }
6134
6227
  return {
6135
6228
  name: "planning-with-files plugin",
6136
6229
  status: "warn",
6137
- message: "plugin directory exists but no version subdir found",
6230
+ message: "no readable nonempty planning-with-files skill, scripts and templates found together",
6138
6231
  fix: REMEDIATION,
6139
6232
  install_commands: INSTALL_COMMANDS
6140
6233
  };
@@ -6142,7 +6235,7 @@ async function checkPlanningWithFiles() {
6142
6235
  return {
6143
6236
  name: "planning-with-files plugin",
6144
6237
  status: "warn",
6145
- message: "not installed (plugin cache path missing)",
6238
+ message: "local plugin content not detected (plugin cache path missing or unreadable)",
6146
6239
  fix: REMEDIATION,
6147
6240
  install_commands: INSTALL_COMMANDS
6148
6241
  };
@@ -6169,7 +6262,29 @@ function installCommands() {
6169
6262
  const agent = detectPlatform().id === "codex" ? "codex" : "claude-code";
6170
6263
  return [`npx skills@latest add mattpocock/skills --copy -y --agent ${agent}`];
6171
6264
  }
6265
+ async function hasSkillContent(root) {
6266
+ try {
6267
+ const path = join(root, "SKILL.md");
6268
+ return (await stat(path)).isFile() && (await readFile(path, "utf8")).trim().length > 0;
6269
+ } catch {
6270
+ return false;
6271
+ }
6272
+ }
6273
+ async function findIndicator(root) {
6274
+ for (const indicator of INDICATORS) {
6275
+ if (await hasSkillContent(join(root, indicator))) return indicator;
6276
+ }
6277
+ return null;
6278
+ }
6279
+ function contentDetected(indicator, root) {
6280
+ return {
6281
+ name: "mattpocock-skills",
6282
+ status: "pass",
6283
+ message: `partial local content detected: ${indicator}/SKILL.md (${root}); complete package and runtime not verified`
6284
+ };
6285
+ }
6172
6286
  async function checkMattpocockSkills() {
6287
+ const platform = detectPlatform();
6173
6288
  const pluginRoot = join(
6174
6289
  homedir(),
6175
6290
  ".claude",
@@ -6180,57 +6295,40 @@ async function checkMattpocockSkills() {
6180
6295
  );
6181
6296
  if (getPluginsRegistry() !== null) {
6182
6297
  try {
6183
- const entries = await readdir(pluginRoot);
6184
- const versions = entries.filter((e) => /^\d+\.\d+/.test(e));
6185
- if (versions.length > 0) {
6186
- return {
6187
- name: "mattpocock-skills",
6188
- status: "pass",
6189
- message: `installed as plugin (version ${versions.join(", ")})`
6190
- };
6298
+ const entries = await readdir(pluginRoot, { withFileTypes: true });
6299
+ for (const version of entries) {
6300
+ if (!version.isDirectory() || !/^\d+\.\d+/.test(version.name)) continue;
6301
+ const root = join(pluginRoot, version.name, "skills");
6302
+ const indicator = await findIndicator(root);
6303
+ if (indicator) return contentDetected(indicator, root);
6191
6304
  }
6192
6305
  } catch {
6193
6306
  }
6194
6307
  }
6195
- for (const skillsDir of harnessSkillsDirs()) {
6196
- try {
6197
- const skillRoot = join(skillsDir, "mattpocock-skills");
6198
- await stat(skillRoot);
6199
- return {
6200
- name: "mattpocock-skills",
6201
- status: "pass",
6202
- message: `installed as user-skill (${skillRoot})`
6203
- };
6204
- } catch {
6205
- }
6206
- }
6207
- const indicators = ["tdd", "diagnosing-bugs", "grill-with-docs", "diagnose"];
6208
- for (const skillsDir of harnessSkillsDirs()) {
6209
- for (const ind of indicators) {
6210
- try {
6211
- await stat(join(skillsDir, ind));
6212
- return {
6213
- name: "mattpocock-skills",
6214
- status: "pass",
6215
- message: `installed as individual skills (found ${ind}/)`
6216
- };
6217
- } catch {
6218
- }
6308
+ const skillsDirs = platform.id === "codex" ? [getSkillsDir(), join(process.env.CODEX_HOME || platform.homeDir, "skills")] : harnessSkillsDirs();
6309
+ let packageContent = false;
6310
+ for (const skillsDir of skillsDirs) {
6311
+ const packRoot = join(skillsDir, "mattpocock-skills");
6312
+ for (const root of [packRoot, join(packRoot, "skills"), skillsDir]) {
6313
+ const indicator = await findIndicator(root);
6314
+ if (indicator) return contentDetected(indicator, root);
6219
6315
  }
6316
+ packageContent = await hasSkillContent(packRoot) || packageContent;
6220
6317
  }
6221
6318
  return {
6222
6319
  name: "mattpocock-skills",
6223
6320
  status: "warn",
6224
- message: "not installed (plugin cache + user-skill paths both missing)",
6225
- fix: REMEDIATION2,
6321
+ message: packageContent ? "local package SKILL.md content detected, but no readable known indicator; package completeness and runtime not verified" : "no readable nonempty known indicator SKILL.md detected (plugin cache + user-skill paths); runtime not verified",
6322
+ fix: platform.id === "codex" ? "install via `npx skills@latest add mattpocock/skills --copy -y --agent codex`; optional methodology fallback remains in role-prompts.yaml" : REMEDIATION2,
6226
6323
  install_commands: installCommands()
6227
6324
  };
6228
6325
  }
6229
- var REMEDIATION2;
6326
+ var REMEDIATION2, INDICATORS;
6230
6327
  var init_check_mattpocock_skills = __esm({
6231
6328
  "src/cli/lib/check-mattpocock-skills.ts"() {
6232
6329
  init_platform();
6233
6330
  REMEDIATION2 = "install via `npx skills@latest add mattpocock/skills` (or git clone https://github.com/mattpocock/skills ~/.claude/skills/mattpocock-skills); methodology fallback already inline in role-prompts.yaml per v3.6.0 Phase 1 \u2014 install is optional but enables /grill-with-docs /tdd /diagnosing-bugs etc. SlashCommand acceleration";
6331
+ INDICATORS = ["tdd", "diagnosing-bugs", "grill-with-docs", "diagnose"];
6234
6332
  }
6235
6333
  });
6236
6334
 
@@ -6282,9 +6380,11 @@ async function missingSearchMcpKeys() {
6282
6380
  async function searchMcpKeyHintLines() {
6283
6381
  const missing = await missingSearchMcpKeys();
6284
6382
  if (missing.length === 0) return [];
6285
- const lines = [t("setup.search_key_hint.header")];
6383
+ const isCodex = detectPlatform().id === "codex";
6384
+ const lines = [t(isCodex ? "setup.search_key_hint.header_codex" : "setup.search_key_hint.header")];
6385
+ const lineKey = isCodex ? "setup.search_key_hint.line_codex" : "setup.search_key_hint.line";
6286
6386
  for (const m of missing) {
6287
- lines.push(t("setup.search_key_hint.line", { server: m.server, envVar: m.envVar }));
6387
+ lines.push(t(lineKey, { server: m.server, envVar: m.envVar }));
6288
6388
  }
6289
6389
  return lines;
6290
6390
  }
@@ -6307,30 +6407,51 @@ __export(check_mcp_availability_exports, {
6307
6407
  checkMcpAvailability: () => checkMcpAvailability
6308
6408
  });
6309
6409
  async function checkMcpAvailability() {
6410
+ const isCodex = detectPlatform().id === "codex";
6411
+ const metadata = isCodex ? await listCodexMcpServerMetadata() : null;
6412
+ if (isCodex && metadata === null) {
6413
+ return {
6414
+ name: CHECK_NAME,
6415
+ status: "warn",
6416
+ message: `registration unknown (Codex CLI listing unavailable or unparseable); enablement unknown; ${UNVERIFIED}`
6417
+ };
6418
+ }
6310
6419
  const installed2 = [];
6311
6420
  const missing = [];
6421
+ const enabled = [];
6422
+ const disabled = [];
6423
+ const unknown = [];
6312
6424
  for (const s of TARGET_SERVERS) {
6313
- if (await isMcpServerRegistered(s)) installed2.push(s);
6314
- else missing.push(s);
6425
+ const entry = metadata?.find((server) => server.name === s);
6426
+ const registered = isCodex ? entry !== void 0 : await isMcpServerRegistered(s);
6427
+ if (!registered) {
6428
+ missing.push(s);
6429
+ continue;
6430
+ }
6431
+ installed2.push(s);
6432
+ if (entry?.enabled === true) enabled.push(s);
6433
+ else if (entry?.enabled === false) disabled.push(s);
6434
+ else unknown.push(s);
6315
6435
  }
6316
6436
  const keyless = [];
6437
+ const observed = [];
6317
6438
  for (const s of installed2) {
6318
6439
  const probe = await probeSearchMcpKey(s);
6319
6440
  if (!probe.present) keyless.push(probe);
6320
- }
6321
- if (missing.length === 0 && keyless.length === 0) {
6322
- return {
6323
- name: CHECK_NAME,
6324
- status: "pass",
6325
- message: `installed: ${installed2.join(", ")} (API keys configured)`
6326
- };
6441
+ else observed.push(s);
6327
6442
  }
6328
6443
  const parts = [];
6329
- if (installed2.length > 0) parts.push(`installed: ${installed2.join(", ")}`);
6444
+ if (installed2.length > 0) parts.push(`registered: ${installed2.join(", ")}`);
6330
6445
  if (missing.length > 0) parts.push(`not registered: ${missing.join(", ")}`);
6446
+ if (enabled.length > 0) parts.push(`enabled: ${enabled.join(", ")}`);
6447
+ if (disabled.length > 0) parts.push(`disabled: ${disabled.join(", ")}`);
6448
+ if (unknown.length > 0) parts.push(`enablement unknown: ${unknown.join(", ")}`);
6449
+ if (observed.length > 0) parts.push(`API key hints observed: ${observed.join(", ")}`);
6331
6450
  if (keyless.length > 0) {
6332
- parts.push(`API key missing: ${keyless.map((k) => `${k.server} \u2192 ${k.envVar}`).join(", ")}`);
6451
+ const label = isCodex ? "API key not visible to this check" : "API key missing";
6452
+ parts.push(`${label}: ${keyless.map((k) => `${k.server} \u2192 ${k.envVar}`).join(", ")}`);
6333
6453
  }
6454
+ parts.push(UNVERIFIED);
6334
6455
  const fixes = [];
6335
6456
  if (missing.length > 0) {
6336
6457
  fixes.push("run `harnessed setup` to install missing MCPs via Step B (manifests/tools/)");
@@ -6338,24 +6459,26 @@ async function checkMcpAvailability() {
6338
6459
  if (keyless.length > 0) {
6339
6460
  const vars = keyless.map((k) => k.envVar).join(" / ");
6340
6461
  fixes.push(
6341
- detectPlatform().id === "codex" ? `export ${vars} in your shell (on codex that is the only source this check can read \u2014 its MCP config is TOML and there is no JSON settings file)` : `set ${vars} in the ~/.claude/settings.json "env" block (e.g. {"env": {"${keyless[0]?.envVar}": "<your-key>"}}) or export it in your shell; a mcpServers.<name>.env entry in ~/.claude.json also works`
6462
+ isCodex ? `export ${vars} in your shell (on codex that is the only source this check can read \u2014 its MCP config is TOML and there is no JSON settings file)` : `set ${vars} in the ~/.claude/settings.json "env" block (e.g. {"env": {"${keyless[0]?.envVar}": "<your-key>"}}) or export it in your shell; a mcpServers.<name>.env entry in ~/.claude.json also works`
6342
6463
  );
6343
6464
  }
6344
6465
  return {
6345
6466
  name: CHECK_NAME,
6346
6467
  status: "warn",
6347
6468
  message: parts.join("; "),
6348
- fix: fixes.join("; ")
6469
+ ...fixes.length > 0 ? { fix: fixes.join("; ") } : {}
6349
6470
  };
6350
6471
  }
6351
- var TARGET_SERVERS, CHECK_NAME;
6472
+ var TARGET_SERVERS, CHECK_NAME, UNVERIFIED;
6352
6473
  var init_check_mcp_availability = __esm({
6353
6474
  "src/cli/lib/check-mcp-availability.ts"() {
6475
+ init_codexMcpServers();
6354
6476
  init_readClaudeConfig();
6355
6477
  init_platform();
6356
6478
  init_search_mcp_keys();
6357
6479
  TARGET_SERVERS = Object.keys(SEARCH_MCP_KEY_VARS);
6358
6480
  CHECK_NAME = "MCP servers (tavily/exa)";
6481
+ UNVERIFIED = "authentication not verified; approval not probed; runtime availability not verified";
6359
6482
  }
6360
6483
  });
6361
6484
 
@@ -6406,9 +6529,9 @@ function realRun2(finder) {
6406
6529
  }
6407
6530
  function checkBun(deps) {
6408
6531
  const platform = deps?.platform ?? process.platform;
6409
- const run = deps?.run ?? realRun2;
6532
+ const run2 = deps?.run ?? realRun2;
6410
6533
  const finder = platform === "win32" ? "where" : "which";
6411
- const r = run(finder);
6534
+ const r = run2(finder);
6412
6535
  if (r && r.status === 0 && r.stdout.trim().length > 0) {
6413
6536
  return {
6414
6537
  name: "bun present",
@@ -7748,7 +7871,7 @@ async function withAppServer(deps, body) {
7748
7871
  const call = (method, params) => {
7749
7872
  if (closed) return Promise.reject(closed);
7750
7873
  const id = nextId++;
7751
- return new Promise((resolve23, reject) => {
7874
+ return new Promise((resolve25, reject) => {
7752
7875
  const timer = setTimeout(() => {
7753
7876
  pending.delete(id);
7754
7877
  reject(new RpcError("timeout", `${method} timed out after ${timeoutMs}ms`));
@@ -7756,7 +7879,7 @@ async function withAppServer(deps, body) {
7756
7879
  pending.set(id, {
7757
7880
  resolve: (v) => {
7758
7881
  clearTimeout(timer);
7759
- resolve23(v);
7882
+ resolve25(v);
7760
7883
  },
7761
7884
  reject: (e) => {
7762
7885
  clearTimeout(timer);
@@ -8714,25 +8837,25 @@ var init_discipline = __esm({
8714
8837
  );
8715
8838
  }
8716
8839
  });
8717
- async function loadDiscipline(basename4, packageRoot) {
8718
- const cached = _cache.get(basename4);
8840
+ async function loadDiscipline(basename5, packageRoot) {
8841
+ const cached = _cache.get(basename5);
8719
8842
  if (cached) return cached;
8720
- const yamlPath = resolve(packageRoot, "workflows", "disciplines", `${basename4}.yaml`);
8843
+ const yamlPath = resolve(packageRoot, "workflows", "disciplines", `${basename5}.yaml`);
8721
8844
  const raw = await readFile(yamlPath, "utf8");
8722
8845
  const parsedRaw = parse(raw);
8723
8846
  if (!Value.Check(Discipline, parsedRaw)) {
8724
8847
  const errors = [...Value.Errors(Discipline, parsedRaw)].slice(0, 3).map((e) => `${e.path} ${e.message}`).join("; ");
8725
- throw new Error(`Invalid discipline file ${basename4}.yaml: ${errors}`);
8848
+ throw new Error(`Invalid discipline file ${basename5}.yaml: ${errors}`);
8726
8849
  }
8727
8850
  const parsed = parsedRaw;
8728
- _cache.set(basename4, parsed);
8851
+ _cache.set(basename5, parsed);
8729
8852
  return parsed;
8730
8853
  }
8731
8854
  async function loadAllApplied(disciplines_applied, packageRoot) {
8732
8855
  const applied = disciplines_applied && disciplines_applied.length > 0 ? disciplines_applied : DEFAULT_APPLIED;
8733
8856
  const out = /* @__PURE__ */ new Map();
8734
- for (const basename4 of applied) {
8735
- out.set(basename4, await loadDiscipline(basename4, packageRoot));
8857
+ for (const basename5 of applied) {
8858
+ out.set(basename5, await loadDiscipline(basename5, packageRoot));
8736
8859
  }
8737
8860
  return out;
8738
8861
  }
@@ -9245,7 +9368,7 @@ function realSpawn(req) {
9245
9368
  };
9246
9369
  }
9247
9370
  function runOnce(req, spawnFn, timeoutMs, onThreadId) {
9248
- return new Promise((resolve23, reject) => {
9371
+ return new Promise((resolve25, reject) => {
9249
9372
  const events = [];
9250
9373
  let garbageLines = 0;
9251
9374
  let stderr = "";
@@ -9266,7 +9389,7 @@ function runOnce(req, spawnFn, timeoutMs, onThreadId) {
9266
9389
  if (settled || !exited || openStreams > 0) return;
9267
9390
  settled = true;
9268
9391
  clearTimeout(timer);
9269
- resolve23({ exitCode: exited.code, signal: exited.signal, events, garbageLines, stderr });
9392
+ resolve25({ exitCode: exited.code, signal: exited.signal, events, garbageLines, stderr });
9270
9393
  };
9271
9394
  const fail = (err2) => {
9272
9395
  if (settled) return;
@@ -9347,9 +9470,9 @@ async function codexExecSpawn(def, opts, deps = {}) {
9347
9470
  let failure;
9348
9471
  let detail;
9349
9472
  try {
9350
- const run = await runOnce(req, spawnFn, timeoutMs, opts.onThreadId);
9473
+ const run2 = await runOnce(req, spawnFn, timeoutMs, opts.onThreadId);
9351
9474
  const verdict = classifyCodexExec({
9352
- ...run,
9475
+ ...run2,
9353
9476
  lastMessage: await readIfPresent(outPath)
9354
9477
  });
9355
9478
  if (verdict.ok) return toEnvelope(verdict.value);
@@ -10550,7 +10673,10 @@ function pickHostValues(capability, host = "claude") {
10550
10673
  };
10551
10674
  }
10552
10675
  function resolveCapabilityCmd(capability, installedPlugins, installedUserSkills, host = "claude") {
10553
- const { install_type, plugin_id, skill_dir } = capability;
10676
+ const override = capability.by_host?.[host];
10677
+ const install_type = override?.install_type ?? capability.install_type;
10678
+ const skill_dir = override?.skill_dir ?? capability.skill_dir;
10679
+ const { plugin_id } = capability;
10554
10680
  const cmd = pickHostValues(capability, host).cmd ?? capability.cmd;
10555
10681
  if (!install_type) return { renderedCmd: cmd };
10556
10682
  const types = Array.isArray(install_type) ? install_type : [install_type];
@@ -11793,6 +11919,48 @@ var init_nativeTest = __esm({
11793
11919
  UNSAFE_PATH_RE = /[|&;<>()*?"'`$={}[\]]/;
11794
11920
  }
11795
11921
  });
11922
+
11923
+ // src/installers/lib/verificationEnv.ts
11924
+ function verificationEnv(parent, overrides = {}, platform = process.platform) {
11925
+ const normalize2 = (key) => platform === "win32" ? key.toUpperCase() : key;
11926
+ const allowed = new Map(ALLOWED_KEYS.map((key) => [normalize2(key), key]));
11927
+ const env = {};
11928
+ for (const source of [parent, overrides]) {
11929
+ for (const [key, value] of Object.entries(source)) {
11930
+ const canonical = allowed.get(normalize2(key));
11931
+ if (canonical !== void 0 && value !== void 0) env[canonical] = value;
11932
+ }
11933
+ }
11934
+ return env;
11935
+ }
11936
+ var ALLOWED_KEYS;
11937
+ var init_verificationEnv = __esm({
11938
+ "src/installers/lib/verificationEnv.ts"() {
11939
+ ALLOWED_KEYS = [
11940
+ "PATH",
11941
+ "PATHEXT",
11942
+ "COMSPEC",
11943
+ "SystemRoot",
11944
+ "WINDIR",
11945
+ "HOME",
11946
+ "USERPROFILE",
11947
+ "APPDATA",
11948
+ "LOCALAPPDATA",
11949
+ "TEMP",
11950
+ "TMP",
11951
+ "TMPDIR",
11952
+ "CODEX_HOME",
11953
+ "CLAUDE_CONFIG_DIR",
11954
+ "HARNESSED_PLATFORM",
11955
+ "PLAYWRIGHT_BROWSERS_PATH",
11956
+ "MSYS",
11957
+ "CYGWIN",
11958
+ "MSYS2",
11959
+ "MSYS2_ARG_CONV_EXCL",
11960
+ "MSYS_NO_PATHCONV"
11961
+ ];
11962
+ }
11963
+ });
11796
11964
  function expandTildeForWindows(cmd) {
11797
11965
  const home = homedir().replace(/\\/g, "/");
11798
11966
  return cmd.replace(/(^|[\s"'`(])~\//g, `$1${home}/`);
@@ -11825,7 +11993,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
11825
11993
  }
11826
11994
  const installCfg = ctx.manifest.spec.install;
11827
11995
  const effectiveTimeoutMs = timeoutMs ?? DEFAULT_INSTALL_TIMEOUT_MS;
11828
- const env = { ...process.env, ...installCfg.env ?? {} };
11996
+ const env = opts?.envMode === "verify" ? verificationEnv(process.env, installCfg.env) : { ...process.env, ...installCfg.env ?? {} };
11829
11997
  const cwd = installCfg.cwd ?? (opts?.neutralCwd ? getNeutralSpawnCwd() ?? ctx.cwd : ctx.cwd);
11830
11998
  let child;
11831
11999
  let triedBash = false;
@@ -11870,10 +12038,10 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
11870
12038
  child.stderr?.setEncoding("utf8").on("data", (chunk) => {
11871
12039
  stderr += chunk;
11872
12040
  });
11873
- return await new Promise((resolve23) => {
12041
+ return await new Promise((resolve25) => {
11874
12042
  const timer = setTimeout(() => {
11875
12043
  killProcessTree(child);
11876
- resolve23({
12044
+ resolve25({
11877
12045
  ok: false,
11878
12046
  phase: "spawn",
11879
12047
  error: {
@@ -11894,7 +12062,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
11894
12062
  child.on("error", (err2) => {
11895
12063
  clearTimeout(timer);
11896
12064
  const bashMissing = triedBash && err2.code === "ENOENT";
11897
- resolve23({
12065
+ resolve25({
11898
12066
  ok: false,
11899
12067
  phase: "spawn",
11900
12068
  error: {
@@ -11909,7 +12077,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
11909
12077
  });
11910
12078
  child.on("close", (code2) => {
11911
12079
  clearTimeout(timer);
11912
- resolve23({ ok: true, exitCode: code2 ?? -1, stdout: stdout2, stderr });
12080
+ resolve25({ ok: true, exitCode: code2 ?? -1, stdout: stdout2, stderr });
11913
12081
  });
11914
12082
  });
11915
12083
  }
@@ -11921,6 +12089,7 @@ var init_spawn = __esm({
11921
12089
  init_nativeTest();
11922
12090
  init_resolveBash();
11923
12091
  init_safeCwd();
12092
+ init_verificationEnv();
11924
12093
  init_verifyMessage();
11925
12094
  POSIX_SYNTAX_RE = /[|;<>`$~[\]{}()*?!]|&&/;
11926
12095
  POSIX_FIRST_TOKENS = /* @__PURE__ */ new Set([
@@ -11966,13 +12135,19 @@ function extractGitCloneTarget(cmd) {
11966
12135
  if (dest.startsWith("/") || /^[A-Z]:[\\/]/i.test(dest)) return dest;
11967
12136
  return null;
11968
12137
  }
12138
+ function skillProbeDirs() {
12139
+ const platform = detectPlatform();
12140
+ return platform.id === "codex" ? [getSkillsDir(), join(platform.homeDir, "skills")] : harnessSkillsDirs();
12141
+ }
11969
12142
  async function indicatorPresent(name) {
11970
12143
  const indicators = INSTALLED_INDICATORS[name];
11971
12144
  if (!indicators) return false;
11972
- for (const skillsDir of harnessSkillsDirs()) {
12145
+ for (const skillsDir of skillProbeDirs()) {
11973
12146
  for (const ind of indicators) {
11974
12147
  try {
11975
- await access(join(skillsDir, ind));
12148
+ const skillMd = join(skillsDir, ind, "SKILL.md");
12149
+ if (!(await stat(skillMd)).isFile()) continue;
12150
+ await readFile(skillMd, "utf8");
11976
12151
  return true;
11977
12152
  } catch {
11978
12153
  }
@@ -11983,7 +12158,7 @@ async function indicatorPresent(name) {
11983
12158
  async function detectSkillPresence(cmd, name) {
11984
12159
  if (await indicatorPresent(name)) return true;
11985
12160
  const skillName = extractSkillName(cmd, name);
11986
- for (const skillsDir of harnessSkillsDirs()) {
12161
+ for (const skillsDir of skillProbeDirs()) {
11987
12162
  try {
11988
12163
  await access(join(skillsDir, skillName, "SKILL.md"));
11989
12164
  return true;
@@ -12014,7 +12189,7 @@ async function detectNative(ctx) {
12014
12189
  }
12015
12190
  if (method === "npx-skill-installer") {
12016
12191
  const skillName = extractSkillName(cmd, name);
12017
- for (const skillsDir of harnessSkillsDirs()) {
12192
+ for (const skillsDir of skillProbeDirs()) {
12018
12193
  const skillMd = join(skillsDir, skillName, "SKILL.md");
12019
12194
  try {
12020
12195
  await access(skillMd);
@@ -12058,6 +12233,20 @@ async function isAlreadyInstalled(ctx, opts = {}) {
12058
12233
  if (honorUpdateFlag && ctx.opts.updateInstalled === true) return false;
12059
12234
  if (ctx.opts.dryRun) return false;
12060
12235
  const installCfg = ctx.manifest.spec.install;
12236
+ if (installCfg.method === "npm-cli" && (ctx.manifest.spec.component_type === "cli-binary" || extractVerifyBinary(ctx.manifest.spec.verify?.cmd, "") !== null)) {
12237
+ const bin = extractVerifyBinary(
12238
+ ctx.manifest.spec.component_type === "cli-binary" ? void 0 : ctx.manifest.spec.verify?.cmd,
12239
+ ctx.manifest.metadata.name
12240
+ );
12241
+ return bin !== null && binaryOnPath(bin);
12242
+ }
12243
+ if ((installCfg.method === "mcp-stdio-add" || installCfg.method === "mcp-http-add") && detectPlatform().id === "codex") {
12244
+ try {
12245
+ return await isMcpServerRegistered(ctx.manifest.metadata.name);
12246
+ } catch {
12247
+ return false;
12248
+ }
12249
+ }
12061
12250
  if (installCfg.method === "cc-hook-add") {
12062
12251
  if (detectPlatform().id === "codex")
12063
12252
  return isCodexPluginInstalled(codexHookPluginId(ctx.manifest.metadata.name));
@@ -12087,6 +12276,9 @@ async function isAlreadyInstalled(ctx, opts = {}) {
12087
12276
  if (typeof idempotentCmd !== "string" || idempotentCmd.length === 0) {
12088
12277
  return false;
12089
12278
  }
12279
+ if ((installCfg.method === "npx-skill-installer" || Object.hasOwn(INSTALLED_INDICATORS, ctx.manifest.metadata.name)) && detectPlatform().id === "codex" && /\bclaude\b/i.test(idempotentCmd)) {
12280
+ return false;
12281
+ }
12090
12282
  const r = await spawnCmd(ctx, idempotentCmd, [], IDEMPOTENT_CHECK_TIMEOUT_MS);
12091
12283
  if (!("exitCode" in r)) return false;
12092
12284
  return r.exitCode === 0;
@@ -12280,6 +12472,54 @@ ${newEntry}
12280
12472
  };
12281
12473
  }
12282
12474
  });
12475
+ async function repairGstackCodexRuntimeAfterConfirm(options) {
12476
+ const platform = detectPlatform();
12477
+ if (platform.id !== "codex")
12478
+ throw new Error("gstack runtime repair requires the active Codex host");
12479
+ const codexHome = (options.codexHome ?? process.env.CODEX_HOME) || platform.homeDir;
12480
+ if (!isAbsolute(codexHome) || !isAbsolute(options.sourceDir)) {
12481
+ throw new Error("gstack runtime repair requires absolute CODEX_HOME and sourceDir paths");
12482
+ }
12483
+ const runtimeRoot = join(codexHome, "skills", "gstack");
12484
+ const rootEntry = await lstat(runtimeRoot);
12485
+ if (!rootEntry.isDirectory() || rootEntry.isSymbolicLink()) {
12486
+ throw new Error(`gstack runtime root must be an existing real directory: ${runtimeRoot}`);
12487
+ }
12488
+ const source = await realpath(options.sourceDir);
12489
+ const recordedSource = (await readFile(join(runtimeRoot, ".source-path"), "utf8")).trim();
12490
+ if (!isAbsolute(recordedSource) || await realpath(recordedSource) !== source) {
12491
+ throw new Error(`gstack runtime .source-path does not match expected source: ${source}`);
12492
+ }
12493
+ const pkg = JSON.parse(await readFile(join(source, "package.json"), "utf8"));
12494
+ if (pkg.name !== "gstack") throw new Error(`expected a gstack source checkout: ${source}`);
12495
+ const sourceModules = await realpath(join(source, "node_modules"));
12496
+ if (!(await stat(sourceModules)).isDirectory() || !(await stat(join(sourceModules, "playwright"))).isDirectory()) {
12497
+ throw new Error(`gstack source dependencies are unavailable: ${sourceModules}`);
12498
+ }
12499
+ const target = join(runtimeRoot, "node_modules");
12500
+ const entry = await lstat(target).catch((error) => {
12501
+ if (error.code === "ENOENT") return void 0;
12502
+ throw error;
12503
+ });
12504
+ if (entry) {
12505
+ if (entry.isSymbolicLink()) {
12506
+ const actual = await realpath(target).catch(() => null);
12507
+ if (actual !== sourceModules) {
12508
+ throw new Error(`refusing to replace an existing gstack dependency link: ${target}`);
12509
+ }
12510
+ } else if (!entry.isDirectory()) {
12511
+ throw new Error(`refusing to replace an existing gstack dependency entry: ${target}`);
12512
+ }
12513
+ return { status: "unchanged", runtimeRoot };
12514
+ }
12515
+ await symlink(sourceModules, target, process.platform === "win32" ? "junction" : "dir");
12516
+ return { status: "created", runtimeRoot };
12517
+ }
12518
+ var init_gstackRuntime = __esm({
12519
+ "src/installers/lib/gstackRuntime.ts"() {
12520
+ init_platform();
12521
+ }
12522
+ });
12283
12523
  async function snapshotSkillNames(skillsDir = getSkillsDir()) {
12284
12524
  try {
12285
12525
  const entries = await readdir(skillsDir, { withFileTypes: true });
@@ -12349,8 +12589,419 @@ var init_packSkillAudit = __esm({
12349
12589
  workflowNamesCache = null;
12350
12590
  }
12351
12591
  });
12592
+ function shellPath(path) {
12593
+ return process.platform === "win32" ? path.replace(/\\/g, "/") : path;
12594
+ }
12595
+ function touch(binary, lease, source, scratch) {
12596
+ const env = {};
12597
+ for (const key of [
12598
+ "PATH",
12599
+ "SystemRoot",
12600
+ "WINDIR",
12601
+ "HOME",
12602
+ "USERPROFILE",
12603
+ "TEMP",
12604
+ "TMP",
12605
+ "MSYS",
12606
+ "MSYS2",
12607
+ "CYGWIN"
12608
+ ]) {
12609
+ if (process.env[key] !== void 0) env[key] = process.env[key];
12610
+ }
12611
+ env.GSTACK_LEASE_DIR = shellPath(scratch);
12612
+ env.GSTACK_LEASE_LOCK_TRIES = "1";
12613
+ return new Promise((resolve25, reject) => {
12614
+ const child = execFile(
12615
+ binary,
12616
+ [
12617
+ "--noprofile",
12618
+ "--norc",
12619
+ "-c",
12620
+ 'exec "$BASH" --noprofile --norc "$1" touch --root "$2" --pid "$$"',
12621
+ "harnessed-gstack-lease",
12622
+ shellPath(lease),
12623
+ shellPath(source)
12624
+ ],
12625
+ {
12626
+ cwd: source,
12627
+ env,
12628
+ shell: false,
12629
+ windowsHide: true,
12630
+ timeout: TIMEOUT_MS,
12631
+ killSignal: "SIGKILL",
12632
+ maxBuffer: 64 * 1024,
12633
+ encoding: "utf8"
12634
+ },
12635
+ (error, _stdout, stderr) => {
12636
+ if (error)
12637
+ reject(
12638
+ new Error(
12639
+ `official lease touch exit ${error.code ?? "unknown"}${error.killed ? " (timeout or termination)" : ""}: ${stderr.trim() || error.message}`
12640
+ )
12641
+ );
12642
+ else resolve25();
12643
+ }
12644
+ );
12645
+ child.stdin?.end();
12646
+ });
12647
+ }
12648
+ async function cleanupScratch(scratch, source) {
12649
+ const owned = await realpath(scratch);
12650
+ if (dirname(owned) !== source || !basename(owned).startsWith(SCRATCH_PREFIX) || (await lstat(scratch)).isSymbolicLink()) {
12651
+ throw new Error("refusing cleanup outside the owned source-checkout scratch");
12652
+ }
12653
+ await rm(scratch, { recursive: true, force: true });
12654
+ }
12655
+ async function verifyGstackLease(ctx) {
12656
+ if (ctx.opts.dryRun || ctx.manifest.metadata.name !== "gstack") return null;
12657
+ const platform = detectPlatform();
12658
+ if (platform.id !== "codex") return null;
12659
+ let scratch;
12660
+ let source;
12661
+ let problem;
12662
+ try {
12663
+ const home = (ctx.manifest.spec.install.env?.CODEX_HOME ?? process.env.CODEX_HOME) || platform.homeDir;
12664
+ if (!isAbsolute(home)) throw new Error("CODEX_HOME must be absolute");
12665
+ const runtime = await realpath(join(home, "skills", "gstack"));
12666
+ const lease = join(runtime, "bin", "gstack-lease");
12667
+ const script = await stat(lease);
12668
+ if (!script.isFile() || script.size === 0)
12669
+ throw new Error(`missing installed lease script: ${lease}`);
12670
+ const recordedSource = await readFile(join(runtime, ".source-path"), "utf8").catch(
12671
+ (error) => {
12672
+ if (error.code === "ENOENT") return runtime;
12673
+ throw error;
12674
+ }
12675
+ );
12676
+ if (!isAbsolute(recordedSource.trim())) throw new Error("gstack .source-path must be absolute");
12677
+ source = await realpath(recordedSource.trim());
12678
+ const bash = process.platform === "win32" ? resolveBash().path : "bash";
12679
+ if (!bash) throw new Error("a usable Git Bash is required");
12680
+ scratch = await mkdtemp(join(source, SCRATCH_PREFIX));
12681
+ await touch(bash, lease, source, scratch);
12682
+ const entries = await readdir(scratch);
12683
+ const record = entries[0];
12684
+ if (entries.length !== 1 || !record || !/^\d+$/.test(record) || !(await lstat(join(scratch, record))).isFile()) {
12685
+ throw new Error(
12686
+ "official touch did not publish exactly one lease record and release its locks"
12687
+ );
12688
+ }
12689
+ } catch (error) {
12690
+ problem = error instanceof Error ? error.message : String(error);
12691
+ } finally {
12692
+ if (scratch) {
12693
+ try {
12694
+ await cleanupScratch(scratch, source);
12695
+ } catch (error) {
12696
+ problem = `${problem ? `${problem}; ` : ""}scratch cleanup failed: ${String(error)}`;
12697
+ }
12698
+ }
12699
+ }
12700
+ if (!problem) return null;
12701
+ return {
12702
+ ok: false,
12703
+ phase: "verify",
12704
+ error: {
12705
+ ...err(
12706
+ ctx,
12707
+ "/spec/verify/cmd",
12708
+ `gstack Codex lease readiness unavailable (owned scratch: ${scratch ?? "not created"}): ${problem}. Lock-primitive failure in a fresh scratch does not prove live-process contention. Upstream blocker; native security and shared user leases were not changed.`,
12709
+ "upstream-lease-unavailable"
12710
+ ),
12711
+ suggest: "Wait for an upstream lease compatibility fix and rerun verification. Do not bypass locking, change native symlink security, or treat skill-start exit 0 as lease readiness."
12712
+ }
12713
+ };
12714
+ }
12715
+ var SCRATCH_PREFIX, TIMEOUT_MS;
12716
+ var init_gstackLease = __esm({
12717
+ "src/installers/lib/gstackLease.ts"() {
12718
+ init_platform();
12719
+ init_err();
12720
+ init_resolveBash();
12721
+ SCRATCH_PREFIX = ".harnessed-gstack-lease-";
12722
+ TIMEOUT_MS = 1e4;
12723
+ }
12724
+ });
12725
+ async function requireFile(path) {
12726
+ try {
12727
+ const info = await stat(path);
12728
+ if (!info.isFile() || info.size === 0) throw new Error("not a nonempty file");
12729
+ await access(path, constants.R_OK);
12730
+ } catch {
12731
+ throw new Error(`Required installed resource is missing, empty or unreadable: ${path}`);
12732
+ }
12733
+ }
12734
+ async function skillRoot(dirs, name) {
12735
+ for (const dir of dirs) {
12736
+ const root = join(dir, name);
12737
+ try {
12738
+ await stat(join(root, "SKILL.md"));
12739
+ } catch {
12740
+ continue;
12741
+ }
12742
+ await requireFile(join(root, "SKILL.md"));
12743
+ return root;
12744
+ }
12745
+ throw new Error(`Required installed skill is missing: ${name} (${dirs.join(", ")})`);
12746
+ }
12747
+ async function verifyGsd(root, dirs, codex, cwd) {
12748
+ await skillRoot(dirs, "gsd-plan-phase");
12749
+ for (const phase of ["discuss-phase", "plan-phase", "execute-phase", "verify-work", "progress"]) {
12750
+ await requireFile(join(root, "gsd-core", "workflows", `${phase}.md`));
12751
+ }
12752
+ await requireFile(join(root, "gsd-core", "bin", "gsd-tools.cjs"));
12753
+ await requireFile(join(root, "gsd-core", "references", "ui-brand.md"));
12754
+ for (const role of ["phase-researcher", "planner", "plan-checker", "executor", "verifier"]) {
12755
+ await requireFile(join(root, "agents", `gsd-${role}.${codex ? "toml" : "md"}`));
12756
+ }
12757
+ const script = join(root, "gsd-core", "bin", "gsd-tools.cjs");
12758
+ const output = await run("node", [script, "runtime-identity"], cwd);
12759
+ let identity;
12760
+ try {
12761
+ identity = JSON.parse(output);
12762
+ } catch {
12763
+ throw new Error(`GSD runtime-identity did not return JSON: ${script}`);
12764
+ }
12765
+ if (identity?.packageName !== "@opengsd/gsd-core" || typeof identity.version !== "string" || !identity.version.trim()) {
12766
+ throw new Error(
12767
+ `GSD runtime-identity did not prove @opengsd/gsd-core with a version: ${script}`
12768
+ );
12769
+ }
12770
+ }
12771
+ function run(binary, args, cwd) {
12772
+ return new Promise((resolveOutput, reject) => {
12773
+ const child = execFile(
12774
+ binary,
12775
+ args,
12776
+ {
12777
+ cwd,
12778
+ shell: false,
12779
+ windowsHide: true,
12780
+ timeout: 5e3,
12781
+ maxBuffer: 256 * 1024,
12782
+ encoding: "utf8",
12783
+ // Probes need an interpreter, not the host's provider credentials or Python startup hooks.
12784
+ env: {
12785
+ PATH: process.env.PATH,
12786
+ SystemRoot: process.env.SystemRoot,
12787
+ WINDIR: process.env.WINDIR,
12788
+ TEMP: process.env.TEMP,
12789
+ TMP: process.env.TMP,
12790
+ PYTHONDONTWRITEBYTECODE: "1",
12791
+ PYTHONIOENCODING: "utf-8",
12792
+ PYTHONUTF8: "1"
12793
+ }
12794
+ },
12795
+ (error, stdout2, stderr) => {
12796
+ if (error)
12797
+ reject(new Error(`Runtime command failed (${binary}): ${stderr.trim() || error.message}`));
12798
+ else resolveOutput(stdout2);
12799
+ }
12800
+ );
12801
+ child.stdin?.end();
12802
+ });
12803
+ }
12804
+ async function python(cwd) {
12805
+ const probe = 'import sys; assert sys.version_info >= (3, 8); print("HARNESSED_PYTHON_OK")';
12806
+ for (const [binary, prefix] of [
12807
+ ["python3", []],
12808
+ ["python", []],
12809
+ ["py", ["-3"]]
12810
+ ]) {
12811
+ const args = [...prefix, "-B", "-S"];
12812
+ try {
12813
+ if ((await run(binary, [...args, "-I", "-c", probe], cwd)).trim() === "HARNESSED_PYTHON_OK") {
12814
+ return { binary, args };
12815
+ }
12816
+ } catch {
12817
+ }
12818
+ }
12819
+ throw new Error(
12820
+ "Python 3.8+ is required for this installed skill; no usable python3, python or py -3 was found"
12821
+ );
12822
+ }
12823
+ async function verifyPlanning(root, cwd) {
12824
+ const script = join(root, "scripts", "session-catchup.py");
12825
+ await requireFile(script);
12826
+ for (const name of ["init-session", "check-complete"]) {
12827
+ await requireFile(
12828
+ join(root, "scripts", `${name}.${process.platform === "win32" ? "ps1" : "sh"}`)
12829
+ );
12830
+ }
12831
+ for (const name of ["task_plan", "progress", "findings"]) {
12832
+ await requireFile(join(root, "templates", `${name}.md`));
12833
+ }
12834
+ const py = await python(cwd);
12835
+ await run(
12836
+ py.binary,
12837
+ [
12838
+ ...py.args,
12839
+ "-I",
12840
+ "-c",
12841
+ 'import ast, pathlib, sys; ast.parse(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8-sig"))',
12842
+ script
12843
+ ],
12844
+ cwd
12845
+ );
12846
+ }
12847
+ async function verifyUi(root, cwd) {
12848
+ const script = join(root, "scripts", "search.py");
12849
+ await requireFile(script);
12850
+ await requireFile(join(root, "scripts", "core.py"));
12851
+ const data = [
12852
+ "styles",
12853
+ "prompts",
12854
+ "colors",
12855
+ "charts",
12856
+ "landing",
12857
+ "products",
12858
+ "ux-guidelines",
12859
+ "typography",
12860
+ "stacks/html-tailwind"
12861
+ ].map((name) => join(root, "data", `${name}.csv`));
12862
+ for (const path of data) await requireFile(path);
12863
+ const py = await python(cwd);
12864
+ await run(
12865
+ py.binary,
12866
+ [
12867
+ ...py.args,
12868
+ "-I",
12869
+ "-c",
12870
+ [
12871
+ "import csv, sys",
12872
+ "for path in sys.argv[1:]:",
12873
+ ' with open(path, encoding="utf-8-sig", newline="") as source:',
12874
+ " rows = csv.DictReader(source)",
12875
+ ' assert rows.fieldnames and next(rows, None), "No data rows: " + path'
12876
+ ].join("\n"),
12877
+ ...data
12878
+ ],
12879
+ cwd
12880
+ );
12881
+ for (const mode of [
12882
+ ["--domain", "style"],
12883
+ ["--stack", "html-tailwind"]
12884
+ ]) {
12885
+ const query2 = mode[0] === "--stack" ? "responsive" : "dashboard";
12886
+ const output = await run(
12887
+ py.binary,
12888
+ [...py.args, script, query2, ...mode, "--json", "--max-results", "1"],
12889
+ cwd
12890
+ );
12891
+ let result;
12892
+ try {
12893
+ result = JSON.parse(output);
12894
+ } catch {
12895
+ throw new Error(`UI helper did not return JSON search results: ${script}`);
12896
+ }
12897
+ if (!result || result.error || typeof result.count !== "number" || result.count < 1 || !Array.isArray(result.results) || result.results.length < 1 || !result.results.every(
12898
+ (row) => row !== null && typeof row === "object" && !Array.isArray(row) && Object.values(row).some((value) => typeof value === "string" && value.trim().length > 0)
12899
+ )) {
12900
+ throw new Error(`UI helper returned no usable search results (${mode.join(" ")}): ${script}`);
12901
+ }
12902
+ }
12903
+ }
12904
+ async function verifySkillRuntime(ctx) {
12905
+ const name = ctx.manifest.metadata.name;
12906
+ if (ctx.opts.dryRun || !["gsd", "planning-with-files", "ui-ux-pro-max"].includes(name))
12907
+ return null;
12908
+ const platform = detectPlatform();
12909
+ if (platform.id !== "codex" && platform.id !== "claude") return null;
12910
+ const codex = platform.id === "codex";
12911
+ if (!codex && name !== "gsd") return null;
12912
+ const rootKey = codex ? "CODEX_HOME" : "CLAUDE_CONFIG_DIR";
12913
+ const configuredRoot = ctx.manifest.spec.install.env?.[rootKey] ?? process.env[rootKey];
12914
+ const root = resolve(configuredRoot || platform.homeDir);
12915
+ const dirs = [.../* @__PURE__ */ new Set([platform.skillsDir, join(root, "skills")])];
12916
+ try {
12917
+ if (name === "gsd") await verifyGsd(root, dirs, codex, ctx.cwd);
12918
+ else {
12919
+ const installedRoot = await skillRoot(dirs, name);
12920
+ if (name === "planning-with-files") await verifyPlanning(installedRoot, ctx.cwd);
12921
+ else await verifyUi(installedRoot, ctx.cwd);
12922
+ }
12923
+ return null;
12924
+ } catch (error) {
12925
+ return {
12926
+ ok: false,
12927
+ phase: "verify",
12928
+ error: err(ctx, "/spec/verify/cmd", error.message, "skill-runtime-incomplete")
12929
+ };
12930
+ }
12931
+ }
12932
+ var init_skillRuntime = __esm({
12933
+ "src/installers/lib/skillRuntime.ts"() {
12934
+ init_platform();
12935
+ init_err();
12936
+ }
12937
+ });
12938
+
12939
+ // src/installers/lib/verifyInstalled.ts
12940
+ var verifyInstalled_exports = {};
12941
+ __export(verifyInstalled_exports, {
12942
+ verifyInstalled: () => verifyInstalled
12943
+ });
12944
+ async function verifyInstalled(ctx, opts = {}) {
12945
+ const verify = ctx.manifest.spec.verify;
12946
+ const result = await spawnCmd(
12947
+ ctx,
12948
+ verify.cmd,
12949
+ [],
12950
+ verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS,
12951
+ {
12952
+ posixShell: true,
12953
+ ...opts,
12954
+ envMode: "verify"
12955
+ }
12956
+ );
12957
+ const install = ctx.manifest.spec.install;
12958
+ const systemFlag = install.method === "npm-cli" && !/\bnpx\b/.test(install.cmd) ? " --system" : "";
12959
+ const suggest = `Repair the existing installation or PATH, then rerun \`${verify.cmd}\`; or explicitly reinstall with \`harnessed setup --update-installed${systemFlag}\`. No automatic repair was attempted.`;
12960
+ if (!("exitCode" in result)) {
12961
+ if (!("error" in result)) return result;
12962
+ return {
12963
+ ...result,
12964
+ phase: result.phase === "preflight" ? "preflight" : "verify",
12965
+ error: {
12966
+ ...result.error,
12967
+ path: "/spec/verify/cmd",
12968
+ message: `verify failed (cmd: ${verify.cmd}): ${result.error.message}`,
12969
+ suggest
12970
+ }
12971
+ };
12972
+ }
12973
+ const expected = verify.expected_exit_code ?? 0;
12974
+ if (result.exitCode === expected) {
12975
+ const leaseFailure = await verifyGstackLease(ctx);
12976
+ if (leaseFailure) return leaseFailure;
12977
+ const runtime = await verifySkillRuntime(ctx);
12978
+ return runtime && "error" in runtime ? { ...runtime, error: { ...runtime.error, suggest: runtime.error.suggest ?? suggest } } : runtime;
12979
+ }
12980
+ return {
12981
+ ok: false,
12982
+ phase: "verify",
12983
+ error: {
12984
+ ...err(
12985
+ ctx,
12986
+ "/spec/verify/cmd",
12987
+ formatVerifyFail(verify.cmd, result.exitCode, expected, result.stdout, result.stderr),
12988
+ "verify-failed"
12989
+ ),
12990
+ suggest
12991
+ }
12992
+ };
12993
+ }
12994
+ var init_verifyInstalled = __esm({
12995
+ "src/installers/lib/verifyInstalled.ts"() {
12996
+ init_err();
12997
+ init_gstackLease();
12998
+ init_skillRuntime();
12999
+ init_spawn();
13000
+ init_verifyMessage();
13001
+ }
13002
+ });
12352
13003
  function gitRevParseHead(cwd, timeoutMs = 1e4) {
12353
- return new Promise((resolve23) => {
13004
+ return new Promise((resolve25) => {
12354
13005
  const isWin = process.platform === "win32";
12355
13006
  const child = isWin ? spawn("cmd.exe", ["/c", "git", "rev-parse", "HEAD"], { cwd, windowsHide: true }) : spawn("git", ["rev-parse", "HEAD"], { cwd, shell: false });
12356
13007
  let stdout2 = "";
@@ -12359,15 +13010,15 @@ function gitRevParseHead(cwd, timeoutMs = 1e4) {
12359
13010
  });
12360
13011
  const timer = setTimeout(() => {
12361
13012
  killProcessTree(child);
12362
- resolve23({ sha: "", exit: -1 });
13013
+ resolve25({ sha: "", exit: -1 });
12363
13014
  }, timeoutMs);
12364
13015
  child.on("error", () => {
12365
13016
  clearTimeout(timer);
12366
- resolve23({ sha: "", exit: -1 });
13017
+ resolve25({ sha: "", exit: -1 });
12367
13018
  });
12368
13019
  child.on("close", (code2) => {
12369
13020
  clearTimeout(timer);
12370
- resolve23({ sha: stdout2.trim(), exit: code2 ?? -1 });
13021
+ resolve25({ sha: stdout2.trim(), exit: code2 ?? -1 });
12371
13022
  });
12372
13023
  });
12373
13024
  }
@@ -12400,17 +13051,20 @@ function isSelfCleaningCloneCmd(cmd) {
12400
13051
  var installGitCloneWithSetup;
12401
13052
  var init_gitCloneWithSetup2 = __esm({
12402
13053
  "src/installers/gitCloneWithSetup.ts"() {
13054
+ init_platform();
12403
13055
  init_backup();
12404
13056
  init_confirm();
12405
13057
  init_diff();
12406
13058
  init_err();
12407
13059
  init_gitCloneArgs();
13060
+ init_gstackRuntime();
12408
13061
  init_idempotent();
12409
13062
  init_killTree();
12410
13063
  init_packSkillAudit();
12411
13064
  init_preflight();
12412
13065
  init_spawn();
12413
13066
  init_state2();
13067
+ init_verifyInstalled();
12414
13068
  init_verifyMessage();
12415
13069
  installGitCloneWithSetup = async (ctx) => {
12416
13070
  const install = ctx.manifest.spec.install;
@@ -12433,10 +13087,6 @@ var init_gitCloneWithSetup2 = __esm({
12433
13087
  const e = pre.errors[0] ?? err(ctx, "/", "preflight failed (no detail)", "preflight");
12434
13088
  return { ok: false, phase: "preflight", error: e };
12435
13089
  }
12436
- if (await isAlreadyInstalled(ctx)) {
12437
- await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
12438
- return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
12439
- }
12440
13090
  if (!/^[a-f0-9]{7,40}$/.test(install.git_ref)) {
12441
13091
  return {
12442
13092
  ok: false,
@@ -12468,6 +13118,12 @@ var init_gitCloneWithSetup2 = __esm({
12468
13118
  }
12469
13119
  };
12470
13120
  }
13121
+ if (await isAlreadyInstalled(ctx)) {
13122
+ const verifyFailure2 = await verifyInstalled(ctx);
13123
+ if (verifyFailure2) return verifyFailure2;
13124
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
13125
+ return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
13126
+ }
12471
13127
  const name = ctx.manifest.metadata.name;
12472
13128
  const plan = {
12473
13129
  files: [
@@ -12533,26 +13189,33 @@ var init_gitCloneWithSetup2 = __esm({
12533
13189
  };
12534
13190
  }
12535
13191
  }
12536
- const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
12537
- const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
12538
- posixShell: true
12539
- });
12540
- if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
12541
- const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
12542
- if (vr.exitCode !== expected) {
12543
- return {
12544
- ok: false,
12545
- phase: "verify",
12546
- backupId: bk.backupId,
12547
- error: err(
12548
- ctx,
12549
- "/spec/verify/cmd",
12550
- // v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
12551
- formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
12552
- "verify-failed"
12553
- )
12554
- };
13192
+ if (name === "gstack" && detectPlatform().id === "codex") {
13193
+ try {
13194
+ await repairGstackCodexRuntimeAfterConfirm({
13195
+ host: "codex",
13196
+ sourceDir: resolve(install.cwd ?? ctx.cwd, cloneTarget),
13197
+ codexHome: install.env?.CODEX_HOME,
13198
+ confirmed: true
13199
+ });
13200
+ } catch (error) {
13201
+ return {
13202
+ ok: false,
13203
+ phase: "verify",
13204
+ backupId: bk.backupId,
13205
+ error: {
13206
+ ...err(
13207
+ ctx,
13208
+ "/spec/verify/cmd",
13209
+ `gstack runtime repair failed: ${error.message}`,
13210
+ "verify-failed"
13211
+ ),
13212
+ suggest: "Repair the gstack source dependencies, then explicitly rerun `harnessed setup --update-installed`."
13213
+ }
13214
+ };
13215
+ }
12555
13216
  }
13217
+ const verifyFailure = await verifyInstalled(ctx);
13218
+ if (verifyFailure) return { ...verifyFailure, backupId: bk.backupId };
12556
13219
  await updateInstalled(ctx.cwd, name, install.git_ref, "");
12557
13220
  return { ok: true, backupId: bk.backupId, appliedFiles: [cloneTarget] };
12558
13221
  };
@@ -12944,6 +13607,7 @@ var init_npmCli2 = __esm({
12944
13607
  init_preflight();
12945
13608
  init_spawn();
12946
13609
  init_state2();
13610
+ init_verifyInstalled();
12947
13611
  init_verifyMessage();
12948
13612
  installNpmCli = async (ctx) => {
12949
13613
  const install = ctx.manifest.spec.install;
@@ -12967,6 +13631,8 @@ var init_npmCli2 = __esm({
12967
13631
  return { ok: false, phase: "preflight", error: e };
12968
13632
  }
12969
13633
  if (await isAlreadyInstalled(ctx)) {
13634
+ const verifyFailure2 = await verifyInstalled(ctx, { neutralCwd: true });
13635
+ if (verifyFailure2) return verifyFailure2;
12970
13636
  await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
12971
13637
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
12972
13638
  }
@@ -13023,27 +13689,8 @@ var init_npmCli2 = __esm({
13023
13689
  };
13024
13690
  }
13025
13691
  await auditPostInstall(ctx, packSnapshot);
13026
- const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
13027
- const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
13028
- posixShell: true,
13029
- neutralCwd: true
13030
- });
13031
- if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
13032
- const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
13033
- if (vr.exitCode !== expected) {
13034
- return {
13035
- ok: false,
13036
- phase: "verify",
13037
- backupId: bk.backupId,
13038
- error: err(
13039
- ctx,
13040
- "/spec/verify/cmd",
13041
- // v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
13042
- formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
13043
- "verify-failed"
13044
- )
13045
- };
13046
- }
13692
+ const verifyFailure = await verifyInstalled(ctx, { neutralCwd: true });
13693
+ if (verifyFailure) return { ...verifyFailure, backupId: bk.backupId };
13047
13694
  await updateInstalled(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
13048
13695
  return { ok: true, backupId: bk.backupId, appliedFiles: [] };
13049
13696
  };
@@ -13062,6 +13709,7 @@ var init_npxSkillInstaller2 = __esm({
13062
13709
  init_preflight();
13063
13710
  init_spawn();
13064
13711
  init_state2();
13712
+ init_verifyInstalled();
13065
13713
  init_verifyMessage();
13066
13714
  HARD_CRASH_EXITS = /* @__PURE__ */ new Set([3221226505, 3221225477]);
13067
13715
  HARD_CRASH_RETRY_DELAY_MS = 500;
@@ -13086,10 +13734,6 @@ var init_npxSkillInstaller2 = __esm({
13086
13734
  const e = pre.errors[0] ?? err(ctx, "/", "preflight failed (no detail)", "preflight");
13087
13735
  return { ok: false, phase: "preflight", error: e };
13088
13736
  }
13089
- if (await isAlreadyInstalled(ctx)) {
13090
- await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
13091
- return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
13092
- }
13093
13737
  if (!/\B--copy\b/.test(install.cmd)) {
13094
13738
  return {
13095
13739
  ok: false,
@@ -13105,6 +13749,12 @@ var init_npxSkillInstaller2 = __esm({
13105
13749
  }
13106
13750
  };
13107
13751
  }
13752
+ if (await isAlreadyInstalled(ctx)) {
13753
+ const verifyFailure2 = await verifyInstalled(ctx, { neutralCwd: true });
13754
+ if (verifyFailure2) return verifyFailure2;
13755
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
13756
+ return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
13757
+ }
13108
13758
  const AGENT_BY_PLATFORM = {
13109
13759
  claude: "claude-code",
13110
13760
  codex: "codex"
@@ -13178,27 +13828,8 @@ var init_npxSkillInstaller2 = __esm({
13178
13828
  }
13179
13829
  };
13180
13830
  }
13181
- const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
13182
- const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
13183
- posixShell: true,
13184
- neutralCwd: true
13185
- });
13186
- if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
13187
- const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
13188
- if (vr.exitCode !== expected) {
13189
- return {
13190
- ok: false,
13191
- phase: "verify",
13192
- backupId: bk.backupId,
13193
- error: err(
13194
- ctx,
13195
- "/spec/verify/cmd",
13196
- // v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
13197
- formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
13198
- "verify-failed"
13199
- )
13200
- };
13201
- }
13831
+ const verifyFailure = await verifyInstalled(ctx, { neutralCwd: true });
13832
+ if (verifyFailure) return { ...verifyFailure, backupId: bk.backupId };
13202
13833
  await updateInstalled(ctx.cwd, name, install.npm_version, "");
13203
13834
  return { ok: true, backupId: bk.backupId, appliedFiles: [skillMdPath] };
13204
13835
  };
@@ -13206,6 +13837,12 @@ var init_npxSkillInstaller2 = __esm({
13206
13837
  });
13207
13838
 
13208
13839
  // src/installers/index.ts
13840
+ var installers_exports = {};
13841
+ __export(installers_exports, {
13842
+ installers: () => installers,
13843
+ resolveForHarness: () => resolveForHarness,
13844
+ runInstall: () => runInstall
13845
+ });
13209
13846
  function levelOf(manifest) {
13210
13847
  const method = manifest.spec.install.method;
13211
13848
  switch (method) {
@@ -14734,9 +15371,9 @@ function realSelfUpdateDeps() {
14734
15371
  return res.text();
14735
15372
  },
14736
15373
  smoke: async (bin) => {
14737
- const { execFile: execFile3 } = await import('child_process');
15374
+ const { execFile: execFile5 } = await import('child_process');
14738
15375
  const { promisify: promisify4 } = await import('util');
14739
- const { stdout: stdout2 } = await promisify4(execFile3)(bin, ["--version"], {
15376
+ const { stdout: stdout2 } = await promisify4(execFile5)(bin, ["--version"], {
14740
15377
  timeout: 3e4,
14741
15378
  windowsHide: true
14742
15379
  });
@@ -15090,7 +15727,7 @@ function renderHumanTable(records) {
15090
15727
  }
15091
15728
  }
15092
15729
  function pipeToJq(filterExpr, lines) {
15093
- return new Promise((resolve23, reject) => {
15730
+ return new Promise((resolve25, reject) => {
15094
15731
  const child = spawn("jq", [filterExpr], {
15095
15732
  stdio: ["pipe", "inherit", "inherit"],
15096
15733
  windowsHide: true
@@ -15099,12 +15736,12 @@ function pipeToJq(filterExpr, lines) {
15099
15736
  const e = err2;
15100
15737
  if (e.code === "ENOENT") {
15101
15738
  console.error(t("audit_log.jq_missing"));
15102
- resolve23(1);
15739
+ resolve25(1);
15103
15740
  } else {
15104
15741
  reject(err2);
15105
15742
  }
15106
15743
  });
15107
- child.on("close", (code2) => resolve23(code2 ?? 0));
15744
+ child.on("close", (code2) => resolve25(code2 ?? 0));
15108
15745
  child.stdin.on("error", (err2) => {
15109
15746
  if (err2.code !== "EPIPE") reject(err2);
15110
15747
  });
@@ -16278,14 +16915,14 @@ init_judgmentResolver();
16278
16915
  init_gates();
16279
16916
  init_probe_chrome_devtools();
16280
16917
  var VALID_MASTERS2 = new Set(GATE_MASTERS);
16281
- function deriveGitFacts(run) {
16918
+ function deriveGitFacts(run2) {
16282
16919
  let lines = 0;
16283
16920
  let sawNumstat = false;
16284
16921
  for (const args of [
16285
16922
  ["diff", "--numstat"],
16286
16923
  ["diff", "--cached", "--numstat"]
16287
16924
  ]) {
16288
- const out = run(args);
16925
+ const out = run2(args);
16289
16926
  if (out === null) continue;
16290
16927
  sawNumstat = true;
16291
16928
  for (const row of out.split(/\r?\n/)) {
@@ -16299,7 +16936,7 @@ function deriveGitFacts(run) {
16299
16936
  ["diff", "--name-only"],
16300
16937
  ["diff", "--cached", "--name-only"]
16301
16938
  ]) {
16302
- const out = run(args);
16939
+ const out = run2(args);
16303
16940
  if (out === null) continue;
16304
16941
  sawNames = true;
16305
16942
  for (const row of out.split(/\r?\n/)) {
@@ -16331,8 +16968,8 @@ function onOrchestrationSurface(path) {
16331
16968
  if (/^workflows\/.+\/SKILL(\.[A-Za-z-]+)?\.md$/.test(p8)) return true;
16332
16969
  return ORCHESTRATION_SURFACE.some((s) => s.endsWith("/") ? p8.startsWith(s) : p8 === s);
16333
16970
  }
16334
- function deriveSecondOpinion(run) {
16335
- const tagOut = run(["describe", "--tags", "--abbrev=0"]);
16971
+ function deriveSecondOpinion(run2) {
16972
+ const tagOut = run2(["describe", "--tags", "--abbrev=0"]);
16336
16973
  const tag = tagOut === null ? null : tagOut.trim();
16337
16974
  if (!tag) {
16338
16975
  return {
@@ -16340,7 +16977,7 @@ function deriveSecondOpinion(run) {
16340
16977
  reason: "no release tag found (git describe --tags failed or the repo has no tags)"
16341
16978
  };
16342
16979
  }
16343
- const diff = run(["diff", "--name-only", tag]);
16980
+ const diff = run2(["diff", "--name-only", tag]);
16344
16981
  if (diff === null) {
16345
16982
  return { fires: false, reason: `git diff --name-only ${tag} failed` };
16346
16983
  }
@@ -16903,14 +17540,14 @@ var QA = [
16903
17540
  { q: "\u2463 \u662F import \u6982\u5FF5 (\u53EF\u63A7) \u8FD8\u662F import \u522B\u4EBA\u4EA7\u54C1\u8EAB\u4EFD (\u9AD8\u8026\u5408)?", f: "q4_concept_vs_identity" },
16904
17541
  { q: "\u2464 user \u4E0D\u77E5 upstream \u8FD8\u80FD\u7406\u89E3\u8BE5\u88C5\u914D\u5417?", f: "q5_user_understanding" }
16905
17542
  ];
16906
- function basename2(upstream) {
17543
+ function basename3(upstream) {
16907
17544
  return (upstream.split("/").pop() ?? upstream).replace(/\.git$/, "");
16908
17545
  }
16909
17546
  function registerManifestAdd(program2) {
16910
17547
  program2.command("manifest-add <upstream>").description(
16911
17548
  "Add a new upstream adapter (EE-5 5-question merge gate; immediate by default \u2014 use --dry-run for preview)"
16912
17549
  ).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) => {
16913
- const name = raw.name ?? basename2(upstream);
17550
+ const name = raw.name ?? basename3(upstream);
16914
17551
  const category = raw.category ?? "skill-packs";
16915
17552
  try {
16916
17553
  checkSafeSegment(category);
@@ -18113,7 +18750,7 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
18113
18750
  const opts = {
18114
18751
  apply: true,
18115
18752
  dryRun: false,
18116
- system: false,
18753
+ system: runOpts.system === true,
18117
18754
  nonInteractive: true,
18118
18755
  fullDiff: false,
18119
18756
  color: "auto",
@@ -18234,7 +18871,11 @@ async function makeIdempotentProbe(manifestPaths) {
18234
18871
  try {
18235
18872
  const yamlSrc = await readFile(path, "utf8");
18236
18873
  const v = validateManifestFile(yamlSrc, path);
18237
- if (v.ok) byName.set(v.manifest.metadata.name, v.manifest);
18874
+ if (v.ok) {
18875
+ const { resolveForHarness: resolveForHarness2 } = await Promise.resolve().then(() => (init_installers(), installers_exports));
18876
+ const resolved = resolveForHarness2(v.manifest);
18877
+ if (!resolved.gate) byName.set(resolved.manifest.metadata.name, resolved.manifest);
18878
+ }
18238
18879
  } catch {
18239
18880
  }
18240
18881
  }
@@ -18253,7 +18894,9 @@ async function makeIdempotentProbe(manifestPaths) {
18253
18894
  };
18254
18895
  const ctx = { manifest, opts, level: "L2", cwd: process.cwd() };
18255
18896
  try {
18256
- return await isAlreadyInstalled(ctx);
18897
+ if (!await isAlreadyInstalled(ctx)) return false;
18898
+ const { verifyInstalled: verifyInstalled2 } = await Promise.resolve().then(() => (init_verifyInstalled(), verifyInstalled_exports));
18899
+ return await verifyInstalled2(ctx) === null;
18257
18900
  } catch {
18258
18901
  return false;
18259
18902
  }
@@ -18335,6 +18978,31 @@ async function listBaseManifests2(pkgRoot) {
18335
18978
  }
18336
18979
  return out;
18337
18980
  }
18981
+ function mergeStepBResults(first, next) {
18982
+ const failureName = (failure) => failure.split(": ", 1)[0] ?? failure;
18983
+ const known = /* @__PURE__ */ new Set([
18984
+ ...first.installed,
18985
+ ...first.alreadyInstalled,
18986
+ ...first.skipped.map((entry) => entry.name),
18987
+ ...first.failed.map(failureName),
18988
+ ...(first.keptExisting ?? []).map((entry) => entry.name)
18989
+ ]);
18990
+ const skipped = next.skipped.filter((entry) => !known.has(entry.name));
18991
+ const replaced = /* @__PURE__ */ new Set([
18992
+ ...next.installed,
18993
+ ...next.alreadyInstalled,
18994
+ ...next.failed.map(failureName),
18995
+ ...(next.keptExisting ?? []).map((entry) => entry.name),
18996
+ ...skipped.map((entry) => entry.name)
18997
+ ]);
18998
+ first.installed = first.installed.filter((name) => !replaced.has(name)).concat(next.installed);
18999
+ first.alreadyInstalled = first.alreadyInstalled.filter((name) => !replaced.has(name)).concat(next.alreadyInstalled);
19000
+ first.failed = first.failed.filter((entry) => !replaced.has(failureName(entry))).concat(next.failed);
19001
+ first.skipped = first.skipped.filter((entry) => !replaced.has(entry.name)).concat(skipped);
19002
+ first.keptExisting = (first.keptExisting ?? []).filter((entry) => !replaced.has(entry.name)).concat(next.keptExisting ?? []);
19003
+ first.componentTypes = { ...first.componentTypes, ...next.componentTypes };
19004
+ first.elapsedMs += next.elapsedMs;
19005
+ }
18338
19006
  function printGrouped(b, prefix = "") {
18339
19007
  const GROUP_LABELS = {
18340
19008
  "mcp-tool": "MCP servers",
@@ -18423,11 +19091,11 @@ function makeProgressPrinter(out = process.stdout) {
18423
19091
  }
18424
19092
  function registerSetup(program2) {
18425
19093
  program2.command("setup").description(
18426
- "One-shot onboarding: install workflow skills + base manifests to ~/.claude/ (immediate by default \u2014 use --dry-run for preview)"
19094
+ "One-shot onboarding: install workflow skills + base manifests for the selected host (immediate by default \u2014 use --dry-run for preview)"
18427
19095
  ).option("--dry-run", "preview only \u2014 do not write to disk (opt-in for advanced users)").option(
18428
19096
  "--user-lang <code>",
18429
19097
  "override detected OS locale for env.HARNESSED_USER_LANG (en | zh-Hans / zh-CN / zh-TW)"
18430
- ).option("--platform <id>", "target harness platform (claude | codex); default: auto-detect").option("--non-interactive", "skip all confirm prompts (CI / scripted setup)").option("--no-auto-install", "do not prompt to auto-install missing plugins (advisory only)").option(
19098
+ ).option("--platform <id>", "target harness platform (claude | codex); default: auto-detect").option("--non-interactive", "skip all confirm prompts (CI / scripted setup)").option("--system", "allow L4 system-wide installs (e.g. global npm install)").option("--no-auto-install", "do not prompt to auto-install missing plugins (advisory only)").option(
18431
19099
  "--update-installed",
18432
19100
  "force re-install already-installed plugins (excludes MCP servers); default: skip if installed"
18433
19101
  ).option(
@@ -18471,6 +19139,7 @@ installing ${manifestPaths.length} upstream components (MCP serialized, rest par
18471
19139
  );
18472
19140
  const b = await runStepBInstall(manifestPaths, {
18473
19141
  updateInstalled: forceFirstPass,
19142
+ system: raw.system === true,
18474
19143
  quiet: true,
18475
19144
  onProgress: progress.onProgress
18476
19145
  });
@@ -18501,6 +19170,7 @@ installing ${manifestPaths.length} upstream components (MCP serialized, rest par
18501
19170
  force-updating ${b.alreadyInstalled.length} plugin(s)...`);
18502
19171
  const b2 = await runStepBInstall(manifestPaths, {
18503
19172
  updateInstalled: true,
19173
+ system: raw.system === true,
18504
19174
  quiet: true,
18505
19175
  onProgress: progress.onProgress
18506
19176
  });
@@ -18521,6 +19191,7 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
18521
19191
  ${b2.keptExisting.length} plugin(s) kept their existing version \u2014 refresh failed but the prior install is still usable. Re-run \`harnessed setup\` later to retry the update.`
18522
19192
  );
18523
19193
  }
19194
+ mergeStepBResults(b, b2);
18524
19195
  }
18525
19196
  }
18526
19197
  }
@@ -18675,9 +19346,29 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
18675
19346
  const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
18676
19347
  if (isTty) {
18677
19348
  const { runL4Rescue: runL4Rescue2 } = await Promise.resolve().then(() => (init_l4_rescue(), l4_rescue_exports));
18678
- await runL4Rescue2(manifestPaths, b.skipped);
19349
+ const rescue = await runL4Rescue2(manifestPaths, b.skipped);
19350
+ b.installed.push(...rescue.installed);
19351
+ for (const failure of rescue.failed) {
19352
+ const detail = `${failure.name}: ${failure.reason}`;
19353
+ b.failed.push(detail);
19354
+ console.error(` [L4 rescue] ${detail}`);
19355
+ }
19356
+ const resolved = /* @__PURE__ */ new Set([
19357
+ ...rescue.installed,
19358
+ ...rescue.failed.map((failure) => failure.name)
19359
+ ]);
19360
+ b.skipped = b.skipped.filter(
19361
+ (skip) => skip.reason !== "level-flag-missing" || !resolved.has(skip.name)
19362
+ );
18679
19363
  }
18680
19364
  }
19365
+ if (raw.system !== true && b.skipped.some(
19366
+ (skip) => skip.reason === "level-flag-missing" || skip.reason.startsWith("L4 system-scope")
19367
+ )) {
19368
+ console.warn(
19369
+ "\nL4 system-wide installs remain skipped. To explicitly authorize them, run: harnessed setup --system --non-interactive"
19370
+ );
19371
+ }
18681
19372
  if (!dryRun) {
18682
19373
  const optIsTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
18683
19374
  const { runOptionalOffer: runOptionalOffer2 } = await Promise.resolve().then(() => (init_optional_offer(), optional_offer_exports));
@@ -18692,13 +19383,14 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
18692
19383
  ${b.failed.length} component(s) failed \u2014 see the notes in the tables above; re-run \`harnessed setup\` to retry, or run \`harnessed doctor\` for environment diagnostics.`
18693
19384
  );
18694
19385
  }
19386
+ const configured = b.installed.length + b.alreadyInstalled.length + (b.keptExisting?.length ?? 0);
18695
19387
  console.log(
18696
19388
  t("setup.complete", {
18697
19389
  skills: skillsInstalled,
18698
- manifests: b.installed.length + b.alreadyInstalled.length
19390
+ manifests: configured
18699
19391
  })
18700
19392
  );
18701
- if (b.alreadyInstalled.length > 0 || b.installed.length > 0) {
19393
+ if (configured > 0) {
18702
19394
  console.log(t(detectPlatform().id === "codex" ? "setup.mcp_hint_codex" : "setup.mcp_hint"));
18703
19395
  }
18704
19396
  try {
@@ -18792,7 +19484,7 @@ ${b.failed.length} component(s) failed \u2014 see the notes in the tables above;
18792
19484
  }
18793
19485
  } catch {
18794
19486
  }
18795
- process.exit(0);
19487
+ process.exit(b.failed.length > 0 ? 1 : 0);
18796
19488
  });
18797
19489
  }
18798
19490
 
@@ -19119,7 +19811,7 @@ var uninstallNpmCli = async (ctx) => {
19119
19811
  const m = install.cmd.match(/npm\s+(?:install|i)\s+(?:-g\s+)?(\S+)/);
19120
19812
  const pkg = m?.[1] ?? ctx.manifest.metadata.upstream.source;
19121
19813
  const isWin = process.platform === "win32";
19122
- const result = await new Promise((resolve23) => {
19814
+ const result = await new Promise((resolve25) => {
19123
19815
  const child = isWin ? spawn("cmd.exe", ["/c", "npm", "uninstall", "-g", pkg], { windowsHide: true }) : spawn("npm", ["uninstall", "-g", pkg], { shell: false });
19124
19816
  let stderr = "";
19125
19817
  child.stderr?.setEncoding("utf8").on("data", (c) => {
@@ -19127,15 +19819,15 @@ var uninstallNpmCli = async (ctx) => {
19127
19819
  });
19128
19820
  const timer = setTimeout(() => {
19129
19821
  child.kill("SIGKILL");
19130
- resolve23({ exitCode: -1, stderr: `${stderr}[timeout]` });
19822
+ resolve25({ exitCode: -1, stderr: `${stderr}[timeout]` });
19131
19823
  }, 3e4);
19132
19824
  child.on("error", (e) => {
19133
19825
  clearTimeout(timer);
19134
- resolve23({ exitCode: -1, stderr: e.message });
19826
+ resolve25({ exitCode: -1, stderr: e.message });
19135
19827
  });
19136
19828
  child.on("close", (code2) => {
19137
19829
  clearTimeout(timer);
19138
- resolve23({ exitCode: code2 ?? -1, stderr });
19830
+ resolve25({ exitCode: code2 ?? -1, stderr });
19139
19831
  });
19140
19832
  });
19141
19833
  if (result.exitCode !== 0) {
@@ -19492,7 +20184,9 @@ ${t("install.manifest_not_found.fix", { name: resolvedName })}`
19492
20184
  init_package();
19493
20185
  init_assetsRoot();
19494
20186
  init_harnessedRoot();
20187
+ init_platform();
19495
20188
  async function runCompiledFlow(opts) {
20189
+ const hostName = detectPlatform().id === "codex" ? "Codex" : "Claude Code";
19496
20190
  const { realSelfUpdateDeps: realSelfUpdateDeps2, runBinaryRollback: runBinaryRollback2, runBinarySelfUpdate: runBinarySelfUpdate2 } = await Promise.resolve().then(() => (init_selfUpdateBinary(), selfUpdateBinary_exports));
19497
20191
  if (opts.rollback !== void 0 && opts.rollback !== false) {
19498
20192
  const r2 = await runBinaryRollback2(realSelfUpdateDeps2(), {
@@ -19509,7 +20203,7 @@ async function runCompiledFlow(opts) {
19509
20203
  return true;
19510
20204
  case "rolled-back":
19511
20205
  console.log(`[harnessed] rolled back ${r2.from} \u2192 ${r2.to} (from ${r2.backupUsed}).`);
19512
- console.log("[harnessed] restart Claude Code so the restored version takes effect.");
20206
+ console.log(`[harnessed] restart ${hostName} so the restored version takes effect.`);
19513
20207
  process.exit(0);
19514
20208
  return true;
19515
20209
  }
@@ -19546,17 +20240,16 @@ async function runCompiledFlow(opts) {
19546
20240
  );
19547
20241
  try {
19548
20242
  const { gcCompiledArtifacts: gcCompiledArtifacts2 } = await Promise.resolve().then(() => (init_gc(), gc_exports));
19549
- const { detectPlatform: detectPlatform2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
19550
20243
  await gcCompiledArtifacts2({
19551
20244
  keepVersions: [r.from, r.to],
19552
- stateRoot: detectPlatform2().stateRoot,
20245
+ stateRoot: detectPlatform().stateRoot,
19553
20246
  execPath: null
19554
20247
  // never sweep .bak in the same run that created it
19555
20248
  });
19556
20249
  } catch {
19557
20250
  }
19558
20251
  console.log(
19559
- `[harnessed] restart Claude Code so the new version + hooks take effect. Manual rollback if needed: copy the binary back from the bin-backup dir above.`
20252
+ `[harnessed] restart ${hostName} so the new version + hooks take effect. Manual rollback if needed: copy the binary back from the bin-backup dir above.`
19560
20253
  );
19561
20254
  process.exit(0);
19562
20255
  return true;
@@ -19641,8 +20334,9 @@ function registerUpdate(program2) {
19641
20334
  if (cl) console.log(`
19642
20335
  ${cl}
19643
20336
  `);
20337
+ const hostName = detectPlatform().id === "codex" ? "Codex" : "Claude Code";
19644
20338
  console.log(
19645
- "[harnessed] updated. Restart Claude Code so the new version + hooks take effect."
20339
+ `[harnessed] updated. Restart ${hostName} so the new version + hooks take effect.`
19646
20340
  );
19647
20341
  } else {
19648
20342
  console.log(`[harnessed] already up to date (${package_default.version}).`);