agents-inc 0.173.0 → 0.175.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/{chunk-LJQXQTFC.js → chunk-37QFHJUW.js} +142 -13
  3. package/dist/chunk-37QFHJUW.js.map +1 -0
  4. package/dist/chunk-6HJVH27C.js +114 -0
  5. package/dist/chunk-6HJVH27C.js.map +1 -0
  6. package/dist/{chunk-ITQF35UQ.js → chunk-DQB3E2SX.js} +3 -3
  7. package/dist/{chunk-AARQBW5L.js → chunk-EGC7PNDI.js} +46 -32
  8. package/dist/chunk-EGC7PNDI.js.map +1 -0
  9. package/dist/{chunk-3N4FSTVX.js → chunk-EHEBN4NB.js} +2 -2
  10. package/dist/{chunk-EHJIQDXR.js → chunk-GNMRXXRY.js} +39 -40
  11. package/dist/chunk-GNMRXXRY.js.map +1 -0
  12. package/dist/{chunk-G7NUK3BF.js → chunk-ICHWAFAC.js} +29 -19
  13. package/dist/chunk-ICHWAFAC.js.map +1 -0
  14. package/dist/{chunk-Q4UNHVPX.js → chunk-MFCZARV2.js} +9 -9
  15. package/dist/chunk-MFCZARV2.js.map +1 -0
  16. package/dist/{chunk-SPQSNZMM.js → chunk-P5XEK7HC.js} +2 -2
  17. package/dist/{chunk-VR6QTK5Z.js → chunk-Q4NWATGH.js} +31 -27
  18. package/dist/chunk-Q4NWATGH.js.map +1 -0
  19. package/dist/{chunk-BRZA7ZCX.js → chunk-SI2LLEIR.js} +5 -5
  20. package/dist/{chunk-VSPC74SS.js → chunk-SNXEYAFP.js} +45 -30
  21. package/dist/chunk-SNXEYAFP.js.map +1 -0
  22. package/dist/{chunk-A3ZAXL5T.js → chunk-SRII2GMF.js} +3 -3
  23. package/dist/{chunk-7OG635DK.js → chunk-TG3SPPZY.js} +6 -2
  24. package/dist/{chunk-7OG635DK.js.map → chunk-TG3SPPZY.js.map} +1 -1
  25. package/dist/{chunk-MHAQWMNJ.js → chunk-U46LYYRA.js} +3 -6
  26. package/dist/{chunk-MHAQWMNJ.js.map → chunk-U46LYYRA.js.map} +1 -1
  27. package/dist/{chunk-3R3LHA4Q.js → chunk-XYBHH3M5.js} +2 -2
  28. package/dist/{chunk-F437ICEG.js → chunk-YLFKFVQP.js} +11 -11
  29. package/dist/chunk-YLFKFVQP.js.map +1 -0
  30. package/dist/{chunk-WVFBBZEP.js → chunk-YM3VEDAP.js} +698 -325
  31. package/dist/chunk-YM3VEDAP.js.map +1 -0
  32. package/dist/commands/build/marketplace.js +4 -4
  33. package/dist/commands/build/plugins.js +6 -6
  34. package/dist/commands/compile.js +16 -16
  35. package/dist/commands/compile.js.map +1 -1
  36. package/dist/commands/doctor.js +73 -78
  37. package/dist/commands/doctor.js.map +1 -1
  38. package/dist/commands/edit.js +84 -80
  39. package/dist/commands/edit.js.map +1 -1
  40. package/dist/commands/eject.js +27 -18
  41. package/dist/commands/eject.js.map +1 -1
  42. package/dist/commands/init.js +16 -18
  43. package/dist/commands/list.js +42 -18
  44. package/dist/commands/list.js.map +1 -1
  45. package/dist/commands/new/marketplace.js +4 -4
  46. package/dist/commands/search.js +9 -9
  47. package/dist/commands/share.js +13 -13
  48. package/dist/commands/share.js.map +1 -1
  49. package/dist/commands/uninstall.js +29 -27
  50. package/dist/commands/uninstall.js.map +1 -1
  51. package/dist/commands/update.js +17 -18
  52. package/dist/commands/update.js.map +1 -1
  53. package/dist/components/common/select-list.js +2 -2
  54. package/dist/components/common/skill-agent-summary.js +3 -3
  55. package/dist/components/common/summary-panel.js +4 -7
  56. package/dist/hooks/init.js +39 -26
  57. package/dist/hooks/init.js.map +1 -1
  58. package/dist/load-agent-defs-BJ4KBKBA.js +14 -0
  59. package/dist/{recompile-project-agents-6G6M2RS6.js → recompile-project-agents-2QTFMYDC.js} +8 -8
  60. package/dist/{source-loader-W7XCNKNA.js → source-loader-I6SWWDUF.js} +4 -4
  61. package/package.json +1 -1
  62. package/dist/chunk-2RTBSLSR.js +0 -82
  63. package/dist/chunk-2RTBSLSR.js.map +0 -1
  64. package/dist/chunk-AARQBW5L.js.map +0 -1
  65. package/dist/chunk-EHJIQDXR.js.map +0 -1
  66. package/dist/chunk-F437ICEG.js.map +0 -1
  67. package/dist/chunk-G7NUK3BF.js.map +0 -1
  68. package/dist/chunk-LJQXQTFC.js.map +0 -1
  69. package/dist/chunk-N33AKFLR.js +0 -24
  70. package/dist/chunk-N33AKFLR.js.map +0 -1
  71. package/dist/chunk-Q4UNHVPX.js.map +0 -1
  72. package/dist/chunk-Q6WRR4BN.js +0 -195
  73. package/dist/chunk-Q6WRR4BN.js.map +0 -1
  74. package/dist/chunk-VR6QTK5Z.js.map +0 -1
  75. package/dist/chunk-VSPC74SS.js.map +0 -1
  76. package/dist/chunk-WVFBBZEP.js.map +0 -1
  77. package/dist/components/common/scroll-affordance.js +0 -9
  78. package/dist/load-agent-defs-E67DSYTN.js +0 -14
  79. package/dist/source-loader-W7XCNKNA.js.map +0 -1
  80. /package/dist/{chunk-ITQF35UQ.js.map → chunk-DQB3E2SX.js.map} +0 -0
  81. /package/dist/{chunk-3N4FSTVX.js.map → chunk-EHEBN4NB.js.map} +0 -0
  82. /package/dist/{chunk-SPQSNZMM.js.map → chunk-P5XEK7HC.js.map} +0 -0
  83. /package/dist/{chunk-BRZA7ZCX.js.map → chunk-SI2LLEIR.js.map} +0 -0
  84. /package/dist/{chunk-A3ZAXL5T.js.map → chunk-SRII2GMF.js.map} +0 -0
  85. /package/dist/{chunk-3R3LHA4Q.js.map → chunk-XYBHH3M5.js.map} +0 -0
  86. /package/dist/{components/common/scroll-affordance.js.map → load-agent-defs-BJ4KBKBA.js.map} +0 -0
  87. /package/dist/{recompile-project-agents-6G6M2RS6.js.map → recompile-project-agents-2QTFMYDC.js.map} +0 -0
  88. /package/dist/{load-agent-defs-E67DSYTN.js.map → source-loader-I6SWWDUF.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BUILT_IN_MATRIX,
4
4
  getSkillById,
5
- getSkillDisplayName,
5
+ getSkillEntryDisplayName,
6
6
  inertLine,
7
7
  initializeMatrix,
8
8
  matrix,
@@ -13,7 +13,7 @@ import {
13
13
  typedFromEntries,
14
14
  typedKeys,
15
15
  typedValues
16
- } from "./chunk-7OG635DK.js";
16
+ } from "./chunk-TG3SPPZY.js";
17
17
  import {
18
18
  AGENT_NAMES,
19
19
  AUTHOR_HANDLE_PATTERN,
@@ -82,7 +82,7 @@ import {
82
82
  seedAgentScope,
83
83
  sourceDirName,
84
84
  validateSelection
85
- } from "./chunk-MHAQWMNJ.js";
85
+ } from "./chunk-U46LYYRA.js";
86
86
  import {
87
87
  defaultCategories,
88
88
  defaultRules,
@@ -91,8 +91,8 @@ import {
91
91
 
92
92
  // src/cli/lib/loading/source-loader.ts
93
93
  import os14 from "os";
94
- import { partition as partition4, unique as unique6 } from "remeda";
95
- import path29 from "path";
94
+ import { partition as partition5, unique as unique6 } from "remeda";
95
+ import path28 from "path";
96
96
 
97
97
  // src/cli/lib/installation/is-home-directory.ts
98
98
  import fs from "fs";
@@ -105,33 +105,6 @@ function isHomeDirectory(dir) {
105
105
  }
106
106
  }
107
107
 
108
- // src/cli/lib/metadata-keys.ts
109
- var METADATA_KEYS = {
110
- DISPLAY_NAME: "displayName",
111
- CLI_DESCRIPTION: "cliDescription",
112
- CATEGORY: "category",
113
- FORKED_FROM: "forkedFrom",
114
- CONTENT_HASH: "contentHash",
115
- USAGE_GUIDANCE: "usageGuidance",
116
- CUSTOM: "custom"
117
- };
118
- var LOCAL_DEFAULTS = {
119
- AUTHOR: "@dummy-author"
120
- };
121
- var SKILL_CONTENT_FILES = [STANDARD_FILES.SKILL_MD, STANDARD_FILES.REFERENCE_MD];
122
- var SKILL_CONTENT_DIRS = [STANDARD_DIRS.EXAMPLES, STANDARD_DIRS.SCRIPTS];
123
-
124
- // src/cli/utils/errors.ts
125
- function getErrorMessage(error) {
126
- return stripTerminalControls(error instanceof Error ? error.message : String(error));
127
- }
128
-
129
- // src/cli/utils/fs.ts
130
- import fs3 from "fs-extra";
131
- import fg from "fast-glob";
132
- import os3 from "os";
133
- import path2 from "path";
134
-
135
108
  // src/cli/lib/installation/install-layout.ts
136
109
  import fs2 from "fs";
137
110
  import os2 from "os";
@@ -490,8 +463,9 @@ function sourceRootOf(root) {
490
463
  return { dir: path.join(root, SOURCE_ROOT_DIR), relName: SOURCE_ROOT_DIR };
491
464
  }
492
465
  var RETIRED_SOURCE_FOLDER = ".claude-src";
493
- function retiredSourceFolderIn(roots) {
494
- return [...new Set(roots)].filter(holdsTheRetiredSourceFolder);
466
+ function rootsHoldingTheRetiredSourceFolder(cwd) {
467
+ const roots = isHomeDirectory(cwd) ? [os2.homedir()] : [os2.homedir(), cwd];
468
+ return roots.filter(holdsTheRetiredSourceFolder);
495
469
  }
496
470
  function holdsTheRetiredSourceFolder(root) {
497
471
  return directoryExists(path.join(root, RETIRED_SOURCE_FOLDER));
@@ -504,11 +478,40 @@ var providerChosenForThisRun;
504
478
  function chooseProviderForThisRun(provider) {
505
479
  providerChosenForThisRun = provider;
506
480
  }
481
+ function forgetTheProviderChosenForThisRun() {
482
+ providerChosenForThisRun = void 0;
483
+ }
484
+ var declaresNothingAsRead = /* @__PURE__ */ new Map();
485
+ function recordWhetherItDeclaresNothing(configPath, declaresNothing) {
486
+ const stamp = stampOf(configPath);
487
+ if (stamp !== null) declaresNothingAsRead.set(configPath, { stamp, declaresNothing });
488
+ }
489
+ function declaresNothingAsLastRead(configPath) {
490
+ const read = declaresNothingAsRead.get(configPath);
491
+ if (read === void 0 || read.stamp !== stampOf(configPath)) return void 0;
492
+ return read.declaresNothing;
493
+ }
494
+ function stampOf(file) {
495
+ try {
496
+ const stats = fs2.statSync(file, { throwIfNoEntry: false });
497
+ return stats === void 0 ? null : `${stats.mtimeMs}:${stats.size}`;
498
+ } catch {
499
+ return null;
500
+ }
501
+ }
507
502
  function providerInUse(root) {
508
503
  if (providerChosenForThisRun !== void 0) return providerChosenForThisRun;
509
504
  if (root === void 0) return PROVIDER_OF_A_NEW_INSTALLATION;
510
505
  return providerOnDisk(root);
511
506
  }
507
+ function inheritedGlobalProvider(projectDir, own = providerInUse(projectDir)) {
508
+ const home = os2.homedir();
509
+ const inheritsItsOwn = holdsAnInstallation(projectDir, own) && holdsAnInstallation(home, own);
510
+ return inheritsItsOwn ? own : providerInUse(home);
511
+ }
512
+ function providerAtScope(projectDir, scope) {
513
+ return scope === "global" ? inheritedGlobalProvider(projectDir) : providerInUse(projectDir);
514
+ }
512
515
  function providerOnDisk(root) {
513
516
  const live = PROVIDERS.find((provider) => holdsAnInstallation(root, provider));
514
517
  if (live !== void 0) return live;
@@ -516,7 +519,8 @@ function providerOnDisk(root) {
516
519
  return started ?? PROVIDER_OF_A_NEW_INSTALLATION;
517
520
  }
518
521
  function holdsAnInstallation(root, provider) {
519
- return holdsAConfig(sourceDir(root, provider));
522
+ const dir = sourceDir(root, provider);
523
+ return holdsAConfig(dir) && declaresNothingAsLastRead(configIn(dir)) !== true;
520
524
  }
521
525
  function holdsASourceFolder(root, provider) {
522
526
  return holdsAnything(sourceDir(root, provider));
@@ -672,7 +676,10 @@ function advisesOnPermissions(provider) {
672
676
  }
673
677
  }
674
678
  function holdsAConfig(dir) {
675
- return fs2.existsSync(path.join(dir, STANDARD_FILES.CONFIG_TS));
679
+ return fs2.existsSync(configIn(dir));
680
+ }
681
+ function configIn(dir) {
682
+ return path.join(dir, STANDARD_FILES.CONFIG_TS);
676
683
  }
677
684
  function holdsAnything(dir) {
678
685
  return directoryExists(dir) && isNotEmpty(dir);
@@ -692,6 +699,29 @@ function directoryExists(dir) {
692
699
  }
693
700
  }
694
701
 
702
+ // src/cli/lib/metadata-keys.ts
703
+ var METADATA_KEYS = {
704
+ DISPLAY_NAME: "displayName",
705
+ CATEGORY: "category",
706
+ CUSTOM: "custom"
707
+ };
708
+ var LOCAL_DEFAULTS = {
709
+ AUTHOR: "@dummy-author"
710
+ };
711
+ var SKILL_CONTENT_FILES = [STANDARD_FILES.SKILL_MD, STANDARD_FILES.REFERENCE_MD];
712
+ var SKILL_CONTENT_DIRS = [STANDARD_DIRS.EXAMPLES, STANDARD_DIRS.SCRIPTS];
713
+
714
+ // src/cli/utils/errors.ts
715
+ function getErrorMessage(error) {
716
+ return stripTerminalControls(error instanceof Error ? error.message : String(error));
717
+ }
718
+
719
+ // src/cli/utils/fs.ts
720
+ import fs3 from "fs-extra";
721
+ import fg from "fast-glob";
722
+ import os3 from "os";
723
+ import path2 from "path";
724
+
695
725
  // src/cli/lib/config-gate/gate-token.ts
696
726
  import { AsyncLocalStorage } from "async_hooks";
697
727
  var gateToken = new AsyncLocalStorage();
@@ -872,6 +902,7 @@ function warnOnce(msg) {
872
902
 
873
903
  // src/cli/utils/messages.ts
874
904
  import path3 from "path";
905
+ import { partition } from "remeda";
875
906
 
876
907
  // src/cli/lib/validate-kebab-name.ts
877
908
  import { unique } from "remeda";
@@ -953,6 +984,8 @@ var INFO_MESSAGES = {
953
984
  CONFIG_TYPES_REFRESHED: `Refreshed ${STANDARD_FILES.CONFIG_TYPES_TS}`,
954
985
  EJECTED_SKILLS_USER_OWNED: `Ejected skills are yours to own \u2014 '${CLI_INVOKE_COMMAND} update' does not change them.`,
955
986
  NO_PLUGIN_MARKETPLACES: "No plugin marketplaces are configured \u2014 nothing to refresh.",
987
+ /** The owner's words (2026-10-24), on stderr before the command's own output. */
988
+ GLOBAL_INSTALLATION_STANDS_IN: "This project's config declares nothing, so this works on your global installation.",
956
989
  /** Under doctor's marketplace row, when its download replaced a saved copy whose files differed. */
957
990
  SAVED_COPY_REPLACED: "The saved copy differed from the marketplace and has been replaced",
958
991
  /** Printed under the destination already named, so it names files only. */
@@ -967,8 +1000,8 @@ function pluginsInstalled(count) {
967
1000
  function localSkillsCopied(count) {
968
1001
  return `Copied ${count} local skill(s)`;
969
1002
  }
970
- function recompileSummary(rewritten, unchanged, subject) {
971
- return `${plural(rewritten, subject)} rewritten, ${unchanged} unchanged`;
1003
+ function recompileSummary(rewritten2, unchanged, subject) {
1004
+ return `${plural(rewritten2, subject)} rewritten, ${unchanged} unchanged`;
972
1005
  }
973
1006
  function agentsNotCompiled(agentNames) {
974
1007
  return `${agentNames.length} sub-agent(s) did not compile: ${agentNames.join(", ")}`;
@@ -1012,6 +1045,9 @@ function marketplaceRefreshFailed(marketplace, reason) {
1012
1045
  function sourceUnreachableUsingCache(source) {
1013
1046
  return `Could not reach ${source} \u2014 using the cached copy, which may be out of date.`;
1014
1047
  }
1048
+ function sourceRefusedUsingCache(source, status) {
1049
+ return `${source} refused the request (${status}) \u2014 using the cached copy, which may be out of date.`;
1050
+ }
1015
1051
  function marketplacesRefreshFailed(marketplaces) {
1016
1052
  return `${plural(marketplaces.length, "marketplace")} could not be updated: ${marketplaces.join(", ")}`;
1017
1053
  }
@@ -1160,14 +1196,27 @@ function changeTheGlobalInstallFromHome(named) {
1160
1196
  function unknownKeys(keys) {
1161
1197
  return keys.map(inertLine).join(", ");
1162
1198
  }
1163
- function skippedUnknownSkills(skillIds, installedWithout) {
1199
+ var SKIP_CAUSE = {
1200
+ UNLOADED: "could not load",
1201
+ UNKNOWN: "does not know"
1202
+ };
1203
+ function skippedSkills(skillIds, installedWithout, unloadedSkillIds) {
1204
+ const [unloaded, unknown] = partition(skillIds, (id) => unloadedSkillIds.has(id));
1164
1205
  return [
1165
- `Skipped ${skillIds.length} skill(s) this catalog does not know: ${unknownKeys(skillIds)}`,
1166
- ...installedWithout.map(
1167
- ({ skillId, agentNames }) => ` sub-agent(s) installed without ${unknownKeys([skillId])}, carrying nothing else this catalog knows: ${agentNames.join(", ")}`
1168
- )
1206
+ ...skippedFor(SKIP_CAUSE.UNLOADED, unloaded, installedWithout),
1207
+ ...skippedFor(SKIP_CAUSE.UNKNOWN, unknown, installedWithout)
1169
1208
  ].join("\n");
1170
1209
  }
1210
+ function skippedFor(cause, skillIds, installedWithout) {
1211
+ if (skillIds.length === 0) return [];
1212
+ return [
1213
+ `Skipped ${skillIds.length} skill(s) this catalog ${cause}: ${unknownKeys(skillIds)}`,
1214
+ ...installedWithout.filter(({ skillId }) => skillIds.includes(skillId)).map(subAgentsInstalledWithout)
1215
+ ];
1216
+ }
1217
+ function subAgentsInstalledWithout({ skillId, agentNames }) {
1218
+ return ` sub-agent(s) installed without ${unknownKeys([skillId])}, carrying nothing else this catalog knows: ${agentNames.join(", ")}`;
1219
+ }
1171
1220
  function skippedUnknownAgents(agentNames) {
1172
1221
  return `Skipped ${agentNames.length} unknown sub-agent(s): ${unknownKeys(agentNames)}`;
1173
1222
  }
@@ -1205,18 +1254,22 @@ function addMarketplaceInTheEditor(ref, isFolder) {
1205
1254
  var SHARED_CONFIG_ARRIVALS = {
1206
1255
  INSTALL_CONFIRM: "Install this configuration?"
1207
1256
  };
1208
- function keptAsInstalledGlobally(skillIds, agentNames, idAppliedAtHome, provider) {
1257
+ function skillName(id, namedBy) {
1258
+ return getSkillEntryDisplayName(namedBy[id] ?? { id });
1259
+ }
1260
+ function keptAsInstalledGlobally(skillIds, agentNames, idAppliedAtHome, provider, namedBy) {
1209
1261
  return [
1210
1262
  "Kept as installed in the global install \u2014 this configuration states them differently or leaves them out, and a project run only adds to the global install:",
1211
- ...skillIds.map((id) => ` skill ${id}`),
1263
+ ...skillIds.map((id) => ` skill ${skillName(id, namedBy)}`),
1212
1264
  ...agentNames.map((name) => ` sub-agent ${name}`),
1213
1265
  ...idAppliedAtHome === void 0 ? [] : [
1214
1266
  `Change them with '${CLI_INVOKE_COMMAND} edit --from ${idAppliedAtHome}${providerArgument(provider)}' from your home directory.`
1215
1267
  ]
1216
1268
  ].join("\n");
1217
1269
  }
1218
- function skillsMoved(verb, skillIds) {
1219
- return skillIds.length === 0 ? [] : [`${verb} ${listed(skillIds.map(getSkillDisplayName))}`];
1270
+ function skillsMoved(verb, skillIds, namedBy) {
1271
+ const names = skillIds.map((id) => skillName(id, namedBy));
1272
+ return names.length === 0 ? [] : [`${verb} ${listed(names)}`];
1220
1273
  }
1221
1274
  function settingMoved({ setting, from, to }) {
1222
1275
  return `${setting} ${from ?? "default"} \u2192 ${to ?? "default"}`;
@@ -1226,38 +1279,44 @@ function listed(names) {
1226
1279
  return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
1227
1280
  }
1228
1281
  var SKILLS_REASSIGNED = "skills reassigned";
1229
- function subAgentChanged({ name, scope, gains, loses, settings }) {
1282
+ function subAgentChanged({
1283
+ name,
1284
+ scope,
1285
+ gains,
1286
+ loses,
1287
+ settings,
1288
+ namedBy = {}
1289
+ }) {
1230
1290
  const details = [
1231
- ...skillsMoved("gains", gains),
1232
- ...skillsMoved("loses", loses),
1291
+ ...skillsMoved("gains", gains, namedBy),
1292
+ ...skillsMoved("loses", loses, namedBy),
1233
1293
  ...settings.map(settingMoved)
1234
1294
  ];
1235
1295
  const where = scope === "global" ? " (global)" : "";
1236
1296
  return `~ ${name}${where}: ${details.length > 0 ? details.join(", ") : SKILLS_REASSIGNED}`;
1237
1297
  }
1238
- function addedToGlobalSubAgents(joined) {
1298
+ function addedToGlobalSubAgents(joined, namedBy) {
1299
+ const gains = (skillIds) => skillIds.map((id) => skillName(id, namedBy)).join(", ");
1239
1300
  return [
1240
1301
  "Added to sub-agents in the global install \u2014 each keeps everything it already has, since a project run only adds to the global install:",
1241
- ...joined.map(
1242
- ({ agentName, skillIds }) => ` sub-agent ${agentName}: + ${skillIds.join(", ")}`
1243
- )
1302
+ ...joined.map(({ agentName, skillIds }) => ` sub-agent ${agentName}: + ${gains(skillIds)}`)
1244
1303
  ].join("\n");
1245
1304
  }
1246
- function authoredHereKept(skillIds) {
1305
+ function authoredHereKept(skillIds, namedBy) {
1247
1306
  return [
1248
1307
  "Kept \u2014 written here rather than installed, so a shared configuration never carried them:",
1249
- ...skillIds.map((id) => ` skill ${id}`)
1308
+ ...skillIds.map((id) => ` skill ${skillName(id, namedBy)}`)
1250
1309
  ].join("\n");
1251
1310
  }
1252
- function unplaceableKept(skillIds) {
1311
+ function unplaceableKept(skillIds, namedBy) {
1253
1312
  return [
1254
1313
  "Kept \u2014 named by this configuration, and this catalogue cannot place them:",
1255
- ...skillIds.map((id) => ` skill ${id}`),
1314
+ ...skillIds.map((id) => ` skill ${skillName(id, namedBy)}`),
1256
1315
  `Run '${CLI_INVOKE_COMMAND} update' to refresh this installation's marketplace, then apply the configuration again.`
1257
1316
  ].join("\n");
1258
1317
  }
1259
- function keptUnassigned(skillId, agentName, category) {
1260
- return `${skillId}: kept, no longer assigned to ${agentName}'s ${category}`;
1318
+ function keptUnassigned({ skillId, agentName, category }, namedBy) {
1319
+ return `${skillName(skillId, namedBy)}: kept, no longer assigned to ${agentName}'s ${category}`;
1261
1320
  }
1262
1321
  function doctorReportsTheSame(count) {
1263
1322
  return `'${CLI_INVOKE_COMMAND} doctor' reports the same ${count === 1 ? "file" : "files"}, alongside whatever else is wrong here.`;
@@ -1318,8 +1377,9 @@ function sentenceCase(text) {
1318
1377
  function layoutIsCurrent(label, to) {
1319
1378
  return `${label} is on ${to}/`;
1320
1379
  }
1321
- function retiredSourceFolderUnsupported(root) {
1322
- return `${path3.join(root, RETIRED_SOURCE_FOLDER)}/ is no longer supported (agents-inc now serves Claude and Codex). Move it to ${path3.join(root, sourceDirName("claude"))}/.`;
1380
+ function retiredSourceFolderIgnored(root, provider) {
1381
+ const named = isHomeDirectory(root) ? "~" : root;
1382
+ return `${path3.join(named, RETIRED_SOURCE_FOLDER)}/ is ignored; agents-inc reads ${path3.join(named, sourceDirName(provider))}/. Delete the old folder once you have kept anything you need from it.`;
1323
1383
  }
1324
1384
 
1325
1385
  // src/cli/types/generated/source-types.ts
@@ -1951,16 +2011,16 @@ import { z as z3 } from "zod";
1951
2011
 
1952
2012
  // src/cli/lib/schemas.ts
1953
2013
  import { z as z2 } from "zod";
1954
- import { partition } from "remeda";
2014
+ import { partition as partition2 } from "remeda";
1955
2015
 
1956
2016
  // src/cli/lib/schema-validator.ts
1957
2017
  import "zod";
1958
2018
  function formatZodIssue(issue) {
1959
- const path30 = stripTerminalControls(issue.path.join("."));
1960
2019
  if (issue.code === "unrecognized_keys") {
1961
- return `Unrecognized key: "${stripTerminalControls(issue.keys.join('", "'))}"`;
2020
+ return `Unrecognized key: "${inertLine(issue.keys.join('", "'))}"`;
1962
2021
  }
1963
- return path30 ? `${path30}: ${stripTerminalControls(issue.message)}` : stripTerminalControls(issue.message);
2022
+ const path29 = inertLine(issue.path.join("."));
2023
+ return path29 ? `${path29}: ${inertLine(issue.message)}` : inertLine(issue.message);
1964
2024
  }
1965
2025
  function formatZodErrors(error) {
1966
2026
  return error.issues.map(formatZodIssue);
@@ -2102,12 +2162,12 @@ var RENAMED_SKILL_ENTRY_FIELDS = { source: "origin" };
2102
2162
  function renamedFieldMessage(oldKey, newKey) {
2103
2163
  return `"${oldKey}" was renamed to "${newKey}". Rename the key in this config \u2014 the CLI does not read "${oldKey}" any more and will not fall back to it.`;
2104
2164
  }
2105
- function reportRenamedKeys(record, renames, path30, ctx) {
2165
+ function reportRenamedKeys(record, renames, path29, ctx) {
2106
2166
  for (const [oldKey, newKey] of Object.entries(renames)) {
2107
2167
  if (!(oldKey in record)) continue;
2108
2168
  ctx.addIssue({
2109
2169
  code: "custom",
2110
- path: [...path30, oldKey],
2170
+ path: [...path29, oldKey],
2111
2171
  message: renamedFieldMessage(oldKey, newKey)
2112
2172
  });
2113
2173
  }
@@ -2141,6 +2201,7 @@ var projectConfigFields = z2.object({
2141
2201
  id: z2.string(),
2142
2202
  scope: z2.enum(["project", "global"]),
2143
2203
  origin: z2.string(),
2204
+ displayName: z2.string().exactOptional(),
2144
2205
  excluded: z2.boolean().exactOptional()
2145
2206
  })
2146
2207
  ).exactOptional(),
@@ -2437,7 +2498,7 @@ function metadataSchemaFor(raw) {
2437
2498
  return isCarriedMetadata(raw) ? carriedMetadataValidationSchema : customMetadataValidationSchema;
2438
2499
  }
2439
2500
  function describeMetadataSchemaFailure(issues, rawMetadata) {
2440
- const [absent, malformed] = partition(issues, (issue) => isAbsentField(issue, rawMetadata));
2501
+ const [absent, malformed] = partition2(issues, (issue) => isAbsentField(issue, rawMetadata));
2441
2502
  return [
2442
2503
  ...absent.length > 0 ? [nameMissingFields(absent)] : [],
2443
2504
  ...malformed.map(formatZodIssue)
@@ -2464,7 +2525,7 @@ function formatOverLengthWarning(issue, cliDescription) {
2464
2525
  return `cliDescription is ${cliDescription.length} characters \u2014 exceeds the recommended maximum of ${CLI_DESCRIPTION_MAX_LENGTH}`;
2465
2526
  }
2466
2527
  function splitMetadataValidationIssues(error, rawMetadata) {
2467
- const [overLength, hardFailures] = partition(error.issues, isOverLengthCliDescription);
2528
+ const [overLength, hardFailures] = partition2(error.issues, isOverLengthCliDescription);
2468
2529
  const cliDescription = readCliDescription(rawMetadata);
2469
2530
  const warnings = overLength.map((issue) => formatOverLengthWarning(issue, cliDescription));
2470
2531
  return { errors: hardFailures.map(formatZodIssue), warnings };
@@ -2581,7 +2642,7 @@ function getInstalledConfigPath(dir) {
2581
2642
  }
2582
2643
  function resolveInstallPaths(projectDir, scope = "project") {
2583
2644
  const baseDir = installBaseDir(projectDir, scope);
2584
- const provider = providerInUse(baseDir);
2645
+ const provider = providerAtScope(projectDir, scope);
2585
2646
  return {
2586
2647
  skillsDir: skillsDir(provider, scope, projectDir),
2587
2648
  agentsDir: agentsDir(provider, scope, projectDir),
@@ -2671,13 +2732,16 @@ async function loadSourceRepoConfig(basePath) {
2671
2732
  async function loadProjectSourceConfig(projectDir) {
2672
2733
  return loadSourceConfig(projectDir, isHomeDirectory(projectDir) ? "global" : "project");
2673
2734
  }
2674
- async function loadGlobalSourceConfig() {
2675
- return loadSourceConfig(os4.homedir(), "global");
2735
+ async function loadGlobalSourceConfig(provider) {
2736
+ return loadSourceConfig(os4.homedir(), "global", provider);
2676
2737
  }
2677
2738
  async function loadEffectiveSourceConfig(projectDir, provider) {
2678
2739
  const ownDir = ownProjectDir(projectDir);
2679
2740
  const own = ownDir === null ? null : await readStoredRung(ownDir, "project", provider);
2680
- return own ?? await readStoredRung(os4.homedir(), "global", provider);
2741
+ return own ?? await readStoredRung(os4.homedir(), "global", provider ?? inheritedBy(projectDir));
2742
+ }
2743
+ function inheritedBy(projectDir) {
2744
+ return inheritedGlobalProvider(projectDir ?? os4.homedir());
2681
2745
  }
2682
2746
  async function readStoredRung(dir, origin, provider) {
2683
2747
  const config = await loadSourceConfig(dir, origin, provider);
@@ -2776,7 +2840,7 @@ ${getErrorMessage(error)}`
2776
2840
  async function resolveBranding(projectDir) {
2777
2841
  const [own, global] = await Promise.all([
2778
2842
  loadOwnProjectSourceConfig(projectDir),
2779
- loadGlobalSourceConfig()
2843
+ loadGlobalSourceConfig(inheritedBy(projectDir))
2780
2844
  ]);
2781
2845
  return {
2782
2846
  name: own?.branding?.name ?? global?.branding?.name ?? DEFAULT_BRANDING.NAME
@@ -3122,7 +3186,7 @@ seatDiagnostics({
3122
3186
  });
3123
3187
 
3124
3188
  // ../compile/src/seed-to-config.ts
3125
- import { groupBy, indexBy, isDefined, mapValues, omit as omit2, partition as partition2 } from "remeda";
3189
+ import { groupBy, indexBy, isDefined, mapValues, omit as omit2, partition as partition3 } from "remeda";
3126
3190
 
3127
3191
  // ../compile/src/config-source.ts
3128
3192
  import { omit } from "remeda";
@@ -3357,6 +3421,7 @@ var CANONICAL_SKILL_ENTRY_ORDER = [
3357
3421
  "id",
3358
3422
  "scope",
3359
3423
  "origin",
3424
+ "displayName",
3360
3425
  "excluded"
3361
3426
  ];
3362
3427
  var CANONICAL_AGENT_ENTRY_ORDER = [
@@ -3638,12 +3703,12 @@ function mergeInlinedScalarFields(cleaned, cleanedGlobal) {
3638
3703
  ).filter(([key]) => isCopiedScalarField(key));
3639
3704
  }
3640
3705
  function generateProjectConfigWithInlinedGlobal(cleaned, cleanedGlobal) {
3641
- const partition5 = partitionInlinedConfigEntries(cleaned, cleanedGlobal);
3706
+ const partition6 = partitionInlinedConfigEntries(cleaned, cleanedGlobal);
3642
3707
  const emitted = {
3643
- hasSkills: partition5.globalSkills.length > 0 || partition5.projectSkills.length > 0,
3644
- hasAgents: partition5.globalAgents.length > 0 || partition5.projectAgents.length > 0,
3645
- hasStack: hasStackEntries(partition5.filteredStack),
3646
- hasSelectedDomains: partition5.selectedDomains.length > 0
3708
+ hasSkills: partition6.globalSkills.length > 0 || partition6.projectSkills.length > 0,
3709
+ hasAgents: partition6.globalAgents.length > 0 || partition6.projectAgents.length > 0,
3710
+ hasStack: hasStackEntries(partition6.filteredStack),
3711
+ hasSelectedDomains: partition6.selectedDomains.length > 0
3647
3712
  };
3648
3713
  const scalarFields = mergeInlinedScalarFields(cleaned, cleanedGlobal);
3649
3714
  return assembleConfigSource({
@@ -3654,15 +3719,15 @@ function generateProjectConfigWithInlinedGlobal(cleaned, cleanedGlobal) {
3654
3719
  ...emitted.hasSkills ? entryDeclaration(
3655
3720
  "skills",
3656
3721
  "SkillConfig[]",
3657
- scopeSectionEntries(partition5.globalSkills, partition5.projectSkills)
3722
+ scopeSectionEntries(partition6.globalSkills, partition6.projectSkills)
3658
3723
  ) : [],
3659
3724
  ...emitted.hasAgents ? entryDeclaration(
3660
3725
  "agents",
3661
3726
  "AgentScopeConfig[]",
3662
- scopeSectionEntries(partition5.globalAgents, partition5.projectAgents)
3727
+ scopeSectionEntries(partition6.globalAgents, partition6.projectAgents)
3663
3728
  ) : [],
3664
- ...emitted.hasStack ? declaration("stack", STACK_TYPE, partition5.filteredStack) : [],
3665
- ...emitted.hasSelectedDomains ? declaration("selectedDomains", "Domain[]", partition5.selectedDomains) : []
3729
+ ...emitted.hasStack ? declaration("stack", STACK_TYPE, partition6.filteredStack) : [],
3730
+ ...emitted.hasSelectedDomains ? declaration("selectedDomains", "Domain[]", partition6.selectedDomains) : []
3666
3731
  ],
3667
3732
  exportFields: [
3668
3733
  renderScalarField("name", resolveProjectName(cleaned)),
@@ -3817,7 +3882,7 @@ function assertScopeConfigsGiven(skillConfigs, agentConfigs) {
3817
3882
  }
3818
3883
  }
3819
3884
  function resolveValidSkills(selectedSkillIds, skillConfigs, catalog) {
3820
- const [found, absent] = partition2(
3885
+ const [found, absent] = partition3(
3821
3886
  selectedSkillIds.map((skillId) => ({
3822
3887
  skillId,
3823
3888
  skill: catalog.skills[skillId]
@@ -3867,7 +3932,7 @@ function skillIdsByCategory(skills) {
3867
3932
  );
3868
3933
  }
3869
3934
  function buildSkillScopeMap(skillConfigs) {
3870
- const [excludedConfigs, activeConfigs] = partition2(
3935
+ const [excludedConfigs, activeConfigs] = partition3(
3871
3936
  skillConfigs,
3872
3937
  (s) => Boolean(s.excluded)
3873
3938
  );
@@ -4012,11 +4077,11 @@ function mapCategoriesDroppingEmpty(agentStack, transform) {
4012
4077
  );
4013
4078
  }
4014
4079
  function splitConfigByScope(config) {
4015
- const [globalSkills, projectSkills] = partition2(
4080
+ const [globalSkills, projectSkills] = partition3(
4016
4081
  config.skills,
4017
4082
  (s) => isActiveAt(s, "global")
4018
4083
  );
4019
- const [globalAgents, projectAgents] = partition2(
4084
+ const [globalAgents, projectAgents] = partition3(
4020
4085
  config.agents,
4021
4086
  (a) => isActiveAt(a, "global")
4022
4087
  );
@@ -4076,9 +4141,9 @@ function splitAgentStack(agentStack, globalSkillIds) {
4076
4141
  }
4077
4142
  function seedToInstallSelection(payload, catalog) {
4078
4143
  const agentMap = readAgentMap(payload.agents);
4144
+ refuseUnwritableAssignments(payload.skills, agentMap);
4079
4145
  const { installable, skipped } = resolveSeedSkills(payload.skills, catalog);
4080
4146
  const rows = installable.flatMap((skill) => assignmentRows(skill, agentMap));
4081
- refuseUnwritableAssignments(rows);
4082
4147
  const placed = rows.filter((row) => row.kind === "placed");
4083
4148
  const carried = new Set(agentsCarriedIn(placed, agentMap));
4084
4149
  const selectedAgents = withAgentsSkippedSkillsName(carried, skipped, agentMap);
@@ -4112,12 +4177,23 @@ function seedToInstallSelection(payload, catalog) {
4112
4177
  )
4113
4178
  };
4114
4179
  }
4115
- function refuseUnwritableAssignments(rows) {
4116
- const unwritable = rows.filter((row) => row.kind === "unwritable");
4180
+ function refuseUnwritableAssignments(seedSkills, agentMap) {
4181
+ const unwritable = unwritableAssignmentsOf(seedSkills, agentMap);
4117
4182
  if (unwritable.length > 0) {
4118
4183
  throw new Error(unwritableAssignmentsError(unwritable));
4119
4184
  }
4120
4185
  }
4186
+ function unwritableAssignmentsOf(seedSkills, agentMap) {
4187
+ return Object.entries(seedSkills).flatMap(
4188
+ ([skillId, seedSkill]) => agentsNamedBy(seedSkill, agentMap).filter((agent) => !isWritablePair(seedSkill, agent, agentMap)).map((agent) => ({ skillId, agent }))
4189
+ );
4190
+ }
4191
+ function isWritablePair(seedSkill, agent, agentMap) {
4192
+ return isScopePairCompatible(
4193
+ seedSkill.scope,
4194
+ seedAgentScope(agentMap.known.get(agent))
4195
+ );
4196
+ }
4121
4197
  function agentsCarriedIn(placed, agentMap) {
4122
4198
  return [...placed.map((row) => row.agent), ...agentsSwitchedOn(agentMap)];
4123
4199
  }
@@ -4125,7 +4201,7 @@ function withAgentsSkippedSkillsName(carried, skipped, agentMap) {
4125
4201
  return [
4126
4202
  .../* @__PURE__ */ new Set([
4127
4203
  ...carried,
4128
- ...skipped.flatMap((skill) => agentsNamedBy(skill, agentMap))
4204
+ ...skipped.flatMap((skill) => agentsNamedBy(skill.seedSkill, agentMap))
4129
4205
  ])
4130
4206
  ];
4131
4207
  }
@@ -4133,11 +4209,11 @@ function skippedAgentNamesOf(agentMap, rows) {
4133
4209
  const unknownAssignees = rows.filter((row) => row.kind === "unknownAgent").map((row) => row.agentName);
4134
4210
  return [.../* @__PURE__ */ new Set([...agentMap.unknown, ...unknownAssignees])];
4135
4211
  }
4136
- function agentsNamedBy({ seedSkill }, agentMap) {
4212
+ function agentsNamedBy(seedSkill, agentMap) {
4137
4213
  return Object.keys(seedSkill.assignments).filter(isAgentName2).filter((name) => !agentMap.switchedOff.has(name));
4138
4214
  }
4139
4215
  function agentsOnlyItCarried(skill, agentMap, carried) {
4140
- const agentNames = agentsNamedBy(skill, agentMap).filter(
4216
+ const agentNames = agentsNamedBy(skill.seedSkill, agentMap).filter(
4141
4217
  (name) => !carried.has(name)
4142
4218
  );
4143
4219
  return agentNames.length === 0 ? [] : [{ skillId: skill.skillId, agentNames }];
@@ -4188,7 +4264,8 @@ function toSeedSkillConfig({
4188
4264
  return {
4189
4265
  id,
4190
4266
  scope: seedSkill.scope,
4191
- origin: seedSkill.install === "eject" ? EJECT_SOURCE : sourceForSkill(catalogSkill)
4267
+ origin: seedSkill.install === "eject" ? EJECT_SOURCE : sourceForSkill(catalogSkill),
4268
+ displayName: catalogSkill.displayName
4192
4269
  };
4193
4270
  }
4194
4271
  function sourceForSkill(skill) {
@@ -4200,10 +4277,6 @@ function assignmentRows(skill, agentMap) {
4200
4277
  function assignmentRow(skill, agentName, load, agentMap) {
4201
4278
  if (agentMap.switchedOff.has(agentName)) return void 0;
4202
4279
  if (!isAgentName2(agentName)) return { kind: "unknownAgent", agentName };
4203
- const agentScope = seedAgentScope(agentMap.known.get(agentName));
4204
- if (!isScopePairCompatible(skill.seedSkill.scope, agentScope)) {
4205
- return { kind: "unwritable", skillId: skill.id, agent: agentName };
4206
- }
4207
4280
  return {
4208
4281
  kind: "placed",
4209
4282
  agent: agentName,
@@ -4262,7 +4335,7 @@ import path8 from "path";
4262
4335
 
4263
4336
  // src/cli/lib/stacks/stacks-loader.ts
4264
4337
  import path7 from "path";
4265
- import { flatMap, groupBy as groupBy2, mapValues as mapValues2, partition as partition3, pipe, unique as unique2, uniqueBy } from "remeda";
4338
+ import { flatMap, groupBy as groupBy2, mapValues as mapValues2, partition as partition4, pipe, unique as unique2, uniqueBy } from "remeda";
4266
4339
  var stacksCache = /* @__PURE__ */ new Map();
4267
4340
  function normalizeAgentConfig(agentConfig) {
4268
4341
  return mapValues2(agentConfig, (value) => {
@@ -4293,7 +4366,7 @@ function placeAssignments(agentConfig) {
4293
4366
  );
4294
4367
  }
4295
4368
  function rekeyToLiveCategories(agentConfig) {
4296
- const [settled, moved] = partition3(
4369
+ const [settled, moved] = partition4(
4297
4370
  placeAssignments(agentConfig),
4298
4371
  (placed) => placed.liveCategory === placed.storedCategory
4299
4372
  );
@@ -4418,6 +4491,14 @@ var ConfigLoadError = class extends Error {
4418
4491
  /** Named in the remedy's `init --from` half, which a bare run would answer with another one. */
4419
4492
  initProviderToName;
4420
4493
  };
4494
+ function declaresNoContent(config) {
4495
+ return config.skills.length === 0 && config.agents.length === 0;
4496
+ }
4497
+ async function configDeclaresNothing(projectDir, provider) {
4498
+ const configPath = getProjectConfigPath(projectDir, provider);
4499
+ const parsed = await parseConfigFile(configPath, refusalAt(configPath, projectDir, provider));
4500
+ return declaresNoContent({ skills: parsed.skills ?? [], agents: parsed.agents ?? [] });
4501
+ }
4421
4502
  async function loadProjectConfigFromDir(projectDir, provider) {
4422
4503
  return loadProjectConfigAt(getProjectConfigPath(projectDir, provider), projectDir, provider);
4423
4504
  }
@@ -4428,8 +4509,7 @@ async function loadProjectConfigAt(configPath, projectDir, provider) {
4428
4509
  verbose(`${scopeLabel2} config not found at ${configPath}`);
4429
4510
  return null;
4430
4511
  }
4431
- const refuse = (reason) => new ConfigLoadError(configPath, reason, projectDir, provider);
4432
- const parsed = await parseConfigFile(configPath, refuse);
4512
+ const parsed = await parseConfigFile(configPath, refusalAt(configPath, projectDir, provider));
4433
4513
  const config = asProjectConfig(parsed, projectDir);
4434
4514
  warnOfDefaultedFields(parsed, configPath);
4435
4515
  verbose(`Loaded ${scope} config from ${configPath}`);
@@ -4439,6 +4519,9 @@ async function loadProjectConfigAt(configPath, projectDir, provider) {
4439
4519
  provider
4440
4520
  };
4441
4521
  }
4522
+ function refusalAt(configPath, projectDir, provider) {
4523
+ return (reason) => new ConfigLoadError(configPath, reason, projectDir, provider);
4524
+ }
4442
4525
  async function parseConfigFile(configPath, refuse) {
4443
4526
  let raw;
4444
4527
  try {
@@ -4474,29 +4557,39 @@ function warnOfDefaultedFields(parsed, configPath) {
4474
4557
  async function loadInstalledConfig(dir) {
4475
4558
  return loadProjectConfigFromDir(dir, providerInUse(dir));
4476
4559
  }
4477
- function configDirsInPlay(projectDir) {
4478
- return isHomeDirectory(projectDir) ? [projectDir] : [projectDir, os5.homedir()];
4560
+ function configsInPlay(projectDir) {
4561
+ const own = { dir: projectDir, provider: providerInUse(projectDir) };
4562
+ if (isHomeDirectory(projectDir)) return [own];
4563
+ return [own, { dir: os5.homedir(), provider: inheritedGlobalProvider(projectDir) }];
4479
4564
  }
4480
4565
  async function findConfigLoadFailures(projectDir) {
4481
- const outcomes = await Promise.all(configDirsInPlay(projectDir).map(configLoadFailure2));
4566
+ const outcomes = await Promise.all(configsInPlay(projectDir).map(configLoadFailure2));
4482
4567
  return outcomes.filter((failure) => failure !== void 0);
4483
4568
  }
4484
- async function configLoadFailure2(dir) {
4569
+ async function configLoadFailure2({
4570
+ dir,
4571
+ provider
4572
+ }) {
4485
4573
  try {
4486
- await loadInstalledConfig(dir);
4574
+ await loadProjectConfigFromDir(dir, provider);
4487
4575
  return void 0;
4488
4576
  } catch (error) {
4489
4577
  if (error instanceof ConfigLoadError) return error;
4490
4578
  throw error;
4491
4579
  }
4492
4580
  }
4493
- async function loadProjectConfig(projectDir) {
4494
- const provider = providerInUse(projectDir);
4581
+ async function loadProjectConfig(projectDir, provider = providerInUse(projectDir)) {
4495
4582
  const projectResult = await loadProjectConfigFromDir(projectDir, provider);
4496
4583
  if (projectResult) return projectResult;
4497
4584
  if (isHomeDirectory(projectDir)) return null;
4498
4585
  return loadProjectConfigFromDir(os5.homedir(), provider);
4499
4586
  }
4587
+ async function loadConfigInPlay(projectDir) {
4588
+ const own = await loadInstalledConfig(projectDir);
4589
+ if (isHomeDirectory(projectDir)) return own;
4590
+ if (own !== null && !declaresNoContent(own.config)) return own;
4591
+ return loadInstalledConfig(os5.homedir());
4592
+ }
4500
4593
  function validateProjectConfig(config) {
4501
4594
  const result = projectConfigLoaderSchema.safeParse(config);
4502
4595
  if (!result.success) {
@@ -4851,6 +4944,21 @@ async function copySkillsToLocalFlattened(selectedSkillIds, localSkillsDir, sour
4851
4944
  (skillId) => copySelectedSkill(skillId, localSkillsDir, sourceResult, sourceSelections?.[skillId])
4852
4945
  );
4853
4946
  }
4947
+ async function copyMarketplaceSkillsToLocalFlattened(marketplaceSkillIds, localSkillsDir, sourceResult) {
4948
+ return copyEachSkill(
4949
+ marketplaceSkillIds,
4950
+ (skillId) => copySkillToLocalFlattened(
4951
+ marketplaceSkillOf(skillId, sourceResult),
4952
+ localSkillsDir,
4953
+ sourceResult
4954
+ )
4955
+ );
4956
+ }
4957
+ function marketplaceSkillOf(skillId, sourceResult) {
4958
+ const skill = sourceResult.marketplaceSkills[skillId];
4959
+ if (!skill) throw new Error(`Not one of the marketplace's skills: ${skillId}`);
4960
+ return skill;
4961
+ }
4854
4962
  async function copySelectedSkill(skillId, localSkillsDir, sourceResult, selectedSource) {
4855
4963
  const skill = getSkillById(skillId);
4856
4964
  const localPath = picksRemoteSource(selectedSource) ? void 0 : localPathOf(skill);
@@ -4877,7 +4985,7 @@ async function copyLocalSkillTo(skill, localPath, destPath) {
4877
4985
  }
4878
4986
 
4879
4987
  // src/cli/lib/skills/skill-plugin-compiler.ts
4880
- import path24 from "path";
4988
+ import path23 from "path";
4881
4989
  import { parse as parseYaml4 } from "yaml";
4882
4990
 
4883
4991
  // src/cli/lib/plugins/plugin-manifest.ts
@@ -4984,7 +5092,6 @@ import { readdir } from "fs/promises";
4984
5092
 
4985
5093
  // src/cli/lib/installation/installation.ts
4986
5094
  import os7 from "os";
4987
- import path14 from "path";
4988
5095
  var INSTALL_MODE_LABELS = {
4989
5096
  plugin: "Plugin",
4990
5097
  mixed: "Mixed",
@@ -4994,9 +5101,6 @@ var INSTALL_MODE_DESCRIPTIONS = {
4994
5101
  plugin: `${INSTALL_MODE_LABELS.plugin} (native install)`,
4995
5102
  eject: `${INSTALL_MODE_LABELS.eject} (local copy)`
4996
5103
  };
4997
- function declaresNoContent(config) {
4998
- return config.skills.length === 0 && config.agents.length === 0;
4999
- }
5000
5104
  function deriveInstallMode(skills) {
5001
5105
  if (skills.length === 0) return "eject";
5002
5106
  const hasEject = skills.some((s) => s.origin === EJECT_SOURCE);
@@ -5004,8 +5108,7 @@ function deriveInstallMode(skills) {
5004
5108
  if (hasEject && hasPlugin) return "mixed";
5005
5109
  return hasEject ? "eject" : "plugin";
5006
5110
  }
5007
- async function detectInstallationInDir(dir, scope) {
5008
- const provider = providerInUse(dir);
5111
+ async function detectInstallationInDir(dir, scope, provider = providerInUse(dir)) {
5009
5112
  const configPath = getProjectConfigPath(dir, provider);
5010
5113
  if (!await fileExists(configPath)) {
5011
5114
  return null;
@@ -5017,17 +5120,10 @@ async function detectInstallationInDir(dir, scope) {
5017
5120
  if (declaresNoContent(loaded.config)) {
5018
5121
  return null;
5019
5122
  }
5020
- const mode = deriveInstallMode(loaded.config.skills);
5021
5123
  return {
5022
- mode,
5124
+ mode: deriveInstallMode(loaded.config.skills),
5023
5125
  configPath,
5024
5126
  agentsDir: agentsDir(provider, scope, dir),
5025
- // Mixed mode uses the local skills dir, as eject does.
5026
- skillsDir: path14.join(
5027
- dir,
5028
- CLAUDE_DIR,
5029
- mode === "plugin" ? PLUGINS_SUBDIR : STANDARD_DIRS.SKILLS
5030
- ),
5031
5127
  projectDir: dir
5032
5128
  };
5033
5129
  }
@@ -5042,23 +5138,23 @@ async function holdsItsOwnInstallation(dir) {
5042
5138
  throw error;
5043
5139
  }
5044
5140
  }
5045
- async function detectGlobalInstallation() {
5046
- return detectInstallationInDir(os7.homedir(), "global");
5141
+ async function detectGlobalInstallation(projectDir) {
5142
+ return detectInstallationInDir(os7.homedir(), "global", inheritedGlobalProvider(projectDir));
5047
5143
  }
5048
5144
  async function detectInstallation(projectDir = process.cwd()) {
5049
5145
  const projectInstallation = await detectProjectInstallation(projectDir);
5050
5146
  if (projectInstallation) return projectInstallation;
5051
- return detectGlobalInstallation();
5147
+ return detectGlobalInstallation(projectDir);
5052
5148
  }
5053
5149
 
5054
5150
  // src/cli/lib/installation/local-installer.ts
5055
5151
  import os10 from "os";
5056
- import path18 from "path";
5152
+ import path17 from "path";
5057
5153
  import { unique as unique4 } from "remeda";
5058
5154
 
5059
5155
  // src/cli/lib/loading/loader.ts
5060
5156
  import { parse as parseYaml3 } from "yaml";
5061
- import path15 from "path";
5157
+ import path14 from "path";
5062
5158
 
5063
5159
  // src/cli/utils/frontmatter.ts
5064
5160
  import { parse as parseYaml2 } from "yaml";
@@ -5131,7 +5227,7 @@ async function loadAgentsFromDir(agentsDir2, sourceRoot, options) {
5131
5227
  return agents;
5132
5228
  }
5133
5229
  async function readAgentDefinition(agentsDir2, file, sourceRoot, options) {
5134
- const fullPath = path15.join(agentsDir2, file);
5230
+ const fullPath = path14.join(agentsDir2, file);
5135
5231
  try {
5136
5232
  const content = await readFile(fullPath);
5137
5233
  const parsed = agentYamlConfigSchema.safeParse(parseYaml3(content));
@@ -5164,7 +5260,7 @@ function toAgentDefinition(config, file, sourceRoot, options) {
5164
5260
  ...config.hooks !== void 0 && { hooks: config.hooks },
5165
5261
  ...config.experimental !== void 0 && { experimental: config.experimental },
5166
5262
  ...config.outputFormat !== void 0 && { outputFormat: config.outputFormat },
5167
- path: path15.dirname(file),
5263
+ path: path14.dirname(file),
5168
5264
  sourceRoot,
5169
5265
  ...options.agentBaseDir ? { agentBaseDir: options.agentBaseDir } : {},
5170
5266
  ...config.domain ? { domain: config.domain } : {},
@@ -5172,7 +5268,7 @@ function toAgentDefinition(config, file, sourceRoot, options) {
5172
5268
  };
5173
5269
  }
5174
5270
  async function loadAllAgents(projectRoot) {
5175
- return loadAgentsFromDir(path15.join(projectRoot, DIRS.agents), projectRoot, {
5271
+ return loadAgentsFromDir(path14.join(projectRoot, DIRS.agents), projectRoot, {
5176
5272
  includeCustomFlag: true,
5177
5273
  verboseLabel: "agent"
5178
5274
  });
@@ -5184,9 +5280,9 @@ async function loadMergedAgents(sourcePath) {
5184
5280
  ]);
5185
5281
  return { ...cliAgents, ...sourceAgents };
5186
5282
  }
5187
- async function loadProjectAgents(projectRoot) {
5188
- const sourceFolder = sourceFolderInUse(projectRoot, providerInUse(projectRoot));
5189
- const projectAgentsDir = path15.join(sourceFolder.dir, STANDARD_DIRS.AGENTS);
5283
+ async function loadProjectAgents(projectRoot, provider = providerInUse(projectRoot)) {
5284
+ const sourceFolder = sourceFolderInUse(projectRoot, provider);
5285
+ const projectAgentsDir = path14.join(sourceFolder.dir, STANDARD_DIRS.AGENTS);
5190
5286
  if (!await directoryExists2(projectAgentsDir)) {
5191
5287
  verbose(`No project agents directory at ${projectAgentsDir}`);
5192
5288
  return {};
@@ -5218,19 +5314,19 @@ async function loadSkillsFromDir(skillsDir2, options = {}) {
5218
5314
  return { skills, unusableMetadata };
5219
5315
  }
5220
5316
  function locateSkill(skillsDir2, skillFile, pathPrefix) {
5221
- const skillMdPath = path15.join(skillsDir2, skillFile);
5222
- const skillDir = path15.dirname(skillMdPath);
5223
- const relativePath = path15.relative(skillsDir2, skillDir);
5317
+ const skillMdPath = path14.join(skillsDir2, skillFile);
5318
+ const skillDir = path14.dirname(skillMdPath);
5319
+ const relativePath = path14.relative(skillsDir2, skillDir);
5224
5320
  return {
5225
5321
  skillFile,
5226
5322
  skillMdPath,
5227
5323
  skillDir,
5228
- skillDirName: path15.basename(skillDir),
5324
+ skillDirName: path14.basename(skillDir),
5229
5325
  displayPath: pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`
5230
5326
  };
5231
5327
  }
5232
5328
  async function judgeSkillMetadata(skill) {
5233
- const metadataPath = path15.join(skill.skillDir, STANDARD_FILES.METADATA_YAML);
5329
+ const metadataPath = path14.join(skill.skillDir, STANDARD_FILES.METADATA_YAML);
5234
5330
  if (!await fileExists(metadataPath)) {
5235
5331
  warn(
5236
5332
  `Skill '${skill.skillDirName}' in '${skill.displayPath}' is missing ${STANDARD_FILES.METADATA_YAML} \u2014 skipped. Add ${STANDARD_FILES.METADATA_YAML} to register it with the CLI.`
@@ -5272,7 +5368,7 @@ async function readSkillDefinition(skill) {
5272
5368
  }
5273
5369
  }
5274
5370
  async function loadPluginSkills(pluginDir) {
5275
- const { skills } = await loadSkillsFromDir(path15.join(pluginDir, "skills"), {
5371
+ const { skills } = await loadSkillsFromDir(path14.join(pluginDir, "skills"), {
5276
5372
  pathPrefix: "skills",
5277
5373
  requireMetadata: false
5278
5374
  });
@@ -5281,17 +5377,18 @@ async function loadPluginSkills(pluginDir) {
5281
5377
 
5282
5378
  // src/cli/lib/loading/source-fetcher.ts
5283
5379
  import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
5284
- import { createHash as createHash2 } from "crypto";
5380
+ import { createHash as createHash2, randomUUID } from "crypto";
5285
5381
  import { readFileSync } from "fs";
5286
- import { rename, stat } from "fs/promises";
5382
+ import { open, rename, stat } from "fs/promises";
5383
+ import { setTimeout as sleep } from "timers/promises";
5287
5384
  import { downloadTemplate } from "giget";
5288
5385
  import os8 from "os";
5289
- import path17 from "path";
5386
+ import path16 from "path";
5290
5387
  import { isDeepEqual } from "remeda";
5291
5388
  import { z as z4 } from "zod";
5292
5389
 
5293
5390
  // src/cli/lib/marketplace-generator.ts
5294
- import path16 from "path";
5391
+ import path15 from "path";
5295
5392
  import { countBy, sortBy } from "remeda";
5296
5393
  var PLUGIN_MANIFEST_PATH = `${PLUGIN_MANIFEST_DIR}/${PLUGIN_MANIFEST_FILE}`;
5297
5394
  var MARKETPLACE_SCHEMA_URL = "https://anthropic.com/claude-code/marketplace.schema.json";
@@ -5323,7 +5420,7 @@ async function generateMarketplace(pluginsDir2, options) {
5323
5420
  const rootWithoutDotSlash = options.pluginRoot.replace(/^\.\//, "");
5324
5421
  for (const manifestFile of manifestFiles) {
5325
5422
  const pluginDirName = pluginDirNameOf(manifestFile);
5326
- const pluginDir = path16.join(pluginsDir2, pluginDirName);
5423
+ const pluginDir = path15.join(pluginsDir2, pluginDirName);
5327
5424
  const manifest = await readPluginManifest(pluginDir);
5328
5425
  if (!manifest) {
5329
5426
  warn(`Could not read plugin manifest: '${manifestFile}'`);
@@ -5388,7 +5485,7 @@ function namespaceViolationError(foreignIds, marketplaceName) {
5388
5485
  ].join("\n");
5389
5486
  }
5390
5487
  async function writeMarketplace(outputPath, marketplace) {
5391
- await ensureDir(path16.dirname(outputPath));
5488
+ await ensureDir(path15.dirname(outputPath));
5392
5489
  const content = `${JSON.stringify(marketplace, null, 2)}
5393
5490
  `;
5394
5491
  await writeFile(outputPath, content);
@@ -5417,9 +5514,11 @@ var MarketplaceUnreachableError = class extends Error {
5417
5514
  reason;
5418
5515
  };
5419
5516
  var TarballWithheldError = class extends Error {
5517
+ status;
5420
5518
  constructor({ status, statusText }) {
5421
5519
  super(`the marketplace answered ${status} ${statusText}`.trimEnd());
5422
5520
  this.name = "TarballWithheldError";
5521
+ this.status = status;
5423
5522
  }
5424
5523
  };
5425
5524
  var marketplaceMustAnswer = new AsyncLocalStorage3();
@@ -5430,6 +5529,29 @@ function askingEachMarketplaceItself(body) {
5430
5529
  function mustAnswer() {
5431
5530
  return marketplaceMustAnswer.getStore() !== void 0;
5432
5531
  }
5532
+ var refusalStopsTheLoad = new AsyncLocalStorage3();
5533
+ function stoppingOnARefusal(body) {
5534
+ return refusalStopsTheLoad.run(true, body);
5535
+ }
5536
+ function stopsOnARefusal() {
5537
+ return refusalStopsTheLoad.getStore() !== void 0;
5538
+ }
5539
+ var METHOD_NOT_ALLOWED = 405;
5540
+ function postureOn(status) {
5541
+ if (mustAnswer()) return "stop";
5542
+ if (status === METHOD_NOT_ALLOWED || isServerError(status)) return "keep";
5543
+ if (!isClientError(status)) return void 0;
5544
+ return stopsOnARefusal() ? "stop" : "pass over";
5545
+ }
5546
+ var FIRST_CLIENT_ERROR = 400;
5547
+ var FIRST_SERVER_ERROR = 500;
5548
+ var PAST_THE_SERVER_ERRORS = 600;
5549
+ function isClientError(status) {
5550
+ return status >= FIRST_CLIENT_ERROR && status < FIRST_SERVER_ERROR;
5551
+ }
5552
+ function isServerError(status) {
5553
+ return status >= FIRST_SERVER_ERROR && status < PAST_THE_SERVER_ERRORS;
5554
+ }
5433
5555
  function sanitizeSourceForCache(source) {
5434
5556
  const hash = createHash2("sha256").update(source).digest("hex").slice(0, CACHE_HASH_LENGTH);
5435
5557
  const readable = source.replace(/[^a-zA-Z0-9]/g, "-").replace(/--+/g, "-").replace(/^-|-$/g, "").slice(0, CACHE_READABLE_PREFIX_LENGTH);
@@ -5437,7 +5559,7 @@ function sanitizeSourceForCache(source) {
5437
5559
  }
5438
5560
  function getCacheDir(source) {
5439
5561
  const sanitized = sanitizeSourceForCache(source) || "unknown";
5440
- return path17.join(cacheRoot(), "sources", sanitized);
5562
+ return path16.join(cacheRoot(), "sources", sanitized);
5441
5563
  }
5442
5564
  async function fetchFromSource(source, options = {}) {
5443
5565
  const { subdir } = options;
@@ -5448,8 +5570,8 @@ async function fetchFromSource(source, options = {}) {
5448
5570
  return fetchFromRemoteSource(source, subdir);
5449
5571
  }
5450
5572
  async function fetchFromLocalSource(source, subdir) {
5451
- const fullPath = subdir ? path17.join(source, subdir) : source;
5452
- const absolutePath = path17.isAbsolute(fullPath) ? fullPath : path17.resolve(process.cwd(), fullPath);
5573
+ const fullPath = subdir ? path16.join(source, subdir) : source;
5574
+ const absolutePath = path16.isAbsolute(fullPath) ? fullPath : path16.resolve(process.cwd(), fullPath);
5453
5575
  if (!await directoryExists2(absolutePath)) {
5454
5576
  throw new Error(
5455
5577
  `Local marketplace not found: '${absolutePath}'
@@ -5480,18 +5602,16 @@ function getGigetCacheDir(source) {
5480
5602
  return void 0;
5481
5603
  }
5482
5604
  const templateName = uriMatch.groups.repo.replace("/", "-").replace(/[^\da-z-]/gi, "-");
5483
- return path17.join(gigetCacheRoot(), providerName, templateName);
5605
+ return path16.join(gigetCacheRoot(), providerName, templateName);
5484
5606
  }
5485
5607
  function gigetCacheRoot() {
5486
- return process.env.XDG_CACHE_HOME ? path17.resolve(process.env.XDG_CACHE_HOME, "giget") : path17.resolve(os8.homedir(), ".cache", "giget");
5608
+ return process.env.XDG_CACHE_HOME ? path16.resolve(process.env.XDG_CACHE_HOME, "giget") : path16.resolve(os8.homedir(), ".cache", "giget");
5487
5609
  }
5488
5610
  async function clearGigetCache(source) {
5489
5611
  const gigetDir = getGigetCacheDir(source);
5490
- if (!gigetDir) return;
5491
- if (await directoryExists2(gigetDir)) {
5492
- verbose(`Clearing giget cache: ${gigetDir}`);
5493
- await remove(gigetDir);
5494
- }
5612
+ if (!gigetDir || !await directoryExists2(gigetDir)) return;
5613
+ verbose(`Clearing giget cache: ${gigetDir}`);
5614
+ await holdingGigetFolder(path16.dirname(gigetDir), () => remove(gigetDir));
5495
5615
  }
5496
5616
  async function fetchFromRemoteSource(source, subdir) {
5497
5617
  const cacheDir = getCacheDir(source);
@@ -5500,7 +5620,7 @@ async function fetchFromRemoteSource(source, subdir) {
5500
5620
  verbose(`Cache directory: ${cacheDir}`);
5501
5621
  if (await directoryExists2(cacheDir)) {
5502
5622
  const verdict = await revalidateCachedCopy(cacheDir, source);
5503
- if (verdict === "current" || verdict === "unreachable") {
5623
+ if (keepsTheCopy(verdict)) {
5504
5624
  verbose(`Using cached marketplace: ${cacheDir}`);
5505
5625
  return {
5506
5626
  path: cacheDir,
@@ -5520,7 +5640,7 @@ async function discardCachedCopy(cacheDir, source) {
5520
5640
  await remove(cacheDir);
5521
5641
  }
5522
5642
  async function downloadFreshCopy(cacheDir, source, fullSource) {
5523
- await ensureDir(path17.dirname(cacheDir));
5643
+ await ensureDir(path16.dirname(cacheDir));
5524
5644
  try {
5525
5645
  const { result, savedTarball } = await gigetDownload(source, fullSource, {
5526
5646
  dir: cacheDir,
@@ -5529,6 +5649,7 @@ async function downloadFreshCopy(cacheDir, source, fullSource) {
5529
5649
  offline: false
5530
5650
  });
5531
5651
  verbose(`Downloaded to: ${result.dir}`);
5652
+ if (savedTarball) await askBeforeKeepingTheSavedTarball(cacheDir, result, source);
5532
5653
  await recordFetchedCopy(cacheDir, result, savedTarball);
5533
5654
  markCopyCurrentForThisRun(cacheDir);
5534
5655
  return {
@@ -5541,6 +5662,31 @@ async function downloadFreshCopy(cacheDir, source, fullSource) {
5541
5662
  throw createDetailedFetchError(error, source);
5542
5663
  }
5543
5664
  }
5665
+ async function askBeforeKeepingTheSavedTarball(cacheDir, result, source) {
5666
+ const tar = tarballOf(result);
5667
+ if (tar === void 0) return;
5668
+ const answer = await answerAbout(tar);
5669
+ if (answer === "answered") return;
5670
+ if (answer === "unreachable") {
5671
+ warn(sourceUnreachableUsingCache(source));
5672
+ return;
5673
+ }
5674
+ if (stopsTheLoad(answer)) {
5675
+ await remove(cacheDir);
5676
+ throw answer;
5677
+ }
5678
+ announceTheCopyKept(answer, source);
5679
+ }
5680
+ async function answerAbout(tar) {
5681
+ try {
5682
+ await fetchEtag(tar);
5683
+ return "answered";
5684
+ } catch (error) {
5685
+ if (error instanceof TarballWithheldError) return error;
5686
+ verbose(`Could not ask ${tar} about the tarball giget saved: ${getErrorMessage(error)}`);
5687
+ return "unreachable";
5688
+ }
5689
+ }
5544
5690
  var STAGED_DOWNLOAD_SUFFIX = ".download";
5545
5691
  var ONLY_A_SAVED_COPY_CAME_BACK = "the download failed and only a saved copy came back";
5546
5692
  var SET_ASIDE_SUFFIX = ".set-aside";
@@ -5552,7 +5698,7 @@ async function downloadAnsweredFor(cacheDir, source, fullSource, differingCopies
5552
5698
  forceClean: true,
5553
5699
  offline: false
5554
5700
  });
5555
- await ensureDir(path17.dirname(cacheDir));
5701
+ await ensureDir(path16.dirname(cacheDir));
5556
5702
  try {
5557
5703
  const { result, savedTarball } = await downloadStaged();
5558
5704
  const record = await askAfterTheDownload(result, source);
@@ -5573,7 +5719,10 @@ async function downloadPast(savedTarball, record, download, source) {
5573
5719
  if (!savedUnder(savedTarball, record)) {
5574
5720
  throw new MarketplaceUnreachableError(source, ONLY_A_SAVED_COPY_CAME_BACK);
5575
5721
  }
5576
- await withTarballSetAside(savedTarball.path, download);
5722
+ await holdingGigetFolder(
5723
+ gigetProviderDir(source),
5724
+ () => withTarballSetAside(savedTarball.path, download)
5725
+ );
5577
5726
  }
5578
5727
  async function withTarballSetAside(tarball, download) {
5579
5728
  const record = gigetRecordOf(tarball);
@@ -5609,7 +5758,7 @@ function everyFileIn(dir) {
5609
5758
  return glob(EVERY_FILE, dir, { dot: true });
5610
5759
  }
5611
5760
  function sameBytesAt(file, left, right) {
5612
- return readFileSync(path17.join(left, file)).equals(readFileSync(path17.join(right, file)));
5761
+ return readFileSync(path16.join(left, file)).equals(readFileSync(path16.join(right, file)));
5613
5762
  }
5614
5763
  async function replaceCopy(cacheDir, staged, record) {
5615
5764
  await remove(cacheDir);
@@ -5620,33 +5769,156 @@ var GIGET_TARBALLS = "**/*.tar.gz";
5620
5769
  var gigetTarballRecordSchema = z4.object({ etag: z4.string().min(1).optional() });
5621
5770
  async function gigetDownload(source, fullSource, options) {
5622
5771
  const providerDir = gigetProviderDir(source);
5623
- const timesBefore = await tarballTimes(providerDir);
5624
- const result = await downloadTemplate(fullSource, options);
5625
- const tarball = path17.join(providerDir, gigetTarballOf(result));
5626
- const writtenByThisDownload = timesBefore.get(tarball) !== await modifiedAt(tarball);
5627
- if (writtenByThisDownload) return { result };
5628
- verbose(`giget extracted the tarball it saved earlier, not a download: ${tarball}`);
5629
- return { result, savedTarball: { path: tarball, etag: await etagSavedWith(tarball) } };
5772
+ return holdingGigetFolder(
5773
+ providerDir,
5774
+ () => downloadOverMarkedRecords(providerDir, fullSource, options)
5775
+ );
5776
+ }
5777
+ async function downloadOverMarkedRecords(providerDir, fullSource, options) {
5778
+ const marks = await markSavedRecords(providerDir);
5779
+ try {
5780
+ const result = await downloadTemplate(fullSource, options);
5781
+ const tarball = path16.join(providerDir, gigetTarballOf(result));
5782
+ if (await writtenByThisDownload(marks.get(tarball))) return { result };
5783
+ verbose(`giget extracted the tarball it saved earlier, not a download: ${tarball}`);
5784
+ return { result, savedTarball: { path: tarball, etag: await etagSavedWith(tarball) } };
5785
+ } finally {
5786
+ await Promise.all([...marks.values()].map(unmark));
5787
+ }
5630
5788
  }
5631
5789
  function gigetProviderDir(source) {
5632
5790
  const provider = SOURCE_PROTO_RE.exec(source)?.[1];
5633
5791
  if (provider === void 0) throw new Error(`No provider named in '${source}'`);
5634
- return path17.join(gigetCacheRoot(), provider);
5792
+ return path16.join(gigetCacheRoot(), provider);
5793
+ }
5794
+ var GIGET_FOLDER_LOCK = "agents-inc.lock";
5795
+ var EXCLUSIVE_CREATE = "wx";
5796
+ var LOCK_RETRY_MS = 100;
5797
+ var LOCK_ABANDONED_MS = 10 * 60 * 1e3;
5798
+ var gigetFolderHeld = new AsyncLocalStorage3();
5799
+ var holdersInThisProcess = /* @__PURE__ */ new Set();
5800
+ async function holdingGigetFolder(folder, body) {
5801
+ if (gigetFolderHeld.getStore() === folder) return body();
5802
+ const lock = lockFor(folder);
5803
+ try {
5804
+ await lockGigetFolder(folder, lock);
5805
+ return await gigetFolderHeld.run(folder, body);
5806
+ } finally {
5807
+ await letGo(lock);
5808
+ }
5809
+ }
5810
+ function lockFor(folder) {
5811
+ const holder = `${process.pid} ${randomUUID()}`;
5812
+ holdersInThisProcess.add(holder);
5813
+ return { path: path16.join(folder, GIGET_FOLDER_LOCK), holder };
5814
+ }
5815
+ async function letGo({ path: lockPath, holder }) {
5816
+ try {
5817
+ await removeLockHeldBy(lockPath, holder);
5818
+ } finally {
5819
+ holdersInThisProcess.delete(holder);
5820
+ }
5821
+ }
5822
+ async function lockGigetFolder(folder, lock) {
5823
+ await ensureDir(folder);
5824
+ while (!await created(lock)) {
5825
+ const holder = await readFileOptional(lock.path);
5826
+ if (await abandoned(lock.path, holder)) {
5827
+ verbose(`Taking over the lock on ${folder}: its run ended, or held it past any download`);
5828
+ await removeLockHeldBy(lock.path, holder);
5829
+ } else {
5830
+ await sleep(LOCK_RETRY_MS);
5831
+ }
5832
+ }
5833
+ }
5834
+ async function created({ path: lockPath, holder }) {
5835
+ try {
5836
+ await (await open(lockPath, EXCLUSIVE_CREATE)).close();
5837
+ } catch (error) {
5838
+ if (failedWith(error, "EEXIST")) return false;
5839
+ throw error;
5840
+ }
5841
+ await writeFile(lockPath, holder);
5842
+ return true;
5843
+ }
5844
+ async function abandoned(lockPath, holder) {
5845
+ return holderEnded(holder) || await outlastedAnyDownload(lockPath);
5846
+ }
5847
+ function holderEnded(holder) {
5848
+ const pid = Number.parseInt(holder, 10);
5849
+ if (pid === process.pid) return !holdersInThisProcess.has(holder);
5850
+ return pid > 0 && !processRunning(pid);
5851
+ }
5852
+ async function outlastedAnyDownload(lockPath) {
5853
+ const age = await ageOf(lockPath);
5854
+ return age !== void 0 && age > LOCK_ABANDONED_MS;
5855
+ }
5856
+ function processRunning(pid) {
5857
+ try {
5858
+ process.kill(pid, 0);
5859
+ return true;
5860
+ } catch (error) {
5861
+ return !failedWith(error, "ESRCH");
5862
+ }
5863
+ }
5864
+ async function ageOf(file) {
5865
+ try {
5866
+ return Date.now() - (await stat(file)).mtimeMs;
5867
+ } catch (error) {
5868
+ if (failedWith(error, "ENOENT")) return void 0;
5869
+ throw error;
5870
+ }
5635
5871
  }
5636
- async function tarballTimes(providerDir) {
5872
+ async function removeLockHeldBy(lockPath, holder) {
5873
+ if (await readFileOptional(lockPath) === holder) await remove(lockPath);
5874
+ }
5875
+ function failedWith(error, code) {
5876
+ return isRecord(error) && error.code === code;
5877
+ }
5878
+ var RECORD_MARK = "\n";
5879
+ var NO_RECORD = "{}";
5880
+ var UNMARKED_SUFFIX = ".unmarked";
5881
+ async function markSavedRecords(providerDir) {
5637
5882
  const tarballs = await glob(GIGET_TARBALLS, providerDir);
5638
- const paths = tarballs.map((tarball) => path17.join(providerDir, tarball));
5639
- return new Map(await Promise.all(paths.map(async (at) => [at, await modifiedAt(at)])));
5883
+ const paths = tarballs.map((tarball) => path16.join(providerDir, tarball));
5884
+ return new Map(await Promise.all(paths.map(async (at) => [at, await markRecordOf(at)])));
5885
+ }
5886
+ async function markRecordOf(tarball) {
5887
+ const record = gigetRecordOf(tarball);
5888
+ await putBackLeftUnmarked(record);
5889
+ const held = await fileExists(record);
5890
+ const marked = `${RECORD_MARK}${await readFileOptional(record, NO_RECORD)}`;
5891
+ if (held) await rename(record, unmarkedOf(record));
5892
+ await writeFile(record, marked);
5893
+ return { record, marked, held };
5894
+ }
5895
+ async function putBackLeftUnmarked(record) {
5896
+ if (await fileExists(unmarkedOf(record))) await rename(unmarkedOf(record), record);
5897
+ }
5898
+ function unmarkedOf(record) {
5899
+ return `${record}${UNMARKED_SUFFIX}`;
5900
+ }
5901
+ async function writtenByThisDownload(mark) {
5902
+ return mark === void 0 || await rewritten(mark);
5640
5903
  }
5641
- async function modifiedAt(file) {
5642
- return await fileExists(file) ? (await stat(file)).mtimeMs : void 0;
5904
+ async function rewritten({ record, marked }) {
5905
+ return await readFileOptional(record, marked) !== marked;
5906
+ }
5907
+ async function unmark(mark) {
5908
+ const { record, held } = mark;
5909
+ if (await rewritten(mark)) {
5910
+ if (held) await remove(unmarkedOf(record));
5911
+ return;
5912
+ }
5913
+ if (held) await rename(unmarkedOf(record), record);
5914
+ else await remove(record);
5643
5915
  }
5644
5916
  function gigetTarballOf(result) {
5645
5917
  const name = result.name;
5646
5918
  const version = result.version;
5647
5919
  if (typeof name !== "string") throw new Error("the download named no template");
5648
5920
  const stem = typeof version === "string" && version !== "" ? version : name;
5649
- return path17.join(name, `${stem}.tar.gz`);
5921
+ return path16.join(name, `${stem}.tar.gz`);
5650
5922
  }
5651
5923
  function gigetRecordOf(tarball) {
5652
5924
  return `${tarball}.json`;
@@ -5659,6 +5931,9 @@ async function etagSavedWith(tarballPath) {
5659
5931
  function savedUnder(savedTarball, record) {
5660
5932
  return savedTarball.etag !== void 0 && savedTarball.etag === record.etag;
5661
5933
  }
5934
+ function keepsTheCopy(verdict) {
5935
+ return verdict === "current" || verdict === "unreachable" || verdict === "refused";
5936
+ }
5662
5937
  var REVALIDATION_TIMEOUT_MS = 5e3;
5663
5938
  var FETCH_RECORD_SUFFIX = ".etag.json";
5664
5939
  var askedThisRun = /* @__PURE__ */ new Map();
@@ -5692,13 +5967,18 @@ async function classifyCachedCopy(cacheDir, source) {
5692
5967
  try {
5693
5968
  return judgeAnswer(record, await fetchEtag(record.tar));
5694
5969
  } catch (error) {
5695
- if (error instanceof TarballWithheldError) throw createDetailedFetchError(error, source);
5970
+ if (error instanceof TarballWithheldError) return stopOrKeepTheCopy(error, source);
5696
5971
  verbose(`Could not revalidate ${record.tar}: ${getErrorMessage(error)}`);
5697
5972
  if (mustAnswer()) throw new MarketplaceUnreachableError(source, getErrorMessage(error));
5698
5973
  warn(sourceUnreachableUsingCache(source));
5699
5974
  return "unreachable";
5700
5975
  }
5701
5976
  }
5977
+ function stopOrKeepTheCopy(refusal2, source) {
5978
+ if (stopsTheLoad(refusal2)) throw createDetailedFetchError(refusal2, source);
5979
+ announceTheCopyKept(refusal2, source);
5980
+ return "refused";
5981
+ }
5702
5982
  function judgeAnswer(record, live) {
5703
5983
  if (movedOn(record, live)) return "superseded";
5704
5984
  if (mustAnswer()) return "answered";
@@ -5718,9 +5998,22 @@ async function fetchEtag(tar) {
5718
5998
  signal: AbortSignal.timeout(REVALIDATION_TIMEOUT_MS)
5719
5999
  });
5720
6000
  await response.body?.cancel();
5721
- if (mustAnswer() && !response.ok) throw new TarballWithheldError(response);
6001
+ if (withheld(response)) throw new TarballWithheldError(response);
5722
6002
  return response.headers.get("etag") ?? void 0;
5723
6003
  }
6004
+ function withheld({ ok, status }) {
6005
+ return !ok && postureOn(status) !== void 0;
6006
+ }
6007
+ function stopsTheLoad(refusal2) {
6008
+ return postureOn(refusal2.status) === "stop";
6009
+ }
6010
+ function announceTheCopyKept(refusal2, source) {
6011
+ if (postureOn(refusal2.status) === "keep") {
6012
+ warn(sourceRefusedUsingCache(source, refusal2.status));
6013
+ return;
6014
+ }
6015
+ verbose(`Keeping the saved copy of ${source} over its refusal: ${refusal2.message}`);
6016
+ }
5724
6017
  function fetchRecordPath(cacheDir) {
5725
6018
  return `${cacheDir}${FETCH_RECORD_SUFFIX}`;
5726
6019
  }
@@ -6011,7 +6304,7 @@ function markInstalledAsPlugin(skill, primarySourceName, primarySourceType) {
6011
6304
  }
6012
6305
  async function collectPluginSkillIds(projectDir) {
6013
6306
  const projectSkillIds = await pluginSkillIdsIn(projectDir);
6014
- const globalSkillIds = isHomeDirectory(projectDir) ? [] : await pluginSkillIdsIn(os9.homedir());
6307
+ const globalSkillIds = isHomeDirectory(projectDir) ? [] : await pluginSkillIdsIn(os9.homedir(), inheritedGlobalProvider(projectDir));
6015
6308
  if (globalSkillIds.length > 0) {
6016
6309
  verbose(`Found ${globalSkillIds.length} global plugin skill(s)`);
6017
6310
  return unique3([...projectSkillIds, ...globalSkillIds]);
@@ -6021,8 +6314,8 @@ async function collectPluginSkillIds(projectDir) {
6021
6314
  }
6022
6315
  return projectSkillIds;
6023
6316
  }
6024
- async function pluginSkillIdsIn(dir) {
6025
- return typedKeys(await discoverAllPluginSkills(dir));
6317
+ async function pluginSkillIdsIn(dir, provider) {
6318
+ return typedKeys(await discoverAllPluginSkills(dir, provider));
6026
6319
  }
6027
6320
  function setActiveSources(matrix2) {
6028
6321
  for (const [, skill] of typedEntries(matrix2.skills)) {
@@ -6115,14 +6408,18 @@ function resolveDescription(loadedStack, shared) {
6115
6408
  return shared ?? loadedStack?.description;
6116
6409
  }
6117
6410
  function configNameFor(projectDir) {
6118
- return isHomeDirectory(projectDir) ? DEFAULT_PLUGIN_NAME : path18.basename(projectDir);
6411
+ return isHomeDirectory(projectDir) ? DEFAULT_PLUGIN_NAME : path17.basename(projectDir);
6119
6412
  }
6120
6413
  async function loadCuratedStack(projectDir, projectStack) {
6121
- const globalStack = isHomeDirectory(projectDir) ? void 0 : await loadGlobalStack();
6414
+ const globalStack = isHomeDirectory(projectDir) ? void 0 : await loadGlobalStack(projectDir);
6122
6415
  return { ...globalStack, ...projectStack };
6123
6416
  }
6124
- async function loadGlobalStack() {
6125
- return (await loadInstalledConfig(os10.homedir()))?.config.stack;
6417
+ async function loadGlobalStack(projectDir) {
6418
+ const inherited = await loadProjectConfigFromDir(
6419
+ os10.homedir(),
6420
+ inheritedGlobalProvider(projectDir)
6421
+ );
6422
+ return inherited?.config.stack;
6126
6423
  }
6127
6424
  async function buildInstallConfig(selection, sourceResult, projectDir) {
6128
6425
  const skillIds = unique4(selection.skills.map((s) => s.id));
@@ -6269,31 +6566,61 @@ async function describeScope(kind, root, provider) {
6269
6566
 
6270
6567
  // src/cli/lib/installation/detect-installations.ts
6271
6568
  async function detectInstallations(cwd) {
6569
+ const configs = await configsRead(cwd);
6570
+ return configs.filter((config) => !config.declaresNothingInAProject).map(asInstallation);
6571
+ }
6572
+ async function configsDeclaringNothing(cwd) {
6573
+ const configs = await configsRead(cwd);
6574
+ return configs.filter((config) => config.declaresNothingInAProject).map(asInstallation);
6575
+ }
6576
+ async function holdsAConfigDeclaringNothing(cwd) {
6577
+ return (await configsDeclaringNothing(cwd)).length > 0;
6578
+ }
6579
+ async function configsRead(cwd) {
6272
6580
  const everywhereOneCouldBe = scopeRootsInPlay(cwd).flatMap(everyProviderUnder);
6273
- const found = await Promise.all(everywhereOneCouldBe.map(installationIfPresent));
6274
- return found.filter(
6275
- (installation) => installation !== null
6276
- );
6581
+ const found = await Promise.all(everywhereOneCouldBe.map(configIfPresent));
6582
+ const onDisk = found.filter((config) => config !== null);
6583
+ return Promise.all(onDisk.map(withWhetherItDeclaresNothing));
6277
6584
  }
6278
6585
  function everyProviderUnder({ kind, root }) {
6279
6586
  return PROVIDERS.map((provider) => ({
6280
6587
  provider,
6281
6588
  scope: kind,
6589
+ root,
6282
6590
  configPath: getProjectConfigPath(root, provider)
6283
6591
  }));
6284
6592
  }
6285
- async function installationIfPresent(candidate) {
6593
+ async function configIfPresent(candidate) {
6286
6594
  return await fileExists(candidate.configPath) ? candidate : null;
6287
6595
  }
6596
+ async function withWhetherItDeclaresNothing(config) {
6597
+ return { ...config, declaresNothingInAProject: await declaresNothingInAProject(config) };
6598
+ }
6599
+ async function declaresNothingInAProject(config) {
6600
+ if (config.scope === "global") return false;
6601
+ const asRead = declaresNothingAsLastRead(config.configPath);
6602
+ if (asRead !== void 0) return asRead;
6603
+ try {
6604
+ const declaresNothing = await configDeclaresNothing(config.root, config.provider);
6605
+ recordWhetherItDeclaresNothing(config.configPath, declaresNothing);
6606
+ return declaresNothing;
6607
+ } catch (error) {
6608
+ if (error instanceof ConfigLoadError) return false;
6609
+ throw error;
6610
+ }
6611
+ }
6612
+ function asInstallation({ provider, scope, configPath }) {
6613
+ return { provider, scope, configPath };
6614
+ }
6288
6615
 
6289
6616
  // src/cli/lib/hosts/claude-host.ts
6290
6617
  import os12 from "os";
6291
- import path21 from "path";
6618
+ import path20 from "path";
6292
6619
  import { z as z6 } from "zod";
6293
6620
 
6294
6621
  // src/cli/utils/exec.ts
6295
6622
  import { spawn } from "child_process";
6296
- import path19 from "path";
6623
+ import path18 from "path";
6297
6624
  var MAX_PLUGIN_PATH_LENGTH = 1024;
6298
6625
  var MAX_PLUGIN_NAME_LENGTH = 256;
6299
6626
  var MAX_MARKETPLACE_SOURCE_LENGTH = 1024;
@@ -6301,7 +6628,7 @@ var SAFE_NAME_PATTERN2 = /^[a-zA-Z0-9._@/-]+$/;
6301
6628
  var SAFE_PLUGIN_PATH_PATTERN = /^[a-zA-Z0-9._@/:~-]+$/;
6302
6629
  var OPENS_A_RELATIVE_PATH = /^\.\.?[/\\]/;
6303
6630
  function namesADirectoryOnThisMachine(source) {
6304
- return path19.isAbsolute(source) || OPENS_A_RELATIVE_PATH.test(source);
6631
+ return path18.isAbsolute(source) || OPENS_A_RELATIVE_PATH.test(source);
6305
6632
  }
6306
6633
  var CONTROL_CHAR_PATTERN = /[\x00-\x08\x0E-\x1F\x7F]/u;
6307
6634
  function validatePluginPath(pluginPath) {
@@ -6391,7 +6718,7 @@ async function execCommand(command, args, options) {
6391
6718
  }
6392
6719
 
6393
6720
  // src/cli/lib/plugins/plugin-settings.ts
6394
- import path20 from "path";
6721
+ import path19 from "path";
6395
6722
  import { z as z5 } from "zod";
6396
6723
  var pluginSettingsSchema = z5.object({
6397
6724
  // Absent when no plugin is enabled.
@@ -6412,7 +6739,7 @@ var installedPluginsSchema = z5.object({
6412
6739
  plugins: z5.record(z5.string(), z5.array(pluginInstallationSchema))
6413
6740
  }).passthrough();
6414
6741
  function getInstalledPluginsRegistryPath(pluginsDir2) {
6415
- return path20.join(pluginsDir2, INSTALLED_PLUGINS_FILE);
6742
+ return path19.join(pluginsDir2, INSTALLED_PLUGINS_FILE);
6416
6743
  }
6417
6744
  async function readRegisteredInstallations(pluginsDir2) {
6418
6745
  const registryPath = getInstalledPluginsRegistryPath(pluginsDir2);
@@ -6445,7 +6772,7 @@ async function listPluginInstallsForProject(pluginsDir2, projectDir) {
6445
6772
  });
6446
6773
  }
6447
6774
  async function getEnabledPluginKeys(projectDir) {
6448
- const settingsPath = path20.join(projectDir, CLAUDE_DIR, STANDARD_FILES.SETTINGS_JSON);
6775
+ const settingsPath = path19.join(projectDir, CLAUDE_DIR, STANDARD_FILES.SETTINGS_JSON);
6449
6776
  if (!await fileExists(settingsPath)) {
6450
6777
  verbose(`No settings.json found at '${settingsPath}'`);
6451
6778
  return [];
@@ -6593,7 +6920,7 @@ function namesNothingThere(message) {
6593
6920
  return NOT_INSTALLED_MESSAGES.some((phrase) => message.includes(phrase));
6594
6921
  }
6595
6922
  function claudePluginsRoot(projectDir, options) {
6596
- if (options?.configDir !== void 0) return path21.join(options.configDir, PLUGINS_SUBDIR);
6923
+ if (options?.configDir !== void 0) return path20.join(options.configDir, PLUGINS_SUBDIR);
6597
6924
  return pluginsDir(CLAUDE, "global", projectDir);
6598
6925
  }
6599
6926
  async function claudeListPlugins(projectDir, options) {
@@ -6628,7 +6955,7 @@ function claudeHost() {
6628
6955
 
6629
6956
  // src/cli/lib/hosts/codex-host.ts
6630
6957
  import os13 from "os";
6631
- import path22 from "path";
6958
+ import path21 from "path";
6632
6959
  import { z as z7 } from "zod";
6633
6960
  var CODEX = "codex";
6634
6961
  var PLUGIN_CACHE_SUBDIR = "cache";
@@ -6712,7 +7039,7 @@ var pluginListingSchema = z7.object({
6712
7039
  )
6713
7040
  });
6714
7041
  function codexPluginsRoot(projectDir, options) {
6715
- if (options?.configDir !== void 0) return path22.join(options.configDir, PLUGINS_SUBDIR);
7042
+ if (options?.configDir !== void 0) return path21.join(options.configDir, PLUGINS_SUBDIR);
6716
7043
  return pluginsDir(CODEX, "global", projectDir);
6717
7044
  }
6718
7045
  async function isCodexCLIAvailable(options) {
@@ -6842,7 +7169,7 @@ async function codexListPlugins(projectDir, options) {
6842
7169
  async function codexPluginsOrUnreadable(projectDir, options) {
6843
7170
  const pluginsRoot = codexPluginsRoot(projectDir, options);
6844
7171
  if (pluginsRoot === null) return { kind: "listed", plugins: [] };
6845
- const cacheRoot2 = path22.join(pluginsRoot, PLUGIN_CACHE_SUBDIR);
7172
+ const cacheRoot2 = path21.join(pluginsRoot, PLUGIN_CACHE_SUBDIR);
6846
7173
  let installed;
6847
7174
  try {
6848
7175
  installed = await codexPluginListing(options, projectDir);
@@ -6854,7 +7181,7 @@ async function codexPluginsOrUnreadable(projectDir, options) {
6854
7181
  kind: "listed",
6855
7182
  plugins: installed.map((plugin) => ({
6856
7183
  pluginKey: plugin.pluginId,
6857
- installPath: path22.join(cacheRoot2, plugin.marketplaceName, plugin.name, plugin.version),
7184
+ installPath: path21.join(cacheRoot2, plugin.marketplaceName, plugin.name, plugin.version),
6858
7185
  enabled: plugin.enabled
6859
7186
  }))
6860
7187
  };
@@ -7134,10 +7461,11 @@ function sumCounts(scopeCounts) {
7134
7461
  async function countCompiledAgentsPerScope(installation, scopes) {
7135
7462
  return Promise.all(
7136
7463
  scopes.map(async (scope) => {
7137
- const dir = resolveInstallPaths(installation.projectDir, scope).agentsDir;
7464
+ const provider = providerAtScope(installation.projectDir, scope);
7465
+ const dir = agentsDir(provider, scope, installation.projectDir);
7138
7466
  return {
7139
7467
  dir,
7140
- count: await countDirEntries(dir, isCompiledAgentFileIn(agentCodec("claude").extension))
7468
+ count: await countDirEntries(dir, isCompiledAgentFileIn(agentCodec(provider).extension))
7141
7469
  };
7142
7470
  })
7143
7471
  );
@@ -7153,18 +7481,20 @@ async function countDirEntries(dir, pred) {
7153
7481
  return 0;
7154
7482
  }
7155
7483
  }
7156
- function formatInstallationDisplay(info) {
7484
+ function formatInstallationDisplay(info, skillLines = []) {
7485
+ const namedSkillLines = skillLines.map((line2) => `
7486
+ ${line2}`).join("");
7157
7487
  const agentDirLines = info.agentDirs.map((dir) => `
7158
7488
  Agents: ${dir}`).join("");
7159
7489
  return `Installation: ${info.name}
7160
7490
  Mode: ${INSTALL_MODE_LABELS[info.mode]}
7161
- Skills: ${info.skillCount}
7491
+ Skills: ${info.skillCount}${namedSkillLines}
7162
7492
  Agents: ${info.agentCount}
7163
7493
  Config: ${info.configPath}${agentDirLines}`;
7164
7494
  }
7165
7495
 
7166
7496
  // src/cli/lib/plugins/plugin-validator.ts
7167
- import path23 from "path";
7497
+ import path22 from "path";
7168
7498
 
7169
7499
  // src/cli/lib/validation-result.ts
7170
7500
  function validResult() {
@@ -7196,15 +7526,15 @@ async function validatePluginStructure(pluginPath) {
7196
7526
  if (!await directoryExists2(pluginPath)) {
7197
7527
  return invalidResult(`Plugin directory does not exist: ${pluginPath}`);
7198
7528
  }
7199
- const pluginDir = path23.join(pluginPath, PLUGIN_MANIFEST_DIR);
7529
+ const pluginDir = path22.join(pluginPath, PLUGIN_MANIFEST_DIR);
7200
7530
  if (!await directoryExists2(pluginDir)) {
7201
7531
  errors.push(`Missing ${PLUGIN_MANIFEST_DIR}/ directory`);
7202
7532
  }
7203
- const manifestPath = path23.join(pluginDir, STANDARD_FILES.PLUGIN_JSON);
7533
+ const manifestPath = path22.join(pluginDir, STANDARD_FILES.PLUGIN_JSON);
7204
7534
  if (!await fileExists(manifestPath)) {
7205
7535
  errors.push(`Missing ${PLUGIN_MANIFEST_DIR}/${STANDARD_FILES.PLUGIN_JSON}`);
7206
7536
  }
7207
- const readmePath = path23.join(pluginPath, STANDARD_FILES.README_MD);
7537
+ const readmePath = path22.join(pluginPath, STANDARD_FILES.README_MD);
7208
7538
  if (!await fileExists(readmePath)) {
7209
7539
  warnings.push("Missing README.md (recommended for documentation)");
7210
7540
  }
@@ -7247,15 +7577,15 @@ async function validatePluginManifest(manifestPath) {
7247
7577
  if (!manifest.description) {
7248
7578
  warnings.push("Missing description field (recommended for discoverability)");
7249
7579
  }
7250
- const pluginDir = path23.dirname(path23.dirname(manifestPath));
7580
+ const pluginDir = path22.dirname(path22.dirname(manifestPath));
7251
7581
  if (isNonEmptyString(manifest.skills)) {
7252
- const skillsPath = path23.join(pluginDir, manifest.skills);
7582
+ const skillsPath = path22.join(pluginDir, manifest.skills);
7253
7583
  if (!await directoryExists2(skillsPath)) {
7254
7584
  errors.push(`Skills path does not exist: ${manifest.skills}`);
7255
7585
  }
7256
7586
  }
7257
7587
  if (isNonEmptyString(manifest.agents)) {
7258
- const agentsPath = path23.join(pluginDir, manifest.agents);
7588
+ const agentsPath = path22.join(pluginDir, manifest.agents);
7259
7589
  if (!await directoryExists2(agentsPath)) {
7260
7590
  errors.push(`Agents path does not exist: ${manifest.agents}`);
7261
7591
  }
@@ -7324,14 +7654,14 @@ function prefixResult(result, prefix) {
7324
7654
  async function validateEachFile(pluginPath, scannedDir, files, validate) {
7325
7655
  const results = await Promise.all(
7326
7656
  files.map(async (file) => {
7327
- const filePath = path23.join(scannedDir, file);
7328
- return prefixResult(await validate(filePath), path23.relative(pluginPath, filePath));
7657
+ const filePath = path22.join(scannedDir, file);
7658
+ return prefixResult(await validate(filePath), path22.relative(pluginPath, filePath));
7329
7659
  })
7330
7660
  );
7331
7661
  return mergeValidationResults(results);
7332
7662
  }
7333
7663
  async function validatePluginSkillFiles(pluginPath, skillsRelPath) {
7334
- const skillsDir2 = path23.join(pluginPath, skillsRelPath);
7664
+ const skillsDir2 = path22.join(pluginPath, skillsRelPath);
7335
7665
  if (!await directoryExists2(skillsDir2)) return validResult();
7336
7666
  const files = await glob(`**/${STANDARD_FILES.SKILL_MD}`, skillsDir2);
7337
7667
  if (files.length === 0) {
@@ -7344,7 +7674,7 @@ async function validatePluginSkillFiles(pluginPath, skillsRelPath) {
7344
7674
  return validateEachFile(pluginPath, skillsDir2, files, validateSkillFrontmatter);
7345
7675
  }
7346
7676
  async function validatePluginAgentFiles(pluginPath, agentsRelPath) {
7347
- const agentsDir2 = path23.join(pluginPath, agentsRelPath);
7677
+ const agentsDir2 = path22.join(pluginPath, agentsRelPath);
7348
7678
  if (!await directoryExists2(agentsDir2)) return validResult();
7349
7679
  const files = await glob(agentCodec("claude").listGlob, agentsDir2);
7350
7680
  if (files.length === 0) {
@@ -7415,7 +7745,7 @@ async function listPluginDirNames(pluginsDir2) {
7415
7745
  const dirChecks = await Promise.all(
7416
7746
  allDirs.map(async (dirName) => ({
7417
7747
  dirName,
7418
- isPlugin: await directoryExists2(path23.join(pluginsDir2, dirName, PLUGIN_MANIFEST_DIR))
7748
+ isPlugin: await directoryExists2(path22.join(pluginsDir2, dirName, PLUGIN_MANIFEST_DIR))
7419
7749
  }))
7420
7750
  );
7421
7751
  return dirChecks.filter((c) => c.isPlugin).map((c) => c.dirName);
@@ -7423,7 +7753,7 @@ async function listPluginDirNames(pluginsDir2) {
7423
7753
  async function validateEachPlugin(pluginsDir2, pluginDirs) {
7424
7754
  const results = [];
7425
7755
  for (const pluginName of pluginDirs) {
7426
- const result = await validatePlugin(path23.join(pluginsDir2, pluginName));
7756
+ const result = await validatePlugin(path22.join(pluginsDir2, pluginName));
7427
7757
  results.push({ name: pluginName, result });
7428
7758
  }
7429
7759
  return results;
@@ -7444,10 +7774,10 @@ function summarizePluginValidations(results) {
7444
7774
  }
7445
7775
 
7446
7776
  // src/cli/lib/plugins/plugin-discovery.ts
7447
- async function getVerifiedPluginInstallPaths(projectDir) {
7777
+ async function getVerifiedPluginInstallPaths(projectDir, provider = providerInUse(projectDir)) {
7448
7778
  let enabled;
7449
7779
  try {
7450
- const installed = await hostAt(projectDir).listPlugins(projectDir);
7780
+ const installed = await hostFor(provider).listPlugins(projectDir);
7451
7781
  enabled = installed.filter((plugin) => plugin.enabled).map(({ pluginKey, installPath }) => ({ pluginKey, installPath }));
7452
7782
  } catch (error) {
7453
7783
  verbose(`Failed to list installed plugins: ${getErrorMessage(error)}`);
@@ -7466,8 +7796,8 @@ async function hasManifestOnDisk({ pluginKey, installPath }) {
7466
7796
  }
7467
7797
  return manifestExists;
7468
7798
  }
7469
- async function discoverAllPluginSkills(projectDir) {
7470
- const pluginPaths = await getVerifiedPluginInstallPaths(projectDir);
7799
+ async function discoverAllPluginSkills(projectDir, provider = providerInUse(projectDir)) {
7800
+ const pluginPaths = await getVerifiedPluginInstallPaths(projectDir, provider);
7471
7801
  if (pluginPaths.length === 0) {
7472
7802
  verbose(`No enabled plugins found for '${projectDir}'`);
7473
7803
  return {};
@@ -7506,14 +7836,14 @@ function sanitizeSkillName(name) {
7506
7836
  return name.replace(/\+/g, "-");
7507
7837
  }
7508
7838
  function isSingleFolderName(name) {
7509
- return name !== "" && name !== "." && name !== ".." && path24.basename(name) === name;
7839
+ return name !== "" && name !== "." && name !== ".." && path23.basename(name) === name;
7510
7840
  }
7511
- async function assertClearable(pluginDir, skillPath, skillName) {
7512
- const skill = `Skill '${path24.basename(skillPath)}'`;
7513
- const file = `File: ${path24.join(skillPath, STANDARD_FILES.SKILL_MD)}`;
7514
- if (!isSingleFolderName(skillName)) {
7841
+ async function assertClearable(pluginDir, skillPath, skillName2) {
7842
+ const skill = `Skill '${path23.basename(skillPath)}'`;
7843
+ const file = `File: ${path23.join(skillPath, STANDARD_FILES.SKILL_MD)}`;
7844
+ if (!isSingleFolderName(skillName2)) {
7515
7845
  throw new Error(
7516
- `${skill} is named '${skillName}', which is not a single folder name, so its plugin cannot be built inside the output directory. ${file}`
7846
+ `${skill} is named '${skillName2}', which is not a single folder name, so its plugin cannot be built inside the output directory. ${file}`
7517
7847
  );
7518
7848
  }
7519
7849
  if (isPathWithin(skillPath, pluginDir)) {
@@ -7523,12 +7853,12 @@ async function assertClearable(pluginDir, skillPath, skillName) {
7523
7853
  }
7524
7854
  if (await holdsContentNoBuildMade(pluginDir)) {
7525
7855
  throw new Error(
7526
- `${skill} would be built into ${pluginDir}, which holds no ${path24.join(PLUGIN_MANIFEST_DIR, PLUGIN_MANIFEST_FILE)} and is not empty, so no earlier build made it and a rebuild would delete what it holds. Move its contents out, or build into another output directory. ${file}`
7856
+ `${skill} would be built into ${pluginDir}, which holds no ${path23.join(PLUGIN_MANIFEST_DIR, PLUGIN_MANIFEST_FILE)} and is not empty, so no earlier build made it and a rebuild would delete what it holds. Move its contents out, or build into another output directory. ${file}`
7527
7857
  );
7528
7858
  }
7529
7859
  }
7530
7860
  async function readPluginSkillMetadata(skillPath) {
7531
- const metadataPath = path24.join(skillPath, STANDARD_FILES.METADATA_YAML);
7861
+ const metadataPath = path23.join(skillPath, STANDARD_FILES.METADATA_YAML);
7532
7862
  if (!await fileExists(metadataPath)) {
7533
7863
  return null;
7534
7864
  }
@@ -7546,8 +7876,8 @@ async function readPluginSkillMetadata(skillPath) {
7546
7876
  return null;
7547
7877
  }
7548
7878
  }
7549
- function generateReadme(skillName, frontmatter) {
7550
- return `# ${skillName}
7879
+ function generateReadme(skillName2, frontmatter) {
7880
+ return `# ${skillName2}
7551
7881
 
7552
7882
  ${frontmatter.description}
7553
7883
 
@@ -7557,7 +7887,7 @@ Add this plugin to your Claude Code configuration:
7557
7887
 
7558
7888
  \`\`\`json
7559
7889
  {
7560
- "plugins": ["${skillName}"]
7890
+ "plugins": ["${skillName2}"]
7561
7891
  }
7562
7892
  \`\`\`
7563
7893
 
@@ -7572,28 +7902,28 @@ This skill is automatically available when installed.
7572
7902
  }
7573
7903
  async function writeSkillFiles(skillPath, pluginSkillDir, skillMdContent) {
7574
7904
  await ensureDir(pluginSkillDir);
7575
- await writeFile(path24.join(pluginSkillDir, STANDARD_FILES.SKILL_MD), skillMdContent);
7905
+ await writeFile(path23.join(pluginSkillDir, STANDARD_FILES.SKILL_MD), skillMdContent);
7576
7906
  verbose(` Copied ${STANDARD_FILES.SKILL_MD}`);
7577
7907
  for (const fileName of SKILL_CONTENT_FILES) {
7578
7908
  if (fileName === STANDARD_FILES.SKILL_MD) continue;
7579
- const sourcePath = path24.join(skillPath, fileName);
7909
+ const sourcePath = path23.join(skillPath, fileName);
7580
7910
  if (await fileExists(sourcePath)) {
7581
7911
  const content = await readFile(sourcePath);
7582
- await writeFile(path24.join(pluginSkillDir, fileName), content);
7912
+ await writeFile(path23.join(pluginSkillDir, fileName), content);
7583
7913
  verbose(` Copied ${fileName}`);
7584
7914
  }
7585
7915
  }
7586
7916
  for (const dirName of SKILL_CONTENT_DIRS) {
7587
- const sourceDir2 = path24.join(skillPath, dirName);
7917
+ const sourceDir2 = path23.join(skillPath, dirName);
7588
7918
  if (await fileExists(sourceDir2)) {
7589
- await copy(sourceDir2, path24.join(pluginSkillDir, dirName));
7919
+ await copy(sourceDir2, path23.join(pluginSkillDir, dirName));
7590
7920
  verbose(` Copied ${dirName}/`);
7591
7921
  }
7592
7922
  }
7593
7923
  }
7594
7924
  async function readSkillMdToBuild(skillPath) {
7595
- const dirBasename = path24.basename(skillPath);
7596
- const skillMdPath = path24.join(skillPath, STANDARD_FILES.SKILL_MD);
7925
+ const dirBasename = path23.basename(skillPath);
7926
+ const skillMdPath = path23.join(skillPath, STANDARD_FILES.SKILL_MD);
7597
7927
  if (!await fileExists(skillMdPath)) {
7598
7928
  throw new Error(
7599
7929
  `Skill '${dirBasename}' is missing required ${STANDARD_FILES.SKILL_MD} file. Expected at: ${skillMdPath}`
@@ -7611,13 +7941,13 @@ async function readSkillMdToBuild(skillPath) {
7611
7941
  async function compileSkillPlugin(options) {
7612
7942
  const { skillPath, outputDir, skillName: overrideName } = options;
7613
7943
  const { skillMdContent, frontmatter } = await readSkillMdToBuild(skillPath);
7614
- const skillName = overrideName ?? sanitizeSkillName(frontmatter.name);
7615
- const pluginDir = path24.join(outputDir, skillName);
7616
- await assertClearable(pluginDir, skillPath, skillName);
7617
- verbose(`Compiling skill plugin: ${skillName} from ${skillPath}`);
7944
+ const skillName2 = overrideName ?? sanitizeSkillName(frontmatter.name);
7945
+ const pluginDir = path23.join(outputDir, skillName2);
7946
+ await assertClearable(pluginDir, skillPath, skillName2);
7947
+ verbose(`Compiling skill plugin: ${skillName2} from ${skillPath}`);
7618
7948
  const metadata = await readPluginSkillMetadata(skillPath);
7619
7949
  const manifestAt = (version) => generateSkillPluginManifest({
7620
- skillName,
7950
+ skillName: skillName2,
7621
7951
  description: frontmatter.description,
7622
7952
  ...metadata?.author !== void 0 && { author: metadata.author },
7623
7953
  ...metadata?.category !== void 0 && { category: metadata.category },
@@ -7629,21 +7959,21 @@ async function compileSkillPlugin(options) {
7629
7959
  await writeContentHash(pluginDir, await computeSkillFolderHash(skillPath), getPluginManifestPath);
7630
7960
  await writeSkillFiles(
7631
7961
  skillPath,
7632
- path24.join(pluginDir, STANDARD_DIRS.SKILLS, skillName),
7962
+ path23.join(pluginDir, STANDARD_DIRS.SKILLS, skillName2),
7633
7963
  skillMdContent
7634
7964
  );
7635
- const readme = generateReadme(skillName, frontmatter);
7636
- await writeFile(path24.join(pluginDir, STANDARD_FILES.README_MD), readme);
7965
+ const readme = generateReadme(skillName2, frontmatter);
7966
+ await writeFile(path23.join(pluginDir, STANDARD_FILES.README_MD), readme);
7637
7967
  verbose(" Generated README.md");
7638
7968
  const manifest = manifestAt(
7639
7969
  versionAfterRebuild(earlierBuild, await computeShippedHash(pluginDir))
7640
7970
  );
7641
7971
  await writePluginManifest(pluginDir, manifest);
7642
- verbose(` Wrote plugin.json for ${skillName} (v${manifest.version})`);
7972
+ verbose(` Wrote plugin.json for ${skillName2} (v${manifest.version})`);
7643
7973
  return {
7644
7974
  pluginPath: pluginDir,
7645
7975
  manifest,
7646
- skillName
7976
+ skillName: skillName2
7647
7977
  };
7648
7978
  }
7649
7979
  async function compileAllSkillPlugins(skillsDir2, outputDir) {
@@ -7651,7 +7981,7 @@ async function compileAllSkillPlugins(skillsDir2, outputDir) {
7651
7981
  const failed = [];
7652
7982
  const skillMdFiles = await glob(`**/${STANDARD_FILES.SKILL_MD}`, skillsDir2);
7653
7983
  for (const skillMdFile of skillMdFiles) {
7654
- const skillPath = path24.join(skillsDir2, path24.dirname(skillMdFile));
7984
+ const skillPath = path23.join(skillsDir2, path23.dirname(skillMdFile));
7655
7985
  try {
7656
7986
  const result = await compileSkillPlugin({
7657
7987
  skillPath,
@@ -7661,7 +7991,7 @@ async function compileAllSkillPlugins(skillsDir2, outputDir) {
7661
7991
  log(` [OK] ${result.skillName}`);
7662
7992
  } catch (error) {
7663
7993
  const errorMessage = getErrorMessage(error);
7664
- const dirBasename = path24.basename(skillPath);
7994
+ const dirBasename = path23.basename(skillPath);
7665
7995
  failed.push(dirBasename);
7666
7996
  warn(`Failed to compile skill from '${dirBasename}': ${errorMessage}`);
7667
7997
  }
@@ -7677,7 +8007,7 @@ Compiled ${plural(results.length, "skill plugin")}:`);
7677
8007
  }
7678
8008
 
7679
8009
  // src/cli/lib/skills/local-skill-loader.ts
7680
- import path25 from "path";
8010
+ import path24 from "path";
7681
8011
  function copiedInSkillsAt(root, provider) {
7682
8012
  const scope = isHomeDirectory(root) ? "global" : "project";
7683
8013
  return {
@@ -7703,9 +8033,9 @@ async function discoverLocalSkills(root, provider = providerInUse(root)) {
7703
8033
  };
7704
8034
  }
7705
8035
  async function extractLocalSkill(localSkillsPath, pathPrefix, skillDirName) {
7706
- const skillDir = path25.join(localSkillsPath, skillDirName);
7707
- const metadataPath = path25.join(skillDir, STANDARD_FILES.METADATA_YAML);
7708
- const skillMdPath = path25.join(skillDir, STANDARD_FILES.SKILL_MD);
8036
+ const skillDir = path24.join(localSkillsPath, skillDirName);
8037
+ const metadataPath = path24.join(skillDir, STANDARD_FILES.METADATA_YAML);
8038
+ const skillMdPath = path24.join(skillDir, STANDARD_FILES.SKILL_MD);
7709
8039
  if (!await fileExists(metadataPath)) {
7710
8040
  verbose(`Skipping local skill '${skillDirName}': No metadata.yaml found`);
7711
8041
  return null;
@@ -7735,7 +8065,7 @@ async function extractLocalSkill(localSkillsPath, pathPrefix, skillDirName) {
7735
8065
  return null;
7736
8066
  }
7737
8067
  const relativePath = `${pathPrefix}/${skillDirName}/`;
7738
- const absolutePath = path25.join(localSkillsPath, skillDirName) + path25.sep;
8068
+ const absolutePath = path24.join(localSkillsPath, skillDirName) + path24.sep;
7739
8069
  const skillId = frontmatter.name;
7740
8070
  const extracted = {
7741
8071
  id: skillId,
@@ -7758,7 +8088,7 @@ async function extractLocalSkill(localSkillsPath, pathPrefix, skillDirName) {
7758
8088
  }
7759
8089
 
7760
8090
  // src/cli/lib/skills/unresolved-skill-entries.ts
7761
- import path26 from "path";
8091
+ import path25 from "path";
7762
8092
  async function findUnusableSavedSkillMetadata(savedSkills, projectDir) {
7763
8093
  const verdicts = await Promise.all(
7764
8094
  savedSkills.map((saved) => unusableMetadataOf(saved, projectDir))
@@ -7777,11 +8107,11 @@ function claimsLocalCopy(saved) {
7777
8107
  }
7778
8108
  function installedMetadataPath(saved, projectDir) {
7779
8109
  const { skillsDir: skillsDir2 } = resolveInstallPaths(projectDir, saved.scope);
7780
- return path26.join(skillsDir2, saved.id, STANDARD_FILES.METADATA_YAML);
8110
+ return path25.join(skillsDir2, saved.id, STANDARD_FILES.METADATA_YAML);
7781
8111
  }
7782
8112
 
7783
8113
  // src/cli/lib/skills/local-skill-mover.ts
7784
- import path27 from "path";
8114
+ import path26 from "path";
7785
8115
  var THE_DIRECTORY_ITSELF = ".";
7786
8116
  function validateSkillId(skillId) {
7787
8117
  return !(skillId.length === 0 || skillId === THE_DIRECTORY_ITSELF || skillId.includes("\0") || skillId.includes("..") || skillId.includes("/") || skillId.includes("\\"));
@@ -7791,8 +8121,8 @@ async function deleteLocalSkill(projectDir, skillId, scope = "project") {
7791
8121
  warn(`Invalid skill ID for deletion: '${skillId}'`);
7792
8122
  return;
7793
8123
  }
7794
- const skillsDir2 = path27.resolve(resolveInstallPaths(projectDir, scope).skillsDir);
7795
- const skillPath = path27.resolve(skillsDir2, skillId);
8124
+ const skillsDir2 = path26.resolve(resolveInstallPaths(projectDir, scope).skillsDir);
8125
+ const skillPath = path26.resolve(skillsDir2, skillId);
7796
8126
  if (!isPathWithin(skillPath, skillsDir2)) {
7797
8127
  warn(`Skill ID '${skillId}' resolves outside the skills directory.`);
7798
8128
  return;
@@ -7810,10 +8140,10 @@ async function migrateLocalSkillScope(skillId, fromScope, projectDir) {
7810
8140
  return;
7811
8141
  }
7812
8142
  const toScope = fromScope === "global" ? "project" : "global";
7813
- const fromSkillsDir = path27.resolve(resolveInstallPaths(projectDir, fromScope).skillsDir);
7814
- const toSkillsDir = path27.resolve(resolveInstallPaths(projectDir, toScope).skillsDir);
7815
- const fromPath = path27.resolve(fromSkillsDir, skillId);
7816
- const toPath = path27.resolve(toSkillsDir, skillId);
8143
+ const fromSkillsDir = path26.resolve(resolveInstallPaths(projectDir, fromScope).skillsDir);
8144
+ const toSkillsDir = path26.resolve(resolveInstallPaths(projectDir, toScope).skillsDir);
8145
+ const fromPath = path26.resolve(fromSkillsDir, skillId);
8146
+ const toPath = path26.resolve(toSkillsDir, skillId);
7817
8147
  if (!isPathWithin(fromPath, fromSkillsDir)) {
7818
8148
  warn(`Skill ID '${skillId}' resolves outside the source skills directory.`);
7819
8149
  return;
@@ -7840,7 +8170,7 @@ async function migrateLocalSkillScope(skillId, fromScope, projectDir) {
7840
8170
 
7841
8171
  // src/cli/lib/matrix/matrix-loader.ts
7842
8172
  import { parse as parseYaml5 } from "yaml";
7843
- import path28 from "path";
8173
+ import path27 from "path";
7844
8174
  async function loadSkillCategories(configPath) {
7845
8175
  const data = await loadConfig(configPath, skillCategoriesFileSchema);
7846
8176
  if (!data) {
@@ -7868,29 +8198,33 @@ async function loadSkillRules(configPath) {
7868
8198
  }
7869
8199
  async function extractAllSkills(skillsDir2) {
7870
8200
  const metadataFiles = await glob(`**/${STANDARD_FILES.METADATA_YAML}`, skillsDir2);
7871
- const skills = [];
8201
+ const folders = [];
7872
8202
  for (const metadataFile of metadataFiles) {
7873
- const skill = await extractSkill(skillsDir2, metadataFile);
7874
- if (skill) skills.push(skill);
8203
+ folders.push(await readSkillFolder(skillsDir2, metadataFile));
7875
8204
  }
7876
- return skills;
8205
+ return {
8206
+ skills: folders.flatMap((folder) => folder.kind === "loaded" ? [folder.skill] : []),
8207
+ unloadedSkillIds: folders.flatMap(
8208
+ (folder) => folder.kind === "unloaded" ? [folder.skillId] : []
8209
+ )
8210
+ };
7877
8211
  }
7878
- async function extractSkill(skillsDir2, metadataFile) {
7879
- const skillDir = path28.dirname(metadataFile);
7880
- const skillMdPath = path28.join(skillsDir2, skillDir, STANDARD_FILES.SKILL_MD);
8212
+ async function readSkillFolder(skillsDir2, metadataFile) {
8213
+ const skillDir = path27.dirname(metadataFile);
8214
+ const skillMdPath = path27.join(skillsDir2, skillDir, STANDARD_FILES.SKILL_MD);
7881
8215
  if (!await fileExists(skillMdPath)) {
7882
- verbose(`Skipping ${metadataFile}: No ${STANDARD_FILES.SKILL_MD} found`);
7883
- return null;
8216
+ warn(`Skipping '${metadataFile}': No ${STANDARD_FILES.SKILL_MD} found`);
8217
+ return { kind: "unnamed" };
7884
8218
  }
7885
- const metadata = await readMatrixMetadataOrWarn(metadataFile, path28.join(skillsDir2, metadataFile));
7886
- if (!metadata) return null;
8219
+ const metadata = await readMatrixMetadataOrWarn(metadataFile, path27.join(skillsDir2, metadataFile));
8220
+ if (!metadata) return unloadedSkillNamedBy(skillMdPath);
7887
8221
  const frontmatter = parseFrontmatterOrWarn(skillDir, skillMdPath, await readFile(skillMdPath));
7888
- if (!frontmatter) return null;
8222
+ if (!frontmatter) return { kind: "unnamed" };
7889
8223
  if (!metadata.displayName) {
7890
8224
  warn(
7891
8225
  `Skipping '${metadataFile}': invalid ${STANDARD_FILES.METADATA_YAML} \u2014 missing required field: ${METADATA_KEYS.DISPLAY_NAME}`
7892
8226
  );
7893
- return null;
8227
+ return { kind: "unloaded", skillId: frontmatter.name };
7894
8228
  }
7895
8229
  const skillId = frontmatter.name;
7896
8230
  const extracted = {
@@ -7908,7 +8242,16 @@ async function extractSkill(skillsDir2, metadataFile) {
7908
8242
  ...metadata.custom === true ? { custom: true } : {}
7909
8243
  };
7910
8244
  verbose(`Extracted skill: ${skillId}`);
7911
- return extracted;
8245
+ return { kind: "loaded", skill: extracted };
8246
+ }
8247
+ async function unloadedSkillNamedBy(skillMdPath) {
8248
+ try {
8249
+ const frontmatter = parseFrontmatter(await readFile(skillMdPath), skillMdPath);
8250
+ return frontmatter ? { kind: "unloaded", skillId: frontmatter.name } : { kind: "unnamed" };
8251
+ } catch (error) {
8252
+ verbose(`No skill named by '${skillMdPath}' \u2014 ${getErrorMessage(error)}`);
8253
+ return { kind: "unnamed" };
8254
+ }
7912
8255
  }
7913
8256
  async function readMatrixMetadataOrWarn(metadataFile, metadataPath) {
7914
8257
  const metadataContent = await readFile(metadataPath);
@@ -7936,7 +8279,7 @@ function parseFrontmatterOrWarn(skillDir, skillMdPath, skillMdContent) {
7936
8279
  const unreadable = unreadableFrontmatter(skillMdContent);
7937
8280
  if (unreadable !== void 0) {
7938
8281
  warn(
7939
- `Skipping '${path28.join(skillDir, STANDARD_FILES.SKILL_MD)}': unparseable ${STANDARD_FILES.SKILL_MD} frontmatter at ${skillMdPath} \u2014 ${unreadable}`
8282
+ `Skipping '${path27.join(skillDir, STANDARD_FILES.SKILL_MD)}': unparseable ${STANDARD_FILES.SKILL_MD} frontmatter at ${skillMdPath} \u2014 ${unreadable}`
7940
8283
  );
7941
8284
  }
7942
8285
  return null;
@@ -9825,10 +10168,17 @@ async function loadCatalogue(options) {
9825
10168
  const resolvedProjectDir = projectDir || process.cwd();
9826
10169
  const result = {
9827
10170
  ...catalogue,
9828
- marketplaceSkillIds: new Set(typedKeys(catalogue.matrix.skills))
10171
+ marketplaceSkillIds: new Set(typedKeys(catalogue.matrix.skills)),
10172
+ marketplaceSkills: { ...catalogue.matrix.skills }
9829
10173
  };
9830
- result.matrix = await mergeLocalSkills(result.matrix, resolvedProjectDir, provider);
9831
- await seatGlobalInstallationSkills(result.matrix, source, purpose);
10174
+ const globalProvider = provider ?? inheritedGlobalProvider(resolvedProjectDir);
10175
+ result.matrix = await mergeLocalSkills(
10176
+ result.matrix,
10177
+ resolvedProjectDir,
10178
+ provider,
10179
+ globalProvider
10180
+ );
10181
+ await seatGlobalInstallationSkills(result.matrix, source, purpose, globalProvider);
9832
10182
  if (!options.skipExtraSources) {
9833
10183
  await loadSkillsFromAllSources(
9834
10184
  result.matrix,
@@ -9842,16 +10192,20 @@ async function loadCatalogue(options) {
9842
10192
  initializeMatrix(result.matrix);
9843
10193
  return result;
9844
10194
  }
9845
- async function seatGlobalInstallationSkills(matrix2, loadedSource, purpose) {
9846
- const uncarried = await globalPluginSkillsUncarried(matrix2);
10195
+ async function seatGlobalInstallationSkills(matrix2, loadedSource, purpose, globalProvider) {
10196
+ const uncarried = await globalPluginSkillsUncarried(matrix2, globalProvider);
9847
10197
  if (uncarried.length === 0) return;
9848
- const globalCatalogue = await loadGlobalInstallationCatalogue(loadedSource, purpose);
10198
+ const globalCatalogue = await loadGlobalInstallationCatalogue(
10199
+ loadedSource,
10200
+ purpose,
10201
+ globalProvider
10202
+ );
9849
10203
  if (globalCatalogue === null) return;
9850
10204
  for (const id of uncarried) seatFromCatalogue(matrix2, globalCatalogue, id);
9851
10205
  }
9852
- async function globalPluginSkillsUncarried(matrix2) {
10206
+ async function globalPluginSkillsUncarried(matrix2, globalProvider) {
9853
10207
  try {
9854
- const globalConfig = await loadGlobalSourceConfig();
10208
+ const globalConfig = await loadGlobalSourceConfig(globalProvider);
9855
10209
  return (globalConfig?.skills ?? []).filter(isActivePlugin).filter((skill) => matrix2.skills[skill.id] === void 0).map((skill) => skill.id);
9856
10210
  } catch (error) {
9857
10211
  verbose(`Global installation's skills not seated \u2014 ${getErrorMessage(error)}`);
@@ -9861,9 +10215,13 @@ async function globalPluginSkillsUncarried(matrix2) {
9861
10215
  function isActivePlugin(skill) {
9862
10216
  return !skill.excluded && skill.origin !== EJECT_SOURCE;
9863
10217
  }
9864
- async function loadGlobalInstallationCatalogue(loadedSource, purpose) {
10218
+ async function loadGlobalInstallationCatalogue(loadedSource, purpose, globalProvider) {
9865
10219
  try {
9866
- const globalSourceConfig = await resolveSource({ caller: "stored", projectDir: os14.homedir() });
10220
+ const globalSourceConfig = await resolveSource({
10221
+ caller: "stored",
10222
+ projectDir: os14.homedir(),
10223
+ provider: globalProvider
10224
+ });
9867
10225
  if (globalSourceConfig.source === loadedSource) return null;
9868
10226
  return await resolveBaseResult(globalSourceConfig, {
9869
10227
  purpose,
@@ -9919,6 +10277,8 @@ async function resolveBaseResult(sourceConfig, { purpose, devMode, matrixOnly })
9919
10277
  const fetched = matrixOnly ? NOTHING_FETCHED : await fetchFromSource(source);
9920
10278
  return {
9921
10279
  matrix: copyOfBuiltInMatrix(),
10280
+ // Checked when it was generated, so nothing in it failed to load.
10281
+ unloadedSkillIds: /* @__PURE__ */ new Set(),
9922
10282
  sourceConfig,
9923
10283
  sourcePath: fetched.path,
9924
10284
  isLocal: false,
@@ -9989,8 +10349,8 @@ function goesOnWithoutManifest(source, purpose) {
9989
10349
  function configuredLabel(sourceConfig) {
9990
10350
  return sourceConfig.marketplace === void 0 ? {} : { marketplace: sourceConfig.marketplace };
9991
10351
  }
9992
- async function mergeLocalSkills(matrix2, projectDir, provider) {
9993
- const withGlobal = isHomeDirectory(projectDir) ? matrix2 : await mergeDiscoveredLocalSkills(matrix2, os14.homedir(), "global", provider);
10352
+ async function mergeLocalSkills(matrix2, projectDir, provider, globalProvider) {
10353
+ const withGlobal = isHomeDirectory(projectDir) ? matrix2 : await mergeDiscoveredLocalSkills(matrix2, os14.homedir(), "global", globalProvider);
9994
10354
  return mergeDiscoveredLocalSkills(withGlobal, projectDir, "project", provider);
9995
10355
  }
9996
10356
  async function mergeDiscoveredLocalSkills(matrix2, dir, label, provider) {
@@ -10004,10 +10364,11 @@ async function mergeDiscoveredLocalSkills(matrix2, dir, label, provider) {
10004
10364
  async function loadFromLocal(source, sourceConfig, purpose) {
10005
10365
  const skillsPath = isLocalSource(source) ? (await fetchFromSource(source)).path : PROJECT_ROOT;
10006
10366
  verbose(`Loading skills from local path: ${skillsPath}`);
10007
- const mergedMatrix = await loadAndMergeFromBasePath(skillsPath, source);
10367
+ const { matrix: matrix2, unloadedSkillIds } = await loadAndMergeFromBasePath(skillsPath, source);
10008
10368
  const labels = await resolveMarketplaceLabels(skillsPath, sourceConfig, purpose);
10009
10369
  return {
10010
- matrix: mergedMatrix,
10370
+ matrix: matrix2,
10371
+ unloadedSkillIds,
10011
10372
  sourceConfig,
10012
10373
  sourcePath: skillsPath,
10013
10374
  isLocal: true,
@@ -10019,10 +10380,11 @@ async function loadFromRemote(source, sourceConfig, purpose) {
10019
10380
  verbose(`Fetching skills from remote source: ${source}`);
10020
10381
  const fetchResult = await fetchFromSource(source);
10021
10382
  verbose(`Fetched to: ${fetchResult.path}`);
10022
- const mergedMatrix = await loadAndMergeFromBasePath(fetchResult.path, source);
10383
+ const { matrix: matrix2, unloadedSkillIds } = await loadAndMergeFromBasePath(fetchResult.path, source);
10023
10384
  const labels = await resolveMarketplaceLabels(source, sourceConfig, purpose);
10024
10385
  return {
10025
- matrix: mergedMatrix,
10386
+ matrix: matrix2,
10387
+ unloadedSkillIds,
10026
10388
  sourceConfig,
10027
10389
  sourcePath: fetchResult.path,
10028
10390
  isLocal: false,
@@ -10031,7 +10393,7 @@ async function loadFromRemote(source, sourceConfig, purpose) {
10031
10393
  };
10032
10394
  }
10033
10395
  async function loadMarketplaceMatrix(marketplaceDir) {
10034
- const matrix2 = await loadAndMergeFromBasePath(marketplaceDir, marketplaceDir);
10396
+ const { matrix: matrix2 } = await loadAndMergeFromBasePath(marketplaceDir, marketplaceDir);
10035
10397
  return { ...matrix2, categories: categoriesTheseSkillsAreIn(matrix2) };
10036
10398
  }
10037
10399
  function categoriesTheseSkillsAreIn(matrix2) {
@@ -10047,16 +10409,17 @@ async function loadAndMergeFromBasePath(basePath, source) {
10047
10409
  const skillsDirRelPath = sourceProjectConfig?.skillsDir ?? SKILLS_DIR_PATH;
10048
10410
  const stacksRelFile = sourceProjectConfig?.stacksFile;
10049
10411
  const { categories, sourceRules } = await loadSourceTaxonomy(basePath);
10050
- const skillsDir2 = path29.join(basePath, skillsDirRelPath);
10412
+ const skillsDir2 = path28.join(basePath, skillsDirRelPath);
10051
10413
  verbose(`Skills from source: ${skillsDir2}`);
10052
- const skills = await extractAllSkills(skillsDir2);
10414
+ const { skills, unloadedSkillIds } = await extractAllSkills(skillsDir2);
10053
10415
  await refuseCatalogueCollisions(basePath, source, skills);
10054
10416
  const relationships = relationshipsForSource(skills, sourceRules);
10055
10417
  const mergedMatrix = mergeMatrixWithSkills(categories, relationships, skills);
10056
- initializeMatrix(mergedMatrix);
10057
10418
  const stacks = await resolveOfferedStacks(basePath, stacksRelFile, source);
10058
- mergedMatrix.suggestedStacks = stacks.map((stack) => convertStackToResolvedStack(stack));
10059
- return mergedMatrix;
10419
+ mergedMatrix.suggestedStacks = stacks.map(
10420
+ (stack) => convertStackToResolvedStack(stack, mergedMatrix)
10421
+ );
10422
+ return { matrix: mergedMatrix, unloadedSkillIds: new Set(unloadedSkillIds) };
10060
10423
  }
10061
10424
  async function loadSourceTaxonomy(basePath) {
10062
10425
  const sourceCategories = await loadSourceCategories(basePath);
@@ -10070,7 +10433,7 @@ async function loadSourceTaxonomy(basePath) {
10070
10433
  return { categories, sourceRules };
10071
10434
  }
10072
10435
  async function loadSourceCategories(basePath) {
10073
- const categoriesPath = path29.join(basePath, SKILL_CATEGORIES_PATH);
10436
+ const categoriesPath = path28.join(basePath, SKILL_CATEGORIES_PATH);
10074
10437
  if (!await fileExists(categoriesPath)) return void 0;
10075
10438
  const categories = await loadSkillCategories(categoriesPath);
10076
10439
  verbose(
@@ -10079,7 +10442,7 @@ async function loadSourceCategories(basePath) {
10079
10442
  return categories;
10080
10443
  }
10081
10444
  async function loadSourceRules(basePath) {
10082
- const rulesPath = path29.join(basePath, SKILL_RULES_PATH);
10445
+ const rulesPath = path28.join(basePath, SKILL_RULES_PATH);
10083
10446
  if (!await fileExists(rulesPath)) return void 0;
10084
10447
  const rules = await loadSkillRules(rulesPath);
10085
10448
  verbose(`Loaded source rules: ${rulesPath}`);
@@ -10133,11 +10496,12 @@ function withdrawnSkillsWarning(stack, withdrawn) {
10133
10496
  const named = withdrawn.map((id) => `'${id}'`).join(", ");
10134
10497
  return `Stack '${stack.id}' names ${withdrawn.length} skill(s) this marketplace's catalogue does not carry: ${named}. Left out of the stack \u2014 selecting it would install nothing.`;
10135
10498
  }
10136
- function convertStackToResolvedStack(stack) {
10499
+ function convertStackToResolvedStack(stack, catalogue) {
10137
10500
  const { declared, undeclared } = declaredAgentsIn(stack);
10138
10501
  if (undeclared.length > 0) warn(undeclaredAgentsWarning(stack, undeclared));
10502
+ const isCarried = carriedBy(catalogue);
10139
10503
  const agentConfigs = agentConfigsFor(stack, declared);
10140
- const [allSkillIds, withdrawn] = partition4(namedSkillIds(agentConfigs), isInCurrentCatalogue);
10504
+ const [allSkillIds, withdrawn] = partition5(namedSkillIds(agentConfigs), isCarried);
10141
10505
  if (withdrawn.length > 0) warn(withdrawnSkillsWarning(stack, withdrawn));
10142
10506
  verbose(
10143
10507
  `Stack '${stack.id}' has ${allSkillIds.length} skills from ${agentConfigs.length} agents`
@@ -10146,7 +10510,7 @@ function convertStackToResolvedStack(stack) {
10146
10510
  id: stack.id,
10147
10511
  name: stack.name,
10148
10512
  description: stack.description,
10149
- skills: skillsByAgent(agentConfigs),
10513
+ skills: skillsByAgent(agentConfigs, isCarried),
10150
10514
  allSkillIds,
10151
10515
  philosophy: stack.philosophy || ""
10152
10516
  };
@@ -10164,21 +10528,21 @@ function namedSkillIds(agentConfigs) {
10164
10528
  )
10165
10529
  );
10166
10530
  }
10167
- function isInCurrentCatalogue(id) {
10168
- return id in matrix.skills;
10531
+ function carriedBy(catalogue) {
10532
+ return (id) => id in catalogue.skills;
10169
10533
  }
10170
- function skillsByAgent(agentConfigs) {
10534
+ function skillsByAgent(agentConfigs, isCarried) {
10171
10535
  return typedFromEntries(
10172
10536
  agentConfigs.map(
10173
- ({ agentId, agentConfig }) => [agentId, resolveStackAgentSkills(agentConfig)]
10537
+ ({ agentId, agentConfig }) => [agentId, resolveStackAgentSkills(agentConfig, isCarried)]
10174
10538
  )
10175
10539
  );
10176
10540
  }
10177
- function resolveStackAgentSkills(agentConfig) {
10541
+ function resolveStackAgentSkills(agentConfig, isCarried) {
10178
10542
  const carriedByCategory = typedEntries(agentConfig).map(
10179
10543
  ([category, assignments]) => (
10180
10544
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Object.entries drops the `| undefined` a Partial<Record> admits
10181
- [category, (assignments ?? []).map((a) => a.id).filter(isInCurrentCatalogue)]
10545
+ [category, (assignments ?? []).map((a) => a.id).filter(isCarried)]
10182
10546
  )
10183
10547
  );
10184
10548
  return typedFromEntries(carriedByCategory.filter(([, ids]) => ids.length > 0));
@@ -10187,7 +10551,7 @@ function declaresCategory(matrix2, category) {
10187
10551
  return category !== LOCAL_PSEUDO_CATEGORY && matrix2.categories[category] !== void 0;
10188
10552
  }
10189
10553
  function undeclaredCategoryRefusal(metadata, category) {
10190
- const metadataPath = path29.join(metadata.path, STANDARD_FILES.METADATA_YAML);
10554
+ const metadataPath = path28.join(metadata.path, STANDARD_FILES.METADATA_YAML);
10191
10555
  return `Skipping local skill '${metadata.id}': ${METADATA_KEYS.CATEGORY} '${category}' is not one this installation declares, so the skill belongs in no grid tab and can be given to no sub-agent. Set ${METADATA_KEYS.CATEGORY} in ${metadataPath} to a category that already exists \u2014 a skill is placed in the taxonomy, it does not extend it.`;
10192
10556
  }
10193
10557
  function mergeLocalSkillsIntoMatrix(matrix2, localResult) {
@@ -10259,10 +10623,14 @@ export {
10259
10623
  pluginRefFor,
10260
10624
  renderAgent,
10261
10625
  renderAgentBody,
10626
+ isHomeDirectory,
10262
10627
  sourceRootOf,
10263
- retiredSourceFolderIn,
10628
+ rootsHoldingTheRetiredSourceFolder,
10264
10629
  chooseProviderForThisRun,
10630
+ forgetTheProviderChosenForThisRun,
10265
10631
  providerInUse,
10632
+ inheritedGlobalProvider,
10633
+ providerAtScope,
10266
10634
  sourceFolderInUse,
10267
10635
  relativeConfigPath,
10268
10636
  sourceFolderName,
@@ -10319,7 +10687,7 @@ export {
10319
10687
  sharedSkillsLeftBehind,
10320
10688
  sharedConfigExistingInstall,
10321
10689
  sharedConfigProjectScopeAtHome,
10322
- skippedUnknownSkills,
10690
+ skippedSkills,
10323
10691
  skippedUnknownAgents,
10324
10692
  carriedSkillsWritten,
10325
10693
  SHARED_CONFIG_APPLY,
@@ -10347,7 +10715,7 @@ export {
10347
10715
  scopeNoun,
10348
10716
  scopeLabel,
10349
10717
  layoutIsCurrent,
10350
- retiredSourceFolderUnsupported,
10718
+ retiredSourceFolderIgnored,
10351
10719
  GlobalPairWriteViolation,
10352
10720
  withGateToken,
10353
10721
  assertGateToken,
@@ -10389,7 +10757,6 @@ export {
10389
10757
  resolveInstallPaths,
10390
10758
  providerToNameAt,
10391
10759
  initProviderToNameAt,
10392
- isHomeDirectory,
10393
10760
  SOURCE_ENV_VAR,
10394
10761
  readSourceRepoConfig,
10395
10762
  loadSourceRepoConfig,
@@ -10405,16 +10772,17 @@ export {
10405
10772
  resolveAgentConfigToSkills,
10406
10773
  getStackSkillIds,
10407
10774
  ConfigLoadError,
10775
+ declaresNoContent,
10408
10776
  loadProjectConfigFromDir,
10409
10777
  loadProjectConfigAt,
10410
10778
  loadInstalledConfig,
10411
- configDirsInPlay,
10779
+ configsInPlay,
10412
10780
  findConfigLoadFailures,
10413
10781
  loadProjectConfig,
10782
+ loadConfigInPlay,
10414
10783
  validateProjectConfig,
10415
10784
  INSTALL_MODE_LABELS,
10416
10785
  INSTALL_MODE_DESCRIPTIONS,
10417
- declaresNoContent,
10418
10786
  deriveInstallMode,
10419
10787
  detectProjectInstallation,
10420
10788
  holdsItsOwnInstallation,
@@ -10456,6 +10824,7 @@ export {
10456
10824
  readLocalSkillMetadata,
10457
10825
  validateSkillPath,
10458
10826
  copySkillsToLocalFlattened,
10827
+ copyMarketplaceSkillsToLocalFlattened,
10459
10828
  getUserPluginsDir,
10460
10829
  getProjectPluginsDir,
10461
10830
  getPluginAgentsDir,
@@ -10485,6 +10854,7 @@ export {
10485
10854
  refuseUnofferedPlacements,
10486
10855
  hostFor,
10487
10856
  hostAt,
10857
+ getVerifiedPluginInstallPaths,
10488
10858
  discoverAllPluginSkills,
10489
10859
  listPluginNames,
10490
10860
  compileSkillPlugin,
@@ -10502,6 +10872,7 @@ export {
10502
10872
  getMarketplaceStats,
10503
10873
  MarketplaceUnreachableError,
10504
10874
  askingEachMarketplaceItself,
10875
+ stoppingOnARefusal,
10505
10876
  MarketplaceNameRefusedError,
10506
10877
  fetchMarketplace,
10507
10878
  isLocalOnlySkill,
@@ -10518,6 +10889,8 @@ export {
10518
10889
  sourceScopesInPlay,
10519
10890
  scopeRootsInPlay,
10520
10891
  detectInstallations,
10892
+ configsDeclaringNothing,
10893
+ holdsAConfigDeclaringNothing,
10521
10894
  ejectCopyFailureError,
10522
10895
  copyingBesideGlobalPlugins,
10523
10896
  installingBesideGlobalCopies,
@@ -10525,4 +10898,4 @@ export {
10525
10898
  executeMigration,
10526
10899
  keepsGlobalInstall
10527
10900
  };
10528
- //# sourceMappingURL=chunk-WVFBBZEP.js.map
10901
+ //# sourceMappingURL=chunk-YM3VEDAP.js.map