agents-inc 0.176.0 → 0.177.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 (104) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-FACDJH6O.js → chunk-2FE4AJNC.js} +20 -26
  4. package/dist/chunk-2FE4AJNC.js.map +1 -0
  5. package/dist/{chunk-U46LYYRA.js → chunk-4SIBDIIO.js} +49 -13
  6. package/dist/chunk-4SIBDIIO.js.map +1 -0
  7. package/dist/chunk-5ZK4IND4.js +30 -0
  8. package/dist/chunk-5ZK4IND4.js.map +1 -0
  9. package/dist/{chunk-MQZNDK5F.js → chunk-77SHXTDD.js} +137 -56
  10. package/dist/chunk-77SHXTDD.js.map +1 -0
  11. package/dist/{chunk-U672FZVC.js → chunk-7OJ2SS4E.js} +10 -86
  12. package/dist/chunk-7OJ2SS4E.js.map +1 -0
  13. package/dist/{chunk-C2BSCEDN.js → chunk-7WN6TUZP.js} +7 -8
  14. package/dist/chunk-7WN6TUZP.js.map +1 -0
  15. package/dist/chunk-AVKX3IXF.js +117 -0
  16. package/dist/chunk-AVKX3IXF.js.map +1 -0
  17. package/dist/{chunk-ENET4IF6.js → chunk-D2PC7NIR.js} +1653 -1734
  18. package/dist/chunk-D2PC7NIR.js.map +1 -0
  19. package/dist/{chunk-JTMSFBCA.js → chunk-E6W3PYGF.js} +823 -72
  20. package/dist/chunk-E6W3PYGF.js.map +1 -0
  21. package/dist/chunk-H33ZAEKH.js +147 -0
  22. package/dist/chunk-H33ZAEKH.js.map +1 -0
  23. package/dist/{chunk-B7AVWSK2.js → chunk-JEFVFZAR.js} +39 -151
  24. package/dist/chunk-JEFVFZAR.js.map +1 -0
  25. package/dist/{chunk-UE4Z3YMB.js → chunk-KKGJH46C.js} +3 -21
  26. package/dist/chunk-KKGJH46C.js.map +1 -0
  27. package/dist/chunk-OIQKRXHH.js +142 -0
  28. package/dist/chunk-OIQKRXHH.js.map +1 -0
  29. package/dist/{chunk-CKBWEWHZ.js → chunk-TNN72UL6.js} +264 -247
  30. package/dist/chunk-TNN72UL6.js.map +1 -0
  31. package/dist/{chunk-XMQIWPIR.js → chunk-V3WJMNBF.js} +45 -18
  32. package/dist/chunk-V3WJMNBF.js.map +1 -0
  33. package/dist/chunk-VFD2XYM7.js +14 -0
  34. package/dist/chunk-VFD2XYM7.js.map +1 -0
  35. package/dist/{chunk-XYBHH3M5.js → chunk-WH7JXGDA.js} +2 -2
  36. package/dist/{chunk-JNRACLNS.js → chunk-XSR4WRXJ.js} +3 -3
  37. package/dist/{chunk-3F5LT433.js → chunk-Y5VMB73R.js} +202 -116
  38. package/dist/chunk-Y5VMB73R.js.map +1 -0
  39. package/dist/chunk-ZIBWVTLN.js +18 -0
  40. package/dist/chunk-ZIBWVTLN.js.map +1 -0
  41. package/dist/commands/build/marketplace.js +6 -10
  42. package/dist/commands/build/marketplace.js.map +1 -1
  43. package/dist/commands/build/plugins.js +10 -39
  44. package/dist/commands/build/plugins.js.map +1 -1
  45. package/dist/commands/compile.js +60 -81
  46. package/dist/commands/compile.js.map +1 -1
  47. package/dist/commands/doctor.js +234 -145
  48. package/dist/commands/doctor.js.map +1 -1
  49. package/dist/commands/edit.js +64 -159
  50. package/dist/commands/edit.js.map +1 -1
  51. package/dist/commands/eject.js +64 -54
  52. package/dist/commands/eject.js.map +1 -1
  53. package/dist/commands/init.js +19 -17
  54. package/dist/commands/list.js +10 -12
  55. package/dist/commands/list.js.map +1 -1
  56. package/dist/commands/new/marketplace.js +5 -5
  57. package/dist/commands/search.js +14 -13
  58. package/dist/commands/search.js.map +1 -1
  59. package/dist/commands/share.js +21 -44
  60. package/dist/commands/share.js.map +1 -1
  61. package/dist/commands/uninstall.js +139 -56
  62. package/dist/commands/uninstall.js.map +1 -1
  63. package/dist/commands/update.js +22 -37
  64. package/dist/commands/update.js.map +1 -1
  65. package/dist/components/common/header-row.js +9 -0
  66. package/dist/components/common/select-list.js +2 -2
  67. package/dist/components/common/skill-agent-summary.js +4 -4
  68. package/dist/components/common/summary-panel.js +6 -5
  69. package/dist/hooks/init.js +35 -22
  70. package/dist/hooks/init.js.map +1 -1
  71. package/dist/load-agent-defs-OCFWOZD2.js +14 -0
  72. package/dist/{recompile-project-agents-U3UGHPWG.js → recompile-project-agents-CXZBPIUS.js} +9 -9
  73. package/dist/{recompile-project-agents-U3UGHPWG.js.map → recompile-project-agents-CXZBPIUS.js.map} +1 -1
  74. package/dist/{source-loader-E2Y5MMN5.js → source-loader-GGDQDMN4.js} +6 -4
  75. package/dist/source-loader-GGDQDMN4.js.map +1 -0
  76. package/package.json +1 -1
  77. package/src/schemas/stacks.schema.json +105 -1
  78. package/dist/chunk-3F5LT433.js.map +0 -1
  79. package/dist/chunk-5CFHP6Z5.js +0 -109
  80. package/dist/chunk-5CFHP6Z5.js.map +0 -1
  81. package/dist/chunk-B7AVWSK2.js.map +0 -1
  82. package/dist/chunk-C2BSCEDN.js.map +0 -1
  83. package/dist/chunk-CKBWEWHZ.js.map +0 -1
  84. package/dist/chunk-EC3JXT23.js +0 -160
  85. package/dist/chunk-EC3JXT23.js.map +0 -1
  86. package/dist/chunk-ENET4IF6.js.map +0 -1
  87. package/dist/chunk-FACDJH6O.js.map +0 -1
  88. package/dist/chunk-H6WUOW5F.js +0 -35
  89. package/dist/chunk-H6WUOW5F.js.map +0 -1
  90. package/dist/chunk-JTMSFBCA.js.map +0 -1
  91. package/dist/chunk-MQZNDK5F.js.map +0 -1
  92. package/dist/chunk-SN64WNWE.js +0 -428
  93. package/dist/chunk-SN64WNWE.js.map +0 -1
  94. package/dist/chunk-U46LYYRA.js.map +0 -1
  95. package/dist/chunk-U672FZVC.js.map +0 -1
  96. package/dist/chunk-UE4Z3YMB.js.map +0 -1
  97. package/dist/chunk-XMQIWPIR.js.map +0 -1
  98. package/dist/chunk-ZBI6GFJD.js +0 -39
  99. package/dist/chunk-ZBI6GFJD.js.map +0 -1
  100. package/dist/load-agent-defs-5BSECHE6.js +0 -14
  101. /package/dist/{chunk-XYBHH3M5.js.map → chunk-WH7JXGDA.js.map} +0 -0
  102. /package/dist/{chunk-JNRACLNS.js.map → chunk-XSR4WRXJ.js.map} +0 -0
  103. /package/dist/{load-agent-defs-5BSECHE6.js.map → components/common/header-row.js.map} +0 -0
  104. /package/dist/{source-loader-E2Y5MMN5.js.map → load-agent-defs-OCFWOZD2.js.map} +0 -0
