agents-inc 0.164.0 → 0.165.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 (191) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +8 -9
  3. package/dist/{chunk-B6FSLXYN.js → chunk-42TNV2TK.js} +3 -3
  4. package/dist/chunk-4AAOOAIN.js +49 -0
  5. package/dist/chunk-4AAOOAIN.js.map +1 -0
  6. package/dist/{chunk-NQXO4LR3.js → chunk-4C7GL4F7.js} +16 -11
  7. package/dist/chunk-4C7GL4F7.js.map +1 -0
  8. package/dist/{chunk-Q4IRRVXK.js → chunk-57KU6SPH.js} +3 -3
  9. package/dist/{chunk-S63LXWMC.js → chunk-5M3PQNXI.js} +2 -2
  10. package/dist/{chunk-3WVH2CTK.js → chunk-5P26XBZO.js} +15 -8
  11. package/dist/chunk-5P26XBZO.js.map +1 -0
  12. package/dist/{chunk-G2JJ5BO5.js → chunk-6AIZPSEI.js} +337 -140
  13. package/dist/chunk-6AIZPSEI.js.map +1 -0
  14. package/dist/{chunk-NKGYKOB7.js → chunk-6CY6PW5X.js} +7 -8
  15. package/dist/chunk-6CY6PW5X.js.map +1 -0
  16. package/dist/{chunk-XHPWTL4I.js → chunk-6SW6SB7H.js} +3 -3
  17. package/dist/chunk-AAWZED5M.js +980 -0
  18. package/dist/chunk-AAWZED5M.js.map +1 -0
  19. package/dist/{chunk-UITEKY2R.js → chunk-AQXKAPCD.js} +30 -4
  20. package/dist/chunk-AQXKAPCD.js.map +1 -0
  21. package/dist/{chunk-X4SSJZLY.js → chunk-B5UUHBAM.js} +12 -261
  22. package/dist/chunk-B5UUHBAM.js.map +1 -0
  23. package/dist/{chunk-ARYNOWKF.js → chunk-BGU25XAY.js} +8 -8
  24. package/dist/{chunk-QGUP3QJF.js → chunk-CBMAO6OP.js} +22 -18
  25. package/dist/{chunk-QGUP3QJF.js.map → chunk-CBMAO6OP.js.map} +1 -1
  26. package/dist/{chunk-YRS3QZP2.js → chunk-CEBDGZID.js} +3 -3
  27. package/dist/{chunk-ABAZMMG4.js → chunk-CK5RM3DJ.js} +2 -2
  28. package/dist/{chunk-PHCPUQVR.js → chunk-CTUJO23Z.js} +2 -2
  29. package/dist/{chunk-QZX7SYKU.js → chunk-E6CHHXGY.js} +2 -2
  30. package/dist/{chunk-ZVXGW2IC.js → chunk-F2ZWFWTP.js} +4 -6
  31. package/dist/chunk-F2ZWFWTP.js.map +1 -0
  32. package/dist/{chunk-AVK2HEKB.js → chunk-GKPW33FP.js} +2 -6
  33. package/dist/{chunk-AVK2HEKB.js.map → chunk-GKPW33FP.js.map} +1 -1
  34. package/dist/{chunk-ECURHW3T.js → chunk-HR4YDSJK.js} +13 -12
  35. package/dist/chunk-HR4YDSJK.js.map +1 -0
  36. package/dist/{chunk-XPDVAJDH.js → chunk-IM45LLQX.js} +3599 -1558
  37. package/dist/chunk-IM45LLQX.js.map +1 -0
  38. package/dist/chunk-IVNKU4DM.js +39 -0
  39. package/dist/chunk-IVNKU4DM.js.map +1 -0
  40. package/dist/{chunk-XVAQG2CV.js → chunk-JOEA52NR.js} +10 -8
  41. package/dist/chunk-JOEA52NR.js.map +1 -0
  42. package/dist/{chunk-RGYDFBCT.js → chunk-JV4TKXEN.js} +5 -5
  43. package/dist/{chunk-4VL3CEOS.js → chunk-LXXGZAD3.js} +3 -3
  44. package/dist/chunk-MBUGQI2M.js +73 -0
  45. package/dist/chunk-MBUGQI2M.js.map +1 -0
  46. package/dist/{chunk-URXIQE7I.js → chunk-MWDY76MT.js} +2 -2
  47. package/dist/{chunk-V5GLL2JB.js → chunk-P3KJCYSR.js} +7 -7
  48. package/dist/{chunk-6MV4JOCL.js → chunk-PSX7CT6V.js} +2 -2
  49. package/dist/{chunk-B3Y3QMWI.js → chunk-TRTVOVHR.js} +4 -4
  50. package/dist/{chunk-AOTCIUGX.js → chunk-TV5Y53R2.js} +2 -2
  51. package/dist/{chunk-K5ITEA3I.js → chunk-UBSSIIWD.js} +34 -17
  52. package/dist/chunk-UBSSIIWD.js.map +1 -0
  53. package/dist/chunk-UCORXS4D.js +250 -0
  54. package/dist/chunk-UCORXS4D.js.map +1 -0
  55. package/dist/chunk-UR3RRTPO.js +159 -0
  56. package/dist/chunk-UR3RRTPO.js.map +1 -0
  57. package/dist/chunk-V5CWACR5.js +375 -0
  58. package/dist/chunk-V5CWACR5.js.map +1 -0
  59. package/dist/{chunk-LT5GXEB2.js → chunk-VPJUCVU7.js} +8 -7
  60. package/dist/chunk-VPJUCVU7.js.map +1 -0
  61. package/dist/chunk-VRXX4D6K.js +31 -0
  62. package/dist/chunk-VRXX4D6K.js.map +1 -0
  63. package/dist/{chunk-2CQNPLVF.js → chunk-WIFIAQZU.js} +63 -42
  64. package/dist/chunk-WIFIAQZU.js.map +1 -0
  65. package/dist/chunk-WSGX4IWC.js +356 -0
  66. package/dist/chunk-WSGX4IWC.js.map +1 -0
  67. package/dist/{chunk-X37UYIE3.js → chunk-WTANOSXK.js} +436 -739
  68. package/dist/chunk-WTANOSXK.js.map +1 -0
  69. package/dist/{chunk-XATLUKXK.js → chunk-X2KUI7V3.js} +6 -6
  70. package/dist/{chunk-NTF4UXGK.js → chunk-XATIKM3P.js} +73 -30
  71. package/dist/chunk-XATIKM3P.js.map +1 -0
  72. package/dist/{chunk-J27W6TXS.js → chunk-XQHZPINL.js} +8 -4
  73. package/dist/chunk-XQHZPINL.js.map +1 -0
  74. package/dist/{chunk-DSL66I4N.js → chunk-Y5SNGMB7.js} +6 -6
  75. package/dist/{chunk-7REKOTKG.js → chunk-YNOOZFIB.js} +3 -3
  76. package/dist/commands/build/marketplace.js +17 -17
  77. package/dist/commands/build/marketplace.js.map +1 -1
  78. package/dist/commands/build/plugins.js +11 -9
  79. package/dist/commands/build/plugins.js.map +1 -1
  80. package/dist/commands/compile.js +106 -27
  81. package/dist/commands/compile.js.map +1 -1
  82. package/dist/commands/doctor.js +427 -192
  83. package/dist/commands/doctor.js.map +1 -1
  84. package/dist/commands/edit.js +504 -314
  85. package/dist/commands/edit.js.map +1 -1
  86. package/dist/commands/eject.js +41 -23
  87. package/dist/commands/eject.js.map +1 -1
  88. package/dist/commands/init.js +44 -40
  89. package/dist/commands/list.js +44 -10
  90. package/dist/commands/list.js.map +1 -1
  91. package/dist/commands/new/marketplace.js +13 -10
  92. package/dist/commands/new/marketplace.js.map +1 -1
  93. package/dist/commands/search.js +12 -10
  94. package/dist/commands/search.js.map +1 -1
  95. package/dist/commands/share.js +103 -15
  96. package/dist/commands/share.js.map +1 -1
  97. package/dist/commands/uninstall.js +264 -106
  98. package/dist/commands/uninstall.js.map +1 -1
  99. package/dist/commands/update.js +50 -20
  100. package/dist/commands/update.js.map +1 -1
  101. package/dist/components/common/prompt-confirm.js +1 -1
  102. package/dist/components/common/removal-plan-confirm.js +2 -2
  103. package/dist/components/common/select-list.js +3 -3
  104. package/dist/components/common/spinner.js +6 -3
  105. package/dist/components/wizard/category-grid.js +5 -5
  106. package/dist/components/wizard/checkbox-grid.js +4 -4
  107. package/dist/components/wizard/domain-selection.js +9 -9
  108. package/dist/components/wizard/run-wizard-session.js +29 -29
  109. package/dist/components/wizard/scroll-affordance.js +2 -2
  110. package/dist/components/wizard/skill-agent-summary.js +5 -5
  111. package/dist/components/wizard/source-grid.js +6 -6
  112. package/dist/components/wizard/stack-selection.js +8 -8
  113. package/dist/components/wizard/step-agents.js +8 -8
  114. package/dist/components/wizard/step-build.js +8 -8
  115. package/dist/components/wizard/step-confirm.js +9 -9
  116. package/dist/components/wizard/step-sources.js +9 -9
  117. package/dist/components/wizard/step-stack.js +9 -9
  118. package/dist/components/wizard/summary-panel.js +8 -8
  119. package/dist/components/wizard/toast.js +2 -2
  120. package/dist/components/wizard/wizard-layout.js +12 -12
  121. package/dist/components/wizard/wizard-tabs.js +2 -2
  122. package/dist/components/wizard/wizard.js +27 -27
  123. package/dist/hooks/init.js +59 -43
  124. package/dist/hooks/init.js.map +1 -1
  125. package/dist/load-agent-defs-JHLE6MAE.js +14 -0
  126. package/dist/recompile-project-agents-ZPP5NOLZ.js +18 -0
  127. package/dist/{source-loader-GRBVNRAW.js → source-loader-RWZAYJ7E.js} +6 -4
  128. package/dist/src/agents/_templates/agent-body.liquid +55 -0
  129. package/dist/src/agents/_templates/agent.liquid +1 -55
  130. package/dist/src/agents/meta/agent-summoner/output.md +1 -1
  131. package/dist/src/agents/meta/agent-summoner/playbook.md +15 -7
  132. package/dist/stores/wizard-store.js +4 -4
  133. package/package.json +10 -9
  134. package/src/agents/_templates/agent-body.liquid +55 -0
  135. package/src/agents/_templates/agent.liquid +1 -55
  136. package/src/agents/meta/agent-summoner/output.md +1 -1
  137. package/src/agents/meta/agent-summoner/playbook.md +15 -7
  138. package/src/schemas/project-config.schema.json +1 -1
  139. package/src/schemas/project-source-config.schema.json +1 -1
  140. package/dist/chunk-2CQNPLVF.js.map +0 -1
  141. package/dist/chunk-3WVH2CTK.js.map +0 -1
  142. package/dist/chunk-7ANJQLPJ.js +0 -35
  143. package/dist/chunk-7ANJQLPJ.js.map +0 -1
  144. package/dist/chunk-ECURHW3T.js.map +0 -1
  145. package/dist/chunk-FLW25ORT.js +0 -130
  146. package/dist/chunk-FLW25ORT.js.map +0 -1
  147. package/dist/chunk-G2JJ5BO5.js.map +0 -1
  148. package/dist/chunk-J27W6TXS.js.map +0 -1
  149. package/dist/chunk-JCPANDNR.js +0 -35
  150. package/dist/chunk-JCPANDNR.js.map +0 -1
  151. package/dist/chunk-JIERYE6B.js +0 -480
  152. package/dist/chunk-JIERYE6B.js.map +0 -1
  153. package/dist/chunk-JU4ZGJ7A.js +0 -668
  154. package/dist/chunk-JU4ZGJ7A.js.map +0 -1
  155. package/dist/chunk-K5ITEA3I.js.map +0 -1
  156. package/dist/chunk-LT5GXEB2.js.map +0 -1
  157. package/dist/chunk-NKGYKOB7.js.map +0 -1
  158. package/dist/chunk-NQXO4LR3.js.map +0 -1
  159. package/dist/chunk-NTF4UXGK.js.map +0 -1
  160. package/dist/chunk-UITEKY2R.js.map +0 -1
  161. package/dist/chunk-X37UYIE3.js.map +0 -1
  162. package/dist/chunk-X4SSJZLY.js.map +0 -1
  163. package/dist/chunk-XPDVAJDH.js.map +0 -1
  164. package/dist/chunk-XVAQG2CV.js.map +0 -1
  165. package/dist/chunk-ZBPEFQ4G.js +0 -12
  166. package/dist/chunk-ZBPEFQ4G.js.map +0 -1
  167. package/dist/chunk-ZVXGW2IC.js.map +0 -1
  168. package/dist/load-agent-defs-7IM3GBEQ.js +0 -13
  169. package/dist/recompile-project-agents-VR4NLGOU.js +0 -17
  170. /package/dist/{chunk-B6FSLXYN.js.map → chunk-42TNV2TK.js.map} +0 -0
  171. /package/dist/{chunk-Q4IRRVXK.js.map → chunk-57KU6SPH.js.map} +0 -0
  172. /package/dist/{chunk-S63LXWMC.js.map → chunk-5M3PQNXI.js.map} +0 -0
  173. /package/dist/{chunk-XHPWTL4I.js.map → chunk-6SW6SB7H.js.map} +0 -0
  174. /package/dist/{chunk-ARYNOWKF.js.map → chunk-BGU25XAY.js.map} +0 -0
  175. /package/dist/{chunk-YRS3QZP2.js.map → chunk-CEBDGZID.js.map} +0 -0
  176. /package/dist/{chunk-ABAZMMG4.js.map → chunk-CK5RM3DJ.js.map} +0 -0
  177. /package/dist/{chunk-PHCPUQVR.js.map → chunk-CTUJO23Z.js.map} +0 -0
  178. /package/dist/{chunk-QZX7SYKU.js.map → chunk-E6CHHXGY.js.map} +0 -0
  179. /package/dist/{chunk-RGYDFBCT.js.map → chunk-JV4TKXEN.js.map} +0 -0
  180. /package/dist/{chunk-4VL3CEOS.js.map → chunk-LXXGZAD3.js.map} +0 -0
  181. /package/dist/{chunk-URXIQE7I.js.map → chunk-MWDY76MT.js.map} +0 -0
  182. /package/dist/{chunk-V5GLL2JB.js.map → chunk-P3KJCYSR.js.map} +0 -0
  183. /package/dist/{chunk-6MV4JOCL.js.map → chunk-PSX7CT6V.js.map} +0 -0
  184. /package/dist/{chunk-B3Y3QMWI.js.map → chunk-TRTVOVHR.js.map} +0 -0
  185. /package/dist/{chunk-AOTCIUGX.js.map → chunk-TV5Y53R2.js.map} +0 -0
  186. /package/dist/{chunk-XATLUKXK.js.map → chunk-X2KUI7V3.js.map} +0 -0
  187. /package/dist/{chunk-DSL66I4N.js.map → chunk-Y5SNGMB7.js.map} +0 -0
  188. /package/dist/{chunk-7REKOTKG.js.map → chunk-YNOOZFIB.js.map} +0 -0
  189. /package/dist/{load-agent-defs-7IM3GBEQ.js.map → load-agent-defs-JHLE6MAE.js.map} +0 -0
  190. /package/dist/{recompile-project-agents-VR4NLGOU.js.map → recompile-project-agents-ZPP5NOLZ.js.map} +0 -0
  191. /package/dist/{source-loader-GRBVNRAW.js.map → source-loader-RWZAYJ7E.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/lib/exit-codes.ts","../src/cli/lib/seed/external-skills.ts","../../compile/src/carried-skill.ts","../src/cli/base-command.ts","../src/cli/lib/operations/source/ensure-marketplace.ts","../src/cli/lib/operations/source/require-marketplace.ts"],"sourcesContent":["export const EXIT_CODES = {\n SUCCESS: 0,\n ERROR: 1,\n INVALID_ARGS: 2,\n NETWORK_ERROR: 3,\n CANCELLED: 4,\n /**\n * The command ran to the end and part of what it set out to do did not happen.\n *\n * Distinct from {@link EXIT_CODES.ERROR} because the two ask opposite things of whoever reads\n * them: an `ERROR` aborted, so nothing landed and the run can be repeated; this one landed and\n * the repeat is the wrong move — what is owed is the remedy the output names, per failure.\n * Collapsing it into `ERROR` would re-make the defect it exists to close one value along, and\n * a spec asserting `not.toBe(0)` cannot tell a refusal from a partial apply either.\n *\n * It is raised at the END of a command, never mid-flight: the work completes first, which is\n * the whole difference between this and `this.error`.\n */\n COMPLETED_WITH_FAILURES: 5,\n} as const;\n","import os from \"os\";\nimport path from \"path\";\nimport { mkdtemp } from \"fs/promises\";\n\nimport { isDeepEqual, omit } from \"remeda\";\nimport { seedExternalSkillSchema } from \"@workspace/matrix/seed\";\nimport {\n carriedSkillAuthor,\n carriedSkillMetadata,\n withInstalledName,\n} from \"@workspace/compile/carried-skill\";\n\nimport { GITHUB_SOURCE, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../../consts.js\";\nimport { resolveInstallPaths } from \"../installation/install-base-dir.js\";\nimport { parseFrontmatter, readSkillMetadata } from \"../loading/loader.js\";\nimport { getCategoryDomain } from \"../matrix/matrix-provider.js\";\nimport { claimSlug } from \"../matrix/skill-resolution.js\";\nimport { validateSkillPath } from \"../skills/skill-copier.js\";\nimport {\n injectForkedFromMetadata,\n readForkedFromMetadata,\n readLocalSkillMetadata,\n writeMetadataYaml,\n} from \"../skills/skill-metadata.js\";\nimport { defaultUsageGuidance } from \"../stacks/stacks-loader.js\";\nimport { BUILT_IN_MATRIX } from \"../../types/generated/matrix.js\";\nimport { computeFileHash } from \"../versioning.js\";\nimport { copy, directoryExists, glob, readFile, remove, writeFile } from \"../../utils/fs.js\";\nimport { typedEntries, typedKeys } from \"../../utils/typed-object.js\";\n\nimport type { SkillScope } from \"../../types/config.js\";\nimport type { Domain, MergedSkillsMatrix, ResolvedSkill } from \"../../types/matrix.js\";\nimport type { CategoryPath, SkillId, SkillSlug } from \"../../types/skills.js\";\nimport type { ForkedFromMetadata, LocalSkillMetadata } from \"../skills/skill-metadata.js\";\nimport type {\n SeedExternalSkill,\n SeedPayload,\n SeedSkill,\n SeedSkillTree,\n} from \"@workspace/matrix/seed\";\n\n/**\n * One skill the payload carries rather than names, seated and ready to be written.\n *\n * `skillDir` and `domain` are resolved once, where the checks that make them safe already are:\n * the directory has to be the one the catalogue entry points at, because that is what tells the\n * copy step this skill is already where it belongs, and the domain is what the category guard has\n * just proved this catalogue declares.\n */\nexport type ExternalSkillInstall = {\n id: SkillId;\n scope: SkillScope;\n skill: SeedExternalSkill;\n domain: Domain;\n skillDir: string;\n};\n\n/** One external entry with the skill row that selected it — what the payload says about it. */\ntype SelectedExternal = { id: SkillId; skill: SeedExternalSkill; entry: SeedSkill };\n\n/**\n * Names every carried skill a payload asks to install as a plugin, not just the first.\n *\n * There is nothing to install them FROM: the payload is the source, so no marketplace serves\n * these ids. Coercing them to eject would install something the payload did not ask for, under a\n * mode the sharer's own screen still shows as plugin — so the ids are named and the run stops.\n */\nfunction pluginInstallError(ids: SkillId[]): string {\n return [\n \"This configuration cannot be installed: these skills travel inside it, so no marketplace \" +\n \"serves them and they cannot be installed as plugins:\",\n ...ids.map((id) => ` ${id}`),\n \"Re-share it with each skill above set to eject, which is the only way a carried skill installs.\",\n ].join(\"\\n\");\n}\n\n/**\n * The external entries this selection actually names.\n *\n * Presence in `skills` is selection and `external` is only where the bytes are, so content nobody\n * picked installs nothing — seating it would put a skill in the catalogue no part of the\n * configuration asked for.\n */\nfunction selectedExternals(payload: SeedPayload): SelectedExternal[] {\n return typedEntries<SkillId, SeedExternalSkill>(payload.external ?? {}).flatMap(([id, skill]) => {\n const entry = payload.skills[id];\n return entry ? [{ id, skill, entry }] : [];\n });\n}\n\nfunction askedForAsPlugin(externals: SelectedExternal[]): SkillId[] {\n return externals.filter(({ entry }) => entry.install !== \"eject\").map(({ id }) => id);\n}\n\n/**\n * Names every carried skill claiming an id a catalogue already owns, not just the first.\n *\n * A skill id is the directory the skill installs into, so a carried skill taking a catalogue id\n * writes its own bytes where that catalogue's own copy belongs, and the id every sub-agent\n * references afterwards resolves to whatever the payload shipped. Nothing later can tell the two\n * apart either: the local-skill merge inherits an incumbent's `displayName`, `slug` and `category`\n * on the next load, so the impostor renders under the catalogue's own name and placement.\n *\n * **The union of two catalogues, and each half answers what the other cannot.** The LOADED matrix\n * catches the same defect one marketplace along — an external id colliding with a loaded custom\n * marketplace's own ids, which the shipped set has never heard of. The SHIPPED catalogue is the\n * half no payload can move: `sharedConfigSourceFlags` in `commands/init.tsx` passes\n * `payload.marketplace` to the loader, so a payload naming a marketplace that does not ship the id\n * it impersonates meets no incumbent in the loaded matrix at all — which is exactly why\n * `refuseCatalogueCollisions` in `loading/source-loader.ts` reads {@link BUILT_IN_MATRIX} and says\n * so: nothing a source ships is unforgeable, so the consumer's own load has to ask the question\n * again of a set the source cannot choose.\n */\nfunction claimingACatalogueId(\n externals: SelectedExternal[],\n matrix: MergedSkillsMatrix,\n): SkillId[] {\n return externals.filter(({ id }) => heldByEitherCatalogue(id, matrix)).map(({ id }) => id);\n}\n\n/** Every skill id the shipped catalogue owns — the half of the incumbent set a payload cannot move. */\nconst CATALOGUE_SKILL_IDS: ReadonlySet<SkillId> = new Set(typedKeys(BUILT_IN_MATRIX.skills));\n\nfunction heldByEitherCatalogue(id: SkillId, matrix: MergedSkillsMatrix): boolean {\n return heldByLoadedCatalogue(matrix.skills[id]) || CATALOGUE_SKILL_IDS.has(id);\n}\n\n/**\n * Whether the LOADED matrix's entry for an id is one a payload has no right to write over.\n *\n * An incumbent this installation merged off its own disk is not a collision on this axis.\n * `edit --from` applies destructively over an existing install and hands this the source's matrix,\n * which has already had the local-skill merge run over it — so a carried skill a previous apply\n * wrote arrives back here seated and `local`, and refusing it would make a shared configuration\n * installable exactly once. The same carve-out {@link claimSlug} makes for a claim it already\n * holds, on the axis the merge already treats as override-able.\n *\n * `local` is all the matrix can say, and it says less than it looks like: the merge writes that\n * flag on EVERYTHING it finds, so a skill the user wrote by hand wears it too, and a directory\n * carrying no `metadata.yaml` at all never reaches the matrix to be asked. Which directories this\n * installation may actually be written over is therefore settled on disk rather than here — see\n * {@link refuseUncarriedDestinations}.\n */\nfunction heldByLoadedCatalogue(incumbent: ResolvedSkill | undefined): boolean {\n return incumbent !== undefined && incumbent.local !== true;\n}\n\n/**\n * Every colliding id at once, and the fix rather than only the fault.\n *\n * Not truncated, unlike the marketplace refusal's list in `loading/source-loader.ts`: that one\n * reports a whole repository's directory scan, where hundreds of ids can collide at once, while\n * these are the skills one sharer added by hand to one configuration. {@link pluginInstallError}\n * draws from the same set and names all of it, and two refusals over one set disagreeing about\n * that would be an inconsistency with nothing behind it.\n */\nfunction catalogueIdCollisionError(ids: SkillId[]): string {\n return [\n \"This configuration cannot be installed: these skills travel inside it under ids a \" +\n \"catalogue already owns:\",\n ...ids.map((id) => ` ${id}`),\n \"A skill id is the directory the skill installs into, so each would be written over the \" +\n \"catalogue's own copy of that skill. Re-share it with each skill above added again, which \" +\n \"mints an id — 'external-<category>-<name>' — that no catalogue owns.\",\n ].join(\"\\n\");\n}\n\n/**\n * Boundary cast: a carried skill's id is minted at intake and belongs to no generated union,\n * which is exactly what makes it external. It is its own slug too — a skill outside every\n * catalogue has no shorter name anything else would recognise, and the sending side says the same.\n */\nfunction externalSlug(id: SkillId): SkillSlug {\n return id as SkillSlug;\n}\n\n/** The repository ref a carried skill's provenance records, in the form every other ref wears. */\nfunction repoRef(repo: string): string {\n return `${GITHUB_SOURCE.GITHUB_PREFIX}${repo}`;\n}\n\n/** Where a carried skill's directory goes: under the skills directory of the scope it names. */\nfunction externalSkillDir(id: SkillId, scope: SkillScope, projectDir: string): string {\n return path.join(resolveInstallPaths(projectDir, scope).skillsDir, id);\n}\n\n/**\n * The catalogue entry a carried skill becomes on arrival.\n *\n * It declares no relationships and is named by none, which is honest: nothing outside the\n * catalogue can say what this skill conflicts with, and nothing inside it knows the skill exists.\n */\nfunction externalCatalogueEntry(install: ExternalSkillInstall): ResolvedSkill {\n return {\n id: install.id,\n slug: externalSlug(install.id),\n displayName: install.skill.displayName,\n description: install.skill.description,\n // Boundary cast held by the guard above it: the category was confirmed against the catalogue\n // the payload names, and this one has just been shown to declare it too.\n category: install.skill.categoryId as CategoryPath,\n author: carriedSkillAuthor(install.skill.repo),\n path: `${LOCAL_SKILLS_PATH}/${install.id}/`,\n conflictsWith: [],\n requires: [],\n alternatives: [],\n discourages: [],\n // Local and custom for the same reason: the bytes are on this machine and nowhere else, and\n // the skill was authored outside the vocabulary this catalogue ships.\n local: true,\n custom: true,\n localPath: install.skillDir,\n };\n}\n\n/**\n * Seats one carried skill in the catalogue, or leaves it unseated.\n *\n * A skill is PLACED in the taxonomy and never extends it, so a category this catalogue has no\n * definition for belongs to no domain, renders in no tab and reaches no sub-agent. Left unseated,\n * the id falls to the decode's own skip, which reports it by name.\n */\nfunction seatExternalSkill(\n { id, skill, entry }: SelectedExternal,\n matrix: MergedSkillsMatrix,\n projectDir: string,\n): ExternalSkillInstall[] {\n const domain = getCategoryDomain(skill.categoryId);\n if (domain === undefined) return [];\n\n const install: ExternalSkillInstall = {\n id,\n skill,\n domain,\n scope: entry.scope,\n skillDir: externalSkillDir(id, entry.scope, projectDir),\n };\n\n matrix.skills[id] = externalCatalogueEntry(install);\n // Completes the map over the matrix: an entry the slug map does not carry is invisible to\n // anything that addresses a skill by slug.\n claimSlug(matrix.slugMap, externalSlug(id), id);\n\n return [install];\n}\n\n/**\n * Seats the catalogue entries a payload carries, and says where each one's bytes go.\n *\n * Every other id in a payload is resolved against a catalogue the receiver already has, so one it\n * does not know is skipped and reported. A carried skill answers to no catalogue at all — which is\n * why its whole directory travels — so it has to BECOME a catalogue entry before the decode reads\n * the selection, or it is skipped like any other unknown id and the configuration installs\n * quietly smaller than it was shared.\n *\n * The entries are written into `matrix` in place, exactly as the local-skill merge writes the\n * skills it discovers on disk. That matrix is the object `initializeMatrix` seated, which is what\n * {@link getCategoryDomain} reads — every caller passes the loaded source's own.\n *\n * Both refusals are decided before anything is seated, because the seat writes into `matrix` in\n * place: a guard placed after it would stop the run having already replaced entries every later\n * read in this process resolves, and a guard that threw on the first collision it met would have\n * overwritten whatever it seated on the way there.\n *\n * The third refusal is not here. Whether a DIRECTORY may be written over is a question about the\n * disk rather than about the catalogue — see {@link refuseUncarriedDestinations}.\n *\n * @throws {Error} If any carried skill asks to be installed as a plugin — see\n * {@link pluginInstallError} — or claims an id either catalogue already owns, see\n * {@link catalogueIdCollisionError}.\n */\nexport function registerExternalSkills(\n payload: SeedPayload,\n matrix: MergedSkillsMatrix,\n projectDir: string,\n): ExternalSkillInstall[] {\n const externals = selectedExternals(payload);\n const asPlugin = askedForAsPlugin(externals);\n const colliding = claimingACatalogueId(externals, matrix);\n\n if (asPlugin.length > 0) throw new Error(pluginInstallError(asPlugin));\n if (colliding.length > 0) throw new Error(catalogueIdCollisionError(colliding));\n\n return externals.flatMap((external) => seatExternalSkill(external, matrix, projectDir));\n}\n\n/**\n * Writes each carried skill's directory where its own entry said, and registers it on disk.\n *\n * Three things have to be true afterwards, and each is a separate act: the files are there, the\n * skill answers to the id the configuration recorded, and a metadata.yaml describes it well\n * enough for the next `edit`, `compile` or `list` to find it again. The seat above lasts one run;\n * this is what makes the install survive.\n *\n * Its callers have already asked {@link refuseUncarriedDestinations}, before they listed the\n * install or asked about it; it is asked again here because the question was put to a person,\n * and a directory written while they read it is no less theirs.\n *\n * Answers with the ids whose directories now read differently: a re-applied skill whose bytes\n * changed is a change the configuration's own entries cannot show.\n *\n * @throws {Error} If any destination is a directory this installation did not receive inside a\n * shared configuration — see {@link refuseUncarriedDestinations}.\n */\nexport async function writeExternalSkills(installs: ExternalSkillInstall[]): Promise<SkillId[]> {\n await refuseUncarriedDestinations(installs);\n\n const written = await Promise.all(installs.map(writeExternalSkill));\n return changedIds(written);\n}\n\nconst SCRATCH_DIR_PREFIX = \"agents-inc-carried-\";\n\n/**\n * The carried skills whose installed copy {@link writeExternalSkills} would change, asked of a\n * scratch copy of each directory so nothing installed is touched.\n *\n * For a run that may not write them: from a project, a carried skill the global install already\n * holds stays as that install holds it, and a revision that does not arrive is named rather than\n * dropped in silence. The comparison is the write's own, so \"would change\" and \"changed\" are one\n * definition.\n */\nexport async function carriedSkillsThatDiffer(\n installs: ExternalSkillInstall[],\n): Promise<SkillId[]> {\n if (installs.length === 0) return [];\n\n const scratch = await mkdtemp(path.join(os.tmpdir(), SCRATCH_DIR_PREFIX));\n try {\n const written = await Promise.all(\n installs.map(async (install) => writeExternalSkill(await scratchCopyOf(install, scratch))),\n );\n return changedIds(written);\n } finally {\n await remove(scratch);\n }\n}\n\n/** The install, pointed at a copy of its directory under `scratch` — taken now, if there is one. */\nasync function scratchCopyOf(\n install: ExternalSkillInstall,\n scratch: string,\n): Promise<ExternalSkillInstall> {\n const skillDir = path.join(scratch, install.id);\n if (await directoryExists(install.skillDir)) await copy(install.skillDir, skillDir);\n return { ...install, skillDir };\n}\n\n/** One carried skill as written, and whether its directory now reads differently. */\ntype WrittenSkill = { id: SkillId; changed: boolean };\n\n/** The skills whose directories now read differently. */\nfunction changedIds(written: WrittenSkill[]): SkillId[] {\n return written.filter(({ changed }) => changed).map(({ id }) => id);\n}\n\nasync function writeExternalSkill(install: ExternalSkillInstall): Promise<WrittenSkill> {\n const before = await readSkillDir(install.skillDir);\n\n await writeSkillTree(install);\n await writeSkillManifest(install);\n await registerSkillOnDisk(install);\n\n return { id: install.id, changed: !isDeepEqual(before, await readSkillDir(install.skillDir)) };\n}\n\n/** A skill directory as a load reads it: its files, and its metadata as data. */\ntype SkillDirReading = { files: SeedSkillTree; metadata: Record<string, unknown> | null };\n\n/**\n * What a load reads out of one skill directory, or nothing where there is none — less the day\n * `forkedFrom` was stamped, which every write moves whether or not anything else did. The metadata\n * is read as data because the stamp's place in the file differs between a first write and a\n * second (see `withForkedFrom` in `@workspace/compile/carried-skill`).\n */\nasync function readSkillDir(skillDir: string): Promise<SkillDirReading | null> {\n if (!(await directoryExists(skillDir))) return null;\n\n const files = omit(await readSkillTree(skillDir), [STANDARD_FILES.METADATA_YAML]);\n return { files, metadata: undated(await readLocalSkillMetadata(skillDir)) };\n}\n\nfunction undated(metadata: LocalSkillMetadata | null): Record<string, unknown> | null {\n if (metadata?.forkedFrom === undefined) return metadata;\n return { ...metadata, forkedFrom: omit(metadata.forkedFrom, [\"date\"]) };\n}\n\n/** One destination a carried skill's bytes may not be written to, and what stands there. */\ntype BlockedDestination = { id: SkillId; skillDir: string };\n\n/**\n * Refuses the run when any destination already holds content no shared configuration carried.\n *\n * **This is the disk half of the collision question, and the matrix cannot answer it.**\n * {@link heldByLoadedCatalogue} carves out every `local` incumbent so a re-apply works, and the\n * local-skill merge writes `local` on everything it merges — so that carve-out also exempts a\n * skill the user wrote by hand and a marketplace skill ejected here, neither of which is the\n * round trip's to replace. Worse, a directory with no readable `metadata.yaml` never reaches the\n * matrix at all, so no in-memory guard, with or without a provenance field on `ResolvedSkill`,\n * could ever see it. The bytes are the subject, so the bytes are what is asked.\n *\n * `forkedFrom.path` is the discriminator, not `forkedFrom` itself: {@link registerSkillOnDisk} is\n * the only writer of that field — `copySkillTo` deliberately omits it, because a marketplace skill\n * is installed again by its id — and {@link readCarriedSkill} reads it for this exact question one\n * layer up. So a directory that names the repository directory its bytes came from is one a\n * shared configuration put here, and everything else is somebody else's.\n *\n * Every destination is judged before any is written, for the same reason the two refusals in\n * {@link registerExternalSkills} are decided before anything is seated: a guard that threw on the\n * first blocked destination it met would have overwritten whatever it wrote on the way there.\n *\n * Exported for the `--from` producers, which ask it before they list what they would install or\n * ask whether to: a refusal that came after the question would ask a person to confirm an\n * install that was never going to happen.\n */\nexport async function refuseUncarriedDestinations(installs: ExternalSkillInstall[]): Promise<void> {\n const judged = await Promise.all(installs.map(judgeDestination));\n const blocked = judged.filter((destination) => destination !== null);\n\n if (blocked.length > 0) throw new Error(uncarriedDestinationError(blocked));\n}\n\n/** One destination: the row a refusal would name, or nothing standing there to protect. */\nasync function judgeDestination(install: ExternalSkillInstall): Promise<BlockedDestination | null> {\n const { id, skillDir } = install;\n if (!(await directoryExists(skillDir))) return null;\n if ((await readForkedFromMetadata(skillDir))?.path !== undefined) return null;\n return { id, skillDir };\n}\n\n/**\n * Every blocked destination at once, with the directory beside the id.\n *\n * The path is what makes this actionable and is what the collision message above cannot say: the\n * fix is the RECEIVER's rather than the sharer's, because the directory is theirs — so the message\n * has to name a path they can move, and a user must be able to copy any line of it and `cd` into\n * it. Both ways out are offered, because only the user knows whose skill matters more.\n */\nfunction uncarriedDestinationError(blocked: BlockedDestination[]): string {\n return [\n \"This configuration cannot be installed: these skills travel inside it under ids this \" +\n \"installation already keeps a skill directory for, and no shared configuration put those \" +\n \"directories there:\",\n ...blocked.map(({ id, skillDir }) => ` ${id} -> ${skillDir}`),\n \"A skill id is the directory the skill installs into, so each would be written over a skill \" +\n \"written here by hand or ejected from a marketplace. Move or rename the directory above, \" +\n \"or re-share the configuration with each skill added again, which mints an id — \" +\n \"'external-<category>-<name>' — that nothing here holds.\",\n ].join(\"\\n\");\n}\n\n/**\n * The directory as the payload holds it, keys and all.\n *\n * The keys came off the wire, so a payload may ask for any path it likes — including one that\n * climbs out of the skill's own directory. They answer to the same guard a marketplace's own\n * paths do.\n */\nasync function writeSkillTree(install: ExternalSkillInstall): Promise<void> {\n for (const [relativePath, contents] of Object.entries(install.skill.files)) {\n const filePath = path.join(install.skillDir, relativePath);\n validateSkillPath(filePath, install.skillDir, relativePath);\n await writeFile(filePath, contents);\n }\n}\n\nasync function writeSkillManifest(install: ExternalSkillInstall): Promise<void> {\n const manifestPath = path.join(install.skillDir, STANDARD_FILES.SKILL_MD);\n await writeFile(\n manifestPath,\n withInstalledName(await readFile(manifestPath), {\n id: install.id,\n description: install.skill.description,\n }),\n );\n}\n\n/**\n * Registers the skill on disk, where the next command will look for it.\n *\n * `forkedFrom` is stamped through the one writer that stamps it, because it is the package's\n * single answer to \"did the CLI put this directory here?\" — `uninstall` reads it to decide what it\n * may delete, and the producer reads it to decide what the round trip owns. A carried skill IS the\n * round trip's; a skill the user wrote by hand is not, and carries nothing.\n *\n * The repository AND the directory inside it, because this is the only record of where these bytes\n * came from. Sharing this installation has to rebuild the entry the payload carried, and a\n * repository alone cannot say which of its directories travelled — see {@link readCarriedSkills}.\n */\nasync function registerSkillOnDisk(install: ExternalSkillInstall): Promise<void> {\n const metadataPath = path.join(install.skillDir, STANDARD_FILES.METADATA_YAML);\n const shipped = await readLocalSkillMetadata(install.skillDir);\n\n await writeMetadataYaml(\n metadataPath,\n carriedSkillMetadata({\n id: install.id,\n skill: install.skill,\n domain: install.domain,\n usageGuidance: defaultUsageGuidance(install.skill.categoryId),\n shipped,\n }),\n );\n await injectForkedFromMetadata(\n install.skillDir,\n install.id,\n await computeFileHash(path.join(install.skillDir, STANDARD_FILES.SKILL_MD)),\n { source: repoRef(install.skill.repo), path: install.skill.path },\n );\n}\n\n/**\n * One installed skill directory the round trip owns, and what its install recorded about it.\n *\n * Read by the caller rather than here: whether a directory is the CLI's copy or the user's own\n * work is a question about ownership, which `installation-payload.ts` already asks of every entry\n * before anything else. This module answers only the next one — whether the bytes have to travel.\n */\nexport type OwnedSkillDir = { id: string; skillDir: string; provenance: ForkedFromMetadata };\n\n/**\n * What one installation carries rather than names.\n *\n * The same shape the mapper's other readings wear: what can travel, and the lines naming what\n * cannot. Both halves matter — a payload quietly missing content it could not read still mints an\n * id, and that id installs a configuration nobody chose.\n */\nexport type ContentReading = {\n /** Skill id -> the entry a receiver seats it from. Keyed exactly as the wire keys `external`. */\n external: Record<string, SeedExternalSkill>;\n /** One line per skill whose content this installation cannot carry, for the refusal. */\n uncarryable: string[];\n};\n\n/** What one owned directory turns out to carry: content, a reason it cannot, or nothing. */\ntype CarriedRead =\n | { carries: \"content\"; id: string; skill: SeedExternalSkill }\n | { carries: \"nothing\" }\n | { carries: \"unshareable\"; line: string };\n\nfunction unnameableRepoMessage(id: string): string {\n return `${id} travels inside a shared configuration, and this installation does not record the repository its content came from`;\n}\n\nfunction uncarryableContentMessage(id: string, reason: string): string {\n return `${id} travels inside a shared configuration, and ${reason}`;\n}\n\n/**\n * The inverse of {@link repoRef}: the repository a ref names, or nothing when it names none this\n * contract can state.\n *\n * Provenance is written as a ref because that is the form every other source in a configuration\n * wears; the wire wants GitHub's own `owner/name`. Any other ref is a repository this contract has\n * no word for, which is a refusal rather than something to guess at.\n */\nfunction repoFromRef(ref: string | undefined): string | undefined {\n if (ref === undefined || !ref.startsWith(GITHUB_SOURCE.GITHUB_PREFIX)) return undefined;\n return ref.slice(GITHUB_SOURCE.GITHUB_PREFIX.length);\n}\n\nconst NO_MANIFEST_DESCRIPTION = `no description can be read from its ${STANDARD_FILES.SKILL_MD}`;\n\n/** The description the skill's own SKILL.md states, or null where none can be read from it. */\nfunction manifestDescription(files: SeedSkillTree, skillDir: string): string | null {\n const manifest = files[STANDARD_FILES.SKILL_MD];\n if (manifest === undefined) return null;\n\n const frontmatter = parseFrontmatter(manifest, path.join(skillDir, STANDARD_FILES.SKILL_MD));\n return frontmatter === null ? null : frontmatter.description;\n}\n\n/** Every file under the skill, keyed by its path relative to it — dotfiles and nesting included. */\nasync function readSkillTree(skillDir: string): Promise<SeedSkillTree> {\n const files = await glob(\"**/*\", skillDir, { dot: true });\n const entries = await Promise.all(\n files.map(async (file) => [file, await readFile(path.join(skillDir, file))] as const),\n );\n return Object.fromEntries(entries);\n}\n\n/**\n * Rebuilds the entry a carried skill arrived as, from the directory the install wrote.\n *\n * The bytes as they stand rather than as they arrived: the manifest was renamed to the id this\n * install recorded, and a user may have edited the skill since. Both are what is installed here,\n * and what is installed here is what a share carries.\n *\n * The description is the manifest's own. The `cliDescription` beside it is the wizard's label,\n * cut to the length `doctor` accepts, so a re-share sending it would shorten the skill once per\n * round trip.\n *\n * Validated against the contract's own schema rather than by rules restated here — that is what\n * makes the weight limit and every field's shape one definition rather than two that can drift.\n */\nasync function readCarriedSkill({ id, skillDir, provenance }: OwnedSkillDir): Promise<CarriedRead> {\n // The directory is what marks a skill as one no catalogue can resolve. Without it there is a\n // catalogue behind this id, so the receiver installs it from there and the bytes stay home.\n if (provenance.path === undefined) return { carries: \"nothing\" };\n\n const repo = repoFromRef(provenance.source);\n if (repo === undefined) return { carries: \"unshareable\", line: unnameableRepoMessage(id) };\n\n const described = await readSkillMetadata(path.join(skillDir, STANDARD_FILES.METADATA_YAML));\n if (!described.usable) {\n return { carries: \"unshareable\", line: uncarryableContentMessage(id, described.reason) };\n }\n\n const files = await readSkillTree(skillDir);\n const description = manifestDescription(files, skillDir);\n if (description === null) {\n return { carries: \"unshareable\", line: uncarryableContentMessage(id, NO_MANIFEST_DESCRIPTION) };\n }\n\n const parsed = seedExternalSkillSchema.safeParse({\n displayName: described.metadata.displayName,\n description,\n categoryId: described.metadata.category,\n repo,\n path: provenance.path,\n files,\n });\n if (!parsed.success) {\n const reason = parsed.error.issues.map((issue) => issue.message).join(\"; \");\n return { carries: \"unshareable\", line: uncarryableContentMessage(id, reason) };\n }\n\n return { carries: \"content\", id, skill: parsed.data };\n}\n\n/**\n * What a set of owned skill directories carries, and what it cannot.\n *\n * The mirror of {@link registerExternalSkills}: that seats an entry a payload carried and writes\n * its bytes, this reads those bytes back into the entry a payload carries. Every other id in a\n * configuration is resolved by the receiver against a catalogue it already has, so its content has\n * nothing to add; an added skill answers to no catalogue in either direction, and a share that\n * named it without carrying it would mint an id that installs a configuration missing it.\n */\nexport async function readCarriedSkills(owned: OwnedSkillDir[]): Promise<ContentReading> {\n const reads = await Promise.all(owned.map(readCarriedSkill));\n\n return {\n external: Object.fromEntries(\n reads.flatMap((read) => (read.carries === \"content\" ? [[read.id, read.skill]] : [])),\n ),\n uncarryable: reads.flatMap((read) => (read.carries === \"unshareable\" ? [read.line] : [])),\n };\n}\n","import { parse as parseYaml, stringify as stringifyYaml } from \"yaml\"\n\nimport { GITHUB_PREFIX, STANDARD_FILES } from \"./paths.js\"\n\nimport type { SeedExternalSkill, SeedSkillTree } from \"@workspace/matrix\"\n\n/**\n * WHAT AN INSTALL DOES TO A SKILL A CONFIGURATION CARRIES rather than names —\n * one added in the editor, whose whole directory travels inside the payload —\n * on its way to disk.\n *\n * The CLI's `seed/external-skills.ts` writes with {@link withInstalledName} and\n * {@link carriedSkillMetadata}. The editor's output preview draws the whole\n * directory with {@link installedSkillTree}, which composes those two with the\n * half the CLI keeps because it needs a disk — reading the shipped\n * `metadata.yaml` back, and stamping `forkedFrom` through\n * `injectForkedFromMetadata` — and the CLI's `external-skills.test.ts` holds\n * that composition against a real install, byte for byte.\n */\n\n/** The frontmatter block at the head of a SKILL.md, and the `name` field inside it. */\nconst FRONTMATTER_BLOCK = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---/\nconst NAME_FIELD = /^name:.*$/m\n\n/** The id a carried skill installs under, and the sentence the payload describes it with. */\nexport type InstalledSkillIdentity = { id: string; description: string }\n\n/**\n * Names the skill by the id it installs under.\n *\n * Every loader reads a skill's id off this one field, and a compiled sub-agent references the id\n * the configuration recorded — the one minted at intake, which is also this directory's name. The\n * repository the skill came from knew about neither, so left as it was written the two never\n * meet: the sub-agent names a skill Claude Code knows as something else, and the next load\n * registers an id no configuration carries.\n *\n * Only the name. Everything else in the block is the author's and travels untouched.\n */\nexport function withInstalledName(\n manifest: string,\n { id, description }: InstalledSkillIdentity\n): string {\n const named = `name: ${id}`\n const block = FRONTMATTER_BLOCK.exec(manifest)\n\n // A manifest with no frontmatter at all describes no skill to Claude Code either. The payload\n // carries both fields one needs, so it is given one rather than installed unreadable.\n if (!block) {\n return `---\\n${named}\\ndescription: ${description}\\n---\\n\\n${manifest}`\n }\n\n const [whole, fields = \"\"] = block\n const renamed = NAME_FIELD.test(fields)\n ? fields.replace(NAME_FIELD, named)\n : `${named}\\n${fields}`\n\n // The block is anchored at the head of the file, so what follows it is the rest verbatim.\n return `---\\n${renamed}\\n---${manifest.slice(whole.length)}`\n}\n\n/** The repository's owner as a handle, which is all the authorship a carried skill records. */\nexport function carriedSkillAuthor(repo: string): string {\n const [owner = repo] = repo.split(\"/\")\n return `@${owner}`\n}\n\n/** Where a carried skill was placed, and what its `metadata.yaml` falls back to. */\nexport type CarriedSkillPlacement = {\n id: string\n skill: Pick<\n SeedExternalSkill,\n \"displayName\" | \"description\" | \"categoryId\" | \"repo\"\n >\n /** The domain the receiving catalogue files the skill's category under. */\n domain: string\n /**\n * The usage line a skill stating none is given — the caller's own call rather than a sentence\n * spelled here, because the CLI's stack loader owns that sentence (`defaultUsageGuidance`) and a\n * second spelling of it drifted once already.\n */\n usageGuidance: string\n /** The `metadata.yaml` the repository shipped beside the skill, as the CLI reads it back. */\n shipped: Readonly<Record<string, unknown>> | null\n}\n\n/**\n * What the payload confirmed, over what the repository shipped, over what neither says.\n *\n * The order is the whole of it. The taxonomy is the placement the user chose against the\n * catalogue this configuration names, and the repository's own idea of where its skill belongs\n * answers to a taxonomy nobody here shares — so that is written over the file. Everything else\n * the repository wrote is kept, because its author knows more about their skill than a default\n * does.\n *\n * The defaults underneath exist because `doctor` validates every installed metadata.yaml, and a\n * file the install writes that that command reports as an error is the CLI disagreeing with\n * itself — in a file the user cannot fix, since the skill is somebody else's repository. Neither\n * is invented: the authorship is the repository's owner, and the usage line is the one the\n * caller's stack loader gives every skill reference it has nothing more specific for. The label is\n * shortened to the length that command accepts for the same reason.\n */\nexport function carriedSkillMetadata({\n id,\n skill,\n domain,\n usageGuidance,\n shipped,\n}: CarriedSkillPlacement): Record<string, unknown> {\n return {\n author: carriedSkillAuthor(skill.repo),\n usageGuidance,\n ...shipped,\n displayName: skill.displayName,\n slug: id,\n category: skill.categoryId,\n domain,\n cliDescription: shortLabel(skill.description),\n custom: true,\n }\n}\n\n/**\n * `CLI_DESCRIPTION_MAX_LENGTH` in the CLI's `schemas.ts`: the longest `cliDescription` its `doctor`\n * accepts without a warning.\n */\nconst CLI_DESCRIPTION_MAX_LENGTH = 60\n\nconst ELLIPSIS = \"…\"\n\n/**\n * The description as the wizard's short label: whole where it fits the length `doctor` accepts,\n * otherwise cut at the last word that fits and marked as cut. A sub-agent is compiled from the\n * SKILL.md's own description, so nothing it reads is shortened.\n */\nfunction shortLabel(description: string): string {\n if (description.length <= CLI_DESCRIPTION_MAX_LENGTH) return description\n\n const room = description.slice(0, CLI_DESCRIPTION_MAX_LENGTH - ELLIPSIS.length)\n return `${toLastWholeWord(room)}${ELLIPSIS}`\n}\n\n/** The text up to its last whole word — all of it, where it holds no break. */\nfunction toLastWholeWord(text: string): string {\n const lastBreak = text.lastIndexOf(\" \")\n return (lastBreak > 0 ? text.slice(0, lastBreak) : text).trimEnd()\n}\n\n/** One carried skill as {@link installedSkillTree} needs it: its whole directory, and the day. */\nexport type CarriedSkillInstall = Omit<\n CarriedSkillPlacement,\n \"shipped\" | \"skill\"\n> & {\n skill: SeedExternalSkill\n /** The day the install ran, which only the machine running it knows. */\n date: string\n}\n\n/**\n * The directory a carried skill's install leaves, keyed as the payload keys it.\n *\n * Every file the payload carries, with the SKILL.md renamed by {@link withInstalledName} and a\n * `metadata.yaml` written beside it — over the one the repository shipped, when it shipped one.\n */\nexport async function installedSkillTree(\n install: CarriedSkillInstall\n): Promise<SeedSkillTree> {\n const manifest = withInstalledName(manifestOf(install.skill.files), {\n id: install.id,\n description: install.skill.description,\n })\n\n return {\n ...install.skill.files,\n [STANDARD_FILES.SKILL_MD]: manifest,\n [STANDARD_FILES.METADATA_YAML]: await metadataYaml(install, manifest),\n }\n}\n\n/**\n * The line `injectForkedFromMetadata` writes above the file:\n * `yamlSchemaComment(SCHEMA_PATHS.metadata)` in the CLI's `consts.ts`.\n */\nconst METADATA_SCHEMA_COMMENT =\n \"# yaml-language-server: $schema=https://raw.githubusercontent.com/agents-inc/agents-inc/main/packages/cli/src/schemas/metadata.schema.json\"\n\n/** `YAML_FORMATTING.LINE_WIDTH_NONE`: the CLI folds no line of a metadata file. */\nconst NO_LINE_FOLDING = 0\n\n/**\n * `registerSkillOnDisk`'s two writes as the bytes they leave: the shared metadata, then the\n * provenance `injectForkedFromMetadata` stamps over it.\n */\nasync function metadataYaml(\n install: CarriedSkillInstall,\n manifest: string\n): Promise<string> {\n const metadata = carriedSkillMetadata({\n ...install,\n shipped: shippedMetadata(install.skill.files),\n })\n const stamp = await provenanceStamp(install, manifest)\n\n return asMetadataFile(withForkedFrom(metadata, stamp))\n}\n\n/**\n * What `injectForkedFromMetadata` records about where the bytes came from: the id they install\n * under, the hash of the manifest as installed, the day, and the repository directory — the only\n * address a carried skill has.\n */\nasync function provenanceStamp(\n install: CarriedSkillInstall,\n manifest: string\n): Promise<Record<string, string>> {\n return {\n skillId: install.id,\n contentHash: await contentHashOf(manifest),\n date: install.date,\n source: `${GITHUB_PREFIX}${install.skill.repo}`,\n path: install.skill.path,\n }\n}\n\n/** The bytes `writeMetadataYaml` leaves for a mapping, under the schema comment. */\nconst asMetadataFile = (metadata: Record<string, unknown>): string =>\n `${METADATA_SCHEMA_COMMENT}\\n${stringifyYaml(metadata, {\n lineWidth: NO_LINE_FOLDING,\n })}`\n\n/**\n * The stamp, where `injectForkedFromMetadata` puts it. It reads the file back through\n * `localSkillMetadataSchema` first, and that schema's one declared key comes out of a parse ahead\n * of every passed-through one: a repository that shipped its own `forkedFrom` has the stamp at the\n * top of the file, and one that did not has it last.\n */\nfunction withForkedFrom(\n metadata: Record<string, unknown>,\n forkedFrom: Record<string, string>\n): Record<string, unknown> {\n if (!Object.hasOwn(metadata, \"forkedFrom\")) return { ...metadata, forkedFrom }\n\n const { forkedFrom: _shipped, ...rest } = metadata\n return { forkedFrom, ...rest }\n}\n\n/**\n * The `metadata.yaml` the repository shipped, read the way `readLocalSkillMetadata` reads it: a\n * file no parser can read, one that is not a mapping, or one whose `forkedFrom` block\n * `localSkillMetadataSchema` refuses, is no metadata at all.\n */\nfunction shippedMetadata(files: SeedSkillTree): Record<string, unknown> | null {\n const shipped = files[STANDARD_FILES.METADATA_YAML]\n if (shipped === undefined) return null\n\n const parsed = parsedYaml(shipped)\n return isMapping(parsed) && hasReadableProvenance(parsed) ? parsed : null\n}\n\nfunction parsedYaml(text: string): unknown {\n try {\n return parseYaml(text)\n } catch {\n // The CLI warns and reads no metadata; there is nobody here to warn.\n return undefined\n }\n}\n\nconst isMapping = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n\n/** The `forkedFrom` fields `localSkillMetadataSchema` requires, and the ones it allows. */\nconst PROVENANCE_REQUIRED = [\"skillId\", \"contentHash\", \"date\"] as const\nconst PROVENANCE_OPTIONAL = [\"source\", \"path\"] as const\n\n/** No `forkedFrom` at all, or one whose every field is a string the schema names. */\nfunction hasReadableProvenance(metadata: Record<string, unknown>): boolean {\n if (!Object.hasOwn(metadata, \"forkedFrom\")) return true\n\n const provenance = metadata.forkedFrom\n return (\n isMapping(provenance) &&\n PROVENANCE_REQUIRED.every((key) => typeof provenance[key] === \"string\") &&\n PROVENANCE_OPTIONAL.every(\n (key) =>\n !Object.hasOwn(provenance, key) || typeof provenance[key] === \"string\"\n )\n )\n}\n\n/** The `SKILL.md` a carried skill's directory holds, which the seed contract refuses one without. */\nfunction manifestOf(files: SeedSkillTree): string {\n const manifest = files[STANDARD_FILES.SKILL_MD]\n if (manifest === undefined) {\n throw new Error(\n `A carried skill's directory holds no ${STANDARD_FILES.SKILL_MD}, which seedSkillTreeSchema refuses`\n )\n }\n return manifest\n}\n\n/** `HASH_PREFIX_LENGTH`: how much of the digest the CLI's `computeStringHash` keeps. */\nconst CONTENT_HASH_LENGTH = 7\n\n/**\n * `computeStringHash` over the installed SKILL.md, which is what `computeFileHash` reads back — the\n * leading hex digits of its SHA-256. Web Crypto rather than `node:crypto`, because this package\n * runs in a browser.\n */\nasync function contentHashOf(text: string): Promise<string> {\n const digest = await crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(text)\n )\n return hexOf(new Uint8Array(digest)).slice(0, CONTENT_HASH_LENGTH)\n}\n\nconst hexOf = (bytes: Uint8Array): string =>\n Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")\n","import { Command } from \"@oclif/core\";\n\nimport chalk from \"chalk\";\nimport { unique } from \"remeda\";\n\nimport { CLI_COLORS, DEFAULT_BRANDING, MIN_TERMINAL_SIZE } from \"./consts.js\";\nimport { getErrorMessage } from \"./utils/errors.js\";\nimport { verbose, warn } from \"./utils/logger.js\";\nimport {\n completedWithFailures,\n installationConfigsUnreadable,\n rivalSourceFoldersRefuseWrites,\n type IncompleteWork,\n pluginsInstalled,\n propagatedRecompileSummary,\n registeredProjectConfigUnreadable,\n registeredProjectGone,\n registeredProjectOnAnotherProvider,\n savedSkillMetadataUnusableError,\n scopeBlockedStackAssignment,\n sharedConfigProjectScopeAtHome,\n skillAssignedToNoAgent,\n skillMetadataUnusableDetail,\n STATUS_MESSAGES,\n WRITE_REFUSED_RIVAL_SOURCE_FOLDERS,\n} from \"./utils/messages.js\";\nimport {\n clearTerminalScreen,\n formatTerminalTooSmallMessage,\n isTerminalLargeEnough,\n} from \"./utils/terminal.js\";\nimport { EXIT_CODES } from \"./lib/exit-codes.js\";\nimport { isActiveAt } from \"./lib/configuration/scope-predicates.js\";\nimport { resolveBranding } from \"./lib/configuration/config.js\";\nimport { isHomeDirectory, refuseUnofferedStack } from \"./lib/installation/index.js\";\nimport {\n folderBeingRead,\n sourceScopesInPlay,\n type SourceScope,\n} from \"./lib/installation/source-scopes.js\";\nimport type { WizardResultV2 } from \"./components/wizard/wizard.js\";\nimport { getStackSkillIds } from \"./lib/stacks/index.js\";\nimport type {\n AgentName,\n MergedSkillsMatrix,\n ProjectConfig,\n SelectionValidation,\n SkillConfig,\n SkillId,\n} from \"./types/index.js\";\nimport { findConfigLoadFailures } from \"./lib/configuration/project-config.js\";\nimport { findUnusableSavedSkillMetadata } from \"./lib/skills/index.js\";\nimport type { PluginHost } from \"./lib/hosts/plugin-host.js\";\nimport { hostAt } from \"./lib/hosts/host-for.js\";\nimport { refuseUnofferedPlacements } from \"./lib/hosts/offered-placements.js\";\nimport {\n refuseUncarriedDestinations,\n type ExternalSkillInstall,\n} from \"./lib/seed/external-skills.js\";\nimport { refuseUnwritableStack } from \"@workspace/compile/config-source\";\nimport { requireMarketplace } from \"./lib/operations/source/require-marketplace.js\";\nimport {\n installPluginSkills,\n pluginInstallFailureError,\n unbackedPluginInstallError,\n unbackedPluginSkillIds,\n type PluginInstallResult,\n} from \"./lib/operations/skills/install-plugin-skills.js\";\nimport type { GateReport } from \"./lib/config-gate/index.js\";\nimport type { SourceLoadResult } from \"./lib/loading/source-loader.js\";\n\n/**\n * How often the size gate re-reads the terminal while it is blocked. `resize` is what normally\n * ends the wait; the poll is the belt for the terminals and multiplexers that resize without\n * ever emitting one, and it is the only reason a blocked command is not a hung one there.\n */\nconst TERMINAL_RESIZE_POLL_MS = 500;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- @types/node declares this as `number`; it is undefined whenever stdout is not a TTY\nconst terminalColumns = (): number => process.stdout.columns ?? MIN_TERMINAL_SIZE.COLS;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- @types/node declares this as `number`; it is undefined whenever stdout is not a TTY\nconst terminalRows = (): number => process.stdout.rows ?? MIN_TERMINAL_SIZE.ROWS;\n\nfunction isTerminalBigEnough(): boolean {\n return isTerminalLargeEnough(terminalColumns(), terminalRows());\n}\n\n/**\n * Resolves the moment the terminal satisfies `isSatisfied` — on the resize event where there is\n * one, on the poll where there is not. Both listeners are torn down before resolving, so a\n * command that got past the gate leaves nothing behind holding the process open.\n */\nfunction waitForTerminal(isSatisfied: () => boolean): Promise<void> {\n return new Promise<void>((resolve) => {\n const check = () => {\n if (!isSatisfied()) return;\n clearInterval(interval);\n process.stdout.off(\"resize\", check);\n resolve();\n };\n const interval = setInterval(check, TERMINAL_RESIZE_POLL_MS);\n process.stdout.on(\"resize\", check);\n });\n}\n\n/** A selected skill no sub-agent's stack carries, and the sub-agents the scope rule blocked. */\ntype UnassignedSkill = { skillId: SkillId; blockedBy: AgentName[] };\n\n/**\n * Every active skill this save selected that no agent's stack in the saved config references,\n * paired with the global-scoped sub-agents that could not have carried it.\n *\n * Only the selection is judged. A project's saved config also lists the global skills it\n * inherits, while the stack a shared configuration brings names only the sub-agents it carries —\n * a global sub-agent's rows stay in the global config — so an inherited skill is missing from\n * this stack without being unassigned.\n *\n * `blockedBy` is empty for a global-scoped skill: the scope rule had no say there, and the\n * skill reached nothing for a different reason (no selected sub-agent the resolver\n * considers it relevant to). Naming sub-agents there would blame the wrong rule.\n */\nfunction findUnassignedSkills(\n config: ProjectConfig,\n selected: readonly SkillConfig[],\n): UnassignedSkill[] {\n const assignedIds = new Set(config.stack ? getStackSkillIds(config.stack) : []);\n const selectedIds = new Set(selected.map((skill) => skill.id));\n const globalAgentNames = config.agents\n .filter((agent) => isActiveAt(agent, \"global\"))\n .map((agent) => agent.name);\n\n const unassignedIds = unique(\n config.skills\n .filter((skill) => !skill.excluded && selectedIds.has(skill.id))\n .map((skill) => skill.id)\n .filter((skillId) => !assignedIds.has(skillId)),\n );\n\n return unassignedIds.map((skillId) => ({\n skillId,\n blockedBy: hasActiveProjectEntry(config.skills, skillId) ? globalAgentNames : [],\n }));\n}\n\n/** True when an ACTIVE entry for this id sits at project scope — the only case the rule explains. */\nfunction hasActiveProjectEntry(skills: readonly SkillConfig[], skillId: SkillId): boolean {\n return skills.some((skill) => skill.id === skillId && isActiveAt(skill, \"project\"));\n}\n\n/**\n * What a decoded selection would file at PROJECT scope, split by kind because a skill's scope\n * and a sub-agent's are independent decisions in a payload — a refusal naming only one kind\n * would send the sharer to change the wrong entry.\n */\nfunction projectScopedContent(result: WizardResultV2): {\n skillIds: SkillId[];\n agentNames: AgentName[];\n} {\n return {\n skillIds: result.skills\n .filter((skill) => isActiveAt(skill, \"project\"))\n .map((skill) => skill.id),\n agentNames: result.agentConfigs\n .filter((agent) => isActiveAt(agent, \"project\"))\n .map((agent) => agent.name),\n };\n}\n\n/**\n * Nothing is inherited by every command, so this class declares no `baseFlags`.\n *\n * There was one — the marketplace flag — until naming a marketplace became `init`'s\n * decision alone (owner ruling 2026-08-09). Six commands were already opting out of it\n * through an exported empty-object cast; a flag one command wants is that command's flag,\n * so it is declared in `init` as `--marketplace` and the six opt-outs went with it.\n */\nexport abstract class BaseCommand extends Command {\n /**\n * Everything this run set out to do and did not, in the order it hit them.\n *\n * Non-empty is the whole of the exit-code decision — see {@link exitIfWorkIncomplete}. It is\n * deliberately not a boolean: a non-zero exit whose output does not say what failed and what\n * finishes it is worse than the silent success it replaces.\n *\n * Private, with {@link hasIncompleteWork} the only reading a subclass gets. A command records\n * through the two methods below and asks whether anything is owed; the list itself is this\n * class's, because it is this class that answers for it.\n */\n private readonly incompleteWork: IncompleteWork[] = [];\n\n async init(): Promise<void> {\n await super.init();\n await this.ensureTerminalSize();\n }\n\n /**\n * Blocks the command from launching in a terminal below\n * {@link MIN_TERMINAL_SIZE}. This runs once, before Ink mounts; the terminal\n * shrinking mid-session is caught by the matching guard in `WizardLayout`.\n */\n protected async ensureTerminalSize(): Promise<void> {\n if (isTerminalBigEnough()) return;\n\n this.clearTerminal();\n this.log(chalk.hex(CLI_COLORS.WARNING)(formatTerminalTooSmallMessage(terminalColumns())));\n\n await waitForTerminal(isTerminalBigEnough);\n }\n\n protected handleError(error: unknown): never {\n const message = getErrorMessage(error);\n this.error(message, { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * The name this run prints itself under: `branding.name` where a config supplies one, and\n * {@link DEFAULT_BRANDING.NAME} everywhere else.\n *\n * **DEGRADE is the posture, and it is chosen here for every command that prints a name.**\n * `loadSourceConfig` raises for a config that exists and cannot be evaluated, and two of the\n * four callers must survive precisely that state: `doctor`'s whole job is naming it, and\n * `uninstall` is the only way out of it. A heading is decoration — nothing about a display name\n * is worth refusing a command over, and refusing here would turn the branding wiring into a new\n * way for an unreadable config to abort two commands that survive it today. `init` and `eject`\n * cannot reach the catch at all: {@link ensureConfigReadable} has already refused every config\n * they would read.\n *\n * The cause is not swallowed: it goes to `verbose`, and the command's own config reader reports\n * it in full where the user needs to act on it. Reporting it twice would put a warning about\n * the configuration above a heading, which is the one line that has to be the first thing on\n * screen.\n */\n protected async resolveBrandingName(projectDir: string): Promise<string> {\n try {\n const branding = await resolveBranding(projectDir);\n return branding.name;\n } catch (error) {\n verbose(`Could not read branding from the config: ${getErrorMessage(error)}`);\n return DEFAULT_BRANDING.NAME;\n }\n }\n\n protected logSuccess(message: string): void {\n this.log(`✓ ${message}`);\n }\n\n protected logWarning(message: string): void {\n this.warn(message);\n }\n\n protected logInfo(message: string): void {\n this.log(message);\n }\n\n protected clearTerminal(): void {\n clearTerminalScreen();\n }\n\n /**\n * Resolves the marketplace required for a plugin operation, or hard-exits with\n * an actionable error when it cannot be resolved. `onRegistered` is invoked\n * (when provided) if the marketplace had to be registered — init uses it to log.\n *\n * `host` is the caller's because a marketplace registration is handed no directory of its own:\n * every caller here holds the install root the run is about, and `hostAt` turns one into the\n * host whose registry the marketplace has to land in.\n */\n protected async requireMarketplaceOrExit(\n sourceResult: SourceLoadResult,\n purpose: string,\n host: PluginHost,\n onRegistered?: (marketplace: string) => void,\n ): Promise<string> {\n const required = await requireMarketplace(sourceResult, purpose, host);\n if (!required.ok) {\n this.error(required.error, { exit: EXIT_CODES.ERROR });\n }\n if (required.registered) {\n onRegistered?.(required.marketplace);\n }\n return required.marketplace;\n }\n\n /**\n * Reports every constraint a completed selection breaks — a conflicting pair, an unmet\n * requirement, an exclusive category with two picks.\n *\n * Shared by `init` and `edit` so one selection cannot be reported two ways. Both commands ask\n * the same question of the same matrix, so a roster that draws a warning through one must draw\n * the same warning through the other; `init` used to compute the answer and drop it, which is\n * the whole reason this lives here rather than on either command.\n *\n * These are advisory (`ValidationError` in types/matrix.ts): the selection is installed either\n * way and neither command's exit code turns on them, so they are warnings and not errors. The\n * loop is its own guard — an accepted selection carries no errors and says nothing.\n */\n protected reportValidationErrors(validation: SelectionValidation): void {\n for (const error of validation.errors) {\n this.warn(error.message);\n }\n }\n\n /**\n * Installs skill plugins and narrates the operation.\n *\n * Shared by `init` and `edit` for the same reason as {@link reportValidationErrors}:\n * both run the SAME install against the same marketplace, so a line one prints about\n * it the other owes. `edit` used to run it in silence — a real `claude plugin install`\n * was indistinguishable in the output from nothing having happened.\n *\n * The skills nothing carries are refused FIRST, by name: an install no marketplace\n * could serve is knowable before the Claude CLI is asked, and the generic\n * install-failure advice is unfollowable for a skill the user wrote themselves.\n */\n protected async installPluginSkillsReported(\n skills: SkillConfig[],\n marketplace: string,\n projectDir: string,\n matrix: MergedSkillsMatrix,\n ): Promise<PluginInstallResult> {\n const unbacked = unbackedPluginSkillIds(skills, matrix);\n if (unbacked.length > 0) {\n this.error(unbackedPluginInstallError(unbacked), { exit: EXIT_CODES.ERROR });\n }\n\n this.announcePluginInstall();\n const result = await installPluginSkills(skills, marketplace, projectDir);\n this.reportPluginInstalls(result);\n return result;\n }\n\n /**\n * The opening half of the narration above, exposed for the one caller that cannot\n * use the whole of it: an eject→plugin migration installs each plugin and deletes\n * that skill's working copy in the same step (see `executeMigration`), so the\n * install it performs is not this command's to run.\n */\n protected announcePluginInstall(): void {\n this.log(STATUS_MESSAGES.INSTALLING_PLUGINS);\n }\n\n /**\n * The closing half: what was installed, what was not, and the refusal to continue\n * past a failure.\n *\n * The hard-error is part of the report rather than each caller's own postscript\n * because it is the same rule everywhere — plugin install intent is inviolable, so\n * a run that could not honor it must stop BEFORE any config records a marketplace\n * `origin` for a skill with no plugin registration.\n */\n protected reportPluginInstalls(result: PluginInstallResult): void {\n for (const item of result.installed) {\n this.log(` Installed ${item.ref}`);\n }\n for (const item of result.failed) {\n this.warn(`Failed to install plugin ${item.id}: ${item.error}`);\n }\n if (result.failed.length > 0) {\n this.error(pluginInstallFailureError(result.failed.length), { exit: EXIT_CODES.ERROR });\n }\n this.log(`${pluginsInstalled(result.installed.length)}\\n`);\n }\n\n /**\n * Renders what a gated write's fan-out did to the OTHER registered projects: one line for each\n * it left alone because its config.ts cannot be loaded, then the recompile it performed.\n *\n * `uninstall` alone calls {@link reportPropagatedRecompile} directly, since it words the projects\n * whose config it could not prune in its own terms.\n */\n protected reportFanOut(report: GateReport): void {\n for (const projectPath of report.propagated.unreadable) {\n this.warn(registeredProjectConfigUnreadable(projectPath));\n }\n this.reportPropagatedRecompile(report);\n }\n\n /**\n * One line for each registered project a fan-out left alone because nothing of this\n * installation is there to rewrite: nothing is installed at its path any more, or it is another\n * provider's installation. `compile` and `uninstall` print it — neither project's config can\n * hold what either run changed.\n */\n protected reportProjectsOutOfReach(propagated: GateReport[\"propagated\"]): void {\n for (const projectPath of propagated.gone) {\n this.warn(registeredProjectGone(projectPath));\n }\n for (const projectPath of propagated.notOurs) {\n this.warn(registeredProjectOnAnotherProvider(projectPath));\n }\n }\n\n /**\n * Renders the recompile a gated write already performed on every OTHER registered\n * project this run's global change was propagated into.\n *\n * Shared by all four commands that fan out — the count and its wording are one\n * statement about one operation, and four copies of it had already drifted into two\n * spellings of the same sentence.\n */\n protected reportPropagatedRecompile(report: GateReport): void {\n if (report.propagated.updated.length === 0) return;\n\n const { rewrittenCount, unchangedCount, failedCount, warnings } = report.recompile;\n for (const warning of warnings) {\n this.warn(warning);\n }\n this.log(propagatedRecompileSummary(rewrittenCount, unchangedCount, failedCount));\n }\n\n /**\n * Names every selected skill this save left in no sub-agent's stack, and — where the\n * scope rule is why — every sub-agent it was kept away from.\n *\n * Shared by `init` and `edit` for the reason {@link reportValidationErrors} is: both\n * build the stack from the same rules over the same selection, so a skill that reaches\n * nothing through one reaches nothing through the other. The rule being reported is\n * CORRECT and nothing here changes it — a project-scoped skill installs, is written to\n * `config.ts`, and is loaded by nobody, which every other surface reports as a clean\n * install.\n *\n * `compile` says the same thing about the same shape one layer over, for a config\n * hand-edited into it — see `Compile.warnScopeDroppedStackPairs`.\n */\n protected reportUnassignedSkills(config: ProjectConfig, selected: readonly SkillConfig[]): void {\n for (const { skillId, blockedBy } of findUnassignedSkills(config, selected)) {\n this.warn(skillAssignedToNoAgent(skillId));\n if (blockedBy.length > 0) {\n this.warn(scopeBlockedStackAssignment(blockedBy, skillId));\n }\n }\n }\n\n /**\n * Refuses to run when a config file exists but cannot be loaded.\n *\n * Both configs this run would read are checked, because both are read on the way through: a\n * project's own `config.ts` and the global one every project write inlines. Checking up\n * front is the whole point — an unreadable GLOBAL config otherwise surfaced only at the\n * config write, after the wizard had copied skills and installed plugins, as a warning that\n * the write never happened.\n *\n * Every command that reads an installation's config calls it before anything else reads one:\n * the writes (`init`, `edit`, `compile`, `update`, `share`, `eject`) and the two that only\n * report (`search`, `list`). `doctor` reports the same file instead, and `uninstall` is the way\n * out of it, so neither does.\n *\n * A MISSING config is not a corrupt one and passes here untouched: it is the legitimate\n * state `init` exists for, and the state `edit` reports as \"no installation\".\n */\n protected async ensureConfigReadable(projectDir: string): Promise<void> {\n const failures = await findConfigLoadFailures(projectDir);\n if (failures.length > 0) {\n this.error(installationConfigsUnreadable(failures), { exit: EXIT_CODES.ERROR });\n }\n }\n\n /**\n * Refuses to run when a saved skill entry names a local skill that IS installed and whose\n * metadata.yaml describes no skill.\n *\n * One layer below {@link ensureConfigReadable} and for the same reason: the config parses,\n * and a file it points at does not. Both wizards resolve their saved roster against the\n * loaded catalogue, and an id nothing can be loaded for reaches no screen — so without this\n * the entry is dropped and reported as a skill the marketplace no longer carries, which is a\n * removal the user never asked for and a sentence blaming the wrong thing.\n *\n * Only entries the catalogue does not carry are looked at, so a healthy install pays a\n * filesystem read for nothing. An entry whose files are simply GONE is not refused — there\n * is no file to repair, so it is removed with a reason that says so\n * (`unresolvedSkillRemovalReasons`).\n *\n * Runs before the wizard mounts, which is the whole point: past that, a refusal costs the\n * user the session they had already spent, and everything this protects has been rewritten.\n */\n protected async ensureSavedSkillsReadable(\n savedSkills: readonly SkillConfig[],\n matrix: MergedSkillsMatrix,\n projectDir: string,\n ): Promise<void> {\n const unresolved = savedSkills\n .filter((saved) => !saved.excluded && !matrix.skills[saved.id])\n .map((saved) => saved.id);\n if (unresolved.length === 0) return;\n\n const unusable = await findUnusableSavedSkillMetadata(unresolved, savedSkills, projectDir);\n if (unusable.length === 0) return;\n\n // The detail is LOGGED and only the refusal is raised — oclif hard-wraps error text at the\n // terminal width, and a path broken across two lines is one nobody can copy. Same split\n // `compile` makes over the same verdict.\n for (const entry of unusable) {\n this.log(skillMetadataUnusableDetail(entry));\n }\n this.error(savedSkillMetadataUnusableError(unusable), { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * Refuses a shared configuration carrying project-scoped content at the home directory.\n *\n * The home directory IS the global scope, and a global installation holds only global-scoped\n * content. Both scopes read one config file there, and on Claude one skills directory and one\n * agents directory as well — so a project-scoped entry lands in the global config wearing a\n * label that contradicts the file it is in, and on Claude `toClaudePluginScope` maps that\n * declared scope onward, registering the skill against `$HOME` as a project. Nothing\n * below this point reads the scope again, so whatever the boundary lets through becomes the\n * truth.\n *\n * Shared by `init --from` and `edit --from` for the reason {@link reportValidationErrors} is\n * shared: it is a fact about the payload and the directory, identical whichever command asked,\n * and an invariant enforced on one producer and not the other is enforced nowhere. It matters\n * more on the destructive one — `edit --from` reaches the same contradiction through the other\n * door and can remove global entries on the way.\n *\n * The interactive producer has always answered this for itself — `isHomeDirectory(projectDir)`\n * reaches the wizard session as `isGlobalRoot` and the scope toggles are inert under it — so\n * this puts both `--from` paths on the rule the wizard already follows.\n *\n * It takes the DECODED selection, so it must run after the decode and can run no earlier: an\n * all-global configuration is exactly what a global installation is for, and only the decode\n * says which entries survived this catalogue and what scope each rests at. Every caller runs it\n * before it reports a skip and before it writes anything, so a run about to be refused neither\n * narrates nor mutates.\n */\n protected refuseProjectScopedContentAtHome(result: WizardResultV2, projectDir: string): void {\n if (!isHomeDirectory(projectDir)) return;\n\n const { skillIds, agentNames } = projectScopedContent(result);\n if (skillIds.length === 0 && agentNames.length === 0) return;\n\n this.error(sharedConfigProjectScopeAtHome(skillIds, agentNames), { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * The refusals a `--from` producer can decide only once it holds what it would install — the\n * selection and the skills the configuration carries — asked before it lists any of it or asks\n * whether to install it.\n *\n * A run that lists, asks, and is told yes has promised that a yes installs what was listed (the\n * u01 ruling: \"On yes, it installs what is listed\"), so a refusal still to come after the\n * question would ask a person to confirm an install that was never going to happen. Every other\n * `--from` refusal is already decided above the lists — a carried skill asked for as a plugin or\n * under a catalogue's id, project content at the home directory, an installation already here —\n * and these four are the ones that need the decoded selection to be asked of:\n *\n * - **A placement the host does not offer.** Read off the selection and the host the run\n * installs through, nothing else, so nothing makes it wait for the yes.\n * - **A stack the marketplace does not ship.** The stack supplies only the configuration's\n * description, yet the install refuses an id it cannot resolve — after the plugins are\n * installed and the skills copied. So it is asked here, through the lookup the install makes,\n * of the marketplace the install reads.\n * - **A carried skill over a directory no shared configuration put there** — the user's own\n * skill at the id the configuration minted for it. Judged on the same set the producer writes,\n * so the skills already installed globally, which it does not write, are not asked about.\n * - **A stack the config writer would refuse** — two skills in a category that holds one, as a\n * hand-written row or the kept skills an apply puts back can make. Asked through the writer's\n * own rule, because `edit --from` writes the config after its removals have landed.\n *\n * Shared by `init --from` and `edit --from` for the reason {@link refuseProjectScopedContentAtHome}\n * is: an invariant enforced on one producer and not the other is enforced nowhere.\n */\n protected async refuseSharedConfigBeforeAsking(\n selection: WizardResultV2,\n carried: ExternalSkillInstall[],\n root: string,\n sourceResult: SourceLoadResult,\n ): Promise<void> {\n this.refuseUnofferablePlacementsBeforeWriting(selection.skills, root);\n try {\n await refuseUnofferedStack(selection.selectedStackId, sourceResult);\n await refuseUncarriedDestinations(carried);\n refuseUnwritableStack(selection.assignedStack, sourceResult.matrix);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /**\n * Refuses a SELECTION asking for a mode/scope cell this host does not offer, before the run has\n * touched anything.\n *\n * **`bindsItsOfferedPlacements` is not a pre-flight and cannot be made into one.** It refuses\n * at `installPlugin`, which `installPluginSkills` calls once per skill inside a loop that\n * collects per-skill failures — so a payload whose first plugin row is offerable and whose\n * second is not installed a real plugin into the user's Codex registry and only then stopped,\n * on a message ending \"Nothing has been changed.\" Nothing removed it afterwards: no `config.ts`\n * was written, so `uninstall` had no row naming it and `doctor` had no configuration to check\n * it against — an orphan in the host's own registry that no command in this CLI can see. The\n * single-row case cannot show it, because with one unofferable row the loop's first iteration\n * IS the refusal. `edit --from` had no pre-flight at all until it came here, and met exactly\n * that per-plugin guard after its own yes.\n *\n * It reads the whole selection — ejected rows included — because the roster is about CELLS\n * rather than about plugins: a host that stopped offering `eject+project` would owe the same\n * refusal, and a guard that only looked at plugin rows would go on writing files for it.\n *\n * The same function the read path calls (`refuseUnofferedPlacements`, off the same host\n * roster), so `init`'s sentence and `compile`'s are one sentence rather than two that agree\n * today. The per-call guard stays where it is: it is the backstop for a caller that did not\n * come through here, and for the one host this release ships every cell is offered, so a\n * backstop that never fires is what a deleted one would look like.\n */\n protected refuseUnofferablePlacementsBeforeWriting(\n skills: readonly SkillConfig[],\n root: string,\n ): void {\n try {\n refuseUnofferedPlacements(skills, hostAt(root));\n } catch (error) {\n this.error(getErrorMessage(error), { exit: EXIT_CODES.ERROR });\n }\n }\n\n /**\n * What a command that is about to WRITE owes the user about the layout of the folders it will\n * write into: a refusal where a scope holds two of them.\n *\n * A scope on the retired name alone is NOT nudged and never was a fault. Such an installation\n * is read and written exactly where it is, indefinitely; there is no command that moves one,\n * and a line printed on every write about a supported state is one people learn to skip.\n *\n * Read-only commands do not call this: `doctor`'s Layout row is where a command that changes\n * nothing says all of this, and a user whose scope holds two folders has to be able to LOOK at\n * it. `share` changes nothing here and calls it anyway, because it PUBLISHES what it reads — an\n * id minted from whichever folder the resolver picked describes an installation nobody chose,\n * and it outlives the folder it was read from.\n */\n protected async settleSourceLayoutBeforeWriting(projectDir: string): Promise<void> {\n this.refuseRivalSourceFolders(await sourceScopesInPlay(projectDir));\n }\n\n /**\n * A scope holding both source folders stops a write command, and names both.\n *\n * The preference order is why it is a refusal rather than a warning: with two folders on disk\n * the resolver reads whichever holds a `config.ts`, and that can be the STALE one — so the\n * write lands in a folder nothing compiles, beside a folder holding the sub-agents the user is\n * about to stop seeing. Both of its causes are the product's own: a compiled `agent-summoner`\n * names the source folder in its prompt, so a copy compiled under either layout authors into\n * the other one.\n *\n * The way out is a manual one, and the sentence names it: nothing in this CLI merges two source\n * folders, so the user moves what they want into the folder being read and removes the other.\n * Which folder that is comes from {@link folderBeingRead} rather than from the new name — the\n * preference order takes whichever holds a `config.ts`, so in the state this refusal is read in\n * the live folder is very often the OLD one.\n */\n private refuseRivalSourceFolders(scopes: readonly SourceScope[]): void {\n const rivals = scopes.filter((scope) => scope.both);\n const [first] = rivals;\n if (first?.move === undefined || first.move === null) return;\n\n // Through `warn()` from `utils/logger.ts` rather than `this.warn`: oclif hard-wraps at the\n // terminal width, and this sentence names three folders and an invocation — none of which\n // survives being broken in half.\n warn(\n rivalSourceFoldersRefuseWrites(\n rivals.map((scope) => scope.kind),\n first.move.from.relName,\n first.move.to.relName,\n folderBeingRead(first, first.move),\n ),\n );\n this.error(WRITE_REFUSED_RIVAL_SOURCE_FOLDERS, { exit: EXIT_CODES.ERROR });\n }\n\n /** Whether this run owes an account — the one thing a command may ask about the list. */\n protected get hasIncompleteWork(): boolean {\n return this.incompleteWork.length > 0;\n }\n\n /**\n * Warns about work this run attempted and did not complete, and records it for the ending.\n *\n * Both halves, always. The warning stays at the point of failure because that is where it is\n * explicable and where the surrounding output says what was being attempted; the record is\n * what decides the exit code, and a failure the user is told about while the process reports\n * success is exactly the state this closes.\n *\n * What it must never do is abort. Every caller sits past the point where the mutation it is\n * reporting on has already happened, so stopping would relabel a state already committed to\n * disk rather than prevent it — and would abandon the steps after it that can still land.\n *\n * The `recovery` sentences live in `INCOMPLETE_WORK_RECOVERY` in `utils/messages.ts`. One\n * spelling per remedy is what matters; three spellings of \"run compile\" read as three\n * different instructions.\n */\n protected reportIncompleteWork(what: string, recovery: string): void {\n this.warn(what);\n this.recordIncompleteWork(what, recovery);\n }\n\n /**\n * The recording half alone, for a caller that has already said its piece: a recompile warns\n * once per failed sub-agent with the compiler's own reason, so the ending names the roster\n * those reasons belong to instead of repeating any of them.\n */\n protected recordIncompleteWork(what: string, recovery: string): void {\n this.incompleteWork.push({ what, recovery });\n }\n\n /**\n * The command's last word: what did not happen, what finishes it, and a non-zero exit.\n *\n * `this.exit` raises oclif's `ExitError`, which the framework carries to the process exit\n * code and prints nothing for — so the account printed here is the whole of the output, with\n * none of the `Error:` framing `this.error` would add to a command that in fact completed.\n *\n * A command that records must call this, or it files failures into a list nothing reads —\n * which is the original silence wearing the mechanism built to close it, and is what\n * `failure-reporting-classification.test.ts` holds every command in `src/cli/commands/` to.\n */\n protected exitIfWorkIncomplete(): void {\n if (!this.hasIncompleteWork) return;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.WARNING)(completedWithFailures(this.incompleteWork))}\\n`);\n this.exit(EXIT_CODES.COMPLETED_WITH_FAILURES);\n }\n}\n","import type { PluginHost } from \"../../hosts/plugin-host.js\";\nimport { fetchMarketplace } from \"../../loading/index.js\";\nimport { warn } from \"../../../utils/logger.js\";\nimport { getErrorMessage } from \"../../../utils/errors.js\";\nimport type { SourceLoadResult } from \"../../loading/source-loader.js\";\n\nexport type MarketplaceResult = {\n /** The resolved marketplace name, or null if no marketplace is configured. */\n marketplace: string | null;\n /** Whether a new marketplace was registered (vs. updated or already existed). */\n registered: boolean;\n};\n\n/**\n * Ensures the marketplace is registered with the host this installation runs on.\n *\n * The host is a parameter rather than something resolved here: this is the one plugin operation\n * that is handed no directory at all — a marketplace is user-level state under one HOME, and its\n * verbs take a name and a source and nothing else — so there is no folder for it to read a\n * provider off.\n *\n * If the marketplace does not exist, registers it. If it exists, updates it.\n * Handles lazy marketplace name resolution when sourceResult.marketplace is undefined.\n *\n * Reports nothing on success — commands decide what to log based on the `registered`\n * flag — but never swallows a failure: `requireMarketplace` turns a null marketplace\n * into a hard error whose text cannot tell a transient fetch failure apart from a\n * source that genuinely ships no marketplace, so the cause is warned here or nowhere.\n */\nexport async function ensureMarketplace(\n sourceResult: SourceLoadResult,\n host: PluginHost,\n): Promise<MarketplaceResult> {\n const source = sourceResult.sourceConfig.source;\n\n if (!sourceResult.marketplace) {\n try {\n const marketplaceResult = await fetchMarketplace(source);\n sourceResult.marketplace = marketplaceResult.marketplace.name;\n } catch (error) {\n warn(`Could not resolve a marketplace from '${source}': ${getErrorMessage(error)}`);\n return { marketplace: null, registered: false };\n }\n }\n\n const marketplace = sourceResult.marketplace;\n const exists = await host.marketplaceExists(marketplace);\n\n if (!exists) {\n const marketplaceSource = source.replace(/^github:/, \"\");\n await host.addMarketplace(marketplaceSource);\n return { marketplace, registered: true };\n }\n\n try {\n await host.refreshMarketplace(marketplace);\n } catch {\n warn(\"Could not update marketplace — continuing with cached version\");\n }\n\n return { marketplace, registered: false };\n}\n","import { ensureMarketplace } from \"./ensure-marketplace.js\";\nimport type { PluginHost } from \"../../hosts/plugin-host.js\";\nimport type { SourceLoadResult } from \"../../loading/source-loader.js\";\n\nexport type MarketplaceRequirement =\n { ok: true; marketplace: string; registered: boolean } | { ok: false; error: string };\n\n/**\n * Resolves the marketplace required for plugin operations. Plugin install\n * intent is inviolable — callers must hard-error on `ok: false` rather than\n * silently falling back to eject or skipping, and must do so BEFORE any\n * filesystem mutation so a failure leaves no partial state on disk.\n */\nexport async function requireMarketplace(\n sourceResult: SourceLoadResult,\n purpose: string,\n host: PluginHost,\n): Promise<MarketplaceRequirement> {\n const mpResult = await ensureMarketplace(sourceResult, host);\n if (!mpResult.marketplace) {\n return {\n ok: false,\n error:\n `Cannot ${purpose}: marketplace could not be resolved from '${sourceResult.sourceConfig.source}'. ` +\n `Plugin install mode requires a marketplace — fix the marketplace or switch the affected skills to eject mode.`,\n };\n }\n return { ok: true, marketplace: mpResult.marketplace, registered: mpResult.registered };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaX,yBAAyB;AAC3B;;;ACnBA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,SAAS,aAAa,YAAY;;;ACJlC,SAAS,SAAS,WAAW,aAAa,qBAAqB;AAqB/D,IAAM,oBAAoB;AAC1B,IAAM,aAAa;AAgBZ,SAAS,kBACd,UACA,EAAE,IAAI,YAAY,GACV;AACR,QAAM,QAAQ,SAAS,EAAE;AACzB,QAAM,QAAQ,kBAAkB,KAAK,QAAQ;AAI7C,MAAI,CAAC,OAAO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A;AAAA,EAOU,qBAAqB,MAAc,UAAwB;AACnE,SAAK,eAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaU,uBAA6B;AACrC,QAAI,CAAC,KAAK,kBAAmB;AAE7B,SAAK,IAAI;AAAA,EAAK,MAAM,IAAI,WAAW,OAAO,EAAE,sBAAsB,KAAK,cAAc,CAAC,CAAC;AAAA,CAAI;AAC3F,SAAK,KAAK,WAAW,uBAAuB;AAAA,EAC9C;AACF;","names":[]}
