harnessed 4.32.3 → 4.32.5

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/README.md CHANGED
@@ -501,7 +501,7 @@ planning-with-files /plan (cross-cutting tool) → write artifacts to .planning/
501
501
  | `harnessed run <name>` | Run a workflow via in-process SDK spawn (CI/headless mode). Slash commands use CC-native spawn instead. |
502
502
  | `harnessed resume` | Resume from the most recent checkpoint after a session interruption |
503
503
  | `harnessed status` | Current phase + lock holder |
504
- | `harnessed doctor` | Health check (Node / MCP / jq / Win bash / routing / token budget / skill integrity / GateGuard conflict / update-available, etc.) |
504
+ | `harnessed doctor` | Health check (Node / MCP / jq / Win bash / routing / token budget / skill integrity / GateGuard conflict / update-available / stale hooks, etc.). The **stale hooks** check flags orphaned harnessed `Stop`/`UserPromptSubmit` entries in `~/.claude/settings.json` that point at a deleted `bin/*.mjs` — the cause of a `MODULE_NOT_FOUND` error on every prompt after a raw `npm uninstall -g harnessed`. Fix: run `harnessed uninstall` (it strips them) **before** removing the package. |
505
505
  | `harnessed update [--check\|--upstreams\|--migration-report]` | Self-update, channel-aware: binary installs replace themselves in place from GitHub releases (sha256-verified, previous version kept for rollback); npm installs run `npm i -g harnessed@latest`. `--check` reports the latest version; `--upstreams` re-runs the base manifests; `--migration-report` is a read-only stale-state inventory |
506
506
  | `harnessed release-preflight` | Read-only release-readiness gate (CHANGELOG `[Unreleased]` / version / git-clean / tag-absent); exits 1 if not ready. The Ship-stage gate. |
507
507
  | `harnessed retro --done` | Reset the retro-reminder phase counter after running `/retro` (clears the per-turn RETRO-DUE nudge). |
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, realpathSync, mkdtempSync, utimesSync, rmSync, statSync } from 'fs';
3
3
  import { homedir, tmpdir } from 'os';
4
- import { join, resolve, dirname, basename, sep, isAbsolute, win32, relative } from 'path';
4
+ import { join, resolve, dirname, basename, sep, isAbsolute, win32, posix, relative } from 'path';
5
5
  import { Type } from '@sinclair/typebox';
6
6
  import { readFile, readdir, unlink, writeFile, stat, rm, cp, mkdir, access, rename, appendFile, copyFile, chmod } from 'fs/promises';
7
7
  import { Value } from '@sinclair/typebox/value';
