harnessed 4.15.2 → 4.16.1

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
@@ -38,7 +38,7 @@ var init_package = __esm({
38
38
  "package.json"() {
39
39
  package_default = {
40
40
  name: "harnessed",
41
- version: "4.15.2",
41
+ version: "4.16.1",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -4512,10 +4512,26 @@ function sanitizeOutputTail(raw, cap = 160) {
4512
4512
  const printable = firstNonEmpty.replace(/[^\x20-\x7E]/g, "").trim();
4513
4513
  return printable.length > 0 ? printable.slice(0, cap) : "(unreadable output)";
4514
4514
  }
4515
+ function sanitizeOutputTailEnd(raw, cap = 300) {
4516
+ const lines = raw.split(/\r?\n/).map((l) => l.replace(/[^\x20-\x7E]/g, "").trim()).filter((l) => l.length > 0);
4517
+ if (lines.length === 0) return "(unreadable output)";
4518
+ let out = "";
4519
+ for (let i = lines.length - 1; i >= 0; i--) {
4520
+ const cand = out ? `${lines[i]} | ${out}` : lines[i];
4521
+ if (cand.length > cap) break;
4522
+ out = cand;
4523
+ }
4524
+ return out || `${lines[lines.length - 1].slice(0, cap)}\u2026`;
4525
+ }
4526
+ function formatSpawnFail(label, exitCode, stdout2, stderr) {
4527
+ const rawTail = stderr.trim() || stdout2.trim();
4528
+ const tail = rawTail.length > 0 ? sanitizeOutputTailEnd(rawTail, 300) : "(no output)";
4529
+ return `${label} exited ${exitCode}: ${tail}`;
4530
+ }
4515
4531
  function formatVerifyFail(cmd, exitCode, expected, stdout2, stderr) {
4516
4532
  const cmdPart = cmd.length > 80 ? `${cmd.slice(0, 80)}\u2026` : cmd;
4517
4533
  const rawTail = stderr.trim() || stdout2.trim();
4518
- const tail = rawTail.length > 0 ? sanitizeOutputTail(rawTail) : "(no output)";
4534
+ const tail = rawTail.length > 0 ? sanitizeOutputTailEnd(rawTail, 160) : "(no output)";
4519
4535
  return `verify failed (exit ${exitCode} \u2260 expected ${expected}): \`${cmdPart}\` \u2014 ${tail}`;
4520
4536
  }
4521
4537
  var init_verifyMessage = __esm({
@@ -5014,7 +5030,7 @@ async function checkMattpocockSkills() {
5014
5030
  } catch {
5015
5031
  }
5016
5032
  }
5017
- const indicators = ["diagnose", "tdd", "zoom-out"];
5033
+ const indicators = ["tdd", "diagnosing-bugs", "grill-with-docs", "diagnose"];
5018
5034
  for (const skillsDir of harnessSkillsDirs()) {
5019
5035
  for (const ind of indicators) {
5020
5036
  try {
@@ -5040,7 +5056,7 @@ var REMEDIATION2;
5040
5056
  var init_check_mattpocock_skills = __esm({
5041
5057
  "src/cli/lib/check-mattpocock-skills.ts"() {
5042
5058
  init_platform();
5043
- 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 /zoom-out etc. SlashCommand acceleration";
5059
+ 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";
5044
5060
  }
5045
5061
  });
5046
5062
  function getUserClaudeJsonPath() {
@@ -5191,6 +5207,62 @@ var init_check_codegraph = __esm({
5191
5207
  }
5192
5208
  });
5193
5209
 
5210
+ // src/cli/lib/check-bun.ts
5211
+ var check_bun_exports = {};
5212
+ __export(check_bun_exports, {
5213
+ checkBun: () => checkBun
5214
+ });
5215
+ function realRun(finder) {
5216
+ try {
5217
+ if (typeof spawnSync !== "function") return null;
5218
+ const r = spawnSync(finder, ["bun"], { encoding: "utf8" });
5219
+ if (!r || r.error) return null;
5220
+ return { status: r.status, stdout: r.stdout ?? "" };
5221
+ } catch {
5222
+ return null;
5223
+ }
5224
+ }
5225
+ function checkBun(deps) {
5226
+ const platform = deps?.platform ?? process.platform;
5227
+ const run = deps?.run ?? realRun;
5228
+ const finder = platform === "win32" ? "where" : "which";
5229
+ const r = run(finder);
5230
+ if (r && r.status === 0 && r.stdout.trim().length > 0) {
5231
+ return {
5232
+ name: "bun present",
5233
+ status: "pass",
5234
+ message: r.stdout.split(/\r?\n/)[0]?.trim() ?? "bun found"
5235
+ };
5236
+ }
5237
+ const missing = {
5238
+ name: "bun present",
5239
+ status: "warn",
5240
+ message: "bun not found in PATH \u2014 gstack setup builds its browse binary with bun (gstack refresh will fail without it)"
5241
+ };
5242
+ if (platform === "win32") {
5243
+ return {
5244
+ ...missing,
5245
+ fix: "winget install Oven-sh.Bun",
5246
+ install_commands: ["winget install Oven-sh.Bun"]
5247
+ };
5248
+ }
5249
+ if (platform === "darwin") {
5250
+ return {
5251
+ ...missing,
5252
+ fix: "brew install oven-sh/bun/bun",
5253
+ install_commands: ["brew install oven-sh/bun/bun"]
5254
+ };
5255
+ }
5256
+ return {
5257
+ ...missing,
5258
+ fix: "see https://bun.sh/docs/installation (curl -fsSL https://bun.sh/install | bash \u2014 review the script first)"
5259
+ };
5260
+ }
5261
+ var init_check_bun = __esm({
5262
+ "src/cli/lib/check-bun.ts"() {
5263
+ }
5264
+ });
5265
+
5194
5266
  // src/cli/lib/version-check.ts
5195
5267
  var version_check_exports = {};
5196
5268
  __export(version_check_exports, {
@@ -5298,6 +5370,9 @@ var init_doctor_registry = __esm({
5298
5370
  // Phase 18 — opt-in CodeGraph semantic-index detect (always 'pass'; absence of an
5299
5371
  // optional tool is not a health failure).
5300
5372
  async () => (await Promise.resolve().then(() => (init_check_codegraph(), check_codegraph_exports))).checkCodeGraph(process.cwd()),
5373
+ // v4.16.1 T3 — bun presence (warn-only): gstack's upstream setup hard-requires
5374
+ // bun; missing bun is THE gstack refresh-failure cause on user dogfood machines.
5375
+ async () => (await Promise.resolve().then(() => (init_check_bun(), check_bun_exports))).checkBun(),
5301
5376
  // Phase 20 — "update available" version check ('warn' only when behind; 'pass'
5302
5377
  // when current/ahead/npm-unreachable — fail-soft, never flips the summary).
5303
5378
  async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate()
@@ -5620,6 +5695,57 @@ var init_ccHookAdd2 = __esm({
5620
5695
  };
5621
5696
  }
5622
5697
  });
5698
+ function extractVerifyBinary(verifyCmd, fallback) {
5699
+ const token = verifyCmd?.trim().split(/\s+/)[0];
5700
+ if (token && BARE_BIN_RE.test(token) && !NON_COMPONENT_TOKENS.has(token)) return token;
5701
+ if (BARE_BIN_RE.test(fallback) && !NON_COMPONENT_TOKENS.has(fallback)) return fallback;
5702
+ return null;
5703
+ }
5704
+ function realRun2(finder, bin) {
5705
+ try {
5706
+ if (typeof spawnSync !== "function") return null;
5707
+ const r = spawnSync(finder, [bin], { encoding: "utf8" });
5708
+ if (!r || r.error) return null;
5709
+ return { status: r.status, stdout: r.stdout ?? "" };
5710
+ } catch {
5711
+ return null;
5712
+ }
5713
+ }
5714
+ function binaryOnPath(bin, deps) {
5715
+ const platform = process.platform;
5716
+ const run = realRun2;
5717
+ const finder = platform === "win32" ? "where" : "which";
5718
+ const r = run(finder, bin);
5719
+ if (!r || r.status !== 0) return false;
5720
+ return r.stdout.trim().length > 0;
5721
+ }
5722
+ var NON_COMPONENT_TOKENS, BARE_BIN_RE;
5723
+ var init_binaryProbe = __esm({
5724
+ "src/installers/lib/binaryProbe.ts"() {
5725
+ NON_COMPONENT_TOKENS = /* @__PURE__ */ new Set([
5726
+ "test",
5727
+ "grep",
5728
+ "ls",
5729
+ "cat",
5730
+ "echo",
5731
+ "command",
5732
+ "sh",
5733
+ "bash",
5734
+ "[",
5735
+ "npx",
5736
+ "npm",
5737
+ "node",
5738
+ "corepack",
5739
+ "pnpm",
5740
+ "yarn",
5741
+ "bun",
5742
+ "git",
5743
+ "claude",
5744
+ "codex"
5745
+ ]);
5746
+ BARE_BIN_RE = /^[A-Za-z0-9][\w.@-]*$/;
5747
+ }
5748
+ });
5623
5749
  function evalClause(clause, home) {
5624
5750
  const m = clause.match(CLAUSE_RE);
5625
5751
  if (!m?.[1] || !m[2]) return null;
@@ -5760,7 +5886,8 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
5760
5886
  // some CLIs write their error text to stdout; a bare trailing colon
5761
5887
  // read as "no reason" in user dogfood). v4.15.2 — sanitized (CP936
5762
5888
  // mojibake was embedded verbatim in the ctx7 dogfood error).
5763
- message: `spawn timed out after ${effectiveTimeoutMs}ms (cmd: ${cmd}); partial output: ${(stderr || stdout2).trim() ? sanitizeOutputTail(stderr || stdout2, 200) : "(no output)"}`,
5889
+ // v4.16.1 T2 — tail-END biased (errors live at the end of output).
5890
+ message: `spawn timed out after ${effectiveTimeoutMs}ms (cmd: ${cmd}); partial output: ${(stderr || stdout2).trim() ? sanitizeOutputTailEnd(stderr || stdout2, 200) : "(no output)"}`,
5764
5891
  line: null,
5765
5892
  column: null,
5766
5893
  keyword: "spawn-timeout"
@@ -5916,6 +6043,8 @@ async function detectNative(ctx) {
5916
6043
  }
5917
6044
  }
5918
6045
  if (method === "npm-cli") {
6046
+ const bin = extractVerifyBinary(ctx.manifest.spec.verify?.cmd, name);
6047
+ if (bin && binaryOnPath(bin)) return true;
5919
6048
  const skillDir = join(getSkillsDir(), name);
5920
6049
  try {
5921
6050
  await access(skillDir);
@@ -5950,13 +6079,14 @@ async function isAlreadyInstalled(ctx, opts = {}) {
5950
6079
  var IDEMPOTENT_CHECK_TIMEOUT_MS, INSTALLED_INDICATORS;
5951
6080
  var init_idempotent = __esm({
5952
6081
  "src/installers/lib/idempotent.ts"() {
6082
+ init_binaryProbe();
5953
6083
  init_platform();
5954
6084
  init_readClaudeConfig();
5955
6085
  init_spawn();
5956
6086
  IDEMPOTENT_CHECK_TIMEOUT_MS = 1e4;
5957
6087
  INSTALLED_INDICATORS = {
5958
6088
  gsd: ["gsd-progress", "gsd-plan-phase"],
5959
- "mattpocock-skills": ["diagnose", "tdd", "zoom-out"]
6089
+ "mattpocock-skills": ["tdd", "diagnosing-bugs", "grill-with-docs", "diagnose"]
5960
6090
  };
5961
6091
  }
5962
6092
  });
@@ -6032,6 +6162,7 @@ var init_ccPluginMarketplace2 = __esm({
6032
6162
  init_runClaudeArgs();
6033
6163
  init_safeCwd();
6034
6164
  init_state2();
6165
+ init_verifyMessage();
6035
6166
  installCcPluginMarketplace = async (ctx) => {
6036
6167
  const install = ctx.manifest.spec.install;
6037
6168
  if (install.method !== "cc-plugin-marketplace") {
@@ -6145,7 +6276,8 @@ ${newEntry}
6145
6276
  error: err(
6146
6277
  ctx,
6147
6278
  "/spec/install/cmd",
6148
- `${bin} plugin ${bin === "codex" ? "add" : "install"} exited ${r2.exitCode}: ${r2.stderr.slice(0, 200)}${stepOneStderr ? ` | marketplace-add stderr: ${stepOneStderr.slice(0, 100)}` : ""}`,
6279
+ // v4.16.0 T5 — shared spawn-fail format (stderr → stdout fallback).
6280
+ `${formatSpawnFail(`${bin} plugin ${bin === "codex" ? "add" : "install"}`, r2.exitCode, r2.stdout, r2.stderr)}${stepOneStderr ? ` | marketplace-add stderr: ${stepOneStderr.slice(0, 100)}` : ""}`,
6149
6281
  "install-failed"
6150
6282
  )
6151
6283
  };
@@ -6323,37 +6455,35 @@ var init_gitCloneWithSetup2 = __esm({
6323
6455
  error: err(
6324
6456
  ctx,
6325
6457
  "/spec/install/cmd",
6326
- `git-clone-with-setup cmd exited ${sp.exitCode}: ${sp.stderr.slice(0, 200)}`,
6458
+ // v4.16.0 T5 — shared spawn-fail format (stderr → stdout fallback).
6459
+ formatSpawnFail("git-clone-with-setup cmd", sp.exitCode, sp.stdout, sp.stderr),
6327
6460
  "install-failed"
6328
6461
  )
6329
6462
  };
6330
6463
  }
6331
6464
  const rp = await gitRevParseHead(cloneTarget);
6332
6465
  if (rp.exit !== 0 || !rp.sha) {
6333
- return {
6334
- ok: false,
6335
- phase: "verify",
6336
- backupId: bk.backupId,
6337
- error: err(
6338
- ctx,
6339
- "/spec/install/git_ref",
6340
- `git rev-parse HEAD failed in ${cloneTarget} (exit ${rp.exit}); cannot verify SHA pin '${install.git_ref}'`,
6341
- "sha-mismatch"
6342
- )
6343
- };
6344
- }
6345
- if (!rp.sha.startsWith(install.git_ref)) {
6346
- return {
6347
- ok: false,
6348
- phase: "verify",
6349
- backupId: bk.backupId,
6350
- error: err(
6351
- ctx,
6352
- "/spec/install/git_ref",
6353
- `git_ref SHA mismatch: manifest pinned '${install.git_ref}' but HEAD is '${rp.sha}' in ${cloneTarget}`,
6354
- "sha-mismatch"
6355
- )
6356
- };
6466
+ console.warn(
6467
+ ` \u26A0 ${name}: git_ref SHA pin '${install.git_ref}' unverifiable \u2014 \`git rev-parse HEAD\` exit ${rp.exit} in ${cloneTarget} (the install cmd may remove its own clone dir); falling back to the manifest verify cmd as the install authority`
6468
+ );
6469
+ } else if (!rp.sha.startsWith(install.git_ref)) {
6470
+ if (ctx.opts.updateInstalled === true) {
6471
+ console.warn(
6472
+ ` \u26A0 ${name}: upstream HEAD '${rp.sha}' no longer matches manifest git_ref pin '${install.git_ref}' (expected under force-update \u2014 the pin records install-time state); consider bumping git_ref in the manifest`
6473
+ );
6474
+ } else {
6475
+ return {
6476
+ ok: false,
6477
+ phase: "verify",
6478
+ backupId: bk.backupId,
6479
+ error: err(
6480
+ ctx,
6481
+ "/spec/install/git_ref",
6482
+ `git_ref SHA mismatch: manifest pinned '${install.git_ref}' but HEAD is '${rp.sha}' in ${cloneTarget}`,
6483
+ "sha-mismatch"
6484
+ )
6485
+ };
6486
+ }
6357
6487
  }
6358
6488
  const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
6359
6489
  const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
@@ -6818,7 +6948,8 @@ var init_npmCli2 = __esm({
6818
6948
  error: err(
6819
6949
  ctx,
6820
6950
  "/spec/install/cmd",
6821
- `install cmd exited ${sp.exitCode}: ${sp.stderr.slice(0, 200)}`,
6951
+ // v4.16.0 T5 — shared spawn-fail format (stderr → stdout fallback).
6952
+ formatSpawnFail("install cmd", sp.exitCode, sp.stdout, sp.stderr),
6822
6953
  "install-failed"
6823
6954
  )
6824
6955
  };
@@ -6848,7 +6979,7 @@ var init_npmCli2 = __esm({
6848
6979
  };
6849
6980
  }
6850
6981
  });
6851
- var installNpxSkillInstaller;
6982
+ var HARD_CRASH_EXITS, HARD_CRASH_RETRY_DELAY_MS, installNpxSkillInstaller;
6852
6983
  var init_npxSkillInstaller2 = __esm({
6853
6984
  "src/installers/npxSkillInstaller.ts"() {
6854
6985
  init_backup();
@@ -6861,6 +6992,8 @@ var init_npxSkillInstaller2 = __esm({
6861
6992
  init_spawn();
6862
6993
  init_state2();
6863
6994
  init_verifyMessage();
6995
+ HARD_CRASH_EXITS = /* @__PURE__ */ new Set([3221226505, 3221225477]);
6996
+ HARD_CRASH_RETRY_DELAY_MS = 500;
6864
6997
  installNpxSkillInstaller = async (ctx) => {
6865
6998
  const install = ctx.manifest.spec.install;
6866
6999
  if (install.method !== "npx-skill-installer") {
@@ -6932,8 +7065,13 @@ var init_npxSkillInstaller2 = __esm({
6932
7065
  if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
6933
7066
  const bk = await backup(plan, ctx);
6934
7067
  if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
6935
- const sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
7068
+ let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
6936
7069
  if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
7070
+ if (HARD_CRASH_EXITS.has(sp.exitCode)) {
7071
+ await new Promise((r) => setTimeout(r, HARD_CRASH_RETRY_DELAY_MS));
7072
+ sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
7073
+ if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
7074
+ }
6937
7075
  if (sp.exitCode !== 0) {
6938
7076
  return {
6939
7077
  ok: false,
@@ -6942,7 +7080,8 @@ var init_npxSkillInstaller2 = __esm({
6942
7080
  error: err(
6943
7081
  ctx,
6944
7082
  "/spec/install/cmd",
6945
- `npx skills add exited ${sp.exitCode}: ${sp.stderr.slice(0, 200)}`,
7083
+ // v4.16.0 T5 — shared spawn-fail format (stderr → stdout fallback).
7084
+ formatSpawnFail("npx skills add", sp.exitCode, sp.stdout, sp.stderr),
6946
7085
  "install-failed"
6947
7086
  )
6948
7087
  };
@@ -9834,7 +9973,7 @@ function printGrouped(b, prefix = "") {
9834
9973
  };
9835
9974
  for (const n of b.failed) {
9836
9975
  const m = n.match(/^([^:]+):\s*(.*)$/s);
9837
- push(groupOf(m?.[1] ?? n), { status: "failed", name: m?.[1] ?? n, note: m?.[2] });
9976
+ push(groupOf(m?.[1] ?? n), { status: "failed", name: m?.[1] ?? n, note: m?.[2], full: m?.[2] });
9838
9977
  }
9839
9978
  for (const n of b.installed) push(groupOf(n), { status: "installed", name: n });
9840
9979
  for (const s of b.skipped)
@@ -9845,7 +9984,8 @@ function printGrouped(b, prefix = "") {
9845
9984
  push(groupOf(k.name), {
9846
9985
  status: "kept-existing",
9847
9986
  name: k.name,
9848
- note: `${why} \u2014 prior version retained`
9987
+ note: `${why} \u2014 prior version retained`,
9988
+ full: k.reason
9849
9989
  });
9850
9990
  }
9851
9991
  for (const g of GROUP_ORDER) {
@@ -9866,6 +10006,15 @@ function printGrouped(b, prefix = "") {
9866
10006
  else if (r.status === "kept-existing") console.warn(r.line);
9867
10007
  else console.log(r.line);
9868
10008
  }
10009
+ for (const e of entries) {
10010
+ if (!e.full) continue;
10011
+ const shownNote = (e.note ?? "").slice(0, NOTE_MAX);
10012
+ if (shownNote.includes(e.full)) continue;
10013
+ const full = e.full.length > 400 ? `${e.full.slice(0, 400)}\u2026` : e.full;
10014
+ const line = ` \u21B3 ${e.name}: ${full}`;
10015
+ if (e.status === "failed") console.error(line);
10016
+ else console.warn(line);
10017
+ }
9869
10018
  }
9870
10019
  }
9871
10020
  function registerSetup(program2) {