@@ -9778,6 +9778,8 @@ var resolvedSkillSchema = z.object({
9778
9778
  // category — but a schema that omits the field STRIPS it, which is the same value
9779
9779
  // arriving by a route nothing can tell apart from the skill stating nothing.
9780
9780
  usageGuidance: z.string().exactOptional(),
9781
+ // The SKILL.md description compile renders — see `SkillCore.activationDescription`.
9782
+ activationDescription: z.string().exactOptional(),
9781
9783
  category: categorySchema,
9782
9784
  conflictsWith: z.array(skillRelationSchema),
9783
9785
  discourages: z.array(skillRelationSchema),
@@ -10254,7 +10256,7 @@ var domainOfSkill = (skillId) => {
10254
10256
  return skill.domainId;
10255
10257
  };
10256
10258
  var isDomainlessRoleAgent = (agentId) => agentDomainOf(agentId) === "meta" && AGENT_DEFINITIONS[agentId].flavor !== "meta";
10257
- var hasDomainAffinity = (skillDomain, agentId) => skillDomain === "shared" || skillDomain === "meta" || skillDomain === agentDomainOf(agentId) || isDomainlessRoleAgent(agentId);
10259
+ var hasDomainAffinity = (skillDomain2, agentId) => skillDomain2 === "shared" || skillDomain2 === "meta" || skillDomain2 === agentDomainOf(agentId) || isDomainlessRoleAgent(agentId);
10258
10260
  var createLoadStateResolver = (defaults) => ({ skillId, agentId, explicit }) => {
10259
10261
  assertKnownSkill(skillId);
10260
10262
  assertKnownAgent(agentId);
@@ -10719,6 +10721,10 @@ var matrixSkillSchema = z4.object({
10719
10721
  // skills may state none; omitting it here would strip it from every fetched
10720
10722
  // `catalog.json` and make every marketplace look like it states none.
10721
10723
  usageGuidance: z4.string().exactOptional(),
10724
+ // The SKILL.md description a compiled sub-agent's activation table shows —
10725
+ // `description` is the wizard's short label. The preview renders this one so
10726
+ // it shows what the install writes (CLI-898); absent on older catalogues.
10727
+ activationDescription: z4.string().exactOptional(),
10722
10728
  category: idSchema,
10723
10729
  conflictsWith: z4.array(skillRelationSchema2),
10724
10730
  discourages: z4.array(skillRelationSchema2),
@@ -10794,12 +10800,15 @@ function orderDomains(domains) {
10794
10800
 
10795
10801
  // ../compile/src/paths.ts
10796
10802
  var CLAUDE_DIR = ".claude";
10797
- var CLAUDE_SRC_DIR = ".claude-src";
10803
+ var SOURCE_ROOT_DIR = ".agents-inc";
10804
+ var LEGACY_SOURCE_DIR = ".claude-src";
10798
10805
  var SOURCE_SRC_DIR = "src";
10799
10806
  var SKILLS_DIR_PATH = `${SOURCE_SRC_DIR}/skills`;
10800
10807
  var LOCAL_SKILLS_PATH = ".claude/skills";
10801
10808
  var DEFAULT_PLUGIN_NAME = "agents-inc";
10802
10809
  var DEFAULT_PUBLIC_SOURCE_NAME = DEFAULT_PLUGIN_NAME;
10810
+ var GITHUB_PREFIX = "github:";
10811
+ var DEFAULT_SOURCE = `${GITHUB_PREFIX}agents-inc/skills`;
10803
10812
  var CLI_INVOKE_COMMAND = "npx agents-inc";
10804
10813
  var EJECT_SOURCE = "eject";
10805
10814
  var LOCAL_PSEUDO_CATEGORY = "local";
@@ -10884,6 +10893,10 @@ function isExclusiveCategory(catalog, category) {
10884
10893
  function categoryDomain(catalog, category) {
10885
10894
  return catalog.categories[category]?.domain;
10886
10895
  }
10896
+ function skillDomain(catalog, skillId) {
10897
+ const skill = catalog.skills[skillId];
10898
+ return skill && categoryDomain(catalog, skill.category);
10899
+ }
10887
10900
  function byCategoryDeclarationOrder(catalog) {
10888
10901
  const declarationRank = new Map(
10889
10902
  Object.keys(catalog.categories).map((category, rank) => [category, rank])
@@ -11009,6 +11022,12 @@ function validateSelection(selections, catalog) {
11009
11022
  return { valid: errors.length === 0, errors };
11010
11023
  }
11011
11024
 
11025
+ // ../compile/src/source-layout.ts
11026
+ var PROVIDERS = ["claude", "codex"];
11027
+ function sourceDirName(provider) {
11028
+ return `${SOURCE_ROOT_DIR}/${provider}`;
11029
+ }
11030
+
11012
11031
  // src/cli/consts.ts
11013
11032
  import os from "os";
11014
11033
  import path from "path";
@@ -11038,6 +11057,7 @@ function editorConfigUrl(id) {
11038
11057
  return `${EDITOR_URL}/?fromId=${encodeURIComponent(id)}`;
11039
11058
  }
11040
11059
  var EDIT_PROJECT_SETUP_FLAG = "project-setup";
11060
+ var EDIT_PROJECT_SETUP_MARKETPLACE_FLAG = "project-setup-marketplace";
11041
11061
  var SKILL_CATEGORIES_PATH = "config/skill-categories.ts";
11042
11062
  var SKILL_RULES_PATH = "config/skill-rules.ts";
11043
11063
  var STACKS_FILE_PATH = "config/stacks.ts";
@@ -11160,6 +11180,7 @@ var ASCII_LOGO = ` \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u258
11160
11180
  export {
11161
11181
  isExclusiveCategory,
11162
11182
  categoryDomain,
11183
+ skillDomain,
11163
11184
  byCategoryDeclarationOrder,
11164
11185
  SKILL_IDS,
11165
11186
  AGENT_NAMES,
@@ -11183,12 +11204,14 @@ export {
11183
11204
  orderDomains,
11184
11205
  bytewise,
11185
11206
  CLAUDE_DIR,
11186
- CLAUDE_SRC_DIR,
11207
+ SOURCE_ROOT_DIR,
11208
+ LEGACY_SOURCE_DIR,
11187
11209
  SOURCE_SRC_DIR,
11188
11210
  SKILLS_DIR_PATH,
11189
11211
  LOCAL_SKILLS_PATH,
11190
11212
  DEFAULT_PLUGIN_NAME,
11191
11213
  DEFAULT_PUBLIC_SOURCE_NAME,
11214
+ DEFAULT_SOURCE,
11192
11215
  CLI_INVOKE_COMMAND,
11193
11216
  EJECT_SOURCE,
11194
11217
  LOCAL_PSEUDO_CATEGORY,
@@ -11206,6 +11229,8 @@ export {
11206
11229
  activeSkillScopeMap,
11207
11230
  activeAgentScopeMap,
11208
11231
  effectivelyExcludedSkillIds,
11232
+ PROVIDERS,
11233
+ sourceDirName,
11209
11234
  PROJECT_ROOT,
11210
11235
  PLUGINS_SUBDIR,
11211
11236
  PLUGIN_MANIFEST_DIR,
@@ -11219,6 +11244,7 @@ export {
11219
11244
  EDITOR_URL,
11220
11245
  editorConfigUrl,
11221
11246
  EDIT_PROJECT_SETUP_FLAG,
11247
+ EDIT_PROJECT_SETUP_MARKETPLACE_FLAG,
11222
11248
  SKILL_CATEGORIES_PATH,
11223
11249
  SKILL_RULES_PATH,
11224
11250
  STACKS_FILE_PATH,
@@ -11251,4 +11277,4 @@ export {
11251
11277
  FALLBACK_DOMAIN,
11252
11278
  ASCII_LOGO
11253
11279
  };
11254
- //# sourceMappingURL=chunk-UITEKY2R.js.map
11280
+ //# sourceMappingURL=chunk-AQXKAPCD.js.map