harnessed 4.32.7 → 4.32.9

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.32.7",
41
+ version: "4.32.9",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -548,9 +548,6 @@ __export(workflowStore_exports, {
548
548
  function storePath() {
549
549
  return harnessedFile("workflows.json");
550
550
  }
551
- function legacyPath() {
552
- return harnessedFile("current-workflow.json");
553
- }
554
551
  function emptyStore() {
555
552
  return { schemaVersion: SCHEMA_VERSIONS.workflowStore, workflows: {} };
556
553
  }
@@ -576,16 +573,6 @@ async function readStoreRaw() {
576
573
  if (Value.Check(WorkflowStoreV1, parsed)) return parsed;
577
574
  } catch {
578
575
  }
579
- try {
580
- const legacy = JSON.parse(await readFile(legacyPath(), "utf8"));
581
- if (Value.Check(CurrentWorkflowV1, legacy)) {
582
- return {
583
- schemaVersion: SCHEMA_VERSIONS.workflowStore,
584
- workflows: { [repoKey()]: legacy }
585
- };
586
- }
587
- } catch {
588
- }
589
576
  return emptyStore();
590
577
  }
591
578
  async function writeStoreRaw(store) {
@@ -3109,7 +3096,7 @@ function buildOrchestratorBody(name, prompt) {
3109
3096
  ``,
3110
3097
  `- Generated by \`harnessed setup\`. Re-run after a harnessed upgrade to refresh.`,
3111
3098
  `- gate/discipline SoT: \`workflows/${nameToYamlHintPath(name)}\` + \`workflows/judgments/\` \u2014 consumed by \`harnessed gates\` + \`harnessed prompt\`.`,
3112
- `- The per-sub ledger + evidence guard live in \`current-workflow.json\` (sole SoT) \u2014 written only by \`harnessed checkpoint\`; never edit state files directly.`,
3099
+ `- The per-sub ledger + evidence guard live in \`workflows.json\` (per-repo store, sole SoT) \u2014 written only by \`harnessed checkpoint\`; never edit state files directly.`,
3113
3100
  ``,
3114
3101
  MARKER,
3115
3102
  ``
@@ -5359,13 +5346,13 @@ async function runCheckpointStart(sub, opts, deps = defaultRunDeps) {
5359
5346
  const { activatePhase: activatePhase2 } = await Promise.resolve().then(() => (init_engineHook(), engineHook_exports));
5360
5347
  try {
5361
5348
  const { stat: statFs } = await import('fs/promises');
5362
- const { resolve: resolvePath } = await import('path');
5363
- const planningDir = resolvePath(process.cwd(), ".planning");
5349
+ const { resolve: resolvePath2 } = await import('path');
5350
+ const planningDir = resolvePath2(process.cwd(), ".planning");
5364
5351
  const hasPlanning = await statFs(planningDir).then((s) => s.isDirectory()).catch(() => false);
5365
5352
  if (hasPlanning) {
5366
5353
  const missing = [];
5367
5354
  for (const f of ["STATE.md", "ROADMAP.md"]) {
5368
- const ok = await statFs(resolvePath(planningDir, f)).then((s) => s.isFile()).catch(() => false);
5355
+ const ok = await statFs(resolvePath2(planningDir, f)).then((s) => s.isFile()).catch(() => false);
5369
5356
  if (!ok) missing.push(`.planning/${f}`);
5370
5357
  }
5371
5358
  if (missing.length > 0) {
@@ -10983,9 +10970,9 @@ function redactRecord(r) {
10983
10970
  }
10984
10971
  function renderHumanTable(records) {
10985
10972
  const header = `${"ts".padEnd(19)} | ${"phase".padEnd(6)} | ${"category".padEnd(11)} | ${"matched_rule_id".padEnd(20)} | outcome`;
10986
- const sep2 = `${"-".repeat(19)}-+-${"-".repeat(6)}-+-${"-".repeat(11)}-+-${"-".repeat(20)}-+--------`;
10973
+ const sep3 = `${"-".repeat(19)}-+-${"-".repeat(6)}-+-${"-".repeat(11)}-+-${"-".repeat(20)}-+--------`;
10987
10974
  console.log(header);
10988
- console.log(sep2);
10975
+ console.log(sep3);
10989
10976
  for (const r of records) {
10990
10977
  const ts = r.ts.slice(0, 19);
10991
10978
  const phase = r.phase.padEnd(6);
@@ -13689,6 +13676,77 @@ var uninstallGitCloneWithSetup = async (ctx) => {
13689
13676
  return { ok: true, removedPaths: [cloneTarget] };
13690
13677
  };
13691
13678
 
13679
+ // src/uninstallers/lib/declaredTeardown.ts
13680
+ init_spawn();
13681
+ init_path_guard();
13682
+ function hasDeclaredUninstall(ctx) {
13683
+ return ctx.manifest.spec.uninstall != null;
13684
+ }
13685
+ function expandTilde(p7) {
13686
+ if (p7 === "~") return homedir();
13687
+ if (p7.startsWith("~/") || p7.startsWith("~\\")) return homedir() + p7.slice(1);
13688
+ return p7;
13689
+ }
13690
+ function confineCleanupPath(raw) {
13691
+ checkPathSafe(raw);
13692
+ const expanded = expandTilde(raw);
13693
+ const abs = isAbsolute(expanded) ? resolve(expanded) : resolve(homedir(), expanded);
13694
+ const home = resolve(homedir());
13695
+ if (abs === home) return null;
13696
+ if (!abs.startsWith(home + sep)) return null;
13697
+ return abs;
13698
+ }
13699
+ async function runDeclaredTeardown(ctx) {
13700
+ const u = ctx.manifest.spec.uninstall;
13701
+ if (!u) return { ok: false, phase: "preflight", error: "no declared uninstall contract" };
13702
+ const abort = dryRunGate(ctx);
13703
+ if (abort) return abort;
13704
+ const confined = [];
13705
+ for (const raw of u.cleanup_paths ?? []) {
13706
+ let abs;
13707
+ try {
13708
+ abs = confineCleanupPath(raw);
13709
+ } catch {
13710
+ return {
13711
+ ok: false,
13712
+ phase: "preflight",
13713
+ error: `refusing to remove cleanup_path (path traversal): ${raw}`
13714
+ };
13715
+ }
13716
+ if (abs === null) {
13717
+ return {
13718
+ ok: false,
13719
+ phase: "preflight",
13720
+ error: `refusing to remove cleanup_path outside $HOME: ${raw}`
13721
+ };
13722
+ }
13723
+ confined.push(abs);
13724
+ }
13725
+ const spawnCtx = {
13726
+ manifest: ctx.manifest,
13727
+ cwd: ctx.cwd};
13728
+ const spawnRes = await spawnCmd(spawnCtx, u.cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, {
13729
+ posixShell: true
13730
+ });
13731
+ const name = ctx.manifest.metadata.name;
13732
+ if (!("exitCode" in spawnRes)) {
13733
+ const msg = "error" in spawnRes ? spawnRes.error.message : "unknown spawn failure";
13734
+ console.warn(
13735
+ `declared uninstall cmd for '${name}' could not run (${msg}); continuing to cleanup_paths (best-effort teardown).`
13736
+ );
13737
+ } else if (spawnRes.exitCode !== 0) {
13738
+ console.warn(
13739
+ `declared uninstall cmd for '${name}' exited ${spawnRes.exitCode} (best-effort teardown; continuing to cleanup_paths): ` + (spawnRes.stderr || spawnRes.stdout || "(no output)").slice(0, 200)
13740
+ );
13741
+ }
13742
+ const removedPaths = [];
13743
+ for (const abs of confined) {
13744
+ await rm(abs, { recursive: true, force: true, maxRetries: 3 });
13745
+ removedPaths.push(abs);
13746
+ }
13747
+ return { ok: true, removedPaths };
13748
+ }
13749
+
13692
13750
  // src/uninstallers/mcpHttpAdd.ts
13693
13751
  init_platform();
13694
13752
  init_runClaudeArgs();
@@ -13807,9 +13865,19 @@ var uninstallers = {
13807
13865
  "npx-skill-installer": uninstallNpxSkillInstaller,
13808
13866
  "cc-hook-add": uninstallCcHookAdd
13809
13867
  };
13868
+ var DECLARED_TEARDOWN_METHODS = /* @__PURE__ */ new Set([
13869
+ "npm-cli",
13870
+ "git-clone-with-setup",
13871
+ "npx-skill-installer"
13872
+ ]);
13810
13873
  async function runUninstall(manifest, opts) {
13811
- const uninstaller = uninstallers[manifest.spec.install.method];
13812
- return uninstaller({ manifest, opts, cwd: process.cwd() });
13874
+ const ctx = { manifest, opts, cwd: process.cwd() };
13875
+ const method = manifest.spec.install.method;
13876
+ if (DECLARED_TEARDOWN_METHODS.has(method) && hasDeclaredUninstall(ctx)) {
13877
+ return runDeclaredTeardown(ctx);
13878
+ }
13879
+ const uninstaller = uninstallers[method];
13880
+ return uninstaller(ctx);
13813
13881
  }
13814
13882
 
13815
13883
  // src/cli/uninstall.ts