harnessed 4.20.0 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -38,7 +38,7 @@ var init_package = __esm({
38
38
  "package.json"() {
39
39
  package_default = {
40
40
  name: "harnessed",
41
- version: "4.20.0",
41
+ version: "4.21.0",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -2495,13 +2495,17 @@ function buildInteractiveBody(name, prompt) {
2495
2495
  ``,
2496
2496
  `Clarification requires real user dialogue. Spawned subagents cannot ask the user questions, so run this stage directly in this session \u2014 do NOT spawn it.`,
2497
2497
  ``,
2498
+ // v4.21.0 (KidsTetris dogfood) — bootstrap step + GSD-standard phase-dir
2499
+ // convention: the loose \`.planning/\` wording let agents invent their own
2500
+ // layout (phase-0-discuss/ etc.) on fresh projects with no ROADMAP.
2501
+ `0. New-project bootstrap \u2014 if \`.planning/ROADMAP.md\` does not exist: invoke \`/gsd-new-project\` when available; otherwise create a minimal \`ROADMAP.md\` (one table row per phase), \`STATE.md\` (digest, <100 lines), and \`REQUIREMENTS.md\` (numbered acceptance criteria) before continuing.`,
2498
2502
  `1. Evaluate the clarification criteria for "$ARGUMENTS":`,
2499
2503
  ` - Strategic layer: new feature / new milestone / unclear business scope \u2192 run gstack \`/office-hours\` + \`/plan-ceo-review\``,
2500
2504
  ` - Phase layer: \u22652 open implementation decisions / unclear cross-phase API contract \u2192 run GSD \`/gsd-discuss-phase\``,
2501
2505
  ` - Subtask layer: \u22652 distinct approaches / core algorithm / API contract design / high error cost \u2192 run superpowers brainstorming`,
2502
2506
  `2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions). Lock every open decision.`,
2503
2507
  `3. Skip layers that don't fire \u2014 state which were skipped and why (transparent skip).`,
2504
- `4. Persist locked decisions to \`.planning/\` via planning-with-files (\`findings.md\` / \`task_plan.md\`).`,
2508
+ `4. Persist locked decisions to \`.planning/phases/<NN>-<slug>/\` via planning-with-files (\`findings.md\` / \`task_plan.md\`; NN = two-digit, one above the highest existing phase dir; slug = kebab-case short name).`,
2505
2509
  ``,
2506
2510
  `Output: a locked spec the execution stages can consume without further user input. Then run \`/plan\` \u2192 \`/task\` \u2192 \`/verify\` with that spec.`,
2507
2511
  ``,
@@ -5690,7 +5694,7 @@ function resolveHookCommand(raw, deps) {
5690
5694
  root = root ?? deps.assetsRoot();
5691
5695
  const abs = join(root, bare2);
5692
5696
  if (!deps.exists(abs)) return token;
5693
- return abs.includes(" ") ? `"${abs}"` : abs;
5697
+ return `"${abs.replace(/\\/g, "/")}"`;
5694
5698
  });
5695
5699
  return out.join(" ");
5696
5700
  }
@@ -6073,6 +6077,29 @@ var init_nativeTest = __esm({
6073
6077
  UNSAFE_PATH_RE = /[|&;<>()*?"'`$={}[\]]/;
6074
6078
  }
6075
6079
  });
6080
+ function getMcpSpawnCwd() {
6081
+ return homedir();
6082
+ }
6083
+ function getNeutralSpawnCwd() {
6084
+ const override = process.env.HARNESSED_SPAWN_CWD;
6085
+ if (override !== void 0 && override.trim().length > 0) return override.trim();
6086
+ try {
6087
+ const dir = join(detectPlatform().stateRoot, ".spawn");
6088
+ mkdirSync(dir, { recursive: true });
6089
+ const sentinel = join(dir, "package.json");
6090
+ if (!existsSync(sentinel)) writeFileSync(sentinel, NEUTRAL_SENTINEL, "utf8");
6091
+ return dir;
6092
+ } catch {
6093
+ return null;
6094
+ }
6095
+ }
6096
+ var NEUTRAL_SENTINEL;
6097
+ var init_safeCwd = __esm({
6098
+ "src/installers/lib/safeCwd.ts"() {
6099
+ init_platform();
6100
+ NEUTRAL_SENTINEL = '{\n "name": "harnessed-neutral-spawn",\n "private": true\n}\n';
6101
+ }
6102
+ });
6076
6103
  function expandTildeForWindows(cmd) {
6077
6104
  const home = homedir().replace(/\\/g, "/");
6078
6105
  return cmd.replace(/(^|[\s"'`(])~\//g, `$1${home}/`);
@@ -6106,7 +6133,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
6106
6133
  const installCfg = ctx.manifest.spec.install;
6107
6134
  const effectiveTimeoutMs = timeoutMs ?? DEFAULT_INSTALL_TIMEOUT_MS;
6108
6135
  const env = { ...process.env, ...installCfg.env ?? {} };
6109
- const cwd = installCfg.cwd ?? ctx.cwd;
6136
+ const cwd = installCfg.cwd ?? (opts?.neutralCwd ? getNeutralSpawnCwd() ?? ctx.cwd : ctx.cwd);
6110
6137
  let child;
6111
6138
  let triedBash = false;
6112
6139
  const stdio = ["ignore", "pipe", "pipe"];
@@ -6199,6 +6226,7 @@ var init_spawn = __esm({
6199
6226
  init_security();
6200
6227
  init_nativeTest();
6201
6228
  init_resolveBash();
6229
+ init_safeCwd();
6202
6230
  init_verifyMessage();
6203
6231
  POSIX_SYNTAX_RE = /[|;<>`$~[\]{}()*?!]|&&/;
6204
6232
  POSIX_FIRST_TOKENS = /* @__PURE__ */ new Set([
@@ -6424,13 +6452,6 @@ var init_runClaudeArgs = __esm({
6424
6452
  "src/installers/lib/runClaudeArgs.ts"() {
6425
6453
  }
6426
6454
  });
6427
- function getMcpSpawnCwd() {
6428
- return homedir();
6429
- }
6430
- var init_safeCwd = __esm({
6431
- "src/installers/lib/safeCwd.ts"() {
6432
- }
6433
- });
6434
6455
 
6435
6456
  // src/installers/ccPluginMarketplace.ts
6436
6457
  function parseCmd(cmd) {
@@ -7260,7 +7281,7 @@ var init_npmCli2 = __esm({
7260
7281
  if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
7261
7282
  const bk = await backup(plan, ctx);
7262
7283
  if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
7263
- const sp = await spawnCmd(ctx, cmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
7284
+ const sp = await spawnCmd(ctx, cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
7264
7285
  if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
7265
7286
  if (sp.exitCode !== 0) {
7266
7287
  return {
@@ -7278,7 +7299,8 @@ var init_npmCli2 = __esm({
7278
7299
  }
7279
7300
  const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
7280
7301
  const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
7281
- posixShell: true
7302
+ posixShell: true,
7303
+ neutralCwd: true
7282
7304
  });
7283
7305
  if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
7284
7306
  const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
@@ -7387,11 +7409,11 @@ var init_npxSkillInstaller2 = __esm({
7387
7409
  if (ctx.opts.dryRun) return { aborted: true, reason: "user-cancel" };
7388
7410
  const bk = await backup(plan, ctx);
7389
7411
  if (!bk.ok) return { ok: false, phase: "preflight", error: bk.error };
7390
- let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
7412
+ let sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
7391
7413
  if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
7392
7414
  if (HARD_CRASH_EXITS.has(sp.exitCode)) {
7393
7415
  await new Promise((r) => setTimeout(r, HARD_CRASH_RETRY_DELAY_MS));
7394
- sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS);
7416
+ sp = await spawnCmd(ctx, effectiveCmd, [], DEFAULT_INSTALL_TIMEOUT_MS, { neutralCwd: true });
7395
7417
  if (!("exitCode" in sp)) return { ...sp, backupId: bk.backupId };
7396
7418
  }
7397
7419
  if (sp.exitCode !== 0) {
@@ -7427,7 +7449,8 @@ var init_npxSkillInstaller2 = __esm({
7427
7449
  }
7428
7450
  const verifyTimeoutMs = ctx.manifest.spec.verify.timeout_ms ?? DEFAULT_VERIFY_TIMEOUT_MS;
7429
7451
  const vr = await spawnCmd(ctx, ctx.manifest.spec.verify.cmd, [], verifyTimeoutMs, {
7430
- posixShell: true
7452
+ posixShell: true,
7453
+ neutralCwd: true
7431
7454
  });
7432
7455
  if (!("exitCode" in vr)) return { ...vr, backupId: bk.backupId };
7433
7456
  const expected = ctx.manifest.spec.verify.expected_exit_code ?? 0;
@@ -8122,7 +8145,12 @@ async function runAutoInstall(opts) {
8122
8145
  // Windows needs shell for `.cmd` / `.bat` exes (npx.cmd / claude.cmd
8123
8146
  // shims); Unix is fine either way. Pass-through to OS shell handles
8124
8147
  // PATH resolution + extension lookup.
8125
- shell: true
8148
+ shell: true,
8149
+ // v4.20.1 — neutral cwd: install commands are global-semantics; the
8150
+ // user's shell cwd may carry an ambient devEngines package.json that
8151
+ // kills every npx-based command (EBADDEVENGINES dogfood). Fail-open to
8152
+ // inherited cwd when neutral resolution is unavailable.
8153
+ cwd: getNeutralSpawnCwd() ?? void 0
8126
8154
  });
8127
8155
  if (r.status !== 0) {
8128
8156
  const reason = r.error !== void 0 ? `spawn error on \`${cmd}\`: ${r.error.message}` : `exit ${r.status ?? "<unknown>"} on \`${cmd}\``;
@@ -8157,6 +8185,7 @@ Auto-install summary: ${out.installed.length} installed / ${out.skipped.length}
8157
8185
  }
8158
8186
  var init_auto_install = __esm({
8159
8187
  "src/cli/lib/auto-install.ts"() {
8188
+ init_safeCwd();
8160
8189
  init_doctor_registry();
8161
8190
  }
8162
8191
  });