dispach 0.2.3 → 0.2.13

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 (219) hide show
  1. package/README.md +46 -43
  2. package/dist/APEv2Parser-rt8hyadd.js +5 -0
  3. package/dist/{AiffParser-9hj6fpmy.js → AiffParser-gvpmtb2e.js} +3 -3
  4. package/dist/{AiffParser-9hj6fpmy.js.map → AiffParser-gvpmtb2e.js.map} +1 -1
  5. package/dist/App-18dvbyev.js +11 -0
  6. package/dist/{App-2f72vhjv.js.map → App-18dvbyev.js.map} +1 -1
  7. package/dist/AsfParser-h9zyh6cx.js +5 -0
  8. package/dist/{AsfParser-7emspn04.js.map → AsfParser-h9zyh6cx.js.map} +1 -1
  9. package/dist/ConfigEditor-444m13ta.js +6 -0
  10. package/dist/{ConfigEditor-vk7vxaa6.js.map → ConfigEditor-444m13ta.js.map} +1 -1
  11. package/dist/DsdiffParser-gxqv4gn1.js +5 -0
  12. package/dist/{DsdiffParser-dz88pnnr.js.map → DsdiffParser-gxqv4gn1.js.map} +1 -1
  13. package/dist/{DsfParser-qgh63tbs.js → DsfParser-sndt4jbk.js} +3 -3
  14. package/dist/{DsfParser-qgh63tbs.js.map → DsfParser-sndt4jbk.js.map} +1 -1
  15. package/dist/FlacParser-rmkpvf9e.js +5 -0
  16. package/dist/{KeyProbe-5anphmb7.js → KeyProbe-6t531sy6.js} +3 -3
  17. package/dist/{KeyProbe-5anphmb7.js.map → KeyProbe-6t531sy6.js.map} +1 -1
  18. package/dist/MP4Parser-87xfsck4.js +5 -0
  19. package/dist/{MP4Parser-yr7p3z12.js.map → MP4Parser-87xfsck4.js.map} +2 -2
  20. package/dist/{MatroskaParser-jkbsbsk3.js → MatroskaParser-7krspfgx.js} +3 -3
  21. package/dist/{MatroskaParser-jkbsbsk3.js.map → MatroskaParser-7krspfgx.js.map} +1 -1
  22. package/dist/{MpegParser-t93vwnew.js → MpegParser-jcs35q0h.js} +3 -3
  23. package/dist/{MpegParser-t93vwnew.js.map → MpegParser-jcs35q0h.js.map} +1 -1
  24. package/dist/MusepackParser-d4zfnzk3.js +5 -0
  25. package/dist/{MusepackParser-6e8kbh2d.js.map → MusepackParser-d4zfnzk3.js.map} +2 -2
  26. package/dist/OggParser-fbspjs7v.js +5 -0
  27. package/dist/{OggParser-ggcypmag.js.map → OggParser-fbspjs7v.js.map} +1 -1
  28. package/dist/Picker-x6aj42tc.js +5 -0
  29. package/dist/{Picker-j7txnm7w.js.map → Picker-x6aj42tc.js.map} +1 -1
  30. package/dist/SessionPicker-pngdv97x.js +5 -0
  31. package/dist/{SessionPicker-hpv2ncsb.js.map → SessionPicker-pngdv97x.js.map} +1 -1
  32. package/dist/SkillBrowser-3mnzkakr.js +5 -0
  33. package/dist/{SkillBrowser-qc542n71.js.map → SkillBrowser-3mnzkakr.js.map} +1 -1
  34. package/dist/WavPackParser-0x9z4466.js +5 -0
  35. package/dist/{WavPackParser-jw9stzqp.js.map → WavPackParser-0x9z4466.js.map} +1 -1
  36. package/dist/WaveParser-31b6qtef.js +5 -0
  37. package/dist/{WaveParser-epmncs9w.js.map → WaveParser-31b6qtef.js.map} +1 -1
  38. package/dist/WizardApp-c42wc116.js +5 -0
  39. package/dist/{WizardApp-pgzcz9zq.js.map → WizardApp-c42wc116.js.map} +1 -1
  40. package/dist/channels-nf6d8fvx.js +31 -0
  41. package/dist/{channels-m8nambmm.js.map → channels-nf6d8fvx.js.map} +1 -1
  42. package/dist/client.d.ts +1 -1
  43. package/dist/client.js +11 -11
  44. package/dist/client.js.map +4 -4
  45. package/dist/config-sx40rg8m.js +24 -0
  46. package/dist/{config-hmgrqgf2.js.map → config-sx40rg8m.js.map} +2 -2
  47. package/dist/credential-vdbkfk65.js +19 -0
  48. package/dist/{credential-nkb2ya59.js.map → credential-vdbkfk65.js.map} +1 -1
  49. package/dist/daemon.d.ts.map +1 -1
  50. package/dist/{index-51x0n5z0.js → index-0dcpsfet.js} +4 -4
  51. package/dist/{index-51x0n5z0.js.map → index-0dcpsfet.js.map} +1 -1
  52. package/dist/{index-yw3fby4n.js → index-1h8s50d9.js} +3 -3
  53. package/dist/{index-yw3fby4n.js.map → index-1h8s50d9.js.map} +1 -1
  54. package/dist/index-1hbvhrsj.js +6 -0
  55. package/dist/{index-dzy19wtf.js.map → index-1hbvhrsj.js.map} +1 -1
  56. package/dist/index-1hfece7s.js +10 -0
  57. package/dist/{index-22fzzn7z.js.map → index-1hfece7s.js.map} +2 -2
  58. package/dist/index-2h566rtg.js +6 -0
  59. package/dist/{index-jc4kmfwa.js.map → index-2h566rtg.js.map} +1 -1
  60. package/dist/index-4g4smpkk.js +11 -0
  61. package/dist/{index-sh44ymqz.js.map → index-4g4smpkk.js.map} +1 -1
  62. package/dist/index-4gfsf9n8.js +6 -0
  63. package/dist/{index-8tmv33mr.js.map → index-4gfsf9n8.js.map} +1 -1
  64. package/dist/{index-dv9pdjy4.js → index-5ptbytze.js} +10 -10
  65. package/dist/{index-dv9pdjy4.js.map → index-5ptbytze.js.map} +1 -1
  66. package/dist/index-5s1cq8np.js +8 -0
  67. package/dist/{index-9t4dz145.js.map → index-5s1cq8np.js.map} +1 -1
  68. package/dist/{index-2zjh5zd5.js → index-659ggfbf.js} +2 -2
  69. package/dist/index-6ebppx3t.js +6 -0
  70. package/dist/{index-1x8mzvz7.js.map → index-6ebppx3t.js.map} +1 -1
  71. package/dist/index-6pym9p8h.js +9 -0
  72. package/dist/{index-38gs9anh.js.map → index-6pym9p8h.js.map} +1 -1
  73. package/dist/index-9ejax6hp.js +6 -0
  74. package/dist/{index-8edck2pr.js.map → index-9ejax6hp.js.map} +1 -1
  75. package/dist/{index-zw6wyas6.js → index-9hw9j1qg.js} +4 -4
  76. package/dist/{index-zw6wyas6.js.map → index-9hw9j1qg.js.map} +1 -1
  77. package/dist/{index-bqdkm3de.js → index-9xhresrg.js} +4 -4
  78. package/dist/{index-bqdkm3de.js.map → index-9xhresrg.js.map} +1 -1
  79. package/dist/{index-hgm2gchq.js → index-abm0zyc0.js} +12 -12
  80. package/dist/{index-hgm2gchq.js.map → index-abm0zyc0.js.map} +1 -1
  81. package/dist/index-ar5c9d2f.js +7 -0
  82. package/dist/{index-3826kf9t.js.map → index-ar5c9d2f.js.map} +1 -1
  83. package/dist/index-bhj4pmrx.js +74 -0
  84. package/dist/index-bhj4pmrx.js.map +13 -0
  85. package/dist/index-brt17yfr.js +6 -0
  86. package/dist/{index-hrwakb11.js.map → index-brt17yfr.js.map} +2 -2
  87. package/dist/index-bysnsdkd.js +6 -0
  88. package/dist/{index-nxhqf597.js.map → index-bysnsdkd.js.map} +1 -1
  89. package/dist/index-c74wx9pv.js +6 -0
  90. package/dist/{index-323jvr1g.js.map → index-c74wx9pv.js.map} +1 -1
  91. package/dist/index-cm3g4t3r.js +14 -0
  92. package/dist/{index-y7dxq4a4.js.map → index-cm3g4t3r.js.map} +2 -2
  93. package/dist/index-dzp6mc5h.js +6 -0
  94. package/dist/{index-42e29zs4.js.map → index-dzp6mc5h.js.map} +1 -1
  95. package/dist/index-fad09b8c.js +6 -0
  96. package/dist/{index-836hc2h1.js.map → index-fad09b8c.js.map} +2 -2
  97. package/dist/{index-0444sh6x.js → index-fvb2dxzn.js} +4 -4
  98. package/dist/{index-0444sh6x.js.map → index-fvb2dxzn.js.map} +1 -1
  99. package/dist/{index-2bsardvh.js → index-gpq4agva.js} +3 -3
  100. package/dist/{index-2bsardvh.js.map → index-gpq4agva.js.map} +1 -1
  101. package/dist/{index-qgsdgbk8.js → index-hcpvk5de.js} +3 -3
  102. package/dist/{index-qgsdgbk8.js.map → index-hcpvk5de.js.map} +1 -1
  103. package/dist/{index-pqw1n1pv.js → index-jv5t63tp.js} +4 -4
  104. package/dist/{index-pqw1n1pv.js.map → index-jv5t63tp.js.map} +1 -1
  105. package/dist/index-kyz4t0j0.js +126 -0
  106. package/dist/{index-ry6a4bqh.js.map → index-kyz4t0j0.js.map} +2 -2
  107. package/dist/{index-ytxbw8py.js → index-m6r2sxcw.js} +33 -33
  108. package/dist/{index-ytxbw8py.js.map → index-m6r2sxcw.js.map} +1 -1
  109. package/dist/{index-snz49ndn.js → index-mhw3d7af.js} +3 -3
  110. package/dist/{index-snz49ndn.js.map → index-mhw3d7af.js.map} +1 -1
  111. package/dist/{index-1mbdz3f7.js → index-mk7hrzq7.js} +9 -9
  112. package/dist/{index-1mbdz3f7.js.map → index-mk7hrzq7.js.map} +1 -1
  113. package/dist/index-n0hqgwad.js +6 -0
  114. package/dist/{index-xg7s813b.js.map → index-n0hqgwad.js.map} +2 -2
  115. package/dist/index-ncb840sk.js +6 -0
  116. package/dist/{index-mjfv7k5w.js.map → index-ncb840sk.js.map} +1 -1
  117. package/dist/{index-fbsrhcga.js → index-ntczmwnf.js} +4 -4
  118. package/dist/{index-fbsrhcga.js.map → index-ntczmwnf.js.map} +1 -1
  119. package/dist/{index-095hrkyr.js → index-p5gy5s7p.js} +4 -4
  120. package/dist/{index-095hrkyr.js.map → index-p5gy5s7p.js.map} +1 -1
  121. package/dist/{index-3c5jt6by.js → index-p86w0qjw.js} +3 -3
  122. package/dist/{index-3c5jt6by.js.map → index-p86w0qjw.js.map} +1 -1
  123. package/dist/index-qhh30m9p.js +6 -0
  124. package/dist/{index-nvc24414.js.map → index-qhh30m9p.js.map} +1 -1
  125. package/dist/{index-p6ya59m6.js → index-rerdsr3d.js} +4 -4
  126. package/dist/{index-p6ya59m6.js.map → index-rerdsr3d.js.map} +1 -1
  127. package/dist/{index-k8e9f466.js → index-s0mfq8t7.js} +19 -19
  128. package/dist/index-s0mfq8t7.js.map +11 -0
  129. package/dist/{index-3vzf253k.js → index-s9ybp2r1.js} +7 -7
  130. package/dist/{index-3vzf253k.js.map → index-s9ybp2r1.js.map} +1 -1
  131. package/dist/index-ss77hvwy.js +1246 -0
  132. package/dist/{index-hpvfqq6r.js.map → index-ss77hvwy.js.map} +32 -31
  133. package/dist/{index-jff5q27j.js → index-t9bnt6a1.js} +4 -4
  134. package/dist/{index-jff5q27j.js.map → index-t9bnt6a1.js.map} +1 -1
  135. package/dist/index-w2ss9hn5.js +9 -0
  136. package/dist/{index-eztfverw.js.map → index-w2ss9hn5.js.map} +1 -1
  137. package/dist/{index-pszmnhgq.js → index-w80shmpv.js} +9 -9
  138. package/dist/{index-pszmnhgq.js.map → index-w80shmpv.js.map} +1 -1
  139. package/dist/index-w8e8qxd4.js +337 -0
  140. package/dist/index-w8e8qxd4.js.map +21 -0
  141. package/dist/{index-308y9xt0.js → index-z9r4e0yq.js} +4 -4
  142. package/dist/{index-308y9xt0.js.map → index-z9r4e0yq.js.map} +1 -1
  143. package/dist/index-zj87j4j2.js +6 -0
  144. package/dist/index-zj87j4j2.js.map +10 -0
  145. package/dist/{index-m6fqx0ch.js → index-zmerx9rc.js} +6 -6
  146. package/dist/{index-m6fqx0ch.js.map → index-zmerx9rc.js.map} +1 -1
  147. package/dist/index-zqjtjs7c.js +153 -0
  148. package/dist/{index-dpcm1j62.js.map → index-zqjtjs7c.js.map} +2 -2
  149. package/dist/index.js +381 -368
  150. package/dist/index.js.map +7 -6
  151. package/dist/lib/launchd.d.ts.map +1 -1
  152. package/dist/lib/service-env.d.ts.map +1 -1
  153. package/dist/lib/templates.d.ts.map +1 -1
  154. package/dist/lib/theme.d.ts.map +1 -1
  155. package/dist/lib/watchdog.d.ts +20 -0
  156. package/dist/lib/watchdog.d.ts.map +1 -0
  157. package/dist/serve.d.ts.map +1 -1
  158. package/dist/skills.d.ts.map +1 -1
  159. package/dist/sources.d.ts.map +1 -1
  160. package/dist/web-zvf80ns1.js +14 -0
  161. package/dist/{web-gfv0mzgs.js.map → web-zvf80ns1.js.map} +1 -1
  162. package/dist/wire.js +11 -11
  163. package/dist/wire.js.map +4 -4
  164. package/dist/wrapper-5zhcdmnk.js +5 -0
  165. package/package.json +4 -4
  166. package/dist/APEv2Parser-ysjr6adv.js +0 -5
  167. package/dist/App-2f72vhjv.js +0 -11
  168. package/dist/AsfParser-7emspn04.js +0 -5
  169. package/dist/ConfigEditor-vk7vxaa6.js +0 -6
  170. package/dist/DsdiffParser-dz88pnnr.js +0 -5
  171. package/dist/FlacParser-drm5wq0p.js +0 -5
  172. package/dist/MP4Parser-yr7p3z12.js +0 -5
  173. package/dist/MusepackParser-6e8kbh2d.js +0 -5
  174. package/dist/OggParser-ggcypmag.js +0 -5
  175. package/dist/Picker-j7txnm7w.js +0 -5
  176. package/dist/SessionPicker-hpv2ncsb.js +0 -5
  177. package/dist/SkillBrowser-qc542n71.js +0 -5
  178. package/dist/WavPackParser-jw9stzqp.js +0 -5
  179. package/dist/WaveParser-epmncs9w.js +0 -5
  180. package/dist/WizardApp-pgzcz9zq.js +0 -5
  181. package/dist/channels-m8nambmm.js +0 -31
  182. package/dist/config-hmgrqgf2.js +0 -24
  183. package/dist/credential-nkb2ya59.js +0 -19
  184. package/dist/index-1x8mzvz7.js +0 -6
  185. package/dist/index-22fzzn7z.js +0 -10
  186. package/dist/index-323jvr1g.js +0 -6
  187. package/dist/index-3826kf9t.js +0 -7
  188. package/dist/index-38gs9anh.js +0 -9
  189. package/dist/index-42e29zs4.js +0 -6
  190. package/dist/index-836hc2h1.js +0 -6
  191. package/dist/index-8edck2pr.js +0 -6
  192. package/dist/index-8tmv33mr.js +0 -6
  193. package/dist/index-9t4dz145.js +0 -8
  194. package/dist/index-djeqvfms.js +0 -74
  195. package/dist/index-djeqvfms.js.map +0 -13
  196. package/dist/index-dpcm1j62.js +0 -153
  197. package/dist/index-dzy19wtf.js +0 -6
  198. package/dist/index-eztfverw.js +0 -9
  199. package/dist/index-fxpmx6cr.js +0 -308
  200. package/dist/index-fxpmx6cr.js.map +0 -21
  201. package/dist/index-hpvfqq6r.js +0 -1252
  202. package/dist/index-hrwakb11.js +0 -6
  203. package/dist/index-jc4kmfwa.js +0 -6
  204. package/dist/index-k8e9f466.js.map +0 -13
  205. package/dist/index-mjfv7k5w.js +0 -6
  206. package/dist/index-nvc24414.js +0 -6
  207. package/dist/index-nxhqf597.js +0 -6
  208. package/dist/index-qv6ktepc.js +0 -6
  209. package/dist/index-qv6ktepc.js.map +0 -10
  210. package/dist/index-ry6a4bqh.js +0 -126
  211. package/dist/index-sh44ymqz.js +0 -11
  212. package/dist/index-xg7s813b.js +0 -6
  213. package/dist/index-y7dxq4a4.js +0 -14
  214. package/dist/web-gfv0mzgs.js +0 -14
  215. package/dist/wrapper-f662ny3r.js +0 -5
  216. /package/dist/{APEv2Parser-ysjr6adv.js.map → APEv2Parser-rt8hyadd.js.map} +0 -0
  217. /package/dist/{FlacParser-drm5wq0p.js.map → FlacParser-rmkpvf9e.js.map} +0 -0
  218. /package/dist/{index-2zjh5zd5.js.map → index-659ggfbf.js.map} +0 -0
  219. /package/dist/{wrapper-f662ny3r.js.map → wrapper-5zhcdmnk.js.map} +0 -0
