harnesstap 1.0.2 → 1.1.0

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/index.js CHANGED
@@ -5548,6 +5548,56 @@ var init_imported_snapshot = __esm({
5548
5548
  }
5549
5549
  });
5550
5550
 
5551
+ // src/services/merge-skill-markdown.ts
5552
+ import matter4 from "gray-matter";
5553
+ function normalizeNewlines(text) {
5554
+ return text.replace(/\r\n/g, "\n");
5555
+ }
5556
+ function generatedIsLiveSubset(live, generated) {
5557
+ const liveNorm = normalizeNewlines(live);
5558
+ const generatedNorm = normalizeNewlines(generated).replace(/\s+$/u, "");
5559
+ if (generatedNorm.length === 0) {
5560
+ return true;
5561
+ }
5562
+ if (liveNorm.startsWith(generatedNorm) || liveNorm.includes(generatedNorm)) {
5563
+ return true;
5564
+ }
5565
+ const liveParsed = matter4(liveNorm);
5566
+ const generatedParsed = matter4(generatedNorm);
5567
+ const generatedBody = generatedParsed.content.trim();
5568
+ if (generatedBody.length === 0) {
5569
+ return true;
5570
+ }
5571
+ return liveParsed.content.includes(generatedBody);
5572
+ }
5573
+ function mergeSkillMarkdown(live, generated) {
5574
+ if (!live) {
5575
+ return generated;
5576
+ }
5577
+ const liveParsed = matter4(normalizeNewlines(live));
5578
+ const generatedParsed = matter4(normalizeNewlines(generated));
5579
+ const data = {
5580
+ ...liveParsed.data,
5581
+ ...generatedParsed.data
5582
+ };
5583
+ const keepLiveBody = generatedIsLiveSubset(live, generated);
5584
+ const body = keepLiveBody ? liveParsed.content : generatedParsed.content;
5585
+ const nonEmpty = Object.fromEntries(
5586
+ Object.entries(data).filter(
5587
+ ([, value]) => value !== void 0 && value !== null && value !== ""
5588
+ )
5589
+ );
5590
+ if (Object.keys(nonEmpty).length === 0) {
5591
+ return body.startsWith("\n") ? body.slice(1) : body;
5592
+ }
5593
+ return matter4.stringify(body.replace(/^\n/, ""), nonEmpty);
5594
+ }
5595
+ var init_merge_skill_markdown = __esm({
5596
+ "src/services/merge-skill-markdown.ts"() {
5597
+ "use strict";
5598
+ }
5599
+ });
5600
+
5551
5601
  // src/services/mcp-target.ts
