harnessed 4.32.7 → 4.32.8

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.8",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -5359,13 +5359,13 @@ async function runCheckpointStart(sub, opts, deps = defaultRunDeps) {
5359
5359
  const { activatePhase: activatePhase2 } = await Promise.resolve().then(() => (init_engineHook(), engineHook_exports));
5360
5360
  try {
5361
5361
  const { stat: statFs } = await import('fs/promises');
5362
- const { resolve: resolvePath } = await import('path');
5363
- const planningDir = resolvePath(process.cwd(), ".planning");
5362
+ const { resolve: resolvePath2 } = await import('path');
5363
+ const planningDir = resolvePath2(process.cwd(), ".planning");
5364
5364
  const hasPlanning = await statFs(planningDir).then((s) => s.isDirectory()).catch(() => false);
5365
5365
  if (hasPlanning) {
5366
5366
  const missing = [];
5367
5367
  for (const f of ["STATE.md", "ROADMAP.md"]) {
5368
- const ok = await statFs(resolvePath(planningDir, f)).then((s) => s.isFile()).catch(() => false);
5368
+ const ok = await statFs(resolvePath2(planningDir, f)).then((s) => s.isFile()).catch(() => false);
5369
5369
  if (!ok) missing.push(`.planning/${f}`);
5370
5370
  }
5371
5371
  if (missing.length > 0) {
@@ -10983,9 +10983,9 @@ function redactRecord(r) {
10983
10983
  }
10984
10984
  function renderHumanTable(records) {
10985
10985
  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)}-+--------`;
10986
+ const sep3 = `${"-".repeat(19)}-+-${"-".repeat(6)}-+-${"-".repeat(11)}-+-${"-".repeat(20)}-+--------`;
10987
10987
  console.log(header);
10988
- console.log(sep2);
10988
+ console.log(sep3);
10989
10989
  for (const r of records) {
10990
10990
  const ts = r.ts.slice(0, 19);
10991
10991
  const phase = r.phase.padEnd(6);
@@ -13689,6 +13689,77 @@ var uninstallGitCloneWithSetup = async (ctx) => {
13689
13689
  return { ok: true, removedPaths: [cloneTarget] };
13690
13690
  };
13691
13691
 
13692
+ // src/uninstallers/lib/declaredTeardown.ts
13693
+ init_spawn();
13694
+ init_path_guard();
13695
+ function hasDeclaredUninstall(ctx) {
13696
+ return ctx.manifest.spec.uninstall != null;
13697
+ }
13698
+ function expandTilde(p7) {
13699
+ if (p7 === "~") return homedir();
13700
+ if (p7.startsWith("~/") || p7.startsWith("~\\")) return homedir() + p7.slice(1);
13701
+ return p7;
13702
+ }
13703
+ function confineCleanupPath(raw) {
13704
+ checkPathSafe(raw);
13705
+ const expanded = expandTilde(raw);
13706
+ const abs = isAbsolute(expanded) ? resolve(expanded) : resolve(homedir(), expanded);
13707
+ const home = resolve(homedir());
13708
+ if (abs === home) return null;
13709
+ if (!abs.startsWith(home + sep)) return null;
13710
+ return abs;
13711
+ }
13712
+ async function runDeclaredTeardown(ctx) {
13713
+ const u = ctx.manifest.spec.uninstall;
13714
+ if (!u) return { ok: false, phase: "preflight", error: "no declared uninstall contract" };
13715
+ const abort = dryRunGate(ctx);
13716
+ if (abort) return abort;
13717
+ const confined = [];
13718
+ for (const raw of u.cleanup_paths ?? []) {
13719
+ let abs;
13720
+ try {
13721
+ abs = confineCleanupPath(raw);
13722
+ } catch {
13723
+ return {
13724
+ ok: false,
13725
+ phase: "preflight",
13726
+ error: `refusing to remove cleanup_path (path traversal): ${raw}`
13727
+ };
13728
+ }
13729
+ if (abs === null) {
13730
+ return {
13731
+ ok: false,
13732
+ phase: "preflight",
13733
+ error: `refusing to remove cleanup_path outside $HOME: ${raw}`
13734
+ };
13735
+ }
13736
+ confined.push(abs);
13737
+ }
13738
+ const spawnCtx = {
13739
+ manifest: ctx.manifest,
13740
+ cwd: ctx.cwd};
13741
+ const spawnRes = await spawnCmd(spawnCtx, u.cmd, [], DEFAULT_INSTALL_TIMEOUT_MS, {
13742
+ posixShell: true
13743
+ });
13744
+ const name = ctx.manifest.metadata.name;
13745
+ if (!("exitCode" in spawnRes)) {
13746
+ const msg = "error" in spawnRes ? spawnRes.error.message : "unknown spawn failure";
13747
+ console.warn(
13748
+ `declared uninstall cmd for '${name}' could not run (${msg}); continuing to cleanup_paths (best-effort teardown).`
13749
+ );
13750
+ } else if (spawnRes.exitCode !== 0) {
13751
+ console.warn(
13752
+ `declared uninstall cmd for '${name}' exited ${spawnRes.exitCode} (best-effort teardown; continuing to cleanup_paths): ` + (spawnRes.stderr || spawnRes.stdout || "(no output)").slice(0, 200)
13753
+ );
13754
+ }
13755
+ const removedPaths = [];
13756
+ for (const abs of confined) {
13757
+ await rm(abs, { recursive: true, force: true, maxRetries: 3 });
13758
+ removedPaths.push(abs);
13759
+ }
13760
+ return { ok: true, removedPaths };
13761
+ }
13762
+
13692
13763
  // src/uninstallers/mcpHttpAdd.ts
13693
13764
  init_platform();
13694
13765
  init_runClaudeArgs();
@@ -13807,9 +13878,19 @@ var uninstallers = {
13807
13878
  "npx-skill-installer": uninstallNpxSkillInstaller,
13808
13879
  "cc-hook-add": uninstallCcHookAdd
13809
13880
  };
13881
+ var DECLARED_TEARDOWN_METHODS = /* @__PURE__ */ new Set([
13882
+ "npm-cli",
13883
+ "git-clone-with-setup",
13884
+ "npx-skill-installer"
13885
+ ]);
13810
13886
  async function runUninstall(manifest, opts) {
13811
- const uninstaller = uninstallers[manifest.spec.install.method];
13812
- return uninstaller({ manifest, opts, cwd: process.cwd() });
13887
+ const ctx = { manifest, opts, cwd: process.cwd() };
13888
+ const method = manifest.spec.install.method;
13889
+ if (DECLARED_TEARDOWN_METHODS.has(method) && hasDeclaredUninstall(ctx)) {
13890
+ return runDeclaredTeardown(ctx);
13891
+ }
13892
+ const uninstaller = uninstallers[method];
13893
+ return uninstaller(ctx);
13813
13894
  }
13814
13895
 
13815
13896
  // src/cli/uninstall.ts