@@ -4,11 +4,11 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * Fetching a source, and reading the skills out of it. The only place in the CLI that reaches a network.\n *\n * ## Git, and the two-minute hang that shaped this file\n *\n * `git ls-remote https://github.com/github/skills` — a repository that does not exist — did not fail.\n * It sat for two minutes waiting for a credential prompt on a terminal nobody was watching, because a\n * 404 on a private-or-absent repo is indistinguishable from \"you are not logged in yet\". So every\n * invocation here runs with prompting switched off in all four ways git can be asked\n * (`GIT_TERMINAL_PROMPT`, `GIT_ASKPASS`, `SSH_ASKPASS`, `BatchMode`) **and** under a wall-clock\n * timeout. A command that cannot fail is worse than one that fails slowly.\n *\n * The user's own git config is deliberately left alone — `GIT_CONFIG_NOSYSTEM` would drop the\n * credential helper, which is exactly how a private source is meant to work.\n *\n * ## Blobless and sparse, measured\n *\n * `git clone --depth 1 --single-branch --filter=blob:none --sparse` then `sparse-checkout set <path>`.\n * On `github/awesome-copilot`: 100 MB of repository becomes 22 MB on disk in 9 s, with all 425 skills\n * present. A plain shallow clone of the same repo is the full 100 MB, for the same 425 files. The\n * filter is refused by some servers, so a failure retries without it rather than reporting one.\n *\n * ## Update is re-clone, on purpose\n *\n * One code path instead of `fetch` + `reset --hard` + reconciling sparse state, and one thing that\n * cannot happen: a cache in a half-updated shape nobody can reason about. Every fetch lands in\n * `<name>.partial` and is renamed into place only once it has worked, so an interrupted update leaves\n * the previous catalogue intact and searchable — and an interrupted *first* fetch leaves no directory\n * at all, rather than an empty repo that looks like a source with no skills in it.\n */\n\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\"\nimport { join, relative } from \"node:path\"\nimport { estimateTokens, HarnessError, parseSkillFile } from \"@dispach/core\"\nimport { cacheDir, cacheRoot, type SourceSpec } from \"#lib/sources\"\nimport { spawnCaptureAsync } from \"#lib/spawn\"\n\nconst SKILL_FILE = \"SKILL.md\"\n\n/** Long enough for a 100 MB repository on a slow link; short enough to be a failure, not a hang. */\nexport const FETCH_TIMEOUT_MS = 180_000\n\nexport interface GitResult {\n readonly code: number\n readonly stdout: string\n readonly stderr: string\n /** True when the process was killed by the timeout rather than exiting on its own. */\n readonly timedOut?: boolean\n}\n\n/**\n * Injected by the tests, which never reach a network.\n *\n * Async, and that is load-bearing rather than stylistic: `spawnSync` inside a rendered screen freezes the\n * whole app — no spinner frame advances, and the keys pressed during a twenty-second clone are echoed by\n * the tty instead of being consumed, which is how `^[[B^[[A` was printed into a fetch progress line.\n */\nexport type Git = (args: readonly string[], cwd?: string) => Promise<GitResult>\n\nexport const realGit: Git = async (args, cwd) => {\n const result = await spawnCaptureAsync({\n command: \"git\",\n args,\n ...(cwd === undefined ? {} : { cwd }),\n timeoutMs: FETCH_TIMEOUT_MS,\n maxBuffer: 32 * 1024 * 1024,\n env: {\n ...process.env,\n // All four, because each covers a different way git asks for a credential and any one left\n // open is the hang described above. The user's own git config is untouched: dropping it would\n // drop the credential helper, which is exactly how a private source is meant to work.\n GIT_TERMINAL_PROMPT: \"0\",\n GIT_ASKPASS: \"\",\n SSH_ASKPASS: \"\",\n SSH_ASKPASS_REQUIRE: \"never\",\n GIT_SSH_COMMAND: \"ssh -oBatchMode=yes -oStrictHostKeyChecking=accept-new\",\n },\n })\n if (result.notFound) {\n throw new HarnessError({\n code: \"git_missing\",\n message: \"git is not on PATH, and a skill source is a git repository\",\n hint: \"Install git — on macOS `xcode-select --install` is enough. Until then, clone a repository by hand and use `skills install <agent> <path>`.\",\n })\n }\n return {\n code: result.code,\n stdout: result.stdout,\n stderr: result.stderr,\n ...(result.signalled ? { timedOut: true } : {}),\n }\n}\n\n/** One skill as it exists in a source, before anything is copied. */\nexport interface CatalogueEntry {\n readonly source: string\n /** The frontmatter `name`, which is what it will be installed as. */\n readonly skill: string\n /** Absolute path in the cache. */\n readonly dir: string\n /** Path inside the repository, recorded as provenance on install. */\n readonly repoPath: string\n readonly description: string\n readonly tokens: number\n /** Files that would run: an executable bit, or a script extension. A trust signal, not a count. */\n readonly scripts: readonly string[]\n /** Present when the folder holds a `SKILL.md` that will not load. Listed anyway, honestly. */\n readonly problem?: string\n}\n\nexport interface SourceMeta {\n readonly commit?: string\n readonly fetchedAt?: string\n readonly skills?: number\n}\n\nfunction metaPath(name: string, env?: Readonly<Record<string, string | undefined>>): string {\n return join(cacheRoot(env), `${name}.json`)\n}\n\nexport function readMeta(\n name: string,\n env?: Readonly<Record<string, string | undefined>>,\n): SourceMeta {\n const path = metaPath(name, env)\n if (!existsSync(path)) return {}\n try {\n return JSON.parse(readFileSync(path, \"utf8\")) as SourceMeta\n } catch {\n // A corrupt meta file costs a \"never fetched\" line and nothing else; it is not worth failing\n // a listing over, and the next fetch overwrites it.\n return {}\n }\n}\n\nexport function isCached(\n name: string,\n env?: Readonly<Record<string, string | undefined>>,\n): boolean {\n return existsSync(join(cacheDir(name, env), \".git\"))\n}\n\n/**\n * True when a skill reference should be read as a path on disk instead.\n *\n * Filesystem-first, which is git's pathspec rule and the one `resolveAgentRef` already follows. The three\n * prefixes are checked *before* existence so a mistyped `./skils/pdf` is reported as a missing directory\n * rather than as an unknown skill — the two failures have completely different remedies.\n */\nexport function looksLikePath(ref: string): boolean {\n return ref.startsWith(\".\") || ref.startsWith(\"/\") || ref.startsWith(\"~\") || existsSync(ref)\n}\n\nexport interface FetchResult {\n readonly commit: string\n readonly skills: number\n /** True when the partial-clone filter was refused and a full shallow clone was used instead. */\n readonly unfiltered: boolean\n}\n\n/**\n * Clone or re-clone a source into the cache.\n *\n * Failure throws with git's own stderr attached: it is almost always the useful part — a wrong branch\n * name, a repository that needs credentials, a host that is down — and paraphrasing it would lose the\n * one sentence that says which.\n */\nexport async function fetchSource(\n spec: SourceSpec,\n options: {\n readonly env?: Readonly<Record<string, string | undefined>>\n readonly git?: Git\n } = {},\n): Promise<FetchResult> {\n const git = options.git ?? realGit\n const env = options.env\n const target = cacheDir(spec.name, env)\n const partial = `${target}.partial`\n\n mkdirSync(cacheRoot(env), { recursive: true })\n rmSync(partial, { recursive: true, force: true })\n\n const base = [\n \"clone\",\n \"--depth\",\n \"1\",\n \"--single-branch\",\n ...(spec.ref === undefined ? [] : [\"--branch\", spec.ref]),\n ]\n const sparse = spec.path !== undefined\n let unfiltered = !sparse\n let result = sparse\n ? await git([...base, \"--filter=blob:none\", \"--sparse\", spec.url, partial])\n : await git([...base, spec.url, partial])\n\n if (result.code !== 0 && sparse) {\n // Some servers refuse a partial clone. Retrying full is a bigger download, never a failure.\n rmSync(partial, { recursive: true, force: true })\n const retry = await git([...base, spec.url, partial])\n if (retry.code === 0) {\n unfiltered = true\n result = retry\n }\n }\n if (result.code !== 0) {\n rmSync(partial, { recursive: true, force: true })\n throw cloneFailed(spec, result)\n }\n\n if (spec.path !== undefined && !unfiltered) {\n const narrowed = await git([\"sparse-checkout\", \"set\", spec.path], partial)\n if (narrowed.code !== 0) {\n rmSync(partial, { recursive: true, force: true })\n throw new HarnessError({\n code: \"skill_source_path_missing\",\n message: `${spec.name}: could not narrow the checkout to ${spec.path}`,\n hint: `Check the path exists in ${spec.url}. ${narrowed.stderr.trim() || \"git said nothing.\"}`,\n })\n }\n }\n\n const head = await git([\"rev-parse\", \"--short\", \"HEAD\"], partial)\n const commit = head.code === 0 ? head.stdout.trim() : \"unknown\"\n\n rmSync(target, { recursive: true, force: true })\n renameSync(partial, target)\n\n const skills = readCatalogue(spec, env).length\n writeFileSync(\n metaPath(spec.name, env),\n `${JSON.stringify({ commit, fetchedAt: new Date().toISOString(), skills }, null, 4)}\\n`,\n )\n return { commit, skills, unfiltered }\n}\n\nfunction cloneFailed(spec: SourceSpec, result: GitResult): HarnessError {\n const said = result.stderr.trim().split(\"\\n\").slice(-3).join(\" \")\n if (result.timedOut === true) {\n return new HarnessError({\n code: \"skill_source_timeout\",\n message: `${spec.name}: git did not finish within ${Math.round(FETCH_TIMEOUT_MS / 1000)}s`,\n hint: `Check the network, then try again — a partly fetched source was discarded, so the previous copy of ${spec.name} is untouched.`,\n })\n }\n return new HarnessError({\n code: \"skill_source_fetch_failed\",\n message: `${spec.name}: could not clone ${spec.url}${said.length === 0 ? \"\" : ` — ${said}`}`,\n hint: \"A private repository needs a credential helper git can use without prompting. Check the URL and the branch; `sources remove` drops a source you no longer want.\",\n })\n}\n\n/** Depth from the scan root. Four covers `skills/<name>/`, a namespace level, and slack. */\nconst MAX_DEPTH = 4\nconst SKIPPED = new Set([\"node_modules\", \"dist\", \"build\", \"target\", \"vendor\", \".git\"])\n\nfunction skillDirs(root: string): string[] {\n const found: string[] = []\n const walk = (dir: string, depth: number): void => {\n if (depth > MAX_DEPTH) return\n let entries: readonly { name: string; isDirectory(): boolean }[]\n try {\n entries = readdirSync(dir, { withFileTypes: true })\n } catch {\n return\n }\n // A skill folder is **not** a leaf, and assuming it was hid fifteen skills on the first real run.\n // `github/awesome-copilot` nests them: `skills/qdrant-scaling/SKILL.md` is a skill and so are the\n // four inside it, three levels deep in one case. Stopping here reported 410 of 425 with nothing\n // saying which were missing.\n //\n // The cost of descending is a false positive — a `references/SKILL.md` kept as an example would be\n // listed as a skill — and that is the cheaper mistake by a wide margin: it appears in a listing\n // where a person can see it, while a false negative is a skill that simply does not exist as far\n // as this tool is concerned. `parseSkillFile` filters most of it anyway, since the spec requires\n // `name` to equal the directory.\n if (existsSync(join(dir, SKILL_FILE))) found.push(dir)\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (entry.name.startsWith(\".\") || SKIPPED.has(entry.name)) continue\n walk(join(dir, entry.name), depth + 1)\n }\n }\n walk(root, 0)\n return found.sort()\n}\n\nconst SCRIPT_EXTENSIONS = [\".py\", \".sh\", \".js\", \".ts\", \".mjs\", \".rb\", \".pl\"]\n\n/**\n * Files in a skill that would run if the model called them.\n *\n * Over-reports on purpose: a `.py` with no executable bit still runs under `python3`, and this is the\n * line a person reads before agreeing to install somebody else's folder. Under-reporting here is the\n * only failure that matters.\n */\nfunction scriptsIn(dir: string, depth = 0): string[] {\n if (depth > 3) return []\n const found: string[] = []\n let entries: readonly { name: string; isDirectory(): boolean; isFile(): boolean }[]\n try {\n entries = readdirSync(dir, { withFileTypes: true })\n } catch {\n return []\n }\n for (const entry of entries) {\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || SKIPPED.has(entry.name)) continue\n found.push(...scriptsIn(full, depth + 1))\n continue\n }\n if (!entry.isFile()) continue\n const executable = (statSync(full).mode & 0o111) !== 0\n if (executable || SCRIPT_EXTENSIONS.some((extension) => entry.name.endsWith(extension))) {\n found.push(full)\n }\n }\n return found\n}\n\n/**\n * Every skill in a fetched source.\n *\n * Reads whole files rather than only frontmatter, because the token count is a property of the body and\n * it is the number that decides whether a skill can be installed at all. 425 skills is a few megabytes.\n */\nexport function readCatalogue(\n spec: SourceSpec,\n env?: Readonly<Record<string, string | undefined>>,\n): readonly CatalogueEntry[] {\n const base = cacheDir(spec.name, env)\n const root = spec.path === undefined ? base : join(base, spec.path)\n if (!existsSync(root)) return []\n\n const entries: CatalogueEntry[] = []\n for (const dir of skillDirs(root)) {\n const raw = readFileSync(join(dir, SKILL_FILE), \"utf8\")\n const folder = dir.slice(dir.lastIndexOf(\"/\") + 1)\n const shared = {\n source: spec.name,\n dir,\n repoPath: relative(base, dir),\n scripts: scriptsIn(dir),\n }\n try {\n const parsed = parseSkillFile(folder, raw)\n entries.push({\n ...shared,\n skill: parsed.frontmatter.name,\n description: parsed.frontmatter.description,\n tokens: estimateTokens(parsed.body),\n })\n } catch (error) {\n // Listed with its problem rather than dropped — the same rule the sandbox listing follows.\n // A skill that will not load is information; a skill that silently is not there is a\n // filesystem investigation.\n entries.push({\n ...shared,\n skill: folder,\n description: \"\",\n tokens: estimateTokens(raw),\n problem: error instanceof Error ? error.message : String(error),\n })\n }\n }\n return entries\n}\n",
6
6
  "/**\n * Where skills come from: a named list of repositories, machine-level and the person's.\n *\n * ## Why this is not in `agent.yaml`\n *\n * A source is a place *you* trust, not a property of one agent. Put it in the manifest and you add a\n * repository once per agent, and — worse — you put a fetchable URL inside the document the runtime\n * loads at boot, which is an invitation to resolve it there. Hard rule 4 exists because the runtime\n * this replaces spent four minutes on network calls during initialisation. Nothing here is reachable\n * from `Runtime.create`: this module lives in the CLI, every fetch is an explicit command a person\n * typed, and the runtime's only relationship with a source is that a directory was copied before it\n * ever started.\n *\n * `skills.sources` was a manifest field reserved for this and is deliberately gone (decision 11.46).\n * A field only a CLI reads is a field the runtime will eventually be asked to read.\n *\n * ## Built-ins are compiled in, never written to the file\n *\n * `DEFAULT_SOURCES` ships in the binary. If it were seeded into `sources.json` on first run, a repo\n * that moves would stay broken until every user hand-edited a file, and an upgrade could not fix it.\n * A user entry with a built-in's name overrides it; `sources remove <builtin>` records the name in\n * `disabled` instead, because a default is an endorsement and refusing to let someone drop one would\n * make the endorsement mandatory.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { HarnessError } from \"@dispach/core\"\nimport { CURATED_COMMUNITY_SKILLS } from \"#lib/curated\"\nimport { sandboxRoot } from \"#lib/sandbox\"\n\n/** A repository to look for skills in. */\nexport interface SourceSpec {\n /**\n * The nickname you install by — `install <agent> <name>/<skill>`.\n *\n * One path segment, so it can be a directory name in the cache and cannot be confused with the\n * `owner/repo` shorthand a URL uses.\n */\n readonly name: string\n /** Anything `git clone` accepts. */\n readonly url: string\n /**\n * Subdirectory holding the skill folders, if the repo does not keep them at the root.\n *\n * Load-bearing for more than tidiness: it is what `git sparse-checkout` narrows to, and narrowing\n * took `github/awesome-copilot` from 100 MB to 22 MB (measured). With no path the whole repository\n * is checked out, so a source without one is a source that costs its full size.\n */\n readonly path?: string\n /** Branch or tag. Omitted means whatever the remote's HEAD points at. */\n readonly ref?: string\n /** Shipped rather than added. Never written to the registry file. */\n readonly builtin?: boolean\n /**\n * Folder names to show when *browsing*, or absent to show everything.\n *\n * A filter on the catalogue rather than on the checkout. Narrowing the clone was the obvious\n * optimisation and does not work: `git sparse-checkout set` given twenty `skills/<name>` paths in cone\n * mode (git 2.55) writes them as root-level patterns and materialises one folder out of twenty. The\n * whole `skills/` tree is 22 MB fetched once per machine and shared by every agent on it, which is not\n * worth a git edge case.\n *\n * Never applied to `sources search`. Curation is a recommendation, and a search that refused to find a\n * skill somebody named would make it a restriction.\n */\n readonly curated?: readonly string[]\n}\n\n/**\n * The two sources every install starts with.\n *\n * Both verified to exist, to use `skills/<name>/SKILL.md`, and to be readable without credentials on\n * 2026-08-17: `anthropics/skills` carries 18 skills, `github/awesome-copilot` 425. Deliberately short\n * — a default is an endorsement of somebody else's executable code, so the list holds the spec's own\n * authors and one large community catalogue, and everything else is `sources add`.\n */\nexport const DEFAULT_SOURCES: readonly SourceSpec[] = [\n {\n name: \"anthropic\",\n url: \"https://github.com/anthropics/skills\",\n path: \"skills\",\n builtin: true,\n },\n {\n name: \"github\",\n url: \"https://github.com/github/awesome-copilot\",\n path: \"skills\",\n builtin: true,\n // 425 skills upstream, mostly developer tooling. See `curated.ts` for what this keeps and why.\n curated: CURATED_COMMUNITY_SKILLS,\n },\n]\n\n/** One path segment, no dots, so it is safe as a cache directory and as a ref prefix. */\nconst SOURCE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\n\nexport function isSourceName(name: string): boolean {\n return name.length > 0 && name.length <= 64 && SOURCE_NAME.test(name)\n}\n\ninterface RegistryFile {\n readonly version?: number\n readonly sources?: readonly SourceSpec[]\n readonly disabled?: readonly string[]\n}\n\nconst VERSION = 1\n\nexport function registryPath(env?: Readonly<Record<string, string | undefined>>): string {\n return join(sandboxRoot(env), \"sources.json\")\n}\n\n/** Where a source's working copy is cached. One directory per source name. */\nexport function cacheRoot(env?: Readonly<Record<string, string | undefined>>): string {\n return join(sandboxRoot(env), \"sources\")\n}\n\nexport function cacheDir(name: string, env?: Readonly<Record<string, string | undefined>>): string {\n return join(cacheRoot(env), name)\n}\n\nfunction readRegistry(env?: Readonly<Record<string, string | undefined>>): RegistryFile {\n const path = registryPath(env)\n if (!existsSync(path)) return {}\n let parsed: unknown\n try {\n parsed = JSON.parse(readFileSync(path, \"utf8\"))\n } catch (error) {\n throw new HarnessError({\n code: \"skill_sources_unreadable\",\n message: `${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n hint: \"Fix the file, or delete it — the built-in sources work with no file at all.\",\n })\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n throw new HarnessError({\n code: \"skill_sources_unreadable\",\n message: `${path} does not hold a JSON object`,\n hint: `Expected {\"version\": ${VERSION}, \"sources\": [...]}. Delete the file to start from the built-in sources.`,\n })\n }\n return parsed as RegistryFile\n}\n\n/**\n * Every source `search` and `install` will look in: built-ins minus disabled, then user entries.\n *\n * Order is the resolution order for a bare skill name, so built-ins are first and a user's own\n * additions are tried after — which is also why an overriding entry keeps the built-in's position\n * rather than moving to the end.\n */\nexport function loadSources(\n env?: Readonly<Record<string, string | undefined>>,\n): readonly SourceSpec[] {\n const file = readRegistry(env)\n const added = (file.sources ?? []).filter((entry) => isSourceName(entry.name))\n const disabled = new Set(file.disabled ?? [])\n const overridden = new Map(added.map((entry) => [entry.name, entry]))\n\n const resolved: SourceSpec[] = []\n for (const builtin of DEFAULT_SOURCES) {\n if (disabled.has(builtin.name)) continue\n const override = overridden.get(builtin.name)\n resolved.push(override === undefined ? builtin : { ...override, builtin: false })\n }\n for (const entry of added) {\n if (DEFAULT_SOURCES.some((builtin) => builtin.name === entry.name)) continue\n resolved.push({ ...entry, builtin: false })\n }\n return resolved\n}\n\nfunction writeRegistry(\n file: RegistryFile,\n env?: Readonly<Record<string, string | undefined>>,\n): void {\n const path = registryPath(env)\n mkdirSync(sandboxRoot(env), { recursive: true })\n const body: RegistryFile = {\n version: VERSION,\n sources: file.sources ?? [],\n ...(file.disabled === undefined || file.disabled.length === 0\n ? {}\n : { disabled: file.disabled }),\n }\n writeFileSync(path, `${JSON.stringify(body, null, 4)}\\n`)\n}\n\nexport function addSource(\n spec: SourceSpec,\n env?: Readonly<Record<string, string | undefined>>,\n): void {\n const file = readRegistry(env)\n const kept = (file.sources ?? []).filter((entry) => entry.name !== spec.name)\n // Adding back a disabled built-in re-enables it; anything else would make `add` silently do\n // nothing for the one name most likely to be re-added.\n const disabled = (file.disabled ?? []).filter((name) => name !== spec.name)\n writeRegistry({ ...file, sources: [...kept, spec], disabled }, env)\n}\n\n/** Returns false when there was nothing by that name to remove. */\nexport function removeSource(\n name: string,\n env?: Readonly<Record<string, string | undefined>>,\n): boolean {\n const file = readRegistry(env)\n const kept = (file.sources ?? []).filter((entry) => entry.name !== name)\n const wasAdded = kept.length !== (file.sources ?? []).length\n const builtin = DEFAULT_SOURCES.some((entry) => entry.name === name)\n const already = (file.disabled ?? []).includes(name)\n if (!wasAdded && !builtin) return false\n if (builtin && already && !wasAdded) return false\n const disabled = builtin && !already ? [...(file.disabled ?? []), name] : (file.disabled ?? [])\n writeRegistry({ ...file, sources: kept, disabled }, env)\n return true\n}\n\n/**\n * What a person types for a repository, turned into a clone URL and — where the URL says so — a ref\n * and a path.\n *\n * The browser URL case is the one that has to work: someone finding a skill collection pastes\n * `https://github.com/anthropics/skills/tree/main/skills`, which is not a clone URL and carries two\n * fields inside its path. Refusing it would mean the documented way to add a source is to hand-edit\n * what GitHub put in the address bar.\n */\nexport function parseSourceUrl(input: string): {\n readonly url: string\n readonly ref?: string\n readonly path?: string\n} {\n const trimmed = input.trim()\n if (trimmed.length === 0) throw badUrl(input)\n\n // `owner/repo` — the shorthand every git front end accepts. Two segments exactly, so it cannot\n // swallow a path that was meant as one.\n if (/^[\\w.-]+\\/[\\w.-]+$/.test(trimmed)) {\n return { url: `https://github.com/${trimmed.replace(/\\.git$/, \"\")}` }\n }\n\n if (trimmed.startsWith(\"git@\") || trimmed.startsWith(\"ssh://\")) return { url: trimmed }\n\n let parsed: URL\n try {\n parsed = new URL(trimmed)\n } catch {\n throw badUrl(input)\n }\n if (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") throw badUrl(input)\n\n const segments = parsed.pathname.split(\"/\").filter((segment) => segment.length > 0)\n const cut = segments.findIndex((segment) => segment === \"tree\" || segment === \"blob\")\n if (cut < 2) {\n return { url: `${parsed.origin}/${segments.join(\"/\")}`.replace(/\\.git$/, \"\") }\n }\n const repo = segments.slice(0, cut).join(\"/\")\n const ref = segments[cut + 1]\n const path = segments.slice(cut + 2).join(\"/\")\n return {\n url: `${parsed.origin}/${repo}`.replace(/\\.git$/, \"\"),\n ...(ref === undefined ? {} : { ref }),\n ...(path.length === 0 ? {} : { path }),\n }\n}\n\nfunction badUrl(input: string): HarnessError {\n return new HarnessError({\n code: \"skill_source_url_invalid\",\n message: `${JSON.stringify(input)} is not a repository`,\n hint: \"Accepted: owner/repo, an https:// clone URL, a git@ SSH URL, or the page URL you were reading — .../tree/<branch>/<subdir> is understood.\",\n })\n}\n\n/** A skill reference as typed: `pdf`, or `anthropic/pdf`. */\nexport interface SkillRef {\n readonly source?: string\n readonly skill: string\n}\n\nexport function parseSkillRef(input: string): SkillRef {\n const parts = input.split(\"/\").filter((part) => part.length > 0)\n if (parts.length === 1) return { skill: parts[0] as string }\n if (parts.length === 2) return { source: parts[0] as string, skill: parts[1] as string }\n throw new HarnessError({\n code: \"skill_ref_invalid\",\n message: `${JSON.stringify(input)} is neither a skill name nor <source>/<skill>`,\n hint: \"Use `pdf` to search every source, or `anthropic/pdf` to name one. A path is taken as a path only if it exists on disk.\",\n })\n}\n",
7
- "/**\n * `skills list|show|validate <manifest>` — what this agent knows how to do, and how well it is written.\n *\n * Three questions, deliberately not one command. `list` is the inventory, `show` is one skill in full —\n * including the parts the model never sees, which is the only way to check what it *will* see — and\n * `validate` is the authoring read.\n *\n * `validate` warns and exits 0, with `--strict` for CI. That is the `workspace` split rather than the\n * `validate` one: a skill that does not load already fails here loudly, because this calls the same\n * `loadSkills` the runtime does, and everything past that is a judgement. In particular a missing\n * when-not-to-use is a warning and never a refusal — requiring it would reject every skill vendored from\n * `anthropics/skills` and withdraw decision 6.1's compliance claim to buy a nag.\n *\n * A `ScriptRunner` is supplied here for the same reason `run` supplies one: without it a skill's\n * `scripts/` is never scanned, so `skills list` would report \"no scripts\" for a skill that ships three.\n * The command answers about the runtime, not about a subset of it.\n */\n\nimport {\n cpSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\"\nimport { basename, isAbsolute, join, relative, resolve } from \"node:path\"\nimport {\n checkSkillAuthoring,\n type ErrorDetail,\n editManifestSync,\n isHarnessError,\n isSkillName,\n loadManifest,\n loadSkills,\n nearest,\n parseSkillFile,\n resolveCapabilities,\n type Skill,\n type SkillsConfig,\n whenNotToUseKey,\n} from \"@dispach/core\"\nimport { ambientEnv } from \"#lib/ambient\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport { forgetOrigin, type Origin, readOrigins, recordOrigins } from \"#lib/origins\"\nimport { scriptRunner } from \"#lib/providers\"\nimport { bullet, indent, keyValue, section } from \"#lib/render\"\nimport {\n type CatalogueEntry,\n isCached,\n looksLikePath,\n readCatalogue,\n readMeta,\n} from \"#lib/source-cache\"\nimport { loadSources, parseSkillRef, type SkillRef, type SourceSpec } from \"#lib/sources\"\nimport { fillTemplate, SKILL_TEMPLATE } from \"#lib/templates\"\n\n/** A skill found in a fetched source, with everything provenance needs. */\ninterface Located {\n readonly entry: CatalogueEntry\n readonly spec: SourceSpec\n readonly commit: string\n}\n\nconst SKILL_FILE = \"SKILL.md\"\n\n/**\n * The actions this command accepts, pinned so `--help` and the switch below cannot drift.\n *\n * The same guard `DAEMON_ACTIONS` gets: a verb added in one place and not the other fails a test rather\n * than at the moment somebody types it.\n */\nexport const SKILLS_ACTIONS = [\"list\", \"show\", \"new\", \"install\", \"remove\", \"validate\"] as const\n\nexport interface SkillsOptions {\n readonly manifestPath: string\n /** `list`, `show` or `validate`. Checked by the dispatcher against the spec's `choices`. */\n readonly action: string\n /**\n * The skill `show`, `new` and `remove` act on — or, for `install`, the directory to copy from.\n *\n * One positional rather than three, because the parser has one slot after the manifest and a\n * command with `--name`, `--from` and `--skill` flags reads worse than the thing it replaced.\n */\n readonly name?: string\n readonly json?: boolean\n /** `validate` only: exit non-zero when anything was reported. */\n readonly strict?: boolean\n /**\n * The `<ENVPREFIX>HOME` override that says where the source registry and cache live.\n *\n * Deliberately **not** the manifest environment — that one is `ambientEnv` below and answers \"which\n * model, which key\". This one answers \"which `sources.json`\", and it exists because `install` resolves\n * a `<source>/<skill>` ref against it: without the field, this command read the real home directory\n * while its caller read a sandbox, so an install driven from a test or from `init` looked up a\n * registry nobody had written to and reported `no source called test` on a source that plainly existed.\n */\n readonly sandboxEnv?: Readonly<Record<string, string | undefined>>\n /**\n * Extra variables layered on top of the resolved manifest environment.\n *\n * One caller: `init`, which stubs the API key variable it has just written as an empty line. Without\n * it, installing a skill during setup failed with `model.main.apiKeyEnv names MODEL_API_KEY, which is\n * not set` — correct, useless, and about a key nobody could have filled in yet. `init`'s own load\n * check has always done this; the command it calls needed the same courtesy.\n */\n readonly envOverlay?: Readonly<Record<string, string | undefined>>\n /**\n * Report nothing and let the caller summarise. Set by a batch install.\n *\n * Eleven ticked skills produced **eleven** `from/installed/this installed code/next` blocks — a screenful\n * of repeated narrative for one action, which is what \"the TUI should be everything\" was objecting to.\n * The per-skill report is right for `skills install <one>` and wrong the moment there are eleven, so the\n * caller decides. `collect` is how it gets the facts it needs to write one summary instead.\n */\n readonly quiet?: boolean\n /** Appended to, when given: what happened to each skill this call touched. */\n readonly collect?: InstallOutcome[]\n}\n\n/** What one install did, for a caller aggregating several. */\nexport interface InstallOutcome {\n readonly name: string\n readonly ok: boolean\n /** Why not, when `ok` is false. */\n readonly reason?: string\n /** Files that would run, relative to the skills directory. */\n readonly runnable: readonly string[]\n}\n\nexport function skillsCommand(options: SkillsOptions): number {\n try {\n const loaded = loadManifest(options.manifestPath, {\n // The same environment `run` uses, or this reports on a different agent — the asymmetry\n // every command that loads a manifest exists to avoid.\n env: { ...ambientEnv([options.manifestPath]), ...options.envOverlay },\n })\n\n // `new` and `install` are the two that may run with nothing configured — turning skills on is\n // exactly what they are for, so they do it rather than reporting that it has not been done.\n const creating = options.action === \"new\" || options.action === \"install\"\n const configured = creating\n ? enable(loaded.path, loaded.dir, loaded.manifest.skills)\n : loaded.manifest.skills\n if (configured === undefined) {\n return unconfigured(options)\n }\n\n const capabilities = resolveCapabilities(\n loaded.manifest.model.main.id,\n loaded.manifest.model.main.capabilities,\n )\n const resolvedDir = isAbsolute(configured.dir)\n ? configured.dir\n : resolve(loaded.dir, configured.dir)\n\n // `new` and `remove` run **before** the catalogue is loaded, and that ordering is the fix for a\n // dead end this command had: a skill over `skills.budget` fails the load, so with `remove` behind\n // `loadSkills` the one command that could undo it was the one that could not run. Neither needs a\n // catalogue — one writes a directory, the other deletes one — so neither waits for it.\n if (options.action === \"new\") return create(resolvedDir, options)\n if (options.action === \"remove\") return remove(resolvedDir, options)\n\n const catalogue = loadSkills({\n dir: resolvedDir,\n maxActive: configured.maxActive,\n threshold: configured.threshold,\n style: capabilities.promptStyle,\n agentDir: loaded.dir,\n runner: scriptRunner(),\n })\n\n switch (options.action) {\n case \"list\":\n return list(resolvedDir, catalogue.skills, catalogue, options)\n case \"show\":\n return show(catalogue.skills, options)\n case \"install\":\n return install(resolvedDir, options)\n default:\n // `validate` is the fallback rather than a named case because the parser has already\n // rejected anything outside `SKILLS_ACTIONS`, and the safest thing to do with an action\n // that somehow got through is the one that changes nothing.\n return validate(catalogue.skills, options)\n }\n } catch (error) {\n if (options.json === true && isHarnessError(error)) {\n process.stdout.write(\n `${JSON.stringify({ ok: false, error: error.toDetail(), details: error.details }, null, 2)}\\n`,\n )\n return EXIT_FAILURE\n }\n throw error\n }\n}\n\n/**\n * No `skills:` block at all.\n *\n * Not an error — an agent without skills is an ordinary agent — but it names the block, because someone\n * who typed this command was looking for something and \"no skills\" without a way forward is the shape\n * decision 4.53 objects to.\n */\nfunction unconfigured(options: SkillsOptions): number {\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify({ ok: true, configured: false, skills: [] }, null, 2)}\\n`,\n )\n return EXIT_OK\n }\n // Two commands, not a YAML fragment. This used to print the block to add by hand, which is the\n // workaround `skills new` was built to remove — and it kept printing it for a phase after that\n // command existed, so the one place someone lands when looking for skills was the one place still\n // recommending the manual edit.\n process.stdout.write(\n \"this agent has no skills configured\\n\\n\" +\n \" · find one and install it — searches the catalogues, 440+ skills:\\n\" +\n \" sources search <what it should do>\\n\" +\n ` skills install ${options.manifestPath} <source>/<skill>\\n\\n` +\n \" · or write your own from a template:\\n\" +\n ` skills new ${options.manifestPath} <name>\\n\\n` +\n \" either one turns skills on for this agent; neither needs agent.yaml edited by hand\\n\",\n )\n return EXIT_OK\n}\n\nfunction list(\n dir: string,\n skills: readonly Skill[],\n catalogue: {\n readonly maxActive: number\n readonly threshold: number\n readonly cached: boolean\n },\n options: SkillsOptions,\n): number {\n // Read here rather than inside the loop: one file for the whole directory, and a listing that opened\n // it per skill would be doing filesystem work proportional to a catalogue it already has in memory.\n const origins = readOrigins(dir)\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n configured: true,\n cached: catalogue.cached,\n maxActive: catalogue.maxActive,\n threshold: catalogue.threshold,\n skills: skills.map((skill) => ({\n ...summarise(skill),\n ...(origins[skill.name] === undefined\n ? {}\n : { origin: origins[skill.name] }),\n })),\n },\n null,\n 2,\n )}\\n`,\n )\n return EXIT_OK\n }\n\n if (skills.length === 0) {\n process.stdout.write(\n `no skills in ${dir}\\n\\n \\`sources search <what it should do>\\` ranks 440+ from the configured catalogues, then\\n \\`skills install <agent> <source>/<skill>\\`. \\`skills new <agent> <name>\\` writes one from a template.\\n`,\n )\n return EXIT_OK\n }\n\n process.stdout.write(\n `${keyValue([\n { label: \"skills\", value: String(skills.length) },\n { label: \"per turn\", value: `at most ${catalogue.maxActive}` },\n { label: \"threshold\", value: catalogue.threshold.toFixed(2) },\n { label: \"index\", value: catalogue.cached ? \"cached\" : \"scanned\" },\n ])}\\n`,\n )\n\n process.stdout.write(`${section(\"catalogue\")}\\n`)\n for (const skill of skills) {\n const scripts = skill.scripts.length === 0 ? \"\" : ` ${skill.scripts.length} script(s)`\n // A missing negative guidance is flagged even in `list`, because it is the one thing that is\n // both cheap to fix and invisible until something routes wrongly.\n const gap = skill.frontmatter.whenNotToUse === undefined ? \" no when-not-to-use\" : \"\"\n // Where it came from, on the line that lists it. The origins file is hidden by a leading dot to\n // stay out of the way; that must not make it hidden *information*.\n const origin = origins[skill.name]\n const from = origin === undefined ? \"\" : ` ${origin.source}@${origin.commit}`\n process.stdout.write(\n ` ${skill.name.padEnd(20)} ${String(skill.tokens).padStart(5)} tokens${scripts}${from}${gap}\\n`,\n )\n }\n return EXIT_OK\n}\n\nfunction show(skills: readonly Skill[], options: SkillsOptions): number {\n const wanted = options.name\n if (wanted === undefined) {\n process.stdout.write(\"skills show needs a skill name — `skills list` names them\\n\")\n return EXIT_FAILURE\n }\n const skill = skills.find((entry) => entry.name === wanted)\n if (skill === undefined) {\n const known = skills.map((entry) => entry.name).join(\", \")\n process.stdout.write(`no skill named ${wanted}${known === \"\" ? \"\" : `. Known: ${known}`}\\n`)\n return EXIT_FAILURE\n }\n\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify({ ok: true, skill: detail(skill) }, null, 2)}\\n`)\n return EXIT_OK\n }\n\n const { frontmatter } = skill\n process.stdout.write(\n `${keyValue([\n { label: \"name\", value: skill.name },\n { label: \"directory\", value: skill.dir },\n { label: \"body\", value: `${skill.tokens} tokens` },\n ...(frontmatter.license === undefined\n ? []\n : [{ label: \"license\", value: frontmatter.license }]),\n ...(frontmatter.compatibility === undefined\n ? []\n : [{ label: \"needs\", value: frontmatter.compatibility }]),\n ])}\\n`,\n )\n\n process.stdout.write(`${section(\"description\")}\\n`)\n process.stdout.write(`${indent(frontmatter.description)}\\n`)\n\n process.stdout.write(`${section(\"when not to use\")}\\n`)\n process.stdout.write(\n `${indent(\n frontmatter.whenNotToUse ??\n `not declared — add metadata.${whenNotToUseKey()} to improve routing`,\n )}\\n`,\n )\n\n if (skill.scripts.length > 0) {\n process.stdout.write(`${section(\"scripts\")}\\n`)\n for (const plan of skill.scripts) {\n process.stdout.write(\n `${bullet(`${plan.slug} — scripts/${plan.file} via ${plan.interpreter ?? \"its own shebang\"}`)}\\n`,\n )\n }\n }\n\n if (skill.ignoredScripts.length > 0) {\n process.stdout.write(`${section(\"in scripts/ and not runnable\")}\\n`)\n for (const ignored of skill.ignoredScripts) {\n process.stdout.write(`${bullet(`${ignored.file} — ${ignored.reason}`)}\\n`)\n }\n }\n\n if (frontmatter.allowedTools !== undefined) {\n process.stdout.write(`${section(\"allowed-tools, declared and not honoured\")}\\n`)\n // Printed rather than ignored, and labelled rather than merely printed. A downloaded folder does\n // not widen what this agent may run — that is `tools.policy`, and only a person edits it.\n process.stdout.write(`${indent(frontmatter.allowedTools)}\\n`)\n process.stdout.write(\n `${indent(\"this runtime reads the field and never acts on it; permissions live in tools.policy\")}\\n`,\n )\n }\n\n const extra = Object.entries(frontmatter.metadata).filter(([key]) => key !== whenNotToUseKey())\n if (extra.length > 0) {\n process.stdout.write(`${section(\"metadata\")}\\n`)\n process.stdout.write(`${keyValue(extra.map(([label, value]) => ({ label, value })))}\\n`)\n }\n\n return EXIT_OK\n}\n\nfunction validate(skills: readonly Skill[], options: SkillsOptions): number {\n const findings = checkSkillAuthoring(skills)\n\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify(\n { ok: findings.length === 0, skills: skills.map(summarise), findings },\n null,\n 2,\n )}\\n`,\n )\n return options.strict === true && findings.length > 0 ? EXIT_FAILURE : EXIT_OK\n }\n\n // Every skill is named whether or not it has findings, so a clean one is visibly checked rather\n // than merely absent from a list of problems.\n const byName = new Map<string, ErrorDetail[]>()\n for (const finding of findings) {\n const name = skills.find((skill) => finding.message.includes(` ${skill.name}:`))?.name\n const key = name ?? \"\"\n byName.set(key, [...(byName.get(key) ?? []), finding])\n }\n\n for (const skill of skills) {\n const own = byName.get(skill.name) ?? []\n process.stdout.write(\n ` ${skill.name.padEnd(20)} ${own.length === 0 ? \"ok\" : `${own.length} warning(s)`}\\n`,\n )\n }\n\n if (findings.length === 0) {\n process.stdout.write(\"\\nno findings\\n\")\n return EXIT_OK\n }\n\n for (const finding of findings) {\n process.stdout.write(`\\n ${finding.code}: ${finding.message}\\n`)\n process.stdout.write(` hint: ${finding.hint}\\n`)\n }\n process.stdout.write(\n `\\n${findings.length} finding(s) — warnings, not failures. --strict exits non-zero.\\n`,\n )\n return options.strict === true ? EXIT_FAILURE : EXIT_OK\n}\n\nfunction summarise(skill: Skill) {\n return {\n name: skill.name,\n tokens: skill.tokens,\n hasWhenNotToUse: skill.frontmatter.whenNotToUse !== undefined,\n scripts: skill.scripts.map((plan) => plan.slug),\n ignoredScripts: skill.ignoredScripts,\n }\n}\n\nfunction detail(skill: Skill) {\n return {\n ...summarise(skill),\n dir: skill.dir,\n description: skill.frontmatter.description,\n ...(skill.frontmatter.whenNotToUse === undefined\n ? {}\n : { whenNotToUse: skill.frontmatter.whenNotToUse }),\n ...(skill.frontmatter.license === undefined ? {} : { license: skill.frontmatter.license }),\n ...(skill.frontmatter.compatibility === undefined\n ? {}\n : { compatibility: skill.frontmatter.compatibility }),\n ...(skill.frontmatter.allowedTools === undefined\n ? {}\n : { allowedToolsDeclaredNotHonoured: skill.frontmatter.allowedTools }),\n metadata: skill.frontmatter.metadata,\n }\n}\n\n// ─── writing ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Turn skills on for an agent that has not got them, and return the resolved config.\n *\n * Both halves or neither: `skills.dir` naming a directory that does not exist is a **load failure**, so\n * writing the block without creating the directory would leave an agent that refuses to start. That is\n * the reason this is a command rather than a `config_set` path — the agent cannot be trusted to do two\n * things atomically, and it is exactly the shape that made `config_set` report a pending `tokenEnv`.\n *\n * The manifest goes through `editManifest`, the one writer every surface uses. It used to place the\n * block itself and write it unvalidated, on the reasoning that \"the next load\" would catch a bad\n * result — which is the failure that validation exists to prevent, because the next load is a person's\n * agent refusing to start after this command reported success. The block is a fixed known-good shape,\n * so nothing was ever actually broken; the *guarantee* differed by which caller you happened to be.\n *\n * The uncommenting this used to do itself is `uncommentInSource` now, reached automatically for a\n * top-level path: `setInSource` appends to a parent and `skills` has none, so it declines, and the\n * generated manifest ships the line commented under its own heading. Generalising it was worth doing —\n * `channels` needed exactly the same thing, and writing it for the first time had been reflowing 98\n * lines of somebody's manifest.\n */\nfunction enable(\n manifestPath: string,\n agentDir: string,\n existing: SkillsConfig | undefined,\n): SkillsConfig | undefined {\n const dir = existing?.dir ?? \"./skills\"\n const absolute = isAbsolute(dir) ? dir : resolve(agentDir, dir)\n mkdirSync(absolute, { recursive: true })\n\n if (existing !== undefined) return existing\n\n const written = editManifestSync({ file: manifestPath, path: [\"skills\"], value: block(dir) })\n process.stdout.write(`${keyValue([{ label: \"enabled\", value: `skills.dir = ${dir}` }])}\\n`)\n if (written.reflowed) {\n // Said rather than swallowed. A manifest with no commented `# skills:` line to uncomment — a\n // hand-written one — goes through the round-trip, which is valid and moves comments, and\n // finding that in a later `git diff` with nothing having mentioned it is the worse outcome.\n process.stdout.write(\n `${bullet(\"the file was re-serialised to add the block — it is valid, and comments may have moved\")}\\n`,\n )\n }\n // Validated before it was written, so this is a resolved config rather than an assumption.\n return { dir, ...DEFAULTS }\n}\n\n/** Written once, so what is stored and what is printed cannot disagree. */\nconst DEFAULTS = { maxActive: 1, threshold: 0.35 } as const\n\nfunction block(dir: string): Record<string, unknown> {\n return { dir, ...DEFAULTS }\n}\n\nfunction create(dir: string, options: SkillsOptions): number {\n const name = options.name\n if (name === undefined) {\n process.stdout.write(\"skills new needs a name — `skills new <manifest> <name>`\\n\")\n return EXIT_FAILURE\n }\n if (!isSkillName(name)) {\n // The spec's own rule, checked here so a scaffold the loader would refuse is never written.\n process.stdout.write(\n `${name} is not a legal skill name: lowercase letters, digits and single hyphens, never leading, trailing or doubled, at most 64 characters.\\n`,\n )\n return EXIT_FAILURE\n }\n\n const target = join(dir, name)\n if (existsSync(target)) {\n process.stdout.write(`${target} already exists — nothing was written\\n`)\n return EXIT_FAILURE\n }\n\n mkdirSync(target, { recursive: true })\n writeFileSync(\n join(target, \"SKILL.md\"),\n fillTemplate(SKILL_TEMPLATE, {\n SKILL_NAME: name,\n WHEN_NOT_TO_USE_KEY: whenNotToUseKey(),\n }),\n \"utf8\",\n )\n\n process.stdout.write(\n `${keyValue([\n { label: \"created\", value: join(target, \"SKILL.md\") },\n { label: \"name\", value: name },\n ])}\\n`,\n )\n process.stdout.write(\n `${section(\"next\")}\\n` +\n `${bullet(\"edit the description — it is the only thing selection reads, so name the words someone would actually type\")}\\n` +\n `${bullet(\"write the steps in place of the placeholder body\")}\\n` +\n `${bullet(`skills validate — it warns until the scaffold is replaced`)}\\n` +\n `${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`,\n )\n return EXIT_OK\n}\n\n/**\n * Copy a skill, or a directory of skills, into this agent.\n *\n * A **local path only**, and that is a decision rather than an unfinished feature. A skill may ship\n * executable scripts, so installing one from a URL is running someone else's code on this machine — a\n * thing that deserves its own decision about provenance and trust, not a flag added beside a copy\n * command. `git clone` or `gh repo clone` first, then install from the path; the network stays out of a\n * command whose job is to move files.\n *\n * Modes are preserved, because an executable bit is what makes a script runnable at all.\n */\nfunction install(dir: string, options: SkillsOptions): number {\n const from = options.name\n if (from === undefined) {\n process.stdout.write(\n \"skills install needs something to install — `skills install <manifest> anthropic/pdf`, or a local path\\n\\n `sources search <what you need>` finds one.\\n\",\n )\n return EXIT_FAILURE\n }\n\n // Filesystem-first, which is git's pathspec rule and the one `resolveAgentRef` already follows: a\n // name shadowed by a directory in the cwd resolves to the directory, with a note, rather than\n // silently installing something else.\n const asPath = looksLikePath(from)\n let origin: Located | undefined\n if (!asPath) {\n const located = locate(from, options.sandboxEnv)\n if (located === undefined) return EXIT_FAILURE\n origin = located\n }\n\n const source = origin === undefined ? resolve(from) : origin.entry.dir\n if (origin === undefined) {\n if (!existsSync(source) || !statSync(source).isDirectory()) {\n process.stdout.write(`${source} is not a directory\\n`)\n return EXIT_FAILURE\n }\n if (\n existsSync(from) &&\n loadSources(options.sandboxEnv).some((spec) => spec.name === from)\n ) {\n process.stdout.write(\n `note: ${from} is also a source, and a directory of that name here wins — \\`sources search\\` to install from the source instead\\n\\n`,\n )\n }\n }\n\n const origins: Record<string, Origin> = {}\n const runnable: string[] = []\n\n // One skill, or a folder holding several. Detected rather than flagged: `skills/` from a cloned\n // repository and a single `pdf/` are both obvious to look at, and asking which would be a question\n // the filesystem has already answered.\n const single = existsSync(join(source, SKILL_FILE))\n const candidates = single\n ? [source]\n : readdirSync(source, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(source, entry.name, SKILL_FILE)),\n )\n .map((entry) => join(source, entry.name))\n\n if (candidates.length === 0) {\n process.stdout.write(\n `no ${SKILL_FILE} in ${source} or in any directory directly inside it\\n`,\n )\n return EXIT_FAILURE\n }\n\n const installed: string[] = []\n const skipped: string[] = []\n for (const candidate of candidates) {\n // The destination is the skill's declared `name`, not the source folder's — the spec requires\n // them to match, so a mismatched source is a skill that would fail to load wherever it landed.\n let name: string\n try {\n const parsed = parseSkillFile(\n basename(candidate),\n readFileSync(join(candidate, SKILL_FILE), \"utf8\"),\n )\n name = parsed.frontmatter.name\n } catch (error) {\n skipped.push(\n `${basename(candidate)} — ${error instanceof Error ? error.message : String(error)}`,\n )\n continue\n }\n const target = join(dir, name)\n if (existsSync(target)) {\n skipped.push(`${name} — already installed at ${target}`)\n continue\n }\n // No size check. There was one, against `skills.budget`, and it is what turned a person ticking\n // eleven skills into \"9 of 11 installed\" — refusing `pptx` at 5,441 tokens and `skill-creator` at\n // 9,065 against a default of 5,000 they never chose. The budget is gone (decision 11.59): the\n // catalogue prints every body's size on the row where the choice is made, and a large skill that\n // somebody picked on purpose is not a configuration error.\n cpSync(candidate, target, { recursive: true, preserveTimestamps: true })\n installed.push(name)\n if (origin !== undefined) {\n origins[name] = {\n source: origin.spec.name,\n url: origin.spec.url,\n repoPath: origin.entry.repoPath,\n commit: origin.commit,\n ...(origin.spec.ref === undefined ? {} : { ref: origin.spec.ref }),\n installedAt: new Date().toISOString(),\n }\n }\n // Named, not counted. This is the only moment somebody can decide to go and read code they are\n // about to give an agent, and \"3 runnable files\" does not tell them which files.\n runnable.push(...scriptFiles(target).map((file) => `${name}/${relative(target, file)}`))\n }\n\n if (Object.keys(origins).length > 0) recordOrigins(dir, origins)\n\n if (options.collect !== undefined) {\n for (const name of installed) {\n options.collect.push({\n name,\n ok: true,\n runnable: runnable.filter((file) => file.startsWith(`${name}/`)),\n })\n }\n for (const entry of skipped) {\n const cut = entry.indexOf(\" — \")\n options.collect.push({\n name: cut === -1 ? entry : entry.slice(0, cut),\n ok: false,\n reason: cut === -1 ? entry : entry.slice(cut + 3),\n runnable: [],\n })\n }\n }\n if (options.quiet === true) return installed.length === 0 ? EXIT_FAILURE : EXIT_OK\n\n process.stdout.write(\n `${keyValue([\n {\n label: \"from\",\n value:\n origin === undefined\n ? source\n : `${origin.spec.name} (${origin.spec.url}) at ${origin.commit}`,\n },\n { label: \"installed\", value: installed.join(\", \") },\n { label: \"skipped\", value: skipped.length === 0 ? \"\" : String(skipped.length) },\n ])}\\n`,\n )\n for (const entry of skipped) process.stdout.write(`${bullet(entry)}\\n`)\n if (runnable.length > 0) {\n // Disclosure rather than a prompt. Nothing runs at install time — a skill script becomes a tool\n // only once the skill activates, and it arrives `untrusted` and `mutating`, so the write gate and\n // `tools.policy` both still apply. A confirmation dialog on every install would be answered\n // reflexively within a week and would buy none of that.\n process.stdout.write(\n `${section(\"this installed code, which the agent can run\")}\\n${runnable\n .slice(0, 12)\n .map((file) => bullet(file))\n .join(\"\\n\")}\\n`,\n )\n if (runnable.length > 12) {\n process.stdout.write(`${indent(`… and ${runnable.length - 12} more`)}\\n`)\n }\n process.stdout.write(\n `${indent(\"read them before the agent does; `tools.policy` can name a skill script by slug\")}\\n`,\n )\n }\n if (installed.length > 0) {\n process.stdout.write(\n `${section(\"next\")}\\n${bullet(\"skills validate — a vendored skill usually has no negative guidance, which is a warning and not a problem\")}\\n${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`,\n )\n }\n return installed.length === 0 ? EXIT_FAILURE : EXIT_OK\n}\n\n/**\n * Turn `pdf` or `anthropic/pdf` into a folder in the source cache.\n *\n * Ambiguity is refused rather than resolved by source order: with two sources carrying a `pdf`, picking\n * the first would install one and report a name that describes both, and the person would find out which\n * they got by reading the file. Naming the candidates costs one retyped command and cannot be wrong.\n */\nfunction locate(\n ref: string,\n env?: Readonly<Record<string, string | undefined>>,\n): Located | undefined {\n let parsed: SkillRef\n try {\n parsed = parseSkillRef(ref)\n } catch (error) {\n if (!isHarnessError(error)) throw error\n process.stdout.write(`${error.message}\\n\\n ${error.hint}\\n`)\n return undefined\n }\n\n const sources = loadSources(env)\n const named =\n parsed.source === undefined\n ? sources\n : sources.filter((spec) => spec.name === parsed.source)\n if (named.length === 0) {\n const suggestion = nearest(\n parsed.source ?? \"\",\n sources.map((spec) => spec.name),\n )\n process.stdout.write(\n `no source called ${parsed.source}\\n\\n ${suggestion === undefined ? \"`sources list` shows them.\" : `Did you mean ${suggestion}?`}\\n`,\n )\n return undefined\n }\n\n const cold = named.filter((spec) => !isCached(spec.name, env))\n if (cold.length === named.length) {\n // The distinction that matters: an empty cache is not a mistyped name, and only this layer knows\n // which. Reporting \"no skill called pdf\" against a cache that has never been fetched blames the\n // person for the tool's state — the same failure `explainUnresolved` exists to prevent.\n process.stdout.write(\n `${named.length === 1 ? `${named[0]?.name} has not` : \"no source has\"} been fetched yet, so there is nothing to install from\\n\\n \\`sources update${parsed.source === undefined ? \"\" : ` ${parsed.source}`}\\` first, or \\`sources search ${parsed.skill}\\` which fetches on demand.\\n`,\n )\n return undefined\n }\n\n const entries = named\n .filter((spec) => isCached(spec.name, env))\n .flatMap((spec) => readCatalogue(spec, env).map((entry) => ({ entry, spec })))\n const matches = entries.filter((row) => row.entry.skill === parsed.skill)\n\n if (matches.length === 0) {\n const suggestion = nearest(\n parsed.skill,\n entries.map((row) => row.entry.skill),\n )\n process.stdout.write(\n `no skill called ${parsed.skill} in ${named.map((spec) => spec.name).join(\", \")}\\n\\n ${\n suggestion === undefined\n ? `\\`sources search ${parsed.skill}\\` ranks what is there.`\n : `Did you mean ${suggestion}? \\`sources search ${parsed.skill}\\` ranks the alternatives.`\n }\\n`,\n )\n return undefined\n }\n if (matches.length > 1) {\n process.stdout.write(\n `${matches.length} sources carry a skill called ${parsed.skill}\\n\\n${matches\n .map((row) => ` ${row.spec.name}/${row.entry.skill} — ${row.spec.url}\\n`)\n .join(\"\")}\\n Name one.\\n`,\n )\n return undefined\n }\n\n const only = matches[0] as { entry: CatalogueEntry; spec: SourceSpec }\n if (only.entry.problem !== undefined) {\n process.stdout.write(\n `${only.spec.name}/${only.entry.skill} will not load: ${only.entry.problem}\\n\\n Nothing was copied. That is upstream's to fix — installing a hand-edited copy from a path is the way round it.\\n`,\n )\n return undefined\n }\n return {\n entry: only.entry,\n spec: only.spec,\n commit: readMeta(only.spec.name, env).commit ?? \"unknown\",\n }\n}\n\n/** Files under an installed skill that would run. Same over-reporting rule as the catalogue's. */\nfunction scriptFiles(dir: string, depth = 0): string[] {\n if (depth > 3) return []\n const found: string[] = []\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\")) continue\n found.push(...scriptFiles(full, depth + 1))\n continue\n }\n if (!entry.isFile()) continue\n const executable = (statSync(full).mode & 0o111) !== 0\n if (executable || SCRIPT_EXTENSIONS.some((extension) => entry.name.endsWith(extension))) {\n found.push(full)\n }\n }\n return found\n}\n\nconst SCRIPT_EXTENSIONS = [\".py\", \".sh\", \".js\", \".ts\", \".mjs\", \".rb\", \".pl\"]\n\n/**\n * Deletes files, and says what it removed rather than only that it did.\n *\n * Reads the directory rather than the catalogue on purpose — see the ordering note at the call site. A\n * skill that breaks the load is precisely the skill someone needs to remove.\n */\nfunction remove(dir: string, options: SkillsOptions): number {\n const name = options.name\n if (name === undefined) {\n process.stdout.write(\"skills remove needs a name — `skills list` names them\\n\")\n return EXIT_FAILURE\n }\n const target = join(dir, name)\n if (!existsSync(join(target, SKILL_FILE))) {\n const known = existsSync(dir)\n ? readdirSync(dir, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(dir, entry.name, SKILL_FILE)),\n )\n .map((entry) => entry.name)\n .join(\", \")\n : \"\"\n process.stdout.write(`no skill named ${name}${known === \"\" ? \"\" : `. Known: ${known}`}\\n`)\n return EXIT_FAILURE\n }\n\n // Counted before the delete, so the report is about what was actually there rather than a guess.\n const files = countFiles(target)\n const origin = readOrigins(dir)[name]\n rmSync(target, { recursive: true, force: true })\n // The claim goes with the directory. A record saying `pdf` came from a commit, pointing at a folder\n // that is gone, is worse than no record: the next `install` of the same name would look like a\n // re-install of exactly that commit.\n forgetOrigin(dir, name)\n process.stdout.write(\n `${keyValue([\n { label: \"removed\", value: target },\n { label: \"files\", value: String(files) },\n ...(origin === undefined\n ? []\n : [\n {\n label: \"came from\",\n value: `${origin.source} (${origin.url}) at ${origin.commit}`,\n },\n ]),\n ])}\\n`,\n )\n process.stdout.write(`${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`)\n return EXIT_OK\n}\n\nfunction countFiles(dir: string): number {\n let total = 0\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n total += entry.isDirectory() ? countFiles(join(dir, entry.name)) : 1\n }\n return total\n}\n",
7
+ "/**\n * `skills list|show|validate <manifest>` — what this agent knows how to do, and how well it is written.\n *\n * Three questions, deliberately not one command. `list` is the inventory, `show` is one skill in full —\n * including the parts the model never sees, which is the only way to check what it *will* see — and\n * `validate` is the authoring read.\n *\n * `validate` warns and exits 0, with `--strict` for CI. That is the `workspace` split rather than the\n * `validate` one: a skill that does not load already fails here loudly, because this calls the same\n * `loadSkills` the runtime does, and everything past that is a judgement. In particular a missing\n * when-not-to-use is a warning and never a refusal — requiring it would reject every skill vendored from\n * `anthropics/skills` and withdraw decision 6.1's compliance claim to buy a nag.\n *\n * A `ScriptRunner` is supplied here for the same reason `run` supplies one: without it a skill's\n * `scripts/` is never scanned, so `skills list` would report \"no scripts\" for a skill that ships three.\n * The command answers about the runtime, not about a subset of it.\n */\n\nimport {\n cpSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\"\nimport { basename, isAbsolute, join, relative, resolve } from \"node:path\"\nimport {\n checkSkillAuthoring,\n type ErrorDetail,\n editManifestSync,\n isHarnessError,\n isSkillName,\n loadManifest,\n loadSkills,\n nearest,\n parseSkillFile,\n resolveCapabilities,\n type Skill,\n type SkillsConfig,\n whenNotToUseKey,\n} from \"@dispach/core\"\nimport { ambientEnv } from \"#lib/ambient\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport { forgetOrigin, type Origin, readOrigins, recordOrigins } from \"#lib/origins\"\nimport { scriptRunner } from \"#lib/providers\"\nimport { bullet, indent, keyValue, section } from \"#lib/render\"\nimport {\n type CatalogueEntry,\n isCached,\n looksLikePath,\n readCatalogue,\n readMeta,\n} from \"#lib/source-cache\"\nimport { loadSources, parseSkillRef, type SkillRef, type SourceSpec } from \"#lib/sources\"\nimport { fillTemplate, SKILL_TEMPLATE } from \"#lib/templates\"\n\n/** A skill found in a fetched source, with everything provenance needs. */\ninterface Located {\n readonly entry: CatalogueEntry\n readonly spec: SourceSpec\n readonly commit: string\n}\n\nconst SKILL_FILE = \"SKILL.md\"\n\n/**\n * The actions this command accepts, pinned so `--help` and the switch below cannot drift.\n *\n * The same guard `DAEMON_ACTIONS` gets: a verb added in one place and not the other fails a test rather\n * than at the moment somebody types it.\n */\nexport const SKILLS_ACTIONS = [\"list\", \"show\", \"new\", \"install\", \"remove\", \"validate\"] as const\n\nexport interface SkillsOptions {\n readonly manifestPath: string\n /** `list`, `show` or `validate`. Checked by the dispatcher against the spec's `choices`. */\n readonly action: string\n /**\n * The skill `show`, `new` and `remove` act on — or, for `install`, the directory to copy from.\n *\n * One positional rather than three, because the parser has one slot after the manifest and a\n * command with `--name`, `--from` and `--skill` flags reads worse than the thing it replaced.\n */\n readonly name?: string\n readonly json?: boolean\n /** `validate` only: exit non-zero when anything was reported. */\n readonly strict?: boolean\n /**\n * The `<ENVPREFIX>HOME` override that says where the source registry and cache live.\n *\n * Deliberately **not** the manifest environment — that one is `ambientEnv` below and answers \"which\n * model, which key\". This one answers \"which `sources.json`\", and it exists because `install` resolves\n * a `<source>/<skill>` ref against it: without the field, this command read the real home directory\n * while its caller read a sandbox, so an install driven from a test or from `init` looked up a\n * registry nobody had written to and reported `no source called test` on a source that plainly existed.\n */\n readonly sandboxEnv?: Readonly<Record<string, string | undefined>>\n /**\n * Extra variables layered on top of the resolved manifest environment.\n *\n * One caller: `init`, which stubs the API key variable it has just written as an empty line. Without\n * it, installing a skill during setup failed with `model.main.apiKeyEnv names MODEL_API_KEY, which is\n * not set` — correct, useless, and about a key nobody could have filled in yet. `init`'s own load\n * check has always done this; the command it calls needed the same courtesy.\n */\n readonly envOverlay?: Readonly<Record<string, string | undefined>>\n /**\n * Report nothing and let the caller summarise. Set by a batch install.\n *\n * Eleven ticked skills produced **eleven** `from/installed/this installed code/next` blocks — a screenful\n * of repeated narrative for one action, which is what \"the TUI should be everything\" was objecting to.\n * The per-skill report is right for `skills install <one>` and wrong the moment there are eleven, so the\n * caller decides. `collect` is how it gets the facts it needs to write one summary instead.\n */\n readonly quiet?: boolean\n /** Appended to, when given: what happened to each skill this call touched. */\n readonly collect?: InstallOutcome[]\n}\n\n/** What one install did, for a caller aggregating several. */\nexport interface InstallOutcome {\n readonly name: string\n readonly ok: boolean\n /** Why not, when `ok` is false. */\n readonly reason?: string\n /** Files that would run, relative to the skills directory. */\n readonly runnable: readonly string[]\n}\n\nexport function skillsCommand(options: SkillsOptions): number {\n try {\n const loaded = loadManifest(options.manifestPath, {\n // The same environment `run` uses, or this reports on a different agent — the asymmetry\n // every command that loads a manifest exists to avoid.\n env: { ...ambientEnv([options.manifestPath]), ...options.envOverlay },\n })\n\n // `new` and `install` are the two that may run with nothing configured — turning skills on is\n // exactly what they are for, so they do it rather than reporting that it has not been done.\n const creating = options.action === \"new\" || options.action === \"install\"\n const configured = creating\n ? enable(loaded.path, loaded.dir, loaded.manifest.skills)\n : loaded.manifest.skills\n if (configured === undefined) {\n return unconfigured(options)\n }\n\n const capabilities = resolveCapabilities(\n loaded.manifest.model.main.id,\n loaded.manifest.model.main.capabilities,\n )\n const resolvedDir = isAbsolute(configured.dir)\n ? configured.dir\n : resolve(loaded.dir, configured.dir)\n\n // `new` and `remove` run **before** the catalogue is loaded, and that ordering is the fix for a\n // dead end this command had: a skill over `skills.budget` fails the load, so with `remove` behind\n // `loadSkills` the one command that could undo it was the one that could not run. Neither needs a\n // catalogue — one writes a directory, the other deletes one — so neither waits for it.\n if (options.action === \"new\") return create(resolvedDir, options)\n if (options.action === \"remove\") return remove(resolvedDir, options)\n\n const catalogue = loadSkills({\n dir: resolvedDir,\n maxActive: configured.maxActive,\n threshold: configured.threshold,\n style: capabilities.promptStyle,\n agentDir: loaded.dir,\n runner: scriptRunner(),\n })\n\n switch (options.action) {\n case \"list\":\n return list(resolvedDir, catalogue.skills, catalogue, options)\n case \"show\":\n return show(catalogue.skills, options)\n case \"install\":\n return install(resolvedDir, options)\n default:\n // `validate` is the fallback rather than a named case because the parser has already\n // rejected anything outside `SKILLS_ACTIONS`, and the safest thing to do with an action\n // that somehow got through is the one that changes nothing.\n return validate(catalogue.skills, options)\n }\n } catch (error) {\n if (options.json === true && isHarnessError(error)) {\n process.stdout.write(\n `${JSON.stringify({ ok: false, error: error.toDetail(), details: error.details }, null, 2)}\\n`,\n )\n return EXIT_FAILURE\n }\n throw error\n }\n}\n\n/**\n * No `skills:` block at all.\n *\n * Not an error — an agent without skills is an ordinary agent — but it names the block, because someone\n * who typed this command was looking for something and \"no skills\" without a way forward is the shape\n * decision 4.53 objects to.\n */\nfunction unconfigured(options: SkillsOptions): number {\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify({ ok: true, configured: false, skills: [] }, null, 2)}\\n`,\n )\n return EXIT_OK\n }\n // Two commands, not a YAML fragment. This used to print the block to add by hand, which is the\n // workaround `skills new` was built to remove — and it kept printing it for a phase after that\n // command existed, so the one place someone lands when looking for skills was the one place still\n // recommending the manual edit.\n process.stdout.write(\n \"this agent has no skills configured\\n\\n\" +\n \" · find one and install it — searches the configured catalogues for skills:\\n\" +\n \" sources search <what it should do>\\n\" +\n ` skills install ${options.manifestPath} <source>/<skill>\\n\\n` +\n \" · or write your own from a template:\\n\" +\n ` skills new ${options.manifestPath} <name>\\n\\n` +\n \" either one turns skills on for this agent; neither needs agent.yaml edited by hand\\n\",\n )\n return EXIT_OK\n}\n\nfunction list(\n dir: string,\n skills: readonly Skill[],\n catalogue: {\n readonly maxActive: number\n readonly threshold: number\n readonly cached: boolean\n },\n options: SkillsOptions,\n): number {\n // Read here rather than inside the loop: one file for the whole directory, and a listing that opened\n // it per skill would be doing filesystem work proportional to a catalogue it already has in memory.\n const origins = readOrigins(dir)\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n configured: true,\n cached: catalogue.cached,\n maxActive: catalogue.maxActive,\n threshold: catalogue.threshold,\n skills: skills.map((skill) => ({\n ...summarise(skill),\n ...(origins[skill.name] === undefined\n ? {}\n : { origin: origins[skill.name] }),\n })),\n },\n null,\n 2,\n )}\\n`,\n )\n return EXIT_OK\n }\n\n if (skills.length === 0) {\n process.stdout.write(\n `no skills in ${dir}\\n\\n \\`sources search <what it should do>\\` ranks the skills in the configured catalogues, then\\n \\`skills install <agent> <source>/<skill>\\`. \\`skills new <agent> <name>\\` writes one from a template.\\n`,\n )\n return EXIT_OK\n }\n\n process.stdout.write(\n `${keyValue([\n { label: \"skills\", value: String(skills.length) },\n { label: \"per turn\", value: `at most ${catalogue.maxActive}` },\n { label: \"threshold\", value: catalogue.threshold.toFixed(2) },\n { label: \"index\", value: catalogue.cached ? \"cached\" : \"scanned\" },\n ])}\\n`,\n )\n\n process.stdout.write(`${section(\"catalogue\")}\\n`)\n for (const skill of skills) {\n const scripts = skill.scripts.length === 0 ? \"\" : ` ${skill.scripts.length} script(s)`\n // A missing negative guidance is flagged even in `list`, because it is the one thing that is\n // both cheap to fix and invisible until something routes wrongly.\n const gap = skill.frontmatter.whenNotToUse === undefined ? \" no when-not-to-use\" : \"\"\n // Where it came from, on the line that lists it. The origins file is hidden by a leading dot to\n // stay out of the way; that must not make it hidden *information*.\n const origin = origins[skill.name]\n const from = origin === undefined ? \"\" : ` ${origin.source}@${origin.commit}`\n process.stdout.write(\n ` ${skill.name.padEnd(20)} ${String(skill.tokens).padStart(5)} tokens${scripts}${from}${gap}\\n`,\n )\n }\n return EXIT_OK\n}\n\nfunction show(skills: readonly Skill[], options: SkillsOptions): number {\n const wanted = options.name\n if (wanted === undefined) {\n process.stdout.write(\"skills show needs a skill name — `skills list` names them\\n\")\n return EXIT_FAILURE\n }\n const skill = skills.find((entry) => entry.name === wanted)\n if (skill === undefined) {\n const known = skills.map((entry) => entry.name).join(\", \")\n process.stdout.write(`no skill named ${wanted}${known === \"\" ? \"\" : `. Known: ${known}`}\\n`)\n return EXIT_FAILURE\n }\n\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify({ ok: true, skill: detail(skill) }, null, 2)}\\n`)\n return EXIT_OK\n }\n\n const { frontmatter } = skill\n process.stdout.write(\n `${keyValue([\n { label: \"name\", value: skill.name },\n { label: \"directory\", value: skill.dir },\n { label: \"body\", value: `${skill.tokens} tokens` },\n ...(frontmatter.license === undefined\n ? []\n : [{ label: \"license\", value: frontmatter.license }]),\n ...(frontmatter.compatibility === undefined\n ? []\n : [{ label: \"needs\", value: frontmatter.compatibility }]),\n ])}\\n`,\n )\n\n process.stdout.write(`${section(\"description\")}\\n`)\n process.stdout.write(`${indent(frontmatter.description)}\\n`)\n\n process.stdout.write(`${section(\"when not to use\")}\\n`)\n process.stdout.write(\n `${indent(\n frontmatter.whenNotToUse ??\n `not declared — add metadata.${whenNotToUseKey()} to improve routing`,\n )}\\n`,\n )\n\n if (skill.scripts.length > 0) {\n process.stdout.write(`${section(\"scripts\")}\\n`)\n for (const plan of skill.scripts) {\n process.stdout.write(\n `${bullet(`${plan.slug} — scripts/${plan.file} via ${plan.interpreter ?? \"its own shebang\"}`)}\\n`,\n )\n }\n }\n\n if (skill.ignoredScripts.length > 0) {\n process.stdout.write(`${section(\"in scripts/ and not runnable\")}\\n`)\n for (const ignored of skill.ignoredScripts) {\n process.stdout.write(`${bullet(`${ignored.file} — ${ignored.reason}`)}\\n`)\n }\n }\n\n if (frontmatter.allowedTools !== undefined) {\n process.stdout.write(`${section(\"allowed-tools, declared and not honoured\")}\\n`)\n // Printed rather than ignored, and labelled rather than merely printed. A downloaded folder does\n // not widen what this agent may run — that is `tools.policy`, and only a person edits it.\n process.stdout.write(`${indent(frontmatter.allowedTools)}\\n`)\n process.stdout.write(\n `${indent(\"this runtime reads the field and never acts on it; permissions live in tools.policy\")}\\n`,\n )\n }\n\n const extra = Object.entries(frontmatter.metadata).filter(([key]) => key !== whenNotToUseKey())\n if (extra.length > 0) {\n process.stdout.write(`${section(\"metadata\")}\\n`)\n process.stdout.write(`${keyValue(extra.map(([label, value]) => ({ label, value })))}\\n`)\n }\n\n return EXIT_OK\n}\n\nfunction validate(skills: readonly Skill[], options: SkillsOptions): number {\n const findings = checkSkillAuthoring(skills)\n\n if (options.json === true) {\n process.stdout.write(\n `${JSON.stringify(\n { ok: findings.length === 0, skills: skills.map(summarise), findings },\n null,\n 2,\n )}\\n`,\n )\n return options.strict === true && findings.length > 0 ? EXIT_FAILURE : EXIT_OK\n }\n\n // Every skill is named whether or not it has findings, so a clean one is visibly checked rather\n // than merely absent from a list of problems.\n const byName = new Map<string, ErrorDetail[]>()\n for (const finding of findings) {\n const name = skills.find((skill) => finding.message.includes(` ${skill.name}:`))?.name\n const key = name ?? \"\"\n byName.set(key, [...(byName.get(key) ?? []), finding])\n }\n\n for (const skill of skills) {\n const own = byName.get(skill.name) ?? []\n process.stdout.write(\n ` ${skill.name.padEnd(20)} ${own.length === 0 ? \"ok\" : `${own.length} warning(s)`}\\n`,\n )\n }\n\n if (findings.length === 0) {\n process.stdout.write(\"\\nno findings\\n\")\n return EXIT_OK\n }\n\n for (const finding of findings) {\n process.stdout.write(`\\n ${finding.code}: ${finding.message}\\n`)\n process.stdout.write(` hint: ${finding.hint}\\n`)\n }\n process.stdout.write(\n `\\n${findings.length} finding(s) — warnings, not failures. --strict exits non-zero.\\n`,\n )\n return options.strict === true ? EXIT_FAILURE : EXIT_OK\n}\n\nfunction summarise(skill: Skill) {\n return {\n name: skill.name,\n tokens: skill.tokens,\n hasWhenNotToUse: skill.frontmatter.whenNotToUse !== undefined,\n scripts: skill.scripts.map((plan) => plan.slug),\n ignoredScripts: skill.ignoredScripts,\n }\n}\n\nfunction detail(skill: Skill) {\n return {\n ...summarise(skill),\n dir: skill.dir,\n description: skill.frontmatter.description,\n ...(skill.frontmatter.whenNotToUse === undefined\n ? {}\n : { whenNotToUse: skill.frontmatter.whenNotToUse }),\n ...(skill.frontmatter.license === undefined ? {} : { license: skill.frontmatter.license }),\n ...(skill.frontmatter.compatibility === undefined\n ? {}\n : { compatibility: skill.frontmatter.compatibility }),\n ...(skill.frontmatter.allowedTools === undefined\n ? {}\n : { allowedToolsDeclaredNotHonoured: skill.frontmatter.allowedTools }),\n metadata: skill.frontmatter.metadata,\n }\n}\n\n// ─── writing ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Turn skills on for an agent that has not got them, and return the resolved config.\n *\n * Both halves or neither: `skills.dir` naming a directory that does not exist is a **load failure**, so\n * writing the block without creating the directory would leave an agent that refuses to start. That is\n * the reason this is a command rather than a `config_set` path — the agent cannot be trusted to do two\n * things atomically, and it is exactly the shape that made `config_set` report a pending `tokenEnv`.\n *\n * The manifest goes through `editManifest`, the one writer every surface uses. It used to place the\n * block itself and write it unvalidated, on the reasoning that \"the next load\" would catch a bad\n * result — which is the failure that validation exists to prevent, because the next load is a person's\n * agent refusing to start after this command reported success. The block is a fixed known-good shape,\n * so nothing was ever actually broken; the *guarantee* differed by which caller you happened to be.\n *\n * The uncommenting this used to do itself is `uncommentInSource` now, reached automatically for a\n * top-level path: `setInSource` appends to a parent and `skills` has none, so it declines, and the\n * generated manifest ships the line commented under its own heading. Generalising it was worth doing —\n * `channels` needed exactly the same thing, and writing it for the first time had been reflowing 98\n * lines of somebody's manifest.\n */\nfunction enable(\n manifestPath: string,\n agentDir: string,\n existing: SkillsConfig | undefined,\n): SkillsConfig | undefined {\n const dir = existing?.dir ?? \"./skills\"\n const absolute = isAbsolute(dir) ? dir : resolve(agentDir, dir)\n mkdirSync(absolute, { recursive: true })\n\n if (existing !== undefined) return existing\n\n const written = editManifestSync({ file: manifestPath, path: [\"skills\"], value: block(dir) })\n process.stdout.write(`${keyValue([{ label: \"enabled\", value: `skills.dir = ${dir}` }])}\\n`)\n if (written.reflowed) {\n // Said rather than swallowed. A manifest with no commented `# skills:` line to uncomment — a\n // hand-written one — goes through the round-trip, which is valid and moves comments, and\n // finding that in a later `git diff` with nothing having mentioned it is the worse outcome.\n process.stdout.write(\n `${bullet(\"the file was re-serialised to add the block — it is valid, and comments may have moved\")}\\n`,\n )\n }\n // Validated before it was written, so this is a resolved config rather than an assumption.\n return { dir, ...DEFAULTS }\n}\n\n/** Written once, so what is stored and what is printed cannot disagree. */\nconst DEFAULTS = { maxActive: 1, threshold: 0.35 } as const\n\nfunction block(dir: string): Record<string, unknown> {\n return { dir, ...DEFAULTS }\n}\n\nfunction create(dir: string, options: SkillsOptions): number {\n const name = options.name\n if (name === undefined) {\n process.stdout.write(\"skills new needs a name — `skills new <manifest> <name>`\\n\")\n return EXIT_FAILURE\n }\n if (!isSkillName(name)) {\n // The spec's own rule, checked here so a scaffold the loader would refuse is never written.\n process.stdout.write(\n `${name} is not a legal skill name: lowercase letters, digits and single hyphens, never leading, trailing or doubled, at most 64 characters.\\n`,\n )\n return EXIT_FAILURE\n }\n\n const target = join(dir, name)\n if (existsSync(target)) {\n process.stdout.write(`${target} already exists — nothing was written\\n`)\n return EXIT_FAILURE\n }\n\n mkdirSync(target, { recursive: true })\n writeFileSync(\n join(target, \"SKILL.md\"),\n fillTemplate(SKILL_TEMPLATE, {\n SKILL_NAME: name,\n WHEN_NOT_TO_USE_KEY: whenNotToUseKey(),\n }),\n \"utf8\",\n )\n\n process.stdout.write(\n `${keyValue([\n { label: \"created\", value: join(target, \"SKILL.md\") },\n { label: \"name\", value: name },\n ])}\\n`,\n )\n process.stdout.write(\n `${section(\"next\")}\\n` +\n `${bullet(\"edit the description — it is the only thing selection reads, so name the words someone would actually type\")}\\n` +\n `${bullet(\"write the steps in place of the placeholder body\")}\\n` +\n `${bullet(`skills validate — it warns until the scaffold is replaced`)}\\n` +\n `${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`,\n )\n return EXIT_OK\n}\n\n/**\n * Copy a skill, or a directory of skills, into this agent.\n *\n * A **local path only**, and that is a decision rather than an unfinished feature. A skill may ship\n * executable scripts, so installing one from a URL is running someone else's code on this machine — a\n * thing that deserves its own decision about provenance and trust, not a flag added beside a copy\n * command. `git clone` or `gh repo clone` first, then install from the path; the network stays out of a\n * command whose job is to move files.\n *\n * Modes are preserved, because an executable bit is what makes a script runnable at all.\n */\nfunction install(dir: string, options: SkillsOptions): number {\n const from = options.name\n if (from === undefined) {\n process.stdout.write(\n \"skills install needs something to install — `skills install <manifest> anthropic/pdf`, or a local path\\n\\n `sources search <what you need>` finds one.\\n\",\n )\n return EXIT_FAILURE\n }\n\n // Filesystem-first, which is git's pathspec rule and the one `resolveAgentRef` already follows: a\n // name shadowed by a directory in the cwd resolves to the directory, with a note, rather than\n // silently installing something else.\n const asPath = looksLikePath(from)\n let origin: Located | undefined\n if (!asPath) {\n const located = locate(from, options.sandboxEnv)\n if (located === undefined) return EXIT_FAILURE\n origin = located\n }\n\n const source = origin === undefined ? resolve(from) : origin.entry.dir\n if (origin === undefined) {\n if (!existsSync(source) || !statSync(source).isDirectory()) {\n process.stdout.write(`${source} is not a directory\\n`)\n return EXIT_FAILURE\n }\n if (\n existsSync(from) &&\n loadSources(options.sandboxEnv).some((spec) => spec.name === from)\n ) {\n process.stdout.write(\n `note: ${from} is also a source, and a directory of that name here wins — \\`sources search\\` to install from the source instead\\n\\n`,\n )\n }\n }\n\n const origins: Record<string, Origin> = {}\n const runnable: string[] = []\n\n // One skill, or a folder holding several. Detected rather than flagged: `skills/` from a cloned\n // repository and a single `pdf/` are both obvious to look at, and asking which would be a question\n // the filesystem has already answered.\n const single = existsSync(join(source, SKILL_FILE))\n const candidates = single\n ? [source]\n : readdirSync(source, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(source, entry.name, SKILL_FILE)),\n )\n .map((entry) => join(source, entry.name))\n\n if (candidates.length === 0) {\n process.stdout.write(\n `no ${SKILL_FILE} in ${source} or in any directory directly inside it\\n`,\n )\n return EXIT_FAILURE\n }\n\n const installed: string[] = []\n const skipped: string[] = []\n for (const candidate of candidates) {\n // The destination is the skill's declared `name`, not the source folder's — the spec requires\n // them to match, so a mismatched source is a skill that would fail to load wherever it landed.\n let name: string\n try {\n const parsed = parseSkillFile(\n basename(candidate),\n readFileSync(join(candidate, SKILL_FILE), \"utf8\"),\n )\n name = parsed.frontmatter.name\n } catch (error) {\n skipped.push(\n `${basename(candidate)} — ${error instanceof Error ? error.message : String(error)}`,\n )\n continue\n }\n const target = join(dir, name)\n if (existsSync(target)) {\n skipped.push(`${name} — already installed at ${target}`)\n continue\n }\n // No size check. There was one, against `skills.budget`, and it is what turned a person ticking\n // eleven skills into \"9 of 11 installed\" — refusing `pptx` at 5,441 tokens and `skill-creator` at\n // 9,065 against a default of 5,000 they never chose. The budget is gone (decision 11.59): the\n // catalogue prints every body's size on the row where the choice is made, and a large skill that\n // somebody picked on purpose is not a configuration error.\n cpSync(candidate, target, { recursive: true, preserveTimestamps: true })\n installed.push(name)\n if (origin !== undefined) {\n origins[name] = {\n source: origin.spec.name,\n url: origin.spec.url,\n repoPath: origin.entry.repoPath,\n commit: origin.commit,\n ...(origin.spec.ref === undefined ? {} : { ref: origin.spec.ref }),\n installedAt: new Date().toISOString(),\n }\n }\n // Named, not counted. This is the only moment somebody can decide to go and read code they are\n // about to give an agent, and \"3 runnable files\" does not tell them which files.\n runnable.push(...scriptFiles(target).map((file) => `${name}/${relative(target, file)}`))\n }\n\n if (Object.keys(origins).length > 0) recordOrigins(dir, origins)\n\n if (options.collect !== undefined) {\n for (const name of installed) {\n options.collect.push({\n name,\n ok: true,\n runnable: runnable.filter((file) => file.startsWith(`${name}/`)),\n })\n }\n for (const entry of skipped) {\n const cut = entry.indexOf(\" — \")\n options.collect.push({\n name: cut === -1 ? entry : entry.slice(0, cut),\n ok: false,\n reason: cut === -1 ? entry : entry.slice(cut + 3),\n runnable: [],\n })\n }\n }\n if (options.quiet === true) return installed.length === 0 ? EXIT_FAILURE : EXIT_OK\n\n process.stdout.write(\n `${keyValue([\n {\n label: \"from\",\n value:\n origin === undefined\n ? source\n : `${origin.spec.name} (${origin.spec.url}) at ${origin.commit}`,\n },\n { label: \"installed\", value: installed.join(\", \") },\n { label: \"skipped\", value: skipped.length === 0 ? \"\" : String(skipped.length) },\n ])}\\n`,\n )\n for (const entry of skipped) process.stdout.write(`${bullet(entry)}\\n`)\n if (runnable.length > 0) {\n // Disclosure rather than a prompt. Nothing runs at install time — a skill script becomes a tool\n // only once the skill activates, and it arrives `untrusted` and `mutating`, so the write gate and\n // `tools.policy` both still apply. A confirmation dialog on every install would be answered\n // reflexively within a week and would buy none of that.\n process.stdout.write(\n `${section(\"this installed code, which the agent can run\")}\\n${runnable\n .slice(0, 12)\n .map((file) => bullet(file))\n .join(\"\\n\")}\\n`,\n )\n if (runnable.length > 12) {\n process.stdout.write(`${indent(`… and ${runnable.length - 12} more`)}\\n`)\n }\n process.stdout.write(\n `${indent(\"read them before the agent does; `tools.policy` can name a skill script by slug\")}\\n`,\n )\n }\n if (installed.length > 0) {\n process.stdout.write(\n `${section(\"next\")}\\n${bullet(\"skills validate — a vendored skill usually has no negative guidance, which is a warning and not a problem\")}\\n${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`,\n )\n }\n return installed.length === 0 ? EXIT_FAILURE : EXIT_OK\n}\n\n/**\n * Turn `pdf` or `anthropic/pdf` into a folder in the source cache.\n *\n * Ambiguity is refused rather than resolved by source order: with two sources carrying a `pdf`, picking\n * the first would install one and report a name that describes both, and the person would find out which\n * they got by reading the file. Naming the candidates costs one retyped command and cannot be wrong.\n */\nfunction locate(\n ref: string,\n env?: Readonly<Record<string, string | undefined>>,\n): Located | undefined {\n let parsed: SkillRef\n try {\n parsed = parseSkillRef(ref)\n } catch (error) {\n if (!isHarnessError(error)) throw error\n process.stdout.write(`${error.message}\\n\\n ${error.hint}\\n`)\n return undefined\n }\n\n const sources = loadSources(env)\n const named =\n parsed.source === undefined\n ? sources\n : sources.filter((spec) => spec.name === parsed.source)\n if (named.length === 0) {\n const suggestion = nearest(\n parsed.source ?? \"\",\n sources.map((spec) => spec.name),\n )\n process.stdout.write(\n `no source called ${parsed.source}\\n\\n ${suggestion === undefined ? \"`sources list` shows them.\" : `Did you mean ${suggestion}?`}\\n`,\n )\n return undefined\n }\n\n const cold = named.filter((spec) => !isCached(spec.name, env))\n if (cold.length === named.length) {\n // The distinction that matters: an empty cache is not a mistyped name, and only this layer knows\n // which. Reporting \"no skill called pdf\" against a cache that has never been fetched blames the\n // person for the tool's state — the same failure `explainUnresolved` exists to prevent.\n process.stdout.write(\n `${named.length === 1 ? `${named[0]?.name} has not` : \"no source has\"} been fetched yet, so there is nothing to install from\\n\\n \\`sources update${parsed.source === undefined ? \"\" : ` ${parsed.source}`}\\` first, or \\`sources search ${parsed.skill}\\` which fetches on demand.\\n`,\n )\n return undefined\n }\n\n const entries = named\n .filter((spec) => isCached(spec.name, env))\n .flatMap((spec) => readCatalogue(spec, env).map((entry) => ({ entry, spec })))\n const matches = entries.filter((row) => row.entry.skill === parsed.skill)\n\n if (matches.length === 0) {\n const suggestion = nearest(\n parsed.skill,\n entries.map((row) => row.entry.skill),\n )\n process.stdout.write(\n `no skill called ${parsed.skill} in ${named.map((spec) => spec.name).join(\", \")}\\n\\n ${\n suggestion === undefined\n ? `\\`sources search ${parsed.skill}\\` ranks what is there.`\n : `Did you mean ${suggestion}? \\`sources search ${parsed.skill}\\` ranks the alternatives.`\n }\\n`,\n )\n return undefined\n }\n if (matches.length > 1) {\n process.stdout.write(\n `${matches.length} sources carry a skill called ${parsed.skill}\\n\\n${matches\n .map((row) => ` ${row.spec.name}/${row.entry.skill} — ${row.spec.url}\\n`)\n .join(\"\")}\\n Name one.\\n`,\n )\n return undefined\n }\n\n const only = matches[0] as { entry: CatalogueEntry; spec: SourceSpec }\n if (only.entry.problem !== undefined) {\n process.stdout.write(\n `${only.spec.name}/${only.entry.skill} will not load: ${only.entry.problem}\\n\\n Nothing was copied. That is upstream's to fix — installing a hand-edited copy from a path is the way round it.\\n`,\n )\n return undefined\n }\n return {\n entry: only.entry,\n spec: only.spec,\n commit: readMeta(only.spec.name, env).commit ?? \"unknown\",\n }\n}\n\n/** Files under an installed skill that would run. Same over-reporting rule as the catalogue's. */\nfunction scriptFiles(dir: string, depth = 0): string[] {\n if (depth > 3) return []\n const found: string[] = []\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\")) continue\n found.push(...scriptFiles(full, depth + 1))\n continue\n }\n if (!entry.isFile()) continue\n const executable = (statSync(full).mode & 0o111) !== 0\n if (executable || SCRIPT_EXTENSIONS.some((extension) => entry.name.endsWith(extension))) {\n found.push(full)\n }\n }\n return found\n}\n\nconst SCRIPT_EXTENSIONS = [\".py\", \".sh\", \".js\", \".ts\", \".mjs\", \".rb\", \".pl\"]\n\n/**\n * Deletes files, and says what it removed rather than only that it did.\n *\n * Reads the directory rather than the catalogue on purpose — see the ordering note at the call site. A\n * skill that breaks the load is precisely the skill someone needs to remove.\n */\nfunction remove(dir: string, options: SkillsOptions): number {\n const name = options.name\n if (name === undefined) {\n process.stdout.write(\"skills remove needs a name — `skills list` names them\\n\")\n return EXIT_FAILURE\n }\n const target = join(dir, name)\n if (!existsSync(join(target, SKILL_FILE))) {\n const known = existsSync(dir)\n ? readdirSync(dir, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(dir, entry.name, SKILL_FILE)),\n )\n .map((entry) => entry.name)\n .join(\", \")\n : \"\"\n process.stdout.write(`no skill named ${name}${known === \"\" ? \"\" : `. Known: ${known}`}\\n`)\n return EXIT_FAILURE\n }\n\n // Counted before the delete, so the report is about what was actually there rather than a guess.\n const files = countFiles(target)\n const origin = readOrigins(dir)[name]\n rmSync(target, { recursive: true, force: true })\n // The claim goes with the directory. A record saying `pdf` came from a commit, pointing at a folder\n // that is gone, is worse than no record: the next `install` of the same name would look like a\n // re-install of exactly that commit.\n forgetOrigin(dir, name)\n process.stdout.write(\n `${keyValue([\n { label: \"removed\", value: target },\n { label: \"files\", value: String(files) },\n ...(origin === undefined\n ? []\n : [\n {\n label: \"came from\",\n value: `${origin.source} (${origin.url}) at ${origin.commit}`,\n },\n ]),\n ])}\\n`,\n )\n process.stdout.write(`${bullet(\"restart the agent: the catalogue is scanned once at boot\")}\\n`)\n return EXIT_OK\n}\n\nfunction countFiles(dir: string): number {\n let total = 0\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n total += entry.isDirectory() ? countFiles(join(dir, entry.name)) : 1\n }\n return total\n}\n",
8
8
  "/**\n * Where an installed skill came from, recorded beside the skills rather than inside them.\n *\n * ## Why not in the skill's own frontmatter\n *\n * `metadata` is the spec's extension point and would accept it, and writing there would still be the\n * wrong move: decision 6.1's compliance claim is checked by vendoring a skill from `anthropics/skills`\n * **unmodified**, and a copy this tool has edited is no longer that. Provenance is a fact about the\n * copy, not about the skill.\n *\n * ## Why not in the agent's state directory\n *\n * `<agentDir>/<stateDir>/` is a cache — `skills.idx.json` lives there and is safe to delete. This is\n * not cache: it is the answer to \"where did this folder of somebody else's code come from\", which is\n * worth committing alongside the skills it describes. So it sits at `<skills dir>/.origins.json`, one\n * file for the whole directory rather than one per skill, and the loader never sees it because\n * `loadSkills` scans `<dir>/*​/SKILL.md` and a file is not a directory.\n *\n * Hidden by a leading dot to keep it out of the way, and surfaced by `skills list` so it is not hidden\n * *information* — a distinction this codebase has already had to make once, for boot warnings emitted\n * into an empty room.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\n\nexport const ORIGINS_FILE = \".origins.json\"\n\nexport interface Origin {\n /** The source's nickname at the time of installing. */\n readonly source: string\n readonly url: string\n /** Path inside the repository — what to read to see the upstream copy. */\n readonly repoPath: string\n /** Short commit the copy was taken from. What makes \"has upstream changed?\" answerable. */\n readonly commit: string\n readonly ref?: string\n readonly installedAt: string\n}\n\ninterface OriginsFile {\n readonly version?: number\n readonly origins?: Readonly<Record<string, Origin>>\n}\n\nconst VERSION = 1\n\nexport function originsPath(skillsDir: string): string {\n return join(skillsDir, ORIGINS_FILE)\n}\n\nexport function readOrigins(skillsDir: string): Readonly<Record<string, Origin>> {\n const path = originsPath(skillsDir)\n if (!existsSync(path)) return {}\n try {\n const parsed = JSON.parse(readFileSync(path, \"utf8\")) as OriginsFile\n return parsed.origins ?? {}\n } catch {\n // A record of where things came from is not worth failing a listing over, and the next install\n // rewrites it. Silent here and only here: nothing downstream depends on it being present.\n return {}\n }\n}\n\nexport function recordOrigins(skillsDir: string, added: Readonly<Record<string, Origin>>): void {\n const merged = { ...readOrigins(skillsDir), ...added }\n writeFileSync(\n originsPath(skillsDir),\n `${JSON.stringify({ version: VERSION, origins: merged }, null, 4)}\\n`,\n )\n}\n\n/** Called by `remove`, so a deleted skill does not leave a claim about a directory that is gone. */\nexport function forgetOrigin(skillsDir: string, name: string): void {\n const origins = readOrigins(skillsDir)\n if (origins[name] === undefined) return\n const kept = Object.fromEntries(Object.entries(origins).filter(([skill]) => skill !== name))\n writeFileSync(\n originsPath(skillsDir),\n `${JSON.stringify({ version: VERSION, origins: kept }, null, 4)}\\n`,\n )\n}\n",
9
9
  "/**\n * Bare `skills`, with no arguments: the catalogue, ticked, installed into an agent you pick.\n *\n * This is the entry point the owner asked for and the one the surface was missing. Everything else\n * required knowing something first — `skills list <agent>` needs an agent, `sources search <words>` needs\n * words, and `skills install <agent> <source>/<skill>` needs the name of a skill you have not seen yet.\n * A person who wants skills has none of those, so the command that takes no arguments has to be the one\n * that shows what exists.\n *\n * ## What it does not do\n *\n * It does not fetch on a pipe. `--plain`, a redirect, or CI gets the same list as text, from the same\n * `browseRows`, with the two commands that install a skill non-interactively printed underneath — because\n * a picker is not scriptable and pretending otherwise means somebody's CI job hangs on a keypress.\n *\n * It also does not resolve an agent for you when there are several. Installing somebody else's executable\n * code into whichever agent happened to sort first is not a default worth having, so the second screen\n * asks — and with exactly one agent it does not, because there is nothing to ask.\n */\n\nimport { BRAND, isHarnessError, VERSION } from \"@dispach/core\"\nimport {\n type BrowseInput,\n type BrowseRow,\n browseRows,\n type InstallReport,\n installReport,\n} from \"#lib/browse\"\nimport { ENTER_ALT_SCREEN, EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport { flushOutput, markAltScreen, onExit, restoreTerminal } from \"#lib/exit\"\nimport { negotiateKeyboard } from \"#lib/keyboard\"\nimport { resolveModeFromProcess } from \"#lib/output\"\nimport { bullet, indent, section } from \"#lib/render\"\nimport { columnsFor, layoutRow } from \"#lib/rows\"\nimport { listAgents, type SandboxAgent } from \"#lib/sandbox\"\nimport {\n type CatalogueEntry,\n fetchSource,\n type Git,\n isCached,\n readCatalogue,\n} from \"#lib/source-cache\"\nimport { loadSources } from \"#lib/sources\"\nimport { type InstallOutcome, skillsCommand } from \"#skills\"\n\nexport interface BrowseOptions {\n readonly plain?: boolean\n readonly json?: boolean\n /** Injected by the tests, which never reach a network. */\n readonly git?: Git\n readonly env?: Readonly<Record<string, string | undefined>>\n /** Both overridden in tests; at a terminal they are measured from the stream. */\n readonly rows?: number\n readonly width?: number\n}\n\n/**\n * Fetch what is not cached, then build the rows. Shared by the command and by `init`.\n *\n * Announced before the work: the first run pays ~40 MB once per machine and every agent on it shares the\n * result, and a command that pauses for twenty seconds with no output is indistinguishable from one that\n * has hung — the failure this whole area's git wrapper exists to prevent.\n */\n/**\n * Fetch what is not cached, then build the rows — reporting progress through a callback.\n *\n * A callback rather than `process.stdout` because one caller is *inside* a rendered screen, where writing\n * to stdout paints over the frame Ink is managing. The other caller passes a writer and gets the same lines\n * on a pipe. This is the seam that lets the init wizard show a spinner instead of a printed line.\n */\nexport async function fetchCatalogue(\n options: BrowseOptions & { readonly onStatus?: (line: string) => void },\n): Promise<readonly BrowseRow[]> {\n const say = options.onStatus ?? (() => {})\n const sources = loadSources(options.env)\n const cold = sources.filter((spec) => !isCached(spec.name, options.env))\n for (const [at, spec] of cold.entries()) {\n say(\n `fetching ${spec.name} (${at + 1} of ${cold.length}) — once per machine, shared by every agent`,\n )\n try {\n const result = await fetchSource(spec, {\n ...(options.env === undefined ? {} : { env: options.env }),\n ...(options.git === undefined ? {} : { git: options.git }),\n })\n say(`${spec.name}: ${result.skills} skills`)\n } catch (error) {\n say(\n `${spec.name} could not be fetched: ${isHarnessError(error) ? error.message : String(error)}`,\n )\n }\n }\n const inputs: BrowseInput[] = sources\n .filter((spec) => isCached(spec.name, options.env))\n .map((spec) => ({ spec, entries: readCatalogue(spec, options.env) }))\n return browseRows(inputs)\n}\n\n/** The same thing for the paths that own the terminal, printing each line as it happens. */\nexport async function catalogueRows(options: BrowseOptions): Promise<readonly BrowseRow[]> {\n return await fetchCatalogue({\n ...options,\n onStatus: (line) => process.stdout.write(`${line}\\n`),\n })\n}\n\n/**\n * Install a list of `<source>/<skill>` refs, reporting once.\n *\n * Exported for `init`, whose wizard already collected the refs on its own screen — so it needs the install\n * without the picker.\n */\nexport function installRefs(\n refs: readonly string[],\n manifestPath: string,\n options: BrowseOptions & { readonly envOverlay?: Readonly<Record<string, string | undefined>> },\n): number {\n const outcomes: InstallOutcome[] = []\n for (const ref of refs) {\n skillsCommand({\n action: \"install\",\n manifestPath,\n name: ref,\n quiet: true,\n collect: outcomes,\n ...(options.env === undefined ? {} : { sandboxEnv: options.env }),\n ...(options.envOverlay === undefined ? {} : { envOverlay: options.envOverlay }),\n })\n }\n return report(outcomes)\n}\n\n/**\n * One `skills install` per skill rather than one call with a list.\n *\n * The command's contract is one ref, it reports per skill, and a partial failure leaves the successful\n * ones installed with a named reason for the rest — batching would have to reimplement all of that.\n */\nfunction collectInstall(\n skills: readonly CatalogueEntry[],\n manifestPath: string,\n options: BrowseOptions & { readonly envOverlay?: Readonly<Record<string, string | undefined>> },\n): readonly InstallOutcome[] {\n const outcomes: InstallOutcome[] = []\n for (const entry of skills) {\n skillsCommand({\n action: \"install\",\n manifestPath,\n name: `${entry.source}/${entry.skill}`,\n quiet: true,\n collect: outcomes,\n ...(options.env === undefined ? {} : { sandboxEnv: options.env }),\n ...(options.envOverlay === undefined ? {} : { envOverlay: options.envOverlay }),\n })\n }\n return outcomes\n}\n\n/**\n * The one report for a batch, as text.\n *\n * Renders from `installReport`, which the rich result card also reads — so a pipe and a terminal cannot\n * disagree about what happened. Eleven ticked skills used to produce eleven of these.\n */\nfunction report(outcomes: readonly InstallOutcome[]): number {\n const summary = installReport(outcomes)\n process.stdout.write(\n `${section(`installed ${summary.installed.length} of ${summary.total} skill${summary.total === 1 ? \"\" : \"s\"}`, true)}\\n`,\n )\n if (summary.installed.length > 0) {\n process.stdout.write(`${indent(summary.installed.join(\", \"))}\\n`)\n }\n for (const failure of summary.failed) {\n process.stdout.write(`${bullet(`${failure.name} — ${failure.reason}`)}\\n`)\n }\n if (summary.runnable > 0) {\n // Counted here and named per skill by `skills show`. Twelve file paths per skill across eleven\n // skills is 130 lines of disclosure nobody reads, which discloses less than one honest sentence.\n process.stdout.write(\n `${section(\"code that came with them\")}\\n${indent(\n `${summary.runnable} runnable file${summary.runnable === 1 ? \"\" : \"s\"} across ${summary.withCode} skill${summary.withCode === 1 ? \"\" : \"s\"} — \\`skills show <agent> <skill>\\` names them`,\n )}\\n`,\n )\n }\n return summary.failed.length\n}\n\nexport async function browseCommand(options: BrowseOptions): Promise<number> {\n const sources = loadSources(options.env)\n if (sources.length === 0) {\n process.stdout.write(\n `no skill sources are configured\\n\\n \\`${BRAND.slug} sources add <url>\\` adds one — a repository holding a skills/ directory.\\n`,\n )\n return EXIT_FAILURE\n }\n\n const decision = resolveModeFromProcess({\n plain: options.plain === true,\n json: options.json === true,\n oneShot: false,\n })\n const interactive = decision.mode === \"rich\" && options.json !== true\n\n // The plain and JSON paths still fetch first, because they have nothing to render while they wait\n // and a spinner on a pipe is noise. The rich path does the opposite, and that inversion is the\n // whole point of this stage.\n if (!interactive) {\n const rows = await catalogueRows(options)\n if (rows.length === 0) {\n process.stdout.write(\n `nothing to show — no catalogue could be read\\n\\n \\`${BRAND.slug} sources update\\` reports why.\\n`,\n )\n return EXIT_FAILURE\n }\n if (options.json === true) return printJson(rows)\n return plainList(rows, listAgents(options.env))\n }\n\n const agents = listAgents(options.env)\n if (agents.length === 0) {\n // Checked before the mount because it needs no catalogue: fetching 40 MB to then say there is\n // nowhere to put it would be the wrong order to find out in.\n process.stdout.write(\n `${section(\"no agent to install into\", true)}\\n${indent(`\\`${BRAND.slug} init\\` creates one, then this command installs into it.`)}\\n`,\n )\n return EXIT_FAILURE\n }\n\n const [{ render }, { createElement }, { SkillBrowser }] = await Promise.all([\n import(\"ink\"),\n import(\"react\"),\n import(\"#components/SkillBrowser\"),\n ])\n\n let report: InstallReport | undefined\n let finish: () => void = () => {}\n const closed = new Promise<void>((resolve) => {\n finish = resolve\n })\n\n // Alternate screen: this waits for a keypress, so it takes the terminal and gives it back. The\n // enter sequence and the flag are written together — a flag set without the sequence would make the\n // restore clear the screen the output was just written to.\n markAltScreen()\n process.stdout.write(ENTER_ALT_SCREEN)\n\n const instance = render(\n createElement(SkillBrowser, {\n title: BROWSE_TITLE,\n agents,\n load: (onStatus: (line: string) => void) => fetchCatalogue({ ...options, onStatus }),\n install: async (skills: readonly CatalogueEntry[], manifestPath: string) =>\n installReport(collectInstall(skills, manifestPath, options)),\n onDone: (result: InstallReport | undefined) => {\n report = result\n finish()\n },\n }),\n { exitOnCtrlC: false, ...negotiateKeyboard() },\n )\n onExit(() => instance.unmount())\n await closed\n instance.unmount()\n restoreTerminal()\n await flushOutput()\n\n // Restored first, then one line on the real screen. A clean exit leaves no trace of the browsing;\n // what it does leave is the pointer to what changed, and any failure, because hard rule 8 does not\n // stop applying because a screen has closed.\n if (report === undefined) return EXIT_OK\n for (const failure of report.failed) {\n process.stderr.write(`${failure.name} — ${failure.reason}\\n`)\n }\n if (report.installed.length > 0) {\n process.stdout.write(\n `${report.installed.length} skill${report.installed.length === 1 ? \"\" : \"s\"} installed — \\`${BRAND.slug} skills list <agent>\\` shows them\\n`,\n )\n }\n return report.failed.length === report.total && report.total > 0 ? EXIT_FAILURE : EXIT_OK\n}\n\n/** The JSON form, unchanged and deliberately not rendered. */\nfunction printJson(rows: readonly BrowseRow[]): number {\n process.stdout.write(\n `${JSON.stringify(\n {\n skills: rows\n .filter((row) => row.entry !== undefined)\n .map((row) => ({\n ref: `${row.entry?.source}/${row.entry?.skill}`,\n source: row.entry?.source,\n skill: row.entry?.skill,\n tokens: row.entry?.tokens,\n scripts: row.entry?.scripts.length ?? 0,\n description: row.entry?.description,\n })),\n },\n null,\n 2,\n )}\\n`,\n )\n return EXIT_OK\n}\n\n/**\n * The pipe's rendering: the same rows, laid out in the same columns, at a fixed 100.\n *\n * Fixed rather than measured, because a redirected stream has no width and output that changed shape\n * depending on the terminal it was *not* written to is output no test can pin.\n */\nfunction plainListText(rows: readonly BrowseRow[]): string {\n const width = 100\n const longest = rows.reduce(\n (max, row) => (row.kind === \"item\" ? Math.max(max, row.label.length) : max),\n 0,\n )\n // `longest + 12` and a matching ceiling, because each name is printed as `<source>/<skill>` here.\n const columns = columnsFor(width, longest + 12, { nameMax: 46 })\n const lines: string[] = []\n for (const row of rows) {\n if (row.kind === \"source\") {\n lines.push(`\\n${row.label}`)\n continue\n }\n if (row.kind === \"group\") {\n lines.push(` ${row.label}`)\n continue\n }\n const cells = layoutRow(\n {\n name: `${row.entry?.source}/${row.label}`,\n meta: row.meta ?? \"\",\n description: row.description ?? \"\",\n },\n columns,\n )\n lines.push(` ${cells.name} ${cells.meta} ${cells.description}`.trimEnd())\n }\n return lines.join(\"\\n\")\n}\n\n/**\n * The pipe's answer: the same rows, plus the two commands that install one without a keypress.\n *\n * Exits 0. Asking what exists is a legitimate question and it was answered — unlike bare `run`, which\n * exits non-zero on a pipe because nothing ran and something was supposed to.\n */\nfunction plainList(rows: readonly BrowseRow[], agents: readonly SandboxAgent[]): number {\n process.stdout.write(`${plainListText(rows)}\\n`)\n const example = rows.find((row) => row.entry !== undefined)?.entry\n const agent = agents[0]?.ref ?? \"<agent>\"\n process.stdout.write(\n `${section(\"install\")}\\n${indent(`${BRAND.slug} skills install ${agent} ${example?.source ?? \"anthropic\"}/${example?.skill ?? \"pdf\"}`)}\\n${indent(`${BRAND.slug} skills — at a terminal, ticks several at once`, 2)}\\n`,\n )\n return EXIT_OK\n}\n\n/** Kept beside the command so the banner and the picker cannot disagree about the version. */\nexport const BROWSE_TITLE = `${BRAND.name} ${VERSION}`\n"
10
10
  ],
