plugnz 0.0.32 → 0.0.33

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.
Files changed (2) hide show
  1. package/dist/plugnz.mjs +207 -138
  2. package/package.json +1 -1
package/dist/plugnz.mjs CHANGED
@@ -15375,7 +15375,7 @@ function registerProjectedExtension(stage, key, entry) {
15375
15375
 
15376
15376
  // src/hosts/claude-code-writer.ts
15377
15377
  import { cpSync as cpSync5, existsSync as existsSync21, lstatSync as lstatSync15, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync5, readFileSync as readFileSync23, readdirSync as readdirSync14, renameSync as renameSync3, rmSync as rmSync7, statSync as statSync9, writeFileSync as writeFileSync8 } from "node:fs";
15378
- import { dirname as dirname8, join as join29, relative as relative7, resolve as resolve16 } from "node:path";
15378
+ import { dirname as dirname8, join as join29, relative as relative7, resolve as resolve17 } from "node:path";
15379
15379
  import { tmpdir as tmpdir2 } from "node:os";
15380
15380
 
15381
15381
  // src/conversion.ts
@@ -16802,6 +16802,60 @@ function pinPluginMcpFiles(pluginDir, candidates, opts = {}) {
16802
16802
  return { changes, refusals };
16803
16803
  }
16804
16804
 
16805
+ // src/legacy-claim-ownership.ts
16806
+ import { resolve as resolve15 } from "node:path";
16807
+ function resolveLegacyV1MarkerScopeId(input) {
16808
+ const { target, nativeId, marker, installedFingerprint } = input;
16809
+ if (marker === null || marker === undefined)
16810
+ return;
16811
+ if (marker.scopeId !== undefined)
16812
+ return;
16813
+ const matches = input.matchesPluginId ?? ((markerId, expectedId) => markerId === expectedId);
16814
+ if (!matches(marker.pluginId, nativeId))
16815
+ return;
16816
+ if (installedFingerprint === null || installedFingerprint.length === 0)
16817
+ return;
16818
+ let loaded;
16819
+ try {
16820
+ loaded = readLifecycleState();
16821
+ } catch {
16822
+ return;
16823
+ }
16824
+ const candidates = loaded.state.activations.filter((activation) => {
16825
+ if (activation.ownership.kind !== "legacy-claim" || activation.ownership.prior !== "plgnz" || activation.route.kind !== "legacy-unverified") {
16826
+ return false;
16827
+ }
16828
+ if (activation.nativeId !== nativeId && activation.nativeId !== marker.pluginId) {
16829
+ return false;
16830
+ }
16831
+ if (activation.fingerprints.source === undefined || activation.fingerprints.source !== marker.fingerprint) {
16832
+ return false;
16833
+ }
16834
+ if (activation.fingerprints.installed === undefined || activation.fingerprints.installed !== installedFingerprint) {
16835
+ return false;
16836
+ }
16837
+ const scope = loaded.state.scopes.find((row) => row.id === activation.scopeId);
16838
+ if (scope === undefined || scope.target.kind !== target.kind || scope.target.instance !== target.instance) {
16839
+ return false;
16840
+ }
16841
+ return matchesLegacyMarkerSource(scope.source, marker.source, activation.sourceRevision);
16842
+ });
16843
+ if (candidates.length !== 1)
16844
+ return;
16845
+ return candidates[0].scopeId;
16846
+ }
16847
+ function legacyV1MarkerMatchesScope(input) {
16848
+ return resolveLegacyV1MarkerScopeId(input) === input.scopeId;
16849
+ }
16850
+ function matchesLegacyMarkerSource(source, markerSource, sourceRevision) {
16851
+ if (source.kind === "local") {
16852
+ if (!markerSource.startsWith("/"))
16853
+ return false;
16854
+ return resolve15(markerSource) === resolve15(source.locator);
16855
+ }
16856
+ return markerSource === source.locator || source.ref !== "HEAD" && markerSource === `${source.locator}#${source.ref}` || sourceRevision !== undefined && markerSource === sourceRevision;
16857
+ }
16858
+
16805
16859
  // src/scope-inventory.ts
16806
16860
  var SCOPE_ID = /^scope-v1-[0-9a-f]{64}$/u;
16807
16861
  function projectScopeInventory(state, query) {
@@ -16909,7 +16963,7 @@ function key(value) {
16909
16963
  }
16910
16964
 
16911
16965
  // src/lifecycle-runtime.ts
16912
- import { isAbsolute as isAbsolute10, relative as relative6, resolve as resolve15 } from "node:path";
16966
+ import { isAbsolute as isAbsolute10, relative as relative6, resolve as resolve16 } from "node:path";
16913
16967
  class LifecycleHostPhaseError extends Error {
16914
16968
  phase;
16915
16969
  reason;
@@ -17092,7 +17146,7 @@ function createFrozenPackageSnapshot(input) {
17092
17146
  function createResolvedLifecyclePins(input) {
17093
17147
  const pins = input.map(({ server, executable }) => {
17094
17148
  stable3(server, "pin server");
17095
- if (!isAbsolute10(executable) || resolve15(executable) !== executable)
17149
+ if (!isAbsolute10(executable) || resolve16(executable) !== executable)
17096
17150
  invariant(`pin executable must be a canonical absolute path: ${executable}`);
17097
17151
  return Object.freeze({ server, executable });
17098
17152
  });
@@ -18161,7 +18215,7 @@ function sameTarget(left, right) {
18161
18215
  return canonicalJson(frozenTarget(left)) === canonicalJson(frozenTarget(right));
18162
18216
  }
18163
18217
  function canonicalAbsolute(path, label) {
18164
- if (!isAbsolute10(path) || resolve15(path) !== path)
18218
+ if (!isAbsolute10(path) || resolve16(path) !== path)
18165
18219
  invariant(`${label} must be a canonical absolute path`);
18166
18220
  return path;
18167
18221
  }
@@ -18953,8 +19007,8 @@ function matchesNativeCatalogMember(marketplaces, name, plugin, resolved) {
18953
19007
  const memberSource = selected[0]["source"];
18954
19008
  if (typeof memberSource !== "string" || !memberSource.startsWith("./"))
18955
19009
  return false;
18956
- const nativeDir = resolve16(catalog, memberSource);
18957
- if (!containedPath(catalog, nativeDir) || nativeDir === resolve16(catalog))
19010
+ const nativeDir = resolve17(catalog, memberSource);
19011
+ if (!containedPath(catalog, nativeDir) || nativeDir === resolve17(catalog))
18958
19012
  return false;
18959
19013
  assertCatalogPath(catalog, nativeDir);
18960
19014
  if (!existsSync21(nativeDir) || !lstatSync15(nativeDir).isDirectory())
@@ -18973,14 +19027,14 @@ function matchesNativeCatalogMember(marketplaces, name, plugin, resolved) {
18973
19027
  function containedPath(root, path) {
18974
19028
  if (!root.startsWith("/") || !path.startsWith("/"))
18975
19029
  return false;
18976
- const suffix = relative7(resolve16(root), resolve16(path));
19030
+ const suffix = relative7(resolve17(root), resolve17(path));
18977
19031
  return suffix !== ".." && !suffix.startsWith("../") && !suffix.startsWith("..\\");
18978
19032
  }
18979
19033
  function assertCatalogPath(root, path) {
18980
19034
  if (!containedPath(root, path))
18981
19035
  throw new Error(`Claude Code native catalog member escapes catalog: ${path}`);
18982
- const target = resolve16(path);
18983
- let current = resolve16(root);
19036
+ const target = resolve17(path);
19037
+ let current = resolve17(root);
18984
19038
  for (const part of ["", ...relative7(current, target).split("/").filter(Boolean)]) {
18985
19039
  if (part !== "")
18986
19040
  current = join29(current, part);
@@ -18998,8 +19052,8 @@ function assertTargetIsReplaceable(target, ownership, id, source) {
18998
19052
  throw new Error(`claude-code cache slot ${target} has a different owned source identity; refusing to replace it`);
18999
19053
  }
19000
19054
  function assertManagedPath(path) {
19001
- const root = resolve16(join29(pluginsDir(), ".."));
19002
- const target = resolve16(path);
19055
+ const root = resolve17(join29(pluginsDir(), ".."));
19056
+ const target = resolve17(path);
19003
19057
  const suffix = relative7(root, target);
19004
19058
  if (suffix === ".." || suffix.startsWith("../") || suffix.startsWith("..\\"))
19005
19059
  throw new Error(`Claude Code managed path escapes its root: ${path}`);
@@ -19291,7 +19345,7 @@ function claudeCodeLifecycleDefinition(contracts) {
19291
19345
  const result = nativeProjection(contracts, request, detectedVersion);
19292
19346
  if ("snapshot" in request && result.kind === "requires-managed") {
19293
19347
  for (const path of ["known_marketplaces.json", "installed_plugins.json", "../settings.json"])
19294
- assertManagedPath(resolve16(join29(pluginsDir(), path)));
19348
+ assertManagedPath(resolve17(join29(pluginsDir(), path)));
19295
19349
  assertManagedPath(cacheSlot(request.snapshot.nativeId, slotVersion(request.snapshot.inventory.package.version, request.snapshot.immutableRevision)));
19296
19350
  if (!matchingForeignLifecycleCatalog(request.snapshot.nativeId, request.snapshot.scopeId, request.snapshot.target, request.snapshot.packageRoot, request.snapshot.inventory.package.version ?? request.snapshot.immutableRevision))
19297
19351
  validateLifecycleCatalog(request.snapshot.nativeId, request.snapshot.scopeId);
@@ -19558,7 +19612,7 @@ function observeClaudeInstallations(target, version) {
19558
19612
  const recordedPath = row["installPath"];
19559
19613
  if (typeof recordedPath !== "string")
19560
19614
  continue;
19561
- const installPath = resolve16(recordedPath);
19615
+ const installPath = resolve17(recordedPath);
19562
19616
  if (!existsSync21(installPath))
19563
19617
  continue;
19564
19618
  const marker = readOwnership(installPath);
@@ -19566,6 +19620,7 @@ function observeClaudeInstallations(target, version) {
19566
19620
  const sha = row["gitCommitSha"];
19567
19621
  const revision = typeof sha === "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(sha) ? sha : undefined;
19568
19622
  const locator = marker === null ? undefined : gitLocator(marker.source);
19623
+ const resolvedScopeId = marker?.pluginId === id ? marker.scopeId ?? resolveLegacyV1MarkerScopeId({ target, nativeId: id, marker, installedFingerprint: digest }) : undefined;
19569
19624
  const observedRoute = marker?.pluginId === id && marker.scopeId !== undefined ? observedOwnedRoute(installPath) : undefined;
19570
19625
  const on = enabledPlugins[id] === true;
19571
19626
  const at = id.indexOf("@");
@@ -19575,7 +19630,7 @@ function observeClaudeInstallations(target, version) {
19575
19630
  ownership: marker?.pluginId === id ? {
19576
19631
  kind: "owned",
19577
19632
  proof: marker.adopted === true ? "adopted" : "created",
19578
- scopeId: marker.scopeId ?? `claude-code:${id}`,
19633
+ scopeId: resolvedScopeId ?? `claude-code:${id}`,
19579
19634
  proofId: `claude-code:${id}`
19580
19635
  } : { kind: "unmanaged" },
19581
19636
  presence: "present",
@@ -19638,8 +19693,8 @@ function claudeReadback(identity, absentRoute, version) {
19638
19693
  const installPath = recordedInstallPath(identity.nativeId);
19639
19694
  const present = installPath !== undefined && existsSync21(installPath);
19640
19695
  const retention = {
19641
- pluginData: retained(resolve16(join29(pluginsDir(), "plugin-data", identity.nativeId))),
19642
- inactiveMetadata: retained(resolve16(join29(pluginsDir(), "inactive-metadata", identity.nativeId)))
19696
+ pluginData: retained(resolve17(join29(pluginsDir(), "plugin-data", identity.nativeId))),
19697
+ inactiveMetadata: retained(resolve17(join29(pluginsDir(), "inactive-metadata", identity.nativeId)))
19643
19698
  };
19644
19699
  if (!present || installPath === undefined) {
19645
19700
  return {
@@ -19711,7 +19766,7 @@ function recordedInstallPath(nativeId) {
19711
19766
  continue;
19712
19767
  const record = row;
19713
19768
  if (record["scope"] === "user" && typeof record["installPath"] === "string")
19714
- return resolve16(record["installPath"]);
19769
+ return resolve17(record["installPath"]);
19715
19770
  }
19716
19771
  return;
19717
19772
  }
@@ -19719,13 +19774,13 @@ function cacheSlot(nativeId, version) {
19719
19774
  const at = nativeId.indexOf("@");
19720
19775
  const name = at === -1 ? nativeId : nativeId.slice(0, at);
19721
19776
  const market = at === -1 ? "local" : nativeId.slice(at + 1);
19722
- return resolve16(join29(pluginsDir(), "cache", market, name, version));
19777
+ return resolve17(join29(pluginsDir(), "cache", market, name, version));
19723
19778
  }
19724
19779
  function lifecycleCatalogRoot(nativeId) {
19725
19780
  const market = marketplaceName(nativeId);
19726
19781
  if (market === undefined || market.includes("/") || market.includes("\\"))
19727
19782
  throw new Error("Claude Code lifecycle native identity has no safe marketplace");
19728
- return resolve16(join29(pluginsDir(), "marketplaces", `.plgnz-${market}`));
19783
+ return resolve17(join29(pluginsDir(), "marketplaces", `.plgnz-${market}`));
19729
19784
  }
19730
19785
  function lifecycleCatalogCopy(nativeId) {
19731
19786
  const name = nativeId.slice(0, nativeId.indexOf("@"));
@@ -19741,13 +19796,13 @@ function registeredLifecycleCatalogMember(nativeId) {
19741
19796
  if (!isRecord6(entry) || !isRecord6(entry["source"]) || entry["source"]["source"] !== "directory" || typeof entry["source"]["path"] !== "string" || entry["installLocation"] !== entry["source"]["path"])
19742
19797
  return null;
19743
19798
  const root = entry["source"]["path"];
19744
- if (!root.startsWith("/") || resolve16(root) !== root || !existsSync21(root))
19799
+ if (!root.startsWith("/") || resolve17(root) !== root || !existsSync21(root))
19745
19800
  return null;
19746
19801
  assertCatalogPath(root, join29(root, ".claude-plugin", "marketplace.json"));
19747
19802
  const selected = catalogEntries(lifecycleCatalogDocument(root, market)).filter((item) => isCatalogMember(item, nativeId));
19748
19803
  if (selected.length !== 1 || !isRecord6(selected[0]) || typeof selected[0]["source"] !== "string" || !selected[0]["source"].startsWith("./"))
19749
19804
  return null;
19750
- const member = resolve16(root, selected[0]["source"]);
19805
+ const member = resolve17(root, selected[0]["source"]);
19751
19806
  if (!containedPath(root, member) || root === member || !existsSync21(member))
19752
19807
  return null;
19753
19808
  assertCatalogPath(root, member);
@@ -19836,23 +19891,30 @@ function validateLifecycleCatalog(nativeId, scopeId) {
19836
19891
  const selected = catalogEntries(document).filter((entry) => isCatalogMember(entry, nativeId));
19837
19892
  if (selected.length > 1 || selected.some((entry) => !isRecord6(entry) || entry["source"] !== `./plugins/${nativeId.slice(0, nativeId.indexOf("@"))}`))
19838
19893
  throw new Error(`Claude Code marketplace member ${nativeId} is foreign or ambiguous; refusing to replace it`);
19894
+ const installed = recordedInstallPath(nativeId);
19895
+ const installedOwner = installed === undefined || !existsSync21(installed) ? null : readOwnership(installed);
19896
+ const installedScopeId = installed === undefined || installedOwner === null ? undefined : installedOwner.scopeId ?? resolveLegacyV1MarkerScopeId({ target: { kind: "claude-code", instance: "default" }, nativeId, marker: installedOwner, installedFingerprint: fingerprintTree(installed) });
19839
19897
  if (existsSync21(copy)) {
19840
19898
  assertNoSymlinks2(copy);
19841
19899
  const owner = readOwnership(copy);
19842
- if (owner?.pluginId !== nativeId || owner.scopeId !== scopeId)
19900
+ const copyScopeId = owner?.scopeId !== undefined ? owner.scopeId : owner?.pluginId === nativeId && installed !== undefined && existsSync21(installed) && installedScopeId === scopeId && owner.source === installedOwner?.source && owner.fingerprint === installedOwner?.fingerprint && (fingerprintTree(copy) === fingerprintTree(installed) || fingerprintSourceTree(copy, [OWNERSHIP]) === owner.fingerprint && readFileSync23(join29(copy, OWNERSHIP), "utf8") === readFileSync23(join29(installed, OWNERSHIP), "utf8")) ? scopeId : undefined;
19901
+ if (owner?.pluginId !== nativeId || copyScopeId !== scopeId)
19843
19902
  throw new Error(`Claude Code marketplace member ${copy} has a different owned scope; refusing to replace it`);
19844
19903
  } else if (selected.length > 0) {
19845
- const installed = recordedInstallPath(nativeId);
19846
- const owner = installed === undefined ? null : readOwnership(installed);
19847
- if (owner?.pluginId !== nativeId || owner.scopeId !== scopeId)
19904
+ if (installedOwner?.pluginId !== nativeId || installedScopeId !== scopeId)
19848
19905
  throw new Error(`Claude Code marketplace member ${nativeId} has no ownership proof; refusing to replace it`);
19849
19906
  }
19850
19907
  const known = readMarketplaces(join29(pluginsDir(), "known_marketplaces.json"));
19851
19908
  const extra = readSettings(join29(pluginsDir(), "..", "settings.json"))["extraKnownMarketplaces"];
19909
+ const sameLegacyLocalSource = (candidatePath) => installedScopeId === scopeId && typeof candidatePath === "string" && candidatePath.startsWith("/") && createDeploymentScopeIdentity({ kind: "local", locator: candidatePath }, { kind: "claude-code", instance: "default" }).id === scopeId;
19852
19910
  for (const entry of [known[market], isRecord6(extra) ? extra[market] : undefined]) {
19853
19911
  if (entry === undefined)
19854
19912
  continue;
19855
- if (!isRecord6(entry) || !isRecord6(entry["source"]) || entry["source"]["source"] !== "directory" || entry["source"]["path"] !== root || entry["installLocation"] !== undefined && entry["installLocation"] !== root)
19913
+ const sourcePath = isRecord6(entry) && isRecord6(entry["source"]) ? entry["source"]["path"] : undefined;
19914
+ const allowedPath = sourcePath === root || sameLegacyLocalSource(sourcePath);
19915
+ const installLoc = isRecord6(entry) ? entry["installLocation"] : undefined;
19916
+ const allowedInstallLoc = installLoc === undefined || installLoc === root || installLoc === sourcePath && sameLegacyLocalSource(sourcePath);
19917
+ if (!isRecord6(entry) || !isRecord6(entry["source"]) || entry["source"]["source"] !== "directory" || !allowedPath || !allowedInstallLoc)
19856
19918
  throw new Error(`Claude Code marketplace ${market} is registered from a different source; refusing to replace it`);
19857
19919
  }
19858
19920
  }
@@ -19879,11 +19941,12 @@ function lifecycleCatalogConforms(nativeId, installPath, target) {
19879
19941
  return false;
19880
19942
  const registered = registeredLifecycleCatalogMember(nativeId);
19881
19943
  const owner = readOwnership(installPath);
19944
+ const ownerScopeId = owner?.scopeId ?? (owner?.pluginId === nativeId ? resolveLegacyV1MarkerScopeId({ target, nativeId, marker: owner, installedFingerprint: fingerprintTree(installPath) }) : undefined);
19882
19945
  if (registered !== null && registered.root !== lifecycleCatalogRoot(nativeId)) {
19883
- if (owner?.scopeId === undefined)
19946
+ if (ownerScopeId === undefined)
19884
19947
  return false;
19885
19948
  const manifest = existsSync21(join29(installPath, ".plugin", "plugin.json")) ? join29(installPath, ".plugin", "plugin.json") : join29(installPath, "plugin.json");
19886
- return matchingForeignLifecycleCatalog(nativeId, owner.scopeId, target, installPath, parseManifest(manifest, "canonical").version ?? "") !== null;
19949
+ return matchingForeignLifecycleCatalog(nativeId, ownerScopeId, target, installPath, parseManifest(manifest, "canonical").version ?? "") !== null;
19887
19950
  }
19888
19951
  const known = readMarketplaces(join29(pluginsDir(), "known_marketplaces.json"))[market];
19889
19952
  if (!isRecord6(known) || !isRecord6(known["source"]) || known["source"]["source"] !== "directory" || known["source"]["path"] !== lifecycleCatalogRoot(nativeId) || known["installLocation"] !== lifecycleCatalogRoot(nativeId))
@@ -20029,7 +20092,7 @@ function slotVersion(version, revision) {
20029
20092
  return selected;
20030
20093
  }
20031
20094
  function lifecyclePath(kind, attemptId, operationId) {
20032
- return resolve16(join29(pluginsDir(), kind, attemptId, operationId));
20095
+ return resolve17(join29(pluginsDir(), kind, attemptId, operationId));
20033
20096
  }
20034
20097
  function captureRollback(attemptId, operationId, nativeId) {
20035
20098
  const reference = lifecyclePath(".plgnz-rollback", attemptId, operationId);
@@ -20138,7 +20201,7 @@ function restoreRollback(handle) {
20138
20201
  const appliedSlot = cacheSlot(handle.nativeId, slotVersion(handle.packageVersion, handle.sourceRevision));
20139
20202
  const savedPath = join29(reference, "install-path.txt");
20140
20203
  const previousSlot = existsSync21(savedPath) ? readFileSync23(savedPath, "utf8") : undefined;
20141
- if (previousSlot !== undefined && resolve16(previousSlot) !== appliedSlot && !existsSync21(appliedSlot)) {
20204
+ if (previousSlot !== undefined && resolve17(previousSlot) !== appliedSlot && !existsSync21(appliedSlot)) {
20142
20205
  throw new Error(`claude-code rollback cannot remove the updated cache slot: ${appliedSlot}`);
20143
20206
  }
20144
20207
  const beforeEntry = JSON.stringify(readRegistry(registryFile).plugins[handle.nativeId] ?? null);
@@ -20148,7 +20211,7 @@ function restoreRollback(handle) {
20148
20211
  const beforePrevious = previousSlot !== undefined && existsSync21(previousSlot) ? fingerprintTree(previousSlot) : null;
20149
20212
  restoreLifecycleCatalog(reference, handle.nativeId, handle.scopeId);
20150
20213
  restorePluginSlice(handle.nativeId, reference);
20151
- if (previousSlot !== undefined && resolve16(previousSlot) !== appliedSlot)
20214
+ if (previousSlot !== undefined && resolve17(previousSlot) !== appliedSlot)
20152
20215
  rmSync7(appliedSlot, { recursive: true, force: true });
20153
20216
  const installPath = previousSlot ?? recordedInstallPath(handle.nativeId) ?? appliedSlot;
20154
20217
  const backup = join29(reference, "install");
@@ -20279,7 +20342,7 @@ function hasForeignMarketplaceSibling(nativeId, marketplace) {
20279
20342
  return false;
20280
20343
  if (!isRecord6(entry) || typeof entry["name"] !== "string" || typeof entry["source"] !== "string" || !entry["source"].startsWith("./"))
20281
20344
  return true;
20282
- const member = resolve16(root, entry["source"]);
20345
+ const member = resolve17(root, entry["source"]);
20283
20346
  if (!containedPath(root, member) || member === root || !existsSync21(member))
20284
20347
  return true;
20285
20348
  assertCatalogPath(root, member);
@@ -20318,7 +20381,7 @@ function disableMarketplaceAutoUpdate(nativeId) {
20318
20381
  // src/hosts/codex-writer.ts
20319
20382
  init_codex_hooks();
20320
20383
  import { chmodSync, cpSync as cpSync6, existsSync as existsSync22, lstatSync as lstatSync17, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync6, readFileSync as readFileSync25, readdirSync as readdirSync15, readlinkSync as readlinkSync2, renameSync as renameSync4, rmSync as rmSync8, statSync as statSync10, writeFileSync as writeFileSync9 } from "node:fs";
20321
- import { dirname as dirname9, join as join31, resolve as resolve17 } from "node:path";
20384
+ import { dirname as dirname9, join as join31, resolve as resolve18 } from "node:path";
20322
20385
  import { tmpdir as tmpdir3 } from "node:os";
20323
20386
 
20324
20387
  // src/hosts/codex-agent-config.ts
@@ -20997,7 +21060,7 @@ function assertNoWinningForeignVersion(slot, requested, id, source, handle) {
20997
21060
  if (!statSync10(candidate).isDirectory() || version === requested)
20998
21061
  continue;
20999
21062
  const marker = readOwnership2(candidate);
21000
- if (wins(version, requested) && (marker?.pluginId !== id || marker.source !== source) && !(handle !== undefined && marker !== null && fingerprintTree(candidate) === handle.prior.installedFingerprint && priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof)))) {
21063
+ if (wins(version, requested) && (marker?.pluginId !== id || marker.source !== source) && !(handle !== undefined && marker !== null && fingerprintTree(candidate) === handle.prior.installedFingerprint && (priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof)) || legacyV1MarkerMatchesScope({ target: handle.target, scopeId: handle.scopeId, nativeId: id, marker, installedFingerprint: handle.prior.installedFingerprint })))) {
21001
21064
  throw new Error(`foreign Codex cache version ${version} would remain active over ${requested}`);
21002
21065
  }
21003
21066
  }
@@ -21010,7 +21073,7 @@ function cleanupOwnedVersions(slot, active, id, source, handle) {
21010
21073
  const marker = readOwnership2(candidate);
21011
21074
  if (handle !== undefined && !handle.prior.contentRoots.some((root) => root.path === candidate && root.fingerprint === fingerprintTree(candidate)))
21012
21075
  continue;
21013
- if (marker?.pluginId === id && (marker.source === source || handle !== undefined && fingerprintTree(candidate) === handle.prior.installedFingerprint && priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof))))
21076
+ if (marker?.pluginId === id && (marker.source === source || handle !== undefined && fingerprintTree(candidate) === handle.prior.installedFingerprint && (priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof)) || legacyV1MarkerMatchesScope({ target: handle.target, scopeId: handle.scopeId, nativeId: id, marker, installedFingerprint: handle.prior.installedFingerprint }))))
21014
21077
  rmSync8(candidate, { recursive: true, force: true });
21015
21078
  }
21016
21079
  }
@@ -21170,7 +21233,7 @@ function revalidateCodexTarget(handle) {
21170
21233
  }
21171
21234
  function stageCodexActivation(request) {
21172
21235
  const stagingId = `${request.snapshot.attemptId}:${request.snapshot.operationId}`;
21173
- const stagingRoot = resolve17(join31(codexHome(), ".plgnz-lifecycle", stagingId));
21236
+ const stagingRoot = resolve18(join31(codexHome(), ".plgnz-lifecycle", stagingId));
21174
21237
  assertManagedPath2(codexHome(), stagingRoot);
21175
21238
  rmSync8(stagingRoot, { recursive: true, force: true });
21176
21239
  mkdirSync7(stagingRoot, { recursive: true });
@@ -21281,7 +21344,7 @@ function applyManagedCodexActivation(prepared) {
21281
21344
  const source = readOwnership2(stagingRoot)?.source ?? handle.sourceLocator ?? handle.sourceRevision;
21282
21345
  assertNoWinningForeignVersion(slot, version, handle.nativeId, source, handle);
21283
21346
  const marker = readOwnership2(targetDir);
21284
- if (marker !== null && (marker.source !== source || marker.pluginId !== handle.nativeId) && !(fingerprintTree(targetDir) === handle.prior.installedFingerprint && priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof)))) {
21347
+ if (marker !== null && (marker.source !== source || marker.pluginId !== handle.nativeId) && !(fingerprintTree(targetDir) === handle.prior.installedFingerprint && (priorSourceRepairAllows(handle, (proof) => historicalGitMarker(marker, proof)) || legacyV1MarkerMatchesScope({ target: handle.target, scopeId: handle.scopeId, nativeId: handle.nativeId, marker, installedFingerprint: handle.prior.installedFingerprint })))) {
21285
21348
  throw new Error(`codex cache slot ${targetDir} has a different owned source identity; refusing to replace it`);
21286
21349
  }
21287
21350
  const before = cacheFingerprint(handle.nativeId);
@@ -21430,7 +21493,7 @@ function readCodexInstall(handle) {
21430
21493
  }
21431
21494
  function cleanupCodexStage(reference) {
21432
21495
  releasePriorSourceRepair(reference);
21433
- const stage = resolve17(join31(codexHome(), ".plgnz-lifecycle", `${reference.attemptId}:${reference.operationId}`));
21496
+ const stage = resolve18(join31(codexHome(), ".plgnz-lifecycle", `${reference.attemptId}:${reference.operationId}`));
21434
21497
  if (existsSync22(stage))
21435
21498
  rmSync8(stage, { recursive: true, force: true });
21436
21499
  const rollback = rollbackBundle(reference.attemptId, reference.operationId);
@@ -21593,7 +21656,7 @@ function codexRollbackReference(attemptId, operationId) {
21593
21656
  return `${reference}:native-cache-sha256:${digest}`;
21594
21657
  }
21595
21658
  function rollbackBundle(attemptId, operationId) {
21596
- return resolve17(join31(codexHome(), ".plgnz-rollback", attemptId, operationId));
21659
+ return resolve18(join31(codexHome(), ".plgnz-rollback", attemptId, operationId));
21597
21660
  }
21598
21661
  function nativeCacheFingerprint(root, ignoreOwnership = false) {
21599
21662
  const hash = new CryptoHasher("sha256");
@@ -21777,7 +21840,7 @@ function restoreCodexRollback(handle) {
21777
21840
  function marketplaceCheckout(marketplace) {
21778
21841
  if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(marketplace))
21779
21842
  throw new Error("unsafe Codex marketplace identity");
21780
- const path = resolve17(join31(codexHome(), ".tmp", "marketplaces", marketplace));
21843
+ const path = resolve18(join31(codexHome(), ".tmp", "marketplaces", marketplace));
21781
21844
  assertManagedPath2(codexHome(), path);
21782
21845
  return path;
21783
21846
  }
@@ -22056,8 +22119,8 @@ function parseRollbackVersions(value) {
22056
22119
  function installationRecord(plugin) {
22057
22120
  const linked = plugin.path !== undefined && lstatSync17(plugin.path).isSymbolicLink();
22058
22121
  const owned = plugin.path === undefined || linked ? null : readOwnership2(plugin.path);
22059
- const ownership = owned?.pluginId === plugin.id ? { kind: "owned", proof: "created", scopeId: owned.scopeId ?? `codex:${plugin.id}`, proofId: `marker:${plugin.id}` } : { kind: "unmanaged" };
22060
22122
  if (plugin.path === undefined) {
22123
+ const ownership = owned?.pluginId === plugin.id ? { kind: "owned", proof: "created", scopeId: owned.scopeId ?? `codex:${plugin.id}`, proofId: `marker:${plugin.id}` } : { kind: "unmanaged" };
22061
22124
  return {
22062
22125
  nativeId: plugin.id,
22063
22126
  packageName: plugin.name,
@@ -22072,6 +22135,8 @@ function installationRecord(plugin) {
22072
22135
  };
22073
22136
  }
22074
22137
  const installedFingerprint = linked ? new CryptoHasher("sha256").update(`codex-unmanaged-symlink\x00${readlinkSync2(plugin.path)}`).digest("hex") : fingerprintTree(plugin.path);
22138
+ const resolvedScopeId = owned?.pluginId === plugin.id ? owned.scopeId ?? resolveLegacyV1MarkerScopeId({ target: { kind: "codex", instance: "default" }, nativeId: plugin.id, marker: owned, installedFingerprint }) : undefined;
22139
+ const ownership = owned?.pluginId === plugin.id ? { kind: "owned", proof: "created", scopeId: resolvedScopeId ?? `codex:${plugin.id}`, proofId: `marker:${plugin.id}` } : { kind: "unmanaged" };
22075
22140
  return {
22076
22141
  nativeId: plugin.id,
22077
22142
  packageName: plugin.name,
@@ -22242,7 +22307,7 @@ function comparePrerelease2(left, right) {
22242
22307
 
22243
22308
  // src/hosts/kimi-writer.ts
22244
22309
  import { cpSync as cpSync7, existsSync as existsSync23, lstatSync as lstatSync18, mkdirSync as mkdirSync8, mkdtempSync as mkdtempSync7, readFileSync as readFileSync26, readdirSync as readdirSync16, realpathSync as realpathSync4, renameSync as renameSync5, rmSync as rmSync9, statSync as statSync11, writeFileSync as writeFileSync10 } from "node:fs";
22245
- import { dirname as dirname10, isAbsolute as isAbsolute11, join as join32, resolve as resolve18 } from "node:path";
22310
+ import { dirname as dirname10, isAbsolute as isAbsolute11, join as join32, resolve as resolve19 } from "node:path";
22246
22311
  import { tmpdir as tmpdir4 } from "node:os";
22247
22312
  var MARKER4 = ".plgnz-install.json";
22248
22313
  var samePhysicalKimiNativeIdentity = (plugin, prior, observation) => {
@@ -22388,7 +22453,7 @@ function sameRoot(value, target) {
22388
22453
  const right = statSync11(target);
22389
22454
  return left.dev === right.dev && left.ino === right.ino;
22390
22455
  } catch {
22391
- return resolve18(value) === resolve18(target);
22456
+ return resolve19(value) === resolve19(target);
22392
22457
  }
22393
22458
  }
22394
22459
  function readRegistry2(path) {
@@ -22703,8 +22768,8 @@ function lstatIfPresent(path) {
22703
22768
  }
22704
22769
  }
22705
22770
  function assertManagedPath3(root, target) {
22706
- const base = resolve18(root);
22707
- const selected = resolve18(target);
22771
+ const base = resolve19(root);
22772
+ const selected = resolve19(target);
22708
22773
  if (selected !== base && !selected.startsWith(`${base}/`))
22709
22774
  throw new Error(`Kimi managed path escapes its home: ${target}`);
22710
22775
  let current = base;
@@ -23125,7 +23190,7 @@ function readKimiInstallations() {
23125
23190
  presence: "present",
23126
23191
  enablement: enabled ? "enabled" : "disabled",
23127
23192
  activation: enabled ? "active" : "inactive",
23128
- ...owned && resolve18(plugin.path) === resolve18(managedPluginPath(plugin.name)) ? { observedRoute: "native" } : {},
23193
+ ...owned && resolve19(plugin.path) === resolve19(managedPluginPath(plugin.name)) ? { observedRoute: "native" } : {},
23129
23194
  installedFingerprint: digest,
23130
23195
  installedVersion: null,
23131
23196
  source: owned ? kimiSourceIdentity(marker) : null,
@@ -23234,12 +23299,12 @@ function unexposed(phase) {
23234
23299
 
23235
23300
  // src/hosts/cursor-writer.ts
23236
23301
  import { cpSync as cpSync8, existsSync as existsSync24, lstatSync as lstatSync20, mkdirSync as mkdirSync9, mkdtempSync as mkdtempSync8, readFileSync as readFileSync28, readdirSync as readdirSync18, renameSync as renameSync6, rmSync as rmSync10, statSync as statSync12, writeFileSync as writeFileSync11 } from "node:fs";
23237
- import { join as join34, resolve as resolve20 } from "node:path";
23302
+ import { join as join34, resolve as resolve21 } from "node:path";
23238
23303
  import { tmpdir as tmpdir5 } from "node:os";
23239
23304
 
23240
23305
  // src/hosts/cursor-adoption.ts
23241
23306
  import { accessSync as accessSync4, constants as constants4, lstatSync as lstatSync19, readFileSync as readFileSync27, readdirSync as readdirSync17 } from "node:fs";
23242
- import { dirname as dirname11, join as join33, resolve as resolve19 } from "node:path";
23307
+ import { dirname as dirname11, join as join33, resolve as resolve20 } from "node:path";
23243
23308
  var MARKER5 = ".plgnz-install.json";
23244
23309
  function proveCursorLegacyAdoption(request) {
23245
23310
  const legacy = parseLegacyRecordProof(request.legacy);
@@ -23263,7 +23328,7 @@ function proveCursorLegacyAdoption(request) {
23263
23328
  if (path === undefined)
23264
23329
  fail3("collection identity has no marketplace manifest");
23265
23330
  const marketplace = json(readFileSync27(path), "collection");
23266
- const candidates = Array.isArray(marketplace.plugins) ? marketplace.plugins.filter((value) => plainObject(value) && typeof value.source === "string" && resolve19(snapshot.snapshotRoot, value.source) === snapshot.packageRoot) : [];
23331
+ const candidates = Array.isArray(marketplace.plugins) ? marketplace.plugins.filter((value) => plainObject(value) && typeof value.source === "string" && resolve20(snapshot.snapshotRoot, value.source) === snapshot.packageRoot) : [];
23267
23332
  if ((typeof marketplace.name === "string" ? marketplace.name : "local") !== snapshot.collectionName || candidates.length !== 1)
23268
23333
  fail3("collection identity or package binding differs");
23269
23334
  }
@@ -23273,7 +23338,7 @@ function proveCursorLegacyAdoption(request) {
23273
23338
  const pins = resolvedPins.map((pin) => pin.server);
23274
23339
  if (canonicalAdoptionJson(pins) !== canonicalAdoptionJson(legacy.snapshot.activation.pins) || new Set(pins).size !== pins.length)
23275
23340
  fail3("resolved pins differ from retained original");
23276
- const root = resolve19(join33(localDir(snapshot.target.instance), snapshot.nativeId));
23341
+ const root = resolve20(join33(localDir(snapshot.target.instance), snapshot.nativeId));
23277
23342
  for (const alias of logicalAliases) {
23278
23343
  if (alias !== snapshot.nativeId && present(join33(localDir(snapshot.target.instance), alias)))
23279
23344
  fail3("ambiguous second physical alias");
@@ -23415,7 +23480,7 @@ function readTree(root) {
23415
23480
  return tree;
23416
23481
  }
23417
23482
  function safeAncestors(root, allowMissing) {
23418
- for (let path = resolve19(root);; path = dirname11(path)) {
23483
+ for (let path = resolve20(root);; path = dirname11(path)) {
23419
23484
  if (!allowMissing || present(path)) {
23420
23485
  const stat = lstatSync19(path);
23421
23486
  if (stat.isSymbolicLink() || !stat.isDirectory())
@@ -23757,8 +23822,8 @@ function hashBytes(path) {
23757
23822
  return Array.from(read(path)).join(",");
23758
23823
  }
23759
23824
  function assertManagedDirectory(root, target) {
23760
- const resolvedRoot = resolve20(cursorRoot());
23761
- const resolvedTarget = resolve20(target);
23825
+ const resolvedRoot = resolve21(cursorRoot());
23826
+ const resolvedTarget = resolve21(target);
23762
23827
  if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}/`))
23763
23828
  throw new Error(`Cursor managed path escapes its store: ${target}`);
23764
23829
  let current = resolvedRoot;
@@ -23919,7 +23984,7 @@ var cursorLifecycleDefinition = {
23919
23984
  async stageActivation(request) {
23920
23985
  assertSafeIdentity2(request.snapshot.nativeId);
23921
23986
  const preparation = lifecycleDir(request.snapshot.target.instance, "prepare", request.snapshot.attemptId, request.snapshot.operationId);
23922
- const stagingRoot = resolve20(join34(preparation, "stage"));
23987
+ const stagingRoot = resolve21(join34(preparation, "stage"));
23923
23988
  rmSync10(stagingRoot, { recursive: true, force: true });
23924
23989
  mkdirSync9(preparation, { recursive: true });
23925
23990
  stagePlugin3(request.snapshot.packageRoot, stagingRoot, request.snapshot.nativeId);
@@ -23941,7 +24006,7 @@ var cursorLifecycleDefinition = {
23941
24006
  nativeId: projection.nativeId,
23942
24007
  routeWhenAbsent: "none"
23943
24008
  });
23944
- const active = resolve20(managedPluginDir(projection.target.instance, projection.nativeId));
24009
+ const active = resolve21(managedPluginDir(projection.target.instance, projection.nativeId));
23945
24010
  return {
23946
24011
  prior,
23947
24012
  expected: {
@@ -24114,13 +24179,13 @@ function inventoryLocalStore(target) {
24114
24179
  } catch {
24115
24180
  continue;
24116
24181
  }
24117
- const installation = readLocalInstallation(entry, dir);
24182
+ const installation = readLocalInstallation(target.instance, entry, dir);
24118
24183
  if (installation !== undefined)
24119
24184
  installations.push(installation);
24120
24185
  }
24121
24186
  return { target, installations };
24122
24187
  }
24123
- function readLocalInstallation(entry, dir) {
24188
+ function readLocalInstallation(instance, entry, dir) {
24124
24189
  const manifestPath = join34(dir, ".cursor-plugin", "plugin.json");
24125
24190
  if (!existsSync24(manifestPath))
24126
24191
  return;
@@ -24156,10 +24221,10 @@ function readLocalInstallation(entry, dir) {
24156
24221
  installedFingerprint: digest,
24157
24222
  installedVersion: manifest?.version ?? null,
24158
24223
  source: null,
24159
- contentRoots: [{ label: "local", path: resolve20(dir), fingerprint: digest }]
24224
+ contentRoots: [{ label: "local", path: resolve21(dir), fingerprint: digest }]
24160
24225
  };
24161
24226
  }
24162
- const ownership = ownershipOf(entry, marker);
24227
+ const ownership = ownershipOf(instance, entry, marker, digest);
24163
24228
  return {
24164
24229
  nativeId: entry,
24165
24230
  packageName: manifest.name,
@@ -24171,7 +24236,7 @@ function readLocalInstallation(entry, dir) {
24171
24236
  installedFingerprint: digest,
24172
24237
  installedVersion: manifest.version ?? null,
24173
24238
  source: sourceOf(marker),
24174
- contentRoots: [{ label: "local", path: resolve20(dir), fingerprint: digest }]
24239
+ contentRoots: [{ label: "local", path: resolve21(dir), fingerprint: digest }]
24175
24240
  };
24176
24241
  }
24177
24242
  function unreadableFingerprint(nativeId) {
@@ -24180,16 +24245,19 @@ function unreadableFingerprint(nativeId) {
24180
24245
  hash.update(nativeId);
24181
24246
  return hash.digest("hex");
24182
24247
  }
24183
- function ownershipOf(nativeId, marker) {
24184
- if (marker === null || marker.scopeId === undefined)
24248
+ function ownershipOf(instance, nativeId, marker, installedFingerprint) {
24249
+ if (marker === null)
24185
24250
  return { kind: "unmanaged" };
24186
24251
  if (!ownsNativeDirectory(marker.pluginId, nativeId))
24187
24252
  return { kind: "ambiguous", proofIds: [`cursor-marker-${nativeId}`] };
24253
+ const scopeId = marker.scopeId ?? resolveLegacyV1MarkerScopeId({ target: { kind: "cursor", instance }, nativeId, marker, installedFingerprint, matchesPluginId: ownsNativeDirectory });
24254
+ if (scopeId === undefined)
24255
+ return { kind: "unmanaged" };
24188
24256
  return {
24189
24257
  kind: "owned",
24190
24258
  proof: marker.proof === "adopted" ? "adopted" : "created",
24191
- scopeId: marker.scopeId,
24192
- proofId: `cursor-${nativeId}-${marker.scopeId}`
24259
+ scopeId,
24260
+ proofId: `cursor-${nativeId}-${scopeId}`
24193
24261
  };
24194
24262
  }
24195
24263
  function sourceOf(marker) {
@@ -24283,7 +24351,7 @@ function projectReadback(identity) {
24283
24351
  activation: "active",
24284
24352
  transition: RELOAD_REQUIRED,
24285
24353
  installedFingerprint: digest,
24286
- contentRoots: [{ label: "local", path: resolve20(dir), fingerprint: digest }],
24354
+ contentRoots: [{ label: "local", path: resolve21(dir), fingerprint: digest }],
24287
24355
  retention
24288
24356
  };
24289
24357
  }
@@ -24298,8 +24366,8 @@ function retainedResource(instance, nativeId, kind) {
24298
24366
  }
24299
24367
  function retentionDir(instance, nativeId, kind) {
24300
24368
  assertSafeIdentity2(nativeId);
24301
- const dir = resolve20(join34(cursorInstanceRoot(instance), "plugins", "retained", nativeId, kind));
24302
- const root = resolve20(cursorRoot());
24369
+ const dir = resolve21(join34(cursorInstanceRoot(instance), "plugins", "retained", nativeId, kind));
24370
+ const root = resolve21(cursorRoot());
24303
24371
  if (dir !== root && !dir.startsWith(`${root}/`))
24304
24372
  throw new Error(`Cursor retention path escapes its store: ${dir}`);
24305
24373
  return dir;
@@ -24316,7 +24384,7 @@ function captureRollback2(instance, attemptId, operationId, nativeId, prior) {
24316
24384
  return reference;
24317
24385
  }
24318
24386
  function lifecycleDir(instance, kind, attemptId, operationId) {
24319
- return resolve20(join34(cursorInstanceRoot(instance), "plugins", ".plgnz-lifecycle", kind, operationKey(attemptId, operationId)));
24387
+ return resolve21(join34(cursorInstanceRoot(instance), "plugins", ".plgnz-lifecycle", kind, operationKey(attemptId, operationId)));
24320
24388
  }
24321
24389
  function operationKey(attemptId, operationId) {
24322
24390
  const hash = new CryptoHasher("sha256");
@@ -24372,7 +24440,7 @@ function receipt(kind, handle) {
24372
24440
  // src/hosts/omp-writer.ts
24373
24441
  init_omp_hooks();
24374
24442
  import { cpSync as cpSync9, existsSync as existsSync25, lstatSync as lstatSync21, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync9, readFileSync as readFileSync29, readdirSync as readdirSync19, readlinkSync as readlinkSync3, renameSync as renameSync7, rmSync as rmSync11, symlinkSync, writeFileSync as writeFileSync12 } from "node:fs";
24375
- import { dirname as dirname12, join as join35, resolve as resolve21 } from "node:path";
24443
+ import { dirname as dirname12, join as join35, resolve as resolve22 } from "node:path";
24376
24444
  import { tmpdir as tmpdir6 } from "node:os";
24377
24445
  var MARKER6 = ".plgnz-install.json";
24378
24446
  var MANAGED = "plgnz";
@@ -24524,7 +24592,7 @@ function validateLegacy(rows, id, name, version, adopt) {
24524
24592
  if (typeof row.installPath !== "string" || typeof row.version !== "string" || row.version !== version || marketplace === undefined)
24525
24593
  throw new Error(`OMP marketplace install ${id} has no safe native copy`);
24526
24594
  const expected = join35(cache, `${marketplace}___${name}___${version}`);
24527
- if (resolve21(row.installPath) !== resolve21(expected))
24595
+ if (resolve22(row.installPath) !== resolve22(expected))
24528
24596
  throw new Error(`OMP marketplace install ${id} is outside its approved cache slot`);
24529
24597
  assertExistingDirectoryTree(cache, row.installPath, `OMP marketplace install ${id}`);
24530
24598
  const manifest = readDoc(join35(row.installPath, "plugin.json"), {}, "legacy plugin manifest");
@@ -24533,7 +24601,7 @@ function validateLegacy(rows, id, name, version, adopt) {
24533
24601
  }
24534
24602
  }
24535
24603
  function cleanupLegacy(row, name, retainedPaths) {
24536
- if (typeof row.installPath !== "string" || retainedPaths.has(resolve21(row.installPath)))
24604
+ if (typeof row.installPath !== "string" || retainedPaths.has(resolve22(row.installPath)))
24537
24605
  return;
24538
24606
  const legacyLink = join35(pluginsDir3(), "node_modules", name);
24539
24607
  if (linkPointsTo(legacyLink, row.installPath))
@@ -24555,7 +24623,7 @@ function registryInstallPaths(registry) {
24555
24623
  if (Array.isArray(value)) {
24556
24624
  for (const row of value)
24557
24625
  if (isDoc(row) && typeof row.installPath === "string")
24558
- paths.add(resolve21(row.installPath));
24626
+ paths.add(resolve22(row.installPath));
24559
24627
  }
24560
24628
  return paths;
24561
24629
  }
@@ -24587,7 +24655,7 @@ function lstatExists(path) {
24587
24655
  }
24588
24656
  function linkPointsTo(path, target) {
24589
24657
  try {
24590
- return lstatSync21(path).isSymbolicLink() && resolve21(dirname12(path), readlinkSync3(path)) === resolve21(target);
24658
+ return lstatSync21(path).isSymbolicLink() && resolve22(dirname12(path), readlinkSync3(path)) === resolve22(target);
24591
24659
  } catch {
24592
24660
  return false;
24593
24661
  }
@@ -24620,8 +24688,8 @@ function activate4(stage, target) {
24620
24688
  } };
24621
24689
  }
24622
24690
  function mkdirSafe(path) {
24623
- const boundary = resolve21(pluginsDir3());
24624
- const target = resolve21(path);
24691
+ const boundary = resolve22(pluginsDir3());
24692
+ const target = resolve22(path);
24625
24693
  if (target !== boundary && !target.startsWith(`${boundary}/`))
24626
24694
  throw new Error(`OMP managed path escapes the plugin store: ${target}`);
24627
24695
  const parentBoundary = dirname12(boundary);
@@ -24646,8 +24714,8 @@ function mkdirSafe(path) {
24646
24714
  }
24647
24715
  }
24648
24716
  function assertExistingDirectoryTree(boundaryPath, targetPath, label) {
24649
- const boundary = resolve21(boundaryPath);
24650
- const target = resolve21(targetPath);
24717
+ const boundary = resolve22(boundaryPath);
24718
+ const target = resolve22(targetPath);
24651
24719
  if (target !== boundary && !target.startsWith(`${boundary}/`))
24652
24720
  throw new Error(`${label} escapes its approved cache root`);
24653
24721
  for (let current = target;; current = dirname12(current)) {
@@ -24845,7 +24913,7 @@ var ompLifecycleDefinition = {
24845
24913
  sourceRevision: request.snapshot.immutableRevision,
24846
24914
  sourceLocator: locator
24847
24915
  }));
24848
- return { stagingId: `${request.snapshot.attemptId}:${request.snapshot.operationId}`, stagingRoot: resolve21(stage) };
24916
+ return { stagingId: `${request.snapshot.attemptId}:${request.snapshot.operationId}`, stagingRoot: resolve22(stage) };
24849
24917
  },
24850
24918
  applyLifecycleDirectives: () => Promise.resolve([]),
24851
24919
  applyPins: async (projection) => {
@@ -24925,16 +24993,16 @@ function npmName(nativeId) {
24925
24993
  }
24926
24994
  function managedPackageDir(nativeId) {
24927
24995
  const { marketplace, plugin } = parsePublicId(nativeId);
24928
- return resolve21(join35(pluginsDir3(), MANAGED, nativeSlug(marketplace, plugin)));
24996
+ return resolve22(join35(pluginsDir3(), MANAGED, nativeSlug(marketplace, plugin)));
24929
24997
  }
24930
24998
  function managedLink(nativeId) {
24931
- return resolve21(join35(pluginsDir3(), "node_modules", npmName(nativeId)));
24999
+ return resolve22(join35(pluginsDir3(), "node_modules", npmName(nativeId)));
24932
25000
  }
24933
25001
  function lockPath() {
24934
25002
  return join35(pluginsDir3(), "omp-plugins.lock.json");
24935
25003
  }
24936
25004
  function preparationDir2(attemptId, operationId) {
24937
- return resolve21(join35(pluginsDir3(), ".plgnz-lifecycle", encodeURIComponent(attemptId), encodeURIComponent(operationId)));
25005
+ return resolve22(join35(pluginsDir3(), ".plgnz-lifecycle", encodeURIComponent(attemptId), encodeURIComponent(operationId)));
24938
25006
  }
24939
25007
  function unprovenCandidate(nativeId) {
24940
25008
  const { marketplace, plugin } = parsePublicId(nativeId);
@@ -24975,7 +25043,7 @@ async function observeInventory(target) {
24975
25043
  return { target, installations: omp.listInstalled().map((plugin) => installationOf(plugin)) };
24976
25044
  }
24977
25045
  function installationOf(plugin) {
24978
- const path = plugin.path !== undefined && existsSync25(plugin.path) ? resolve21(plugin.path) : undefined;
25046
+ const path = plugin.path !== undefined && existsSync25(plugin.path) ? resolve22(plugin.path) : undefined;
24979
25047
  if (path === undefined) {
24980
25048
  return {
24981
25049
  nativeId: plugin.id,
@@ -24993,14 +25061,15 @@ function installationOf(plugin) {
24993
25061
  const owner = ownership2(path);
24994
25062
  const digest = fingerprintTree(path);
24995
25063
  const enabled = plugin.enabled !== false;
25064
+ const resolvedScopeId = owner?.pluginId === plugin.id ? owner.scopeId ?? resolveLegacyV1MarkerScopeId({ target: { kind: "omp", instance: "default" }, nativeId: plugin.id, marker: owner, installedFingerprint: digest }) : undefined;
24996
25065
  return {
24997
25066
  nativeId: plugin.id,
24998
25067
  packageName: plugin.name,
24999
- ownership: owner?.scopeId !== undefined ? { kind: "owned", proof: "created", scopeId: owner.scopeId, proofId: owner.fingerprint } : { kind: "unmanaged" },
25068
+ ownership: resolvedScopeId !== undefined && owner !== null ? { kind: "owned", proof: "created", scopeId: resolvedScopeId, proofId: owner.fingerprint } : { kind: "unmanaged" },
25000
25069
  presence: "present",
25001
25070
  enablement: enabled ? "enabled" : "disabled",
25002
25071
  activation: enabled ? "active" : "inactive",
25003
- ...owner?.scopeId !== undefined && owner.pluginId === plugin.id && path === resolve21(managedPackageDir(plugin.id)) && linkPointsTo(managedLink(plugin.id), path) ? { observedRoute: "managed" } : {},
25072
+ ...owner?.scopeId !== undefined && owner.pluginId === plugin.id && path === resolve22(managedPackageDir(plugin.id)) && linkPointsTo(managedLink(plugin.id), path) ? { observedRoute: "managed" } : {},
25004
25073
  installedFingerprint: digest,
25005
25074
  installedVersion: plugin.version ?? null,
25006
25075
  source: sourceOf2(owner),
@@ -25111,7 +25180,7 @@ function captureRollback3(nativeId, attemptId, operationId) {
25111
25180
  if (existsSync25(target))
25112
25181
  cpSync9(target, join35(reference, "package"), { recursive: true });
25113
25182
  writeFileSync12(join35(reference, "state.json"), JSON.stringify({ lock: captureLockRow(nativeId), link: currentLinkTarget(managedLink(nativeId)) }));
25114
- return resolve21(reference);
25183
+ return resolve22(reference);
25115
25184
  }
25116
25185
  function restoreRollback2(nativeId, reference) {
25117
25186
  const state = JSON.parse(readFileSync29(join35(reference, "state.json"), "utf8"));
@@ -25158,7 +25227,7 @@ function restoreLockRow(saved) {
25158
25227
  }
25159
25228
  function currentLinkTarget(path) {
25160
25229
  try {
25161
- return lstatSync21(path).isSymbolicLink() ? resolve21(dirname12(path), readlinkSync3(path)) : null;
25230
+ return lstatSync21(path).isSymbolicLink() ? resolve22(dirname12(path), readlinkSync3(path)) : null;
25162
25231
  } catch {
25163
25232
  return null;
25164
25233
  }
@@ -25467,7 +25536,7 @@ function writeExactFile(path, text) {
25467
25536
 
25468
25537
  // src/hosts/pi-writer.ts
25469
25538
  import { existsSync as existsSync27, lstatSync as lstatSync23, mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync11, readFileSync as readFileSync31, readdirSync as readdirSync20, renameSync as renameSync9, rmSync as rmSync13, writeFileSync as writeFileSync14 } from "node:fs";
25470
- import { basename as basename4, dirname as dirname14, join as join37, resolve as resolve22 } from "node:path";
25539
+ import { basename as basename4, dirname as dirname14, join as join37, resolve as resolve23 } from "node:path";
25471
25540
  import { tmpdir as tmpdir8 } from "node:os";
25472
25541
  var MARKER7 = ".plgnz-install.json";
25473
25542
  var piWriter = {
@@ -25725,7 +25794,7 @@ function assertRealDirectory(path) {
25725
25794
  throw new Error(`Pi managed path component is not a directory: ${path}`);
25726
25795
  }
25727
25796
  function assertUnder(root, path) {
25728
- const base = resolve22(root), candidate = resolve22(path);
25797
+ const base = resolve23(root), candidate = resolve23(path);
25729
25798
  if (candidate !== base && !candidate.startsWith(`${base}/`))
25730
25799
  throw new Error(`Pi path escapes standalone skills store: ${path}`);
25731
25800
  let current = base;
@@ -25748,7 +25817,7 @@ var piHookWriter = createNativeHookWriter({
25748
25817
 
25749
25818
  // src/hosts/dcode-writer.ts
25750
25819
  import { cpSync as cpSync11, existsSync as existsSync28, lstatSync as lstatSync24, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync12, readFileSync as readFileSync32, readdirSync as readdirSync21, realpathSync as realpathSync5, renameSync as renameSync10, rmSync as rmSync14, writeFileSync as writeFileSync15 } from "node:fs";
25751
- import { basename as basename5, dirname as dirname15, join as join38, resolve as resolve23 } from "node:path";
25820
+ import { basename as basename5, dirname as dirname15, join as join38, resolve as resolve24 } from "node:path";
25752
25821
  import { tmpdir as tmpdir9 } from "node:os";
25753
25822
  import { spawn as spawnChild } from "node:child_process";
25754
25823
  var MARKER8 = ".plgnz-install.json";
@@ -25941,7 +26010,7 @@ function captureDcodeRollback(binding, attemptId, operationId) {
25941
26010
  }
25942
26011
  function assertRecoveryRollbackMetadata(handle, state) {
25943
26012
  const rows = rowsFor(state.row);
25944
- if (rows.length !== handle.prior.contentRoots.length || rows.some((row, index) => resolve23(rowInstall(row, handle.nativeId)) !== resolve23(handle.prior.contentRoots[index].path)) || handle.prior.presence === "present" && state.enabled === true !== (handle.prior.enablement === "enabled"))
26013
+ if (rows.length !== handle.prior.contentRoots.length || rows.some((row, index) => resolve24(rowInstall(row, handle.nativeId)) !== resolve24(handle.prior.contentRoots[index].path)) || handle.prior.presence === "present" && state.enabled === true !== (handle.prior.enablement === "enabled"))
25945
26014
  throw new Error("dcode rollback registry snapshot differs from the sealed prior; recovery refused");
25946
26015
  }
25947
26016
  async function lockPreparation(binding, attemptId, operationId, expectedObservationId) {
@@ -26156,7 +26225,7 @@ var dcodeDefinition = {
26156
26225
  const target = handle.projectedFingerprint === null ? undefined : lifecycleSlot(handle.nativeId, handle.projectedFingerprint);
26157
26226
  if (target !== undefined)
26158
26227
  assertCachePath(target);
26159
- if (target !== undefined && existsSync28(target) && !handle.prior.contentRoots.some((root) => resolve23(root.path) === resolve23(target))) {
26228
+ if (target !== undefined && existsSync28(target) && !handle.prior.contentRoots.some((root) => resolve24(root.path) === resolve24(target))) {
26160
26229
  if (ownership3(target)?.pluginId !== handle.nativeId || recoveringNativeLocks.has(`${handle.attemptId}:${handle.operationId}`) && fingerprintTree(target) !== handle.projectedFingerprint)
26161
26230
  throw new Error("dcode rollback candidate differs from the sealed operation; refusing stale overwrite");
26162
26231
  rmSync14(target, { recursive: true });
@@ -26179,7 +26248,7 @@ var dcodeDefinition = {
26179
26248
  },
26180
26249
  beginRecovery: async (handle) => {
26181
26250
  const reference = join38(lifecycleDirectory(handle.attemptId, handle.operationId), "rollback");
26182
- if (resolve23(handle.rollbackReference) !== resolve23(reference))
26251
+ if (resolve24(handle.rollbackReference) !== resolve24(reference))
26183
26252
  throw new Error("dcode recovery reference escapes the operation-owned artifact directory");
26184
26253
  assertManagedPath4(reference);
26185
26254
  for (const root of [...handle.prior.contentRoots, ...handle.expected.contentRoots])
@@ -26198,12 +26267,12 @@ var dcodeDefinition = {
26198
26267
  const priorFile = join38(dir, "rollback", "state.json");
26199
26268
  const next = readDoc2(nextFile, {}, "cleanup target");
26200
26269
  if (disposition === "verified-commit" && recovering !== undefined) {
26201
- const retiredRoots = recovering.prior.contentRoots.filter((root) => !recovering.expected.contentRoots.some((next) => resolve23(next.path) === resolve23(root.path)));
26270
+ const retiredRoots = recovering.prior.contentRoots.filter((root) => !recovering.expected.contentRoots.some((next) => resolve24(next.path) === resolve24(root.path)));
26202
26271
  if (existsSync28(priorFile))
26203
26272
  assertRecoveryRollbackMetadata(recovering, readDoc2(priorFile, {}, "rollback state"));
26204
26273
  else if (retiredRoots.some((root) => existsSync28(root.path)))
26205
26274
  throw new Error("dcode cleanup prior metadata is missing; recovery refused");
26206
- if (existsSync28(nextFile) && (typeof next.target !== "string" || !recovering.expected.contentRoots.some((root) => resolve23(root.path) === resolve23(next.target))))
26275
+ if (existsSync28(nextFile) && (typeof next.target !== "string" || !recovering.expected.contentRoots.some((root) => resolve24(root.path) === resolve24(next.target))))
26207
26276
  throw new Error("dcode cleanup target differs from the sealed expected root; recovery refused");
26208
26277
  for (const root of retiredRoots) {
26209
26278
  if (existsSync28(root.path) && fingerprintTree(root.path) !== root.fingerprint)
@@ -26216,7 +26285,7 @@ var dcodeDefinition = {
26216
26285
  for (const row of rowsFor(prior.row)) {
26217
26286
  const path = rowInstall(row, reference.operationId);
26218
26287
  assertCachePath(path);
26219
- if (resolve23(path) !== resolve23(next.target))
26288
+ if (resolve24(path) !== resolve24(next.target))
26220
26289
  rmSync14(path, { recursive: true, force: true });
26221
26290
  }
26222
26291
  }
@@ -26291,7 +26360,7 @@ var dcodeWriter = {
26291
26360
  if (existsSync28(target) && slot === null)
26292
26361
  throw new Error(`dcode cache target is unowned; refusing to replace it: ${target}`);
26293
26362
  const former = prior.kind === "none" ? undefined : prior.path;
26294
- const unchanged = (former === undefined || resolve23(former) === resolve23(target)) && slot?.kind === "current" && slot.fingerprint === sourceFingerprint && slot.projectedFingerprint === projected && slot.sourceRevision === resolved.sha && sameTree7(stage, target);
26363
+ const unchanged = (former === undefined || resolve24(former) === resolve24(target)) && slot?.kind === "current" && slot.fingerprint === sourceFingerprint && slot.projectedFingerprint === projected && slot.sourceRevision === resolved.sha && sameTree7(stage, target);
26295
26364
  const nextRegistry = { ...registry, plugins: { ...plugins, [id]: [{ installPath: target }] } };
26296
26365
  const nextEnablement = { ...enablement, enabledPlugins: { ...enabled, [id]: true } };
26297
26366
  if (opts?.dryRun) {
@@ -26325,7 +26394,7 @@ var dcodeWriter = {
26325
26394
  throw error;
26326
26395
  }
26327
26396
  activation.commit();
26328
- if (former !== undefined && resolve23(former) !== resolve23(target)) {
26397
+ if (former !== undefined && resolve24(former) !== resolve24(target)) {
26329
26398
  const retained = retireFormer(former);
26330
26399
  if (retained !== undefined)
26331
26400
  console.error(`[dcode] retained former cache: ${retained}`);
@@ -26492,7 +26561,7 @@ function assertReadback(id, registryFile, enablementFile, target, version, proje
26492
26561
  if (rows.length !== 1)
26493
26562
  throw new Error(`dcode readback failed for ${id}`);
26494
26563
  const install = rowInstall(rows[0], id);
26495
- if (resolve23(install) !== resolve23(target))
26564
+ if (resolve24(install) !== resolve24(target))
26496
26565
  throw new Error(`dcode readback path mismatch for ${id}`);
26497
26566
  if (rows[0].version !== undefined && rows[0].version !== null)
26498
26567
  throw new Error(`dcode managed install is eligible for native auto-update: ${id}`);
@@ -26713,8 +26782,8 @@ function assertIdentity2(value, label) {
26713
26782
  throw new Error(`invalid dcode ${label}`);
26714
26783
  }
26715
26784
  function assertCachePath(path) {
26716
- const root = resolve23(dcodeCacheRoot());
26717
- const target = resolve23(path);
26785
+ const root = resolve24(dcodeCacheRoot());
26786
+ const target = resolve24(path);
26718
26787
  if (target === root || !target.startsWith(`${root}/`))
26719
26788
  throw new Error(`dcode path escapes managed cache: ${path}`);
26720
26789
  let current = root;
@@ -26738,8 +26807,8 @@ function assertCachePath(path) {
26738
26807
  throw new Error(`dcode path escapes managed cache: ${path}`);
26739
26808
  }
26740
26809
  function assertManagedPath4(path) {
26741
- const root = resolve23(dcodeRoot());
26742
- const target = resolve23(path);
26810
+ const root = resolve24(dcodeRoot());
26811
+ const target = resolve24(path);
26743
26812
  if (target !== root && !target.startsWith(`${root}/`))
26744
26813
  throw new Error(`dcode path escapes native root: ${path}`);
26745
26814
  let current = root;
@@ -27147,7 +27216,7 @@ var opencodeHookWriter = createNativeHookWriter({
27147
27216
  // src/hosts/grok-writer.ts
27148
27217
  import { spawnSync as spawnSync6 } from "node:child_process";
27149
27218
  import { cpSync as cpSync13, existsSync as existsSync30, lstatSync as lstatSync26, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync14, readFileSync as readFileSync34, readdirSync as readdirSync23, readlinkSync as readlinkSync4, renameSync as renameSync12, rmSync as rmSync16, symlinkSync as symlinkSync2, writeFileSync as writeFileSync17 } from "node:fs";
27150
- import { dirname as dirname17, join as join40, resolve as resolve25 } from "node:path";
27219
+ import { dirname as dirname17, join as join40, resolve as resolve26 } from "node:path";
27151
27220
  import { tmpdir as tmpdir11 } from "node:os";
27152
27221
  var stableId = (plugin) => plugin.marketplace === undefined ? plugin.name : `${plugin.name}@${plugin.marketplace}`;
27153
27222
  var digest6 = (value) => {
@@ -27574,7 +27643,7 @@ function legacyCandidate(plugin, adopt, prior) {
27574
27643
  throw new Error(`Grok ${plugin.name}: legacy source, version, and native bytes must match before adoption`);
27575
27644
  const link = join40(grokRoot(), "plugins", plugin.name);
27576
27645
  if (existsSync30(link) || lstatExists2(link)) {
27577
- if (!lstatSync26(link).isSymbolicLink() || canonical(resolve25(dirname17(link), readlinkSync4(link))) !== installed)
27646
+ if (!lstatSync26(link).isSymbolicLink() || canonical(resolve26(dirname17(link), readlinkSync4(link))) !== installed)
27578
27647
  throw new Error(`Grok ${plugin.name}: unmanaged same-name plugin link blocks adoption`);
27579
27648
  }
27580
27649
  return { source, fingerprint: fingerprintTree(installed), ...lstatExists2(link) ? { link } : {} };
@@ -27658,17 +27727,17 @@ function probeGrokVersion() {
27658
27727
  return parseGrokVersionOutput(result.stdout ?? "", result.status);
27659
27728
  }
27660
27729
  function lifecycleMarketplace(scopeId, nativeId) {
27661
- return resolve25(join40(marketplacesRoot(), `plgnz-${digest6(`${scopeId}\x00${nativeId}`)}`));
27730
+ return resolve26(join40(marketplacesRoot(), `plgnz-${digest6(`${scopeId}\x00${nativeId}`)}`));
27662
27731
  }
27663
27732
  function marketplacePluginPath(scopeId, nativeId, packageName) {
27664
- return resolve25(join40(lifecycleMarketplace(scopeId, nativeId), "plugins", packageName));
27733
+ return resolve26(join40(lifecycleMarketplace(scopeId, nativeId), "plugins", packageName));
27665
27734
  }
27666
27735
  function samePath(left, right) {
27667
- return (canonical(left) ?? resolve25(left)) === (canonical(right) ?? resolve25(right));
27736
+ return (canonical(left) ?? resolve26(left)) === (canonical(right) ?? resolve26(right));
27668
27737
  }
27669
27738
  function registryNativePath(nativeId) {
27670
27739
  const installed = grok.listInstalled().find((plugin) => plugin.id === nativeId && plugin.path !== undefined);
27671
- return installed?.path === undefined ? undefined : resolve25(installed.path);
27740
+ return installed?.path === undefined ? undefined : resolve26(installed.path);
27672
27741
  }
27673
27742
  function declaredVersion(dir) {
27674
27743
  try {
@@ -27727,7 +27796,7 @@ function installationRecord2(plugin) {
27727
27796
  installedFingerprint: digest,
27728
27797
  installedVersion: declaredVersion(plugin.path),
27729
27798
  source: { type: "local", immutableRevision: marker?.immutableRevision ?? digest, locator: null },
27730
- contentRoots: [{ label: "native", path: resolve25(plugin.path), fingerprint: digest }]
27799
+ contentRoots: [{ label: "native", path: resolve26(plugin.path), fingerprint: digest }]
27731
27800
  };
27732
27801
  }
27733
27802
  function targetInventory(target) {
@@ -27774,7 +27843,7 @@ function liveReadback(handle) {
27774
27843
  activation: enabled ? "active" : "inactive",
27775
27844
  transition: RELOAD_EFFECTIVE2,
27776
27845
  installedFingerprint: digest,
27777
- contentRoots: [{ label: "native", path: resolve25(plugin.path), fingerprint: digest }],
27846
+ contentRoots: [{ label: "native", path: resolve26(plugin.path), fingerprint: digest }],
27778
27847
  retention: ABSENT_RETENTION
27779
27848
  };
27780
27849
  }
@@ -27826,7 +27895,7 @@ function stageMarketplace(snapshot) {
27826
27895
  writeFileSync17(catalog, JSON.stringify({ name: basename6(finalPath), plugins: [{ name: snapshot.packageName, source: `./plugins/${snapshot.packageName}` }] }));
27827
27896
  writeStagedMarker(stagedRoot, snapshot, fingerprintTree(stagedPlugin));
27828
27897
  run(["plugin", "validate", stagedPlugin]);
27829
- return { stagingId: `stage:${snapshot.attemptId}:${snapshot.operationId}`, stagingRoot: resolve25(stagedPlugin) };
27898
+ return { stagingId: `stage:${snapshot.attemptId}:${snapshot.operationId}`, stagingRoot: resolve26(stagedPlugin) };
27830
27899
  } catch (error) {
27831
27900
  discardStage(snapshot.attemptId, snapshot.operationId);
27832
27901
  throw error;
@@ -27851,7 +27920,7 @@ function applyRecordedPins2(pluginDir, pins) {
27851
27920
  return pins.map(({ server }) => server);
27852
27921
  }
27853
27922
  function rollbackDirectory(attemptId, operationId) {
27854
- return resolve25(join40(grokRoot(), "plgnz-rollback", `${attemptId}-${operationId}`));
27923
+ return resolve26(join40(grokRoot(), "plgnz-rollback", `${attemptId}-${operationId}`));
27855
27924
  }
27856
27925
  function pluginNamesOf(repo) {
27857
27926
  const plugins = repo["plugins"];
@@ -27940,7 +28009,7 @@ function captureHostSnapshot(directory, nativeId, packageName, attemptId, operat
27940
28009
  cpSync13(priorConfig, join40(directory, "config-prior.json"));
27941
28010
  const plugin = grok.listInstalled().find((candidate) => candidate.id === nativeId);
27942
28011
  if (plugin?.path !== undefined) {
27943
- const native = resolve25(plugin.path);
28012
+ const native = resolve26(plugin.path);
27944
28013
  cpSync13(native, join40(directory, "native"), { recursive: true });
27945
28014
  writeFileSync17(join40(directory, "native-path.txt"), native);
27946
28015
  }
@@ -27961,13 +28030,13 @@ function freshNativePaths(directory, marketplacePath) {
27961
28030
  const paths = new Set;
27962
28031
  const saved = savedRegistryRepo(directory);
27963
28032
  if (saved.repo !== null && typeof saved.repo["path"] === "string" && pluginNamesOf(saved.repo).length === 0)
27964
- paths.add(resolve25(saved.repo["path"]));
28033
+ paths.add(resolve26(saved.repo["path"]));
27965
28034
  for (const [, repo] of repos()) {
27966
28035
  if (typeof repo.path !== "string")
27967
28036
  continue;
27968
28037
  const provenance = provenanceOf(repo);
27969
28038
  if (provenance !== null && samePath(provenance.root, marketplacePath))
27970
- paths.add(resolve25(repo.path));
28039
+ paths.add(resolve26(repo.path));
27971
28040
  }
27972
28041
  return [...paths];
27973
28042
  }
@@ -28216,7 +28285,7 @@ function withRecordedInstallPath(handle, observedPath) {
28216
28285
  if (handle.action !== "install" || handle.prior.presence !== "absent")
28217
28286
  return handle;
28218
28287
  const recorded = registryNativePath(handle.nativeId);
28219
- if (recorded === undefined || observedPath === undefined || resolve25(observedPath) !== recorded)
28288
+ if (recorded === undefined || observedPath === undefined || resolve26(observedPath) !== recorded)
28220
28289
  return handle;
28221
28290
  return {
28222
28291
  ...handle,
@@ -28240,12 +28309,12 @@ function createGrokLifecycleAdapter() {
28240
28309
  // src/hosts/zcode-cli-writer.ts
28241
28310
  init_zcode_cli_hooks();
28242
28311
  import { chmodSync as chmodSync3, cpSync as cpSync14, existsSync as existsSync31, lstatSync as lstatSync28, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync15, readFileSync as readFileSync36, readdirSync as readdirSync25, realpathSync as realpathSync6, renameSync as renameSync13, rmSync as rmSync17, statSync as statSync13, writeFileSync as writeFileSync18 } from "node:fs";
28243
- import { basename as basename7, dirname as dirname19, join as join42, resolve as resolve27 } from "node:path";
28312
+ import { basename as basename7, dirname as dirname19, join as join42, resolve as resolve28 } from "node:path";
28244
28313
  import { tmpdir as tmpdir12 } from "node:os";
28245
28314
 
28246
28315
  // src/hosts/zcode-cli-projection.ts
28247
28316
  import { lstatSync as lstatSync27, readFileSync as readFileSync35, readdirSync as readdirSync24 } from "node:fs";
28248
- import { dirname as dirname18, join as join41, relative as relative8, resolve as resolve26 } from "node:path";
28317
+ import { dirname as dirname18, join as join41, relative as relative8, resolve as resolve27 } from "node:path";
28249
28318
  var encode2 = (value) => new TextEncoder().encode(value);
28250
28319
  var decode = (value) => new TextDecoder().decode(value);
28251
28320
  function readZcodeProjectionTree(root) {
@@ -28547,7 +28616,7 @@ ${body}`, skill);
28547
28616
  return all;
28548
28617
  if (target.startsWith("/") || target.includes("\\"))
28549
28618
  throw new Error(`ZCode unsupported absolute resource reference: ${skill}`);
28550
- const rel = relative8(resolve26(source, skillRoot), resolve26(source, skillRoot, target));
28619
+ const rel = relative8(resolve27(source, skillRoot), resolve27(source, skillRoot, target));
28551
28620
  if (rel === "" || rel.startsWith("..") || resources.get(`${skillRoot}/${rel}`)?.kind !== "file")
28552
28621
  throw new Error(`ZCode resource reference escapes or is missing: ${skill} (${target})`);
28553
28622
  return `${label}(${join41(resourceLinks, skillRoot, rel)}${suffix ?? ""})`;
@@ -28658,10 +28727,10 @@ var zcodeCliWriter = {
28658
28727
  }
28659
28728
  };
28660
28729
  function projectZcodePlugin(source, destination, resourceCopy, resourceLinkRoot, logicalId, nativeId, nativeVersion, fingerprint, sourceUri) {
28661
- const input = resolve27(source);
28662
- const target = resolve27(destination);
28663
- const ownedResources = resolve27(resourceCopy);
28664
- const links = resolve27(resourceLinkRoot);
28730
+ const input = resolve28(source);
28731
+ const target = resolve28(destination);
28732
+ const ownedResources = resolve28(resourceCopy);
28733
+ const links = resolve28(resourceLinkRoot);
28665
28734
  if (!existsSync31(input) || !statSync13(input).isDirectory())
28666
28735
  throw new Error(`ZCode plugin source is not a directory: ${input}`);
28667
28736
  if (target === input || ownedResources === input || target.startsWith(`${input}/`) || ownedResources.startsWith(`${input}/`))
@@ -28737,12 +28806,12 @@ function commandNames(dir, prefix = "") {
28737
28806
  }
28738
28807
  function rejectCommandCollisions(stagedMarket, nativeId, ownPrior) {
28739
28808
  const candidate = commandNames(join42(stagedMarket, "plugins"));
28740
- const own = ownPrior === undefined ? undefined : resolve27(ownPrior);
28809
+ const own = ownPrior === undefined ? undefined : resolve28(ownPrior);
28741
28810
  const enabled = readZcodeEnabledPluginIds();
28742
28811
  for (const native of readZcodeNativeRecords()) {
28743
28812
  if (enabled.get(native.id) !== true)
28744
28813
  continue;
28745
- if (own !== undefined && resolve27(native.installPath) === own)
28814
+ if (own !== undefined && resolve28(native.installPath) === own)
28746
28815
  continue;
28747
28816
  const root = zcodeSafeInstallRoot(native.installPath);
28748
28817
  if (root === undefined)
@@ -29045,7 +29114,7 @@ function capturedNativeRoot(reference, attemptId, operationId) {
29045
29114
  throw error;
29046
29115
  }
29047
29116
  }
29048
- if (resolve27(reference) !== reference || reference !== join42(root, "plgnz-lifecycle", attemptId, operationId) || canonicalExistingPath(root) !== root || canonicalExistingPath(reference) !== reference || realpathSync6(zcodeCliRoot()) !== root)
29117
+ if (resolve28(reference) !== reference || reference !== join42(root, "plgnz-lifecycle", attemptId, operationId) || canonicalExistingPath(root) !== root || canonicalExistingPath(reference) !== reference || realpathSync6(zcodeCliRoot()) !== root)
29049
29118
  throw new Error("ZCode captured native root was redirected");
29050
29119
  return root;
29051
29120
  }
@@ -29736,7 +29805,7 @@ var zcodeCliLifecycle = createLifecycleHostAdapter(zcodeCliLifecycleDefinition);
29736
29805
 
29737
29806
  // src/hosts/hermes-writer.ts
29738
29807
  import { chmodSync as chmodSync4, cpSync as cpSync15, existsSync as existsSync32, lstatSync as lstatSync29, mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync16, readFileSync as readFileSync37, readdirSync as readdirSync26, realpathSync as realpathSync7, renameSync as renameSync14, rmSync as rmSync18, statSync as statSync14, writeFileSync as writeFileSync19 } from "node:fs";
29739
- import { basename as basename8, dirname as dirname20, isAbsolute as isAbsolute12, join as join43, resolve as resolve28 } from "node:path";
29808
+ import { basename as basename8, dirname as dirname20, isAbsolute as isAbsolute12, join as join43, resolve as resolve29 } from "node:path";
29740
29809
  import { tmpdir as tmpdir13 } from "node:os";
29741
29810
 
29742
29811
  // src/hosts/hermes-launcher-templates.ts
@@ -30243,8 +30312,8 @@ function updatePluginConfig(configured, enable, disable) {
30243
30312
  }
30244
30313
  }
30245
30314
  function effectiveConfigPath() {
30246
- const native = resolve28(join43(hermesRoot(), "config.yaml"));
30247
- const configured = resolve28(hermesConfigPath());
30315
+ const native = resolve29(join43(hermesRoot(), "config.yaml"));
30316
+ const configured = resolve29(hermesConfigPath());
30248
30317
  if (native === configured)
30249
30318
  return configured;
30250
30319
  if (!existsSync32(native) || !existsSync32(configured))
@@ -30300,7 +30369,7 @@ function assertTree3(root) {
30300
30369
  }
30301
30370
  }
30302
30371
  function assertManagedPath5(root, target) {
30303
- const base = resolve28(root), selected = resolve28(target);
30372
+ const base = resolve29(root), selected = resolve29(target);
30304
30373
  if (selected !== base && !selected.startsWith(`${base}/`))
30305
30374
  throw new Error(`Hermes managed path escapes its store: ${target}`);
30306
30375
  let current = base;
@@ -30640,8 +30709,8 @@ function storeFor(target) {
30640
30709
  return { root: identity.root, configPath: resolveInstanceConfig(identity.root, identity.configPath), pluginsDir: join43(identity.root, "plugins") };
30641
30710
  }
30642
30711
  function resolveInstanceConfig(root, configPath) {
30643
- const native = resolve28(join43(root, "config.yaml"));
30644
- const configured = resolve28(configPath);
30712
+ const native = resolve29(join43(root, "config.yaml"));
30713
+ const configured = resolve29(configPath);
30645
30714
  if (native === configured)
30646
30715
  return configured;
30647
30716
  if (!existsSync32(native) || !existsSync32(configured))
@@ -31552,7 +31621,7 @@ function invalidSelection2(diagnostic) {
31552
31621
 
31553
31622
  // src/recorded-pins.ts
31554
31623
  import { existsSync as existsSync33, readFileSync as readFileSync38 } from "node:fs";
31555
- import { isAbsolute as isAbsolute13, join as join44, resolve as resolve29 } from "node:path";
31624
+ import { isAbsolute as isAbsolute13, join as join44, resolve as resolve30 } from "node:path";
31556
31625
  function resolveRecordedPinExecutables(packageRoot, servers) {
31557
31626
  const pins = [];
31558
31627
  const dropped = [];
@@ -31600,11 +31669,11 @@ function absolutePinExecutable(command) {
31600
31669
  if (command.includes("/")) {
31601
31670
  if (!isAbsolute13(command))
31602
31671
  return null;
31603
- const canonical = resolve29(command);
31672
+ const canonical = resolve30(command);
31604
31673
  return canonical === command ? command : null;
31605
31674
  }
31606
31675
  const found = which2(command);
31607
- return found === null ? null : resolve29(found);
31676
+ return found === null ? null : resolve30(found);
31608
31677
  }
31609
31678
 
31610
31679
  // src/planner.ts
@@ -33536,7 +33605,7 @@ class Ledger {
33536
33605
  return this.state.attempts.find((attempt) => attempt.id === attemptId)?.journal.find((row) => row.operationId === operationId)?.state;
33537
33606
  }
33538
33607
  activation(scopeId, packageId, nativeId) {
33539
- return this.state.activations.find((row) => row.scopeId === scopeId && row.packageId === packageId && row.nativeId === nativeId);
33608
+ return this.state.activations.find((row) => row.scopeId === scopeId && (row.packageId === packageId || row.ownership.kind === "legacy-claim" && row.nativeId === nativeId) && row.nativeId === nativeId);
33540
33609
  }
33541
33610
  scope(scopeId) {
33542
33611
  return this.state.scopes.find((row) => row.id === scopeId);
@@ -33840,7 +33909,7 @@ function legacyMarketplaceAlias(row, canonical) {
33840
33909
  if (separator <= 0 || row.packageId !== row.nativeId)
33841
33910
  return false;
33842
33911
  const name = row.nativeId.slice(0, separator);
33843
- return name === canonical.packageId && name === canonical.nativeId;
33912
+ return name === canonical.packageId && (name === canonical.nativeId || row.nativeId === canonical.nativeId);
33844
33913
  }
33845
33914
  function legacyBareMarketplaceAlias(row, canonical) {
33846
33915
  return isBareMarketplaceAlias(row, canonical.scopeId, canonical.packageId, canonical.nativeId);
@@ -35239,7 +35308,7 @@ function legacyCommandAction(command) {
35239
35308
  // package.json
35240
35309
  var package_default = {
35241
35310
  name: "plugnz",
35242
- version: "0.0.32",
35311
+ version: "0.0.33",
35243
35312
  description: "Install, diagnose and update agent plugins (Agent Plugins spec) and MCP configs across Claude Code, Codex, Cursor, Kimi and more",
35244
35313
  license: "MIT",
35245
35314
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugnz",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "Install, diagnose and update agent plugins (Agent Plugins spec) and MCP configs across Claude Code, Codex, Cursor, Kimi and more",
5
5
  "license": "MIT",
6
6
  "type": "module",