harnessed 5.0.13 → 5.0.15

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
@@ -42,7 +42,7 @@ var init_package = __esm({
42
42
  "package.json"() {
43
43
  package_default = {
44
44
  name: "harnessed",
45
- version: "5.0.13",
45
+ version: "5.0.15",
46
46
  description: "AI coding harness package manager + composition orchestrator",
47
47
  type: "module",
48
48
  license: "Apache-2.0",
@@ -95,7 +95,6 @@ var init_package = __esm({
95
95
  "schemas",
96
96
  "CHANGELOG.md",
97
97
  "README.md",
98
- "README-en.md",
99
98
  "README-zh.md",
100
99
  "LICENSE",
101
100
  "NOTICE",
@@ -2800,6 +2799,9 @@ var init_spec = __esm({
2800
2799
  );
2801
2800
  OwnershipRoot = Type.Union([
2802
2801
  Type.Literal("platform-skills"),
2802
+ // Phase 85 — the `skills` CLI installs into ~/.agents/skills by default and
2803
+ // links it into the host skills dir; the real files live here.
2804
+ Type.Literal("agents-skills"),
2803
2805
  Type.Literal("native-home"),
2804
2806
  Type.Literal("host-agents"),
2805
2807
  Type.Literal("host-commands")
@@ -14253,6 +14255,7 @@ async function runScenarioDir(dir, opts) {
14253
14255
  const prevRoot = process.env.HARNESSED_ROOT_OVERRIDE;
14254
14256
  const prevAssets = process.env.HARNESSED_ASSETS_OVERRIDE;
14255
14257
  const prevCeiling = process.env.GIT_CEILING_DIRECTORIES;
14258
+ const prevAgentTeams = process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
14256
14259
  const prevScenarioEnv = /* @__PURE__ */ new Map();
14257
14260
  const steps = [];
14258
14261
  const evaluatedGateRefs = /* @__PURE__ */ new Set();
@@ -14264,6 +14267,7 @@ async function runScenarioDir(dir, opts) {
14264
14267
  process.env[key] = value;
14265
14268
  }
14266
14269
  process.env.GIT_CEILING_DIRECTORIES = tmpdir();
14270
+ process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = "1";
14267
14271
  process.env.HARNESSED_ROOT_OVERRIDE = stateRoot;
14268
14272
  if (scenario.assets_dir) {
14269
14273
  process.env.HARNESSED_ASSETS_OVERRIDE = isAbsolute(scenario.assets_dir) ? scenario.assets_dir : resolve(dir, scenario.assets_dir);
@@ -14295,6 +14299,8 @@ async function runScenarioDir(dir, opts) {
14295
14299
  else process.env.HARNESSED_ASSETS_OVERRIDE = prevAssets;
14296
14300
  if (prevCeiling === void 0) delete process.env.GIT_CEILING_DIRECTORIES;
14297
14301
  else process.env.GIT_CEILING_DIRECTORIES = prevCeiling;
14302
+ if (prevAgentTeams === void 0) delete process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
14303
+ else process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = prevAgentTeams;
14298
14304
  for (const [key, prev] of prevScenarioEnv) {
14299
14305
  if (prev === void 0) delete process.env[key];
14300
14306
  else process.env[key] = prev;
@@ -16911,7 +16917,10 @@ var init_ccPluginMarketplace2 = __esm({
16911
16917
  const selectedPlugin = ctx.hostContext ? parseCmd(install.cmd)?.pluginAtMkt : void 0;
16912
16918
  const existingPlugin = ctx.hostContext && selectedPlugin ? await isPluginRegistered(selectedPlugin.split("@")[0] ?? selectedPlugin, ctx.hostContext) : false;
16913
16919
  const conflictingPlugin = ctx.hostContext && selectedPlugin && existingPlugin ? !await isPluginRegistered(selectedPlugin, ctx.hostContext) : false;
16914
- if (conflictingPlugin || ctx.hostContext && ctx.opts.updateInstalled && (existingPlugin || await isAlreadyInstalled(ctx, { honorUpdateFlag: false }))) {
16920
+ const qualifiedProven = Boolean(
16921
+ ctx.hostContext && existingPlugin && selectedPlugin && await isPluginRegistered(selectedPlugin, ctx.hostContext)
16922
+ );
16923
+ if (conflictingPlugin || ctx.hostContext && ctx.opts.updateInstalled && !qualifiedProven && (existingPlugin || await isAlreadyInstalled(ctx, { honorUpdateFlag: false }))) {
16915
16924
  return {
16916
16925
  ok: false,
16917
16926
  phase: "preflight",
@@ -16926,7 +16935,7 @@ var init_ccPluginMarketplace2 = __esm({
16926
16935
  }
16927
16936
  };
16928
16937
  }
16929
- if (existingPlugin || await isAlreadyInstalled(ctx)) {
16938
+ if (existingPlugin && !(ctx.opts.updateInstalled && qualifiedProven) || await isAlreadyInstalled(ctx)) {
16930
16939
  if (ctx.hostContext) {
16931
16940
  const parsed2 = parseCmd(install.cmd);
16932
16941
  if (!parsed2)
@@ -17888,6 +17897,52 @@ function unprovenCloneTarget(ctx) {
17888
17897
  }
17889
17898
  };
17890
17899
  }
17900
+ function normalizeGitUrl(url) {
17901
+ return url.replace(/\/+$/, "").replace(/\.git$/, "");
17902
+ }
17903
+ function extractCloneUrl(cmd) {
17904
+ const m = cmd.match(/\bgit\s+clone\s+((?:-{1,2}[\w-]+(?:\s+\S+)?\s+)*)(\S+)/);
17905
+ return m?.[2] ?? null;
17906
+ }
17907
+ function externalWriteTargets(cmd, destRaw) {
17908
+ const dest = destRaw.replace(/\/+$/, "");
17909
+ const inside = (target) => {
17910
+ const normalized2 = target.replace(/\/+$/, "");
17911
+ return normalized2 === dest || normalized2.startsWith(`${dest}/`);
17912
+ };
17913
+ const out = [];
17914
+ for (const segment of cmd.split(/\s*(?:&&|\|\||;|\|)\s*/)) {
17915
+ const tokens = segment.split(/\s+/).filter(Boolean);
17916
+ for (let index = 0; index < tokens.length; index++) {
17917
+ const token2 = tokens[index];
17918
+ if (token2 === "rm") {
17919
+ let next = index + 1;
17920
+ while (next < tokens.length && tokens[next].startsWith("-")) next++;
17921
+ const target = tokens[next];
17922
+ if (target && !inside(target)) out.push(target);
17923
+ index = next;
17924
+ continue;
17925
+ }
17926
+ if (token2 === "cp" || token2 === "mv" || token2 === "rsync") {
17927
+ const target = tokens[tokens.length - 1];
17928
+ if (target && target !== token2 && !inside(target)) out.push(target);
17929
+ index = tokens.length;
17930
+ }
17931
+ }
17932
+ }
17933
+ return out;
17934
+ }
17935
+ async function cloneOriginProven(checkoutDir, cmdUrl) {
17936
+ if (!cmdUrl) return false;
17937
+ try {
17938
+ const config = await readFile(join(checkoutDir, ".git", "config"), "utf8");
17939
+ const section = config.match(/\[remote "origin"\]([^[]*)/);
17940
+ const url = section?.[1]?.match(/url\s*=\s*(\S+)/)?.[1];
17941
+ return url !== void 0 && normalizeGitUrl(url) === normalizeGitUrl(cmdUrl);
17942
+ } catch {
17943
+ return false;
17944
+ }
17945
+ }
17891
17946
  function isSelfCleaningCloneCmd(cmd) {
17892
17947
  const parsed = extractRawCloneDest(cmd);
17893
17948
  if (!parsed) return false;
@@ -17955,7 +18010,8 @@ var init_gitCloneWithSetup2 = __esm({
17955
18010
  };
17956
18011
  }
17957
18012
  const cloneTarget = extractCloneTarget(install.cmd, ctx.hostContext?.userHome);
17958
- if (!cloneTarget) {
18013
+ const parsedDest = extractRawCloneDest(install.cmd);
18014
+ if (!cloneTarget || !parsedDest) {
17959
18015
  return {
17960
18016
  ok: false,
17961
18017
  phase: "preflight",
@@ -18001,9 +18057,15 @@ var init_gitCloneWithSetup2 = __esm({
18001
18057
  }
18002
18058
  }
18003
18059
  const plainClone = /^\s*git\s+clone\s+[^;&|<>`$\r\n]+$/.test(install.cmd);
18004
- if (ctx.hostContext && ctx.opts.updateInstalled) {
18005
- if (!plainClone || existingTarget || await isAlreadyInstalled(ctx, { honorUpdateFlag: false }))
18006
- return unprovenCloneTarget(ctx);
18060
+ const originProven = await cloneOriginProven(
18061
+ resolve(install.cwd ?? ctx.cwd, cloneTarget),
18062
+ extractCloneUrl(install.cmd)
18063
+ );
18064
+ const footprintBounded = externalWriteTargets(install.cmd, parsedDest.raw).length === 0;
18065
+ const installedSignal = existingTarget || (ctx.hostContext && ctx.opts.updateInstalled ? await isAlreadyInstalled(ctx, { honorUpdateFlag: false }) : false);
18066
+ const refreshAuthorized = ctx.opts.updateInstalled && installedSignal && originProven && footprintBounded;
18067
+ if (ctx.hostContext && ctx.opts.updateInstalled && !refreshAuthorized) {
18068
+ if (!plainClone || installedSignal) return unprovenCloneTarget(ctx);
18007
18069
  }
18008
18070
  if (await isAlreadyInstalled(ctx)) {
18009
18071
  const verifyFailure2 = await verifyInstalled(ctx);
@@ -18017,7 +18079,7 @@ var init_gitCloneWithSetup2 = __esm({
18017
18079
  );
18018
18080
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
18019
18081
  }
18020
- if (existingTarget) return unprovenCloneTarget(ctx);
18082
+ if (existingTarget && !refreshAuthorized) return unprovenCloneTarget(ctx);
18021
18083
  const name = ctx.manifest.metadata.name;
18022
18084
  const plan = {
18023
18085
  files: [
@@ -19080,6 +19142,8 @@ function declaredRootPath(ctx, root) {
19080
19142
  if (!host) return void 0;
19081
19143
  const roots = {
19082
19144
  "platform-skills": host.platform.skillsDir,
19145
+ // Phase 85 — the `skills` CLI's default install root.
19146
+ "agents-skills": join(host.userHome, ".agents", "skills"),
19083
19147
  "native-home": host.nativeHome,
19084
19148
  "host-agents": join(host.nativeHome, "agents"),
19085
19149
  "host-commands": host.platform.commandsDir
@@ -19401,7 +19465,13 @@ function isResource(value) {
19401
19465
  const resource = value;
19402
19466
  const selector = resource.selector;
19403
19467
  const marker = resource.marker;
19404
- const roots = ["platform-skills", "native-home", "host-agents", "host-commands"];
19468
+ const roots = [
19469
+ "platform-skills",
19470
+ "agents-skills",
19471
+ "native-home",
19472
+ "host-agents",
19473
+ "host-commands"
19474
+ ];
19405
19475
  const hasNames = Array.isArray(selector?.names) && selector.names.length > 0 && new Set(selector.names).size === selector.names.length && selector.names.every((name) => typeof name === "string" && name.length > 0);
19406
19476
  const hasPrefix = typeof selector?.prefix === "string" && selector.prefix.length > 0;
19407
19477
  return roots.includes(resource.root) && (resource.kind === "file" || resource.kind === "directory") && Boolean(hasNames) !== Boolean(hasPrefix) && typeof marker?.contains === "string" && marker.contains.length > 0 && (resource.kind === "file" ? marker.path === void 0 || isSafeMarkerPath(marker.path) : typeof marker.path === "string" && isSafeMarkerPath(marker.path));
@@ -19420,6 +19490,9 @@ function rootPath(ctx, root) {
19420
19490
  if (!host) return null;
19421
19491
  const roots = {
19422
19492
  "platform-skills": host.platform.skillsDir,
19493
+ // Phase 85 — the `skills` CLI's default install root (the real files of a
19494
+ // host-skills-dir symlink live here).
19495
+ "agents-skills": join(host.userHome, ".agents", "skills"),
19423
19496
  "native-home": host.nativeHome,
19424
19497
  "host-agents": join(host.nativeHome, "agents"),
19425
19498
  "host-commands": host.platform.commandsDir
@@ -19434,6 +19507,13 @@ function selected(resource, name) {
19434
19507
  const { names, prefix } = resource.selector;
19435
19508
  return Boolean(names?.includes(name) || prefix?.length && name.startsWith(prefix));
19436
19509
  }
19510
+ function declaredCoversSkillNames(ctx, names) {
19511
+ const claimed = (names ?? []).filter((name) => name.length > 0);
19512
+ if (claimed.length === 0) return true;
19513
+ const resources = resourcesFor(ctx);
19514
+ if (resources.length === 0) return false;
19515
+ return claimed.every((name) => resources.some((resource) => selected(resource, name)));
19516
+ }
19437
19517
  async function regularMarker(candidate, canonicalCandidate, resource) {
19438
19518
  const markerRelativePath = resource.marker.path;
19439
19519
  if (resource.kind === "directory" && !markerRelativePath) return false;
@@ -19604,13 +19684,19 @@ var init_npmCli2 = __esm({
19604
19684
  }
19605
19685
  const managesSkillOwnership = isSkillOwnershipManaged(ctx.manifest);
19606
19686
  const ownershipCandidateSnapshot = managesSkillOwnership ? await snapshotDeclaredOwnership(ctx) : void 0;
19607
- const usesDeclaredOwnership = Array.isArray(
19608
- ctx.manifest.spec.ownership?.resources
19609
- );
19687
+ const ownershipResources = ctx.manifest.spec.ownership?.resources;
19688
+ const usesDeclaredOwnership = Array.isArray(ownershipResources) && ownershipResources.length > 0;
19689
+ const declaredSnapshot = ownershipCandidateSnapshot ?? (usesDeclaredOwnership ? await snapshotDeclaredOwnership(ctx) : void 0);
19690
+ const declaredProven = usesDeclaredOwnership && // Phase 85 — every skill the manifest claims to install must be declared,
19691
+ // or the declaration does not bound what a refresh may overwrite.
19692
+ declaredCoversSkillNames(ctx, install.installs_skills) && declaredSnapshot !== void 0 && await (async () => {
19693
+ const discovered = await discoverDeclaredOwnership(ctx);
19694
+ return declaredSnapshot.paths.every((path) => discovered.paths.includes(path));
19695
+ })();
19610
19696
  let existingPackTarget = false;
19611
19697
  if (ctx.hostContext && (ctx.manifest.spec.component_type !== "cli-binary" || install.installs_skills !== void 0)) {
19612
19698
  if (usesDeclaredOwnership) {
19613
- existingPackTarget = (ownershipCandidateSnapshot?.paths.length ?? 0) > 0;
19699
+ existingPackTarget = (declaredSnapshot?.paths.length ?? 0) > 0;
19614
19700
  } else {
19615
19701
  const names = [ctx.manifest.metadata.name, ...install.installs_skills ?? []];
19616
19702
  if (names.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name)))
@@ -19631,7 +19717,7 @@ var init_npmCli2 = __esm({
19631
19717
  existingPackTarget = true;
19632
19718
  }
19633
19719
  }
19634
- if (ctx.opts.updateInstalled && !usesDeclaredOwnership) return unprovenPackTarget(ctx);
19720
+ if (ctx.opts.updateInstalled && !declaredProven) return unprovenPackTarget(ctx);
19635
19721
  }
19636
19722
  if (await isAlreadyInstalled(ctx)) {
19637
19723
  const verifyFailure2 = await verifyInstalled(ctx, { neutralCwd: true });
@@ -19645,7 +19731,8 @@ var init_npmCli2 = __esm({
19645
19731
  );
19646
19732
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
19647
19733
  }
19648
- if (existingPackTarget) return unprovenPackTarget(ctx);
19734
+ if (existingPackTarget && !(ctx.opts.updateInstalled && declaredProven))
19735
+ return unprovenPackTarget(ctx);
19649
19736
  let level = detectLevel(install.cmd);
19650
19737
  let cmd = install.cmd;
19651
19738
  const plan = { files: [] };
@@ -19715,9 +19802,10 @@ var init_npmCli2 = __esm({
19715
19802
  try {
19716
19803
  if (usesDeclaredOwnership) {
19717
19804
  const discovered = await discoverDeclaredOwnership(ctx);
19805
+ const refreshAuthorized = ctx.opts.updateInstalled && declaredProven;
19718
19806
  await writeDeclaredOwnershipReceipt(ctx, {
19719
19807
  roots: discovered.roots,
19720
- paths: discovered.paths.filter((path) => !pathSnapshot.has(path))
19808
+ paths: refreshAuthorized ? discovered.paths : discovered.paths.filter((path) => !pathSnapshot.has(path))
19721
19809
  });
19722
19810
  } else {
19723
19811
  const afterPaths = await declaredSkillPaths(ctx, skillRoots);
@@ -19882,6 +19970,12 @@ var init_npxSkillInstaller2 = __esm({
19882
19970
  ] : [getSkillsDir()];
19883
19971
  const primaryActiveSkillsDir = activeSkillsDirs[0] ?? getSkillsDir();
19884
19972
  const ownershipCandidateSnapshot = await snapshotDeclaredOwnership(ctx);
19973
+ const declaredProven = usesDeclaredOwnership && // Phase 85 — every skill the manifest claims to install must be declared,
19974
+ // or the declaration does not bound what a refresh may overwrite.
19975
+ declaredCoversSkillNames(ctx, install.installs_skills) && await (async () => {
19976
+ const discovered = await discoverDeclaredOwnership(ctx);
19977
+ return ownershipCandidateSnapshot.paths.every((path) => discovered.paths.includes(path));
19978
+ })();
19885
19979
  let anyExistingTarget = false;
19886
19980
  if (ctx.hostContext) {
19887
19981
  if (usesDeclaredOwnership) {
@@ -19909,12 +20003,12 @@ var init_npxSkillInstaller2 = __esm({
19909
20003
  }
19910
20004
  }
19911
20005
  }
19912
- if (ctx.opts.updateInstalled && (!singleSkill || anyExistingTarget || await isAlreadyInstalled(ctx, { honorUpdateFlag: false })))
20006
+ if (ctx.opts.updateInstalled && !declaredProven && (!singleSkill || anyExistingTarget || await isAlreadyInstalled(ctx, { honorUpdateFlag: false })))
19913
20007
  return unprovenSkillTarget(ctx);
19914
20008
  }
19915
20009
  const activeTargetExists = await activeSkillPresent(activeSkillsDirs, activeTargetNames);
19916
20010
  const alreadyInstalled = ctx.hostContext ? !ctx.opts.dryRun && activeTargetExists : await isAlreadyInstalled(ctx);
19917
- if (alreadyInstalled) {
20011
+ if (alreadyInstalled && !(ctx.opts.updateInstalled && declaredProven)) {
19918
20012
  const verifyFailure2 = await verifyInstalled(ctx, { neutralCwd: true });
19919
20013
  if (verifyFailure2) return verifyFailure2;
19920
20014
  await recordObservedInstall(
@@ -20015,9 +20109,10 @@ var init_npxSkillInstaller2 = __esm({
20015
20109
  try {
20016
20110
  if (usesDeclaredOwnership) {
20017
20111
  const discovered = await discoverDeclaredOwnership(ctx);
20112
+ const refreshAuthorized = ctx.opts.updateInstalled && declaredProven;
20018
20113
  await writeDeclaredOwnershipReceipt(ctx, {
20019
20114
  roots: discovered.roots,
20020
- paths: discovered.paths.filter((path) => !pathSnapshot.has(path))
20115
+ paths: refreshAuthorized ? discovered.paths : discovered.paths.filter((path) => !pathSnapshot.has(path))
20021
20116
  });
20022
20117
  } else {
20023
20118
  const afterPaths = await declaredSkillPaths(ctx, skillRoots);
@@ -25748,6 +25843,10 @@ async function warnIfAgentTeamsMissing() {
25748
25843
  async function scanWorkflowsWithSkill(workflowsDir, entries) {
25749
25844
  return scanWorkflowsNested(workflowsDir, entries);
25750
25845
  }
25846
+ function isGlobalNpmInstall(plan) {
25847
+ if (effectiveInstallMethod(plan) !== "npm-cli") return false;
25848
+ return /\bnpm\s+install\s+-g\b/.test(plan.manifest.spec.install.cmd);
25849
+ }
25751
25850
  async function runStepBInstall(manifestPaths, runOpts = {}) {
25752
25851
  const hostContext = runOpts.hostContext ?? captureHostInstallContext();
25753
25852
  const opts = {
@@ -25762,6 +25861,7 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
25762
25861
  };
25763
25862
  const start = Date.now();
25764
25863
  const componentTypes = {};
25864
+ const globalNpmComponents = [];
25765
25865
  const failureKeywords = {};
25766
25866
  const total = manifestPaths.length;
25767
25867
  let done = 0;
@@ -25796,12 +25896,18 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
25796
25896
  }
25797
25897
  const plan = resolveComponentPlan(v.manifest, hostContext, "install");
25798
25898
  componentTypes[v.manifest.metadata.name] = installGroupForPlan(plan);
25899
+ if (isGlobalNpmInstall(plan)) globalNpmComponents.push(v.manifest.metadata.name);
25799
25900
  valid.push({ manifest: v.manifest, plan });
25800
25901
  }
25801
- const runOne = async (manifest) => {
25902
+ const runOne = async (manifest, plan) => {
25802
25903
  const name = manifest.metadata.name;
25803
25904
  try {
25804
- const r = await runInstall(manifest, opts, hostContext);
25905
+ const forceSystem = runOpts.forceSystemScope === true && plan !== void 0 && isGlobalNpmInstall(plan);
25906
+ const r = await runInstall(
25907
+ manifest,
25908
+ forceSystem ? { ...opts, system: true } : opts,
25909
+ hostContext
25910
+ );
25805
25911
  if ("aborted" in r) {
25806
25912
  const reason = r.reason === "harness-mismatch" ? `harness-mismatch \u2014 claude-only install method (no ${hostContext.hostId} equivalent)` : r.reason === "level-flag-missing" && runOpts.updateInstalled === true ? `L4 system-scope \u2014 excluded from force-update; update manually: \`${manifest.spec.install.cmd}\`` : r.reason;
25807
25913
  return emit({ status: "skipped", name, reason });
@@ -25819,12 +25925,12 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
25819
25925
  const rest = valid.filter((v) => !MCP_METHODS.has(effectiveInstallMethod(v.plan)));
25820
25926
  const runMcpSerial = async () => {
25821
25927
  const out = [];
25822
- for (const { manifest } of mcp) out.push(await runOne(manifest));
25928
+ for (const { manifest, plan } of mcp) out.push(await runOne(manifest, plan));
25823
25929
  return out;
25824
25930
  };
25825
25931
  const [mcpEntries, restSettled] = await Promise.all([
25826
25932
  runMcpSerial(),
25827
- Promise.allSettled(rest.map(({ manifest }) => runOne(manifest)))
25933
+ Promise.allSettled(rest.map(({ manifest, plan }) => runOne(manifest, plan)))
25828
25934
  ]);
25829
25935
  const restEntries = restSettled.map(
25830
25936
  (s) => s.status === "fulfilled" ? s.value : { status: "failed", name: "?", reason: String(s.reason) }
@@ -25846,7 +25952,8 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
25846
25952
  failed: failed2,
25847
25953
  failureKeywords,
25848
25954
  elapsedMs: Date.now() - start,
25849
- componentTypes
25955
+ componentTypes,
25956
+ globalNpmComponents
25850
25957
  };
25851
25958
  }
25852
25959
  async function reclassifyForceUpdateFailures(firstPass, forcePass, probe) {
@@ -25858,7 +25965,7 @@ async function reclassifyForceUpdateFailures(firstPass, forcePass, probe) {
25858
25965
  const name = (m?.[1] ?? entry).trim();
25859
25966
  if (priorlyInstalled.has(name)) {
25860
25967
  if (forcePass.failureKeywords?.[name] === "update-unsupported") {
25861
- keptExisting.push({ name, reason: m?.[2]?.trim() ?? "" });
25968
+ keptExisting.push({ name, reason: m?.[2]?.trim() ?? "", retryable: false });
25862
25969
  continue;
25863
25970
  }
25864
25971
  let present = false;
@@ -25868,7 +25975,7 @@ async function reclassifyForceUpdateFailures(firstPass, forcePass, probe) {
25868
25975
  present = false;
25869
25976
  }
25870
25977
  if (present) {
25871
- keptExisting.push({ name, reason: m?.[2]?.trim() ?? "" });
25978
+ keptExisting.push({ name, reason: m?.[2]?.trim() ?? "", retryable: true });
25872
25979
  continue;
25873
25980
  }
25874
25981
  }
@@ -26758,7 +26865,11 @@ installing ${manifestPaths.length} upstream components (MCP serialized, rest par
26758
26865
  }
26759
26866
  if (retained) {
26760
26867
  b.keptExisting ??= [];
26761
- b.keptExisting.push({ name, reason: match?.[2]?.trim() ?? "" });
26868
+ b.keptExisting.push({
26869
+ name,
26870
+ reason: match?.[2]?.trim() ?? "",
26871
+ retryable: b.failureKeywords?.[name] !== "update-unsupported"
26872
+ });
26762
26873
  } else failed2.push(entry);
26763
26874
  }
26764
26875
  b.failed = failed2;
@@ -26774,14 +26885,17 @@ installing ${manifestPaths.length} upstream components (MCP serialized, rest par
26774
26885
  })
26775
26886
  );
26776
26887
  printGrouped(b);
26888
+ let forceInstalledNames = [];
26777
26889
  if (!forceFirstPass && !dryRun && raw.nonInteractive !== true && b.alreadyInstalled.length > 0) {
26778
26890
  const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
26779
26891
  if (isTty) {
26780
26892
  const { confirm: confirm6, isCancel: isCancel8 } = await import('@clack/prompts');
26781
26893
  const mcpExcluded = b.alreadyInstalled.filter((n) => b.componentTypes[n] === "mcp-tool");
26782
26894
  const exclusionNote = mcpExcluded.length > 0 ? ` (${mcpExcluded.length} MCP server(s) excluded \u2014 they ignore force-update: ${mcpExcluded.join(", ")})` : "";
26895
+ const globalNpm = b.globalNpmComponents ?? [];
26896
+ const systemNote = globalNpm.length > 0 ? ` (${globalNpm.join(", ")} will be installed/upgraded in system scope via the official \`npm install -g\` command)` : "";
26783
26897
  const ans = await confirm6({
26784
- message: `Update ${b.alreadyInstalled.length} already-installed plugin(s) listed above?${exclusionNote}`,
26898
+ message: `Update ${b.alreadyInstalled.length} already-installed plugin(s) listed above?${exclusionNote}${systemNote}`,
26785
26899
  initialValue: false
26786
26900
  });
26787
26901
  if (!isCancel8(ans) && ans === true) {
@@ -26791,6 +26905,11 @@ force-updating ${b.alreadyInstalled.length} plugin(s)...`);
26791
26905
  hostContext: setupContext,
26792
26906
  updateInstalled: true,
26793
26907
  system: raw.system === true,
26908
+ // Phase 85 — the force pass upgrades global npm tools with the
26909
+ // official command (`npm install -g <pkg>`). The user already
26910
+ // confirmed this pass; the L4 gate does not apply to the official
26911
+ // npm upgrade path.
26912
+ forceSystemScope: true,
26794
26913
  quiet: true,
26795
26914
  onProgress: progress.onProgress
26796
26915
  });
@@ -26804,12 +26923,23 @@ force-updating ${b.alreadyInstalled.length} plugin(s)...`);
26804
26923
  `
26805
26924
  Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting.length} kept-existing / ${b2.alreadyInstalled.length} still-already-installed (MCP) / ${b2.skipped.length} skipped / ${b2.failed.length} failed [parallel ${stepB2Ms}s]`
26806
26925
  );
26926
+ forceInstalledNames = b2.installed;
26807
26927
  printGrouped(b2, "[force-update] ");
26808
26928
  if (b2.keptExisting.length > 0) {
26809
- console.warn(
26810
- `
26811
- ${b2.keptExisting.length} plugin(s) kept their existing version \u2014 refresh failed but the prior install is still usable. Re-run \`harnessed setup\` later to retry the update.`
26812
- );
26929
+ const blocked = b2.keptExisting.filter((entry) => entry.retryable === false);
26930
+ const retryable = b2.keptExisting.filter((entry) => entry.retryable !== false);
26931
+ if (retryable.length > 0) {
26932
+ console.warn(
26933
+ `
26934
+ ${retryable.length} plugin(s) kept their existing version \u2014 refresh failed but the prior install is still usable. Re-run \`harnessed setup\` later to retry the update.`
26935
+ );
26936
+ }
26937
+ if (blocked.length > 0) {
26938
+ console.warn(
26939
+ `
26940
+ ${blocked.length} component(s) kept their existing version \u2014 harnessed refuses to replace them (existing source or write footprint not provably ours). Update them with their upstream tool: ${blocked.map((entry) => entry.name).join(", ")}`
26941
+ );
26942
+ }
26813
26943
  }
26814
26944
  mergeStepBResults(b, b2);
26815
26945
  }
@@ -27016,6 +27146,14 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
27016
27146
  setupFailures.push(userLangResult.message);
27017
27147
  }
27018
27148
  }
27149
+ if (forceInstalledNames.length > 0) {
27150
+ const upgraded = new Set(forceInstalledNames);
27151
+ b.skipped = b.skipped.filter((entry) => !upgraded.has(entry.name));
27152
+ b.failed = b.failed.filter((failure) => {
27153
+ const name = failure.split(": ", 1)[0] ?? failure;
27154
+ return !upgraded.has(name);
27155
+ });
27156
+ }
27019
27157
  let pendingNonInteractiveL4Repair = false;
27020
27158
  const hasL4RepairCandidate = b.skipped.some((s) => s.reason === "level-flag-missing") || b.failed.some((failure) => {
27021
27159
  const name = failure.split(": ", 1)[0] ?? failure;