5552
5602
  function normalizePath2(path, rootPath = "") {
5553
5603
  let normalized = path.replace(/\\/g, "/");
@@ -5630,12 +5680,13 @@ var init_mcp_target = __esm({
5630
5680
  // src/platforms/base-serializer.ts
5631
5681
  import { readFileSync as readFileSync11, existsSync as existsSync14, readdirSync as readdirSync7, statSync as statSync4 } from "fs";
5632
5682
  import { dirname as dirname3, join as join15, relative as relative3, sep as sep3 } from "path";
5633
- import matter4 from "gray-matter";
5683
+ import matter5 from "gray-matter";
5634
5684
  var BaseSerializer;
5635
5685
  var init_base_serializer = __esm({
5636
5686
  "src/platforms/base-serializer.ts"() {
5637
5687
  "use strict";
5638
5688
  init_agent_bridge();
5689
+ init_merge_skill_markdown();
5639
5690
  init_skill_auxiliary();
5640
5691
  init_skill_command_metadata();
5641
5692
  init_mcp_target();
@@ -5696,7 +5747,7 @@ var init_base_serializer = __esm({
5696
5747
  }
5697
5748
  // ── Frontmatter helpers ─────────────────────────────────────────────
5698
5749
  parseFrontmatter(content) {
5699
- const parsed = matter4(content);
5750
+ const parsed = matter5(content);
5700
5751
  return {
5701
5752
  data: parsed.data,
5702
5753
  content: parsed.content
@@ -5718,7 +5769,7 @@ var init_base_serializer = __esm({
5718
5769
  ([, v]) => v !== void 0 && v !== null && v !== ""
5719
5770
  );
5720
5771
  if (nonEmpty.length === 0) return content;
5721
- return matter4.stringify(content, Object.fromEntries(nonEmpty));
5772
+ return matter5.stringify(content, Object.fromEntries(nonEmpty));
5722
5773
  }
5723
5774
  // ── Resource builder helpers ────────────────────────────────────────
5724
5775
  makeResource(type, name, content, source, metadata = {}, description = "") {
@@ -5821,10 +5872,13 @@ var init_base_serializer = __esm({
5821
5872
  name: resource.name,
5822
5873
  description: resource.description
5823
5874
  };
5875
+ const generated = this.emitFrontmatter(fm, resource.content);
5876
+ const liveRoot = options.projectRoot;
5877
+ const live = liveRoot ? this.readFile(join15(liveRoot, skillMdPath)) : void 0;
5824
5878
  const files = [
5825
5879
  {
5826
5880
  path: skillMdPath,
5827
- content: this.emitFrontmatter(fm, resource.content)
5881
+ content: mergeSkillMarkdown(live, generated)
5828
5882
  }
5829
5883
  ];
5830
5884
  const meta = resource.metadata;
@@ -6190,6 +6244,66 @@ var init_mcp_config_bridge = __esm({
6190
6244
  }
6191
6245
  });
6192
6246
 
6247
+ // src/services/merged-host-config.ts
6248
+ function normalizeHostConfigPath(path) {
6249
+ return path.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^~\//, "");
6250
+ }
6251
+ function isClaudeSettingsPath(path) {
6252
+ const normalized = normalizeHostConfigPath(path);
6253
+ return normalized === CLAUDE_SETTINGS_RELATIVE || normalized.endsWith(`/${CLAUDE_SETTINGS_RELATIVE}`);
6254
+ }
6255
+ function isMergeableHostConfigPath(path) {
6256
+ return isClaudeSettingsPath(path);
6257
+ }
6258
+ function parseJsonObject(raw) {
6259
+ try {
6260
+ const parsed = JSON.parse(raw);
6261
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
6262
+ return null;
6263
+ }
6264
+ return parsed;
6265
+ } catch {
6266
+ return null;
6267
+ }
6268
+ }
6269
+ function mergeEnvRecord(existing, overlay) {
6270
+ const base = typeof existing === "object" && existing !== null && !Array.isArray(existing) ? existing : {};
6271
+ const patch = typeof overlay === "object" && overlay !== null && !Array.isArray(overlay) ? overlay : {};
6272
+ return { ...base, ...patch };
6273
+ }
6274
+ function mergeClaudeSettingsContent(existingRaw, generatedRaw) {
6275
+ const generated = parseJsonObject(generatedRaw);
6276
+ if (!generated) {
6277
+ return generatedRaw;
6278
+ }
6279
+ if (!existingRaw) {
6280
+ return `${JSON.stringify(generated, null, 2)}
6281
+ `;
6282
+ }
6283
+ const existing = parseJsonObject(existingRaw);
6284
+ if (!existing) {
6285
+ return `${JSON.stringify(generated, null, 2)}
6286
+ `;
6287
+ }
6288
+ const merged = { ...existing };
6289
+ for (const [key, value] of Object.entries(generated)) {
6290
+ if (key === "env") {
6291
+ merged.env = mergeEnvRecord(existing.env, value);
6292
+ continue;
6293
+ }
6294
+ merged[key] = value;
6295
+ }
6296
+ return `${JSON.stringify(merged, null, 2)}
6297
+ `;
6298
+ }
6299
+ var CLAUDE_SETTINGS_RELATIVE;
6300
+ var init_merged_host_config = __esm({
6301
+ "src/services/merged-host-config.ts"() {
6302
+ "use strict";
6303
+ CLAUDE_SETTINGS_RELATIVE = ".claude/settings.json";
6304
+ }
6305
+ });
6306
+
6193
6307
  // src/platforms/claude-code.ts
6194
6308
  import { join as join16 } from "path";
6195
6309
  var ClaudeCodeSerializer;
@@ -6202,6 +6316,7 @@ var init_claude_code = __esm({
6202
6316
  init_agent_bridge();
6203
6317
  init_hook_serialization();
6204
6318
  init_mcp_config_bridge();
6319
+ init_merged_host_config();
6205
6320
  ClaudeCodeSerializer = class extends BaseSerializer {
6206
6321
  platformId = "claude-code";
6207
6322
  platform;
@@ -6444,9 +6559,10 @@ var init_claude_code = __esm({
6444
6559
  return resources;
6445
6560
  }
6446
6561
  // ── Serialize ───────────────────────────────────────────────────────
6447
- async serialize(resources, _projectRoot, options = {}) {
6562
+ async serialize(resources, projectRoot, options = {}) {
6448
6563
  const files = [];
6449
6564
  const target = options.target ?? "project";
6565
+ const serializeOptions = { ...options, projectRoot };
6450
6566
  const targetPaths = this.getTargetPaths(target);
6451
6567
  const instructionsPath = this.toTargetRelativePath(targetPaths.instructions, target) ?? (target === "project" ? "CLAUDE.md" : void 0);
6452
6568
  const rulesPath = this.toTargetRelativePath(targetPaths.rules, target);
@@ -6482,7 +6598,7 @@ var init_claude_code = __esm({
6482
6598
  ...this.emitSkillWithAuxiliary(
6483
6599
  r,
6484
6600
  `${skillsPath}${r.name}/SKILL.md`,
6485
- options
6601
+ serializeOptions
6486
6602
  )
6487
6603
  );
6488
6604
  }
@@ -6548,9 +6664,11 @@ var init_claude_code = __esm({
6548
6664
  ).hooks;
6549
6665
  }
6550
6666
  if (Object.keys(settings).length > 0) {
6667
+ const generated = JSON.stringify(settings, null, 2);
6668
+ const existing = this.readFile(join16(projectRoot, settingsPath2));
6551
6669
  files.push({
6552
6670
  path: settingsPath2,
6553
- content: JSON.stringify(settings, null, 2)
6671
+ content: mergeClaudeSettingsContent(existing, generated)
6554
6672
  });
6555
6673
  }
6556
6674
  }
@@ -11838,10 +11956,16 @@ function applyClaudePluginExtensions(files, config, projectRoot) {
11838
11956
  if (existingSettings) {
11839
11957
  try {
11840
11958
  const generated = JSON.parse(existingSettings.content);
11841
- const merged = { ...generated, ...settings };
11959
+ const overlay = { ...generated };
11960
+ if (settings.extraKnownMarketplaces) {
11961
+ overlay.extraKnownMarketplaces = settings.extraKnownMarketplaces;
11962
+ }
11963
+ if (settings.enabledPlugins) {
11964
+ overlay.enabledPlugins = settings.enabledPlugins;
11965
+ }
11842
11966
  return [
11843
11967
  ...withoutSettings,
11844
- { path: SETTINGS_PATH, content: JSON.stringify(merged, null, 2) }
11968
+ { path: SETTINGS_PATH, content: JSON.stringify(overlay, null, 2) }
11845
11969
  ];
11846
11970
  } catch {
11847
11971
  return [...withoutSettings, { path: SETTINGS_PATH, content: settingsContent }];
@@ -12080,7 +12204,7 @@ init_plugin_model();
12080
12204
  // package.json
12081
12205
  var package_default = {
12082
12206
  name: "harnesstap",
12083
- version: "1.0.2",
12207
+ version: "1.1.0",
12084
12208
  description: "Agent harness configuration toolkit for Claude Code, Codex, Cursor, and other coding CLIs",
12085
12209
  type: "module",
12086
12210
  packageManager: "bun@1.3.9",
@@ -14133,7 +14257,8 @@ async function generateFiles(resources, platforms, projectRoot, claudeConfigOrOp
14133
14257
  let files = await serializer.serialize(serializedResources, projectRoot, {
14134
14258
  target,
14135
14259
  skillCursorMode: options.skillCursorMode,
14136
- skillSourceRoot
14260
+ skillSourceRoot,
14261
+ projectRoot
14137
14262
  });
14138
14263
  if (pid === "claude-code" && claudeConfig) {
14139
14264
  files = applyClaudePluginExtensions(files, claudeConfig, projectRoot);
@@ -14477,6 +14602,7 @@ init_connection();
14477
14602
  import { existsSync as existsSync21, readdirSync as readdirSync11, statSync as statSync7 } from "fs";
14478
14603
  import { join as join31 } from "path";
14479
14604
  init_registry();
14605
+ init_merged_host_config();
14480
14606
  function collectOtherProfilesSnapshotTrackedFiles(incomingProfileName) {
14481
14607
  const tracked = /* @__PURE__ */ new Set();
14482
14608
  const seenProfiles = /* @__PURE__ */ new Set();
@@ -14562,7 +14688,9 @@ function expandStaleMcpConfigMirrors(staleFiles, desiredFiles, harnesses) {
14562
14688
  }
14563
14689
  function planStaleGlobalProfileFiles(_homeRoot, desiredFiles, previousTrackedFiles, harnesses) {
14564
14690
  const desired = new Set(desiredFiles);
14565
- const stale = previousTrackedFiles.filter((filePath) => !desired.has(filePath));
14691
+ const stale = previousTrackedFiles.filter(
14692
+ (filePath) => !desired.has(filePath) && !isMergeableHostConfigPath(filePath)
14693
+ );
14566
14694
  return expandStaleMcpConfigMirrors(
14567
14695
  expandStaleSkillHubMirrors(stale, desired),
14568
14696
  desired,
@@ -15044,6 +15172,9 @@ function listMcpPluginFolderNames(homeRoot) {
15044
15172
  return [];
15045
15173
  }
15046
15174
  }
15175
+ function listCursorNativeMcpPluginNames(homeRoot) {
15176
+ return pluginNamesFromMcpFolders(listMcpPluginFolderNames(homeRoot));
15177
+ }
15047
15178
  function resolveCursorStateDbPath() {
15048
15179
  if (process.platform === "darwin") {
15049
15180
  return join35(
@@ -17342,7 +17473,7 @@ init_plugin_model();
17342
17473
  init_resource();
17343
17474
  import { mkdirSync as mkdirSync10, readFileSync as readFileSync24, writeFileSync as writeFileSync10 } from "fs";
17344
17475
  import { dirname as dirname7, join as join42 } from "path";
17345
- import matter5 from "gray-matter";
17476
+ import matter6 from "gray-matter";
17346
17477
  init_plugin_dependency();
17347
17478
  init_skill_auxiliary();
17348
17479
  init_write();
@@ -17484,7 +17615,7 @@ function emitFrontmatter(data, content) {
17484
17615
  ([, value]) => value !== void 0 && value !== null && value !== ""
17485
17616
  );
17486
17617
  if (nonEmpty.length === 0) return content;
17487
- return matter5.stringify(content, Object.fromEntries(nonEmpty));
17618
+ return matter6.stringify(content, Object.fromEntries(nonEmpty));
17488
17619
  }
17489
17620
  function put(files, relativePath2, entry) {
17490
17621
  if (relativePath2.split("/").includes("..")) {
@@ -18175,7 +18306,7 @@ async function validatePublicPluginExists(selector, baseUrl) {
18175
18306
  }
18176
18307
 
18177
18308
  // src/services/agent-plugins/import.ts
18178
- import matter6 from "gray-matter";
18309
+ import matter7 from "gray-matter";
18179
18310
  init_plugin_model();
18180
18311
  init_resource();
18181
18312
  init_types();
@@ -18291,7 +18422,7 @@ function parseNativeMarkdownResources(type, dirName, files) {
18291
18422
  if (!relativePath2.startsWith(prefix) || !relativePath2.endsWith(".md")) continue;
18292
18423
  const entry = files[relativePath2];
18293
18424
  if (!entry) continue;
18294
- const parsed = matter6(fileText(entry));
18425
+ const parsed = matter7(fileText(entry));
18295
18426
  const data = isRecord10(parsed.data) ? { ...parsed.data } : {};
18296
18427
  const fallback = nativeBasename(relativePath2, prefix);
18297
18428
  const name = typeof data.name === "string" && data.name.length > 0 ? data.name : fallback;
@@ -18343,7 +18474,7 @@ function parseSkillResources(files) {
18343
18474
  const skillName = match[1];
18344
18475
  const entry = files[relativePath2];
18345
18476
  if (!entry) continue;
18346
- const parsed = matter6(fileText(entry));
18477
+ const parsed = matter7(fileText(entry));
18347
18478
  const data = isRecord10(parsed.data) ? parsed.data : {};
18348
18479
  const name = typeof data.name === "string" && data.name.length > 0 ? data.name : skillName;
18349
18480
  const description = typeof data.description === "string" ? data.description : "";
@@ -18400,7 +18531,7 @@ function parseMarkdownComponent(type, layoutPath, files) {
18400
18531
  if (!entry) continue;
18401
18532
  const basename13 = relativePath2.slice(prefix.length, -".md".length);
18402
18533
  if (!basename13 || basename13.includes("/")) continue;
18403
- const parsed = matter6(fileText(entry));
18534
+ const parsed = matter7(fileText(entry));
18404
18535
  const data = isRecord10(parsed.data) ? { ...parsed.data } : {};
18405
18536
  const name = typeof data.name === "string" && data.name.length > 0 ? data.name : basename13;
18406
18537
  const description = typeof data.description === "string" ? data.description : "";
@@ -19532,7 +19663,7 @@ import { parse as parseYaml2 } from "yaml";
19532
19663
  // src/services/apm-overlay.ts
19533
19664
  import { existsSync as existsSync30, lstatSync as lstatSync4, readFileSync as readFileSync27, readdirSync as readdirSync16 } from "fs";
19534
19665
  import { join as join45 } from "path";
19535
- import matter7 from "gray-matter";
19666
+ import matter8 from "gray-matter";
19536
19667
  init_hook_serialization();
19537
19668
  init_skill_auxiliary();
19538
19669
  var APM_NATIVE_PRIMITIVE_DIRS = ["agents", "skills", "commands", "hooks"];
@@ -19592,7 +19723,7 @@ function sourceDir(prefix, dir) {
19592
19723
  }
19593
19724
  function parseMarkdown(projectRoot, relativePath2) {
19594
19725
  const raw = readFileSync27(join45(projectRoot, relativePath2), "utf-8");
19595
- const parsed = matter7(raw);
19726
+ const parsed = matter8(raw);
19596
19727
  return {
19597
19728
  data: isRecord11(parsed.data) ? { ...parsed.data } : {},
19598
19729
  content: parsed.content
@@ -26789,6 +26920,301 @@ init_connection();
26789
26920
  init_plugin_origin();
26790
26921
  init_resource_selector();
26791
26922
 
26923
+ // src/services/self-update.ts
26924
+ init_connection();
26925
+ import { spawn } from "child_process";
26926
+ import { chmodSync, createWriteStream, existsSync as existsSync36, mkdirSync as mkdirSync14, readFileSync as readFileSync31, writeFileSync as writeFileSync14 } from "fs";
26927
+ import { join as join50 } from "path";
26928
+ import { Readable } from "stream";
26929
+ import { pipeline } from "stream/promises";
26930
+ import semver9 from "semver";
26931
+ var GITHUB_REPO = "harnesstap/harnesstap";
26932
+ var GITHUB_LATEST_RELEASE_API = `https://api.github.com/repos/${GITHUB_REPO}/releases/latest`;
26933
+ var NPM_LATEST_API = "https://registry.npmjs.org/harnesstap/latest";
26934
+ var NPM_PACKAGE_NAME = "harnesstap";
26935
+ var UPDATE_CHECK_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
26936
+ var UPDATE_LOOKUP_TIMEOUT_MS = 2500;
26937
+ var EMPTY_CACHE = {
26938
+ lastLookupAt: null,
26939
+ latestVersion: null,
26940
+ latestNotes: null,
26941
+ latestHtmlUrl: null,
26942
+ assets: [],
26943
+ notifiedVersion: null
26944
+ };
26945
+ var UPDATE_CHECK_FILENAME = "update-check.json";
26946
+ function updateCheckPath(harnesstapDir) {
26947
+ return join50(harnesstapDir, UPDATE_CHECK_FILENAME);
26948
+ }
26949
+ function normalizePublishedVersion(version) {
26950
+ const trimmed = version.trim();
26951
+ return trimmed.startsWith("v") || trimmed.startsWith("V") ? trimmed.slice(1) : trimmed;
26952
+ }
26953
+ function isNewerPublishedVersion(latest, current) {
26954
+ const latestVersion = normalizePublishedVersion(latest);
26955
+ const currentVersion = normalizePublishedVersion(current);
26956
+ if (!semver9.valid(latestVersion) || !semver9.valid(currentVersion)) {
26957
+ return false;
26958
+ }
26959
+ return semver9.gt(latestVersion, currentVersion);
26960
+ }
26961
+ function detectCliInstallChannel(scriptPath = process.argv[1] ?? "", env = process.env) {
26962
+ if (env.HARNESSTAP_UPDATE_CHANNEL === "npm" || env.HARNESSTAP_UPDATE_CHANNEL === "github") {
26963
+ return env.HARNESSTAP_UPDATE_CHANNEL;
26964
+ }
26965
+ if (env.npm_package_name === NPM_PACKAGE_NAME) {
26966
+ return "npm";
26967
+ }
26968
+ const normalized = scriptPath.replaceAll("\\", "/");
26969
+ if (normalized.includes("/node_modules/harnesstap/") || normalized.includes("/node_modules/.bin/") || normalized.includes("/_npx/") || normalized.includes("/.npm/_npx/")) {
26970
+ return "npm";
26971
+ }
26972
+ return "github";
26973
+ }
26974
+ function cliInstallHint(channel, version) {
26975
+ const normalized = normalizePublishedVersion(version);
26976
+ switch (channel) {
26977
+ case "npm":
26978
+ return `npm install -g ${NPM_PACKAGE_NAME}@${normalized}`;
26979
+ case "github":
26980
+ return `https://github.com/${GITHUB_REPO}/releases/tag/v${normalized}`;
26981
+ default: {
26982
+ const exhaustive = channel;
26983
+ return exhaustive;
26984
+ }
26985
+ }
26986
+ }
26987
+ function githubReleaseHtmlUrl(version) {
26988
+ return `https://github.com/${GITHUB_REPO}/releases/tag/v${normalizePublishedVersion(version)}`;
26989
+ }
26990
+ function loadUpdateCheckCache(harnesstapDir) {
26991
+ const path = updateCheckPath(harnesstapDir);
26992
+ if (!existsSync36(path)) {
26993
+ return { ...EMPTY_CACHE };
26994
+ }
26995
+ try {
26996
+ const raw = JSON.parse(readFileSync31(path, "utf-8"));
26997
+ const assets = Array.isArray(raw.assets) ? raw.assets.filter((asset) => typeof asset?.name === "string" && typeof asset?.browser_download_url === "string") : [];
26998
+ return {
26999
+ lastLookupAt: typeof raw.lastLookupAt === "string" ? raw.lastLookupAt : null,
27000
+ latestVersion: typeof raw.latestVersion === "string" ? raw.latestVersion : null,
27001
+ latestNotes: typeof raw.latestNotes === "string" ? raw.latestNotes : null,
27002
+ latestHtmlUrl: typeof raw.latestHtmlUrl === "string" ? raw.latestHtmlUrl : null,
27003
+ assets,
27004
+ notifiedVersion: typeof raw.notifiedVersion === "string" ? raw.notifiedVersion : null
27005
+ };
27006
+ } catch {
27007
+ return { ...EMPTY_CACHE };
27008
+ }
27009
+ }
27010
+ function saveUpdateCheckCache(harnesstapDir, cache) {
27011
+ mkdirSync14(harnesstapDir, { recursive: true });
27012
+ writeFileSync14(updateCheckPath(harnesstapDir), `${JSON.stringify(cache, null, 2)}
27013
+ `, "utf-8");
27014
+ }
27015
+ function isUpdateLookupFresh(cache, now = /* @__PURE__ */ new Date(), maxAgeMs = UPDATE_CHECK_MAX_AGE_MS) {
27016
+ if (!cache.lastLookupAt) {
27017
+ return false;
27018
+ }
27019
+ const lookedUp = Date.parse(cache.lastLookupAt);
27020
+ if (Number.isNaN(lookedUp)) {
27021
+ return false;
27022
+ }
27023
+ return now.getTime() - lookedUp <= maxAgeMs;
27024
+ }
27025
+ function publishedReleaseUserAgent() {
27026
+ return `HarnessTap/${PACKAGE_VERSION} (+https://github.com/${GITHUB_REPO})`;
27027
+ }
27028
+ function githubHeaders() {
27029
+ return {
27030
+ Accept: "application/vnd.github+json",
27031
+ "User-Agent": publishedReleaseUserAgent(),
27032
+ "X-GitHub-Api-Version": "2022-11-28"
27033
+ };
27034
+ }
27035
+ async function fetchNpmLatestVersion(fetchFn = fetchWithTimeout) {
27036
+ const response = await fetchFn(NPM_LATEST_API, {
27037
+ headers: { Accept: "application/json", "User-Agent": publishedReleaseUserAgent() },
27038
+ timeoutMs: UPDATE_LOOKUP_TIMEOUT_MS,
27039
+ retries: 0
27040
+ });
27041
+ if (!response.ok) {
27042
+ throw new Error(`npm latest lookup failed (${response.status})`);
27043
+ }
27044
+ const body = await response.json();
27045
+ if (typeof body.version !== "string" || body.version.trim().length === 0) {
27046
+ throw new Error("npm latest lookup returned no version");
27047
+ }
27048
+ return normalizePublishedVersion(body.version);
27049
+ }
27050
+ async function fetchGithubLatestRelease(fetchFn = fetchWithTimeout) {
27051
+ const response = await fetchFn(GITHUB_LATEST_RELEASE_API, {
27052
+ headers: githubHeaders(),
27053
+ timeoutMs: UPDATE_LOOKUP_TIMEOUT_MS,
27054
+ retries: 0
27055
+ });
27056
+ if (!response.ok) {
27057
+ throw new Error(`GitHub latest release lookup failed (${response.status})`);
27058
+ }
27059
+ const body = await response.json();
27060
+ if (typeof body.tag_name !== "string" || body.tag_name.trim().length === 0) {
27061
+ throw new Error("GitHub latest release lookup returned no tag");
27062
+ }
27063
+ const version = normalizePublishedVersion(body.tag_name);
27064
+ const assets = Array.isArray(body.assets) ? body.assets.flatMap((asset) => {
27065
+ if (!asset || typeof asset !== "object") {
27066
+ return [];
27067
+ }
27068
+ const record = asset;
27069
+ if (typeof record.name !== "string" || typeof record.browser_download_url !== "string") {
27070
+ return [];
27071
+ }
27072
+ return [{ name: record.name, browser_download_url: record.browser_download_url }];
27073
+ }) : [];
27074
+ return {
27075
+ version,
27076
+ notes: typeof body.body === "string" ? body.body : "",
27077
+ htmlUrl: typeof body.html_url === "string" && body.html_url.length > 0 ? body.html_url : githubReleaseHtmlUrl(version),
27078
+ assets
27079
+ };
27080
+ }
27081
+ async function lookupPublishedRelease(channel, fetchFn = fetchWithTimeout) {
27082
+ switch (channel) {
27083
+ case "github":
27084
+ return fetchGithubLatestRelease(fetchFn);
27085
+ case "npm": {
27086
+ const version = await fetchNpmLatestVersion(fetchFn);
27087
+ try {
27088
+ const github = await fetchGithubLatestRelease(fetchFn);
27089
+ if (github.version === version) {
27090
+ return github;
27091
+ }
27092
+ } catch {
27093
+ }
27094
+ return {
27095
+ version,
27096
+ notes: "",
27097
+ htmlUrl: githubReleaseHtmlUrl(version),
27098
+ assets: []
27099
+ };
27100
+ }
27101
+ default: {
27102
+ const exhaustive = channel;
27103
+ return exhaustive;
27104
+ }
27105
+ }
27106
+ }
27107
+ function releaseFromCache(cache) {
27108
+ if (!cache.latestVersion) {
27109
+ return null;
27110
+ }
27111
+ return {
27112
+ version: cache.latestVersion,
27113
+ notes: cache.latestNotes ?? "",
27114
+ htmlUrl: cache.latestHtmlUrl ?? githubReleaseHtmlUrl(cache.latestVersion),
27115
+ assets: cache.assets
27116
+ };
27117
+ }
27118
+ async function resolvePublishedRelease(options) {
27119
+ const harnesstapDir = options.harnesstapDir ?? getHarnesstapDir();
27120
+ const now = options.now ?? /* @__PURE__ */ new Date();
27121
+ const cache = loadUpdateCheckCache(harnesstapDir);
27122
+ if (!options.forceRefresh && isUpdateLookupFresh(cache, now)) {
27123
+ return releaseFromCache(cache);
27124
+ }
27125
+ try {
27126
+ const release = await lookupPublishedRelease(
27127
+ options.channel,
27128
+ options.fetchFn ?? fetchWithTimeout
27129
+ );
27130
+ saveUpdateCheckCache(harnesstapDir, {
27131
+ ...cache,
27132
+ lastLookupAt: now.toISOString(),
27133
+ latestVersion: release.version,
27134
+ latestNotes: release.notes,
27135
+ latestHtmlUrl: release.htmlUrl,
27136
+ assets: release.assets
27137
+ });
27138
+ return release;
27139
+ } catch {
27140
+ return releaseFromCache(cache);
27141
+ }
27142
+ }
27143
+ function formatCliUpdateNotice(notice) {
27144
+ return `A newer HarnessTap CLI is available: ${notice.currentVersion} \u2192 ${notice.latestVersion}. Install: ${notice.installHint}`;
27145
+ }
27146
+ function shouldSkipCliUpdateNotice(argv = process.argv, env = process.env) {
27147
+ if (env.HARNESSTAP_SKIP_UPDATE_CHECK === "1" || env.HARNESSTAP_SKIP_UPDATE_CHECK === "true") {
27148
+ return true;
27149
+ }
27150
+ if (env.HARNESSTAP_UPDATE_CHECK !== "1" && (Boolean(env.BUN_TEST) || env.NODE_ENV === "test")) {
27151
+ return true;
27152
+ }
27153
+ const args = argv.slice(2);
27154
+ if (args[0] === "__complete" || args[0] === "completion") {
27155
+ return true;
27156
+ }
27157
+ if (args.includes("--json")) {
27158
+ return true;
27159
+ }
27160
+ for (let index = 0; index < args.length; index += 1) {
27161
+ const token = args[index];
27162
+ if (token === "--format" && args[index + 1] === "json") {
27163
+ return true;
27164
+ }
27165
+ if (token === "--format=json") {
27166
+ return true;
27167
+ }
27168
+ }
27169
+ return false;
27170
+ }
27171
+ async function maybeNotifyCliUpdate(options = {}) {
27172
+ const argv = options.argv ?? process.argv;
27173
+ const env = options.env ?? process.env;
27174
+ if (shouldSkipCliUpdateNotice(argv, env)) {
27175
+ return null;
27176
+ }
27177
+ if (typeof process.exitCode === "number" && process.exitCode !== 0) {
27178
+ return null;
27179
+ }
27180
+ try {
27181
+ const harnesstapDir = options.harnesstapDir ?? getHarnesstapDir();
27182
+ const currentVersion = options.currentVersion ?? PACKAGE_VERSION;
27183
+ const channel = detectCliInstallChannel(argv[1], env);
27184
+ const release = await resolvePublishedRelease({
27185
+ channel,
27186
+ harnesstapDir,
27187
+ now: options.now,
27188
+ fetchFn: options.fetchFn
27189
+ });
27190
+ if (!release || !isNewerPublishedVersion(release.version, currentVersion)) {
27191
+ return null;
27192
+ }
27193
+ const cache = loadUpdateCheckCache(harnesstapDir);
27194
+ if (cache.notifiedVersion === release.version) {
27195
+ return null;
27196
+ }
27197
+ const notice = {
27198
+ currentVersion: normalizePublishedVersion(currentVersion),
27199
+ latestVersion: release.version,
27200
+ channel,
27201
+ installHint: cliInstallHint(channel, release.version),
27202
+ htmlUrl: release.htmlUrl
27203
+ };
27204
+ const writeNotice = options.writeNotice ?? ((message) => {
27205
+ console.error(message);
27206
+ });
27207
+ writeNotice(formatCliUpdateNotice(notice));
27208
+ saveUpdateCheckCache(harnesstapDir, {
27209
+ ...loadUpdateCheckCache(harnesstapDir),
27210
+ notifiedVersion: release.version
27211
+ });
27212
+ return notice;
27213
+ } catch {
27214
+ return null;
27215
+ }
27216
+ }
27217
+
26792
27218
  // src/cli/program.ts
26793
27219
  init_connection();
26794
27220
  import { Command } from "commander";
@@ -26913,6 +27339,7 @@ async function runHarnesstapCli(argv = process.argv) {
26913
27339
  for (const notice of takeSelectorDeprecations()) {
26914
27340
  ui.warn(notice);
26915
27341
  }
27342
+ await maybeNotifyCliUpdate({ argv: effectiveArgv });
26916
27343
  } catch (error) {
26917
27344
  if (isPromptCancellationError(error)) {
26918
27345
  return;
@@ -27888,15 +28315,15 @@ init_connection();
27888
28315
  // src/services/marketplace-catalog.ts
27889
28316
  init_settings();
27890
28317
  import {
27891
- existsSync as existsSync36,
27892
- mkdirSync as mkdirSync14,
27893
- readFileSync as readFileSync31,
28318
+ existsSync as existsSync37,
28319
+ mkdirSync as mkdirSync15,
28320
+ readFileSync as readFileSync32,
27894
28321
  renameSync,
27895
28322
  rmSync as rmSync5,
27896
28323
  statSync as statSync10,
27897
- writeFileSync as writeFileSync14
28324
+ writeFileSync as writeFileSync15
27898
28325
  } from "fs";
27899
- import { dirname as dirname10, join as join50 } from "path";
28326
+ import { dirname as dirname10, join as join51 } from "path";
27900
28327
 
27901
28328
  // src/services/marketplace-catalog-parse.ts
27902
28329
  import { basename as basename6 } from "path";
@@ -27983,23 +28410,23 @@ var MANIFEST_PATHS = [
27983
28410
  { path: "marketplace.json", platform: null }
27984
28411
  ];
27985
28412
  function marketplaceCacheDir(harnesstapDir, name) {
27986
- return join50(harnesstapDir, "cache", "marketplaces", name);
28413
+ return join51(harnesstapDir, "cache", "marketplaces", name);
27987
28414
  }
27988
28415
  function marketplaceCatalogPath(harnesstapDir, name) {
27989
- return join50(marketplaceCacheDir(harnesstapDir, name), "catalog.json");
28416
+ return join51(marketplaceCacheDir(harnesstapDir, name), "catalog.json");
27990
28417
  }
27991
28418
  function isGooseOnly(platforms) {
27992
28419
  return platforms.length === 1 && platforms[0] === "goose";
27993
28420
  }
27994
28421
  function catalogIsFresh(catalogPath, maxAgeHours) {
27995
- if (!existsSync36(catalogPath)) return false;
28422
+ if (!existsSync37(catalogPath)) return false;
27996
28423
  const ageMs = Date.now() - statSync10(catalogPath).mtimeMs;
27997
28424
  return ageMs < maxAgeHours * 60 * 60 * 1e3;
27998
28425
  }
27999
28426
  function readStoredCatalog(catalogPath) {
28000
- if (!existsSync36(catalogPath)) return void 0;
28427
+ if (!existsSync37(catalogPath)) return void 0;
28001
28428
  try {
28002
- const raw = JSON.parse(readFileSync31(catalogPath, "utf8"));
28429
+ const raw = JSON.parse(readFileSync32(catalogPath, "utf8"));
28003
28430
  if (!Array.isArray(raw.plugins)) return void 0;
28004
28431
  return raw;
28005
28432
  } catch {
@@ -28007,14 +28434,14 @@ function readStoredCatalog(catalogPath) {
28007
28434
  }
28008
28435
  }
28009
28436
  function writeStoredCatalog(catalogPath, catalog) {
28010
- mkdirSync14(dirname10(catalogPath), { recursive: true });
28011
- writeFileSync14(catalogPath, `${JSON.stringify(catalog, null, 2)}
28437
+ mkdirSync15(dirname10(catalogPath), { recursive: true });
28438
+ writeFileSync15(catalogPath, `${JSON.stringify(catalog, null, 2)}
28012
28439
  `, "utf8");
28013
28440
  }
28014
28441
  function resolveManifest(cacheDir, platforms) {
28015
28442
  for (const candidate of MANIFEST_PATHS) {
28016
- const manifestPath = join50(cacheDir, candidate.path);
28017
- if (!existsSync36(manifestPath)) continue;
28443
+ const manifestPath = join51(cacheDir, candidate.path);
28444
+ if (!existsSync37(manifestPath)) continue;
28018
28445
  if (candidate.platform) {
28019
28446
  return { manifestPath, platform: candidate.platform };
28020
28447
  }
@@ -28093,7 +28520,7 @@ function refreshMarketplaceCatalog(harnesstapDir, options) {
28093
28520
  }
28094
28521
  let raw;
28095
28522
  try {
28096
- raw = JSON.parse(readFileSync31(manifest.manifestPath, "utf8"));
28523
+ raw = JSON.parse(readFileSync32(manifest.manifestPath, "utf8"));
28097
28524
  } catch {
28098
28525
  return { ok: false, message: "Failed to parse marketplace manifest JSON" };
28099
28526
  }
@@ -28353,8 +28780,8 @@ init_connection();
28353
28780
  // src/services/open-path.ts
28354
28781
  init_connection();
28355
28782
  import { spawnSync as spawnSync3 } from "child_process";
28356
- import { existsSync as existsSync38, realpathSync as realpathSync3, statSync as statSync11 } from "fs";
28357
- import { isAbsolute as isAbsolute5, join as join52, relative as relative8, resolve as resolve12, sep as sep6 } from "path";
28783
+ import { existsSync as existsSync39, realpathSync as realpathSync3, statSync as statSync11 } from "fs";
28784
+ import { isAbsolute as isAbsolute5, join as join53, relative as relative8, resolve as resolve12, sep as sep6 } from "path";
28358
28785
 
28359
28786
  // src/services/resource-tracked-directories.ts
28360
28787
  init_connection();
@@ -28363,13 +28790,13 @@ init_registry();
28363
28790
  init_home_root();
28364
28791
  init_scanner();
28365
28792
  import {
28366
- existsSync as existsSync37,
28793
+ existsSync as existsSync38,
28367
28794
  lstatSync as lstatSync7,
28368
- mkdirSync as mkdirSync15,
28369
- readFileSync as readFileSync32,
28370
- writeFileSync as writeFileSync15
28795
+ mkdirSync as mkdirSync16,
28796
+ readFileSync as readFileSync33,
28797
+ writeFileSync as writeFileSync16
28371
28798
  } from "fs";
28372
- import { basename as basename7, dirname as dirname11, join as join51, relative as relative7, resolve as resolve11 } from "path";
28799
+ import { basename as basename7, dirname as dirname11, join as join52, relative as relative7, resolve as resolve11 } from "path";
28373
28800
  var TRACKED_DIRECTORIES_FILE = "resource-tracked-directories.json";
28374
28801
  var ResourceTrackedDirectoryError = class extends Error {
28375
28802
  constructor(message) {
@@ -28382,12 +28809,12 @@ function trackedDirectoriesPath() {
28382
28809
  }
28383
28810
  function readCustomDirectories() {
28384
28811
  const filePath = trackedDirectoriesPath();
28385
- if (!existsSync37(filePath)) {
28812
+ if (!existsSync38(filePath)) {
28386
28813
  return [];
28387
28814
  }
28388
28815
  try {
28389
28816
  const parsed = JSON.parse(
28390
- readFileSync32(filePath, "utf-8")
28817
+ readFileSync33(filePath, "utf-8")
28391
28818
  );
28392
28819
  if (!Array.isArray(parsed.directories)) {
28393
28820
  return [];
@@ -28401,9 +28828,9 @@ function readCustomDirectories() {
28401
28828
  }
28402
28829
  function writeCustomDirectories(directories) {
28403
28830
  const home = getHarnesstapDir();
28404
- mkdirSync15(home, { recursive: true });
28831
+ mkdirSync16(home, { recursive: true });
28405
28832
  const normalized = [...new Set(directories.map((entry) => resolve11(entry)))].sort();
28406
- writeFileSync15(
28833
+ writeFileSync16(
28407
28834
  trackedDirectoriesPath(),
28408
28835
  `${JSON.stringify({ directories: normalized }, null, 2)}
28409
28836
  `,
@@ -28422,7 +28849,7 @@ function countResourcesByOriginRef() {
28422
28849
  return counts;
28423
28850
  }
28424
28851
  function resolveConfiguredPath2(rootPath, configuredPath) {
28425
- return configuredPath.startsWith("~/") ? join51(rootPath, configuredPath.slice(2)) : join51(rootPath, configuredPath);
28852
+ return configuredPath.startsWith("~/") ? join52(rootPath, configuredPath.slice(2)) : join52(rootPath, configuredPath);
28426
28853
  }
28427
28854
  function configuredPathValues(paths) {
28428
28855
  const result = [];
@@ -28448,13 +28875,13 @@ function topLevelFolderUnderRoot(rootPath, absolutePath) {
28448
28875
  if (!first) {
28449
28876
  return null;
28450
28877
  }
28451
- return join51(rootPath, first);
28878
+ return join52(rootPath, first);
28452
28879
  }
28453
28880
  function foldersFromConfiguredPaths(rootPath, configured) {
28454
28881
  const folders = /* @__PURE__ */ new Map();
28455
28882
  for (const entry of configured) {
28456
28883
  const absolute = resolveConfiguredPath2(rootPath, entry.path);
28457
- if (!existsSync37(absolute)) {
28884
+ if (!existsSync38(absolute)) {
28458
28885
  continue;
28459
28886
  }
28460
28887
  let target = absolute;
@@ -28547,7 +28974,7 @@ function homeRootPath() {
28547
28974
  }
28548
28975
  async function addResourceTrackedDirectory(inputPath) {
28549
28976
  const resolved = resolve11(inputPath.trim());
28550
- if (!existsSync37(resolved)) {
28977
+ if (!existsSync38(resolved)) {
28551
28978
  throw new ResourceTrackedDirectoryError(`Directory not found: ${resolved}`);
28552
28979
  }
28553
28980
  const homeRoot = resolve11(homeRootPath());
@@ -28603,7 +29030,7 @@ async function rescanResourceTrackedDirectories() {
28603
29030
  if (resolved === homeRoot) {
28604
29031
  continue;
28605
29032
  }
28606
- if (!existsSync37(resolved)) {
29033
+ if (!existsSync38(resolved)) {
28607
29034
  rescanned.push({
28608
29035
  path: resolved,
28609
29036
  kind: "custom",
@@ -28675,7 +29102,7 @@ function openPathInSystemEditor(filePath) {
28675
29102
  function expandUserPath(candidate) {
28676
29103
  const trimmed = candidate.trim();
28677
29104
  if (trimmed.startsWith("~/")) {
28678
- return join52(resolveHomeRoot(), trimmed.slice(2));
29105
+ return join53(resolveHomeRoot(), trimmed.slice(2));
28679
29106
  }
28680
29107
  if (trimmed === "~") {
28681
29108
  return resolveHomeRoot();
@@ -28683,7 +29110,7 @@ function expandUserPath(candidate) {
28683
29110
  return resolve12(trimmed);
28684
29111
  }
28685
29112
  function realExistingPath(path) {
28686
- if (!existsSync38(path)) {
29113
+ if (!existsSync39(path)) {
28687
29114
  return null;
28688
29115
  }
28689
29116
  try {
@@ -28787,8 +29214,8 @@ init_resource_selector();
28787
29214
  // src/services/profile-commit-resource.ts
28788
29215
  init_resource();
28789
29216
  init_plugin_model();
28790
- import { existsSync as existsSync41, readFileSync as readFileSync35 } from "fs";
28791
- import { join as join54, resolve as resolve16 } from "path";
29217
+ import { existsSync as existsSync42, readFileSync as readFileSync36 } from "fs";
29218
+ import { join as join55, resolve as resolve16 } from "path";
28792
29219
 
28793
29220
  // src/services/plugin-apply-merge.ts
28794
29221
  init_plugin_model();
@@ -29050,8 +29477,8 @@ init_plugin_composition();
29050
29477
  init_plugin_model();
29051
29478
 
29052
29479
  // src/services/project-drift.ts
29053
- import { existsSync as existsSync39, readFileSync as readFileSync33 } from "fs";
29054
- import { join as join53 } from "path";
29480
+ import { existsSync as existsSync40, readFileSync as readFileSync34 } from "fs";
29481
+ import { join as join54 } from "path";
29055
29482
 
29056
29483
  // src/models/snapshot.ts
29057
29484
  init_connection();
@@ -29089,10 +29516,10 @@ function getLatestSnapshot(projectId) {
29089
29516
 
29090
29517
  // src/services/project-drift.ts
29091
29518
  function readProjectFile(projectRoot, relativePath2) {
29092
- const fullPath = join53(projectRoot, relativePath2);
29093
- if (!existsSync39(fullPath)) return null;
29519
+ const fullPath = join54(projectRoot, relativePath2);
29520
+ if (!existsSync40(fullPath)) return null;
29094
29521
  try {
29095
- return readFileSync33(fullPath, "utf-8");
29522
+ return readFileSync34(fullPath, "utf-8");
29096
29523
  } catch {
29097
29524
  return null;
29098
29525
  }
@@ -29343,7 +29770,15 @@ function toContentsResource(resource) {
29343
29770
  id: resource.id,
29344
29771
  type: resource.type,
29345
29772
  name: resource.name,
29346
- source: resource.source
29773
+ source: resource.source,
29774
+ ...resource.origin_kind ? { origin_kind: resource.origin_kind } : {},
29775
+ ...resource.origin_ref ? { origin_ref: resource.origin_ref } : {}
29776
+ };
29777
+ }
29778
+ function toNotStagedContentsResource(resource, kind) {
29779
+ return {
29780
+ ...toContentsResource(resource),
29781
+ not_staged_kind: kind
29347
29782
  };
29348
29783
  }
29349
29784
  function toContentsResources(resources) {
@@ -29593,7 +30028,7 @@ init_mcp_target();
29593
30028
 
29594
30029
  // src/services/profile-untracked-resources.ts
29595
30030
  init_plugin_model();
29596
- import { existsSync as existsSync40, mkdirSync as mkdirSync16, readFileSync as readFileSync34, writeFileSync as writeFileSync16 } from "fs";
30031
+ import { existsSync as existsSync41, mkdirSync as mkdirSync17, readFileSync as readFileSync35, writeFileSync as writeFileSync17 } from "fs";
29597
30032
  import { dirname as dirname12, resolve as resolve15 } from "path";
29598
30033
  init_types();
29599
30034
  init_plugin_versioning();
@@ -29667,30 +30102,48 @@ function profileResourceKey2(resource) {
29667
30102
  return `${resource.type}:${resource.name}`;
29668
30103
  }
29669
30104
  function trackedResourceKeys(profileSelector) {
30105
+ return new Set(trackedResourceMap(profileSelector).keys());
30106
+ }
30107
+ function trackedResourceMap(profileSelector) {
29670
30108
  const profilePlugin = resolvePluginSelector(profileSelector);
29671
30109
  if (!profilePlugin) {
29672
- return /* @__PURE__ */ new Set();
30110
+ return /* @__PURE__ */ new Map();
29673
30111
  }
29674
30112
  const profileResources = mergePluginsForApply(
29675
30113
  collectProfilePluginIds(profilePlugin)
29676
30114
  ).resources;
29677
- return new Set(
29678
- profileResources.filter(isMaterialResource2).map((resource) => profileResourceKey2(resource))
29679
- );
29680
- }
29681
- function resourceKeysAttachedToAnyProfile() {
29682
- const keys = /* @__PURE__ */ new Set();
29683
- for (const profile of listProfilePlugins()) {
29684
- const profileResources = mergePluginsForApply(
29685
- collectProfilePluginIds(profile)
29686
- ).resources;
29687
- for (const resource of profileResources) {
29688
- if (isMaterialResource2(resource)) {
29689
- keys.add(profileResourceKey2(resource));
29690
- }
30115
+ const map = /* @__PURE__ */ new Map();
30116
+ for (const resource of profileResources) {
30117
+ if (!isMaterialResource2(resource)) {
30118
+ continue;
29691
30119
  }
30120
+ map.set(profileResourceKey2(resource), resource);
30121
+ }
30122
+ return map;
30123
+ }
30124
+ function stripLiveMetadata(metadata) {
30125
+ if (!metadata || typeof metadata !== "object") {
30126
+ return {};
30127
+ }
30128
+ const record = { ...metadata };
30129
+ delete record.content_status;
30130
+ return record;
30131
+ }
30132
+ function materialFingerprint(resource) {
30133
+ const description = (resource.description ?? "").trim();
30134
+ const content = (resource.content ?? "").replace(/\r\n/g, "\n").trim();
30135
+ return `${description}
30136
+ ${content}
30137
+ ${JSON.stringify(stripLiveMetadata(resource.metadata))}`;
30138
+ }
30139
+ function liveDiffersFromTracked(live, tracked) {
30140
+ if (!tracked) {
30141
+ return true;
30142
+ }
30143
+ if (isLiveLibraryRef(tracked)) {
30144
+ return false;
29692
30145
  }
29693
- return keys;
30146
+ return materialFingerprint(live) !== materialFingerprint(tracked);
29694
30147
  }
29695
30148
  function normalizeManagedPath(path, rootPath) {
29696
30149
  let normalized = path.replace(/\\/g, "/");
@@ -29710,16 +30163,27 @@ var MERGED_CONTAINER_RESOURCE_TYPES = /* @__PURE__ */ new Set([
29710
30163
  "env_var",
29711
30164
  "hook"
29712
30165
  ]);
29713
- function isClaudeSettingsPath(normalizedPath) {
30166
+ function isClaudeSettingsPath2(normalizedPath) {
29714
30167
  const path = normalizedPath.replace(/^~\//, "");
29715
30168
  return path === ".claude/settings.json" || path.endsWith("/.claude/settings.json");
29716
30169
  }
30170
+ function isMcpConfigPath(normalizedPath) {
30171
+ return /(^|\/)(\.?mcp\.json|mcp[-_]config\.json)$/i.test(
30172
+ normalizedPath.replace(/^~\//, "")
30173
+ );
30174
+ }
29717
30175
  function isMergedContainerResource(resource, rootPath) {
30176
+ const sourcePath = normalizeManagedPath(resource.source ?? "", rootPath);
30177
+ if (!sourcePath) {
30178
+ return false;
30179
+ }
30180
+ if (resource.type === "mcp_server") {
30181
+ return isMcpConfigPath(sourcePath);
30182
+ }
29718
30183
  if (!MERGED_CONTAINER_RESOURCE_TYPES.has(resource.type)) {
29719
30184
  return false;
29720
30185
  }
29721
- const sourcePath = normalizeManagedPath(resource.source ?? "", rootPath);
29722
- return Boolean(sourcePath) && isClaudeSettingsPath(sourcePath);
30186
+ return isClaudeSettingsPath2(sourcePath);
29723
30187
  }
29724
30188
  async function profileOwnedPaths(profileSelector, rootPath, platformIds, target) {
29725
30189
  const profilePlugin = resolvePluginSelector(profileSelector);
@@ -29758,7 +30222,7 @@ async function notStagedFromHomeScan(profileSelector, harness) {
29758
30222
  if (!profilePlugin || !isProfilePlugin(profilePlugin)) {
29759
30223
  return [];
29760
30224
  }
29761
- const committedKeys = resourceKeysAttachedToAnyProfile();
30225
+ const committed = trackedResourceMap(profileSelector);
29762
30226
  const homeRoot = resolveHomeRoot();
29763
30227
  const scanned = await scanHomeDefaults(
29764
30228
  harness ? resolveMainHarnessTarget(harness) : void 0,
@@ -29779,16 +30243,22 @@ async function notStagedFromHomeScan(profileSelector, harness) {
29779
30243
  continue;
29780
30244
  }
29781
30245
  const key = profileResourceKey2(resource);
29782
- if (committedKeys.has(key) || seen.has(key)) {
30246
+ const tracked = committed.get(key);
30247
+ if (tracked && !liveDiffersFromTracked(resource, tracked)) {
30248
+ continue;
30249
+ }
30250
+ if (seen.has(key)) {
29783
30251
  continue;
29784
30252
  }
29785
30253
  const sourcePath = normalizeManagedPath(resource.source ?? "", homeRoot);
29786
- if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, homeRoot)) {
30254
+ if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, homeRoot) && !tracked) {
29787
30255
  continue;
29788
30256
  }
29789
30257
  seen.add(key);
29790
30258
  const live = ensureLiveLibraryRef(resource, homeRoot);
29791
- notStaged.push(toContentsResource(live));
30259
+ notStaged.push(
30260
+ toNotStagedContentsResource(live, tracked ? "update" : "add")
30261
+ );
29792
30262
  }
29793
30263
  }
29794
30264
  return sortContentsResources(notStaged);
@@ -29798,7 +30268,7 @@ async function notStagedFromProjectScan(profileSelector, projectPath) {
29798
30268
  if (!profilePlugin || !isProfilePlugin(profilePlugin)) {
29799
30269
  return [];
29800
30270
  }
29801
- const committedKeys = resourceKeysAttachedToAnyProfile();
30271
+ const committed = trackedResourceMap(profileSelector);
29802
30272
  const resolvedRoot = resolve15(projectPath);
29803
30273
  const scanStatus = await assessProjectScanStatus(resolvedRoot);
29804
30274
  const scanned = await scanProject(resolvedRoot);
@@ -29816,11 +30286,15 @@ async function notStagedFromProjectScan(profileSelector, projectPath) {
29816
30286
  continue;
29817
30287
  }
29818
30288
  const key = profileResourceKey2(resource);
29819
- if (committedKeys.has(key) || seen.has(key)) {
30289
+ const tracked = committed.get(key);
30290
+ if (tracked && !liveDiffersFromTracked(resource, tracked)) {
30291
+ continue;
30292
+ }
30293
+ if (seen.has(key)) {
29820
30294
  continue;
29821
30295
  }
29822
30296
  const sourcePath = normalizeManagedPath(resource.source ?? "", resolvedRoot);
29823
- if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, resolvedRoot)) {
30297
+ if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, resolvedRoot) && !tracked) {
29824
30298
  continue;
29825
30299
  }
29826
30300
  seen.add(key);
@@ -29836,7 +30310,9 @@ async function notStagedFromProjectScan(profileSelector, projectPath) {
29836
30310
  },
29837
30311
  resolvedRoot
29838
30312
  );
29839
- notStaged.push(toContentsResource(live));
30313
+ notStaged.push(
30314
+ toNotStagedContentsResource(live, tracked ? "update" : "add")
30315
+ );
29840
30316
  }
29841
30317
  return sortContentsResources(notStaged);
29842
30318
  }
@@ -29875,9 +30351,7 @@ async function addResourceToProfile(input) {
29875
30351
  }
29876
30352
  const trackedKeys = trackedResourceKeys(input.profileSelector);
29877
30353
  const key = `${input.resourceType}:${input.resourceName}`;
29878
- if (trackedKeys.has(key)) {
29879
- throw new Error(`Resource is already in profile: ${key}`);
29880
- }
30354
+ const alreadyInProfile = trackedKeys.has(key);
29881
30355
  const { originRef: originRef2, scanResults } = await resolveUntrackedScanResults(input);
29882
30356
  const matchingResults = filterScanResultsForResource(
29883
30357
  scanResults,
@@ -29902,16 +30376,19 @@ async function addResourceToProfile(input) {
29902
30376
  );
29903
30377
  }
29904
30378
  markPluginDirty(profilePlugin.id);
29905
- addResourceToPlugin(profilePlugin.id, resource.id);
30379
+ if (!alreadyInProfile) {
30380
+ addResourceToPlugin(profilePlugin.id, resource.id);
30381
+ }
29906
30382
  touchPluginUpdatedAt(profilePlugin.id);
29907
- return toContentsResource(resource);
30383
+ return toNotStagedContentsResource(resource, alreadyInProfile ? "update" : "add");
29908
30384
  }
29909
30385
  async function resolveUntrackedScanResults(input) {
29910
30386
  const profilePlugin = resolvePluginSelector(input.profileSelector);
29911
30387
  if (!profilePlugin || !isProfilePlugin(profilePlugin)) {
29912
30388
  throw new Error(`Profile not found: ${input.profileSelector}`);
29913
30389
  }
29914
- const committedKeys = resourceKeysAttachedToAnyProfile();
30390
+ const committed = trackedResourceMap(input.profileSelector);
30391
+ const mode = input.mode ?? "not-staged";
29915
30392
  if (input.scope === "project") {
29916
30393
  if (!input.projectPath) {
29917
30394
  throw new Error("projectPath is required for project scope");
@@ -29928,9 +30405,10 @@ async function resolveUntrackedScanResults(input) {
29928
30405
  originRef: originRef3,
29929
30406
  scanResults: filterScanResultsToNotStaged(
29930
30407
  scanned2,
29931
- committedKeys,
30408
+ committed,
29932
30409
  ownedPaths2,
29933
- originRef3
30410
+ originRef3,
30411
+ mode
29934
30412
  )
29935
30413
  };
29936
30414
  }
@@ -29949,9 +30427,10 @@ async function resolveUntrackedScanResults(input) {
29949
30427
  originRef: originRef2,
29950
30428
  scanResults: filterScanResultsToNotStaged(
29951
30429
  scanned,
29952
- committedKeys,
30430
+ committed,
29953
30431
  ownedPaths,
29954
- originRef2
30432
+ originRef2,
30433
+ mode
29955
30434
  )
29956
30435
  };
29957
30436
  }
@@ -29986,18 +30465,33 @@ async function addAllUntrackedResourcesToProfile(input) {
29986
30465
  added_count: resources.length
29987
30466
  };
29988
30467
  }
29989
- function filterScanResultsToNotStaged(results, committedKeys, ownedPaths, rootPath) {
30468
+ function filterScanResultsToNotStaged(results, committed, ownedPaths, rootPath, mode) {
29990
30469
  const filtered = [];
29991
30470
  for (const result of results) {
29992
30471
  const resources = result.resources.filter((resource) => {
29993
30472
  if (!isMaterialResource2(resource)) {
29994
30473
  return false;
29995
30474
  }
29996
- if (committedKeys.has(profileResourceKey2(resource))) {
29997
- return false;
30475
+ const key = profileResourceKey2(resource);
30476
+ const tracked = committed.get(key);
30477
+ switch (mode) {
30478
+ case "stash-untracked":
30479
+ if (tracked) {
30480
+ return false;
30481
+ }
30482
+ break;
30483
+ case "not-staged":
30484
+ if (tracked && !liveDiffersFromTracked(resource, tracked)) {
30485
+ return false;
30486
+ }
30487
+ break;
30488
+ default: {
30489
+ const exhaustive = mode;
30490
+ throw new Error(`Unhandled untracked scan mode: ${exhaustive}`);
30491
+ }
29998
30492
  }
29999
30493
  const sourcePath = normalizeManagedPath(resource.source ?? "", rootPath);
30000
- if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, rootPath)) {
30494
+ if (sourcePath && ownedPaths.has(sourcePath) && !isMergedContainerResource(resource, rootPath) && !tracked) {
30001
30495
  return false;
30002
30496
  }
30003
30497
  return true;
@@ -30010,11 +30504,11 @@ function filterScanResultsToNotStaged(results, committedKeys, ownedPaths, rootPa
30010
30504
  }
30011
30505
  function readHomeFile(homeRoot, relativePath2) {
30012
30506
  const fullPath = resolve15(homeRoot, relativePath2);
30013
- if (!existsSync40(fullPath)) {
30507
+ if (!existsSync41(fullPath)) {
30014
30508
  return null;
30015
30509
  }
30016
30510
  try {
30017
- return readFileSync34(fullPath, "utf-8");
30511
+ return readFileSync35(fullPath, "utf-8");
30018
30512
  } catch {
30019
30513
  return null;
30020
30514
  }
@@ -30045,7 +30539,8 @@ async function captureUntrackedResourcesForStash(input) {
30045
30539
  const { scanResults: untrackedScanResults } = await resolveUntrackedScanResults({
30046
30540
  profileSelector: input.profileSelector,
30047
30541
  scope: "home",
30048
- harness: input.harness
30542
+ harness: input.harness,
30543
+ mode: "stash-untracked"
30049
30544
  });
30050
30545
  if (untrackedScanResults.length === 0) {
30051
30546
  throw new Error("No untracked resources to stash.");
@@ -30100,8 +30595,8 @@ function restoreUntrackedStashFiles(homeRoot, files, dryRun = false) {
30100
30595
  continue;
30101
30596
  }
30102
30597
  const fullPath = resolve15(homeRoot, file.path);
30103
- mkdirSync16(dirname12(fullPath), { recursive: true });
30104
- writeFileSync16(fullPath, file.content, "utf-8");
30598
+ mkdirSync17(dirname12(fullPath), { recursive: true });
30599
+ writeFileSync17(fullPath, file.content, "utf-8");
30105
30600
  restored.push(file.path);
30106
30601
  }
30107
30602
  return restored;
@@ -30356,11 +30851,11 @@ async function commitManagedResourceFromLive(input) {
30356
30851
  })).filter((result) => result.resources.length > 0);
30357
30852
  if (matching.length === 0) {
30358
30853
  if (input.path && attached.type === "instruction") {
30359
- const fullPath = join54(originRef2, normalizeManagedPath(input.path, originRef2));
30360
- if (!existsSync41(fullPath)) {
30854
+ const fullPath = join55(originRef2, normalizeManagedPath(input.path, originRef2));
30855
+ if (!existsSync42(fullPath)) {
30361
30856
  throw new Error(`Live file not found: ${input.path}`);
30362
30857
  }
30363
- const content = readFileSync35(fullPath, "utf-8");
30858
+ const content = readFileSync36(fullPath, "utf-8");
30364
30859
  markPluginDirty(profilePlugin.id);
30365
30860
  const updated = upsertResource(
30366
30861
  {
@@ -30431,24 +30926,24 @@ async function commitManagedPathFromLive(input) {
30431
30926
  }
30432
30927
 
30433
30928
  // src/services/profile-file-diff.ts
30434
- import { existsSync as existsSync45, readFileSync as readFileSync39 } from "fs";
30435
- import { join as join58 } from "path";
30929
+ import { existsSync as existsSync47, readFileSync as readFileSync41 } from "fs";
30930
+ import { join as join60 } from "path";
30436
30931
 
30437
30932
  // src/services/profile-apply-preview.ts
30438
- import { existsSync as existsSync44, readFileSync as readFileSync38 } from "fs";
30439
- import { join as join57, resolve as resolve18 } from "path";
30933
+ import { existsSync as existsSync46, readFileSync as readFileSync40 } from "fs";
30934
+ import { join as join59, resolve as resolve18 } from "path";
30440
30935
  init_plugin_model();
30441
30936
  init_home_root();
30442
30937
 
30443
30938
  // src/services/cursor-host-managed-skills.ts
30444
30939
  init_registry();
30445
- import { existsSync as existsSync42, readdirSync as readdirSync17, readFileSync as readFileSync36, statSync as statSync12 } from "fs";
30446
- import { join as join55 } from "path";
30447
- import matter8 from "gray-matter";
30940
+ import { existsSync as existsSync43, readdirSync as readdirSync17, readFileSync as readFileSync37, statSync as statSync12 } from "fs";
30941
+ import { join as join56 } from "path";
30942
+ import matter9 from "gray-matter";
30448
30943
  var CURSOR_HOST_MANAGED_SKILLS_DISPLAY_ROOT = "~/.cursor/skills-cursor";
30449
30944
  var CURSOR_USER_SKILLS_DISPLAY_ROOT = "~/.cursor/skills";
30450
30945
  function resolveConfiguredHomePath(homeRoot, configuredPath) {
30451
- return configuredPath.startsWith("~/") ? join55(homeRoot, configuredPath.slice(2)) : join55(homeRoot, configuredPath);
30946
+ return configuredPath.startsWith("~/") ? join56(homeRoot, configuredPath.slice(2)) : join56(homeRoot, configuredPath);
30452
30947
  }
30453
30948
  function hostManagedSkillsConfiguredPath() {
30454
30949
  const platform = getPlatform("cursor");
@@ -30460,7 +30955,7 @@ function userSkillsConfiguredPath() {
30460
30955
  }
30461
30956
  function tryParseSkillFrontmatter(content) {
30462
30957
  try {
30463
- const parsed = matter8(content);
30958
+ const parsed = matter9(content);
30464
30959
  if (content.startsWith("---") && parsed.content === content) {
30465
30960
  return void 0;
30466
30961
  }
@@ -30475,7 +30970,7 @@ function tryParseSkillFrontmatter(content) {
30475
30970
  function scanCursorHostManagedSkills(homeRoot) {
30476
30971
  const configured = hostManagedSkillsConfiguredPath();
30477
30972
  const fullPath = resolveConfiguredHomePath(homeRoot, configured);
30478
- if (!existsSync42(fullPath)) {
30973
+ if (!existsSync43(fullPath)) {
30479
30974
  return [];
30480
30975
  }
30481
30976
  let entries;
@@ -30487,10 +30982,10 @@ function scanCursorHostManagedSkills(homeRoot) {
30487
30982
  const displayRoot = configured.replace(/\/$/, "");
30488
30983
  const skills = [];
30489
30984
  for (const entry of entries) {
30490
- const entryPath = join55(fullPath, entry);
30491
- const skillMd = join55(entryPath, "SKILL.md");
30985
+ const entryPath = join56(fullPath, entry);
30986
+ const skillMd = join56(entryPath, "SKILL.md");
30492
30987
  try {
30493
- if (!statSync12(entryPath).isDirectory() || !existsSync42(skillMd)) {
30988
+ if (!statSync12(entryPath).isDirectory() || !existsSync43(skillMd)) {
30494
30989
  continue;
30495
30990
  }
30496
30991
  } catch {
@@ -30498,7 +30993,7 @@ function scanCursorHostManagedSkills(homeRoot) {
30498
30993
  }
30499
30994
  let raw;
30500
30995
  try {
30501
- raw = readFileSync36(skillMd, "utf-8");
30996
+ raw = readFileSync37(skillMd, "utf-8");
30502
30997
  } catch {
30503
30998
  continue;
30504
30999
  }
@@ -30531,8 +31026,8 @@ function detectCursorHostManagedSkillCollisions(input) {
30531
31026
  const profileSkills = input.profileSkills ?? /* @__PURE__ */ new Map();
30532
31027
  const collisions = [];
30533
31028
  for (const host of input.hostSkills) {
30534
- const userSkillMd = join55(userSkillsRoot, host.name, "SKILL.md");
30535
- if (existsSync42(userSkillMd)) {
31029
+ const userSkillMd = join56(userSkillsRoot, host.name, "SKILL.md");
31030
+ if (existsSync43(userSkillMd)) {
30536
31031
  collisions.push({
30537
31032
  name: host.name,
30538
31033
  host_source: host.source,
@@ -30583,9 +31078,76 @@ function profileSkillNameMap(resources) {
30583
31078
  // src/services/global-profile-status-panel.ts
30584
31079
  init_claude_plugin_ref();
30585
31080
  init_claude_installed();
30586
- import { existsSync as existsSync43, readFileSync as readFileSync37 } from "fs";
30587
- import { join as join56, resolve as resolve17 } from "path";
31081
+ import { existsSync as existsSync45, readFileSync as readFileSync39 } from "fs";
31082
+ import { join as join58, resolve as resolve17 } from "path";
30588
31083
  init_registry();
31084
+
31085
+ // src/services/host-native-mcp.ts
31086
+ init_claude_installed();
31087
+ init_claude_plugin_ref();
31088
+ import { existsSync as existsSync44, readFileSync as readFileSync38 } from "fs";
31089
+ import { join as join57 } from "path";
31090
+ init_mcp_config_bridge();
31091
+ var PLUGIN_MCP_FILES = ["mcp.json", ".mcp.json"];
31092
+ function mcpNamesFromInstallPath(installPath) {
31093
+ const names = [];
31094
+ for (const fileName of PLUGIN_MCP_FILES) {
31095
+ const fullPath = join57(installPath, fileName);
31096
+ if (!existsSync44(fullPath)) {
31097
+ continue;
31098
+ }
31099
+ try {
31100
+ const document = JSON.parse(readFileSync38(fullPath, "utf-8"));
31101
+ names.push(...Object.keys(parseMcpServersDocument(document)));
31102
+ } catch {
31103
+ }
31104
+ }
31105
+ return names;
31106
+ }
31107
+ function listHostNativeMcpNames(homeRoot, harnessId) {
31108
+ const names = /* @__PURE__ */ new Set();
31109
+ switch (harnessId) {
31110
+ case "cursor": {
31111
+ for (const name of listCursorNativeMcpPluginNames(homeRoot)) {
31112
+ names.add(name);
31113
+ }
31114
+ for (const install of listCursorPluginInstalls(homeRoot)) {
31115
+ if (!install.installPath) {
31116
+ continue;
31117
+ }
31118
+ for (const name of mcpNamesFromInstallPath(install.installPath)) {
31119
+ names.add(name);
31120
+ }
31121
+ }
31122
+ break;
31123
+ }
31124
+ case "claude-code": {
31125
+ for (const install of loadInstalled(homeRoot)) {
31126
+ if (!install.installPath) {
31127
+ continue;
31128
+ }
31129
+ for (const name of mcpNamesFromInstallPath(install.installPath)) {
31130
+ names.add(name);
31131
+ }
31132
+ }
31133
+ break;
31134
+ }
31135
+ default:
31136
+ break;
31137
+ }
31138
+ return names;
31139
+ }
31140
+ function hostPluginPinIsInstalled(homeRoot, pinRef) {
31141
+ if (findInstalledRefForCatalogPin(pinRef, homeRoot)) {
31142
+ return true;
31143
+ }
31144
+ const { name } = parsePluginRef(pinRef);
31145
+ return listCursorPluginInstalls(homeRoot).some(
31146
+ (row) => row.ref === pinRef || row.name === name
31147
+ );
31148
+ }
31149
+
31150
+ // src/services/global-profile-status-panel.ts
30589
31151
  init_mcp_config_bridge();
30590
31152
  var PANEL_HARNESS_IDS = ["claude-code", "cursor"];
30591
31153
  function collectOwnedGlobalProfileFiles(snapshotId) {
@@ -30612,25 +31174,58 @@ function classifyGlobalDriftChanges(changes, ownedFiles) {
30612
31174
  }
30613
31175
  return { owned, nonOwned };
30614
31176
  }
30615
- function readGlobalMcpServerNames(homeRoot, harnessId) {
31177
+ function mcpManagedPathForHarness(harnessId) {
31178
+ switch (harnessId) {
31179
+ case "cursor":
31180
+ return ".cursor/mcp.json";
31181
+ case "claude-code":
31182
+ return ".mcp.json";
31183
+ default:
31184
+ return void 0;
31185
+ }
31186
+ }
31187
+ function declaredMcpFromExpectedFiles(harnessIds, expectedFiles) {
31188
+ const namesByHarness = {};
31189
+ const configsByHarness = {};
31190
+ for (const harnessId of harnessIds) {
31191
+ const mcpPath = mcpManagedPathForHarness(harnessId);
31192
+ const configs = {};
31193
+ if (mcpPath) {
31194
+ for (const file of expectedFiles) {
31195
+ if (file.path !== mcpPath) {
31196
+ continue;
31197
+ }
31198
+ try {
31199
+ const document = JSON.parse(file.content);
31200
+ Object.assign(configs, parseMcpServersDocument(document));
31201
+ } catch {
31202
+ }
31203
+ }
31204
+ }
31205
+ namesByHarness[harnessId] = Object.keys(configs);
31206
+ configsByHarness[harnessId] = configs;
31207
+ }
31208
+ return { namesByHarness, configsByHarness };
31209
+ }
31210
+ function readGlobalMcpServers(homeRoot, harnessId) {
30616
31211
  const platform = getPlatform(harnessId);
30617
31212
  if (!platform) {
30618
- return /* @__PURE__ */ new Set();
31213
+ return {};
30619
31214
  }
30620
31215
  const configuredPath = harnessId === "cursor" ? platform.globalPaths.settings : platform.globalPaths.mcp ?? platform.projectPaths.mcp;
30621
31216
  if (!configuredPath) {
30622
- return /* @__PURE__ */ new Set();
31217
+ return {};
30623
31218
  }
30624
31219
  const relativePath2 = configuredPath.startsWith("~/") ? configuredPath.slice(2) : configuredPath;
30625
- const fullPath = join56(homeRoot, relativePath2);
30626
- if (!existsSync43(fullPath)) {
30627
- return /* @__PURE__ */ new Set();
31220
+ const fullPath = join58(homeRoot, relativePath2);
31221
+ if (!existsSync45(fullPath)) {
31222
+ return {};
30628
31223
  }
30629
31224
  try {
30630
- const document = JSON.parse(readFileSync37(fullPath, "utf-8"));
30631
- return new Set(Object.keys(parseMcpServersDocument(document)));
31225
+ const document = JSON.parse(readFileSync39(fullPath, "utf-8"));
31226
+ return parseMcpServersDocument(document);
30632
31227
  } catch {
30633
- return /* @__PURE__ */ new Set();
31228
+ return {};
30634
31229
  }
30635
31230
  }
30636
31231
  function buildHarnessPluginRows(declaredPins, homeRoot) {
@@ -30686,12 +31281,19 @@ function buildCursorHarnessPluginRows(declaredPins, homeRoot) {
30686
31281
  }
30687
31282
  return rows;
30688
31283
  }
30689
- function buildHarnessMcpRows(declaredNames, liveNames) {
31284
+ function buildHarnessMcpRows(declaredNames, liveNames, comparison) {
30690
31285
  const declared = new Set(declaredNames);
30691
- const rows = declaredNames.map((name) => ({
30692
- name,
30693
- state: liveNames.has(name) ? "present" : "missing"
30694
- }));
31286
+ const rows = declaredNames.map((name) => {
31287
+ if (!liveNames.has(name)) {
31288
+ return { name, state: "missing" };
31289
+ }
31290
+ const expected = comparison?.expected[name];
31291
+ const live = comparison?.live[name];
31292
+ if (expected && live && !mcpServerMetadataEquivalent(expected, live)) {
31293
+ return { name, state: "mismatch" };
31294
+ }
31295
+ return { name, state: "present" };
31296
+ });
30695
31297
  for (const name of liveNames) {
30696
31298
  if (!declared.has(name)) {
30697
31299
  rows.push({ name, state: "extra" });
@@ -30782,7 +31384,12 @@ function buildHarnessLiveStatusMap(input) {
30782
31384
  continue;
30783
31385
  }
30784
31386
  const declaredMcp = input.declaredMcpByHarness[harnessId] ?? [];
30785
- const liveMcp = readGlobalMcpServerNames(input.homeRoot, harnessId);
31387
+ const liveServers = readGlobalMcpServers(input.homeRoot, harnessId);
31388
+ const liveMcp = /* @__PURE__ */ new Set([
31389
+ ...Object.keys(liveServers),
31390
+ ...listHostNativeMcpNames(input.homeRoot, harnessId)
31391
+ ]);
31392
+ const expectedServers = input.expectedMcpConfigsByHarness?.[harnessId];
30786
31393
  let plugins = [];
30787
31394
  switch (harnessId) {
30788
31395
  case "claude-code":
@@ -30803,7 +31410,11 @@ function buildHarnessLiveStatusMap(input) {
30803
31410
  }
30804
31411
  harnesses[harnessId] = {
30805
31412
  plugins,
30806
- mcp: buildHarnessMcpRows(declaredMcp, liveMcp)
31413
+ mcp: buildHarnessMcpRows(
31414
+ declaredMcp,
31415
+ liveMcp,
31416
+ expectedServers ? { expected: expectedServers, live: liveServers } : void 0
31417
+ )
30807
31418
  };
30808
31419
  }
30809
31420
  return harnesses;
@@ -30813,14 +31424,13 @@ function countMissingHarnessRows(harnesses) {
30813
31424
  let missingMcp = 0;
30814
31425
  for (const status2 of Object.values(harnesses)) {
30815
31426
  missingPlugins += status2.plugins.filter((row) => row.state === "missing").length;
30816
- missingMcp += status2.mcp.filter((row) => row.state === "missing").length;
31427
+ missingMcp += status2.mcp.filter(
31428
+ (row) => row.state === "missing" || row.state === "mismatch"
31429
+ ).length;
30817
31430
  }
30818
31431
  return { missingPlugins, missingMcp };
30819
31432
  }
30820
31433
 
30821
- // src/services/profile-apply-preview.ts
30822
- init_mcp_config_bridge();
30823
-
30824
31434
  // src/services/file-contents-drift.ts
30825
31435
  init_mcp_config_bridge();
30826
31436
 
@@ -30878,7 +31488,145 @@ function fileContentsEquivalentForDrift(path, current, expected) {
30878
31488
  return false;
30879
31489
  }
30880
31490
 
31491
+ // src/services/apply-preview-inherited.ts
31492
+ init_resource();
31493
+ init_types();
31494
+ init_mcp_config_bridge();
31495
+ var MATERIAL_TYPE_SET = new Set(MATERIAL_RESOURCE_TYPES);
31496
+ function findMaterialResource(type, name) {
31497
+ if (!MATERIAL_TYPE_SET.has(type)) {
31498
+ return void 0;
31499
+ }
31500
+ return getResource(`${type}:${name}`) ?? findResourceByKey(type, name, "");
31501
+ }
31502
+ function nativeMcpNamesForPath(homeRoot, path) {
31503
+ const normalized = path.replace(/\\/g, "/");
31504
+ if (normalized.includes(".cursor/") && /(^|\/)mcp\.json$/i.test(normalized)) {
31505
+ return listHostNativeMcpNames(homeRoot, "cursor");
31506
+ }
31507
+ if (/(^|\/)\.mcp\.json$/i.test(normalized)) {
31508
+ return listHostNativeMcpNames(homeRoot, "claude-code");
31509
+ }
31510
+ return /* @__PURE__ */ new Set();
31511
+ }
31512
+ function mcpPreviewContentsEquivalent(current, expected, nativeNames) {
31513
+ let expectedDocument;
31514
+ try {
31515
+ expectedDocument = JSON.parse(expected);
31516
+ } catch {
31517
+ return false;
31518
+ }
31519
+ const expectedServers = parseMcpServersDocument(expectedDocument);
31520
+ const expectedNames = Object.keys(expectedServers);
31521
+ const nonNativeExpected = expectedNames.filter((name) => !nativeNames.has(name));
31522
+ if (current === null) {
31523
+ return expectedNames.length === 0 || nonNativeExpected.length === 0;
31524
+ }
31525
+ let currentDocument;
31526
+ try {
31527
+ currentDocument = JSON.parse(current);
31528
+ } catch {
31529
+ return false;
31530
+ }
31531
+ const currentServers = parseMcpServersDocument(currentDocument);
31532
+ const mergedCurrent = {
31533
+ ...currentServers
31534
+ };
31535
+ for (const name of expectedNames) {
31536
+ const expectedMeta = expectedServers[name];
31537
+ if (nativeNames.has(name) && expectedMeta && !(name in mergedCurrent)) {
31538
+ mergedCurrent[name] = expectedMeta;
31539
+ }
31540
+ }
31541
+ return mcpConfigContentsEquivalent(
31542
+ JSON.stringify({ mcpServers: mergedCurrent }),
31543
+ JSON.stringify({ mcpServers: expectedServers })
31544
+ );
31545
+ }
31546
+ function collectOwnedPreviewResources(expectedFiles) {
31547
+ const order = [];
31548
+ const byKey = /* @__PURE__ */ new Map();
31549
+ const add = (type, name) => {
31550
+ const key = `${type}:${name}`;
31551
+ if (byKey.has(key)) {
31552
+ return;
31553
+ }
31554
+ order.push(key);
31555
+ byKey.set(key, { type, name });
31556
+ };
31557
+ for (const file of expectedFiles) {
31558
+ const mapped = resourceKeyFromManagedPath(file.path);
31559
+ if (mapped) {
31560
+ add(mapped.type, mapped.name);
31561
+ }
31562
+ if (!isMcpConfigManagedPath(file.path)) {
31563
+ continue;
31564
+ }
31565
+ try {
31566
+ const document = JSON.parse(file.content);
31567
+ for (const name of Object.keys(parseMcpServersDocument(document))) {
31568
+ add("mcp_server", name);
31569
+ }
31570
+ } catch {
31571
+ }
31572
+ }
31573
+ return order.map((key) => byKey.get(key)).filter((entry) => entry !== void 0);
31574
+ }
31575
+ function resourceIsDeployedHostPluginOwned(type, name, homeRoot) {
31576
+ const resource = findMaterialResource(type, name);
31577
+ if (!resource || resource.origin_kind !== "marketplace_link" || !resource.origin_ref) {
31578
+ return null;
31579
+ }
31580
+ return {
31581
+ originRef: resource.origin_ref,
31582
+ installed: hostPluginPinIsInstalled(homeRoot, resource.origin_ref)
31583
+ };
31584
+ }
31585
+ function omitInheritedPluginFileChanges(homeRoot, changes, targetPinRefs2) {
31586
+ return changes.filter((change) => {
31587
+ if (isMcpConfigManagedPath(change.path)) {
31588
+ return true;
31589
+ }
31590
+ const mapped = change.resource ?? resourceKeyFromManagedPath(change.path);
31591
+ if (!mapped || mapped.type === "mcp_server") {
31592
+ return true;
31593
+ }
31594
+ const owned = resourceIsDeployedHostPluginOwned(
31595
+ mapped.type,
31596
+ mapped.name,
31597
+ homeRoot
31598
+ );
31599
+ if (!owned?.installed) {
31600
+ return true;
31601
+ }
31602
+ switch (change.type) {
31603
+ case "deleted":
31604
+ case "modified":
31605
+ return false;
31606
+ case "added":
31607
+ return !targetPinRefs2.has(owned.originRef);
31608
+ default: {
31609
+ const neverType = change.type;
31610
+ return neverType;
31611
+ }
31612
+ }
31613
+ });
31614
+ }
31615
+ function expectedFileMatchesLiveForPreview(homeRoot, file, current) {
31616
+ if (isMcpConfigManagedPath(file.path)) {
31617
+ const nativeNames = nativeMcpNamesForPath(homeRoot, file.path);
31618
+ if (nativeNames.size > 0) {
31619
+ return mcpPreviewContentsEquivalent(current, file.content, nativeNames);
31620
+ }
31621
+ }
31622
+ if (current === null) {
31623
+ return false;
31624
+ }
31625
+ return fileContentsEquivalentForDrift(file.path, current, file.content);
31626
+ }
31627
+
30881
31628
  // src/services/profile-apply-preview.ts
31629
+ init_merged_host_config();
30882
31630
  init_scanner();
30883
31631
  init_types2();
30884
31632
  function warningFromError(error) {
@@ -30917,41 +31665,21 @@ function spreadWarningFields(input) {
30917
31665
  };
30918
31666
  }
30919
31667
  function readRootFile(rootPath, relativePath2) {
30920
- const fullPath = join57(rootPath, relativePath2);
30921
- if (!existsSync44(fullPath)) {
31668
+ const fullPath = join59(rootPath, relativePath2);
31669
+ if (!existsSync46(fullPath)) {
30922
31670
  return null;
30923
31671
  }
30924
31672
  try {
30925
- return readFileSync38(fullPath, "utf-8");
31673
+ return readFileSync40(fullPath, "utf-8");
30926
31674
  } catch {
30927
31675
  return null;
30928
31676
  }
30929
31677
  }
30930
- function declaredMcpNamesFromExpectedApply(expectedApply) {
30931
- const byHarness = {};
30932
- for (const harnessId of expectedApply.harnesses) {
30933
- const mcpPaths = /* @__PURE__ */ new Set();
30934
- if (harnessId === "cursor") {
30935
- mcpPaths.add(".cursor/mcp.json");
30936
- } else if (harnessId === "claude-code") {
30937
- mcpPaths.add(".mcp.json");
30938
- }
30939
- const names = /* @__PURE__ */ new Set();
30940
- for (const file of expectedApply.expected_files ?? []) {
30941
- if (!mcpPaths.has(file.path)) {
30942
- continue;
30943
- }
30944
- try {
30945
- const document = JSON.parse(file.content);
30946
- for (const name of Object.keys(parseMcpServersDocument(document))) {
30947
- names.add(name);
30948
- }
30949
- } catch {
30950
- }
30951
- }
30952
- byHarness[harnessId] = [...names];
30953
- }
30954
- return byHarness;
31678
+ function declaredMcpFromExpectedApply(expectedApply) {
31679
+ return declaredMcpFromExpectedFiles(
31680
+ expectedApply.harnesses,
31681
+ expectedApply.expected_files ?? []
31682
+ );
30955
31683
  }
30956
31684
  function uniqueExpectedFiles(expectedFiles) {
30957
31685
  const seen = /* @__PURE__ */ new Set();
@@ -30967,8 +31695,12 @@ function uniqueExpectedFiles(expectedFiles) {
30967
31695
  }
30968
31696
  function compareExpectedFiles(rootPath, expectedFiles) {
30969
31697
  const changes = [];
31698
+ const homeRoot = resolveHomeRoot();
30970
31699
  for (const file of uniqueExpectedFiles(expectedFiles)) {
30971
31700
  const current = readRootFile(rootPath, file.path);
31701
+ if (expectedFileMatchesLiveForPreview(homeRoot, file, current)) {
31702
+ continue;
31703
+ }
30972
31704
  if (current === null) {
30973
31705
  changes.push({ path: file.path, type: "deleted" });
30974
31706
  continue;
@@ -31006,44 +31738,11 @@ function omitTransparentCrossHarnessAdds(rootPath, expectedFiles, changes) {
31006
31738
  return !materializedElsewhere;
31007
31739
  });
31008
31740
  }
31009
- var CLAUDE_SETTINGS_RELATIVE = ".claude/settings.json";
31010
- var CLAUDE_MERGED_CONTAINER_RESOURCE_TYPES = /* @__PURE__ */ new Set([
31011
- "permission",
31012
- "env_var",
31013
- "hook"
31014
- ]);
31015
- function profileManagesClaudeSettings(pluginIds) {
31016
- if (!pluginIds || pluginIds.length === 0) {
31017
- return false;
31018
- }
31019
- const merged = mergePluginsForApply(pluginIds);
31020
- return merged.resources.some(
31021
- (resource) => CLAUDE_MERGED_CONTAINER_RESOURCE_TYPES.has(resource.type)
31741
+ function omitMergeableHostConfigRemovals(changes) {
31742
+ return changes.filter(
31743
+ (change) => !(change.type === "added" && isMergeableHostConfigPath(change.path))
31022
31744
  );
31023
31745
  }
31024
- function withUnmanagedMergedContainers(rootPath, expectedFiles, changes, profileManagesSettings) {
31025
- const expectedNormalized = new Set(
31026
- expectedFiles.map(
31027
- (file) => file.path.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^~\//, "")
31028
- )
31029
- );
31030
- const settingsAlreadyExpected = [...expectedNormalized].some(
31031
- (path) => path === CLAUDE_SETTINGS_RELATIVE || path.endsWith(`/${CLAUDE_SETTINGS_RELATIVE}`)
31032
- );
31033
- if (settingsAlreadyExpected || profileManagesSettings) {
31034
- return changes;
31035
- }
31036
- if (readRootFile(rootPath, CLAUDE_SETTINGS_RELATIVE) === null) {
31037
- return changes;
31038
- }
31039
- const alreadyListed = changes.some(
31040
- (change) => change.path.replace(/\\/g, "/").replace(/^~\//, "") === CLAUDE_SETTINGS_RELATIVE || change.path.replace(/\\/g, "/").endsWith(`/${CLAUDE_SETTINGS_RELATIVE}`)
31041
- );
31042
- if (alreadyListed) {
31043
- return changes;
31044
- }
31045
- return [...changes, { path: CLAUDE_SETTINGS_RELATIVE, type: "added" }];
31046
- }
31047
31746
  function withMappedResources(changes) {
31048
31747
  return changes.map((change) => {
31049
31748
  const mapped = resourceKeyFromManagedPath(change.path);
@@ -31057,7 +31756,7 @@ function withManagedRemovals(rootPath, changes, removedFiles) {
31057
31756
  const seen = new Set(changes.map((change) => change.path));
31058
31757
  const next = [...changes];
31059
31758
  for (const path of removedFiles) {
31060
- if (seen.has(path)) {
31759
+ if (seen.has(path) || isMergeableHostConfigPath(path)) {
31061
31760
  continue;
31062
31761
  }
31063
31762
  if (readRootFile(rootPath, path) === null) {
@@ -31068,11 +31767,17 @@ function withManagedRemovals(rootPath, changes, removedFiles) {
31068
31767
  }
31069
31768
  return next;
31070
31769
  }
31770
+ function targetPinRefs(pluginIds) {
31771
+ if (!pluginIds || pluginIds.length === 0) {
31772
+ return /* @__PURE__ */ new Set();
31773
+ }
31774
+ return new Set(
31775
+ mergePluginsForApply(pluginIds).pluginPins.map((pin) => pin.ref)
31776
+ );
31777
+ }
31071
31778
  function buildPreviewFileChanges(rootPath, expectedFiles, removedFiles, pluginIds) {
31072
- return withMappedResources(
31073
- withUnmanagedMergedContainers(
31074
- rootPath,
31075
- expectedFiles,
31779
+ const mapped = withMappedResources(
31780
+ omitMergeableHostConfigRemovals(
31076
31781
  withManagedRemovals(
31077
31782
  rootPath,
31078
31783
  omitTransparentCrossHarnessAdds(
@@ -31081,10 +31786,27 @@ function buildPreviewFileChanges(rootPath, expectedFiles, removedFiles, pluginId
31081
31786
  compareExpectedFiles(rootPath, expectedFiles)
31082
31787
  ),
31083
31788
  removedFiles
31084
- ),
31085
- profileManagesClaudeSettings(pluginIds)
31789
+ )
31086
31790
  )
31087
31791
  );
31792
+ return omitInheritedPluginFileChanges(
31793
+ resolveHomeRoot(),
31794
+ mapped,
31795
+ targetPinRefs(pluginIds)
31796
+ );
31797
+ }
31798
+ function previewFilesResult(rootPath, expectedFiles, removedFiles, pluginIds) {
31799
+ return {
31800
+ expected_count: expectedFiles.length,
31801
+ changes: buildPreviewFileChanges(
31802
+ rootPath,
31803
+ expectedFiles,
31804
+ removedFiles,
31805
+ pluginIds
31806
+ ),
31807
+ root_path: rootPath,
31808
+ owned_resources: collectOwnedPreviewResources(expectedFiles)
31809
+ };
31088
31810
  }
31089
31811
  function isMaterialResource3(resource) {
31090
31812
  return resource.type !== "plugin";
@@ -31276,36 +31998,30 @@ async function previewHomeApply(profile, harness) {
31276
31998
  declaredPins: [],
31277
31999
  declaredMcpByHarness: {}
31278
32000
  }),
31279
- files: {
31280
- expected_count: collected.expectedFiles.length,
31281
- changes: buildPreviewFileChanges(
31282
- collected.rootPath,
31283
- collected.expectedFiles,
31284
- collected.removedFiles,
31285
- collected.pluginIds
31286
- ),
31287
- root_path: collected.rootPath
31288
- }
32001
+ files: previewFilesResult(
32002
+ collected.rootPath,
32003
+ collected.expectedFiles,
32004
+ collected.removedFiles,
32005
+ collected.pluginIds
32006
+ )
31289
32007
  };
31290
32008
  }
31291
32009
  const declaredPins = collected.pluginIds ? mergePluginsForApply(collected.pluginIds).pluginPins : [];
32010
+ const declaredMcp = collected.expectedApply ? declaredMcpFromExpectedApply(collected.expectedApply) : { namesByHarness: {}, configsByHarness: {} };
31292
32011
  return {
31293
32012
  harnesses: buildHarnessLiveStatusMap({
31294
32013
  depth: "full",
31295
32014
  homeRoot: collected.rootPath,
31296
32015
  declaredPins,
31297
- declaredMcpByHarness: collected.expectedApply ? declaredMcpNamesFromExpectedApply(collected.expectedApply) : {}
32016
+ declaredMcpByHarness: declaredMcp.namesByHarness,
32017
+ expectedMcpConfigsByHarness: declaredMcp.configsByHarness
31298
32018
  }),
31299
- files: {
31300
- expected_count: collected.expectedFiles.length,
31301
- changes: buildPreviewFileChanges(
31302
- collected.rootPath,
31303
- collected.expectedFiles,
31304
- collected.removedFiles,
31305
- collected.pluginIds
31306
- ),
31307
- root_path: collected.rootPath
31308
- }
32019
+ files: previewFilesResult(
32020
+ collected.rootPath,
32021
+ collected.expectedFiles,
32022
+ collected.removedFiles,
32023
+ collected.pluginIds
32024
+ )
31309
32025
  };
31310
32026
  }
31311
32027
  async function previewProjectApply(profile, projectPath, harness) {
@@ -31315,16 +32031,12 @@ async function previewProjectApply(profile, projectPath, harness) {
31315
32031
  harness
31316
32032
  );
31317
32033
  return {
31318
- files: {
31319
- expected_count: collected.expectedFiles.length,
31320
- changes: buildPreviewFileChanges(
31321
- collected.rootPath,
31322
- collected.expectedFiles,
31323
- collected.removedFiles,
31324
- collected.pluginIds
31325
- ),
31326
- root_path: collected.rootPath
31327
- },
32034
+ files: previewFilesResult(
32035
+ collected.rootPath,
32036
+ collected.expectedFiles,
32037
+ collected.removedFiles,
32038
+ collected.pluginIds
32039
+ ),
31328
32040
  ...spreadWarningFields(collected)
31329
32041
  };
31330
32042
  }
@@ -31375,11 +32087,11 @@ async function previewProfileApply(input) {
31375
32087
 
31376
32088
  // src/services/profile-file-diff.ts
31377
32089
  function readLiveFile(absolutePath) {
31378
- if (!existsSync45(absolutePath)) {
32090
+ if (!existsSync47(absolutePath)) {
31379
32091
  return null;
31380
32092
  }
31381
32093
  try {
31382
- return readFileSync39(absolutePath, "utf-8");
32094
+ return readFileSync41(absolutePath, "utf-8");
31383
32095
  } catch {
31384
32096
  return null;
31385
32097
  }
@@ -31404,7 +32116,7 @@ async function getManagedFileDiff(input) {
31404
32116
  throw new Error(`Path is not a managed file for this profile: ${input.path}`);
31405
32117
  }
31406
32118
  const relativePath2 = normalizeManagedPath(match.path, collected.rootPath);
31407
- const absolutePath = join58(collected.rootPath, relativePath2);
32119
+ const absolutePath = join60(collected.rootPath, relativePath2);
31408
32120
  return {
31409
32121
  path: relativePath2,
31410
32122
  absolute_path: absolutePath,
@@ -31462,8 +32174,8 @@ function removeResourceFromProfile(input) {
31462
32174
  }
31463
32175
 
31464
32176
  // src/services/profile-restore-file.ts
31465
- import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync17 } from "fs";
31466
- import { dirname as dirname13, join as join59 } from "path";
32177
+ import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync18 } from "fs";
32178
+ import { dirname as dirname13, join as join61 } from "path";
31467
32179
  async function restoreManagedFile(input) {
31468
32180
  const profile = input.profileSelector.trim();
31469
32181
  const requestedPath = normalizeManagedPath(input.path.trim());
@@ -31484,9 +32196,9 @@ async function restoreManagedFile(input) {
31484
32196
  throw new Error(`Path is not a managed file for this profile: ${input.path}`);
31485
32197
  }
31486
32198
  const relativePath2 = normalizeManagedPath(match.path, collected.rootPath);
31487
- const absolutePath = join59(collected.rootPath, relativePath2);
31488
- mkdirSync17(dirname13(absolutePath), { recursive: true });
31489
- writeFileSync17(absolutePath, match.content, "utf-8");
32199
+ const absolutePath = join61(collected.rootPath, relativePath2);
32200
+ mkdirSync18(dirname13(absolutePath), { recursive: true });
32201
+ writeFileSync18(absolutePath, match.content, "utf-8");
31490
32202
  return { path: relativePath2, absolute_path: absolutePath };
31491
32203
  }
31492
32204
 
@@ -31974,7 +32686,7 @@ init_plugin_model();
31974
32686
 
31975
32687
  // src/ui/plugin-list-render.ts
31976
32688
  init_plugin_versioning();
31977
- import semver10 from "semver";
32689
+ import semver11 from "semver";
31978
32690
 
31979
32691
  // src/ui/catalog-list-render.ts
31980
32692
  init_plugin_selector();
@@ -32182,12 +32894,12 @@ function renderCatalogListTable(plugins, opts = {}) {
32182
32894
  }
32183
32895
 
32184
32896
  // src/ui/version-render.ts
32185
- import semver9 from "semver";
32897
+ import semver10 from "semver";
32186
32898
  function normalizeVersion(version) {
32187
32899
  return version.startsWith("v") ? version.slice(1) : version;
32188
32900
  }
32189
32901
  function parseCoreParts(version) {
32190
- const parsed = semver9.parse(normalizeVersion(version), { loose: true });
32902
+ const parsed = semver10.parse(normalizeVersion(version), { loose: true });
32191
32903
  if (!parsed) {
32192
32904
  return null;
32193
32905
  }
@@ -32208,12 +32920,12 @@ function formatVersionWithDrift(current, latest) {
32208
32920
  const currentParts = parseCoreParts(normalizedCurrent);
32209
32921
  const latestParts = parseCoreParts(normalizedLatest);
32210
32922
  if (!currentParts || !latestParts) {
32211
- if (semver9.valid(normalizedCurrent) && semver9.valid(normalizedLatest)) {
32212
- return semver9.gte(normalizedCurrent, normalizedLatest) ? theme.success(normalizedCurrent) : theme.danger(normalizedCurrent);
32923
+ if (semver10.valid(normalizedCurrent) && semver10.valid(normalizedLatest)) {
32924
+ return semver10.gte(normalizedCurrent, normalizedLatest) ? theme.success(normalizedCurrent) : theme.danger(normalizedCurrent);
32213
32925
  }
32214
32926
  return normalizedCurrent;
32215
32927
  }
32216
- if (semver9.gte(normalizedCurrent, normalizedLatest)) {
32928
+ if (semver10.gte(normalizedCurrent, normalizedLatest)) {
32217
32929
  return theme.success(normalizedCurrent);
32218
32930
  }
32219
32931
  let firstDivergentIndex = 3;
@@ -32424,7 +33136,7 @@ function findInstalledLocalPlugin(catalogPlugin, localPlugins) {
32424
33136
  if (publishedMatches.length === 0) {
32425
33137
  return void 0;
32426
33138
  }
32427
- return [...publishedMatches].sort((left, right) => semver10.rcompare(left.version, right.version))[0];
33139
+ return [...publishedMatches].sort((left, right) => semver11.rcompare(left.version, right.version))[0];
32428
33140
  }
32429
33141
  function formatRemoteCatalogVersion(catalogPlugin, localPlugins) {
32430
33142
  const latestVersion = catalogPlugin.latestVersion;
@@ -32690,8 +33402,21 @@ function printInstallGaps(preview) {
32690
33402
  }
32691
33403
  }
32692
33404
  for (const mcp of status2.mcp) {
32693
- if (mcp.state === "missing") {
32694
- ui.dim(`mcp ${mcp.name} not installed`);
33405
+ switch (mcp.state) {
33406
+ case "missing":
33407
+ ui.dim(`mcp ${mcp.name} not installed`);
33408
+ break;
33409
+ case "mismatch":
33410
+ ui.dim(`mcp ${mcp.name} different value`);
33411
+ break;
33412
+ case "present":
33413
+ case "extra":
33414
+ break;
33415
+ default: {
33416
+ const _exhaustive = mcp.state;
33417
+ void _exhaustive;
33418
+ break;
33419
+ }
32695
33420
  }
32696
33421
  }
32697
33422
  }
@@ -33011,15 +33736,15 @@ import { resolve as resolve21 } from "path";
33011
33736
  init_name();
33012
33737
  import { createHash as createHash7 } from "crypto";
33013
33738
  import {
33014
- existsSync as existsSync46,
33739
+ existsSync as existsSync48,
33015
33740
  lstatSync as lstatSync8,
33016
- mkdirSync as mkdirSync18,
33017
- readFileSync as readFileSync40,
33741
+ mkdirSync as mkdirSync19,
33742
+ readFileSync as readFileSync42,
33018
33743
  readdirSync as readdirSync18,
33019
33744
  rmSync as rmSync6,
33020
- writeFileSync as writeFileSync18
33745
+ writeFileSync as writeFileSync19
33021
33746
  } from "fs";
33022
- import { dirname as dirname14, join as join60, relative as relative9, resolve as resolve20, sep as sep7 } from "path";
33747
+ import { dirname as dirname14, join as join62, relative as relative9, resolve as resolve20, sep as sep7 } from "path";
33023
33748
  import { parse as parseYaml4, stringify as stringifyYaml3 } from "yaml";
33024
33749
 
33025
33750
  // src/utils/zip-archive.ts
@@ -33275,7 +34000,7 @@ function walkRegularFiles(root, current, files) {
33275
34000
  assertNotSymlink(current, posixRelative(root, current) || ".");
33276
34001
  for (const entry of readdirSync18(current, { withFileTypes: true })) {
33277
34002
  if (entry.name.startsWith(".")) continue;
33278
- const absolute = join60(current, entry.name);
34003
+ const absolute = join62(current, entry.name);
33279
34004
  const relativePath2 = posixRelative(root, absolute);
33280
34005
  if (entry.isSymbolicLink() || isSymlink(absolute)) {
33281
34006
  throw new BundleSymlinkError(relativePath2);
@@ -33292,9 +34017,9 @@ function walkRegularFiles(root, current, files) {
33292
34017
  }
33293
34018
  function readBytes(root, relativePath2) {
33294
34019
  assertContainedPath(root, relativePath2);
33295
- const absolute = join60(root, relativePath2);
34020
+ const absolute = join62(root, relativePath2);
33296
34021
  assertNotSymlink(absolute, relativePath2);
33297
- return readFileSync40(absolute);
34022
+ return readFileSync42(absolute);
33298
34023
  }
33299
34024
  function remapLocalPath(relativePath2, fromApm) {
33300
34025
  const posix = relativePath2.split("\\").join("/");
@@ -33328,28 +34053,28 @@ function putFile(files, relativePath2, bytes, remappedFrom) {
33328
34053
  });
33329
34054
  }
33330
34055
  function collectDir(projectRoot, sourceRelative, fromApm, files) {
33331
- const sourceDir2 = join60(projectRoot, sourceRelative);
33332
- if (!existsSync46(sourceDir2)) return;
34056
+ const sourceDir2 = join62(projectRoot, sourceRelative);
34057
+ if (!existsSync48(sourceDir2)) return;
33333
34058
  assertNotSymlink(sourceDir2, sourceRelative);
33334
34059
  const found = [];
33335
34060
  walkRegularFiles(sourceDir2, sourceDir2, found);
33336
34061
  for (const child of found) {
33337
- const sourcePath = posixRelative(projectRoot, join60(sourceDir2, child));
34062
+ const sourcePath = posixRelative(projectRoot, join62(sourceDir2, child));
33338
34063
  const mapped = remapLocalPath(sourcePath, fromApm);
33339
34064
  if (!mapped) continue;
33340
34065
  putFile(files, mapped, readBytes(projectRoot, sourcePath), sourcePath);
33341
34066
  }
33342
34067
  }
33343
34068
  function collectLocalPrimitives(projectRoot, files, warnings) {
33344
- const apmDir = join60(projectRoot, ".apm");
33345
- const apmPresent = existsSync46(apmDir);
34069
+ const apmDir = join62(projectRoot, ".apm");
34070
+ const apmPresent = existsSync48(apmDir);
33346
34071
  if (apmPresent) {
33347
34072
  assertNotSymlink(apmDir, ".apm");
33348
34073
  for (const dir of PLUGIN_NATIVE_DIRS) {
33349
- collectDir(projectRoot, join60(".apm", dir), true, files);
34074
+ collectDir(projectRoot, join62(".apm", dir), true, files);
33350
34075
  }
33351
34076
  for (const dir of PLUGIN_NATIVE_DIRS) {
33352
- if (existsSync46(join60(projectRoot, dir))) {
34077
+ if (existsSync48(join62(projectRoot, dir))) {
33353
34078
  warnings.push(skippedRootSourceWarning(dir));
33354
34079
  }
33355
34080
  }
@@ -33362,8 +34087,8 @@ function collectLocalPrimitives(projectRoot, files, warnings) {
33362
34087
  function collectExplicitIncludes(projectRoot, includes, files) {
33363
34088
  for (const include of includes) {
33364
34089
  const relativePath2 = include.split("\\").join("/").replace(/^\.\//, "");
33365
- const absolute = join60(projectRoot, relativePath2);
33366
- if (!existsSync46(absolute)) {
34090
+ const absolute = join62(projectRoot, relativePath2);
34091
+ if (!existsSync48(absolute)) {
33367
34092
  throw new PackError(
33368
34093
  `includes path ${include} is missing and cannot be packed`
33369
34094
  );
@@ -33374,7 +34099,7 @@ function collectExplicitIncludes(projectRoot, includes, files) {
33374
34099
  const found = [];
33375
34100
  walkRegularFiles(absolute, absolute, found);
33376
34101
  for (const child of found) {
33377
- const sourcePath = posixRelative(projectRoot, join60(absolute, child));
34102
+ const sourcePath = posixRelative(projectRoot, join62(absolute, child));
33378
34103
  const mapped2 = remapDependencyPath(sourcePath) ?? sourcePath;
33379
34104
  putFile(files, mapped2, readBytes(projectRoot, sourcePath), sourcePath);
33380
34105
  }
@@ -33452,10 +34177,10 @@ function synthesizePluginManifest(config) {
33452
34177
  }
33453
34178
  function loadAuthoredPluginJson(projectRoot) {
33454
34179
  for (const relativePath2 of AUTHORED_PLUGIN_JSON_PATHS) {
33455
- const absolute = join60(projectRoot, relativePath2);
33456
- if (!existsSync46(absolute)) continue;
34180
+ const absolute = join62(projectRoot, relativePath2);
34181
+ if (!existsSync48(absolute)) continue;
33457
34182
  assertNotSymlink(absolute, relativePath2);
33458
- const bytes = readFileSync40(absolute);
34183
+ const bytes = readFileSync42(absolute);
33459
34184
  let parsed;
33460
34185
  try {
33461
34186
  parsed = JSON.parse(bytes.toString("utf8"));
@@ -33476,26 +34201,26 @@ function loadAuthoredPluginJson(projectRoot) {
33476
34201
  }
33477
34202
  function collectMcpJson(projectRoot, files) {
33478
34203
  for (const source of [".mcp.json", "mcp.json"]) {
33479
- const absolute = join60(projectRoot, source);
33480
- if (!existsSync46(absolute)) continue;
34204
+ const absolute = join62(projectRoot, source);
34205
+ if (!existsSync48(absolute)) continue;
33481
34206
  assertNotSymlink(absolute, source);
33482
- putFile(files, "mcp.json", readFileSync40(absolute), source);
34207
+ putFile(files, "mcp.json", readFileSync42(absolute), source);
33483
34208
  return;
33484
34209
  }
33485
34210
  }
33486
34211
  function lockDocument(projectRoot) {
33487
- const path = join60(projectRoot, APM_LOCKFILE_FILENAME);
33488
- if (!existsSync46(path)) return void 0;
34212
+ const path = join62(projectRoot, APM_LOCKFILE_FILENAME);
34213
+ if (!existsSync48(path)) return void 0;
33489
34214
  assertNotSymlink(path, APM_LOCKFILE_FILENAME);
33490
- const parsed = parseYaml4(readFileSync40(path, "utf8"));
34215
+ const parsed = parseYaml4(readFileSync42(path, "utf8"));
33491
34216
  if (!isRecord16(parsed)) {
33492
34217
  throw new PackError(`Invalid lockfile in ${path}: expected a YAML mapping`);
33493
34218
  }
33494
34219
  return parsed;
33495
34220
  }
33496
34221
  function collectAttestedDependencies(projectRoot, config, lock, files, warnings) {
33497
- const cacheDir = join60(projectRoot, APM_CACHE_DIR);
33498
- if (existsSync46(cacheDir)) {
34222
+ const cacheDir = join62(projectRoot, APM_CACHE_DIR);
34223
+ if (existsSync48(cacheDir)) {
33499
34224
  warnings.push(
33500
34225
  `${APM_CACHE_DIR}/ is never packed; dependency content is taken only from lockfile-attested deployed_files`
33501
34226
  );
@@ -33521,7 +34246,7 @@ function collectAttestedDependencies(projectRoot, config, lock, files, warnings)
33521
34246
  ])
33522
34247
  ) : {};
33523
34248
  if (deployedFiles.length === 0) {
33524
- if (existsSync46(cacheDir)) {
34249
+ if (existsSync48(cacheDir)) {
33525
34250
  throw new PackError(
33526
34251
  `Dependency ${dependency.name} has cached primitives but no deployed_files in ${APM_LOCKFILE_FILENAME}. Run ht apply so the content is attested.`
33527
34252
  );
@@ -33530,14 +34255,14 @@ function collectAttestedDependencies(projectRoot, config, lock, files, warnings)
33530
34255
  }
33531
34256
  for (const deployed of deployedFiles) {
33532
34257
  const relativePath2 = deployed.split("\\").join("/");
33533
- const absolute = join60(projectRoot, relativePath2);
33534
- if (!existsSync46(absolute)) {
34258
+ const absolute = join62(projectRoot, relativePath2);
34259
+ if (!existsSync48(absolute)) {
33535
34260
  throw new PackError(
33536
34261
  `Attested file ${relativePath2} from ${dependency.name} is missing. Run ht apply to restore it.`
33537
34262
  );
33538
34263
  }
33539
34264
  assertNotSymlink(absolute, relativePath2);
33540
- const bytes = readFileSync40(absolute);
34265
+ const bytes = readFileSync42(absolute);
33541
34266
  const expected = hashes[relativePath2];
33542
34267
  if (expected && normalizeSha256(expected) !== sha256Hex(bytes)) {
33543
34268
  throw new PackError(
@@ -33573,14 +34298,14 @@ function embedLockfile(lock, files) {
33573
34298
  putFile(files, PACK_LOCKFILE_NAME, Buffer.from(yaml, "utf8"));
33574
34299
  }
33575
34300
  function writeDirectory(targetDir, files) {
33576
- if (existsSync46(targetDir)) {
34301
+ if (existsSync48(targetDir)) {
33577
34302
  rmSync6(targetDir, { recursive: true, force: true });
33578
34303
  }
33579
- mkdirSync18(targetDir, { recursive: true });
34304
+ mkdirSync19(targetDir, { recursive: true });
33580
34305
  for (const file of files) {
33581
- const absolute = join60(targetDir, file.relativePath);
33582
- mkdirSync18(dirname14(absolute), { recursive: true });
33583
- writeFileSync18(absolute, file.bytes);
34306
+ const absolute = join62(targetDir, file.relativePath);
34307
+ mkdirSync19(dirname14(absolute), { recursive: true });
34308
+ writeFileSync19(absolute, file.bytes);
33584
34309
  }
33585
34310
  }
33586
34311
  function packProject(options = {}) {
@@ -33639,11 +34364,11 @@ function packProject(options = {}) {
33639
34364
  const name = manifest.name;
33640
34365
  const version = manifest.version;
33641
34366
  const outputRoot = resolve20(config.rootPath, options.outputDir ?? "build");
33642
- const outputPath = options.archive ? join60(outputRoot, `${name}-${version}.zip`) : join60(outputRoot, name);
34367
+ const outputPath = options.archive ? join62(outputRoot, `${name}-${version}.zip`) : join62(outputRoot, name);
33643
34368
  if (!options.dryRun) {
33644
- mkdirSync18(outputRoot, { recursive: true });
34369
+ mkdirSync19(outputRoot, { recursive: true });
33645
34370
  if (options.archive) {
33646
- writeFileSync18(
34371
+ writeFileSync19(
33647
34372
  outputPath,
33648
34373
  writeZipArchive(packed.map((file) => ({ path: file.relativePath, data: file.bytes })))
33649
34374
  );
@@ -33732,15 +34457,15 @@ function registerPackCommand(root) {
33732
34457
  import { resolve as resolve23 } from "path";
33733
34458
 
33734
34459
  // src/services/audit.ts
33735
- import { existsSync as existsSync48, lstatSync as lstatSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync20 } from "fs";
33736
- import { isAbsolute as isAbsolute6, join as join62, relative as relative10, resolve as resolve22 } from "path";
34460
+ import { existsSync as existsSync50, lstatSync as lstatSync9, readFileSync as readFileSync44, writeFileSync as writeFileSync21 } from "fs";
34461
+ import { isAbsolute as isAbsolute6, join as join64, relative as relative10, resolve as resolve22 } from "path";
33737
34462
 
33738
34463
  // src/services/executable-trust.ts
33739
34464
  init_settings();
33740
34465
  init_connection();
33741
34466
  init_plugin_model();
33742
- import { existsSync as existsSync47, mkdirSync as mkdirSync19, readFileSync as readFileSync41, writeFileSync as writeFileSync19 } from "fs";
33743
- import { join as join61 } from "path";
34467
+ import { existsSync as existsSync49, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync20 } from "fs";
34468
+ import { join as join63 } from "path";
33744
34469
  import { parse as parseYaml5, stringify as stringifyYaml4 } from "yaml";
33745
34470
  init_resource_resolution();
33746
34471
  var APM_MANIFEST_FILENAME2 = "apm.yml";
@@ -33836,20 +34561,20 @@ function emptyGrantMap() {
33836
34561
  return { allow: {}, deny: {} };
33837
34562
  }
33838
34563
  function userConfigPath(harnesstapDir) {
33839
- const jsoncPath = join61(harnesstapDir, "config.jsonc");
33840
- const jsonPath = join61(harnesstapDir, "config.json");
33841
- if (existsSync47(jsoncPath) || !existsSync47(jsonPath)) {
34564
+ const jsoncPath = join63(harnesstapDir, "config.jsonc");
34565
+ const jsonPath = join63(harnesstapDir, "config.json");
34566
+ if (existsSync49(jsoncPath) || !existsSync49(jsonPath)) {
33842
34567
  return jsoncPath;
33843
34568
  }
33844
34569
  return jsonPath;
33845
34570
  }
33846
34571
  function loadUserExecutables(harnesstapDir = getHarnesstapDir()) {
33847
34572
  const path = userConfigPath(harnesstapDir);
33848
- if (!existsSync47(path)) {
34573
+ if (!existsSync49(path)) {
33849
34574
  return emptyGrantMap();
33850
34575
  }
33851
34576
  try {
33852
- const parsed = parseJsonc(readFileSync41(path, "utf8"));
34577
+ const parsed = parseJsonc(readFileSync43(path, "utf8"));
33853
34578
  if (!isRecord17(parsed)) {
33854
34579
  return emptyGrantMap();
33855
34580
  }
@@ -33859,11 +34584,11 @@ function loadUserExecutables(harnesstapDir = getHarnesstapDir()) {
33859
34584
  }
33860
34585
  }
33861
34586
  function loadProjectExecutables(projectRoot) {
33862
- const manifestPath = join61(projectRoot, APM_MANIFEST_FILENAME2);
33863
- if (!existsSync47(manifestPath)) {
34587
+ const manifestPath = join63(projectRoot, APM_MANIFEST_FILENAME2);
34588
+ if (!existsSync49(manifestPath)) {
33864
34589
  return { present: false, allow: {}, deny: {} };
33865
34590
  }
33866
- const parsed = parseYaml5(readFileSync41(manifestPath, "utf8"));
34591
+ const parsed = parseYaml5(readFileSync43(manifestPath, "utf8"));
33867
34592
  if (!isRecord17(parsed)) {
33868
34593
  return { present: false, allow: {}, deny: {} };
33869
34594
  }
@@ -34028,7 +34753,7 @@ function pluginHasBinDirectory(pluginId) {
34028
34753
  }
34029
34754
  try {
34030
34755
  if (locator.startsWith("/") || locator.startsWith("./") || locator.startsWith("../")) {
34031
- return existsSync47(join61(locator, "bin"));
34756
+ return existsSync49(join63(locator, "bin"));
34032
34757
  }
34033
34758
  } catch {
34034
34759
  return false;
@@ -34134,17 +34859,17 @@ function formatApproveRemedy(refs) {
34134
34859
  return `ht approve ${refs.join(" ")}`;
34135
34860
  }
34136
34861
  function readYamlMapping(filePath) {
34137
- if (!existsSync47(filePath)) {
34862
+ if (!existsSync49(filePath)) {
34138
34863
  throw new Error(`Missing ${filePath}`);
34139
34864
  }
34140
- const parsed = parseYaml5(readFileSync41(filePath, "utf8"));
34865
+ const parsed = parseYaml5(readFileSync43(filePath, "utf8"));
34141
34866
  if (!isRecord17(parsed)) {
34142
34867
  throw new Error(`${filePath} must be a YAML mapping`);
34143
34868
  }
34144
34869
  return parsed;
34145
34870
  }
34146
34871
  function writeYamlMapping(filePath, document) {
34147
- writeFileSync19(
34872
+ writeFileSync20(
34148
34873
  filePath,
34149
34874
  stringifyYaml4(document, {
34150
34875
  indent: 2,
@@ -34166,8 +34891,8 @@ function mergeGrantFlags(existing, types) {
34166
34891
  return next;
34167
34892
  }
34168
34893
  function writeProjectExecutableGrant(options) {
34169
- const manifestPath = join61(options.projectRoot, APM_MANIFEST_FILENAME2);
34170
- const document = existsSync47(manifestPath) ? readYamlMapping(manifestPath) : { name: "project", version: "1.0.0" };
34894
+ const manifestPath = join63(options.projectRoot, APM_MANIFEST_FILENAME2);
34895
+ const document = existsSync49(manifestPath) ? readYamlMapping(manifestPath) : { name: "project", version: "1.0.0" };
34171
34896
  const executablesRaw = document.executables;
34172
34897
  const current = isRecord17(executablesRaw) ? { ...executablesRaw } : {};
34173
34898
  const sideRaw = current[options.side];
@@ -34187,11 +34912,11 @@ function writeProjectExecutableGrant(options) {
34187
34912
  }
34188
34913
  function readUserConfigObject(harnesstapDir) {
34189
34914
  const path = userConfigPath(harnesstapDir);
34190
- if (!existsSync47(path)) {
34915
+ if (!existsSync49(path)) {
34191
34916
  return {};
34192
34917
  }
34193
34918
  try {
34194
- const parsed = parseJsonc(readFileSync41(path, "utf8"));
34919
+ const parsed = parseJsonc(readFileSync43(path, "utf8"));
34195
34920
  return isRecord17(parsed) ? parsed : {};
34196
34921
  } catch {
34197
34922
  return {};
@@ -34215,8 +34940,8 @@ function writeUserExecutableGrant(options) {
34215
34940
  ...current,
34216
34941
  [options.side]: side2
34217
34942
  };
34218
- mkdirSync19(dir, { recursive: true });
34219
- writeFileSync19(userConfigPath(dir), `${JSON.stringify(document, null, 2)}
34943
+ mkdirSync20(dir, { recursive: true });
34944
+ writeFileSync20(userConfigPath(dir), `${JSON.stringify(document, null, 2)}
34220
34945
  `, "utf8");
34221
34946
  }
34222
34947
  function installedTrustReports(context, options) {
@@ -34312,17 +35037,17 @@ function collectLockfileTargets(projectRoot) {
34312
35037
  function collectSourceTargets(projectRoot) {
34313
35038
  const files = [];
34314
35039
  for (const dir of SOURCE_DIRS) {
34315
- const absolute = join62(projectRoot, dir);
34316
- if (!existsSync48(absolute)) continue;
35040
+ const absolute = join64(projectRoot, dir);
35041
+ if (!existsSync50(absolute)) continue;
34317
35042
  if (lstatSync9(absolute).isSymbolicLink()) {
34318
35043
  throw new PathEscapeError(dir, projectRoot);
34319
35044
  }
34320
35045
  for (const child of listContainedFiles(absolute)) {
34321
- files.push(toPosix2(join62(dir, child)));
35046
+ files.push(toPosix2(join64(dir, child)));
34322
35047
  }
34323
35048
  }
34324
35049
  for (const name of ROOT_CONTEXT_FILES) {
34325
- if (existsSync48(join62(projectRoot, name))) {
35050
+ if (existsSync50(join64(projectRoot, name))) {
34326
35051
  files.push(name);
34327
35052
  }
34328
35053
  }
@@ -34332,7 +35057,7 @@ function resolveFileTarget(projectRoot, file) {
34332
35057
  const resolved = isAbsolute6(file) ? resolve22(file) : resolve22(projectRoot, file);
34333
35058
  const rel = toPosix2(relative10(projectRoot, resolved));
34334
35059
  assertContainedPath(projectRoot, rel);
34335
- if (!existsSync48(resolved)) {
35060
+ if (!existsSync50(resolved)) {
34336
35061
  throw new AuditUsageError(`File not found: ${file}`);
34337
35062
  }
34338
35063
  return rel;
@@ -34342,20 +35067,20 @@ function uniqueSorted3(paths) {
34342
35067
  }
34343
35068
  function scanRelativeFile(projectRoot, relativePath2) {
34344
35069
  assertContainedPath(projectRoot, relativePath2);
34345
- const absolute = join62(projectRoot, relativePath2);
34346
- if (!existsSync48(absolute)) return [];
35070
+ const absolute = join64(projectRoot, relativePath2);
35071
+ if (!existsSync50(absolute)) return [];
34347
35072
  if (lstatSync9(absolute).isSymbolicLink()) {
34348
35073
  throw new PathEscapeError(relativePath2, projectRoot);
34349
35074
  }
34350
- return scanUnicodeBuffer(readFileSync42(absolute), relativePath2);
35075
+ return scanUnicodeBuffer(readFileSync44(absolute), relativePath2);
34351
35076
  }
34352
35077
  function readRelativeText(projectRoot, relativePath2) {
34353
- const absolute = join62(projectRoot, relativePath2);
34354
- if (!existsSync48(absolute)) return void 0;
35078
+ const absolute = join64(projectRoot, relativePath2);
35079
+ if (!existsSync50(absolute)) return void 0;
34355
35080
  if (lstatSync9(absolute).isSymbolicLink()) {
34356
35081
  throw new PathEscapeError(relativePath2, projectRoot);
34357
35082
  }
34358
- return readFileSync42(absolute, "utf8");
35083
+ return readFileSync44(absolute, "utf8");
34359
35084
  }
34360
35085
  function integrityForLock(projectRoot) {
34361
35086
  const lock = readLockfile(projectRoot);
@@ -34476,7 +35201,7 @@ function auditProject(options = {}) {
34476
35201
  const projectRoot = resolve22(options.projectRoot ?? process.cwd());
34477
35202
  const scannedFiles = options.file ? [resolveFileTarget(projectRoot, options.file)] : uniqueSorted3([
34478
35203
  ...collectLockfileTargets(projectRoot).filter(
34479
- (relativePath2) => existsSync48(join62(projectRoot, relativePath2))
35204
+ (relativePath2) => existsSync50(join64(projectRoot, relativePath2))
34480
35205
  ),
34481
35206
  ...collectSourceTargets(projectRoot)
34482
35207
  ]);
@@ -34495,7 +35220,7 @@ function auditProject(options = {}) {
34495
35220
  if (result.removed === 0) continue;
34496
35221
  stripped.push({ path: relativePath2, removed: result.removed });
34497
35222
  if (!options.dryRun) {
34498
- writeFileSync20(join62(projectRoot, relativePath2), result.text, "utf8");
35223
+ writeFileSync21(join64(projectRoot, relativePath2), result.text, "utf8");
34499
35224
  }
34500
35225
  }
34501
35226
  }
@@ -34656,7 +35381,7 @@ function registerAuditCommand(root) {
34656
35381
 
34657
35382
  // src/cli/commands/plugin.ts
34658
35383
  import { Option as Option2 } from "commander";
34659
- import { readFileSync as readFileSync51 } from "fs";
35384
+ import { readFileSync as readFileSync53 } from "fs";
34660
35385
  import { resolve as resolve32 } from "path";
34661
35386
 
34662
35387
  // src/cli/formatting.ts
@@ -34729,8 +35454,8 @@ init_connection();
34729
35454
  // src/services/plugin-origin-update.ts
34730
35455
  init_connection();
34731
35456
  init_plugin_model();
34732
- import { existsSync as existsSync50 } from "fs";
34733
- import { join as join64 } from "path";
35457
+ import { existsSync as existsSync52 } from "fs";
35458
+ import { join as join66 } from "path";
34734
35459
  init_plugin_dependency();
34735
35460
 
34736
35461
  // src/services/plugin-origin-apply.ts
@@ -34739,32 +35464,32 @@ init_plugin_model();
34739
35464
  init_resource();
34740
35465
  init_types();
34741
35466
  import { createHash as createHash8 } from "crypto";
34742
- import { existsSync as existsSync49, readdirSync as readdirSync19, statSync as statSync13 } from "fs";
34743
- import { join as join63 } from "path";
35467
+ import { existsSync as existsSync51, readdirSync as readdirSync19, statSync as statSync13 } from "fs";
35468
+ import { join as join65 } from "path";
34744
35469
  init_plugin_dependency();
34745
35470
  init_plugin_source_import();
34746
35471
  var MATERIAL_TYPES = new Set(MATERIAL_RESOURCE_TYPES);
34747
35472
  function isDirectory7(path) {
34748
- return existsSync49(path) && statSync13(path).isDirectory();
35473
+ return existsSync51(path) && statSync13(path).isDirectory();
34749
35474
  }
34750
35475
  function resolveMarketplacePluginDirectory(cacheDir, pluginName) {
34751
- const underPlugins = join63(cacheDir, "plugins", pluginName);
35476
+ const underPlugins = join65(cacheDir, "plugins", pluginName);
34752
35477
  if (isDirectory7(underPlugins)) return underPlugins;
34753
- const atRoot = join63(cacheDir, pluginName);
35478
+ const atRoot = join65(cacheDir, pluginName);
34754
35479
  if (isDirectory7(atRoot)) return atRoot;
34755
35480
  if (!isDirectory7(cacheDir)) return void 0;
34756
35481
  for (const entry of readdirSync19(cacheDir, { withFileTypes: true })) {
34757
35482
  if (!entry.isDirectory() || entry.name === ".git") {
34758
35483
  continue;
34759
35484
  }
34760
- const nested = join63(cacheDir, entry.name, pluginName);
35485
+ const nested = join65(cacheDir, entry.name, pluginName);
34761
35486
  if (isDirectory7(nested)) return nested;
34762
35487
  }
34763
35488
  return void 0;
34764
35489
  }
34765
35490
  function gitOriginCacheDir(harnesstapDir, url) {
34766
35491
  const digest = createHash8("sha256").update(url, "utf8").digest("hex");
34767
- return join63(harnesstapDir, "cache", "git-origins", digest);
35492
+ return join65(harnesstapDir, "cache", "git-origins", digest);
34768
35493
  }
34769
35494
  function originPluginLookupName(plugin, locator) {
34770
35495
  switch (locator.kind) {
@@ -34993,12 +35718,12 @@ function originTreeSignature(resources) {
34993
35718
  }
34994
35719
  async function scanOriginTree(sourcePath, pluginName) {
34995
35720
  const manifestCandidates = [
34996
- join64(sourcePath, ".claude-plugin", "marketplace.json"),
34997
- join64(sourcePath, ".cursor-plugin", "marketplace.json"),
34998
- join64(sourcePath, "marketplace.json")
35721
+ join66(sourcePath, ".claude-plugin", "marketplace.json"),
35722
+ join66(sourcePath, ".cursor-plugin", "marketplace.json"),
35723
+ join66(sourcePath, "marketplace.json")
34999
35724
  ];
35000
35725
  for (const manifestPath of manifestCandidates) {
35001
- if (!existsSync50(manifestPath)) continue;
35726
+ if (!existsSync52(manifestPath)) continue;
35002
35727
  try {
35003
35728
  const scans = await scanPluginSource(manifestPath);
35004
35729
  return scans.find((scan) => scan.plugin_name === pluginName) ?? scans[0];
@@ -35633,13 +36358,13 @@ init_connection();
35633
36358
  init_plugin_selector();
35634
36359
 
35635
36360
  // src/services/plugin-source.ts
35636
- import { mkdtempSync, writeFileSync as writeFileSync21 } from "fs";
36361
+ import { mkdtempSync, writeFileSync as writeFileSync22 } from "fs";
35637
36362
  import { tmpdir } from "os";
35638
- import { join as join66 } from "path";
36363
+ import { join as join68 } from "path";
35639
36364
 
35640
36365
  // src/services/apm-bundle.ts
35641
- import { existsSync as existsSync51, lstatSync as lstatSync10, readFileSync as readFileSync43, statSync as statSync14 } from "fs";
35642
- import { join as join65, resolve as resolve24 } from "path";
36366
+ import { existsSync as existsSync53, lstatSync as lstatSync10, readFileSync as readFileSync45, statSync as statSync14 } from "fs";
36367
+ import { join as join67, resolve as resolve24 } from "path";
35643
36368
  import { parse as parseYaml6 } from "yaml";
35644
36369
 
35645
36370
  // src/services/legacy-toml-transport.ts
@@ -35725,12 +36450,12 @@ function filesFromDirectory(packageDir) {
35725
36450
  }
35726
36451
  const files = {};
35727
36452
  for (const relativePath2 of listContainedRegularFiles(packageDir).sort()) {
35728
- files[relativePath2] = readFileSync43(join65(packageDir, relativePath2));
36453
+ files[relativePath2] = readFileSync45(join67(packageDir, relativePath2));
35729
36454
  }
35730
36455
  return files;
35731
36456
  }
35732
36457
  function filesFromZip(archivePath) {
35733
- const members = readZipArchive(readFileSync43(archivePath));
36458
+ const members = readZipArchive(readFileSync45(archivePath));
35734
36459
  const files = {};
35735
36460
  for (const member of members) {
35736
36461
  files[member.path] = member.data;
@@ -35763,7 +36488,7 @@ function looksLikeFilesystemPath(source) {
35763
36488
  function isPluginPackageDirectory(source) {
35764
36489
  try {
35765
36490
  const resolved = resolve24(source);
35766
- return existsSync51(resolved) && statSync14(resolved).isDirectory() && existsSync51(join65(resolved, "plugin.json"));
36491
+ return existsSync53(resolved) && statSync14(resolved).isDirectory() && existsSync53(join67(resolved, "plugin.json"));
35767
36492
  } catch {
35768
36493
  return false;
35769
36494
  }
@@ -35783,8 +36508,8 @@ function loadVerifiedPackageFiles(filePath) {
35783
36508
  verifyPackedBundleBytes(files);
35784
36509
  return toPackageFiles(files);
35785
36510
  }
35786
- if (existsSync51(resolved) && statSync14(resolved).isDirectory()) {
35787
- if (!existsSync51(join65(resolved, "plugin.json"))) {
36511
+ if (existsSync53(resolved) && statSync14(resolved).isDirectory()) {
36512
+ if (!existsSync53(join67(resolved, "plugin.json"))) {
35788
36513
  throw new Error(
35789
36514
  `${resolved} is a directory but has no plugin.json \u2014 expected an Agent Plugins package.`
35790
36515
  );
@@ -35810,9 +36535,9 @@ function isPluginExportFilePath(source) {
35810
36535
  return looksLikeFilesystemPath(source) && isPluginPackageDirectory(source);
35811
36536
  }
35812
36537
  function writePluginExportToTempFile(body) {
35813
- const dir = mkdtempSync(join66(tmpdir(), "harnesstap-plugin-export-"));
35814
- const filePath = join66(dir, "remote.ap.json");
35815
- writeFileSync21(filePath, body, "utf-8");
36538
+ const dir = mkdtempSync(join68(tmpdir(), "harnesstap-plugin-export-"));
36539
+ const filePath = join68(dir, "remote.ap.json");
36540
+ writeFileSync22(filePath, body, "utf-8");
35816
36541
  return filePath;
35817
36542
  }
35818
36543
  async function fetchPluginExportToTempFile(url) {
@@ -36982,13 +37707,13 @@ function resolveProjectCompileTargets(input) {
36982
37707
 
36983
37708
  // src/services/plugin-editor.ts
36984
37709
  init_connection();
36985
- import { mkdirSync as mkdirSync20 } from "fs";
36986
- import { dirname as dirname15, join as join67 } from "path";
37710
+ import { mkdirSync as mkdirSync21 } from "fs";
37711
+ import { dirname as dirname15, join as join69 } from "path";
36987
37712
 
36988
37713
  // src/services/plugin-export.ts
36989
37714
  init_plugin_model();
36990
37715
  init_plugin_versioning();
36991
- import { existsSync as existsSync52, statSync as statSync15 } from "fs";
37716
+ import { existsSync as existsSync54, statSync as statSync15 } from "fs";
36992
37717
  import { basename as basename8, resolve as resolve26 } from "path";
36993
37718
  init_name();
36994
37719
  function exportPlugin(pluginNameOrId, exportOpts) {
@@ -37014,7 +37739,7 @@ function exportToFile(pluginNameOrId, filePath, exportOpts) {
37014
37739
  writeApEnvelope(files, target);
37015
37740
  return;
37016
37741
  }
37017
- if (existsSync52(target) && statSync15(target).isFile()) {
37742
+ if (existsSync54(target) && statSync15(target).isFile()) {
37018
37743
  throw new Error(
37019
37744
  `Refusing to overwrite file ${target} with a package directory. Pass --single-file or a .ap.json path.`
37020
37745
  );
@@ -37025,7 +37750,7 @@ function exportToFile(pluginNameOrId, filePath, exportOpts) {
37025
37750
  // src/services/plugin-editor.ts
37026
37751
  init_name();
37027
37752
  function resolvePluginDefinitionPath(plugin) {
37028
- return join67(
37753
+ return join69(
37029
37754
  getHarnesstapDir(),
37030
37755
  "plugins",
37031
37756
  `${slugifyApName(plugin.name)}@${plugin.version}.ap.json`
@@ -37033,7 +37758,7 @@ function resolvePluginDefinitionPath(plugin) {
37033
37758
  }
37034
37759
  function exportPluginDefinition(plugin, filePath) {
37035
37760
  const definitionPath = filePath ?? resolvePluginDefinitionPath(plugin);
37036
- mkdirSync20(dirname15(definitionPath), { recursive: true });
37761
+ mkdirSync21(dirname15(definitionPath), { recursive: true });
37037
37762
  exportToFile(plugin.id, definitionPath, { singleFile: true });
37038
37763
  return definitionPath;
37039
37764
  }
@@ -38900,8 +39625,8 @@ init_claude_plugin_ref();
38900
39625
  // src/services/plugin-diff.ts
38901
39626
  init_plugin_model();
38902
39627
  init_plugin_dependency();
38903
- import { existsSync as existsSync53, statSync as statSync16 } from "fs";
38904
- import { join as join68 } from "path";
39628
+ import { existsSync as existsSync55, statSync as statSync16 } from "fs";
39629
+ import { join as join70 } from "path";
38905
39630
  function resourceKey5(resource) {
38906
39631
  if (resource.namespace) {
38907
39632
  return `${resource.type}:${resource.name}@${resource.namespace}`;
@@ -38913,8 +39638,8 @@ function isPackagePath(nameOrPath) {
38913
39638
  return true;
38914
39639
  }
38915
39640
  try {
38916
- if (existsSync53(nameOrPath) && statSync16(nameOrPath).isDirectory()) {
38917
- return existsSync53(join68(nameOrPath, "plugin.json"));
39641
+ if (existsSync55(nameOrPath) && statSync16(nameOrPath).isDirectory()) {
39642
+ return existsSync55(join70(nameOrPath, "plugin.json"));
38918
39643
  }
38919
39644
  } catch {
38920
39645
  return false;
@@ -39667,16 +40392,16 @@ init_resource();
39667
40392
  // src/services/apm-graph.ts
39668
40393
  init_connection();
39669
40394
  init_plugin_model();
39670
- import { existsSync as existsSync56, lstatSync as lstatSync13 } from "fs";
40395
+ import { existsSync as existsSync58, lstatSync as lstatSync13 } from "fs";
39671
40396
  import { homedir as homedir4 } from "os";
39672
- import { isAbsolute as isAbsolute7, join as join71, resolve as resolve28 } from "path";
40397
+ import { isAbsolute as isAbsolute7, join as join73, resolve as resolve28 } from "path";
39673
40398
 
39674
40399
  // src/services/apm-git-import.ts
39675
40400
  init_plugin_model();
39676
40401
  init_resource();
39677
- import { existsSync as existsSync54, lstatSync as lstatSync11, readdirSync as readdirSync20, readFileSync as readFileSync44 } from "fs";
39678
- import { basename as basename10, join as join69 } from "path";
39679
- import matter9 from "gray-matter";
40402
+ import { existsSync as existsSync56, lstatSync as lstatSync11, readdirSync as readdirSync20, readFileSync as readFileSync46 } from "fs";
40403
+ import { basename as basename10, join as join71 } from "path";
40404
+ import matter10 from "gray-matter";
39680
40405
  init_plugin_origin();
39681
40406
  init_plugin_source_import();
39682
40407
  init_scanner();
@@ -39691,13 +40416,13 @@ function virtualFileType(path) {
39691
40416
  }
39692
40417
  function importVirtualFile(checkoutRoot, relativePath2) {
39693
40418
  const absolute = assertCheckoutPathSafe(checkoutRoot, relativePath2);
39694
- if (!existsSync54(absolute) || !lstatSync11(absolute).isFile()) {
40419
+ if (!existsSync56(absolute) || !lstatSync11(absolute).isFile()) {
39695
40420
  throw new ApmGitResolveError(
39696
40421
  `Virtual package file ${relativePath2} is missing \u2014 apply aborted closed`
39697
40422
  );
39698
40423
  }
39699
- const raw = readFileSync44(absolute, "utf8");
39700
- const parsed = matter9(raw);
40424
+ const raw = readFileSync46(absolute, "utf8");
40425
+ const parsed = matter10(raw);
39701
40426
  const data = isRecord19(parsed.data) ? parsed.data : {};
39702
40427
  const fallback = basename10(relativePath2).replace(/\.(agent|prompt|instructions)\.md$/i, "");
39703
40428
  const name = typeof data.name === "string" && data.name.trim().length > 0 ? data.name.trim() : fallback;
@@ -39732,7 +40457,7 @@ function assertPackageRootSafe(packageRoot) {
39732
40457
  if (entry.name === ".git") {
39733
40458
  continue;
39734
40459
  }
39735
- const child = join69(packageRoot, entry.name);
40460
+ const child = join71(packageRoot, entry.name);
39736
40461
  if (entry.isSymbolicLink() || lstatSync11(child).isSymbolicLink()) {
39737
40462
  throw new BundleSymlinkError(entry.name);
39738
40463
  }
@@ -39746,10 +40471,10 @@ function assertPackageRootSafe(packageRoot) {
39746
40471
  }
39747
40472
  }
39748
40473
  function peekApmPackageIdentity(packageRoot) {
39749
- const pluginJson = join69(packageRoot, ".claude-plugin", "plugin.json");
39750
- if (existsSync54(pluginJson) && lstatSync11(pluginJson).isFile()) {
40474
+ const pluginJson = join71(packageRoot, ".claude-plugin", "plugin.json");
40475
+ if (existsSync56(pluginJson) && lstatSync11(pluginJson).isFile()) {
39751
40476
  try {
39752
- const parsed = JSON.parse(readFileSync44(pluginJson, "utf8"));
40477
+ const parsed = JSON.parse(readFileSync46(pluginJson, "utf8"));
39753
40478
  if (isRecord19(parsed)) {
39754
40479
  return {
39755
40480
  ...typeof parsed.name === "string" && parsed.name.trim() ? { name: parsed.name.trim() } : {},
@@ -39759,11 +40484,11 @@ function peekApmPackageIdentity(packageRoot) {
39759
40484
  } catch {
39760
40485
  }
39761
40486
  }
39762
- const manifestPath = join69(packageRoot, APM_MANIFEST_FILENAME);
39763
- if (!existsSync54(manifestPath) || !lstatSync11(manifestPath).isFile()) {
40487
+ const manifestPath = join71(packageRoot, APM_MANIFEST_FILENAME);
40488
+ if (!existsSync56(manifestPath) || !lstatSync11(manifestPath).isFile()) {
39764
40489
  return {};
39765
40490
  }
39766
- const document = parseApmYamlDocument(readFileSync44(manifestPath, "utf8"), manifestPath);
40491
+ const document = parseApmYamlDocument(readFileSync46(manifestPath, "utf8"), manifestPath);
39767
40492
  return {
39768
40493
  ...typeof document.name === "string" && document.name.trim() ? { name: document.name.trim() } : {},
39769
40494
  ...typeof document.version === "string" && document.version.trim() ? { version: document.version.trim() } : {}
@@ -39866,7 +40591,7 @@ async function importApmGitCheckout(resolution, checkoutRoot, options = {}) {
39866
40591
  return upsertGitPlugin(resolution, [file], resolution.name, resolution.commit.slice(0, 12));
39867
40592
  }
39868
40593
  const packageRoot = gitCheckoutPackageRoot(resolution, checkoutRoot);
39869
- if (!existsSync54(packageRoot)) {
40594
+ if (!existsSync56(packageRoot)) {
39870
40595
  throw new ApmGitResolveError(
39871
40596
  `Virtual package path ${resolution.virtualPath ?? "."} is missing \u2014 apply aborted closed`
39872
40597
  );
@@ -39883,7 +40608,7 @@ async function importApmGitCheckout(resolution, checkoutRoot, options = {}) {
39883
40608
  return upsertGitPlugin(resolution, imported.resources, name, version);
39884
40609
  }
39885
40610
  async function importApmLocalPackage(packageRoot, fallbackName, originRef2, options = {}) {
39886
- if (!existsSync54(packageRoot) || !lstatSync11(packageRoot).isDirectory()) {
40611
+ if (!existsSync56(packageRoot) || !lstatSync11(packageRoot).isDirectory()) {
39887
40612
  throw new ApmGitResolveError(
39888
40613
  `APM package path ${originRef2} is missing \u2014 apply aborted closed`
39889
40614
  );
@@ -39919,8 +40644,8 @@ async function importApmLocalPackage(packageRoot, fallbackName, originRef2, opti
39919
40644
  }
39920
40645
 
39921
40646
  // src/services/export/license.ts
39922
- import { existsSync as existsSync55, lstatSync as lstatSync12, readFileSync as readFileSync45 } from "fs";
39923
- import { dirname as dirname16, join as join70 } from "path";
40647
+ import { existsSync as existsSync57, lstatSync as lstatSync12, readFileSync as readFileSync47 } from "fs";
40648
+ import { dirname as dirname16, join as join72 } from "path";
39924
40649
  import { parse as parseYaml7 } from "yaml";
39925
40650
 
39926
40651
  // src/services/export/spdx-ids.ts
@@ -40052,7 +40777,7 @@ function cleanLicense(value) {
40052
40777
  }
40053
40778
  function fromApmYml(path) {
40054
40779
  try {
40055
- const parsed = parseYaml7(readFileSync45(path, "utf8"));
40780
+ const parsed = parseYaml7(readFileSync47(path, "utf8"));
40056
40781
  if (!isRecord20(parsed)) {
40057
40782
  return void 0;
40058
40783
  }
@@ -40063,7 +40788,7 @@ function fromApmYml(path) {
40063
40788
  }
40064
40789
  function fromPluginJson(path) {
40065
40790
  try {
40066
- const parsed = JSON.parse(readFileSync45(path, "utf8"));
40791
+ const parsed = JSON.parse(readFileSync47(path, "utf8"));
40067
40792
  if (!isRecord20(parsed)) {
40068
40793
  return void 0;
40069
40794
  }
@@ -40081,15 +40806,15 @@ function manifestSearchRoot(installPath) {
40081
40806
  }
40082
40807
  function readDeclaredLicense(installPath) {
40083
40808
  const base = manifestSearchRoot(installPath);
40084
- const apmYml = join70(base, "apm.yml");
40085
- if (existsSync55(apmYml)) {
40809
+ const apmYml = join72(base, "apm.yml");
40810
+ if (existsSync57(apmYml)) {
40086
40811
  const declared = fromApmYml(apmYml);
40087
40812
  if (declared !== void 0) {
40088
40813
  return declared;
40089
40814
  }
40090
40815
  }
40091
- const pluginJson = join70(base, "plugin.json");
40092
- if (existsSync55(pluginJson)) {
40816
+ const pluginJson = join72(base, "plugin.json");
40817
+ if (existsSync57(pluginJson)) {
40093
40818
  return fromPluginJson(pluginJson);
40094
40819
  }
40095
40820
  return void 0;
@@ -40225,7 +40950,7 @@ function apmDependencyIdentity(dependency, declaringRoot) {
40225
40950
  }
40226
40951
  function expandHome(originRef2) {
40227
40952
  if (originRef2.startsWith("~/") || originRef2.startsWith("~\\")) {
40228
- return join71(homedir4(), originRef2.slice(2));
40953
+ return join73(homedir4(), originRef2.slice(2));
40229
40954
  }
40230
40955
  return originRef2;
40231
40956
  }
@@ -40250,7 +40975,7 @@ function linkParent(parentPluginId, imported) {
40250
40975
  });
40251
40976
  }
40252
40977
  function pushGitLock(gitLocks, pluginName, fetched) {
40253
- const licenseRoot = fetched.virtualPath ? join71(fetched.checkoutRoot, fetched.virtualPath) : fetched.checkoutRoot;
40978
+ const licenseRoot = fetched.virtualPath ? join73(fetched.checkoutRoot, fetched.virtualPath) : fetched.checkoutRoot;
40254
40979
  const declared_license = readDeclaredLicense(licenseRoot);
40255
40980
  gitLocks.push({
40256
40981
  name: pluginName,
@@ -40364,7 +41089,7 @@ async function visitGit(frame, identity, state) {
40364
41089
  fetched.virtualPath && isApmVirtualFilePath(fetched.virtualPath)
40365
41090
  );
40366
41091
  const packageRoot = virtualFile ? void 0 : gitCheckoutPackageRoot(fetched, fetched.checkoutRoot);
40367
- if (packageRoot && (!existsSync56(packageRoot) || !lstatSync13(packageRoot).isDirectory())) {
41092
+ if (packageRoot && (!existsSync58(packageRoot) || !lstatSync13(packageRoot).isDirectory())) {
40368
41093
  failClosedMissing(frame.dependency.originRef);
40369
41094
  }
40370
41095
  const peeked = packageRoot ? peekApmPackageIdentity(packageRoot) : {};
@@ -40408,7 +41133,7 @@ async function visitLocal(frame, identity, state) {
40408
41133
  return;
40409
41134
  }
40410
41135
  const packageRoot = resolveFilesystemPackageRoot(frame.declaringRoot, frame.dependency);
40411
- if (!existsSync56(packageRoot) || !lstatSync13(packageRoot).isDirectory()) {
41136
+ if (!existsSync58(packageRoot) || !lstatSync13(packageRoot).isDirectory()) {
40412
41137
  failClosedMissing(frame.dependency.originRef);
40413
41138
  }
40414
41139
  if (lstatSync13(packageRoot).isSymbolicLink()) {
@@ -40982,7 +41707,7 @@ init_plugin_model();
40982
41707
  init_resource();
40983
41708
 
40984
41709
  // src/services/environment-import-export.ts
40985
- import { readFileSync as readFileSync46 } from "fs";
41710
+ import { readFileSync as readFileSync48 } from "fs";
40986
41711
  import { parse as parse8 } from "smol-toml";
40987
41712
  init_write();
40988
41713
 
@@ -41107,18 +41832,17 @@ function formatEnvironmentToml(document) {
41107
41832
  }
41108
41833
 
41109
41834
  // src/services/global-profile-drift.ts
41110
- import { existsSync as existsSync57, readFileSync as readFileSync47 } from "fs";
41111
- import { join as join72 } from "path";
41835
+ import { existsSync as existsSync59, readFileSync as readFileSync49 } from "fs";
41836
+ import { join as join74 } from "path";
41112
41837
  init_plugin_model();
41113
41838
  init_home_root();
41114
- init_mcp_config_bridge();
41115
41839
  function readGlobalFile(homeRoot, relativePath2) {
41116
- const fullPath = join72(homeRoot, relativePath2);
41117
- if (!existsSync57(fullPath)) {
41840
+ const fullPath = join74(homeRoot, relativePath2);
41841
+ if (!existsSync59(fullPath)) {
41118
41842
  return null;
41119
41843
  }
41120
41844
  try {
41121
- return readFileSync47(fullPath, "utf-8");
41845
+ return readFileSync49(fullPath, "utf-8");
41122
41846
  } catch {
41123
41847
  return null;
41124
41848
  }
@@ -41129,31 +41853,11 @@ function pluginIdsMatch(left, right) {
41129
41853
  }
41130
41854
  return left.every((pluginId, index) => pluginId === right[index]);
41131
41855
  }
41132
- function declaredMcpNamesFromExpectedApply2(expectedApply) {
41133
- const byHarness = {};
41134
- for (const harnessId of expectedApply.harnesses) {
41135
- const mcpPaths = /* @__PURE__ */ new Set();
41136
- if (harnessId === "cursor") {
41137
- mcpPaths.add(".cursor/mcp.json");
41138
- } else if (harnessId === "claude-code") {
41139
- mcpPaths.add(".mcp.json");
41140
- }
41141
- const names = /* @__PURE__ */ new Set();
41142
- for (const file of expectedApply.expected_files ?? []) {
41143
- if (!mcpPaths.has(file.path)) {
41144
- continue;
41145
- }
41146
- try {
41147
- const document = JSON.parse(file.content);
41148
- for (const name of Object.keys(parseMcpServersDocument(document))) {
41149
- names.add(name);
41150
- }
41151
- } catch {
41152
- }
41153
- }
41154
- byHarness[harnessId] = [...names];
41155
- }
41156
- return byHarness;
41856
+ function declaredMcpFromExpectedApply2(expectedApply) {
41857
+ return declaredMcpFromExpectedFiles(
41858
+ expectedApply.harnesses,
41859
+ expectedApply.expected_files ?? []
41860
+ );
41157
41861
  }
41158
41862
  function declaredMcpNamesFromMergedPlugins(pluginIds) {
41159
41863
  const merged = mergePluginsForApply(pluginIds);
@@ -41169,12 +41873,14 @@ function buildBaseStatusFields(input) {
41169
41873
  const ownedFiles = collectOwnedGlobalProfileFiles(input.snapshotId);
41170
41874
  const { owned, nonOwned } = classifyGlobalDriftChanges(input.changes, ownedFiles);
41171
41875
  const declaredPins = input.pluginIds && input.pluginIds.length > 0 ? mergePluginsForApply(input.pluginIds).pluginPins : [];
41172
- const declaredMcpByHarness = input.expectedApply ? declaredMcpNamesFromExpectedApply2(input.expectedApply) : input.pluginIds ? declaredMcpNamesFromMergedPlugins(input.pluginIds) : { "claude-code": [], cursor: [] };
41876
+ const declaredFromExpected = input.expectedApply ? declaredMcpFromExpectedApply2(input.expectedApply) : null;
41877
+ const declaredMcpByHarness = declaredFromExpected?.namesByHarness ?? (input.pluginIds ? declaredMcpNamesFromMergedPlugins(input.pluginIds) : { "claude-code": [], cursor: [] });
41173
41878
  const harnesses = buildHarnessLiveStatusMap({
41174
41879
  depth: input.depth,
41175
41880
  homeRoot,
41176
41881
  declaredPins,
41177
- declaredMcpByHarness
41882
+ declaredMcpByHarness,
41883
+ ...declaredFromExpected ? { expectedMcpConfigsByHarness: declaredFromExpected.configsByHarness } : {}
41178
41884
  });
41179
41885
  const { missingPlugins, missingMcp } = input.depth === "full" ? countMissingHarnessRows(harnesses) : { missingPlugins: 0, missingMcp: 0 };
41180
41886
  const contents = input.activeProfile ? buildProfileContents(input.activeProfile) : null;
@@ -41455,8 +42161,8 @@ async function promptForProjectProfile(config) {
41455
42161
  }
41456
42162
 
41457
42163
  // src/services/profile-stash.ts
41458
- import { existsSync as existsSync58, mkdirSync as mkdirSync21, readFileSync as readFileSync48, writeFileSync as writeFileSync22 } from "fs";
41459
- import { join as join73 } from "path";
42164
+ import { existsSync as existsSync60, mkdirSync as mkdirSync22, readFileSync as readFileSync50, writeFileSync as writeFileSync23 } from "fs";
42165
+ import { join as join75 } from "path";
41460
42166
  import { ulid as ulid11 } from "ulid";
41461
42167
  init_connection();
41462
42168
  init_home_root();
@@ -41478,7 +42184,7 @@ function emptyProfileContents() {
41478
42184
  };
41479
42185
  }
41480
42186
  function getProfileStashPath() {
41481
- return join73(getHarnesstapDir(), "profile-stash.json");
42187
+ return join75(getHarnesstapDir(), "profile-stash.json");
41482
42188
  }
41483
42189
  function isProfileContents(value) {
41484
42190
  if (typeof value !== "object" || value === null) {
@@ -41518,11 +42224,11 @@ function hydrateStashEntry(raw) {
41518
42224
  }
41519
42225
  function readProfileStashFile() {
41520
42226
  const filePath = getProfileStashPath();
41521
- if (!existsSync58(filePath)) {
42227
+ if (!existsSync60(filePath)) {
41522
42228
  return { entries: [] };
41523
42229
  }
41524
42230
  try {
41525
- const parsed = JSON.parse(readFileSync48(filePath, "utf-8"));
42231
+ const parsed = JSON.parse(readFileSync50(filePath, "utf-8"));
41526
42232
  if (!Array.isArray(parsed.entries)) {
41527
42233
  return { entries: [] };
41528
42234
  }
@@ -41534,8 +42240,8 @@ function readProfileStashFile() {
41534
42240
  }
41535
42241
  function writeProfileStashFile(file) {
41536
42242
  const home = getHarnesstapDir();
41537
- mkdirSync21(home, { recursive: true });
41538
- writeFileSync22(
42243
+ mkdirSync22(home, { recursive: true });
42244
+ writeFileSync23(
41539
42245
  getProfileStashPath(),
41540
42246
  `${JSON.stringify(file, null, 2)}
41541
42247
  `,
@@ -42299,14 +43005,14 @@ import { resolve as resolve31 } from "path";
42299
43005
  // src/services/skill-package-import.ts
42300
43006
  init_imported_snapshot();
42301
43007
  init_resource();
42302
- import { readFileSync as readFileSync50 } from "fs";
42303
- import { isAbsolute as isAbsolute8, join as join75 } from "path";
42304
- import matter11 from "gray-matter";
43008
+ import { readFileSync as readFileSync52 } from "fs";
43009
+ import { isAbsolute as isAbsolute8, join as join77 } from "path";
43010
+ import matter12 from "gray-matter";
42305
43011
 
42306
43012
  // src/services/skill-discovery.ts
42307
- import { existsSync as existsSync59, readdirSync as readdirSync21, readFileSync as readFileSync49, statSync as statSync17 } from "fs";
42308
- import { join as join74, relative as relative11 } from "path";
42309
- import matter10 from "gray-matter";
43013
+ import { existsSync as existsSync61, readdirSync as readdirSync21, readFileSync as readFileSync51, statSync as statSync17 } from "fs";
43014
+ import { join as join76, relative as relative11 } from "path";
43015
+ import matter11 from "gray-matter";
42310
43016
  var SKILL_ROOTS = ["skills", ".agents/skills"];
42311
43017
  function isDirectory8(path) {
42312
43018
  try {
@@ -42316,10 +43022,10 @@ function isDirectory8(path) {
42316
43022
  }
42317
43023
  }
42318
43024
  function readSkillMd(skillDir) {
42319
- const skillPath = join74(skillDir, "SKILL.md");
42320
- if (!existsSync59(skillPath)) return null;
42321
- const raw = readFileSync49(skillPath, "utf-8");
42322
- const parsed = matter10(raw);
43025
+ const skillPath = join76(skillDir, "SKILL.md");
43026
+ if (!existsSync61(skillPath)) return null;
43027
+ const raw = readFileSync51(skillPath, "utf-8");
43028
+ const parsed = matter11(raw);
42323
43029
  const dirName = skillDir.split(/[/\\]/).pop() ?? "skill";
42324
43030
  return {
42325
43031
  name: typeof parsed.data.name === "string" && parsed.data.name.trim() ? parsed.data.name.trim() : dirName,
@@ -42345,17 +43051,17 @@ function walkForSkills(rootPath, currentDir, results) {
42345
43051
  }
42346
43052
  for (const entry of readdirSync21(currentDir)) {
42347
43053
  if (entry.startsWith(".")) continue;
42348
- walkForSkills(rootPath, join74(currentDir, entry), results);
43054
+ walkForSkills(rootPath, join76(currentDir, entry), results);
42349
43055
  }
42350
43056
  }
42351
43057
  function discoverSkillPackage(rootPath) {
42352
43058
  const results = [];
42353
43059
  for (const root of SKILL_ROOTS) {
42354
- const dir = join74(rootPath, root);
43060
+ const dir = join76(rootPath, root);
42355
43061
  if (!isDirectory8(dir)) continue;
42356
43062
  for (const entry of readdirSync21(dir)) {
42357
43063
  if (entry.startsWith(".")) continue;
42358
- walkForSkills(rootPath, join74(dir, entry), results);
43064
+ walkForSkills(rootPath, join76(dir, entry), results);
42359
43065
  }
42360
43066
  }
42361
43067
  const byName = /* @__PURE__ */ new Map();
@@ -42407,18 +43113,18 @@ function buildProvenance2(input) {
42407
43113
  };
42408
43114
  }
42409
43115
  function buildSkillResource(input) {
42410
- const skillPath = join75(input.rootPath, input.skill.skillMdRelative);
42411
- const raw = readFileSync50(skillPath, "utf-8");
43116
+ const skillPath = join77(input.rootPath, input.skill.skillMdRelative);
43117
+ const raw = readFileSync52(skillPath, "utf-8");
42412
43118
  let parsed;
42413
43119
  try {
42414
- parsed = matter11(raw);
43120
+ parsed = matter12(raw);
42415
43121
  } catch {
42416
43122
  throw new Error(`Malformed resource frontmatter: ${skillPath}`);
42417
43123
  }
42418
43124
  if (raw.startsWith("---") && parsed.content === raw) {
42419
43125
  throw new Error(`Malformed resource frontmatter: ${skillPath}`);
42420
43126
  }
42421
- const skillDir = join75(input.rootPath, input.skill.skillDirRelative);
43127
+ const skillDir = join77(input.rootPath, input.skill.skillDirRelative);
42422
43128
  const provenance = buildProvenance2({
42423
43129
  importedAt: input.importedAt,
42424
43130
  sourceLabel: input.sourceLabel,
@@ -42493,10 +43199,10 @@ async function importSkillPackage(options) {
42493
43199
 
42494
43200
  // src/services/skill-install.ts
42495
43201
  init_registry();
42496
- import { cpSync, existsSync as existsSync60, mkdirSync as mkdirSync22, rmSync as rmSync7, symlinkSync } from "fs";
42497
- import { dirname as dirname17, join as join76, relative as relative12, resolve as resolve29 } from "path";
43202
+ import { cpSync, existsSync as existsSync62, mkdirSync as mkdirSync23, rmSync as rmSync7, symlinkSync } from "fs";
43203
+ import { dirname as dirname17, join as join78, relative as relative12, resolve as resolve29 } from "path";
42498
43204
  function resolveConfiguredPath3(baseRoot, configured) {
42499
- return configured.startsWith("~/") ? join76(baseRoot, configured.slice(2)) : join76(baseRoot, configured);
43205
+ return configured.startsWith("~/") ? join78(baseRoot, configured.slice(2)) : join78(baseRoot, configured);
42500
43206
  }
42501
43207
  function resolveGlobalSkillPath(homeRoot, platformId) {
42502
43208
  const platform = getAllPlatforms().find((p) => p.id === platformId);
@@ -42508,18 +43214,18 @@ function resolveProjectSkillPath(projectRoot, platformId) {
42508
43214
  const platform = getAllPlatforms().find((p) => p.id === platformId);
42509
43215
  const configured = platform?.projectPaths.skills;
42510
43216
  if (!configured) return void 0;
42511
- return join76(projectRoot, configured);
43217
+ return join78(projectRoot, configured);
42512
43218
  }
42513
43219
  function ensureSymlink(linkPath, targetPath) {
42514
- mkdirSync22(dirname17(linkPath), { recursive: true });
42515
- if (existsSync60(linkPath)) {
43220
+ mkdirSync23(dirname17(linkPath), { recursive: true });
43221
+ if (existsSync62(linkPath)) {
42516
43222
  rmSync7(linkPath, { recursive: true, force: true });
42517
43223
  }
42518
43224
  symlinkSync(resolve29(targetPath), linkPath);
42519
43225
  }
42520
43226
  function installSkillAtPath(linkPath, targetPath, method) {
42521
43227
  if (method === "copy") {
42522
- mkdirSync22(linkPath, { recursive: true });
43228
+ mkdirSync23(linkPath, { recursive: true });
42523
43229
  cpSync(targetPath, linkPath, { recursive: true });
42524
43230
  return;
42525
43231
  }
@@ -42542,15 +43248,15 @@ async function installSkillsToGlobal(options) {
42542
43248
  const installed = [];
42543
43249
  const files = [];
42544
43250
  for (const skill of options.skills) {
42545
- const sourceDir2 = join76(options.checkoutRoot, skill.skillDirRelative);
42546
- const hubDir = join76(options.homeRoot, ".agents/skills", skill.name);
43251
+ const sourceDir2 = join78(options.checkoutRoot, skill.skillDirRelative);
43252
+ const hubDir = join78(options.homeRoot, ".agents/skills", skill.name);
42547
43253
  installSkillAtPath(hubDir, sourceDir2, options.method);
42548
- files.push(join76(".agents/skills", skill.name));
43254
+ files.push(join78(".agents/skills", skill.name));
42549
43255
  installed.push(skill.name);
42550
43256
  for (const harness of options.harnesses) {
42551
43257
  const targetRoot = resolveGlobalSkillPath(options.homeRoot, harness);
42552
43258
  if (!targetRoot) continue;
42553
- const targetDir = join76(targetRoot, skill.name);
43259
+ const targetDir = join78(targetRoot, skill.name);
42554
43260
  if (targetDir === hubDir) continue;
42555
43261
  installSkillAtPath(targetDir, hubDir, options.method);
42556
43262
  files.push(relativeFromRoot(options.homeRoot, targetDir));
@@ -42563,15 +43269,15 @@ async function installSkillsToProject(options) {
42563
43269
  const installed = [];
42564
43270
  const files = [];
42565
43271
  for (const skill of options.skills) {
42566
- const sourceDir2 = join76(options.checkoutRoot, skill.skillDirRelative);
42567
- const hubDir = join76(options.projectRoot, ".agents/skills", skill.name);
43272
+ const sourceDir2 = join78(options.checkoutRoot, skill.skillDirRelative);
43273
+ const hubDir = join78(options.projectRoot, ".agents/skills", skill.name);
42568
43274
  installSkillAtPath(hubDir, sourceDir2, effectiveMethod);
42569
- files.push(join76(".agents/skills", skill.name));
43275
+ files.push(join78(".agents/skills", skill.name));
42570
43276
  installed.push(skill.name);
42571
43277
  for (const harness of options.harnesses) {
42572
43278
  const targetRoot = resolveProjectSkillPath(options.projectRoot, harness);
42573
43279
  if (!targetRoot) continue;
42574
- const targetDir = join76(targetRoot, skill.name);
43280
+ const targetDir = join78(targetRoot, skill.name);
42575
43281
  if (targetDir === hubDir) continue;
42576
43282
  installSkillAtPath(targetDir, hubDir, effectiveMethod);
42577
43283
  files.push(relativeFromRoot(options.projectRoot, targetDir));
@@ -42584,8 +43290,8 @@ async function installSkillsToProject(options) {
42584
43290
  init_plugin_composition();
42585
43291
 
42586
43292
  // src/services/repo-profile.ts
42587
- import { existsSync as existsSync61 } from "fs";
42588
- import { join as join77 } from "path";
43293
+ import { existsSync as existsSync63 } from "fs";
43294
+ import { join as join79 } from "path";
42589
43295
  init_scanner();
42590
43296
  function classifyRepo(rootPath) {
42591
43297
  const profiles = [];
@@ -42595,7 +43301,7 @@ function classifyRepo(rootPath) {
42595
43301
  if (hasPluginSourceLayout(rootPath)) {
42596
43302
  profiles.push("plugin-source");
42597
43303
  }
42598
- if (existsSync61(join77(rootPath, APM_MANIFEST_FILENAME))) {
43304
+ if (existsSync63(join79(rootPath, APM_MANIFEST_FILENAME))) {
42599
43305
  profiles.push("project-config");
42600
43306
  }
42601
43307
  if (detectPlatforms(rootPath).length > 0) {
@@ -42606,7 +43312,7 @@ function classifyRepo(rootPath) {
42606
43312
  }
42607
43313
 
42608
43314
  // src/services/source-resolver.ts
42609
- import { existsSync as existsSync62 } from "fs";
43315
+ import { existsSync as existsSync64 } from "fs";
42610
43316
  import { basename as basename11, resolve as resolve30 } from "path";
42611
43317
  var GITHUB_SHORTHAND = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
42612
43318
  function parseOwnerRepo(label2) {
@@ -42618,7 +43324,7 @@ function parseOwnerRepo(label2) {
42618
43324
  }
42619
43325
  function resolveRemoteSource(input) {
42620
43326
  const trimmed = input.trim();
42621
- if (existsSync62(trimmed)) {
43327
+ if (existsSync64(trimmed)) {
42622
43328
  return {
42623
43329
  kind: "local",
42624
43330
  path: resolve30(trimmed),
@@ -45037,7 +45743,7 @@ async function handlePluginEditCommand(name, opts) {
45037
45743
  return;
45038
45744
  }
45039
45745
  if (opts.apply) {
45040
- const raw = readFileSync51(opts.apply, "utf8");
45746
+ const raw = readFileSync53(opts.apply, "utf8");
45041
45747
  const attachments = parsePluginEditApplyFile(raw);
45042
45748
  const pending = buildPendingFromApplySpec(candidates, attachments);
45043
45749
  const result2 = await applyPluginEdit({
@@ -46206,14 +46912,14 @@ init_scanner();
46206
46912
  init_home_root();
46207
46913
 
46208
46914
  // src/services/apm-mcp-manifest.ts
46209
- import { existsSync as existsSync63, readFileSync as readFileSync52, writeFileSync as writeFileSync23 } from "fs";
46210
- import { join as join78 } from "path";
46915
+ import { existsSync as existsSync65, readFileSync as readFileSync54, writeFileSync as writeFileSync24 } from "fs";
46916
+ import { join as join80 } from "path";
46211
46917
  import { stringify as stringifyYaml5 } from "yaml";
46212
46918
  function isRecord23(value) {
46213
46919
  return value !== null && typeof value === "object" && !Array.isArray(value);
46214
46920
  }
46215
46921
  function apmManifestPath(projectRoot) {
46216
- return join78(projectRoot, APM_MANIFEST_FILENAME);
46922
+ return join80(projectRoot, APM_MANIFEST_FILENAME);
46217
46923
  }
46218
46924
  function manifestHasMcpRegistryId(raw, registryId) {
46219
46925
  const document = parseApmYamlDocument(raw, APM_MANIFEST_FILENAME);
@@ -46246,19 +46952,19 @@ function appendMcpRegistryIdToManifest(raw, registryId) {
46246
46952
  }
46247
46953
  async function withMcpManifestAppend(options) {
46248
46954
  const path = apmManifestPath(options.projectRoot);
46249
- if (!existsSync63(path)) {
46955
+ if (!existsSync65(path)) {
46250
46956
  throw new Error(
46251
46957
  `No ${APM_MANIFEST_FILENAME} found under ${options.projectRoot}. Run ht config init first.`
46252
46958
  );
46253
46959
  }
46254
- const previous = readFileSync52(path, "utf8");
46960
+ const previous = readFileSync54(path, "utf8");
46255
46961
  const { next, added } = appendMcpRegistryIdToManifest(previous, options.registryId);
46256
46962
  if (added) {
46257
- writeFileSync23(path, next, "utf8");
46963
+ writeFileSync24(path, next, "utf8");
46258
46964
  }
46259
46965
  const restore = () => {
46260
46966
  if (added) {
46261
- writeFileSync23(path, previous, "utf8");
46967
+ writeFileSync24(path, previous, "utf8");
46262
46968
  }
46263
46969
  };
46264
46970
  try {
@@ -46790,7 +47496,7 @@ function registerDenyCommand(root) {
46790
47496
 
46791
47497
  // src/cli/commands/lock.ts
46792
47498
  init_connection();
46793
- import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync24 } from "fs";
47499
+ import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync25 } from "fs";
46794
47500
  import { dirname as dirname18, resolve as resolve37 } from "path";
46795
47501
 
46796
47502
  // src/services/export/purl.ts
@@ -47172,8 +47878,8 @@ function handleLockExportCommand(opts) {
47172
47878
  const document = exportSbom(lock, format, timestamp);
47173
47879
  if (opts.output) {
47174
47880
  const outputPath = resolve37(opts.output);
47175
- mkdirSync23(dirname18(outputPath), { recursive: true });
47176
- writeFileSync24(outputPath, document, "utf8");
47881
+ mkdirSync24(dirname18(outputPath), { recursive: true });
47882
+ writeFileSync25(outputPath, document, "utf8");
47177
47883
  return;
47178
47884
  }
47179
47885
  process.stdout.write(document);
@@ -47285,25 +47991,25 @@ init_connection();
47285
47991
 
47286
47992
  // src/services/migrate-scope.ts
47287
47993
  init_plugin_model();
47288
- import { existsSync as existsSync66, statSync as statSync20 } from "fs";
47289
- import { extname as extname2, join as join80, resolve as resolve41 } from "path";
47994
+ import { existsSync as existsSync68, statSync as statSync20 } from "fs";
47995
+ import { extname as extname2, join as join82, resolve as resolve41 } from "path";
47290
47996
  init_name();
47291
47997
 
47292
47998
  // src/services/migrate.ts
47293
47999
  init_connection();
47294
48000
  import {
47295
48001
  cpSync as cpSync2,
47296
- existsSync as existsSync64,
47297
- mkdirSync as mkdirSync24,
48002
+ existsSync as existsSync66,
48003
+ mkdirSync as mkdirSync25,
47298
48004
  mkdtempSync as mkdtempSync2,
47299
- readFileSync as readFileSync53,
48005
+ readFileSync as readFileSync55,
47300
48006
  readdirSync as readdirSync22,
47301
48007
  rmSync as rmSync8,
47302
48008
  statSync as statSync18,
47303
- writeFileSync as writeFileSync25
48009
+ writeFileSync as writeFileSync26
47304
48010
  } from "fs";
47305
48011
  import { tmpdir as tmpdir2 } from "os";
47306
- import { join as join79, resolve as resolve39 } from "path";
48012
+ import { join as join81, resolve as resolve39 } from "path";
47307
48013
  import { execSync as execSync2 } from "child_process";
47308
48014
  init_plugin_model();
47309
48015
  init_settings();
@@ -47311,7 +48017,7 @@ init_name();
47311
48017
  var MIGRATE_MANIFEST_VERSION_V1 = 1;
47312
48018
  var MIGRATE_MANIFEST_VERSION = 2;
47313
48019
  function writeJson(path, data) {
47314
- writeFileSync25(path, JSON.stringify(data, null, 2), "utf-8");
48020
+ writeFileSync26(path, JSON.stringify(data, null, 2), "utf-8");
47315
48021
  }
47316
48022
  function listArchiveMembers(archivePath) {
47317
48023
  const listing = execSync2(`tar -tzf "${archivePath}"`, {
@@ -47323,8 +48029,8 @@ function listArchiveMembers(archivePath) {
47323
48029
  function extractArchive(archivePath, destDir) {
47324
48030
  const resolved = resolve39(archivePath);
47325
48031
  if (resolved.endsWith(".json") && !resolved.endsWith(".ap.json")) {
47326
- mkdirSync24(join79(destDir, "state"), { recursive: true });
47327
- cpSync2(resolved, join79(destDir, "state", "migrate.json"));
48032
+ mkdirSync25(join81(destDir, "state"), { recursive: true });
48033
+ cpSync2(resolved, join81(destDir, "state", "migrate.json"));
47328
48034
  return;
47329
48035
  }
47330
48036
  assertArchiveMembersContained(destDir, listArchiveMembers(resolved));
@@ -47334,15 +48040,15 @@ function extractArchive(archivePath, destDir) {
47334
48040
  function createArchive(sourceDir2, outputPath) {
47335
48041
  const resolved = resolve39(outputPath);
47336
48042
  if (resolved.endsWith(".json") && !resolved.endsWith(".ap.json")) {
47337
- const manifest = readFileSync53(join79(sourceDir2, "manifest.json"), "utf-8");
47338
- const environmentsDir = join79(sourceDir2, "environments");
47339
- const pluginsDir = join79(sourceDir2, "plugins");
48043
+ const manifest = readFileSync55(join81(sourceDir2, "manifest.json"), "utf-8");
48044
+ const environmentsDir = join81(sourceDir2, "environments");
48045
+ const pluginsDir = join81(sourceDir2, "plugins");
47340
48046
  const plugins = [];
47341
- if (existsSync64(pluginsDir)) {
48047
+ if (existsSync66(pluginsDir)) {
47342
48048
  for (const entry of readdirSync22(pluginsDir)) {
47343
- const packageDir = join79(pluginsDir, entry);
48049
+ const packageDir = join81(pluginsDir, entry);
47344
48050
  if (!statSync18(packageDir).isDirectory()) continue;
47345
- if (!existsSync64(join79(packageDir, "plugin.json"))) {
48051
+ if (!existsSync66(join81(packageDir, "plugin.json"))) {
47346
48052
  throw new Error(
47347
48053
  `Archive plugin directory ${entry} is missing plugin.json`
47348
48054
  );
@@ -47352,15 +48058,15 @@ function createArchive(sourceDir2, outputPath) {
47352
48058
  }
47353
48059
  const state = {
47354
48060
  manifest: JSON.parse(manifest),
47355
- harness: existsSync64(join79(sourceDir2, "harness.json")) ? JSON.parse(readFileSync53(join79(sourceDir2, "harness.json"), "utf-8")) : null,
47356
- config: existsSync64(join79(sourceDir2, "config.json")) ? JSON.parse(readFileSync53(join79(sourceDir2, "config.json"), "utf-8")) : null,
47357
- active_profile: existsSync64(join79(sourceDir2, "active-profile.json")) ? JSON.parse(readFileSync53(join79(sourceDir2, "active-profile.json"), "utf-8")) : null,
48061
+ harness: existsSync66(join81(sourceDir2, "harness.json")) ? JSON.parse(readFileSync55(join81(sourceDir2, "harness.json"), "utf-8")) : null,
48062
+ config: existsSync66(join81(sourceDir2, "config.json")) ? JSON.parse(readFileSync55(join81(sourceDir2, "config.json"), "utf-8")) : null,
48063
+ active_profile: existsSync66(join81(sourceDir2, "active-profile.json")) ? JSON.parse(readFileSync55(join81(sourceDir2, "active-profile.json"), "utf-8")) : null,
47358
48064
  plugins
47359
48065
  };
47360
- if (existsSync64(environmentsDir)) {
47361
- state.environments = readdirSync22(environmentsDir).filter((f) => f.endsWith(".toml")).map((f) => readFileSync53(join79(environmentsDir, f), "utf-8"));
48066
+ if (existsSync66(environmentsDir)) {
48067
+ state.environments = readdirSync22(environmentsDir).filter((f) => f.endsWith(".toml")).map((f) => readFileSync55(join81(environmentsDir, f), "utf-8"));
47362
48068
  }
47363
- writeFileSync25(resolved, JSON.stringify(state, null, 2), "utf-8");
48069
+ writeFileSync26(resolved, JSON.stringify(state, null, 2), "utf-8");
47364
48070
  return;
47365
48071
  }
47366
48072
  execSync2(`tar -czf "${resolved}" -C "${sourceDir2}" .`, { stdio: "pipe" });
@@ -47373,38 +48079,38 @@ function isMigrateManifestV1(manifest) {
47373
48079
  return manifest.version === MIGRATE_MANIFEST_VERSION_V1;
47374
48080
  }
47375
48081
  function exportMigrationState(opts) {
47376
- const workDir = mkdtempSync2(join79(tmpdir2(), "harnesstap-migrate-"));
47377
- const pluginsDir = join79(workDir, "plugins");
47378
- const environmentsDir = join79(workDir, "environments");
47379
- mkdirSync24(pluginsDir, { recursive: true });
47380
- mkdirSync24(environmentsDir, { recursive: true });
48082
+ const workDir = mkdtempSync2(join81(tmpdir2(), "harnesstap-migrate-"));
48083
+ const pluginsDir = join81(workDir, "plugins");
48084
+ const environmentsDir = join81(workDir, "environments");
48085
+ mkdirSync25(pluginsDir, { recursive: true });
48086
+ mkdirSync25(environmentsDir, { recursive: true });
47381
48087
  const plugins = listPlugins();
47382
48088
  const pluginNames = [];
47383
48089
  for (const plugin of plugins) {
47384
48090
  const slug = slugifyApName(plugin.name);
47385
48091
  pluginNames.push(slug);
47386
- const packageDir = join79(pluginsDir, slug);
48092
+ const packageDir = join81(pluginsDir, slug);
47387
48093
  writeApPackageFiles(buildApPackageFiles(plugin.id), packageDir);
47388
48094
  }
47389
48095
  const environments = listEnvironmentDocuments();
47390
48096
  for (const environment of environments) {
47391
- writeFileSync25(
47392
- join79(environmentsDir, `${environment.name}.toml`),
48097
+ writeFileSync26(
48098
+ join81(environmentsDir, `${environment.name}.toml`),
47393
48099
  formatEnvironmentToml(environment),
47394
48100
  "utf-8"
47395
48101
  );
47396
48102
  }
47397
48103
  const harness = getHarnessPreference();
47398
48104
  if (harness) {
47399
- writeJson(join79(workDir, "harness.json"), harness);
48105
+ writeJson(join81(workDir, "harness.json"), harness);
47400
48106
  }
47401
48107
  const config = loadSettings(getHarnesstapDir());
47402
- writeJson(join79(workDir, "config.json"), config);
48108
+ writeJson(join81(workDir, "config.json"), config);
47403
48109
  const harnesstapDir = getHarnesstapDir();
47404
- const activeProfilePath = join79(harnesstapDir, "active-profile.json");
47405
- const includesActiveProfile = existsSync64(activeProfilePath);
48110
+ const activeProfilePath = join81(harnesstapDir, "active-profile.json");
48111
+ const includesActiveProfile = existsSync66(activeProfilePath);
47406
48112
  if (includesActiveProfile) {
47407
- cpSync2(activeProfilePath, join79(workDir, "active-profile.json"));
48113
+ cpSync2(activeProfilePath, join81(workDir, "active-profile.json"));
47408
48114
  }
47409
48115
  const manifest = {
47410
48116
  version: MIGRATE_MANIFEST_VERSION,
@@ -47415,31 +48121,31 @@ function exportMigrationState(opts) {
47415
48121
  include_plugins: opts.includePlugins ?? false,
47416
48122
  includes_active_profile: includesActiveProfile
47417
48123
  };
47418
- writeJson(join79(workDir, "manifest.json"), manifest);
47419
- mkdirSync24(dirnameSafe(resolve39(opts.outputPath)), { recursive: true });
48124
+ writeJson(join81(workDir, "manifest.json"), manifest);
48125
+ mkdirSync25(dirnameSafe(resolve39(opts.outputPath)), { recursive: true });
47420
48126
  createArchive(workDir, opts.outputPath);
47421
48127
  rmSync8(workDir, { recursive: true, force: true });
47422
48128
  return manifest;
47423
48129
  }
47424
48130
  function importEnvironmentsFromDir(environmentsDir) {
47425
- if (!existsSync64(environmentsDir)) {
48131
+ if (!existsSync66(environmentsDir)) {
47426
48132
  return 0;
47427
48133
  }
47428
48134
  let imported = 0;
47429
48135
  for (const file of readdirSync22(environmentsDir)) {
47430
48136
  if (!file.endsWith(".toml")) continue;
47431
- importEnvironmentToml(readFileSync53(join79(environmentsDir, file), "utf-8"));
48137
+ importEnvironmentToml(readFileSync55(join81(environmentsDir, file), "utf-8"));
47432
48138
  imported++;
47433
48139
  }
47434
48140
  return imported;
47435
48141
  }
47436
48142
  function importPluginsFromDir(pluginsDir) {
47437
- if (!existsSync64(pluginsDir)) {
48143
+ if (!existsSync66(pluginsDir)) {
47438
48144
  return 0;
47439
48145
  }
47440
48146
  let imported = 0;
47441
48147
  for (const entry of readdirSync22(pluginsDir)) {
47442
- const packageDir = join79(pluginsDir, entry);
48148
+ const packageDir = join81(pluginsDir, entry);
47443
48149
  if (!statSync18(packageDir).isDirectory()) {
47444
48150
  if (isLegacyPluginTomlPath(entry) || entry.endsWith(".toml")) {
47445
48151
  throw new Error(
@@ -47448,7 +48154,7 @@ function importPluginsFromDir(pluginsDir) {
47448
48154
  }
47449
48155
  continue;
47450
48156
  }
47451
- if (!existsSync64(join79(packageDir, "plugin.json"))) {
48157
+ if (!existsSync66(join81(packageDir, "plugin.json"))) {
47452
48158
  throw new Error(
47453
48159
  `Archive plugin directory ${entry} is missing plugin.json`
47454
48160
  );
@@ -47459,7 +48165,7 @@ function importPluginsFromDir(pluginsDir) {
47459
48165
  return imported;
47460
48166
  }
47461
48167
  function importMigrationState(opts) {
47462
- const workDir = mkdtempSync2(join79(tmpdir2(), "harnesstap-migrate-import-"));
48168
+ const workDir = mkdtempSync2(join81(tmpdir2(), "harnesstap-migrate-import-"));
47463
48169
  try {
47464
48170
  extractArchive(opts.archivePath, workDir);
47465
48171
  let manifest;
@@ -47467,49 +48173,49 @@ function importMigrationState(opts) {
47467
48173
  let environmentsDir;
47468
48174
  let harnessPath;
47469
48175
  let configPath;
47470
- if (existsSync64(join79(workDir, "state", "migrate.json"))) {
48176
+ if (existsSync66(join81(workDir, "state", "migrate.json"))) {
47471
48177
  const state = JSON.parse(
47472
- readFileSync53(join79(workDir, "state", "migrate.json"), "utf-8")
48178
+ readFileSync55(join81(workDir, "state", "migrate.json"), "utf-8")
47473
48179
  );
47474
48180
  manifest = state.manifest;
47475
- pluginsDir = join79(workDir, "import-plugins");
47476
- environmentsDir = join79(workDir, "import-environments");
47477
- mkdirSync24(pluginsDir, { recursive: true });
47478
- mkdirSync24(environmentsDir, { recursive: true });
48181
+ pluginsDir = join81(workDir, "import-plugins");
48182
+ environmentsDir = join81(workDir, "import-environments");
48183
+ mkdirSync25(pluginsDir, { recursive: true });
48184
+ mkdirSync25(environmentsDir, { recursive: true });
47479
48185
  for (let i = 0; i < state.plugins.length; i++) {
47480
- const packageDir = join79(pluginsDir, `plugin-${i}`);
48186
+ const packageDir = join81(pluginsDir, `plugin-${i}`);
47481
48187
  const envelopeRaw = JSON.stringify(state.plugins[i]);
47482
48188
  const files = parseApEnvelope(envelopeRaw, `archive plugin ${i}`);
47483
48189
  writeApPackageFiles(files, packageDir);
47484
48190
  }
47485
48191
  if (state.environments) {
47486
48192
  for (let i = 0; i < state.environments.length; i++) {
47487
- writeFileSync25(
47488
- join79(environmentsDir, `environment-${i}.toml`),
48193
+ writeFileSync26(
48194
+ join81(environmentsDir, `environment-${i}.toml`),
47489
48195
  state.environments[i] ?? "",
47490
48196
  "utf-8"
47491
48197
  );
47492
48198
  }
47493
48199
  }
47494
48200
  if (state.harness) {
47495
- writeJson(join79(workDir, "harness.json"), state.harness);
48201
+ writeJson(join81(workDir, "harness.json"), state.harness);
47496
48202
  }
47497
- writeJson(join79(workDir, "config.json"), state.config);
48203
+ writeJson(join81(workDir, "config.json"), state.config);
47498
48204
  if (state.active_profile) {
47499
- writeJson(join79(workDir, "active-profile.json"), state.active_profile);
48205
+ writeJson(join81(workDir, "active-profile.json"), state.active_profile);
47500
48206
  }
47501
- harnessPath = join79(workDir, "harness.json");
47502
- configPath = join79(workDir, "config.json");
48207
+ harnessPath = join81(workDir, "harness.json");
48208
+ configPath = join81(workDir, "config.json");
47503
48209
  } else {
47504
48210
  manifest = JSON.parse(
47505
- readFileSync53(join79(workDir, "manifest.json"), "utf-8")
48211
+ readFileSync55(join81(workDir, "manifest.json"), "utf-8")
47506
48212
  );
47507
- pluginsDir = join79(workDir, "plugins");
47508
- environmentsDir = join79(workDir, "environments");
47509
- harnessPath = join79(workDir, "harness.json");
47510
- configPath = join79(workDir, "config.json");
48213
+ pluginsDir = join81(workDir, "plugins");
48214
+ environmentsDir = join81(workDir, "environments");
48215
+ harnessPath = join81(workDir, "harness.json");
48216
+ configPath = join81(workDir, "config.json");
47511
48217
  }
47512
- const activeProfilePath = join79(workDir, "active-profile.json");
48218
+ const activeProfilePath = join81(workDir, "active-profile.json");
47513
48219
  if (isMigrateManifestV1(manifest)) {
47514
48220
  throw new Error(
47515
48221
  "This archive uses manifest version 1, which stored plugins as TOML. Version 1 archives were never released and are not supported."
@@ -47521,30 +48227,30 @@ function importMigrationState(opts) {
47521
48227
  }
47522
48228
  const pluginsImported = importPluginsFromDir(pluginsDir);
47523
48229
  const environmentsImported = importEnvironmentsFromDir(environmentsDir);
47524
- if (existsSync64(harnessPath)) {
48230
+ if (existsSync66(harnessPath)) {
47525
48231
  const harness = JSON.parse(
47526
- readFileSync53(harnessPath, "utf-8")
48232
+ readFileSync55(harnessPath, "utf-8")
47527
48233
  );
47528
48234
  setHarnessPreference({
47529
48235
  main_harness: harness.main_harness,
47530
48236
  alias_harnesses: harness.alias_harnesses
47531
48237
  });
47532
48238
  }
47533
- if (existsSync64(configPath)) {
48239
+ if (existsSync66(configPath)) {
47534
48240
  const config = JSON.parse(
47535
- readFileSync53(configPath, "utf-8")
48241
+ readFileSync55(configPath, "utf-8")
47536
48242
  );
47537
48243
  const targetDir = getHarnesstapDir();
47538
- mkdirSync24(targetDir, { recursive: true });
47539
- writeJson(join79(targetDir, "config.json"), config);
48244
+ mkdirSync25(targetDir, { recursive: true });
48245
+ writeJson(join81(targetDir, "config.json"), config);
47540
48246
  }
47541
- if (existsSync64(activeProfilePath)) {
48247
+ if (existsSync66(activeProfilePath)) {
47542
48248
  const activeProfile = JSON.parse(
47543
- readFileSync53(activeProfilePath, "utf-8")
48249
+ readFileSync55(activeProfilePath, "utf-8")
47544
48250
  );
47545
48251
  const targetDir = getHarnesstapDir();
47546
- mkdirSync24(targetDir, { recursive: true });
47547
- writeJson(join79(targetDir, "active-profile.json"), activeProfile);
48252
+ mkdirSync25(targetDir, { recursive: true });
48253
+ writeJson(join81(targetDir, "active-profile.json"), activeProfile);
47548
48254
  }
47549
48255
  return {
47550
48256
  manifest,
@@ -47562,7 +48268,7 @@ init_plugin_versioning();
47562
48268
  // src/services/resource-import-export.ts
47563
48269
  init_plugin_model();
47564
48270
  init_resource();
47565
- import { existsSync as existsSync65, statSync as statSync19 } from "fs";
48271
+ import { existsSync as existsSync67, statSync as statSync19 } from "fs";
47566
48272
  import { resolve as resolve40 } from "path";
47567
48273
  init_plugin_composition();
47568
48274
  init_resource_selector();
@@ -47600,7 +48306,7 @@ function exportResourceToFile(selector, filePath, options) {
47600
48306
  }
47601
48307
  function importResourceFromFile(filePath) {
47602
48308
  const resolved = resolve40(filePath);
47603
- if (!existsSync65(resolved)) {
48309
+ if (!existsSync67(resolved)) {
47604
48310
  throw new Error(`Path not found: ${resolved}`);
47605
48311
  }
47606
48312
  const packageFiles = statSync19(resolved).isDirectory() ? readApPackageFiles(resolved) : isApEnvelopePath(resolved) ? readApEnvelope(resolved) : (() => {
@@ -47704,7 +48410,7 @@ function resolveExportScope(opts) {
47704
48410
  function detectImportScopeFromFile(filePath) {
47705
48411
  const resolved = resolve41(filePath);
47706
48412
  if (statSync20(resolved).isDirectory()) {
47707
- if (!existsSync66(join80(resolved, "plugin.json"))) {
48413
+ if (!existsSync68(join82(resolved, "plugin.json"))) {
47708
48414
  throw new Error(
47709
48415
  `${resolved} is a directory but has no plugin.json \u2014 expected an Agent Plugins package.`
47710
48416
  );
@@ -50380,8 +51086,8 @@ init_imported_snapshot();
50380
51086
  init_plugin_source_import();
50381
51087
 
50382
51088
  // src/services/project-sync.ts
50383
- import { existsSync as existsSync68, mkdirSync as mkdirSync25, symlinkSync as symlinkSync2, unlinkSync as unlinkSync2 } from "fs";
50384
- import { dirname as dirname19, join as join82, relative as relative13 } from "path";
51089
+ import { existsSync as existsSync70, mkdirSync as mkdirSync26, symlinkSync as symlinkSync2, unlinkSync as unlinkSync2 } from "fs";
51090
+ import { dirname as dirname19, join as join84, relative as relative13 } from "path";
50385
51091
  init_scanner();
50386
51092
  init_plugin_source_import();
50387
51093
 
@@ -50407,8 +51113,8 @@ function mainScanLacksPluginSkills(main, plugin) {
50407
51113
  }
50408
51114
 
50409
51115
  // src/services/harness-surface-gaps.ts
50410
- import { existsSync as existsSync67, readdirSync as readdirSync23, readFileSync as readFileSync54 } from "fs";
50411
- import { join as join81 } from "path";
51116
+ import { existsSync as existsSync69, readdirSync as readdirSync23, readFileSync as readFileSync56 } from "fs";
51117
+ import { join as join83 } from "path";
50412
51118
  function listFiles(dir) {
50413
51119
  try {
50414
51120
  return readdirSync23(dir);
@@ -50418,7 +51124,7 @@ function listFiles(dir) {
50418
51124
  }
50419
51125
  function readJson5(filePath) {
50420
51126
  try {
50421
- return JSON.parse(readFileSync54(filePath, "utf-8"));
51127
+ return JSON.parse(readFileSync56(filePath, "utf-8"));
50422
51128
  } catch {
50423
51129
  return void 0;
50424
51130
  }
@@ -50432,7 +51138,7 @@ function isOpencodePluginConfigEntry(entry) {
50432
51138
  }
50433
51139
  function detectHarnessSurfaces(projectRoot) {
50434
51140
  const surfaces = [];
50435
- const opencodePluginsDir = join81(projectRoot, ".opencode", "plugins");
51141
+ const opencodePluginsDir = join83(projectRoot, ".opencode", "plugins");
50436
51142
  for (const file of listFiles(opencodePluginsDir)) {
50437
51143
  if (!isOpencodeServerPluginFile(file)) continue;
50438
51144
  surfaces.push({
@@ -50442,7 +51148,7 @@ function detectHarnessSurfaces(projectRoot) {
50442
51148
  message: "OpenCode server plugins must stay registered in opencode.json on OpenCode."
50443
51149
  });
50444
51150
  }
50445
- const opencodeConfig = readJson5(join81(projectRoot, "opencode.json"));
51151
+ const opencodeConfig = readJson5(join83(projectRoot, "opencode.json"));
50446
51152
  const pluginEntries = opencodeConfig?.["plugin"];
50447
51153
  if (Array.isArray(pluginEntries)) {
50448
51154
  for (const entry of pluginEntries) {
@@ -50459,7 +51165,7 @@ function detectHarnessSurfaces(projectRoot) {
50459
51165
  });
50460
51166
  }
50461
51167
  }
50462
- if (existsSync67(join81(projectRoot, "pi-extension"))) {
51168
+ if (existsSync69(join83(projectRoot, "pi-extension"))) {
50463
51169
  surfaces.push({
50464
51170
  harness: "pi",
50465
51171
  path: "pi-extension/",
@@ -50467,7 +51173,7 @@ function detectHarnessSurfaces(projectRoot) {
50467
51173
  message: "Pi extensions install through the Pi CLI, not mirror."
50468
51174
  });
50469
51175
  }
50470
- if (existsSync67(join81(projectRoot, "gemini-extension.json"))) {
51176
+ if (existsSync69(join83(projectRoot, "gemini-extension.json"))) {
50471
51177
  surfaces.push({
50472
51178
  harness: "gemini-cli",
50473
51179
  path: "gemini-extension.json",
@@ -50475,7 +51181,7 @@ function detectHarnessSurfaces(projectRoot) {
50475
51181
  message: "Gemini extension manifests apply to Gemini CLI and Antigravity only."
50476
51182
  });
50477
51183
  }
50478
- const hooksDir = join81(projectRoot, "hooks");
51184
+ const hooksDir = join83(projectRoot, "hooks");
50479
51185
  for (const file of listFiles(hooksDir)) {
50480
51186
  if (!file.includes("statusline")) continue;
50481
51187
  surfaces.push({
@@ -50531,16 +51237,16 @@ function writeAliasFiles(files, projectRoot, strategy, mainFiles) {
50531
51237
  }
50532
51238
  let written = 0;
50533
51239
  for (const file of files) {
50534
- const fullPath = join82(projectRoot, file.path);
51240
+ const fullPath = join84(projectRoot, file.path);
50535
51241
  const parent = dirname19(fullPath);
50536
- if (!existsSync68(parent)) {
50537
- mkdirSync25(parent, { recursive: true });
51242
+ if (!existsSync70(parent)) {
51243
+ mkdirSync26(parent, { recursive: true });
50538
51244
  }
50539
51245
  const mainPathForContent = mainByContent.get(file.content);
50540
51246
  const useSymlink = strategy === "symlink-preferred" && mainPathForContent !== void 0 && mainPathForContent !== file.path;
50541
51247
  if (useSymlink) {
50542
- const target = join82(projectRoot, mainPathForContent);
50543
- if (existsSync68(fullPath)) {
51248
+ const target = join84(projectRoot, mainPathForContent);
51249
+ if (existsSync70(fullPath)) {
50544
51250
  try {
50545
51251
  unlinkSync2(fullPath);
50546
51252
  } catch {
@@ -51597,8 +52303,8 @@ var CANONICAL_CATALOG_BASELINE = "engineering-foundation";
51597
52303
  var CANONICAL_CATALOG_SEARCH_HINT = "foundation";
51598
52304
 
51599
52305
  // src/services/scenario-guide.ts
51600
- import { existsSync as existsSync69, readFileSync as readFileSync55, readdirSync as readdirSync24 } from "fs";
51601
- import { join as join83, resolve as resolve45 } from "path";
52306
+ import { existsSync as existsSync71, readFileSync as readFileSync57, readdirSync as readdirSync24 } from "fs";
52307
+ import { join as join85, resolve as resolve45 } from "path";
51602
52308
  var SCENARIOS_DETAILS_DIR = resolve45(
51603
52309
  import.meta.dirname,
51604
52310
  "../../docs/scenarios/details"
@@ -51611,7 +52317,7 @@ function scenarioDetailPath(id) {
51611
52317
  if (!match) {
51612
52318
  return void 0;
51613
52319
  }
51614
- return join83(SCENARIOS_DETAILS_DIR, match);
52320
+ return join85(SCENARIOS_DETAILS_DIR, match);
51615
52321
  }
51616
52322
  function parseScenarioMetadata(id, markdown) {
51617
52323
  const titleMatch = /^# Scenario \d+:\s*(.+)$/m.exec(markdown);
@@ -51651,7 +52357,7 @@ function listScenarioIds() {
51651
52357
  function listScenarioSummaries() {
51652
52358
  return listScenarioIds().map((id) => {
51653
52359
  const path = scenarioDetailPath(id);
51654
- if (!path || !existsSync69(path)) {
52360
+ if (!path || !existsSync71(path)) {
51655
52361
  return {
51656
52362
  id,
51657
52363
  title: `Scenario ${id}`,
@@ -51659,7 +52365,7 @@ function listScenarioSummaries() {
51659
52365
  status: null
51660
52366
  };
51661
52367
  }
51662
- const markdown = readFileSync55(path, "utf-8");
52368
+ const markdown = readFileSync57(path, "utf-8");
51663
52369
  return {
51664
52370
  id,
51665
52371
  ...parseScenarioMetadata(id, markdown)
@@ -51668,10 +52374,10 @@ function listScenarioSummaries() {
51668
52374
  }
51669
52375
  function loadScenarioGuide(id) {
51670
52376
  const path = scenarioDetailPath(id);
51671
- if (!path || !existsSync69(path)) {
52377
+ if (!path || !existsSync71(path)) {
51672
52378
  throw new Error(`Scenario not found: ${id}`);
51673
52379
  }
51674
- const markdown = readFileSync55(path, "utf-8");
52380
+ const markdown = readFileSync57(path, "utf-8");
51675
52381
  const summaryBlock = markdown.slice(0, markdown.indexOf("Typical commands:")).split("\n").slice(4).map((line2) => line2.trim()).filter((line2) => line2.length > 0 && !line2.startsWith("["));
51676
52382
  return {
51677
52383
  id,
@@ -51797,7 +52503,7 @@ init_connection();
51797
52503
 
51798
52504
  // src/services/completion/engine.ts
51799
52505
  init_connection();
51800
- import { existsSync as existsSync71 } from "fs";
52506
+ import { existsSync as existsSync73 } from "fs";
51801
52507
 
51802
52508
  // src/services/completion/registry.ts
51803
52509
  init_plugin_composition();
@@ -51998,13 +52704,13 @@ async function completeCloudAccounts(ctx) {
51998
52704
  }
51999
52705
 
52000
52706
  // src/services/completion/providers/file-path.ts
52001
- import { existsSync as existsSync70, readdirSync as readdirSync25, statSync as statSync21 } from "fs";
52002
- import { dirname as dirname20, join as join84, resolve as resolve46 } from "path";
52707
+ import { existsSync as existsSync72, readdirSync as readdirSync25, statSync as statSync21 } from "fs";
52708
+ import { dirname as dirname20, join as join86, resolve as resolve46 } from "path";
52003
52709
  function listPathCandidates(prefix, mode) {
52004
52710
  const resolvedPrefix = resolve46(prefix || ".");
52005
52711
  const directory = dirname20(resolvedPrefix);
52006
52712
  const baseName = resolvedPrefix === directory ? "" : resolvedPrefix.slice(directory.length + 1);
52007
- if (!existsSync70(directory)) {
52713
+ if (!existsSync72(directory)) {
52008
52714
  return [];
52009
52715
  }
52010
52716
  let entries;
@@ -52018,7 +52724,7 @@ function listPathCandidates(prefix, mode) {
52018
52724
  if (!entry.startsWith(baseName)) {
52019
52725
  continue;
52020
52726
  }
52021
- const fullPath = join84(directory, entry);
52727
+ const fullPath = join86(directory, entry);
52022
52728
  let isDirectory9 = false;
52023
52729
  try {
52024
52730
  isDirectory9 = statSync21(fullPath).isDirectory();
@@ -52034,7 +52740,7 @@ function listPathCandidates(prefix, mode) {
52034
52740
  continue;
52035
52741
  }
52036
52742
  }
52037
- const value = directory === process.cwd() ? join84(entry) : fullPath;
52743
+ const value = directory === process.cwd() ? join86(entry) : fullPath;
52038
52744
  candidates.push({ value });
52039
52745
  }
52040
52746
  return candidates;
@@ -52635,7 +53341,7 @@ function parseCompletionContext(program2, line2) {
52635
53341
  consumedPositionals: walked.consumedPositionals,
52636
53342
  prefix,
52637
53343
  account: extractAccount(consumed),
52638
- localDataAvailable: existsSync71(getHarnesstapDir()),
53344
+ localDataAvailable: existsSync73(getHarnesstapDir()),
52639
53345
  ...slotInfo
52640
53346
  };
52641
53347
  }
@@ -52841,7 +53547,7 @@ function registerHelpCommands(root) {
52841
53547
  }
52842
53548
 
52843
53549
  // src/cli/commands/init.ts
52844
- import { existsSync as existsSync74 } from "fs";
53550
+ import { existsSync as existsSync76 } from "fs";
52845
53551
  import { resolve as resolve48 } from "path";
52846
53552
  init_connection();
52847
53553
  init_plugin_model();
@@ -52954,10 +53660,10 @@ async function addSkillPackage(options) {
52954
53660
 
52955
53661
  // src/services/bootstrap-local-library.ts
52956
53662
  init_connection();
52957
- import { existsSync as existsSync72 } from "fs";
53663
+ import { existsSync as existsSync74 } from "fs";
52958
53664
  init_scanner();
52959
53665
  async function bootstrapLocalLibrary(options = {}) {
52960
- const firstRun = !existsSync72(getDbPath());
53666
+ const firstRun = !existsSync74(getDbPath());
52961
53667
  initializeSchema(getDb());
52962
53668
  ensureDefaultEnvironment();
52963
53669
  const homeDefaults = await scanAndPersistHomeDefaults();
@@ -53018,9 +53724,9 @@ async function maybePromptInitCatalogInstall(input) {
53018
53724
  }
53019
53725
 
53020
53726
  // src/services/init-completion-install.ts
53021
- import { existsSync as existsSync73 } from "fs";
53727
+ import { existsSync as existsSync75 } from "fs";
53022
53728
  import { appendFile, mkdir, readFile, writeFile } from "fs/promises";
53023
- import { dirname as dirname21, join as join85 } from "path";
53729
+ import { dirname as dirname21, join as join87 } from "path";
53024
53730
  init_home_root();
53025
53731
 
53026
53732
  // src/services/shell-completion.ts
@@ -53103,11 +53809,11 @@ function detectShellFromEnv(env = process.env) {
53103
53809
  function resolveCompletionTargetPath(shell, homeRoot) {
53104
53810
  switch (shell) {
53105
53811
  case "bash":
53106
- return join85(homeRoot, ".bashrc");
53812
+ return join87(homeRoot, ".bashrc");
53107
53813
  case "zsh":
53108
- return join85(homeRoot, ".zshrc");
53814
+ return join87(homeRoot, ".zshrc");
53109
53815
  case "fish":
53110
- return join85(homeRoot, ".config", "fish", "completions", "ht.fish");
53816
+ return join87(homeRoot, ".config", "fish", "completions", "ht.fish");
53111
53817
  default: {
53112
53818
  const _exhaustive = shell;
53113
53819
  return _exhaustive;
@@ -53121,7 +53827,7 @@ async function installShellCompletion(input) {
53121
53827
  const path = resolveCompletionTargetPath(input.shell, input.homeRoot);
53122
53828
  await mkdir(dirname21(path), { recursive: true });
53123
53829
  if (input.shell === "fish") {
53124
- if (existsSync73(path)) {
53830
+ if (existsSync75(path)) {
53125
53831
  const existing2 = await readFile(path, "utf8");
53126
53832
  if (completionAlreadyInstalled("fish", existing2)) {
53127
53833
  return { status: "already_installed", path };
@@ -53131,7 +53837,7 @@ async function installShellCompletion(input) {
53131
53837
  `, "utf8");
53132
53838
  return { status: "installed", path };
53133
53839
  }
53134
- const existing = existsSync73(path) ? await readFile(path, "utf8") : "";
53840
+ const existing = existsSync75(path) ? await readFile(path, "utf8") : "";
53135
53841
  if (completionAlreadyInstalled(input.shell, existing)) {
53136
53842
  return { status: "already_installed", path };
53137
53843
  }
@@ -53480,7 +54186,7 @@ async function handleAddCommand(source, opts) {
53480
54186
  }
53481
54187
  async function handleInitCommand(opts = {}) {
53482
54188
  const dbPath = getDbPath();
53483
- const hadExistingStore = existsSync74(dbPath);
54189
+ const hadExistingStore = existsSync76(dbPath);
53484
54190
  const { homeDefaults } = await bootstrapLocalLibrary({
53485
54191
  seedDefaultProfile: opts.defaultProfile !== false
53486
54192
  });