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
@@ -5,19 +5,19 @@ import {
5
5
  loadSource,
6
6
  mutateGlobal,
7
7
  writeProjectPartial
8
- } from "../chunk-CKBWEWHZ.js";
9
- import "../chunk-XMQIWPIR.js";
10
- import "../chunk-JNRACLNS.js";
11
- import "../chunk-EC3JXT23.js";
12
- import "../chunk-MQZNDK5F.js";
8
+ } from "../chunk-TNN72UL6.js";
9
+ import "../chunk-V3WJMNBF.js";
10
+ import "../chunk-XSR4WRXJ.js";
11
+ import "../chunk-VFD2XYM7.js";
12
+ import "../chunk-5ZK4IND4.js";
13
+ import "../chunk-77SHXTDD.js";
13
14
  import {
14
15
  BaseCommand,
15
16
  EXIT_CODES,
16
17
  providerFlag,
17
- providerNamedBy,
18
- refuseAnAmbiguousInstallation
19
- } from "../chunk-JTMSFBCA.js";
20
- import "../chunk-FACDJH6O.js";
18
+ providerNamedBy
19
+ } from "../chunk-E6W3PYGF.js";
20
+ import "../chunk-2FE4AJNC.js";
21
21
  import {
22
22
  INCOMPLETE_WORK_RECOVERY,
23
23
  INFO_MESSAGES,
@@ -35,17 +35,18 @@ import {
35
35
  relativeConfigPath,
36
36
  resolveInstallPaths,
37
37
  resolveSource,
38
+ scopeAt,
38
39
  sourceFolderInUse
39
- } from "../chunk-ENET4IF6.js";
40
+ } from "../chunk-D2PC7NIR.js";
40
41
  import {
41
42
  matrix,
42
43
  plural
43
- } from "../chunk-UE4Z3YMB.js";
44
+ } from "../chunk-KKGJH46C.js";
44
45
  import {
45
46
  DIRS,
46
47
  PROJECT_ROOT,
47
48
  bytewise
48
- } from "../chunk-U46LYYRA.js";
49
+ } from "../chunk-4SIBDIIO.js";
49
50
  import "../chunk-GHHJYNAN.js";
50
51
 
51
52
  // src/cli/commands/eject.ts
@@ -107,12 +108,7 @@ var Eject = class _Eject extends BaseCommand {
107
108
  async run() {
108
109
  const { args, flags } = await this.parse(_Eject);
109
110
  const projectDir = process.cwd();
110
- await refuseAnAmbiguousInstallation(
111
- projectDir,
112
- "eject",
113
- providerNamedBy(flags.provider),
114
- (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS })
115
- );
111
+ await this.refuseAnAmbiguousInstallation(projectDir, "eject", providerNamedBy(flags.provider));
116
112
  await this.sayWhenTheProjectsConfigDeclaresNothing(
117
113
  INFO_MESSAGES.DECLARES_NOTHING_TO_EJECT_FROM
118
114
  );
@@ -259,14 +255,15 @@ var Eject = class _Eject extends BaseCommand {
259
255
  );
260
256
  }