@@ -1,17 +1,22 @@
1
1
  #!/usr/bin/env node
2
- import "../chunk-EC3JXT23.js";
2
+ import {
3
+ mapInTurn
4
+ } from "../chunk-VFD2XYM7.js";
5
+ import "../chunk-5ZK4IND4.js";
3
6
  import {
4
7
  filterExcludedEntries,
5
8
  listAgentFilesOf,
6
9
  listAgentMdFiles,
7
10
  splitAgentsByProvenance
8
- } from "../chunk-MQZNDK5F.js";
11
+ } from "../chunk-77SHXTDD.js";
9
12
  import {
10
13
  BaseCommand,
11
14
  EXIT_CODES,
12
- ambiguityFinding
13
- } from "../chunk-JTMSFBCA.js";
14
- import "../chunk-FACDJH6O.js";
15
+ ambiguityFinding,
16
+ placementsAskedIn,
17
+ refusalsAmong
18
+ } from "../chunk-E6W3PYGF.js";
19
+ import "../chunk-2FE4AJNC.js";
15
20
  import {
16
21
  ConfigDefaultExportError,
17
22
  ConfigEvaluationError,
@@ -39,14 +44,13 @@ import {
39
44
  formatZodErrors,
40
45
  getErrorMessage,
41
46
  getInstalledPluginsRegistryPath,
47
+ getPluginsBySwitch,
42
48
  getProjectConfigPath,
43
49
  getProjectPluginsDir,
44
50
  getStackSkillIds,
45
51
  getUserPluginsDir,
46
- getVerifiedPluginInstallPaths,
47
52
  glob,
48
53
  hostCompilesAgent,
49
- hostFor,
50
54
  inheritedGlobalProvider,
51
55
  installBaseDir,
52
56
  invalidResult,
@@ -68,14 +72,16 @@ import {
68
72
  parseMarketplacePluginRef,
69
73
  providerArgument,
70
74
  providerInUse,
75
+ providerToNameAt,
71
76
  readFile,
72
77
  readForkedFromMetadata,
73
78
  readSkillMetadata,
74
79
  recreateConfigFrom,
75
- refuseUnofferedPlacements,
76
80
  relativeConfigPath,
77
81
  resolveInstallPaths,
78
82
  resolvePrimarySourceEntry,
83
+ resultFrom,
84
+ scopeAt,
79
85
  scopeLabel,
80
86
  scopeNoun,
81
87
  scopeRootsInPlay,
@@ -94,12 +100,11 @@ import {
94
100
  validateProjectConfig,
95
101
  validateSkillFrontmatter,
96
102
  validateSkillMetadata
97
- } from "../chunk-ENET4IF6.js";
103
+ } from "../chunk-D2PC7NIR.js";
98
104
  import {
99
105
  matrix,
100
- plural,
101
- typedValues
102
- } from "../chunk-UE4Z3YMB.js";
106
+ plural
107
+ } from "../chunk-KKGJH46C.js";
103
108
  import {
104
109
  CLI_INVOKE_COMMAND,
105
110
  DEFAULT_BRANDING,
@@ -113,8 +118,9 @@ import {
113
118
  STACKS_FILE_PATH,
114
119
  STANDARD_FILES,
115
120
  UI_SYMBOLS,
116
- effectivelyExcludedSkillIds
117
- } from "../chunk-U46LYYRA.js";
121
+ effectivelyExcludedSkillIds,
122
+ typedValues
123
+ } from "../chunk-4SIBDIIO.js";
118
124
  import "../chunk-GHHJYNAN.js";
119
125
 
120
126
  // src/cli/commands/doctor.ts
@@ -153,9 +159,7 @@ async function resolveConfigState({
153
159
  }
154
160
  async function readConfigState(projectDir, hosts) {
155
161
  const own = await loadProjectConfigFromDir(projectDir, hosts.project);
156
- if (own && !declaresNoContent(own.config)) {
157
- return { kind: "loaded", config: own.config, inherited: false };
158
- }
162
+ if (own && !declaresNoContent(own.config)) return ownConfigState(own.config, projectDir, hosts);
159
163
  const inherited = isHomeDirectory(projectDir) ? null : await loadProjectConfigFromDir(os.homedir(), hosts.global);
160
164
  if (inherited && !declaresNoContent(inherited.config)) {
161
165
  return {
@@ -167,42 +171,42 @@ async function readConfigState(projectDir, hosts) {
167
171
  }
168
172
  return own ? { kind: "declares-nothing", config: own.config } : { kind: "absent" };
169
173
  }
174
+ async function ownConfigState(config, projectDir, hosts) {
175
+ const failure = isHomeDirectory(projectDir) ? null : await globalConfigLoadFailure(hosts);
176
+ return failure === null ? { kind: "loaded", config, inherited: false } : { kind: "global-unreadable", config, failure };
177
+ }
178
+ async function globalConfigLoadFailure(hosts) {
179
+ try {
180
+ await loadProjectConfigFromDir(os.homedir(), hosts.global);
181
+ return null;
182
+ } catch (error) {
183
+ if (error instanceof ConfigLoadError) return error;
184
+ throw error;
185
+ }
186
+ }
170
187
  async function providerDeclaringNothingIn(projectDir) {
171
188
  const [leftover] = await configsDeclaringNothing(projectDir);
172
189
  return leftover === void 0 ? null : leftover.provider;
173
190
  }
174
191
  async function installedPluginSkillIds(baseDir, provider) {
175
- const plugins = await getVerifiedPluginInstallPaths(baseDir, provider);
192
+ const { enabled, switchedOff } = await getPluginsBySwitch(baseDir, provider);
193
+ return { enabled: skillIdsOf(enabled), switchedOff: skillIdsOf(switchedOff) };
194
+ }
195
+ function skillIdsOf(plugins) {
176
196
  return new Set(plugins.map((plugin) => parseMarketplacePluginRef(plugin.pluginKey)));
177
197
  }
178
- async function unofferablePlacements({
198
+ async function placementsOffered({
179
199
  projectDir,
180
200
  hosts
181
201
  }) {
182
202
  const projectFirst = [...scopeRootsInPlay(projectDir)].reverse();
183
- const findings = await Promise.all(
184
- projectFirst.map(({ kind, root }) => unofferablePlacementIn(root, hosts[kind]))
203
+ const asked = await Promise.all(
204
+ projectFirst.map(({ kind, root }) => placementsAskedIn({ dir: root, provider: hosts[kind] }))
185
205
  );
186
- return findings.filter((finding) => finding !== null);
187
- }
188
- async function unofferablePlacementIn(root, provider) {
189
- const skills = await configuredSkillsAt(root, provider);
190
- if (skills === null) return null;
191
- try {
192
- refuseUnofferedPlacements(skills, hostFor(provider));
193
- return null;
194
- } catch (error) {
195
- return getErrorMessage(error);
196
- }
197
- }
198
- async function configuredSkillsAt(root, provider) {
199
- try {
200
- const loaded = await loadProjectConfigFromDir(root, provider);
201
- return loaded?.config.skills ?? null;
202
- } catch (error) {
203
- if (error instanceof ConfigLoadError) return null;
204
- throw error;
205
- }
206
+ return {
207
+ configuresASkill: asked.some(({ skills }) => skills.length > 0),
208
+ findings: refusalsAmong(asked)
209
+ };
206
210
  }
207
211
 
208
212
  // src/cli/lib/doctor/ownership.ts
@@ -314,8 +318,10 @@ async function validateSource(sourcePath, reader = "author") {
314
318
  );
315
319
  }
316
320
  async function pairSkillFiles(skillsDir2) {
317
- const skillMdFiles = await glob(`**/${STANDARD_FILES.SKILL_MD}`, skillsDir2);
318
- const metadataFiles = await glob(`**/${STANDARD_FILES.METADATA_YAML}`, skillsDir2);
321
+ const [skillMdFiles, metadataFiles] = await Promise.all([
322
+ glob(`**/${STANDARD_FILES.SKILL_MD}`, skillsDir2),
323
+ glob(`**/${STANDARD_FILES.METADATA_YAML}`, skillsDir2)
324
+ ]);
319
325
  const skillMdDirs = new Set(skillMdFiles.map((f) => path.dirname(f)));
320
326
  const metadataDirs = new Set(metadataFiles.map((f) => path.dirname(f)));
321
327
  return {
@@ -485,12 +491,9 @@ async function validateConfigFiles(resolvedPath, stacksRelFile) {
485
491
  return results.flat();
486
492
  }
487
493
  async function validateYamlFiles(scan) {
488
- const issues = [];
489
494
  const files = await glob(scan.pattern, scan.baseDir);
490
- for (const relFile of files) {
491
- issues.push(...await validateYamlFile(scan, relFile));
492
- }
493
- return issues;
495
+ const issuesPerFile = await Promise.all(files.map((relFile) => validateYamlFile(scan, relFile)));
496
+ return issuesPerFile.flat();
494
497
  }
495
498
  async function validateYamlFile(scan, relFile) {
496
499
  const displayPath = path.join(scan.relBaseDir, relFile);
@@ -539,16 +542,15 @@ function buildResult(issues, skillCount) {
539
542
 
540
543
  // src/cli/lib/content-validator.ts
541
544
  var CWD_SOURCE_NAME = "current directory";
542
- var NOTHING_VALIDATED = { count: 0, issues: [], notes: [] };
545
+ function nothingValidated() {
546
+ return { count: 0, issues: [], notes: [] };
547
+ }
543
548
  function mergeValidations(parts) {
544
- return parts.reduce(
545
- (acc, part) => ({
546
- count: acc.count + part.count,
547
- issues: [...acc.issues, ...part.issues],
548
- notes: [...acc.notes, ...part.notes]
549
- }),
550
- NOTHING_VALIDATED
551
- );
549
+ return {
550
+ count: parts.reduce((sum, part) => sum + part.count, 0),
551
+ issues: parts.flatMap((part) => part.issues),
552
+ notes: parts.flatMap((part) => part.notes)
553
+ };
552
554
  }
553
555
  function displayDir(absolutePath) {
554
556
  const home = os2.homedir();
@@ -564,6 +566,10 @@ function toIssues(file, result) {
564
566
  ...result.warnings.map((message) => ({ severity: "warning", file, message }))
565
567
  ];
566
568
  }
569
+ async function entryIssues(dir, name, validate) {
570
+ const entryPath = path2.join(dir, name);
571
+ return toIssues(displayDir(entryPath), await validate(entryPath));
572
+ }
567
573
  var CONFIG_UNREADABLE = "exists but could not be loaded";
568
574
  async function validateProjectConfigFile(projectDir) {
569
575
  const [present, failures] = await Promise.all([
@@ -636,13 +642,13 @@ async function validateInstalledPlugins(projectDir) {
636
642
  return mergeValidations(await Promise.all(dirs.map(validatePluginsDirectory)));
637
643
  }
638
644
  async function validatePluginsDirectory(pluginsDir) {
639
- if (!await directoryExists(pluginsDir)) return NOTHING_VALIDATED;
645
+ if (!await directoryExists(pluginsDir)) return nothingValidated();
640
646
  if (await fileExists(getInstalledPluginsRegistryPath(pluginsDir))) {
641
647
  const registryValidation = await validateRegistryPlugins(pluginsDir);
642
648
  if (registryValidation !== void 0) return registryValidation;
643
649
  }
644
650
  const pluginDirs = await listPluginDirNames(pluginsDir);
645
- if (pluginDirs.length === 0) return NOTHING_VALIDATED;
651
+ if (pluginDirs.length === 0) return nothingValidated();
646
652
  const { results } = await validateAllPlugins(pluginsDir);
647
653
  return {
648
654
  count: results.length,
@@ -732,18 +738,15 @@ async function listDisplayPaths(dir, listEntries) {
732
738
  return entries.map((entry) => displayDir(path2.join(dir, entry)));
733
739
  }
734
740
  async function validateSkillsDirectory(skillsDir2, configuredIds) {
735
- if (!await directoryExists(skillsDir2)) return NOTHING_VALIDATED;
741
+ if (!await directoryExists(skillsDir2)) return nothingValidated();
736
742
  const skillDirs = await listDirectories(skillsDir2);
737
- if (skillDirs.length === 0) return NOTHING_VALIDATED;
743
+ if (skillDirs.length === 0) return nothingValidated();
738
744
  const [ours, foreign] = await partitionByVerdict(
739
745
  skillDirs,
740
746
  (name) => isOurSkillDirectory(skillsDir2, name, configuredIds)
741
747
  );
742
748
  const results = await Promise.all(
743
- ours.map(async (name) => {
744
- const skillDir = path2.join(skillsDir2, name);
745
- return toIssues(displayDir(skillDir), await validateInstalledSkill(skillDir));
746
- })
749
+ ours.map((name) => entryIssues(skillsDir2, name, validateInstalledSkill))
747
750
  );
748
751
  return {
749
752
  count: ours.length,
@@ -762,14 +765,11 @@ function foreignSkillNote(skillsDir2, name) {
762
765
  return `${displayDir(path2.join(skillsDir2, name))} \u2014 not installed by this CLI and named by no configuration here: not validated`;
763
766
  }
764
767
  async function validateAgentsDirectory(agentsDir2) {
765
- if (!await directoryExists(agentsDir2)) return NOTHING_VALIDATED;
768
+ if (!await directoryExists(agentsDir2)) return nothingValidated();
766
769
  const agentFiles = await listAgentMdFiles(agentsDir2);
767
- if (agentFiles.length === 0) return NOTHING_VALIDATED;
770
+ if (agentFiles.length === 0) return nothingValidated();
768
771
  const results = await Promise.all(
769
- agentFiles.map(async (fileName) => {
770
- const agentPath = path2.join(agentsDir2, fileName);
771
- return toIssues(displayDir(agentPath), await validateAgentFrontmatter(agentPath));
772
- })
772
+ agentFiles.map((fileName) => entryIssues(agentsDir2, fileName, validateAgentFrontmatter))
773
773
  );
774
774
  return { count: agentFiles.length, issues: results.flat(), notes: [] };
775
775
  }
@@ -796,11 +796,10 @@ async function validateInstalledSkillMetadata(metadataPath) {
796
796
  return validResult();
797
797
  }
798
798
  const { errors, warnings } = splitMetadataValidationIssues(result.error, metadata);
799
- return {
800
- valid: errors.length === 0,
801
- errors: errors.map((e) => `${STANDARD_FILES.METADATA_YAML}: ${e}`),
802
- warnings: warnings.map((w) => `${STANDARD_FILES.METADATA_YAML}: ${w}`)
803
- };
799
+ return resultFrom(
800
+ errors.map((e) => `${STANDARD_FILES.METADATA_YAML}: ${e}`),
801
+ warnings.map((w) => `${STANDARD_FILES.METADATA_YAML}: ${w}`)
802
+ );
804
803
  }
805
804
 
806
805
  // src/cli/lib/doctor/ownership.ts
@@ -871,7 +870,7 @@ async function unclaimedAgentFiles({ dir, codec, claimed: claimed2 }) {
871
870
  }
872
871
 
873
872
  // src/cli/commands/doctor.ts
874
- import { countBy, unique as unique2 } from "remeda";
873
+ import { countBy, partition as partition2, unique as unique2 } from "remeda";
875
874
  function checkConfigValid(state, installation) {
876
875
  const theConfig = (verdict) => configRowMessage(state, installation, verdict);
877
876
  switch (state.kind) {
@@ -886,14 +885,11 @@ function checkConfigValid(state, installation) {
886
885
  config: null
887
886
  };
888
887
  case "unreadable":
888
+ return { result: unloadableConfigResult(state.failure, theConfig), config: null };
889
+ case "global-unreadable":
889
890
  return {
890
- result: {
891
- kind: "config",
892
- status: "fail",
893
- message: theConfig("exists but could not be loaded"),
894
- details: [state.failure.reason]
895
- },
896
- config: null
891
+ result: unloadableConfigResult(state.failure, theConfig),
892
+ config: checkLoadedConfig(state.config, theConfig).config
897
893
  };
898
894
  case "declares-nothing":
899
895
  return {
@@ -912,6 +908,14 @@ function checkConfigValid(state, installation) {
912
908
  }
913
909
  }
914
910
  }
911
+ function unloadableConfigResult(failure, theConfig) {
912
+ return {
913
+ kind: "config",
914
+ status: "fail",
915
+ message: theConfig("exists but could not be loaded"),
916
+ details: [failure.reason]
917
+ };
918
+ }
915
919
  function checkLoadedConfig(config, theConfig) {
916
920
  const validation = validateProjectConfig(config);
917
921
  if (!validation.valid) {
@@ -948,22 +952,19 @@ function checkLoadedConfig(config, theConfig) {
948
952
  function configRowMessage(state, { projectDir, hosts }, verdict) {
949
953
  if (state.kind === "loaded" && state.inherited)
950
954
  return `${theInheritedConfig(projectDir, state.declaringNothingIn, hosts.global)}, which ${verdict}`;
951
- if (state.kind === "unreadable") {
955
+ if (state.kind === "unreadable" || state.kind === "global-unreadable") {
952
956
  const { scopeRoot, scope } = state.failure;
953
957
  return `${theConfigAt(scopeRoot, hosts[scope])} ${verdict}`;
954
958
  }
955
959
  return `${theConfigAt(projectDir, hosts.project)} ${verdict}`;
956
960
  }
957
961
  function theConfigAt(root, provider) {
958
- return `${scopeLabel(scopeOf(root))}: ${configNamedFrom(root, provider)}`;
962
+ return `${scopeLabel(scopeAt(root))}: ${configNamedFrom(root, provider)}`;
959
963
  }
960
964
  function theInheritedConfig(projectDir, declaringNothingIn, provider) {
961
965
  const projectHolds = declaringNothingIn === null ? `no ${STANDARD_FILES.CONFIG_TS}` : `${relativeConfigPath(projectDir, declaringNothingIn)} declares nothing`;
962
966
  return `${scopeLabel("project")}: ${projectHolds}, using ${scopeNoun("global")}'s (${configNamedFrom(os3.homedir(), provider)})`;
963
967
  }
964
- function scopeOf(dir) {
965
- return isHomeDirectory(dir) ? "global" : "project";
966
- }
967
968
  function configNamedFrom(root, provider) {
968
969
  const relPath = relativeConfigPath(root, provider);
969
970
  return isHomeDirectory(root) ? `~/${relPath}` : relPath;
@@ -1052,11 +1053,12 @@ async function checkNoOrphans(state, config, installation) {
1052
1053
  return ownershipResult(state, await judgeOwnership(state, config, installation));
1053
1054
  }
1054
1055
  function ownershipResult(state, { unowned, orphanedAgentFiles }) {
1055
- if (unowned.skills.length > 0 || unowned.agents.length > 0) {
1056
+ const unownedCount = unowned.skills.length + unowned.agents.length;
1057
+ if (unownedCount > 0) {
1056
1058
  return {
1057
1059
  kind: "orphans-unowned",
1058
1060
  status: "fail",
1059
- message: `${countedArtifacts(unowned.skills, unowned.agents)} installed here, and no configuration declares them`,
1061
+ message: `${countedArtifacts(unowned.skills, unowned.agents)} installed here, and no configuration declares ${unownedCount === 1 ? "it" : "them"}`,
1060
1062
  details: [...unowned.skills, ...unowned.agents, ...orphanLines(orphanedAgentFiles)].map(
1061
1063
  (line) => `- ${line}`
1062
1064
  )
@@ -1085,7 +1087,7 @@ function countedArtifacts(skills, agents) {
1085
1087
  function nonZeroCounts(...counts) {
1086
1088
  return counts.filter(([count]) => count > 0).map(([count, noun]) => plural(count, noun)).join(" and ");
1087
1089
  }
1088
- async function checkSkillsInstalled(config, installation) {
1090
+ async function checkSkillsInstalled(config, installation, published) {
1089
1091
  const ejectSkills = config.skills.filter((s) => s.origin === EJECT_SOURCE);
1090
1092
  if (ejectSkills.length === 0) {
1091
1093
  return {
@@ -1103,7 +1105,9 @@ async function checkSkillsInstalled(config, installation) {
1103
1105
  kind: "installed",
1104
1106
  status: "warn",
1105
1107
  message: `${plural(missingSkills.length, "skill")} missing from disk`,
1106
- details: missingSkills.map((s) => `- ${s.id} (not found in ${s.lookedIn}/)`)
1108
+ details: missingSkills.map((s) => `- ${s.id} (not found in ${s.lookedIn}/)`),
1109
+ tipKinds: await missingSkillsTips(missingSkills, installation, published),
1110
+ providerAtHome: providerToNameAt(os3.homedir(), installation.hosts.global)
1107
1111
  };
1108
1112
  }
1109
1113
  return {
@@ -1112,12 +1116,50 @@ async function checkSkillsInstalled(config, installation) {
1112
1116
  message: `${ratio(ejectSkills.length, ejectSkills.length, "eject-mode skill")} installed`
1113
1117
  };
1114
1118
  }
1119
+ function missingSkillsTips(missingSkills, installation, published) {
1120
+ const scopes = unique2(missingSkills.map((check) => check.scope));
1121
+ return Promise.all(
1122
+ scopes.map(
1123
+ (scope) => missingFromOnePlaceTip(
1124
+ scope,
1125
+ missingSkills.filter((check) => check.scope === scope),
1126
+ installation,
1127
+ published
1128
+ )
1129
+ )
1130
+ );
1131
+ }
1132
+ async function missingFromOnePlaceTip(scope, missingSkills, installation, published) {
1133
+ const atHome = scope !== scopeAt(installation.projectDir);
1134
+ if (await ejectRestoresEvery(missingSkills, installation, published)) {
1135
+ return atHome ? "installed-at-home" : "installed";
1136
+ }
1137
+ return atHome ? "installed-take-out-at-home" : "installed-take-out";
1138
+ }
1139
+ var EDITOR_ADDED_SKILL_ID_PREFIX = "external-";
1140
+ async function ejectRestoresEvery(missingSkills, { projectDir, hosts }, published) {
1141
+ const unrestorable = missingSkills.some(
1142
+ (check) => check.id.startsWith(EDITOR_ADDED_SKILL_ID_PREFIX) || noLongerPublished(check, published)
1143
+ );
1144
+ if (unrestorable) return false;
1145
+ const globalSkillsDir = skillsDir(hosts.global, "global", projectDir);
1146
+ const heldGlobally = await Promise.all(
1147
+ missingSkills.map(
1148
+ (check) => fileExists(path4.join(globalSkillsDir, check.id, STANDARD_FILES.SKILL_MD))
1149
+ )
1150
+ );
1151
+ return !heldGlobally.includes(true);
1152
+ }
1153
+ function noLongerPublished(check, published) {
1154
+ return published !== null && !published.has(check.id);
1155
+ }
1115
1156
  async function ejectedSkillCheck(skill, { projectDir, hosts }) {
1116
1157
  const provider = hosts[skill.scope];
1117
1158
  const dir = skillsDir(provider, skill.scope, projectDir);
1118
1159
  const installed = await fileExists(path4.join(dir, skill.id, STANDARD_FILES.SKILL_MD));
1119
1160
  return {
1120
1161
  id: skill.id,
1162
+ scope: skill.scope,
1121
1163
  installed,
1122
1164
  lookedIn: skillsPathPrefix(provider, skill.scope, projectDir)
1123
1165
  };
@@ -1140,8 +1182,8 @@ async function checkPluginSkillsInstalled(config, installation) {
1140
1182
  return {
1141
1183
  kind: "plugins",
1142
1184
  status: "warn",
1143
- message: `${plural(missingSkills.length, "skill")} not installed as plugins`,
1144
- details: missingSkills.map((s) => `- ${s} (no enabled plugin found)`)
1185
+ message: missingPluginsHeadline(missingSkills),
1186
+ details: missingSkills.map(missingPluginLine)
1145
1187
  };
1146
1188
  }
1147
1189
  return {
@@ -1150,12 +1192,25 @@ async function checkPluginSkillsInstalled(config, installation) {
1150
1192
  message: `${ratio(pluginSkills.length, pluginSkills.length, "plugin-mode skill")} installed`
1151
1193
  };
1152
1194
  }
1195
+ function missingPluginsHeadline(missing) {
1196
+ const [switchedOff, notInstalled] = partition2(missing, (skill) => skill.switchedOff);
1197
+ return [
1198
+ ...notInstalled.length > 0 ? [notInstalledAsPlugins(notInstalled.length)] : [],
1199
+ ...switchedOff.length > 0 ? [pluginsSwitchedOff(switchedOff.length)] : []
1200
+ ].join(" and ");
1201
+ }
1202
+ function notInstalledAsPlugins(count) {
1203
+ return `${plural(count, "skill")} not installed as ${count === 1 ? "a plugin" : "plugins"}`;
1204
+ }
1205
+ function pluginsSwitchedOff(count) {
1206
+ return `${plural(count, "plugin")} switched off`;
1207
+ }
1208
+ function missingPluginLine({ id, switchedOff }) {
1209
+ return `- ${id} ${switchedOff ? "(plugin switched off)" : "(no enabled plugin found)"}`;
1210
+ }
1153
1211
  async function pluginSkillsMissingAt(scope, pluginSkills, { projectDir, hosts }) {
1154
- const installedIds = await installedPluginSkillIds(
1155
- installBaseDir(projectDir, scope),
1156
- hosts[scope]
1157
- );
1158
- return pluginSkills.filter((skill) => skill.scope === scope).filter((skill) => !installedIds.has(skill.id)).map((skill) => skill.id);
1212
+ const installed = await installedPluginSkillIds(installBaseDir(projectDir, scope), hosts[scope]);
1213
+ return pluginSkills.filter((skill) => skill.scope === scope).filter((skill) => !installed.enabled.has(skill.id)).map((skill) => ({ id: skill.id, switchedOff: installed.switchedOff.has(skill.id) }));
1159
1214
  }
1160
1215
  var MARKETPLACE_CHOSEN_BY = {
1161
1216
  flag: "named by this run",
@@ -1188,14 +1243,15 @@ async function checkSourceReachable({
1188
1243
  hosts
1189
1244
  }) {
1190
1245
  try {
1191
- return await askingEachMarketplaceItself(
1192
- async (differingCopiesReplaced) => reachedMarketplace(
1193
- await loadSkillsMatrixFromSource({ projectDir, provider: hosts.project }),
1194
- differingCopiesReplaced
1195
- )
1196
- );
1246
+ return await askingEachMarketplaceItself(async (differingCopiesReplaced) => {
1247
+ const loaded = await loadSkillsMatrixFromSource({ projectDir, provider: hosts.project });
1248
+ return {
1249
+ result: reachedMarketplace(loaded, differingCopiesReplaced),
1250
+ published: loaded.marketplaceSkillIds
1251
+ };
1252
+ });
1197
1253
  } catch (error) {
1198
- return marketplaceNotLoaded(error);
1254
+ return { result: marketplaceNotLoaded(error), published: null };
1199
1255
  }
1200
1256
  }
1201
1257
  var NO_SAVED_COPY_READ = "Doctor asks the marketplace itself, not the saved copy, which other commands still read offline";
@@ -1340,7 +1396,7 @@ var TIPS = [
1340
1396
  {
1341
1397
  kind: "agents",
1342
1398
  status: "warn",
1343
- line: (provider) => ` Tip: Run '${commandActingOn(provider, "compile")}' to generate missing agent files`
1399
+ line: ({ provider }) => ` Tip: Run '${commandActingOn(provider, "compile")}' to generate missing agent files`
1344
1400
  },
1345
1401
  {
1346
1402
  kind: "config",
@@ -1355,7 +1411,7 @@ var TIPS = [
1355
1411
  {
1356
1412
  kind: "orphans-unowned",
1357
1413
  status: "fail",
1358
- line: (provider) => ` Tip: Nothing declares the files above \u2014 '${commandActingOn(provider, "init --from <id>")}' writes a configuration that can own them again, or '${commandActingOn(provider, "uninstall")}' removes them, the compiled agents included: each file listed carries this CLI's own provenance, which is what that command reads when there is no configuration left`
1414
+ line: ({ provider }) => ` Tip: Nothing declares the files above \u2014 '${commandActingOn(provider, "init --from <id>")}' writes a configuration that can own them again, or '${commandActingOn(provider, "uninstall")}' removes them, the compiled agents included: each file listed carries this CLI's own provenance, which is what that command reads when there is no configuration left`
1359
1415
  },
1360
1416
  {
1361
1417
  kind: "skills",
@@ -1365,21 +1421,42 @@ var TIPS = [
1365
1421
  {
1366
1422
  kind: "installed",
1367
1423
  status: "warn",
1368
- // No command named: `eject skills --force` copies every skill, and only at project scope.
1369
- line: () => " Tip: Re-eject the missing skills from the marketplace to restore their files"
1424
+ line: ({ provider }, scope) => bothWaysOut(provider, scopeNoun(scope))
1425
+ },
1426
+ {
1427
+ kind: "installed-take-out",
1428
+ status: "warn",
1429
+ line: ({ provider }) => takeOut(provider)
1430
+ },
1431
+ {
1432
+ kind: "installed-at-home",
1433
+ status: "warn",
1434
+ line: ({ providerAtHome }) => bothWaysOut(providerAtHome, scopeNoun("global"), IN_YOUR_HOME_FOLDER)
1435
+ },
1436
+ {
1437
+ kind: "installed-take-out-at-home",
1438
+ status: "warn",
1439
+ line: ({ providerAtHome }) => takeOut(providerAtHome, IN_YOUR_HOME_FOLDER)
1370
1440
  }
1371
1441
  ];
1372
1442
  function commandActingOn(provider, command) {
1373
1443
  return `${CLI_INVOKE_COMMAND} ${command}${providerArgument(provider)}`;
1374
1444
  }
1375
- function formatTips(results) {
1376
- return unique2(TIPS.flatMap((tip) => linesOf(tip, results)));
1445
+ var IN_YOUR_HOME_FOLDER = " in your home folder";
1446
+ function takeOut(provider, where = "") {
1447
+ return ` Tip: If you removed the missing skills on purpose, take them out with '${commandActingOn(provider, "edit")}'${where}`;
1377
1448
  }
1378
- function linesOf(tip, results) {
1379
- return results.filter((result) => answers(tip, result)).map((result) => tip.line(result.provider));
1449
+ function bothWaysOut(provider, installation, where = "") {
1450
+ return `${takeOut(provider, where)}; to bring them back, run '${commandActingOn(provider, "eject skills")}'${where}, which also copies every other marketplace skill ${installation} lacks`;
1451
+ }
1452
+ function formatTips(results, scope) {
1453
+ return unique2(TIPS.flatMap((tip) => linesOf(tip, results, scope)));
1454
+ }
1455
+ function linesOf(tip, results, scope) {
1456
+ return results.filter((result) => answers(tip, result)).map((result) => tip.line(result, scope));
1380
1457
  }
1381
1458
  function answers(tip, result) {
1382
- return result.kind === tip.kind && result.status === tip.status;
1459
+ return (result.tipKinds ?? [result.kind]).includes(tip.kind) && result.status === tip.status;
1383
1460
  }
1384
1461
  async function recreateConfigTips(contentResults, projectDir) {
1385
1462
  if (!failedContentKinds(contentResults).has(CONFIG_CHECK.kind)) return [];
@@ -1420,16 +1497,23 @@ function toLayoutResult(scope) {
1420
1497
  }
1421
1498
  var PLACEMENTS_ROW_NAME = "Placements Offered";
1422
1499
  async function checkOfferedPlacements(installation) {
1423
- const findings = await unofferablePlacements(installation);
1424
- if (findings.length === 0) {
1425
- return { kind: "placements", status: "pass", message: "Every configured skill is placeable" };
1500
+ const { configuresASkill, findings } = await placementsOffered(installation);
1501
+ if (findings.length > 0) {
1502
+ return {
1503
+ kind: "placements",
1504
+ status: "fail",
1505
+ message: `${plural(findings.length, "finding")} would stop a command acting here`,
1506
+ details: findings.map((finding) => `- ${finding}`)
1507
+ };
1426
1508
  }
1427
- return {
1428
- kind: "placements",
1429
- status: "fail",
1430
- message: `${plural(findings.length, "finding")} would stop a command acting here`,
1431
- details: findings.map((finding) => `- ${finding}`)
1432
- };
1509
+ const message = configuresASkill ? "Every configured skill is placeable" : "No skills configured";
1510
+ return { kind: "placements", status: "pass", message };
1511
+ }
1512
+ function configRejected(config, state) {
1513
+ return config === null && state.kind !== "absent";
1514
+ }
1515
+ function placementsConfigRejected(config, state) {
1516
+ return configRejected(config, state) || state.kind === "global-unreadable";
1433
1517
  }
1434
1518
  function skippedResult(kind) {
1435
1519
  return { kind, status: "skip", message: "Skipped (config invalid)" };
@@ -1455,12 +1539,6 @@ async function runGatedContentCheck(check, projectDir, configUnreadable) {
1455
1539
  if (check.readsConfig && configUnreadable) return skippedContentResult(check.kind);
1456
1540
  return runContentCheck(check, projectDir);
1457
1541
  }
1458
- async function flatMapInTurn(items, step) {
1459
- return items.reduce(
1460
- async (earlier, item) => [...await earlier, ...await step(item)],
1461
- Promise.resolve([])
1462
- );
1463
- }
1464
1542
  async function safeCheck(kind, fn) {
1465
1543
  try {
1466
1544
  return await fn();
@@ -1489,7 +1567,11 @@ var Doctor = class _Doctor extends BaseCommand {
1489
1567
  const contentResults = await this.runContentChecks(projectDir);
1490
1568
  const operationalResults = await this.runOperationalChecks(projectDir, contentResults);
1491
1569
  const results = [...contentResults, ...operationalResults];
1492
- this.printResults(results, await recreateConfigTips(contentResults, projectDir));
1570
+ this.printResults(
1571
+ results,
1572
+ scopeAt(projectDir),
1573
+ await recreateConfigTips(contentResults, projectDir)
1574
+ );
1493
1575
  if (results.some((r) => r.status === "fail")) {
1494
1576
  this.exit(EXIT_CODES.ERROR);
1495
1577
  }
@@ -1556,11 +1638,11 @@ var Doctor = class _Doctor extends BaseCommand {
1556
1638
  () => checkInstallationsInPlay(projectDir, providers)
1557
1639
  );
1558
1640
  this.logCheck(INSTALLATIONS_ROW_NAME, installations);
1559
- const blocks = await flatMapInTurn(
1641
+ const blocks = await mapInTurn(
1560
1642
  providers,
1561
1643
  (provider) => this.checkOneOf(projectDir, provider, failedContent)
1562
1644
  );
1563
- return [installations, ...blocks];
1645
+ return [installations, ...blocks.flat()];
1564
1646
  }
1565
1647
  async checkOneOf(projectDir, provider, failedContent) {
1566
1648
  this.log("");
@@ -1577,12 +1659,9 @@ var Doctor = class _Doctor extends BaseCommand {
1577
1659
  const { result: configResult, config } = checkConfigValid(configState, installation);
1578
1660
  this.logCheck("Config Valid", configResult);
1579
1661
  const layoutResults = await this.reportLayout(installation);
1580
- const placementsResult = await safeCheck(
1581
- "placements",
1582
- () => checkOfferedPlacements(installation)
1583
- );
1662
+ const placementsResult = await this.resolvePlacementsCheck(config, configState, installation);
1584
1663
  this.logCheck(PLACEMENTS_ROW_NAME, placementsResult);
1585
- const sourceResult = await safeCheck("source", () => checkSourceReachable(installation));
1664
+ const { result: sourceResult, published } = await checkSourceReachable(installation);
1586
1665
  const filteredConfig = config ? filterExcludedEntries(config) : null;
1587
1666
  const skillsResult = await this.resolveSkillsCheck(config, sourceResult, failedContent);
1588
1667
  this.logCheck("Skills Resolved", skillsResult);
@@ -1590,7 +1669,11 @@ var Doctor = class _Doctor extends BaseCommand {
1590
1669
  this.logCheck("Agents Compiled", agentsResult);
1591
1670
  const orphansResult = await this.resolveOrphansCheck(config, configState, installation);
1592
1671
  this.logCheck("No Orphans", orphansResult);
1593
- const installedResult = await this.resolveInstalledCheck(filteredConfig, installation);
1672
+ const installedResult = await this.resolveInstalledCheck(
1673
+ filteredConfig,
1674
+ installation,
1675
+ skillsResult.status === "skip" ? null : published
1676
+ );
1594
1677
  this.logCheck("Skills Installed", installedResult);
1595
1678
  const pluginsResult = await this.resolvePluginsCheck(
1596
1679
  filteredConfig,
@@ -1618,9 +1701,14 @@ var Doctor = class _Doctor extends BaseCommand {
1618
1701
  }
1619
1702
  return rows;
1620
1703
  }
1704
+ /** Stands down over a rejected config; an absent one asks for no placement, which it says. */
1705
+ async resolvePlacementsCheck(config, configState, installation) {
1706
+ if (placementsConfigRejected(config, configState)) return skippedResult("placements");
1707
+ return safeCheck("placements", () => checkOfferedPlacements(installation));
1708
+ }
1621
1709
  /** Skips on a config the checks rejected: ownership can't be judged from a rejected file. */
1622
1710
  async resolveOrphansCheck(config, configState, installation) {
1623
- if (!config && configState.kind !== "absent") return skippedResult("orphans");
1711
+ if (configRejected(config, configState)) return skippedResult("orphans");
1624
1712
  return safeCheck("orphans", () => checkNoOrphans(configState, config, installation));
1625
1713
  }
1626
1714
  async resolveSkillsCheck(config, sourceResult, failedContent) {
@@ -1634,9 +1722,10 @@ var Doctor = class _Doctor extends BaseCommand {
1634
1722
  if (!config) return skippedResult("agents");
1635
1723
  return safeCheck("agents", () => checkAgentsCompiled(config, installation));
1636
1724
  }
1637
- async resolveInstalledCheck(config, installation) {
1725
+ /** `published`: the marketplace's own skills, or null where Skills Resolved stood down. */
1726
+ async resolveInstalledCheck(config, installation, published) {
1638
1727
  if (!config) return skippedResult("installed");
1639
- return safeCheck("installed", () => checkSkillsInstalled(config, installation));
1728
+ return safeCheck("installed", () => checkSkillsInstalled(config, installation, published));
1640
1729
  }
1641
1730
  async resolvePluginsCheck(config, installation, failedContent) {
1642
1731
  if (!config) return skippedResult("plugins");
@@ -1649,10 +1738,10 @@ var Doctor = class _Doctor extends BaseCommand {
1649
1738
  this.log(line);
1650
1739
  }
1651
1740
  }
1652
- printResults(results, recreateTips) {
1741
+ printResults(results, scope, recreateTips) {
1653
1742
  this.log("");
1654
1743
  this.log(formatSummary(results));
1655
- const tips = [...formatTips(results), ...recreateTips];
1744
+ const tips = [...formatTips(results, scope), ...recreateTips];
1656
1745
  if (tips.length > 0) {
1657
1746
  this.log("");
1658
1747
  for (const tip of tips) {