@@ -38,7 +38,7 @@ var init_package = __esm({
38
38
  "package.json"() {
39
39
  package_default = {
40
40
  name: "harnessed",
41
- version: "4.32.3",
41
+ version: "4.32.5",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -1858,6 +1858,7 @@ var init_en = __esm({
1858
1858
  "uninstall.unified.commands": " Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/",
1859
1859
  "uninstall.unified.skills": " Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/",
1860
1860
  "uninstall.unified.settings": " Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json",
1861
+ "uninstall.unified.hooks": " Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json",
1861
1862
  "uninstall.unified.state_dir": " State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)",
1862
1863
  "uninstall.unified.upstream_note": "\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.",
1863
1864
  "uninstall.unified.dry_run_hint": "\n(dry-run \u2014 re-run without --dry-run to actually remove)",
@@ -1866,6 +1867,7 @@ var init_en = __esm({
1866
1867
  "uninstall.unified.removed_commands": " removed {{count}} command file(s)",
1867
1868
  "uninstall.unified.removed_skills": " removed {{count}} skill directory(ies)",
1868
1869
  "uninstall.unified.removed_settings": " removed harnessed env vars from ~/.claude/settings.json",
1870
+ "uninstall.unified.removed_hooks": " removed {{count}} harnessed hook(s) from ~/.claude/settings.json",
1869
1871
  "uninstall.unified.removed_state_dir": " removed ~/.claude/harnessed/",
1870
1872
  "uninstall.unified.partial_failure": "\n{{count}} item(s) could not be removed (permission denied or already gone):",
1871
1873
  "uninstall.unified.complete": "uninstall complete \u2014 harnessed's own files have been removed",
@@ -3181,7 +3183,7 @@ function nameToYamlHintPath(name) {
3181
3183
  function shouldOverwriteFile(content) {
3182
3184
  return HARNESSED_MARKER_RX.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
3183
3185
  }
3184
- async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync19 = (p7) => readFileSync(p7, "utf8")) {
3186
+ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync20 = (p7) => readFileSync(p7, "utf8")) {
3185
3187
  const results = [];
3186
3188
  const aggregatedWarnings = /* @__PURE__ */ new Set();
3187
3189
  for (const name of slashNames) {
@@ -3200,7 +3202,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
3200
3202
  if (fileExists2(path)) {
3201
3203
  let existing = "";
3202
3204
  try {
3203
- existing = readFileSync19(path);
3205
+ existing = readFileSync20(path);
3204
3206
  } catch {
3205
3207
  existing = "";
3206
3208
  }
@@ -6843,6 +6845,213 @@ var init_check_update = __esm({
6843
6845
  }
6844
6846
  });
6845
6847
 
6848
+ // src/cli/lib/check-install-channels.ts
6849
+ var check_install_channels_exports = {};
6850
+ __export(check_install_channels_exports, {
6851
+ checkInstallChannels: () => checkInstallChannels,
6852
+ detectInstallChannels: () => detectInstallChannels,
6853
+ dualChannelLines: () => dualChannelLines
6854
+ });
6855
+ function joinFor(platform) {
6856
+ return platform === "win32" ? win32.join : posix.join;
6857
+ }
6858
+ function realNpmPrefix() {
6859
+ try {
6860
+ if (typeof spawnSync !== "function") return null;
6861
+ const r = spawnSync("npm", ["prefix", "-g"], { encoding: "utf8", timeout: 5e3 });
6862
+ if (!r || r.error || r.status !== 0) return null;
6863
+ const out = (r.stdout ?? "").trim();
6864
+ return out.length > 0 ? out : null;
6865
+ } catch {
6866
+ return null;
6867
+ }
6868
+ }
6869
+ function binaryCandidate(platform, home, env) {
6870
+ const j = joinFor(platform);
6871
+ if (platform === "win32") {
6872
+ const local = env.LOCALAPPDATA ?? j(home, "AppData", "Local");
6873
+ return j(local, "harnessed", "bin", "harnessed.exe");
6874
+ }
6875
+ return j(home, ".local", "bin", "harnessed");
6876
+ }
6877
+ function npmCandidate(platform, prefix) {
6878
+ const j = joinFor(platform);
6879
+ return platform === "win32" ? j(prefix, "harnessed.cmd") : j(prefix, "bin", "harnessed");
6880
+ }
6881
+ function detectInstallChannels(deps) {
6882
+ const platform = deps?.platform ?? process.platform;
6883
+ const home = deps?.home ?? homedir();
6884
+ const env = deps?.env ?? process.env;
6885
+ const execPath = deps?.execPath ?? process.execPath;
6886
+ const exists = deps?.exists ?? existsSync;
6887
+ const npmPrefix = deps?.npmPrefix ?? realNpmPrefix;
6888
+ const running = deps?.running ?? (isCompiledRuntime() ? "binary" : "npm");
6889
+ const binCand = binaryCandidate(platform, home, env);
6890
+ const binaryPresent = running === "binary" || exists(binCand);
6891
+ const binaryPath = running === "binary" ? execPath : binaryPresent ? binCand : null;
6892
+ const prefix = npmPrefix();
6893
+ const npmCand = prefix ? npmCandidate(platform, prefix) : null;
6894
+ const npmPresent = running === "npm" || npmCand != null && exists(npmCand);
6895
+ const npmPath = npmCand != null && exists(npmCand) ? npmCand : null;
6896
+ return { binaryPath, npmPath, running, both: binaryPresent && npmPresent };
6897
+ }
6898
+ function dualChannelLines(r) {
6899
+ if (!r.both) return [];
6900
+ const bin = r.binaryPath ?? "the standalone binary";
6901
+ const npm = r.npmPath ?? "the npm-global package";
6902
+ return [
6903
+ "both harnessed install channels are present \u2014 a bare `harnessed` uses whichever",
6904
+ "is earlier on PATH, and updating one leaves the other stale:",
6905
+ ` binary: ${bin}`,
6906
+ ` npm: ${npm}`,
6907
+ `you are running the ${r.running} one. pick a single channel:`,
6908
+ " keep npm \u2192 update with `npm install -g harnessed@latest`; delete the binary + remove its bin dir from PATH",
6909
+ " keep binary \u2192 update with `harnessed update`; then `npm uninstall -g harnessed`"
6910
+ ];
6911
+ }
6912
+ function checkInstallChannels(deps) {
6913
+ const r = detectInstallChannels(deps);
6914
+ if (!r.both) {
6915
+ return {
6916
+ name: "install channel",
6917
+ status: "pass",
6918
+ message: `single channel (${r.running})`
6919
+ };
6920
+ }
6921
+ return {
6922
+ name: "install channel",
6923
+ status: "warn",
6924
+ message: `both npm-global and standalone-binary harnessed are installed (running the ${r.running} one) \u2014 updating one leaves the other stale`,
6925
+ fix: `pick one: keep npm \u2192 'npm install -g harnessed@latest' + delete ${r.binaryPath ?? "the binary"} (and remove its bin dir from PATH); or keep binary \u2192 'harnessed update' + 'npm uninstall -g harnessed'`
6926
+ };
6927
+ }
6928
+ var init_check_install_channels = __esm({
6929
+ "src/cli/lib/check-install-channels.ts"() {
6930
+ init_assetsRoot();
6931
+ }
6932
+ });
6933
+
6934
+ // src/installers/lib/harnessedHookTeardown.ts
6935
+ function harnessedHookIdentity(raw) {
6936
+ for (const id of IDS) {
6937
+ if (new RegExp(`harnessed-${id}\\.mjs(?:["']|\\s|$)`).test(raw)) return id;
6938
+ if (new RegExp(`harnessed(?:\\.exe)?["']?\\s+${id}(?:\\s|$)`).test(raw)) return id;
6939
+ }
6940
+ return null;
6941
+ }
6942
+ function harnessedHookScriptPath(raw) {
6943
+ const mjs = raw.match(/["']?([^"'\s]*harnessed-(?:inject-state|stop-hook)\.mjs)["']?/);
6944
+ if (mjs?.[1]) return mjs[1];
6945
+ const quotedBin = raw.match(/["']([^"']*harnessed(?:\.exe)?)["']\s+(?:inject-state|stop-hook)\b/);
6946
+ if (quotedBin?.[1]) return quotedBin[1];
6947
+ const bareBin = raw.match(/(?:^|\s)(harnessed(?:\.exe)?)\s+(?:inject-state|stop-hook)\b/);
6948
+ if (bareBin?.[1]) return bareBin[1];
6949
+ return null;
6950
+ }
6951
+ function entryCommands(entry) {
6952
+ const cmds = [];
6953
+ if (typeof entry.command === "string") cmds.push(entry.command);
6954
+ if (Array.isArray(entry.hooks)) {
6955
+ for (const h of entry.hooks) if (h && typeof h.command === "string") cmds.push(h.command);
6956
+ }
6957
+ return cmds;
6958
+ }
6959
+ function entryIsHarnessed(entry) {
6960
+ return entryCommands(entry).some((c) => harnessedHookIdentity(c) !== null);
6961
+ }
6962
+ function stripHarnessedHooks(hooks) {
6963
+ let removed = 0;
6964
+ for (const ev of Object.keys(hooks)) {
6965
+ const arr = hooks[ev];
6966
+ if (!Array.isArray(arr)) continue;
6967
+ const kept = arr.filter((entry) => {
6968
+ const owned = entryIsHarnessed(entry);
6969
+ if (owned) removed++;
6970
+ return !owned;
6971
+ });
6972
+ if (kept.length === 0) delete hooks[ev];
6973
+ else hooks[ev] = kept;
6974
+ }
6975
+ return { removed };
6976
+ }
6977
+ function countHarnessedHooks(hooks) {
6978
+ let n = 0;
6979
+ for (const arr of Object.values(hooks)) {
6980
+ if (!Array.isArray(arr)) continue;
6981
+ for (const entry of arr) if (entryIsHarnessed(entry)) n++;
6982
+ }
6983
+ return n;
6984
+ }
6985
+ function harnessedStaleHookPaths(hooks, exists) {
6986
+ const out = [];
6987
+ for (const [event, arr] of Object.entries(hooks)) {
6988
+ if (!Array.isArray(arr)) continue;
6989
+ for (const entry of arr) {
6990
+ for (const cmd of entryCommands(entry)) {
6991
+ if (harnessedHookIdentity(cmd) === null) continue;
6992
+ const path = harnessedHookScriptPath(cmd);
6993
+ if (path && ABSOLUTE_RE.test(path) && !exists(path)) out.push({ event, path });
6994
+ }
6995
+ }
6996
+ }
6997
+ return out;
6998
+ }
6999
+ var IDS, ABSOLUTE_RE;
7000
+ var init_harnessedHookTeardown = __esm({
7001
+ "src/installers/lib/harnessedHookTeardown.ts"() {
7002
+ IDS = ["inject-state", "stop-hook"];
7003
+ ABSOLUTE_RE = /^([A-Za-z]:[\\/]|[\\/])/;
7004
+ }
7005
+ });
7006
+
7007
+ // src/cli/lib/check-stale-hooks.ts
7008
+ var check_stale_hooks_exports = {};
7009
+ __export(check_stale_hooks_exports, {
7010
+ checkStaleHooks: () => checkStaleHooks
7011
+ });
7012
+ function checkStaleHooks(deps) {
7013
+ const settingsPath = deps?.settingsPath ?? getSettingsPath();
7014
+ const readText = deps?.readText ?? ((p7) => {
7015
+ try {
7016
+ return readFileSync(p7, "utf8");
7017
+ } catch {
7018
+ return null;
7019
+ }
7020
+ });
7021
+ const exists = deps?.exists ?? existsSync;
7022
+ const raw = readText(settingsPath);
7023
+ if (raw === null) return { name: NAME, status: "pass", message: "no settings.json" };
7024
+ let data;
7025
+ try {
7026
+ data = JSON.parse(raw);
7027
+ } catch {
7028
+ return { name: NAME, status: "pass", message: "settings.json unreadable \u2014 skipped" };
7029
+ }
7030
+ const hooks = data.hooks;
7031
+ if (!hooks || typeof hooks !== "object") {
7032
+ return { name: NAME, status: "pass", message: "no hooks registered" };
7033
+ }
7034
+ const stale = harnessedStaleHookPaths(hooks, exists);
7035
+ if (stale.length === 0) {
7036
+ return { name: NAME, status: "pass", message: "no orphaned harnessed hooks" };
7037
+ }
7038
+ const list = stale.map((s) => `${s.event} \u2192 ${s.path}`).join("; ");
7039
+ return {
7040
+ name: NAME,
7041
+ status: "warn",
7042
+ message: `${stale.length} harnessed hook(s) point at a deleted script \u2014 Claude Code errors MODULE_NOT_FOUND every prompt (${list})`,
7043
+ fix: `run 'harnessed uninstall' to strip them, or delete the matching Stop/UserPromptSubmit entries from ${settingsPath}`
7044
+ };
7045
+ }
7046
+ var NAME;
7047
+ var init_check_stale_hooks = __esm({
7048
+ "src/cli/lib/check-stale-hooks.ts"() {
7049
+ init_harnessedHookTeardown();
7050
+ init_platform();
7051
+ NAME = "stale hooks";
7052
+ }
7053
+ });
7054
+
6846
7055
  // src/cli/lib/doctor-registry.ts
6847
7056
  var CHECKS;
6848
7057
  var init_doctor_registry = __esm({
@@ -6883,7 +7092,14 @@ var init_doctor_registry = __esm({
6883
7092
  async () => (await Promise.resolve().then(() => (init_check_skill_integrity(), check_skill_integrity_exports))).checkSkillIntegrity(),
6884
7093
  // Phase 20 — "update available" version check ('warn' only when behind; 'pass'
6885
7094
  // when current/ahead/npm-unreachable — fail-soft, never flips the summary).
6886
- async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate()
7095
+ async () => (await Promise.resolve().then(() => (init_check_update(), check_update_exports))).checkUpdate(),
7096
+ // 4.32.4 — dual install-channel conflict (warn-only): npm-global + standalone
7097
+ // binary both present → ambiguous PATH resolution + stale-update trap.
7098
+ async () => (await Promise.resolve().then(() => (init_check_install_channels(), check_install_channels_exports))).checkInstallChannels(),
7099
+ // issue #8 — orphaned harnessed Stop/UserPromptSubmit hooks (warn-only): a hook
7100
+ // pointing at a deleted bin/*.mjs makes Claude Code error MODULE_NOT_FOUND every
7101
+ // prompt; `harnessed uninstall` now strips them.
7102
+ async () => (await Promise.resolve().then(() => (init_check_stale_hooks(), check_stale_hooks_exports))).checkStaleHooks()
6887
7103
  ];
6888
7104
  }
6889
7105
  });
@@ -7347,7 +7563,7 @@ var init_err = __esm({
7347
7563
  });
7348
7564
  function isRelativeFileToken(token) {
7349
7565
  if (!/[\\/]/.test(token)) return false;
7350
- if (ABSOLUTE_RE.test(token)) return false;
7566
+ if (ABSOLUTE_RE2.test(token)) return false;
7351
7567
  if (/[*?$`]/.test(token)) return false;
7352
7568
  return true;
7353
7569
  }
@@ -7391,7 +7607,7 @@ function hookScriptMarker(raw) {
7391
7607
  }
7392
7608
  return null;
7393
7609
  }
7394
- function entryCommands(entry) {
7610
+ function entryCommands2(entry) {
7395
7611
  const cmds = [];
7396
7612
  if (typeof entry.command === "string") cmds.push(entry.command);
7397
7613
  if (Array.isArray(entry.hooks)) {
@@ -7402,7 +7618,7 @@ function entryCommands(entry) {
7402
7618
  return cmds;
7403
7619
  }
7404
7620
  function entryMatchesRegistration(entry, raw, resolved, marker) {
7405
- const cmds = entryCommands(entry);
7621
+ const cmds = entryCommands2(entry);
7406
7622
  if (cmds.length === 0) return false;
7407
7623
  if (marker) return cmds.some((c) => c.includes(marker));
7408
7624
  return cmds.some((c) => c === raw || c === resolved);
@@ -7435,11 +7651,11 @@ function detectCcHookInstalled(settingsRaw, ev, raw, matcher, deps) {
7435
7651
  const matching = arr.filter((e) => entryMatchesRegistration(e, raw, resolved, marker));
7436
7652
  return matching.length === 1 && isDesiredHookEntry(matching[0] ?? {}, matcher, resolved);
7437
7653
  }
7438
- var COMPILED_HOOK_IDENTITIES, ABSOLUTE_RE;
7654
+ var COMPILED_HOOK_IDENTITIES, ABSOLUTE_RE2;
7439
7655
  var init_hookEntry = __esm({
7440
7656
  "src/installers/lib/hookEntry.ts"() {
7441
7657
  COMPILED_HOOK_IDENTITIES = ["inject-state", "stop-hook"];
7442
- ABSOLUTE_RE = /^([A-Za-z]:[\\/]|[\\/])/;
7658
+ ABSOLUTE_RE2 = /^([A-Za-z]:[\\/]|[\\/])/;
7443
7659
  }
7444
7660
  });
7445
7661
 
@@ -13201,6 +13417,12 @@ ${b.failed.length} component(s) failed \u2014 see the notes in the tables above;
13201
13417
  console.log(t("setup.bundled_summary"));
13202
13418
  console.log(t("setup.bundled_location"));
13203
13419
  console.log(t("setup.doctor_hint"));
13420
+ const { detectInstallChannels: detectInstallChannels2, dualChannelLines: dualChannelLines2 } = await Promise.resolve().then(() => (init_check_install_channels(), check_install_channels_exports));
13421
+ const channels = detectInstallChannels2();
13422
+ if (channels.both) {
13423
+ console.log("");
13424
+ for (const line of dualChannelLines2(channels)) console.log(line);
13425
+ }
13204
13426
  if (!dryRun) {
13205
13427
  const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
13206
13428
  const { runAutoInstall: runAutoInstall2 } = await Promise.resolve().then(() => (init_auto_install(), auto_install_exports));
@@ -13297,6 +13519,7 @@ function registerStopHook(program2) {
13297
13519
 
13298
13520
  // src/cli/uninstall.ts
13299
13521
  init_i18n();
13522
+ init_harnessedHookTeardown();
13300
13523
  init_harnessedRoot();
13301
13524
  init_platform();
13302
13525
  init_path_guard();
@@ -13595,33 +13818,42 @@ async function checkSettingsEnv(settingsPath) {
13595
13818
  const raw = await readFile(settingsPath, "utf8");
13596
13819
  const data = JSON.parse(raw);
13597
13820
  const env = data.env ?? {};
13821
+ const hooks = data.hooks;
13598
13822
  return {
13599
13823
  hasAgentTeams: "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS" in env,
13600
- hasUserLang: "HARNESSED_USER_LANG" in env
13824
+ hasUserLang: "HARNESSED_USER_LANG" in env,
13825
+ // issue #8 — count orphaned harnessed-owned Stop/UserPromptSubmit hooks.
13826
+ staleHooks: hooks && typeof hooks === "object" ? countHarnessedHooks(hooks) : 0
13601
13827
  };
13602
13828
  } catch {
13603
- return { hasAgentTeams: false, hasUserLang: false };
13829
+ return { hasAgentTeams: false, hasUserLang: false, staleHooks: 0 };
13604
13830
  }
13605
13831
  }
13606
- async function removeSettingsEnv(settingsPath) {
13832
+ async function removeSettingsFootprint(settingsPath) {
13607
13833
  const raw = await readFile(settingsPath, "utf8");
13608
13834
  const data = JSON.parse(raw);
13609
13835
  const env = data.env ?? {};
13610
- let changed = false;
13836
+ let envRemoved = false;
13611
13837
  if ("CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS" in env) {
13612
13838
  delete env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
13613
- changed = true;
13839
+ envRemoved = true;
13614
13840
  }
13615
13841
  if ("HARNESSED_USER_LANG" in env) {
13616
13842
  delete env.HARNESSED_USER_LANG;
13617
- changed = true;
13843
+ envRemoved = true;
13618
13844
  }
13619
- if (!changed) return false;
13845
+ let hooksRemoved = 0;
13846
+ const hooks = data.hooks;
13847
+ if (hooks && typeof hooks === "object") {
13848
+ hooksRemoved = stripHarnessedHooks(hooks).removed;
13849
+ if (Object.keys(hooks).length === 0) delete data.hooks;
13850
+ }
13851
+ if (!envRemoved && hooksRemoved === 0) return { envRemoved: false, hooksRemoved: 0 };
13620
13852
  if (Object.keys(env).length === 0) delete data.env;
13621
13853
  else data.env = env;
13622
13854
  await writeFile(settingsPath, `${JSON.stringify(data, null, 2)}
13623
13855
  `, "utf8");
13624
- return true;
13856
+ return { envRemoved, hooksRemoved };
13625
13857
  }
13626
13858
  function printCliRemovalHint() {
13627
13859
  console.log(t("uninstall.unified.cli_hint_header"));
@@ -13654,6 +13886,7 @@ async function runUnifiedUninstall(home, dryRun) {
13654
13886
  const commandFiles = await discoverCommandFiles(commandsDir);
13655
13887
  const settingsEnv = await checkSettingsEnv(settingsPath);
13656
13888
  const hasSettingsChanges = settingsEnv.hasAgentTeams || settingsEnv.hasUserLang;
13889
+ const staleHooks = settingsEnv.staleHooks;
13657
13890
  const skillDirs = [];
13658
13891
  for (const name of workflowNames) {
13659
13892
  const dir = join(skillsDir, name);
@@ -13663,7 +13896,7 @@ async function runUnifiedUninstall(home, dryRun) {
13663
13896
  } catch {
13664
13897
  }
13665
13898
  }
13666
- const discoverable = commandFiles.length + skillDirs.length + (hasSettingsChanges ? 1 : 0);
13899
+ const discoverable = commandFiles.length + skillDirs.length + (hasSettingsChanges ? 1 : 0) + (staleHooks > 0 ? 1 : 0);
13667
13900
  if (discoverable === 0) {
13668
13901
  console.log(t("uninstall.unified.nothing"));
13669
13902
  printCliRemovalHint();
@@ -13674,6 +13907,7 @@ async function runUnifiedUninstall(home, dryRun) {
13674
13907
  console.log(t("uninstall.unified.commands", { count: commandFiles.length }));
13675
13908
  if (skillDirs.length > 0) console.log(t("uninstall.unified.skills", { count: skillDirs.length }));
13676
13909
  if (hasSettingsChanges) console.log(t("uninstall.unified.settings"));
13910
+ if (staleHooks > 0) console.log(t("uninstall.unified.hooks", { count: staleHooks }));
13677
13911
  console.log(t("uninstall.unified.state_dir"));
13678
13912
  console.log(t("uninstall.unified.upstream_note"));
13679
13913
  if (dryRun) {
@@ -13710,9 +13944,12 @@ async function runUnifiedUninstall(home, dryRun) {
13710
13944
  }
13711
13945
  }
13712
13946
  let removedSettings = false;
13713
- if (hasSettingsChanges) {
13947
+ let removedHooks = 0;
13948
+ if (hasSettingsChanges || staleHooks > 0) {
13714
13949
  try {
13715
- removedSettings = await removeSettingsEnv(settingsPath);
13950
+ const r = await removeSettingsFootprint(settingsPath);
13951
+ removedSettings = r.envRemoved;
13952
+ removedHooks = r.hooksRemoved;
13716
13953
  } catch (e) {
13717
13954
  failures.push(`${settingsPath}: ${e.message}`);
13718
13955
  }
@@ -13735,6 +13972,7 @@ async function runUnifiedUninstall(home, dryRun) {
13735
13972
  if (removedSkills > 0)
13736
13973
  console.log(t("uninstall.unified.removed_skills", { count: removedSkills }));
13737
13974
  if (removedSettings) console.log(t("uninstall.unified.removed_settings"));
13975
+ if (removedHooks > 0) console.log(t("uninstall.unified.removed_hooks", { count: removedHooks }));
13738
13976
  if (removedStateDir) console.log(t("uninstall.unified.removed_state_dir"));
13739
13977
  if (failures.length > 0) {
13740
13978
  console.error(t("uninstall.unified.partial_failure", { count: failures.length }));