261
257
  async handleSkills(destinationDir, force, sourceResult) {
262
- const result = await ejectSkills({ destinationDir, force, sourceResult, matrix });
263
- if (result.skipped) {
264
- this.warn(result.skipReason);
258
+ if (sourceResult.marketplaceSkillIds.size === 0) {
259
+ this.warn("No skills found in the marketplace to eject.");
265
260
  return;
266
261
  }
267
- if (result.skippedSkillCount > 0) {
268
- this.warn(skillsAlreadyThere(destinationDir, result.skippedSkillCount));
262
+ const result = await ejectSkills({ destinationDir, force, sourceResult, matrix });
263
+ for (const warning of skillsLeftWarnings(destinationDir, result)) {
264
+ this.warn(warning);
269
265
  }
266
+ if (result.copiedSkills.length === 0) return;
270
267
  this.logSuccess(
271
268
  `${plural(result.copiedSkills.length, "skill")} ejected to ${destinationDir} from ${result.sourceLabel}`
272
269
  );
@@ -279,8 +276,21 @@ function expandHome(outputPath) {
279
276
  function subAgentsAlreadyThere(destDir, subAgents) {
280
277
  return `Agent partials already exist at ${destDir} \u2014 skipped ${plural(subAgents.length, "sub-agent")}: ${subAgents.join(", ")}. Use --force to overwrite them.`;
281
278
  }
282
- function skillsAlreadyThere(destinationDir, skippedCount) {
283
- return `Skills already exist at ${destinationDir} \u2014 skipped ${plural(skippedCount, "skill")}. Use --force to overwrite them.`;
279
+ function skillsLeftWarnings(destinationDir, { copiedSkills, alreadyThere, keptElsewhere }) {
280
+ return [
281
+ ...alreadyThereWarning(destinationDir, alreadyThere.length, copiedSkills.length > 0),
282
+ ...keptElsewhere.map(localCopyKept)
283
+ ];
284
+ }
285
+ function alreadyThereWarning(destinationDir, alreadyThereCount, copiedAny) {
286
+ if (alreadyThereCount === 0) return [];
287
+ if (!copiedAny) return [`Skills already exist at ${destinationDir}. Use --force to overwrite.`];
288
+ return [
289
+ `Skills already exist at ${destinationDir} \u2014 skipped ${plural(alreadyThereCount, "skill")}. Use --force to overwrite them.`
290
+ ];
291
+ }
292
+ function localCopyKept({ skillId, copyDir }) {
293
+ return `Skipped ${skillId}: its local copy at ${copyDir} stays as it is, even with --force.`;
284
294
  }
285
295
  async function alreadyIn(dir, names) {
286
296
  const checked = await Promise.all(
@@ -367,40 +377,40 @@ async function ejectSkills(options) {
367
377
  const marketplaceSkillIds = [...sourceResult.marketplaceSkillIds];
368
378
  const alreadyThere = force ? [] : await alreadyIn(destinationDir, marketplaceSkillIds);
369
379
  const notThere = marketplaceSkillIds.filter((skillId) => !alreadyThere.includes(skillId));
370
- const skillIds = notThere.filter(
371
- (skillId) => !isLocalCopyElsewhere(matrix2.skills[skillId], destinationDir)
372
- );
373
- if (skillIds.length === 0 && alreadyThere.length > 0) {
374
- return {
375
- skipped: true,
376
- skipReason: `Skills already exist at ${destinationDir}. Use --force to overwrite.`
377
- };
378
- }
379
- if (skillIds.length === 0) {
380
- return { skipped: true, skipReason: "No skills found in the marketplace to eject." };
381
- }
382
- await ensureDir(destinationDir);
383
- const copiedSkills = await copyMarketplaceSkillsToLocalFlattened(
384
- skillIds,
385
- destinationDir,
386
- sourceResult
387
- );
388
- const sourceLabel = sourceResult.isLocal ? sourceResult.sourcePath : sourceResult.marketplace || sourceResult.sourceConfig.source;
380
+ const keptElsewhere = localCopiesElsewhere(notThere, matrix2, destinationDir);
381
+ const keptIds = new Set(keptElsewhere.map(({ skillId }) => skillId));
382
+ const toCopy = notThere.filter((skillId) => !keptIds.has(skillId));
389
383
  return {
390
- skipped: false,
391
- copiedSkills,
392
- skippedSkillCount: alreadyThere.length,
393
- sourceLabel
384
+ copiedSkills: await copyInto(destinationDir, toCopy, sourceResult),
385
+ alreadyThere,
386
+ keptElsewhere,
387
+ sourceLabel: sourceLabelOf(sourceResult)
394
388
  };
395
389
  }
396
- function isLocalCopyElsewhere(skill, destinationDir) {
397
- if (!skill?.local) return false;
398
- if (!skill.localPath) return true;
399
- return path.resolve(skill.localPath) !== path.resolve(destinationDir, skill.id);
390
+ async function copyInto(destinationDir, skillIds, sourceResult) {
391
+ if (skillIds.length === 0) return [];
392
+ await ensureDir(destinationDir);
393
+ return copyMarketplaceSkillsToLocalFlattened(skillIds, destinationDir, sourceResult);
394
+ }
395
+ function sourceLabelOf(sourceResult) {
396
+ return sourceResult.isLocal ? sourceResult.sourcePath : sourceResult.marketplace || sourceResult.sourceConfig.source;
397
+ }
398
+ function localCopiesElsewhere(skillIds, matrix2, destinationDir) {
399
+ return skillIds.flatMap((skillId) => {
400
+ const copyDir = localCopyDirElsewhere(matrix2.skills[skillId], destinationDir);
401
+ return copyDir === void 0 ? [] : [{ skillId, copyDir }];
402
+ }).sort((a, b) => bytewise(a.skillId, b.skillId));
403
+ }
404
+ function localCopyDirElsewhere(skill, destinationDir) {
405
+ if (!skill?.local) return void 0;
406
+ if (skill.localPath === void 0) {
407
+ throw new Error(`Local skill '${skill.id}' was discovered without its directory`);
408
+ }
409
+ const copyDir = path.resolve(skill.localPath);
410
+ return copyDir === path.resolve(destinationDir, skill.id) ? void 0 : copyDir;
400
411
  }
401
412
  function installedSkillsDir(projectDir) {
402
- const scope = isHomeDirectory(projectDir) ? "global" : "project";
403
- return resolveInstallPaths(projectDir, scope).skillsDir;
413
+ return resolveInstallPaths(projectDir, scopeAt(projectDir)).skillsDir;
404
414
  }
405
415
  async function ensureMinimalConfig(options) {
406
416
  const { projectDir, sourceResult } = options;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/commands/eject.ts"],"sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport os from \"os\";\nimport { BaseCommand } from \"../base-command.js\";\nimport {\n copy,\n ensureDir,\n directoryExists,\n fileExists,\n isSymlink,\n listDirectories,\n} from \"../utils/fs.js\";\nimport { DIRS, PROJECT_ROOT } from \"../consts.js\";\nimport {\n providerInUse,\n relativeConfigPath,\n sourceFolderInUse,\n} from \"../lib/installation/install-layout.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { type SourceLoadResult } from \"../lib/loading/index.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport { matrix } from \"../lib/matrix/matrix-provider\";\nimport { resolveSource, getProjectConfigPath } from \"../lib/configuration/index.js\";\nimport {\n ensureBlankPair,\n lazyGateDeps,\n mutateGlobal,\n writeProjectPartial,\n} from \"../lib/config-gate/index.js\";\nimport { isHomeDirectory, resolveInstallPaths } from \"../lib/installation/index.js\";\nimport {\n providerFlag,\n providerNamedBy,\n refuseAnAmbiguousInstallation,\n} from \"../lib/installation/provider-flag.js\";\nimport { copyMarketplaceSkillsToLocalFlattened, type CopiedSkill } from \"../lib/skills/index.js\";\nimport { INCOMPLETE_WORK_RECOVERY, INFO_MESSAGES } from \"../utils/messages.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { bytewise, plural } from \"../utils/string.js\";\nimport type { MergedSkillsMatrix, ResolvedSkill } from \"../types/index.js\";\n\nconst EJECT_TYPES = [\"agent-partials\", \"templates\", \"skills\", \"all\"] as const;\ntype EjectType = (typeof EJECT_TYPES)[number];\n\nfunction isEjectType(value: string): value is EjectType {\n return (EJECT_TYPES as readonly string[]).includes(value);\n}\n\n/** Skills come from the marketplace this installation reads, so only their ejects load it. */\ntype EjectPlan =\n | { type: \"agent-partials\" | \"templates\" }\n | { type: \"skills\" | \"all\"; sourceResult: SourceLoadResult };\n\nfunction loadedSourceOf(plan: EjectPlan): SourceLoadResult | undefined {\n return \"sourceResult\" in plan ? plan.sourceResult : undefined;\n}\n\nexport default class Eject extends BaseCommand {\n static summary = \"Eject skills, agent partials, or templates for local customization\";\n static description =\n \"Copy agent partials, templates, or skills to your project for customization. \" +\n \"Agent partials and templates are always copied from the CLI. \" +\n \"Skills are copied from the marketplace this installation is configured to read \" +\n \"(the public one by default).\";\n\n static examples = [\n {\n description: \"Eject agent partials for customization\",\n command: \"<%= config.bin %> <%= command.id %> agent-partials\",\n },\n {\n description: \"Eject only agent templates\",\n command: \"<%= config.bin %> <%= command.id %> templates\",\n },\n {\n description: \"Eject skills to local directory\",\n command: \"<%= config.bin %> <%= command.id %> skills\",\n },\n {\n description: \"Eject everything with force overwrite\",\n command: \"<%= config.bin %> <%= command.id %> all --force\",\n },\n {\n description: \"Eject to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> skills -o ./custom-dir\",\n },\n ];\n\n static args = {\n type: Args.string({\n description: \"What to eject: agent-partials, templates, skills, all\",\n required: false,\n options: [...EJECT_TYPES],\n }),\n };\n\n static flags = {\n provider: providerFlag(),\n force: Flags.boolean({\n char: \"f\",\n description: \"Overwrite existing files\",\n default: false,\n }),\n output: Flags.string({\n char: \"o\",\n // No default: each eject type has its own destination and this replaces all three.\n description:\n \"Write everything into this directory instead of each eject type's own destination\",\n }),\n };\n\n async run(): Promise<void> {\n const { args, flags } = await this.parse(Eject);\n const projectDir = process.cwd();\n\n // Before the layout settle: this decides which installation that refusal is about.\n await refuseAnAmbiguousInstallation(\n projectDir,\n \"eject\",\n providerNamedBy(flags.provider),\n (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n await this.sayWhenTheProjectsConfigDeclaresNothing(\n INFO_MESSAGES.DECLARES_NOTHING_TO_EJECT_FROM,\n );\n\n // Before anything is copied, so a refusal never follows files already written.\n await this.ensureConfigReadable(projectDir);\n const ejectType = this.validateEjectType(args.type);\n const outputBase = await this.resolveOutputBase(flags, projectDir);\n\n this.printHeader(\n await this.resolveBrandingName(projectDir),\n flags.output ? outputBase : undefined,\n );\n\n const plan = await this.planEject(ejectType, projectDir);\n await this.executeEject(plan, outputBase, flags, projectDir);\n await this.ensureConfig(projectDir, loadedSourceOf(plan));\n\n this.reportEnding();\n }\n\n /** Withholds `Eject complete!` when part of the eject did not land. */\n private reportEnding(): void {\n this.log(\"\");\n if (!this.hasIncompleteWork) this.logSuccess(\"Eject complete!\");\n this.log(\"\");\n\n this.exitIfWorkIncomplete();\n }\n\n private validateEjectType(typeArg: string | undefined): EjectType {\n if (!typeArg) {\n this.error(\"Please specify what to eject: agent-partials, templates, skills, or all\", {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n if (!isEjectType(typeArg)) {\n this.error(`Unknown eject type: ${typeArg}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return typeArg;\n }\n\n private async resolveOutputBase(\n flags: { output: string | undefined },\n projectDir: string,\n ): Promise<string> {\n if (!flags.output) return sourceFolderInUse(projectDir, providerInUse(projectDir)).dir;\n\n const outputBase = path.resolve(projectDir, expandHome(flags.output));\n await this.refuseUnwritableOutput(outputBase);\n return outputBase;\n }\n\n private async refuseUnwritableOutput(outputBase: string): Promise<void> {\n // First, as the checks below follow a link, and so would every write.\n if (await isSymlink(outputBase)) {\n this.error(`Output path is a link: ${outputBase}. Name the folder it points to instead.`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n // `fileExists` is true of a directory too; an existing directory is written into, and each\n // kind then skips what it would write there already unless --force.\n const namesAFile = (await fileExists(outputBase)) && !(await directoryExists(outputBase));\n if (namesAFile) {\n this.error(`Output path exists as a file: ${outputBase}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n }\n\n private printHeader(brandingName: string, outputBase?: string): void {\n this.log(\"\");\n this.log(`${brandingName} Eject`);\n this.log(\"\");\n\n if (outputBase) {\n this.log(`Output directory: ${outputBase}`);\n }\n }\n\n private async planEject(type: EjectType, projectDir: string): Promise<EjectPlan> {\n if (type === \"agent-partials\" || type === \"templates\") return { type };\n\n const { sourceResult } = await loadSource({ projectDir });\n return { type, sourceResult };\n }\n\n private async executeEject(\n plan: EjectPlan,\n outputBase: string,\n flags: { force: boolean; output: string | undefined },\n projectDir: string,\n ): Promise<void> {\n const directOutput = !!flags.output;\n\n switch (plan.type) {\n case \"agent-partials\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n break;\n case \"templates\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, true);\n break;\n case \"skills\":\n await this.handleSkills(\n skillsDestination(projectDir, directOutput, outputBase),\n flags.force,\n plan.sourceResult,\n );\n break;\n case \"all\": {\n // The partials carry the templates as one unit, so they arrive once and obey --force.\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n await this.handleSkills(\n skillsDestination(projectDir, directOutput, outputBase),\n flags.force,\n plan.sourceResult,\n );\n break;\n }\n default: {\n const _exhaustive: never = plan;\n return _exhaustive;\n }\n }\n }\n\n /**\n * Writes a minimal config where there is none. A refusal is reported as incomplete work rather\n * than thrown, because the ejection has already landed.\n */\n private async ensureConfig(\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n // Named before the write, which may create the provider folder.\n const configTsRel = relativeConfigPath(projectDir, providerInUse(projectDir));\n\n try {\n const configResult = await ensureMinimalConfig({\n projectDir,\n ...(sourceResult !== undefined && { sourceResult }),\n });\n if (configResult.created) {\n this.logSuccess(`Created ${configTsRel}`);\n }\n } catch (error) {\n this.reportIncompleteWork(\n `Could not create ${configTsRel}: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private async handleAgentPartials(\n outputBase: string,\n force: boolean,\n directOutput: boolean,\n templatesOnly: boolean,\n ): Promise<void> {\n const result = await ejectAgentPartials({\n outputBase,\n force,\n directOutput,\n templatesOnly,\n });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n if (result.skippedSubAgents.length > 0) {\n this.warn(subAgentsAlreadyThere(result.destDir, result.skippedSubAgents));\n }\n\n if (result.templatesSkipped) {\n this.warn(\n \"Agent templates already exist — skipping templates, only ejecting agent partials.\",\n );\n }\n\n this.logSuccess(\n `${templatesOnly ? \"Agent templates\" : \"Agent partials\"} ejected to ${result.destDir}`,\n );\n this.log(\n templatesOnly\n ? \"You can now customize agent templates locally.\"\n : INFO_MESSAGES.AGENT_PARTIALS_CUSTOMIZABLE,\n );\n }\n\n private async handleSkills(\n destinationDir: string,\n force: boolean,\n sourceResult: SourceLoadResult,\n ): Promise<void> {\n const result = await ejectSkills({ destinationDir, force, sourceResult, matrix });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n if (result.skippedSkillCount > 0) {\n this.warn(skillsAlreadyThere(destinationDir, result.skippedSkillCount));\n }\n\n this.logSuccess(\n `${plural(result.copiedSkills.length, \"skill\")} ejected to ${destinationDir} from ${result.sourceLabel}`,\n );\n this.log(\"You can now customize skill content locally.\");\n }\n}\n\nfunction expandHome(outputPath: string): string {\n return outputPath.startsWith(\"~\") ? path.join(os.homedir(), outputPath.slice(1)) : outputPath;\n}\n\n/** Some of what an eject copies was already there: named, with the rest copied beside it. */\nfunction subAgentsAlreadyThere(destDir: string, subAgents: readonly string[]): string {\n return `Agent partials already exist at ${destDir} — skipped ${plural(subAgents.length, \"sub-agent\")}: ${subAgents.join(\", \")}. Use --force to overwrite them.`;\n}\n\n/** Counted rather than named: a re-run into a nearly full folder skips most of the marketplace. */\nfunction skillsAlreadyThere(destinationDir: string, skippedCount: number): string {\n return `Skills already exist at ${destinationDir} — skipped ${plural(skippedCount, \"skill\")}. Use --force to overwrite them.`;\n}\n\n/** Those of `names` already at `dir`, file or folder: what an eject without --force leaves. */\nasync function alreadyIn<Name extends string>(\n dir: string,\n names: readonly Name[],\n): Promise<Name[]> {\n const checked = await Promise.all(\n names.map(async (name) => ({ name, there: await fileExists(path.join(dir, name)) })),\n );\n return checked.filter(({ there }) => there).map(({ name }) => name);\n}\n\ntype EjectAgentPartialsOptions = {\n outputBase: string;\n force: boolean;\n directOutput?: boolean;\n templatesOnly?: boolean;\n};\n\ntype EjectAgentPartialsResult =\n | {\n skipped: true;\n skipReason: string;\n }\n | {\n skipped: false;\n destDir: string;\n /** The sub-agents left as they were, by name, bytewise-sorted. */\n skippedSubAgents: string[];\n templatesSkipped: boolean;\n };\n\nfunction resolveEjectDestDir(\n outputBase: string,\n directOutput: boolean,\n templatesOnly: boolean,\n): string {\n if (directOutput) return outputBase;\n const agentsDir = path.join(outputBase, path.basename(DIRS.agents));\n return templatesOnly ? path.join(agentsDir, path.basename(DIRS.templates)) : agentsDir;\n}\n\nasync function ejectAgentPartials(\n options: EjectAgentPartialsOptions,\n): Promise<EjectAgentPartialsResult> {\n const { outputBase, force, directOutput = false, templatesOnly = false } = options;\n const destDir = resolveEjectDestDir(outputBase, directOutput, templatesOnly);\n\n return templatesOnly ? ejectTemplates(destDir, force) : ejectSubAgentPartials(destDir, force);\n}\n\n/** Whole or not at all: a templates folder already there is kept unless --force. */\nasync function ejectTemplates(destDir: string, force: boolean): Promise<EjectAgentPartialsResult> {\n const sourceDir = path.join(PROJECT_ROOT, DIRS.templates);\n\n if (!(await directoryExists(sourceDir))) {\n return { skipped: true, skipReason: \"No agent templates found in CLI.\" };\n }\n\n if ((await directoryExists(destDir)) && !force) {\n return {\n skipped: true,\n skipReason: `Agent templates already exist at ${destDir}. Use --force to overwrite.`,\n };\n }\n\n await ensureDir(destDir);\n await copy(sourceDir, destDir);\n return { skipped: false, destDir, skippedSubAgents: [], templatesSkipped: false };\n}\n\n/** Unit by unit: one already there is kept unless --force, and the rest are copied beside it. */\nasync function ejectSubAgentPartials(\n destDir: string,\n force: boolean,\n): Promise<EjectAgentPartialsResult> {\n const sourceDir = path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n return { skipped: true, skipReason: \"No agent partials found in CLI.\" };\n }\n\n const units = await partialUnitsIn(sourceDir);\n const present = force ? [] : await alreadyIn(destDir, units);\n const absent = units.filter((unit) => !present.includes(unit));\n\n if (absent.length === 0) {\n return {\n skipped: true,\n skipReason: `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n };\n }\n\n await copyUnits(absent, sourceDir, destDir);\n\n return {\n skipped: false,\n destDir,\n skippedSubAgents: subAgentNames(present),\n templatesSkipped: present.some(isTemplatesUnit),\n };\n}\n\nconst TEMPLATES_UNIT = path.basename(DIRS.templates);\n\nfunction isTemplatesUnit(unit: string): boolean {\n return unit === TEMPLATES_UNIT;\n}\n\n/**\n * What a re-eject keeps or copies whole: each sub-agent's directory, as `<category>/<agent>`, and\n * the templates. A category folder is not one, so a file of the user's in it is written beside.\n */\nasync function partialUnitsIn(agentsSourceDir: string): Promise<string[]> {\n const entries = await listDirectories(agentsSourceDir);\n const categories = entries.filter((entry) => !isTemplatesUnit(entry));\n const subAgentDirs = await Promise.all(\n categories.map((category) => subAgentDirsOf(agentsSourceDir, category)),\n );\n return [...entries.filter(isTemplatesUnit), ...subAgentDirs.flat()];\n}\n\nasync function subAgentDirsOf(agentsSourceDir: string, category: string): Promise<string[]> {\n const agents = await listDirectories(path.join(agentsSourceDir, category));\n return agents.map((agent) => path.join(category, agent));\n}\n\n/** As the skipped-list warning names them: by directory name, bytewise-sorted. */\nfunction subAgentNames(units: readonly string[]): string[] {\n return units\n .filter((unit) => !isTemplatesUnit(unit))\n .map((unit) => path.basename(unit))\n .sort(bytewise);\n}\n\n/** `copy` makes the folders above each unit. */\nasync function copyUnits(\n units: readonly string[],\n sourceDir: string,\n destDir: string,\n): Promise<void> {\n for (const unit of units) {\n await copy(path.join(sourceDir, unit), path.join(destDir, unit));\n }\n}\n\nfunction skillsDestination(projectDir: string, directOutput: boolean, outputBase: string): string {\n return directOutput ? outputBase : installedSkillsDir(projectDir);\n}\n\ntype EjectSkillsOptions = {\n destinationDir: string;\n force: boolean;\n sourceResult: SourceLoadResult;\n matrix: MergedSkillsMatrix;\n};\n\ntype EjectSkillsResult =\n | {\n skipped: true;\n skipReason: string;\n }\n | {\n skipped: false;\n copiedSkills: CopiedSkill[];\n /** How many skills were left as they were. */\n skippedSkillCount: number;\n sourceLabel: string;\n };\n\n/**\n * Only the loaded marketplace's own skills, each copied from the marketplace: others' are not on\n * disk here. One already in the destination is skipped unless --force; a local copy anywhere else\n * is the user's own and is left out either way.\n */\nasync function ejectSkills(options: EjectSkillsOptions): Promise<EjectSkillsResult> {\n const { destinationDir, force, sourceResult, matrix } = options;\n\n const marketplaceSkillIds = [...sourceResult.marketplaceSkillIds];\n const alreadyThere = force ? [] : await alreadyIn(destinationDir, marketplaceSkillIds);\n const notThere = marketplaceSkillIds.filter((skillId) => !alreadyThere.includes(skillId));\n const skillIds = notThere.filter(\n (skillId) => !isLocalCopyElsewhere(matrix.skills[skillId], destinationDir),\n );\n\n if (skillIds.length === 0 && alreadyThere.length > 0) {\n return {\n skipped: true,\n skipReason: `Skills already exist at ${destinationDir}. Use --force to overwrite.`,\n };\n }\n\n if (skillIds.length === 0) {\n return { skipped: true, skipReason: \"No skills found in the marketplace to eject.\" };\n }\n\n await ensureDir(destinationDir);\n\n const copiedSkills = await copyMarketplaceSkillsToLocalFlattened(\n skillIds,\n destinationDir,\n sourceResult,\n );\n\n const sourceLabel = sourceResult.isLocal\n ? sourceResult.sourcePath\n : sourceResult.marketplace || sourceResult.sourceConfig.source;\n\n return {\n skipped: false,\n copiedSkills,\n skippedSkillCount: alreadyThere.length,\n sourceLabel,\n };\n}\n\n/** Local, and not the copy at `<destinationDir>/<id>`, which is where an eject writes the skill. */\nfunction isLocalCopyElsewhere(skill: ResolvedSkill | undefined, destinationDir: string): boolean {\n if (!skill?.local) return false;\n if (!skill.localPath) return true;\n return path.resolve(skill.localPath) !== path.resolve(destinationDir, skill.id);\n}\n\n/** Where the host of the installation `projectDir` roots reads skills. */\nfunction installedSkillsDir(projectDir: string): string {\n const scope = isHomeDirectory(projectDir) ? \"global\" : \"project\";\n return resolveInstallPaths(projectDir, scope).skillsDir;\n}\n\ntype EnsureMinimalConfigOptions = {\n projectDir: string;\n sourceResult?: SourceLoadResult;\n};\n\ntype EnsureMinimalConfigResult = {\n configPath: string;\n created: boolean;\n};\n\nasync function ensureMinimalConfig(\n options: EnsureMinimalConfigOptions,\n): Promise<EnsureMinimalConfigResult> {\n const { projectDir, sourceResult } = options;\n\n const provider = providerInUse(projectDir);\n const tsConfigPath = getProjectConfigPath(projectDir, provider);\n\n if (await fileExists(tsConfigPath)) {\n return { configPath: tsConfigPath, created: false };\n }\n\n // ABORT on an unreadable global config: the invented file would record a marketplace from nowhere.\n const resolvedConfig =\n sourceResult?.sourceConfig ?? (await resolveSource({ caller: \"stored\", projectDir }));\n const source = resolvedConfig.source || undefined;\n\n // At home the invented config is the global manifest, which needs its config-types sibling.\n if (isHomeDirectory(projectDir)) {\n await ensureBlankPair(provider);\n if (source) await recordSourceInGlobal(projectDir, source);\n return { configPath: tsConfigPath, created: true };\n }\n\n await writeProjectPartial(\n projectDir,\n {\n skills: [],\n agents: [],\n ...(source ? { marketplace: source } : {}),\n ...(resolvedConfig.marketplace ? { marketplaceName: resolvedConfig.marketplace } : {}),\n },\n { fallbackName: path.basename(projectDir) },\n );\n\n return { configPath: tsConfigPath, created: true };\n}\n\n/** At home the config is the global manifest projects inline from, so it goes through the gate. */\nasync function recordSourceInGlobal(projectDir: string, source: string): Promise<void> {\n await mutateGlobal(\n { kind: \"set-source\", source, fallbackName: path.basename(projectDir) },\n lazyGateDeps(projectDir),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,aAAa;AAC5B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAuCf,IAAM,cAAc,CAAC,kBAAkB,aAAa,UAAU,KAAK;AAGnE,SAAS,YAAY,O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B,YAAY,MAAM;AACzD,WAAO,EAAE,YAAY,cAAc,SAAS,KAAK;AAAA,EACnD;AAEA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,MACE,QAAQ,CAAC;AAAA,MACT,QAAQ,CAAC;AAAA,MACT,GAAI,SAAS,EAAE,aAAa,OAAO,IAAI,CAAC;AAAA,MACxC,GAAI,eAAe,cAAc,EAAE,iBAAiB,eAAe,YAAY,IAAI,CAAC;AAAA,IACtF;AAAA,IACA,EAAE,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,EAC5C;AAEA,SAAO,EAAE,YAAY,cAAc,SAAS,KAAK;AACnD;AAGA,eAAe,qBAAqB,YAAoB,QAA+B;AACrF,QAAM;AAAA,IACJ,EAAE,MAAM,cAAc,QAAQ,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,IACtE,aAAa,UAAU;AAAA,EACzB;AACF;","names":["matrix"]}
1
+ {"version":3,"sources":["../../src/cli/commands/eject.ts"],"sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport os from \"os\";\nimport { BaseCommand } from \"../base-command.js\";\nimport {\n copy,\n ensureDir,\n directoryExists,\n fileExists,\n isSymlink,\n listDirectories,\n} from \"../utils/fs.js\";\nimport { DIRS, PROJECT_ROOT } from \"../consts.js\";\nimport {\n providerInUse,\n relativeConfigPath,\n sourceFolderInUse,\n} from \"../lib/installation/install-layout.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { type SourceLoadResult } from \"../lib/loading/index.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport { matrix } from \"../lib/matrix/matrix-provider\";\nimport { resolveSource, getProjectConfigPath } from \"../lib/configuration/index.js\";\nimport {\n ensureBlankPair,\n lazyGateDeps,\n mutateGlobal,\n writeProjectPartial,\n} from \"../lib/config-gate/index.js\";\nimport { isHomeDirectory, resolveInstallPaths, scopeAt } from \"../lib/installation/index.js\";\nimport { providerFlag, providerNamedBy } from \"../lib/installation/provider-flag.js\";\nimport { copyMarketplaceSkillsToLocalFlattened, type CopiedSkill } from \"../lib/skills/index.js\";\nimport { INCOMPLETE_WORK_RECOVERY, INFO_MESSAGES } from \"../utils/messages.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { bytewise, plural } from \"../utils/string.js\";\nimport type { MergedSkillsMatrix, ResolvedSkill, SkillId } from \"../types/index.js\";\n\nconst EJECT_TYPES = [\"agent-partials\", \"templates\", \"skills\", \"all\"] as const;\ntype EjectType = (typeof EJECT_TYPES)[number];\n\nfunction isEjectType(value: string): value is EjectType {\n return (EJECT_TYPES as readonly string[]).includes(value);\n}\n\n/** Skills come from the marketplace this installation reads, so only their ejects load it. */\ntype EjectPlan =\n | { type: \"agent-partials\" | \"templates\" }\n | { type: \"skills\" | \"all\"; sourceResult: SourceLoadResult };\n\nfunction loadedSourceOf(plan: EjectPlan): SourceLoadResult | undefined {\n return \"sourceResult\" in plan ? plan.sourceResult : undefined;\n}\n\nexport default class Eject extends BaseCommand {\n static summary = \"Eject skills, agent partials, or templates for local customization\";\n static description =\n \"Copy agent partials, templates, or skills to your project for customization. \" +\n \"Agent partials and templates are always copied from the CLI. \" +\n \"Skills are copied from the marketplace this installation is configured to read \" +\n \"(the public one by default).\";\n\n static examples = [\n {\n description: \"Eject agent partials for customization\",\n command: \"<%= config.bin %> <%= command.id %> agent-partials\",\n },\n {\n description: \"Eject only agent templates\",\n command: \"<%= config.bin %> <%= command.id %> templates\",\n },\n {\n description: \"Eject skills to local directory\",\n command: \"<%= config.bin %> <%= command.id %> skills\",\n },\n {\n description: \"Eject everything with force overwrite\",\n command: \"<%= config.bin %> <%= command.id %> all --force\",\n },\n {\n description: \"Eject to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> skills -o ./custom-dir\",\n },\n ];\n\n static args = {\n type: Args.string({\n description: \"What to eject: agent-partials, templates, skills, all\",\n required: false,\n options: [...EJECT_TYPES],\n }),\n };\n\n static flags = {\n provider: providerFlag(),\n force: Flags.boolean({\n char: \"f\",\n description: \"Overwrite existing files\",\n default: false,\n }),\n output: Flags.string({\n char: \"o\",\n // No default: each eject type has its own destination and this replaces all three.\n description:\n \"Write everything into this directory instead of each eject type's own destination\",\n }),\n };\n\n async run(): Promise<void> {\n const { args, flags } = await this.parse(Eject);\n const projectDir = process.cwd();\n\n // Before the layout settle: this decides which installation that refusal is about.\n await this.refuseAnAmbiguousInstallation(projectDir, \"eject\", providerNamedBy(flags.provider));\n await this.sayWhenTheProjectsConfigDeclaresNothing(\n INFO_MESSAGES.DECLARES_NOTHING_TO_EJECT_FROM,\n );\n\n // Before anything is copied, so a refusal never follows files already written.\n await this.ensureConfigReadable(projectDir);\n const ejectType = this.validateEjectType(args.type);\n const outputBase = await this.resolveOutputBase(flags, projectDir);\n\n this.printHeader(\n await this.resolveBrandingName(projectDir),\n flags.output ? outputBase : undefined,\n );\n\n const plan = await this.planEject(ejectType, projectDir);\n await this.executeEject(plan, outputBase, flags, projectDir);\n await this.ensureConfig(projectDir, loadedSourceOf(plan));\n\n this.reportEnding();\n }\n\n /** Withholds `Eject complete!` when part of the eject did not land. */\n private reportEnding(): void {\n this.log(\"\");\n if (!this.hasIncompleteWork) this.logSuccess(\"Eject complete!\");\n this.log(\"\");\n\n this.exitIfWorkIncomplete();\n }\n\n private validateEjectType(typeArg: string | undefined): EjectType {\n if (!typeArg) {\n this.error(\"Please specify what to eject: agent-partials, templates, skills, or all\", {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n if (!isEjectType(typeArg)) {\n this.error(`Unknown eject type: ${typeArg}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return typeArg;\n }\n\n private async resolveOutputBase(\n flags: { output: string | undefined },\n projectDir: string,\n ): Promise<string> {\n if (!flags.output) return sourceFolderInUse(projectDir, providerInUse(projectDir)).dir;\n\n const outputBase = path.resolve(projectDir, expandHome(flags.output));\n await this.refuseUnwritableOutput(outputBase);\n return outputBase;\n }\n\n private async refuseUnwritableOutput(outputBase: string): Promise<void> {\n // First, as the checks below follow a link, and so would every write.\n if (await isSymlink(outputBase)) {\n this.error(`Output path is a link: ${outputBase}. Name the folder it points to instead.`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n // `fileExists` is true of a directory too; an existing directory is written into, and each\n // kind then skips what it would write there already unless --force.\n const namesAFile = (await fileExists(outputBase)) && !(await directoryExists(outputBase));\n if (namesAFile) {\n this.error(`Output path exists as a file: ${outputBase}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n }\n\n private printHeader(brandingName: string, outputBase?: string): void {\n this.log(\"\");\n this.log(`${brandingName} Eject`);\n this.log(\"\");\n\n if (outputBase) {\n this.log(`Output directory: ${outputBase}`);\n }\n }\n\n private async planEject(type: EjectType, projectDir: string): Promise<EjectPlan> {\n if (type === \"agent-partials\" || type === \"templates\") return { type };\n\n const { sourceResult } = await loadSource({ projectDir });\n return { type, sourceResult };\n }\n\n private async executeEject(\n plan: EjectPlan,\n outputBase: string,\n flags: { force: boolean; output: string | undefined },\n projectDir: string,\n ): Promise<void> {\n const directOutput = !!flags.output;\n\n switch (plan.type) {\n case \"agent-partials\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n break;\n case \"templates\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, true);\n break;\n case \"skills\":\n await this.handleSkills(\n skillsDestination(projectDir, directOutput, outputBase),\n flags.force,\n plan.sourceResult,\n );\n break;\n case \"all\": {\n // The partials carry the templates as one unit, so they arrive once and obey --force.\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n await this.handleSkills(\n skillsDestination(projectDir, directOutput, outputBase),\n flags.force,\n plan.sourceResult,\n );\n break;\n }\n default: {\n const _exhaustive: never = plan;\n return _exhaustive;\n }\n }\n }\n\n /**\n * Writes a minimal config where there is none. A refusal is reported as incomplete work rather\n * than thrown, because the ejection has already landed.\n */\n private async ensureConfig(\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n // Named before the write, which may create the provider folder.\n const configTsRel = relativeConfigPath(projectDir, providerInUse(projectDir));\n\n try {\n const configResult = await ensureMinimalConfig({\n projectDir,\n ...(sourceResult !== undefined && { sourceResult }),\n });\n if (configResult.created) {\n this.logSuccess(`Created ${configTsRel}`);\n }\n } catch (error) {\n this.reportIncompleteWork(\n `Could not create ${configTsRel}: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private async handleAgentPartials(\n outputBase: string,\n force: boolean,\n directOutput: boolean,\n templatesOnly: boolean,\n ): Promise<void> {\n const result = await ejectAgentPartials({\n outputBase,\n force,\n directOutput,\n templatesOnly,\n });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n if (result.skippedSubAgents.length > 0) {\n this.warn(subAgentsAlreadyThere(result.destDir, result.skippedSubAgents));\n }\n\n if (result.templatesSkipped) {\n this.warn(\n \"Agent templates already exist — skipping templates, only ejecting agent partials.\",\n );\n }\n\n this.logSuccess(\n `${templatesOnly ? \"Agent templates\" : \"Agent partials\"} ejected to ${result.destDir}`,\n );\n this.log(\n templatesOnly\n ? \"You can now customize agent templates locally.\"\n : INFO_MESSAGES.AGENT_PARTIALS_CUSTOMIZABLE,\n );\n }\n\n private async handleSkills(\n destinationDir: string,\n force: boolean,\n sourceResult: SourceLoadResult,\n ): Promise<void> {\n if (sourceResult.marketplaceSkillIds.size === 0) {\n this.warn(\"No skills found in the marketplace to eject.\");\n return;\n }\n\n const result = await ejectSkills({ destinationDir, force, sourceResult, matrix });\n\n for (const warning of skillsLeftWarnings(destinationDir, result)) {\n this.warn(warning);\n }\n if (result.copiedSkills.length === 0) return;\n\n this.logSuccess(\n `${plural(result.copiedSkills.length, \"skill\")} ejected to ${destinationDir} from ${result.sourceLabel}`,\n );\n this.log(\"You can now customize skill content locally.\");\n }\n}\n\nfunction expandHome(outputPath: string): string {\n return outputPath.startsWith(\"~\") ? path.join(os.homedir(), outputPath.slice(1)) : outputPath;\n}\n\n/** Some of what an eject copies was already there: named, with the rest copied beside it. */\nfunction subAgentsAlreadyThere(destDir: string, subAgents: readonly string[]): string {\n return `Agent partials already exist at ${destDir} — skipped ${plural(subAgents.length, \"sub-agent\")}: ${subAgents.join(\", \")}. Use --force to overwrite them.`;\n}\n\n/** Those already at the destination as one line, then each local copy elsewhere by name. */\nfunction skillsLeftWarnings(\n destinationDir: string,\n { copiedSkills, alreadyThere, keptElsewhere }: EjectSkillsResult,\n): string[] {\n return [\n ...alreadyThereWarning(destinationDir, alreadyThere.length, copiedSkills.length > 0),\n ...keptElsewhere.map(localCopyKept),\n ];\n}\n\n/** Counted rather than named: a re-run into a nearly full folder skips most of the marketplace. */\nfunction alreadyThereWarning(\n destinationDir: string,\n alreadyThereCount: number,\n copiedAny: boolean,\n): string[] {\n if (alreadyThereCount === 0) return [];\n if (!copiedAny) return [`Skills already exist at ${destinationDir}. Use --force to overwrite.`];\n return [\n `Skills already exist at ${destinationDir} — skipped ${plural(alreadyThereCount, \"skill\")}. Use --force to overwrite them.`,\n ];\n}\n\nfunction localCopyKept({ skillId, copyDir }: LocalCopyElsewhere): string {\n return `Skipped ${skillId}: its local copy at ${copyDir} stays as it is, even with --force.`;\n}\n\n/** Those of `names` already at `dir`, file or folder: what an eject without --force leaves. */\nasync function alreadyIn<Name extends string>(\n dir: string,\n names: readonly Name[],\n): Promise<Name[]> {\n const checked = await Promise.all(\n names.map(async (name) => ({ name, there: await fileExists(path.join(dir, name)) })),\n );\n return checked.filter(({ there }) => there).map(({ name }) => name);\n}\n\ntype EjectAgentPartialsOptions = {\n outputBase: string;\n force: boolean;\n directOutput?: boolean;\n templatesOnly?: boolean;\n};\n\ntype EjectAgentPartialsResult =\n | {\n skipped: true;\n skipReason: string;\n }\n | {\n skipped: false;\n destDir: string;\n /** The sub-agents left as they were, by name, bytewise-sorted. */\n skippedSubAgents: string[];\n templatesSkipped: boolean;\n };\n\nfunction resolveEjectDestDir(\n outputBase: string,\n directOutput: boolean,\n templatesOnly: boolean,\n): string {\n if (directOutput) return outputBase;\n const agentsDir = path.join(outputBase, path.basename(DIRS.agents));\n return templatesOnly ? path.join(agentsDir, path.basename(DIRS.templates)) : agentsDir;\n}\n\nasync function ejectAgentPartials(\n options: EjectAgentPartialsOptions,\n): Promise<EjectAgentPartialsResult> {\n const { outputBase, force, directOutput = false, templatesOnly = false } = options;\n const destDir = resolveEjectDestDir(outputBase, directOutput, templatesOnly);\n\n return templatesOnly ? ejectTemplates(destDir, force) : ejectSubAgentPartials(destDir, force);\n}\n\n/** Whole or not at all: a templates folder already there is kept unless --force. */\nasync function ejectTemplates(destDir: string, force: boolean): Promise<EjectAgentPartialsResult> {\n const sourceDir = path.join(PROJECT_ROOT, DIRS.templates);\n\n if (!(await directoryExists(sourceDir))) {\n return { skipped: true, skipReason: \"No agent templates found in CLI.\" };\n }\n\n if ((await directoryExists(destDir)) && !force) {\n return {\n skipped: true,\n skipReason: `Agent templates already exist at ${destDir}. Use --force to overwrite.`,\n };\n }\n\n await ensureDir(destDir);\n await copy(sourceDir, destDir);\n return { skipped: false, destDir, skippedSubAgents: [], templatesSkipped: false };\n}\n\n/** Unit by unit: one already there is kept unless --force, and the rest are copied beside it. */\nasync function ejectSubAgentPartials(\n destDir: string,\n force: boolean,\n): Promise<EjectAgentPartialsResult> {\n const sourceDir = path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n return { skipped: true, skipReason: \"No agent partials found in CLI.\" };\n }\n\n const units = await partialUnitsIn(sourceDir);\n const present = force ? [] : await alreadyIn(destDir, units);\n const absent = units.filter((unit) => !present.includes(unit));\n\n if (absent.length === 0) {\n return {\n skipped: true,\n skipReason: `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n };\n }\n\n await copyUnits(absent, sourceDir, destDir);\n\n return {\n skipped: false,\n destDir,\n skippedSubAgents: subAgentNames(present),\n templatesSkipped: present.some(isTemplatesUnit),\n };\n}\n\nconst TEMPLATES_UNIT = path.basename(DIRS.templates);\n\nfunction isTemplatesUnit(unit: string): boolean {\n return unit === TEMPLATES_UNIT;\n}\n\n/**\n * What a re-eject keeps or copies whole: each sub-agent's directory, as `<category>/<agent>`, and\n * the templates. A category folder is not one, so a file of the user's in it is written beside.\n */\nasync function partialUnitsIn(agentsSourceDir: string): Promise<string[]> {\n const entries = await listDirectories(agentsSourceDir);\n const categories = entries.filter((entry) => !isTemplatesUnit(entry));\n const subAgentDirs = await Promise.all(\n categories.map((category) => subAgentDirsOf(agentsSourceDir, category)),\n );\n return [...entries.filter(isTemplatesUnit), ...subAgentDirs.flat()];\n}\n\nasync function subAgentDirsOf(agentsSourceDir: string, category: string): Promise<string[]> {\n const agents = await listDirectories(path.join(agentsSourceDir, category));\n return agents.map((agent) => path.join(category, agent));\n}\n\n/** As the skipped-list warning names them: by directory name, bytewise-sorted. */\nfunction subAgentNames(units: readonly string[]): string[] {\n return units\n .filter((unit) => !isTemplatesUnit(unit))\n .map((unit) => path.basename(unit))\n .sort(bytewise);\n}\n\n/** `copy` makes the folders above each unit. */\nasync function copyUnits(\n units: readonly string[],\n sourceDir: string,\n destDir: string,\n): Promise<void> {\n for (const unit of units) {\n await copy(path.join(sourceDir, unit), path.join(destDir, unit));\n }\n}\n\nfunction skillsDestination(projectDir: string, directOutput: boolean, outputBase: string): string {\n return directOutput ? outputBase : installedSkillsDir(projectDir);\n}\n\ntype EjectSkillsOptions = {\n destinationDir: string;\n force: boolean;\n sourceResult: SourceLoadResult;\n matrix: MergedSkillsMatrix;\n};\n\n/** The user's own copy of a skill, outside the folder an eject writes that skill to. */\ntype LocalCopyElsewhere = { skillId: SkillId; copyDir: string };\n\ntype EjectSkillsResult = {\n copiedSkills: CopiedSkill[];\n /** At the destination already, so left as they were; none under --force. */\n alreadyThere: SkillId[];\n /** Left out with or without --force; bytewise by id. */\n keptElsewhere: LocalCopyElsewhere[];\n sourceLabel: string;\n};\n\n/**\n * Only the loaded marketplace's own skills, each copied from the marketplace: others' are not on\n * disk here. One already in the destination is skipped unless --force; a local copy anywhere else\n * is the user's own and is left out either way.\n */\nasync function ejectSkills(options: EjectSkillsOptions): Promise<EjectSkillsResult> {\n const { destinationDir, force, sourceResult, matrix } = options;\n\n const marketplaceSkillIds = [...sourceResult.marketplaceSkillIds];\n const alreadyThere = force ? [] : await alreadyIn(destinationDir, marketplaceSkillIds);\n const notThere = marketplaceSkillIds.filter((skillId) => !alreadyThere.includes(skillId));\n const keptElsewhere = localCopiesElsewhere(notThere, matrix, destinationDir);\n const keptIds = new Set(keptElsewhere.map(({ skillId }) => skillId));\n const toCopy = notThere.filter((skillId) => !keptIds.has(skillId));\n\n return {\n copiedSkills: await copyInto(destinationDir, toCopy, sourceResult),\n alreadyThere,\n keptElsewhere,\n sourceLabel: sourceLabelOf(sourceResult),\n };\n}\n\n/** Makes no folder when there is nothing to copy. */\nasync function copyInto(\n destinationDir: string,\n skillIds: SkillId[],\n sourceResult: SourceLoadResult,\n): Promise<CopiedSkill[]> {\n if (skillIds.length === 0) return [];\n\n await ensureDir(destinationDir);\n return copyMarketplaceSkillsToLocalFlattened(skillIds, destinationDir, sourceResult);\n}\n\nfunction sourceLabelOf(sourceResult: SourceLoadResult): string {\n return sourceResult.isLocal\n ? sourceResult.sourcePath\n : sourceResult.marketplace || sourceResult.sourceConfig.source;\n}\n\nfunction localCopiesElsewhere(\n skillIds: readonly SkillId[],\n matrix: MergedSkillsMatrix,\n destinationDir: string,\n): LocalCopyElsewhere[] {\n return skillIds\n .flatMap((skillId) => {\n const copyDir = localCopyDirElsewhere(matrix.skills[skillId], destinationDir);\n return copyDir === undefined ? [] : [{ skillId, copyDir }];\n })\n .sort((a, b) => bytewise(a.skillId, b.skillId));\n}\n\n/** Its local copy's folder, unless that is `<destinationDir>/<id>`, where an eject writes it. */\nfunction localCopyDirElsewhere(\n skill: ResolvedSkill | undefined,\n destinationDir: string,\n): string | undefined {\n if (!skill?.local) return undefined;\n if (skill.localPath === undefined) {\n throw new Error(`Local skill '${skill.id}' was discovered without its directory`);\n }\n\n const copyDir = path.resolve(skill.localPath);\n return copyDir === path.resolve(destinationDir, skill.id) ? undefined : copyDir;\n}\n\n/** Where the host of the installation `projectDir` roots reads skills. */\nfunction installedSkillsDir(projectDir: string): string {\n return resolveInstallPaths(projectDir, scopeAt(projectDir)).skillsDir;\n}\n\ntype EnsureMinimalConfigOptions = {\n projectDir: string;\n sourceResult?: SourceLoadResult;\n};\n\ntype EnsureMinimalConfigResult = {\n configPath: string;\n created: boolean;\n};\n\nasync function ensureMinimalConfig(\n options: EnsureMinimalConfigOptions,\n): Promise<EnsureMinimalConfigResult> {\n const { projectDir, sourceResult } = options;\n\n const provider = providerInUse(projectDir);\n const tsConfigPath = getProjectConfigPath(projectDir, provider);\n\n if (await fileExists(tsConfigPath)) {\n return { configPath: tsConfigPath, created: false };\n }\n\n // ABORT on an unreadable global config: the invented file would record a marketplace from nowhere.\n const resolvedConfig =\n sourceResult?.sourceConfig ?? (await resolveSource({ caller: \"stored\", projectDir }));\n const source = resolvedConfig.source || undefined;\n\n // At home the invented config is the global manifest, which needs its config-types sibling.\n if (isHomeDirectory(projectDir)) {\n await ensureBlankPair(provider);\n if (source) await recordSourceInGlobal(projectDir, source);\n return { configPath: tsConfigPath, created: true };\n }\n\n await writeProjectPartial(\n projectDir,\n {\n skills: [],\n agents: [],\n ...(source ? { marketplace: source } : {}),\n ...(resolvedConfig.marketplace ? { marketplaceName: resolvedConfig.marketplace } : {}),\n },\n { fallbackName: path.basename(projectDir) },\n );\n\n return { configPath: tsConfigPath, created: true };\n}\n\n/** At home the config is the global manifest projects inline from, so it goes through the gate. */\nasync function recordSourceInGlobal(projectDir: string, source: string): Promise<void> {\n await mutateGlobal(\n { kind: \"set-source\", source, fallbackName: path.basename(projectDir) },\n lazyGateDeps(projectDir),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,aAAa;AAC5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ACJ,EAAE,MAAM,cAAc,QAAQ,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,IACtE,aAAa,UAAU;AAAA,EACzB;AACF;","names":["matrix"]}
@@ -4,26 +4,28 @@ import {
4
4
  Init,
5
5
  formatDashboardText,
6
6
  runDashboardFlow
7
- } from "../chunk-3F5LT433.js";
8
- import "../chunk-XYBHH3M5.js";
9
- import "../chunk-H6WUOW5F.js";
10
- import "../chunk-SN64WNWE.js";
7
+ } from "../chunk-Y5VMB73R.js";
8
+ import "../chunk-WH7JXGDA.js";
9
+ import "../chunk-AVKX3IXF.js";
11
10
  import "../chunk-OZXAJNLA.js";
12
11
  import "../chunk-P6CYS4JK.js";
13
- import "../chunk-C2BSCEDN.js";
14
- import "../chunk-U672FZVC.js";
15
- import "../chunk-CKBWEWHZ.js";
16
- import "../chunk-XMQIWPIR.js";
17
- import "../chunk-JNRACLNS.js";
18
- import "../chunk-EC3JXT23.js";
19
- import "../chunk-MQZNDK5F.js";
12
+ import "../chunk-7WN6TUZP.js";
13
+ import "../chunk-7OJ2SS4E.js";
14
+ import "../chunk-H33ZAEKH.js";
15
+ import "../chunk-TNN72UL6.js";
16
+ import "../chunk-V3WJMNBF.js";
17
+ import "../chunk-XSR4WRXJ.js";
18
+ import "../chunk-VFD2XYM7.js";
19
+ import "../chunk-5ZK4IND4.js";
20
+ import "../chunk-77SHXTDD.js";
20
21
  import "../chunk-KIK5EZYD.js";
21
- import "../chunk-5CFHP6Z5.js";
22
- import "../chunk-JTMSFBCA.js";
23
- import "../chunk-FACDJH6O.js";
24
- import "../chunk-ENET4IF6.js";
25
- import "../chunk-UE4Z3YMB.js";
26
- import "../chunk-U46LYYRA.js";
22
+ import "../chunk-ZIBWVTLN.js";
23
+ import "../chunk-OIQKRXHH.js";
24
+ import "../chunk-E6W3PYGF.js";
25
+ import "../chunk-2FE4AJNC.js";
26
+ import "../chunk-D2PC7NIR.js";
27
+ import "../chunk-KKGJH46C.js";
28
+ import "../chunk-4SIBDIIO.js";
27
29
  import "../chunk-GHHJYNAN.js";
28
30
  export {
29
31
  Dashboard,
@@ -2,18 +2,21 @@
2
2
  import {
3
3
  render
4
4
  } from "../chunk-KIK5EZYD.js";
5
+ import {
6
+ HeaderRow
7
+ } from "../chunk-ZIBWVTLN.js";
5
8
  import {
6
9
  SkillAgentSummary
7
- } from "../chunk-5CFHP6Z5.js";
10
+ } from "../chunk-OIQKRXHH.js";
8
11
  import {
9
12
  BaseCommand,
10
13
  otherInstallationsInThisScope,
11
14
  providerFlag,
12
15
  providerNamedBy
13
- } from "../chunk-JTMSFBCA.js";
16
+ } from "../chunk-E6W3PYGF.js";
14
17
  import {
15
18
  computeScopeDiff
16
- } from "../chunk-FACDJH6O.js";
19
+ } from "../chunk-2FE4AJNC.js";
17
20
  import {
18
21
  INSTALL_MODE_LABELS,
19
22
  chooseProviderForThisRun,
@@ -21,25 +24,20 @@ import {
21
24
  formatInstallationDisplay,
22
25
  getInstallationInfo,
23
26
  loadProjectConfig
24
- } from "../chunk-ENET4IF6.js";
27
+ } from "../chunk-D2PC7NIR.js";
25
28
  import {
26
29
  getSkillEntryDisplayName
27
- } from "../chunk-UE4Z3YMB.js";
30
+ } from "../chunk-KKGJH46C.js";
28
31
  import {
29
- CLI_COLORS,
30
32
  CLI_INVOKE_COMMAND,
31
33
  DEFAULT_BRANDING
32
- } from "../chunk-U46LYYRA.js";
34
+ } from "../chunk-4SIBDIIO.js";
33
35
  import "../chunk-GHHJYNAN.js";
34
36
 
35
37
  // src/cli/commands/list.tsx
36
38
  import { useEffect } from "react";
37
- import { Box, Text, useApp } from "ink";
39
+ import { Box, useApp } from "ink";
38
40
  import { jsx, jsxs } from "react/jsx-runtime";
39
- var HeaderRow = ({ label, value }) => /* @__PURE__ */ jsxs(Box, { flexDirection: "row", columnGap: 1, children: [
40
- /* @__PURE__ */ jsx(Box, { flexShrink: 0, children: /* @__PURE__ */ jsx(Text, { color: CLI_COLORS.WARNING, bold: true, children: label }) }),
41
- /* @__PURE__ */ jsx(Text, { color: CLI_COLORS.NEUTRAL, children: value })
42
- ] });
43
41
  var ListView = ({ mode, source, skillConfigs, agentConfigs }) => {
44
42
  const { exit } = useApp();
45
43
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/commands/list.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { Box, Text, useApp } from \"ink\";\nimport { render } from \"../components/render.js\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { CLI_INVOKE_COMMAND, CLI_COLORS, DEFAULT_BRANDING } from \"../consts.js\";\nimport { chooseProviderForThisRun } from \"../lib/installation/install-layout.js\";\nimport {\n otherInstallationsInThisScope,\n providerFlag,\n providerNamedBy,\n} from \"../lib/installation/provider-flag.js\";\nimport { getInstallationInfo, formatInstallationDisplay } from \"../lib/plugins/index.js\";\nimport {\n detectInstallation,\n INSTALL_MODE_LABELS,\n type Installation,\n} from \"../lib/installation/installation.js\";\nimport { loadProjectConfig } from \"../lib/configuration/project-config.js\";\nimport { computeScopeDiff, type SkillDiffRow } from \"../lib/configuration/scope-diff.js\";\nimport { getSkillEntryDisplayName } from \"../lib/matrix/matrix-provider.js\";\nimport { SkillAgentSummary } from \"../components/common/skill-agent-summary.js\";\nimport type { AgentScopeConfig, ProjectConfig, SkillConfig, SkillScope } from \"../types/config.js\";\n\ntype ListViewProps = {\n mode: string;\n source?: string | undefined;\n skillConfigs: SkillConfig[];\n agentConfigs: AgentScopeConfig[];\n};\n\ntype ActiveRoster = Pick<ListViewProps, \"skillConfigs\" | \"agentConfigs\">;\n\n/** The label never shrinks: a value too long for the line wraps beside it instead. */\nconst HeaderRow: React.FC<{ label: string; value: string }> = ({ label, value }) => (\n <Box flexDirection=\"row\" columnGap={1}>\n <Box flexShrink={0}>\n <Text color={CLI_COLORS.WARNING} bold>\n {label}\n </Text>\n </Box>\n <Text color={CLI_COLORS.NEUTRAL}>{value}</Text>\n </Box>\n);\n\nconst ListView: React.FC<ListViewProps> = ({ mode, source, skillConfigs, agentConfigs }) => {\n const { exit } = useApp();\n\n useEffect(() => {\n const timer = setTimeout(() => exit(), 0);\n return () => clearTimeout(timer);\n }, [exit]);\n\n return (\n <Box flexDirection=\"column\" paddingX={1} paddingY={1}>\n <Box flexDirection=\"column\" marginBottom={1}>\n <HeaderRow label=\"Mode\" value={mode} />\n {source && <HeaderRow label=\"Marketplace\" value={source} />}\n </Box>\n\n {/* Installed and current are one configuration, so every row reads unchanged. */}\n <SkillAgentSummary\n skillConfigs={skillConfigs}\n agentConfigs={agentConfigs}\n installedSkillConfigs={skillConfigs}\n installedAgentConfigs={agentConfigs}\n isInitMode={false}\n />\n </Box>\n );\n};\n\nexport default class List extends BaseCommand {\n static summary = \"Show installation information\";\n static description = `Display details about the ${DEFAULT_BRANDING.NAME} installation (local or plugin mode)`;\n static aliases = [\"ls\"];\n\n static flags = { provider: providerFlag() };\n\n static examples = [\n {\n description: \"Show current installation details\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n ];\n\n /** Names the other installation in this scope; reports rather than refuses, like `doctor`. */\n private async sayWhichInstallationThisIs(providerFlagValue: string | undefined): Promise<void> {\n const named = providerNamedBy(providerFlagValue);\n if (named !== undefined) {\n chooseProviderForThisRun(named);\n return;\n }\n\n const line = await otherInstallationsInThisScope(process.cwd());\n if (line !== null) this.log(line);\n }\n\n async run(): Promise<void> {\n const { flags } = await this.parse(List);\n await this.sayWhenTheGlobalInstallationStandsIn(providerNamedBy(flags.provider));\n await this.sayWhichInstallationThisIs(flags.provider);\n await this.ensureConfigReadable(process.cwd());\n\n const installation = await detectInstallation();\n if (!installation) return this.reportNoInstallation();\n\n const loaded = await loadProjectConfig(installation.projectDir);\n if (loaded === null) return this.printInstallationInfo([]);\n if (!process.stdin.isTTY) {\n return this.printInstallationInfo(skillLinesOf(activeRosterOf(loaded.config)));\n }\n\n await showListView(installation, loaded.config);\n }\n\n private reportNoInstallation(): void {\n this.log(\"No installation found.\");\n this.log(`Run '${CLI_INVOKE_COMMAND} init' to create one.`);\n }\n\n private async printInstallationInfo(skillLines: string[]): Promise<void> {\n const info = await getInstallationInfo();\n if (!info) return;\n\n this.log(\"\");\n this.log(formatInstallationDisplay(info, skillLines));\n this.log(\"\");\n }\n}\n\nasync function showListView(installation: Installation, config: ProjectConfig): Promise<void> {\n const { waitUntilExit, clear } = render(\n <ListView\n mode={INSTALL_MODE_LABELS[installation.mode]}\n source={config.marketplace}\n {...activeRosterOf(config)}\n />,\n );\n\n await waitUntilExit();\n clear();\n}\n\nfunction activeRosterOf(config: ProjectConfig): ActiveRoster {\n return {\n skillConfigs: config.skills.filter((skill) => !skill.excluded),\n agentConfigs: config.agents.filter((agent) => !agent.excluded),\n };\n}\n\n/** The panel's skill rows, read as it reads them: project rows first, each under the panel's name. */\nfunction skillLinesOf({ skillConfigs, agentConfigs }: ActiveRoster): string[] {\n const { projectSkillRows, globalSkillRows } = computeScopeDiff({\n currentSkills: skillConfigs,\n currentAgents: agentConfigs,\n installedSkillConfigs: skillConfigs,\n installedAgentConfigs: agentConfigs,\n isInitMode: false,\n });\n\n return [\n ...projectSkillRows.map((row) => skillLine(row, \"project\")),\n ...globalSkillRows.map((row) => skillLine(row, \"global\")),\n ];\n}\n\nfunction skillLine(row: SkillDiffRow, scope: SkillScope): string {\n return `${getSkillEntryDisplayName(row)} (${scope})`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,iBAAiB;AAEjC,SAAS,KAAK,MAAM,cAAc;AAkChC,SAEI,KAFJ;AADF,IAAM,YAAwD,CAAC,EAAE,OAAO,MAAM,MAC5E,qBAAC,OAAI,eAAc,OAAM,WAAW,GAClC;AAAA,sBAAC,OAAI,YAAY,GACf,8BAAC,QAAK,OAAO,WAAW,SAAS,MAAI,MAClC,iBACH,GACF;AAAA,EACA,oBAAC,QAAK,OAAO,WAAW,SAAU,iBAAM;AAAA,GAC1C;AAGF,IAAM,WAAoC,CAAC,EAAE,MAAM,QAA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AE,kBAAkB,gBAAgB,IAAI,iBAAiB;AAAA,IAC7D,eAAe;AAAA,IACf,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,IACvB,YAAY;AAAA,EACd,CAAC;AAED,SAAO;AAAA,IACL,GAAG,iBAAiB,IAAI,CAAC,QAAQ,UAAU,KAAK,SAAS,CAAC;AAAA,IAC1D,GAAG,gBAAgB,IAAI,CAAC,QAAQ,UAAU,KAAK,QAAQ,CAAC;AAAA,EAC1D;AACF;AAEA,SAAS,UAAU,KAAmB,OAA2B;AAC/D,SAAO,GAAG,yBAAyB,GAAG,CAAC,KAAK,KAAK;AACnD;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/commands/list.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { Box, useApp } from \"ink\";\nimport { render } from \"../components/render.js\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { CLI_INVOKE_COMMAND, DEFAULT_BRANDING } from \"../consts.js\";\nimport { chooseProviderForThisRun } from \"../lib/installation/install-layout.js\";\nimport {\n otherInstallationsInThisScope,\n providerFlag,\n providerNamedBy,\n} from \"../lib/installation/provider-flag.js\";\nimport { getInstallationInfo, formatInstallationDisplay } from \"../lib/plugins/index.js\";\nimport {\n detectInstallation,\n INSTALL_MODE_LABELS,\n type Installation,\n} from \"../lib/installation/installation.js\";\nimport { loadProjectConfig } from \"../lib/configuration/project-config.js\";\nimport { computeScopeDiff, type SkillDiffRow } from \"../lib/configuration/scope-diff.js\";\nimport { getSkillEntryDisplayName } from \"../lib/matrix/matrix-provider.js\";\nimport { HeaderRow } from \"../components/common/header-row.js\";\nimport { SkillAgentSummary } from \"../components/common/skill-agent-summary.js\";\nimport type { AgentScopeConfig, ProjectConfig, SkillConfig, SkillScope } from \"../types/config.js\";\n\ntype ListViewProps = {\n mode: string;\n source?: string | undefined;\n skillConfigs: SkillConfig[];\n agentConfigs: AgentScopeConfig[];\n};\n\ntype ActiveRoster = Pick<ListViewProps, \"skillConfigs\" | \"agentConfigs\">;\n\nconst ListView: React.FC<ListViewProps> = ({ mode, source, skillConfigs, agentConfigs }) => {\n const { exit } = useApp();\n\n useEffect(() => {\n const timer = setTimeout(() => exit(), 0);\n return () => clearTimeout(timer);\n }, [exit]);\n\n return (\n <Box flexDirection=\"column\" paddingX={1} paddingY={1}>\n <Box flexDirection=\"column\" marginBottom={1}>\n <HeaderRow label=\"Mode\" value={mode} />\n {source && <HeaderRow label=\"Marketplace\" value={source} />}\n </Box>\n\n {/* Installed and current are one configuration, so every row reads unchanged. */}\n <SkillAgentSummary\n skillConfigs={skillConfigs}\n agentConfigs={agentConfigs}\n installedSkillConfigs={skillConfigs}\n installedAgentConfigs={agentConfigs}\n isInitMode={false}\n />\n </Box>\n );\n};\n\nexport default class List extends BaseCommand {\n static summary = \"Show installation information\";\n static description = `Display details about the ${DEFAULT_BRANDING.NAME} installation (local or plugin mode)`;\n static aliases = [\"ls\"];\n\n static flags = { provider: providerFlag() };\n\n static examples = [\n {\n description: \"Show current installation details\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n ];\n\n /** Names the other installation in this scope; reports rather than refuses, like `doctor`. */\n private async sayWhichInstallationThisIs(providerFlagValue: string | undefined): Promise<void> {\n const named = providerNamedBy(providerFlagValue);\n if (named !== undefined) {\n chooseProviderForThisRun(named);\n return;\n }\n\n const line = await otherInstallationsInThisScope(process.cwd());\n if (line !== null) this.log(line);\n }\n\n async run(): Promise<void> {\n const { flags } = await this.parse(List);\n await this.sayWhenTheGlobalInstallationStandsIn(providerNamedBy(flags.provider));\n await this.sayWhichInstallationThisIs(flags.provider);\n await this.ensureConfigReadable(process.cwd());\n\n const installation = await detectInstallation();\n if (!installation) return this.reportNoInstallation();\n\n const loaded = await loadProjectConfig(installation.projectDir);\n if (loaded === null) return this.printInstallationInfo([]);\n if (!process.stdin.isTTY) {\n return this.printInstallationInfo(skillLinesOf(activeRosterOf(loaded.config)));\n }\n\n await showListView(installation, loaded.config);\n }\n\n private reportNoInstallation(): void {\n this.log(\"No installation found.\");\n this.log(`Run '${CLI_INVOKE_COMMAND} init' to create one.`);\n }\n\n private async printInstallationInfo(skillLines: string[]): Promise<void> {\n const info = await getInstallationInfo();\n if (!info) return;\n\n this.log(\"\");\n this.log(formatInstallationDisplay(info, skillLines));\n this.log(\"\");\n }\n}\n\nasync function showListView(installation: Installation, config: ProjectConfig): Promise<void> {\n const { waitUntilExit, clear } = render(\n <ListView\n mode={INSTALL_MODE_LABELS[installation.mode]}\n source={config.marketplace}\n {...activeRosterOf(config)}\n />,\n );\n\n await waitUntilExit();\n clear();\n}\n\nfunction activeRosterOf(config: ProjectConfig): ActiveRoster {\n return {\n skillConfigs: config.skills.filter((skill) => !skill.excluded),\n agentConfigs: config.agents.filter((agent) => !agent.excluded),\n };\n}\n\n/** The panel's skill rows, read as it reads them: project rows first, each under the panel's name. */\nfunction skillLinesOf({ skillConfigs, agentConfigs }: ActiveRoster): string[] {\n const { projectSkillRows, globalSkillRows } = computeScopeDiff({\n currentSkills: skillConfigs,\n currentAgents: agentConfigs,\n installedSkillConfigs: skillConfigs,\n installedAgentConfigs: agentConfigs,\n isInitMode: false,\n });\n\n return [\n ...projectSkillRows.map((row) => skillLine(row, \"project\")),\n ...globalSkillRows.map((row) => skillLine(row, \"global\")),\n ];\n}\n\nfunction skillLine(row: SkillDiffRow, scope: SkillScope): string {\n return `${getSkillEntryDisplayName(row)} (${scope})`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,iBAAiB;AAEjC,SAAS,KAAK,cAAc;AA2CtB,SACE,KADF;AAVN,IAAM,WAAoC,CAAC,EAAE,MAAM,QAAQ,cAAc,aAAa,MAAM;AAC1F,QAAM,EAAE,KAAK,IAAI,OAAO;AAExB,YAAU,MAAM;AACd,UAAM,QAAQ,WAAW,MAAM,KAAK,GAAG,CAAC;AACxC,WAAO,MAAM,aAAa,KAAK;AAAA,EACjC,GAAG,CAAC,I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,IAAI,CAAC,QAAQ,UAAU,KAAK,SAAS,CAAC;AAAA,IAC1D,GAAG,gBAAgB,IAAI,CAAC,QAAQ,UAAU,KAAK,QAAQ,CAAC;AAAA,EAC1D;AACF;AAEA,SAAS,UAAU,KAAmB,OAA2B;AAC/D,SAAO,GAAG,yBAAyB,GAAG,CAAC,KAAK,KAAK;AACnD;","names":[]}
@@ -2,15 +2,15 @@
2
2
  import {
3
3
  BaseCommand,
4
4
  EXIT_CODES
5
- } from "../../chunk-JTMSFBCA.js";
6
- import "../../chunk-FACDJH6O.js";
5
+ } from "../../chunk-E6W3PYGF.js";
6
+ import "../../chunk-2FE4AJNC.js";
7
7
  import {
8
8
  isDirectoryEmpty,
9
9
  validateKebabCaseName,
10
10
  validateMarketplaceName,
11
11
  writeFile
12
- } from "../../chunk-ENET4IF6.js";
13
- import "../../chunk-UE4Z3YMB.js";
12
+ } from "../../chunk-D2PC7NIR.js";
13
+ import "../../chunk-KKGJH46C.js";
14
14
  import {
15
15
  CLI_INVOKE_COMMAND,
16
16
  DEFAULT_VERSION,
@@ -20,7 +20,7 @@ import {
20
20
  SKILL_RULES_PATH,
21
21
  STACKS_FILE_PATH,
22
22
  STANDARD_FILES
23
- } from "../../chunk-U46LYYRA.js";
23
+ } from "../../chunk-4SIBDIIO.js";
24
24
  import "../../chunk-GHHJYNAN.js";
25
25
 
26
26
  // src/cli/commands/new/marketplace.ts
@@ -1,28 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  loadSource
4
- } from "../chunk-CKBWEWHZ.js";
5
- import "../chunk-XMQIWPIR.js";
6
- import "../chunk-JNRACLNS.js";
7
- import "../chunk-EC3JXT23.js";
8
- import "../chunk-MQZNDK5F.js";
4
+ } from "../chunk-TNN72UL6.js";
5
+ import "../chunk-V3WJMNBF.js";
6
+ import "../chunk-XSR4WRXJ.js";
7
+ import "../chunk-VFD2XYM7.js";
8
+ import "../chunk-5ZK4IND4.js";
9
+ import "../chunk-77SHXTDD.js";
9
10
  import {
10
11
  BaseCommand
11
- } from "../chunk-JTMSFBCA.js";
12
- import "../chunk-FACDJH6O.js";
12
+ } from "../chunk-E6W3PYGF.js";
13
+ import "../chunk-2FE4AJNC.js";
13
14
  import {
14
15
  INFO_MESSAGES,
15
16
  STATUS_MESSAGES
16
- } from "../chunk-ENET4IF6.js";
17
+ } from "../chunk-D2PC7NIR.js";
17
18
  import {
18
19
  plural,
19
20
  stripTerminalControls,
20
- truncateText,
21
- typedValues
22
- } from "../chunk-UE4Z3YMB.js";
21
+ truncateText
22
+ } from "../chunk-KKGJH46C.js";
23
23
  import {
24
- EDITOR_ADDRESS
25
- } from "../chunk-U46LYYRA.js";
24
+ EDITOR_ADDRESS,
25
+ typedValues
26
+ } from "../chunk-4SIBDIIO.js";
26
27
  import "../chunk-GHHJYNAN.js";