11
11
  "mappings": ";idA+BA,qBACI,eACA,kBACA,kBACA,gBACA,aACA,cACA,oBACA,iBAEJ,eAAS,cAAM,mBChBf,qBAAS,gBAAY,mBAAW,oBAAc,iBAC9C,eAAS,kBAmDF,IAAM,GAAyC,CAClD,CACI,KAAM,YACN,IAAK,uCACL,KAAM,SACN,QAAS,EACb,EACA,CACI,KAAM,SACN,IAAK,4CACL,KAAM,SACN,QAAS,GAET,QAAS,EACb,CACJ,EAGM,GAAc,6BAEb,SAAS,EAAY,CAAC,EAAuB,CAChD,OAAO,EAAK,OAAS,GAAK,EAAK,QAAU,IAAM,GAAY,KAAK,CAAI,EASxE,IAAM,EAAU,EAET,SAAS,EAAY,CAAC,EAA4D,CACrF,OAAO,EAAK,GAAY,CAAG,EAAG,cAAc,EAIzC,SAAS,CAAS,CAAC,EAA4D,CAClF,OAAO,EAAK,GAAY,CAAG,EAAG,SAAS,EAGpC,SAAS,CAAQ,CAAC,EAAc,EAA4D,CAC/F,OAAO,EAAK,EAAU,CAAG,EAAG,CAAI,EAGpC,SAAS,CAAY,CAAC,EAAkE,CACpF,IAAM,EAAO,GAAa,CAAG,EAC7B,GAAI,CAAC,GAAW,CAAI,EAAG,MAAO,CAAC,EAC/B,IAAI,EACJ,GAAI,CACA,EAAS,KAAK,MAAM,GAAa,EAAM,MAAM,CAAC,EAChD,MAAO,EAAO,CACZ,MAAM,IAAI,EAAa,CACnB,KAAM,2BACN,QAAS,GAAG,wBAA2B,aAAiB,MAAQ,EAA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