27
28
 
28
29
  // src/cli/commands/search.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/commands/search.ts"],"sourcesContent":["import { Args } from \"@oclif/core\";\nimport { printTable } from \"@oclif/table\";\nimport { sortBy } from \"remeda\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { EDITOR_ADDRESS } from \"../consts.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport type { ResolvedSkill } from \"../types/index.js\";\nimport { INFO_MESSAGES, STATUS_MESSAGES } from \"../utils/messages.js\";\nimport { plural, stripTerminalControls, truncateText } from \"../utils/string.js\";\nimport { typedValues } from \"../utils/typed-object.js\";\n\nconst MAX_DESCRIPTION_WIDTH = 50;\n\n/** Plain strings: sanitised values are no longer known to be in their unions. */\ntype ResultRow = {\n id: string;\n name: string;\n source: string;\n category: string;\n description: string;\n};\n\nexport default class Search extends BaseCommand {\n static summary = \"Search the catalog of available skills\";\n static description =\n \"Read-only catalog browse. Searches the marketplace this installation reads from, \" +\n \"plus the local skills already on disk, by id, displayName, slug, description, or \" +\n `category. To install one, add it in ${EDITOR_ADDRESS}.`;\n\n static examples = [\n {\n description: \"Search for React skills\",\n command: \"<%= config.bin %> search react\",\n },\n {\n description: \"Search by any keyword (matches id, name, description, category)\",\n command: \"<%= config.bin %> search state\",\n },\n ];\n\n static args = {\n query: Args.string({\n description: \"Search query (matches id, displayName, slug, description, category)\",\n required: true,\n }),\n };\n\n static flags = {};\n\n async run(): Promise<void> {\n const { args } = await this.parse(Search);\n await this.sayWhenTheProjectsConfigDeclaresNothing(\n INFO_MESSAGES.DECLARES_NOTHING_TO_SEARCH_FROM,\n );\n // The configs name the marketplace searched, so an unreadable one is not read past.\n await this.ensureConfigReadable(process.cwd());\n await this.runSearch(args.query);\n }\n\n private async runSearch(query: string): Promise<void> {\n try {\n this.log(STATUS_MESSAGES.LOADING_SKILLS);\n const results = skillsMatching(await loadSearchableSkills(), query);\n\n this.log(\"\");\n if (results.length === 0) {\n this.warn(`No skills found matching \"${query}\"`);\n return;\n }\n\n this.log(`Found ${plural(results.length, \"skill\")} matching \"${query}\"`);\n this.log(\"\");\n printResultsTable(results);\n this.log(\"\");\n } catch (error) {\n this.handleError(error);\n }\n }\n}\n\n/** The marketplace matrix, with on-disk local skills already merged in by `loadSource`. */\nasync function loadSearchableSkills(): Promise<ResolvedSkill[]> {\n const { sourceResult } = await loadSource({ projectDir: process.cwd() });\n\n return typedValues(sourceResult.matrix.skills);\n}\n\n/** In display-name order, case aside. */\nfunction skillsMatching(skills: ResolvedSkill[], query: string): ResolvedSkill[] {\n return sortBy(\n skills.filter((skill) => matchesQuery(skill, query)),\n (skill) => skill.displayName.toLowerCase(),\n );\n}\n\nfunction printResultsTable(results: ResolvedSkill[]): void {\n printTable({\n data: results.map(toResultRow),\n columns: [\n { key: \"id\", name: \"ID\" },\n { key: \"name\", name: \"Name\" },\n { key: \"source\", name: \"Origin\" },\n { key: \"category\", name: \"Category\" },\n { key: \"description\", name: \"Description\" },\n ],\n headerOptions: { bold: true },\n });\n}\n\n/** Strips terminal controls: a third-party marketplace's text could otherwise repaint the table. */\nfunction toResultRow(skill: ResolvedSkill): ResultRow {\n return {\n id: stripTerminalControls(skill.id),\n name: stripTerminalControls(skill.displayName),\n source: stripTerminalControls(activeSourceName(skill)),\n category: stripTerminalControls(skill.category),\n description: truncateText(skill.description, MAX_DESCRIPTION_WIDTH),\n };\n}\n\n/** `loadSource` always tags an origin, so an untagged skill is a bug, not a fallback case. */\nfunction activeSourceName(skill: ResolvedSkill): string {\n const { activeSource } = skill;\n if (!activeSource) {\n throw new Error(\n `Skill \"${skill.id}\" was loaded with no origin, so where it comes from is unknown`,\n );\n }\n return activeSource.name;\n}\n\nfunction matchesQuery(skill: ResolvedSkill, query: string): boolean {\n const lowerQuery = query.toLowerCase();\n return [skill.id, skill.displayName, skill.slug, skill.description, skill.category].some(\n (field) => field.toLowerCase().includes(lowerQuery),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAUvB,IAAM,wBAAwB;AAW9B,IAAqB,SAArB,MAAqB,gBAAe,YAAY;AAAA,EAC9C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL,yMAEuC,cAAc;AAAA,EAEvD,OAAO,WAAW;AAAA,IAChB;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,OAAO,OAAO;AAAA,IACZ,OAAO,KAAK,OAAO;AAAA,MACjB,aAAa;AAAA,MACb,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,QAAQ,CAAC;AAAA,EAEhB,MAAM,MAAqB;AACzB,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,OAAM;AACxC,UAAM,KAAK;AAAA,MACT,cAAc;AAAA,IAChB;AAEA,UAAM,KAAK,qBAAqB,QAAQ,IAAI,CAAC;AAC7C,UAAM,KAAK,UAAU,KAAK,KAAK;AAAA,EACjC;AAAA,EAEA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AAM,WAAW;AAAA,IAC7C,QAAQ,sBAAsB,iBAAiB,KAAK,CAAC;AAAA,IACrD,UAAU,sBAAsB,MAAM,QAAQ;AAAA,IAC9C,aAAa,aAAa,MAAM,aAAa,qBAAqB;AAAA,EACpE;AACF;AAGA,SAAS,iBAAiB,OAA8B;AACtD,QAAM,EAAE,aAAa,IAAI;AACzB,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR,UAAU,MAAM,EAAE;AAAA,IACpB;AAAA,EACF;AACA,SAAO,aAAa;AACtB;AAEA,SAAS,aAAa,OAAsB,OAAwB;AAClE,QAAM,aAAa,MAAM,YAAY;AACrC,SAAO,CAAC,MAAM,IAAI,MAAM,aAAa,MAAM,MAAM,MAAM,aAAa,MAAM,QAAQ,EAAE;AAAA,IAClF,CAAC,UAAU,MAAM,YAAY,EAAE,SAAS,UAAU;AAAA,EACpD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/commands/search.ts"],"sourcesContent":["import { Args } from \"@oclif/core\";\nimport { printTable } from \"@oclif/table\";\nimport { sortBy } from \"remeda\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { EDITOR_ADDRESS } from \"../consts.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport type { ResolvedSkill } from \"../types/index.js\";\nimport { INFO_MESSAGES, STATUS_MESSAGES } from \"../utils/messages.js\";\nimport { plural, stripTerminalControls, truncateText } from \"../utils/string.js\";\nimport { typedValues } from \"../utils/typed-object.js\";\n\nconst MAX_DESCRIPTION_WIDTH = 50;\n\n/** Plain strings: sanitised values are no longer known to be in their unions. */\ntype ResultRow = {\n id: string;\n name: string;\n source: string;\n category: string;\n description: string;\n};\n\nexport default class Search extends BaseCommand {\n static summary = \"Search the catalog of available skills\";\n static description =\n \"Read-only catalog browse. Searches the marketplace this installation reads from, \" +\n \"plus the local skills already on disk, by id, displayName, slug, description, or \" +\n `category. To install one, add it in ${EDITOR_ADDRESS}.`;\n\n static examples = [\n {\n description: \"Search for React skills\",\n command: \"<%= config.bin %> search react\",\n },\n {\n description: \"Search by any keyword (matches id, name, description, category)\",\n command: \"<%= config.bin %> search state\",\n },\n ];\n\n static args = {\n query: Args.string({\n description: \"Search query (matches id, displayName, slug, description, category)\",\n required: true,\n }),\n };\n\n static flags = {};\n\n async run(): Promise<void> {\n const { args } = await this.parse(Search);\n await this.sayWhenTheProjectsConfigDeclaresNothing(\n INFO_MESSAGES.DECLARES_NOTHING_TO_SEARCH_FROM,\n );\n // The configs name the marketplace searched, so an unreadable one is not read past.\n await this.ensureConfigReadable(process.cwd());\n await this.runSearch(args.query);\n }\n\n private async runSearch(query: string): Promise<void> {\n try {\n this.log(STATUS_MESSAGES.LOADING_SKILLS);\n const results = skillsMatching(await loadSearchableSkills(), query);\n\n this.log(\"\");\n if (results.length === 0) {\n this.warn(`No skills found matching \"${query}\"`);\n return;\n }\n\n this.log(`Found ${plural(results.length, \"skill\")} matching \"${query}\"`);\n this.log(\"\");\n printResultsTable(results);\n this.log(\"\");\n } catch (error) {\n this.handleError(error);\n }\n }\n}\n\n/** The marketplace matrix, with on-disk local skills already merged in by `loadSource`. */\nasync function loadSearchableSkills(): Promise<ResolvedSkill[]> {\n const { sourceResult } = await loadSource({ projectDir: process.cwd() });\n\n return typedValues(sourceResult.matrix.skills);\n}\n\n/** In display-name order, case aside. */\nfunction skillsMatching(skills: ResolvedSkill[], query: string): ResolvedSkill[] {\n return sortBy(\n skills.filter((skill) => matchesQuery(skill, query)),\n (skill) => skill.displayName.toLowerCase(),\n );\n}\n\nfunction printResultsTable(results: ResolvedSkill[]): void {\n printTable({\n data: results.map(toResultRow),\n columns: [\n { key: \"id\", name: \"ID\" },\n { key: \"name\", name: \"Name\" },\n { key: \"source\", name: \"Origin\" },\n { key: \"category\", name: \"Category\" },\n { key: \"description\", name: \"Description\" },\n ],\n headerOptions: { bold: true },\n });\n}\n\n/** Strips terminal controls: a third-party marketplace's text could otherwise repaint the table. */\nfunction toResultRow(skill: ResolvedSkill): ResultRow {\n return {\n id: stripTerminalControls(skill.id),\n name: stripTerminalControls(skill.displayName),\n source: stripTerminalControls(activeSourceName(skill)),\n category: stripTerminalControls(skill.category),\n description: truncateText(skill.description, MAX_DESCRIPTION_WIDTH),\n };\n}\n\n/** `loadSource` always tags an origin, so an untagged skill is a bug, not a fallback case. */\nfunction activeSourceName(skill: ResolvedSkill): string {\n const { activeSource } = skill;\n if (!activeSource) {\n throw new Error(\n `Skill \"${skill.id}\" was loaded with no origin, so where it comes from is unknown`,\n );\n }\n return activeSource.name;\n}\n\nfunction matchesQuery(skill: ResolvedSkill, query: string): boolean {\n const lowerQuery = query.toLowerCase();\n return [skill.id, skill.displayName, skill.slug, skill.description, skill.category].some(\n (field) => field.toLowerCase().includes(lowerQuery),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAUvB,IAAM,wBAAwB;AAW9B,IAAqB,SAArB,MAAqB,gBAAe,YAAY;AAAA,EAC9C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL,yMAEuC,cAAc;AAAA,EAEvD,OAAO,WAAW;AAAA,IAChB;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,OAAO,OAAO;AAAA,IACZ,OAAO,KAAK,OAAO;AAAA,MACjB,aAAa;AAAA,MACb,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,QAAQ,CAAC;AAAA,EAEhB,MAAM,MAAqB;AACzB,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,OAAM;AACxC,UAAM,KAAK;AAAA,MACT,cAAc;AAAA,IAChB;AAEA,UAAM,KAAK,qBAAqB,QAAQ,IAAI,CAAC;AAC7C,UAAM,KAAK,UAAU,KAAK,KAAK;AAAA,EACjC;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