dispach 0.1.2 → 0.2.0-pilot.1

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 (247) hide show
  1. package/README.md +196 -118
  2. package/dist/APEv2Parser-2wqk09q7.js +5 -0
  3. package/dist/APEv2Parser-2wqk09q7.js.map +9 -0
  4. package/dist/AiffParser-zw4g2bdd.js +5 -0
  5. package/dist/AiffParser-zw4g2bdd.js.map +12 -0
  6. package/dist/App-ez7ve0yp.js +11 -0
  7. package/dist/{App-b1yrwrcq.js.map → App-ez7ve0yp.js.map} +6 -7
  8. package/dist/AsfParser-2hfcf5z2.js +5 -0
  9. package/dist/AsfParser-2hfcf5z2.js.map +14 -0
  10. package/dist/ConfigEditor-aamadrx3.js +6 -0
  11. package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-aamadrx3.js.map} +2 -2
  12. package/dist/DsdiffParser-n8smktvb.js +5 -0
  13. package/dist/DsdiffParser-n8smktvb.js.map +11 -0
  14. package/dist/DsfParser-npmjp4vr.js +5 -0
  15. package/dist/DsfParser-npmjp4vr.js.map +11 -0
  16. package/dist/FlacParser-xpbs2zmb.js +5 -0
  17. package/dist/FlacParser-xpbs2zmb.js.map +9 -0
  18. package/dist/KeyProbe-4fp152yv.js +5 -0
  19. package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-4fp152yv.js.map} +2 -2
  20. package/dist/MP4Parser-es3afcmw.js +5 -0
  21. package/dist/MP4Parser-es3afcmw.js.map +12 -0
  22. package/dist/MatroskaParser-kxysj649.js +5 -0
  23. package/dist/MatroskaParser-kxysj649.js.map +13 -0
  24. package/dist/MpegParser-b3rr7b0f.js +5 -0
  25. package/dist/MpegParser-b3rr7b0f.js.map +13 -0
  26. package/dist/MusepackParser-sgjzmq0r.js +5 -0
  27. package/dist/MusepackParser-sgjzmq0r.js.map +16 -0
  28. package/dist/OggParser-x8h54ynf.js +5 -0
  29. package/dist/OggParser-x8h54ynf.js.map +18 -0
  30. package/dist/Picker-rq015kzc.js +5 -0
  31. package/dist/{Picker-hfeh1g6m.js.map → Picker-rq015kzc.js.map} +2 -2
  32. package/dist/SessionPicker-03zyvd2f.js +5 -0
  33. package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-03zyvd2f.js.map} +2 -2
  34. package/dist/SkillBrowser-8s8rjv98.js +5 -0
  35. package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-8s8rjv98.js.map} +2 -2
  36. package/dist/WavPackParser-w515nnw2.js +5 -0
  37. package/dist/WavPackParser-w515nnw2.js.map +11 -0
  38. package/dist/WaveParser-sb0w9m20.js +5 -0
  39. package/dist/WaveParser-sb0w9m20.js.map +13 -0
  40. package/dist/WizardApp-wr1tftcr.js +5 -0
  41. package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-wr1tftcr.js.map} +3 -3
  42. package/dist/agents.d.ts +19 -3
  43. package/dist/agents.d.ts.map +1 -1
  44. package/dist/channels-gx951qdp.js +31 -0
  45. package/dist/channels-gx951qdp.js.map +10 -0
  46. package/dist/channels.d.ts +26 -0
  47. package/dist/channels.d.ts.map +1 -0
  48. package/dist/client.js +11 -11
  49. package/dist/client.js.map +3 -3
  50. package/dist/config-wvjeejgd.js +24 -0
  51. package/dist/{config-g7za9x13.js.map → config-wvjeejgd.js.map} +2 -2
  52. package/dist/credential-10dn3fxj.js +19 -0
  53. package/dist/{credential-npr6z8c8.js.map → credential-10dn3fxj.js.map} +1 -1
  54. package/dist/daemon.d.ts.map +1 -1
  55. package/dist/index-10009hp8.js +11 -0
  56. package/dist/index-10009hp8.js.map +11 -0
  57. package/dist/index-1xwrkwh5.js +14 -0
  58. package/dist/index-1xwrkwh5.js.map +50 -0
  59. package/dist/index-34p39yfc.js +47 -0
  60. package/dist/index-34p39yfc.js.map +15 -0
  61. package/dist/index-3y96s740.js +6 -0
  62. package/dist/{index-hwpvhaza.js.map → index-3y96s740.js.map} +1 -1
  63. package/dist/index-4ybeefmn.js +6 -0
  64. package/dist/index-4ybeefmn.js.map +11 -0
  65. package/dist/index-59z88wrb.js +6 -0
  66. package/dist/{index-h9mw7b9d.js.map → index-59z88wrb.js.map} +2 -2
  67. package/dist/index-5fwzn21m.js +6 -0
  68. package/dist/{index-gz9x25tz.js.map → index-5fwzn21m.js.map} +2 -2
  69. package/dist/index-6dvnfk8y.js +6 -0
  70. package/dist/index-6dvnfk8y.js.map +10 -0
  71. package/dist/index-6p70fnb7.js +153 -0
  72. package/dist/index-6p70fnb7.js.map +20 -0
  73. package/dist/index-6s471ydn.js +12 -0
  74. package/dist/{index-j55s3ehk.js.map → index-6s471ydn.js.map} +2 -2
  75. package/dist/index-87wcawta.js +6 -0
  76. package/dist/{index-0d93hyfc.js.map → index-87wcawta.js.map} +2 -2
  77. package/dist/index-92gfcbw0.js +6 -0
  78. package/dist/index-92gfcbw0.js.map +9 -0
  79. package/dist/index-a0h0p20f.js +991 -0
  80. package/dist/{index-tv4yv7d2.js.map → index-a0h0p20f.js.map} +27 -23
  81. package/dist/index-bamw24xc.js +6 -0
  82. package/dist/{index-6q4wf8e3.js.map → index-bamw24xc.js.map} +1 -1
  83. package/dist/index-c8ge88a9.js +12 -0
  84. package/dist/{index-258d8bzg.js.map → index-c8ge88a9.js.map} +4 -3
  85. package/dist/index-cb2q8nae.js +6 -0
  86. package/dist/index-cb2q8nae.js.map +13 -0
  87. package/dist/index-ct6bw0a6.js +6 -0
  88. package/dist/{index-4z7axw4r.js.map → index-ct6bw0a6.js.map} +1 -1
  89. package/dist/index-cz6yjxyz.js +10 -0
  90. package/dist/index-cz6yjxyz.js.map +42 -0
  91. package/dist/index-d0c5abkw.js +6 -0
  92. package/dist/{index-vgc3y3rm.js.map → index-d0c5abkw.js.map} +3 -3
  93. package/dist/index-d0vagham.js +31 -0
  94. package/dist/index-d0vagham.js.map +188 -0
  95. package/dist/index-d0zxvr99.js +90 -0
  96. package/dist/index-d0zxvr99.js.map +13 -0
  97. package/dist/{index-s9mbq7h6.js → index-d9c97ver.js} +4 -4
  98. package/dist/{index-s9mbq7h6.js.map → index-d9c97ver.js.map} +1 -1
  99. package/dist/index-e508e0vt.js +6 -0
  100. package/dist/{index-tf71ap9v.js.map → index-e508e0vt.js.map} +1 -1
  101. package/dist/index-esq0knqx.js +6 -0
  102. package/dist/index-esq0knqx.js.map +10 -0
  103. package/dist/index-featyhps.js +6 -0
  104. package/dist/index-featyhps.js.map +10 -0
  105. package/dist/index-fnq44zdt.js +45 -0
  106. package/dist/index-fnq44zdt.js.map +74 -0
  107. package/dist/index-gmn80dwc.js +7 -0
  108. package/dist/{index-02dn6m2j.js.map → index-gmn80dwc.js.map} +2 -2
  109. package/dist/index-gwhx69qs.js +66 -0
  110. package/dist/index-gwhx69qs.js.map +12 -0
  111. package/dist/index-kjgzhf3w.js +9 -0
  112. package/dist/{index-6p999cx4.js.map → index-kjgzhf3w.js.map} +4 -6
  113. package/dist/index-m68cd91a.js +12 -0
  114. package/dist/index-m68cd91a.js.map +23 -0
  115. package/dist/{index-3g3ny01d.js → index-mhmgw54j.js} +4 -4
  116. package/dist/{index-3g3ny01d.js.map → index-mhmgw54j.js.map} +1 -1
  117. package/dist/{index-gme2egyq.js → index-qm612hwa.js} +4 -4
  118. package/dist/{index-gme2egyq.js.map → index-qm612hwa.js.map} +1 -1
  119. package/dist/{index-j7gyr5nx.js → index-qwntpbwe.js} +7 -7
  120. package/dist/{index-j7gyr5nx.js.map → index-qwntpbwe.js.map} +1 -1
  121. package/dist/index-qx3xdk4x.js +6 -0
  122. package/dist/{index-d4x6yvqh.js.map → index-qx3xdk4x.js.map} +3 -4
  123. package/dist/{index-4cf6v9nb.js → index-rh0meegk.js} +4 -4
  124. package/dist/{index-4cf6v9nb.js.map → index-rh0meegk.js.map} +1 -1
  125. package/dist/index-ryb159ff.js +9 -0
  126. package/dist/{index-ff514z3y.js.map → index-ryb159ff.js.map} +3 -5
  127. package/dist/{index-ammv5st7.js → index-s6zfpyqa.js} +6 -6
  128. package/dist/{index-ammv5st7.js.map → index-s6zfpyqa.js.map} +1 -1
  129. package/dist/index-s9va2kmc.js +429 -0
  130. package/dist/index-s9va2kmc.js.map +11 -0
  131. package/dist/index-v5dmsgpx.js +7 -0
  132. package/dist/index-v5dmsgpx.js.map +11 -0
  133. package/dist/index-vaj3mn3a.js +6 -0
  134. package/dist/index-vaj3mn3a.js.map +14 -0
  135. package/dist/index-vy0rbzws.js +6 -0
  136. package/dist/{index-fex44816.js.map → index-vy0rbzws.js.map} +2 -2
  137. package/dist/index-w0s77wfx.js +6 -0
  138. package/dist/{index-v8e92nfw.js.map → index-w0s77wfx.js.map} +1 -1
  139. package/dist/index-wx1jzjzr.js +6 -0
  140. package/dist/{index-qdbq8crg.js.map → index-wx1jzjzr.js.map} +2 -2
  141. package/dist/index-xbn26c8g.js +126 -0
  142. package/dist/index-xbn26c8g.js.map +14 -0
  143. package/dist/index-ytvwyp6k.js +6 -0
  144. package/dist/{index-9r0wyj6w.js.map → index-ytvwyp6k.js.map} +2 -2
  145. package/dist/{index-cqqb6gaq.js → index-yvnwpxbb.js} +5 -5
  146. package/dist/{index-cqqb6gaq.js.map → index-yvnwpxbb.js.map} +1 -1
  147. package/dist/index.js +379 -448
  148. package/dist/index.js.map +26 -28
  149. package/dist/init.d.ts.map +1 -1
  150. package/dist/lib/agent-secrets.d.ts +38 -0
  151. package/dist/lib/agent-secrets.d.ts.map +1 -0
  152. package/dist/lib/agent-template.d.ts +54 -0
  153. package/dist/lib/agent-template.d.ts.map +1 -0
  154. package/dist/lib/channel-actions.d.ts +103 -0
  155. package/dist/lib/channel-actions.d.ts.map +1 -0
  156. package/dist/lib/chat-frame.d.ts +12 -1
  157. package/dist/lib/chat-frame.d.ts.map +1 -1
  158. package/dist/lib/commands.d.ts +13 -0
  159. package/dist/lib/commands.d.ts.map +1 -1
  160. package/dist/lib/const.d.ts +1 -1
  161. package/dist/lib/daemon-plan.d.ts.map +1 -1
  162. package/dist/lib/help.d.ts.map +1 -1
  163. package/dist/lib/host-actions.d.ts +121 -0
  164. package/dist/lib/host-actions.d.ts.map +1 -0
  165. package/dist/lib/init-flow.d.ts +32 -0
  166. package/dist/lib/init-flow.d.ts.map +1 -1
  167. package/dist/lib/init-whatsapp.d.ts +52 -0
  168. package/dist/lib/init-whatsapp.d.ts.map +1 -0
  169. package/dist/lib/plugin-install.d.ts +120 -0
  170. package/dist/lib/plugin-install.d.ts.map +1 -0
  171. package/dist/lib/providers.d.ts.map +1 -1
  172. package/dist/lib/provision.d.ts +13 -0
  173. package/dist/lib/provision.d.ts.map +1 -1
  174. package/dist/lib/readme-table.d.ts +15 -0
  175. package/dist/lib/readme-table.d.ts.map +1 -0
  176. package/dist/lib/sandbox.d.ts +17 -0
  177. package/dist/lib/sandbox.d.ts.map +1 -1
  178. package/dist/lib/schema.d.ts +34 -1
  179. package/dist/lib/schema.d.ts.map +1 -1
  180. package/dist/lib/subcommand.d.ts.map +1 -1
  181. package/dist/lib/web-url.d.ts +15 -0
  182. package/dist/lib/web-url.d.ts.map +1 -0
  183. package/dist/lib/wizard.d.ts.map +1 -1
  184. package/dist/memory.d.ts.map +1 -1
  185. package/dist/model.d.ts.map +1 -1
  186. package/dist/plugins.d.ts +27 -8
  187. package/dist/plugins.d.ts.map +1 -1
  188. package/dist/restart.d.ts +21 -0
  189. package/dist/restart.d.ts.map +1 -0
  190. package/dist/run.d.ts.map +1 -1
  191. package/dist/schedules.d.ts.map +1 -1
  192. package/dist/serve.d.ts.map +1 -1
  193. package/dist/sessions.d.ts.map +1 -1
  194. package/dist/skills.d.ts.map +1 -1
  195. package/dist/status.d.ts +16 -0
  196. package/dist/status.d.ts.map +1 -0
  197. package/dist/tools.d.ts.map +1 -1
  198. package/dist/validate.d.ts.map +1 -1
  199. package/dist/web-61cjhpv2.js +14 -0
  200. package/dist/{web-vkb16r62.js.map → web-61cjhpv2.js.map} +3 -3
  201. package/dist/web.d.ts +2 -13
  202. package/dist/web.d.ts.map +1 -1
  203. package/dist/workspace.d.ts.map +1 -1
  204. package/dist/wrapper-9msjh1xg.js +5 -0
  205. package/dist/wrapper-9msjh1xg.js.map +9 -0
  206. package/package.json +6 -3
  207. package/dist/App-b1yrwrcq.js +0 -11
  208. package/dist/ConfigEditor-n8hdw6r7.js +0 -6
  209. package/dist/KeyProbe-9jjeze5r.js +0 -5
  210. package/dist/Picker-hfeh1g6m.js +0 -5
  211. package/dist/SessionPicker-zyqkg4dn.js +0 -5
  212. package/dist/SkillBrowser-3qdp8080.js +0 -5
  213. package/dist/WizardApp-vzpbydy3.js +0 -5
  214. package/dist/config-g7za9x13.js +0 -24
  215. package/dist/credential-npr6z8c8.js +0 -19
  216. package/dist/index-02dn6m2j.js +0 -7
  217. package/dist/index-0d93hyfc.js +0 -6
  218. package/dist/index-1c5113t4.js +0 -66
  219. package/dist/index-1c5113t4.js.map +0 -12
  220. package/dist/index-258d8bzg.js +0 -12
  221. package/dist/index-4z7axw4r.js +0 -6
  222. package/dist/index-6p999cx4.js +0 -9
  223. package/dist/index-6q4wf8e3.js +0 -6
  224. package/dist/index-9r0wyj6w.js +0 -6
  225. package/dist/index-d4x6yvqh.js +0 -6
  226. package/dist/index-fecm8xe7.js +0 -77
  227. package/dist/index-fecm8xe7.js.map +0 -12
  228. package/dist/index-fex44816.js +0 -6
  229. package/dist/index-ff514z3y.js +0 -14
  230. package/dist/index-gz9x25tz.js +0 -6
  231. package/dist/index-h9mw7b9d.js +0 -6
  232. package/dist/index-hwpvhaza.js +0 -6
  233. package/dist/index-j55s3ehk.js +0 -12
  234. package/dist/index-mtn0g9vc.js +0 -7
  235. package/dist/index-mtn0g9vc.js.map +0 -11
  236. package/dist/index-qdbq8crg.js +0 -6
  237. package/dist/index-tf71ap9v.js +0 -6
  238. package/dist/index-ttwyrdjs.js +0 -427
  239. package/dist/index-ttwyrdjs.js.map +0 -11
  240. package/dist/index-tv4yv7d2.js +0 -903
  241. package/dist/index-ty24n0jh.js +0 -167
  242. package/dist/index-ty24n0jh.js.map +0 -19
  243. package/dist/index-v8e92nfw.js +0 -6
  244. package/dist/index-vgc3y3rm.js +0 -6
  245. package/dist/index-whaw4b18.js +0 -6
  246. package/dist/index-whaw4b18.js.map +0 -10
  247. package/dist/web-vkb16r62.js +0 -14
@@ -5,7 +5,7 @@
5
5
  "/**\n * A grouped, scrolling, column-aligned multi-select list. One row is one line, always.\n *\n * Not `SelectList` with a flag: rows can be *headings* the cursor skips, rows carry a ticked state, and the\n * list is longer than a terminal, so it needs a viewport. Bending the existing component to do all three\n * would leave both callers reading conditionals.\n *\n * ## One row, one line\n *\n * The first version handed the whole description to Ink and let it wrap. Every long row became two or\n * three lines, the checkbox column stopped lining up, and forty skills were unreadable. All the width\n * arithmetic is in `lib/rows.ts` now — pure, so the layout is asserted as strings — and every field is\n * truncated before it can wrap. `wrap=\"truncate\"` is set as well, but a backstop is not a layout: if the\n * columns did not add up, the cut would land at a width nobody chose.\n *\n * Controlled and presentational, like every component here: the cursor and the chosen set come from\n * `lib/multiselect.ts`, and the screen root owns the single `useInput`. Keyed on the row index rather than\n * the label, because two sources can carry a skill of the same name and a label key would collapse them.\n */\n\nimport { Box, Text } from \"ink\"\nimport { columnsFor, headingRule, layoutRow, viewport } from \"#lib/rows\"\nimport { GLYPH, THEME } from \"#lib/theme\"\n\nexport interface CheckRow {\n /** `source` is a top-level heading, `group` a subheading; neither is selectable. */\n readonly kind: \"source\" | \"group\" | \"item\"\n readonly label: string\n /** Right-aligned column: size and script count, or `installed`. */\n readonly meta?: string\n readonly description?: string\n}\n\nexport interface CheckListProps {\n readonly rows: readonly CheckRow[]\n readonly index: number\n readonly chosen: readonly number[]\n /** Visible rows. The list scrolls inside this rather than growing past the terminal. */\n readonly window: number\n /** Terminal columns. Measured by the caller; this component never reads a stream. */\n readonly width: number\n}\n\nexport function CheckList({ rows, index, chosen, window, width }: CheckListProps) {\n const { from, to } = viewport(rows.length, index, window)\n const picked = new Set(chosen)\n const longest = rows.reduce(\n (max, row) => (row.kind === \"item\" ? Math.max(max, row.label.length) : max),\n 0,\n )\n const columns = columnsFor(width, longest)\n\n return (\n <Box flexDirection=\"column\">\n {from > 0 ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {from} above\n </Text>\n ) : null}\n {rows.slice(from, to).map((row, offset) => {\n const at = from + offset\n if (row.kind !== \"item\") {\n const source = row.kind === \"source\"\n return (\n <Text\n key={at}\n wrap=\"truncate\"\n bold={source}\n color={source ? THEME.accent : THEME.muted}\n >\n {source ? \" \" : \" \"}\n {headingRule(row.label, width - (source ? 2 : 4))}\n </Text>\n )\n }\n const selected = at === index\n const ticked = picked.has(at)\n const cells = layoutRow(\n {\n name: row.label,\n meta: row.meta ?? \"\",\n description: row.description ?? \"\",\n },\n columns,\n )\n return (\n <Text key={at} wrap=\"truncate\">\n <Text color={THEME.accent}>{selected ? GLYPH.pointer : \" \"}</Text>\n <Text color={ticked ? THEME.success : THEME.muted}>\n {ticked ? GLYPH.checked : GLYPH.unchecked}\n </Text>\n <Text bold={selected} {...(ticked ? { color: THEME.success } : {})}>\n {cells.name}\n </Text>\n {\" \"}\n <Text color={THEME.muted}>{cells.meta}</Text>\n {cells.description === \"\" ? \"\" : \" \"}\n <Text dimColor>{cells.description}</Text>\n </Text>\n )\n })}\n {to < rows.length ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {rows.length - to} below\n </Text>\n ) : null}\n </Box>\n )\n}\n",
6
6
  "/**\n * The multi-select reducer: move a cursor, toggle rows, read back what was chosen.\n *\n * Pure, and PURE-listed for the same reason `select.ts` is — one `useInput` per screen root over a pure\n * keymap and a pure reducer, so the behaviour is unit-testable without mounting Ink and the component\n * cannot grow a second copy of the rules.\n *\n * `chosen` is a sorted index array rather than a `Set`, and that is deliberate: it makes the state\n * structurally comparable in a test (`toEqual`), keeps React's identity checks honest, and fixes the\n * install order to the order shown on screen — which is what somebody expects after ticking four boxes\n * top to bottom.\n *\n * Rows that are group headings are not selectable, so `count` alone is not enough: the reducer needs to\n * know which indices are real. `selectable` is passed in rather than derived, because the same reducer\n * serves a flat list (every row selectable) and a grouped one.\n */\n\nimport { moveSelect, type SelectMove, type SelectState } from \"#lib/select\"\n\nexport interface MultiSelectState {\n readonly cursor: SelectState\n /** Indices into the full row list, ascending. */\n readonly chosen: readonly number[]\n}\n\nexport type MultiSelectAction =\n | { readonly kind: \"move\"; readonly move: SelectMove }\n | { readonly kind: \"toggle\" }\n | { readonly kind: \"all\" }\n | { readonly kind: \"none\" }\n\nexport function startMultiSelect(count: number): MultiSelectState {\n return { cursor: { index: 0, count }, chosen: [] }\n}\n\n/**\n * Walk from a landing point until a selectable row is found, in one direction.\n *\n * `undefined` when the walk reaches the end of the list without finding one. Detected by the index\n * stopping rather than by counting: `moveSelect` clamps at both ends, so a walk that has run out of\n * list returns the same index forever, and *that* is the honest end condition.\n */\nfunction walk(\n from: SelectState,\n selectable: readonly boolean[],\n forward: boolean,\n): SelectState | undefined {\n let next = from\n for (let step = 0; step <= selectable.length; step += 1) {\n if (selectable[next.index] === true) return next\n const after = moveSelect(next, { kind: forward ? \"down\" : \"up\" })\n if (after.index === next.index) return undefined\n next = after\n }\n return undefined\n}\n\n/**\n * Put the cursor on a selectable row, given where it was and where the move would have put it.\n *\n * Without this the cursor lands on a group heading and enter does nothing, which reads as a broken\n * keyboard. Group headings are the reason it exists, and the first row of a grouped list is always one.\n *\n * Three passes, in order, and the order is the whole correctness argument:\n *\n * 1. **Continue the way it was going.** Down past a heading keeps going down.\n * 2. **Reverse.** The walk ran out of list — pressing up on the first skill of a grouped catalogue lands\n * on the source heading with nothing selectable above it, so the answer is the row below, which is\n * where the cursor already was. This pass is also what makes `g` (first) and `G` (last) work: `g`\n * lands on row 0, which in a grouped list is always a heading, and only a downward search finds\n * anything.\n * 3. **Stay put.** Nothing anywhere is selectable.\n *\n * Returning `moved` on exhaustion — which is what the first version did, by falling through to its own\n * parameter — put the cursor on the heading. That is the bug this function exists to prevent, wearing\n * the fix's clothes, and a frame test caught it by noticing the pointer had vanished from the list\n * entirely: a heading row draws no cursor, so parking there makes the cursor *invisible* as well as\n * inert.\n */\nfunction selectableCursor(\n from: SelectState,\n moved: SelectState,\n selectable: readonly boolean[],\n forward: boolean,\n): SelectState {\n if (selectable.length === 0) return from\n return walk(moved, selectable, forward) ?? walk(moved, selectable, !forward) ?? from\n}\n\nexport function reduceMultiSelect(\n state: MultiSelectState,\n action: MultiSelectAction,\n selectable: readonly boolean[],\n): MultiSelectState {\n switch (action.kind) {\n case \"move\": {\n // With nothing selectable the cursor does not move at all, rather than moving onto a heading:\n // parking it on an unselectable row is the exact thing `skipUnselectable` exists to prevent, so\n // doing it as a fallback would be the bug wearing the fix's clothes.\n if (!selectable.includes(true)) return state\n const moved = moveSelect(state.cursor, action.move)\n // Derived from where the cursor actually went rather than from the kind of move, because\n // the two disagree for `first` and `last`: `g` travels *backwards* to row 0 and then has to\n // search *forwards* to find anything selectable. Reading it off the indices makes every\n // move kind — including a digit jump — fall out of one rule.\n const forward = moved.index >= state.cursor.index\n return { ...state, cursor: selectableCursor(state.cursor, moved, selectable, forward) }\n }\n case \"toggle\": {\n const index = state.cursor.index\n if (selectable[index] !== true) return state\n const chosen = state.chosen.includes(index)\n ? state.chosen.filter((entry) => entry !== index)\n : [...state.chosen, index].sort((a, b) => a - b)\n return { ...state, chosen }\n }\n case \"all\": {\n const chosen = selectable.flatMap((ok, index) => (ok ? [index] : []))\n return { ...state, chosen }\n }\n case \"none\":\n return { ...state, chosen: [] }\n }\n}\n\n/** Where the cursor should start: the first selectable row, never a heading. */\nexport function firstSelectable(selectable: readonly boolean[]): number {\n const index = selectable.indexOf(true)\n return index === -1 ? 0 : index\n}\n"
7
7
  ],
8
- "mappings": ";mFAoBA,cAAS,UAAK,8DAuBP,SAAS,EAAS,EAAG,OAAM,QAAO,SAAQ,SAAQ,SAAyB,CAC9E,IAAQ,OAAM,MAAO,EAAS,EAAK,OAAQ,EAAO,CAAM,EAClD,EAAS,IAAI,IAAI,C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AM,EAAQ,GAAW,EAAM,OAAQ,EAAO,IAAI,EAK5C,EAAU,EAAM,OAAS,EAAM,OAAO,MAC5C,MAAO,IAAK,EAAO,OAAQ,EAAiB,EAAM,OAAQ,EAAO,EAAY,CAAO,CAAE,CAC1F,KACK,SAAU,CACX,IAAM,EAAQ,EAAM,OAAO,MAC3B,GAAI,EAAW,KAAW,GAAM,OAAO,EACvC,IAAM,EAAS,EAAM,OAAO,SAAS,CAAK,EACpC,EAAM,OAAO,OAAO,CAAC,IAAU,IAAU,CAAK,EAC9C,CAAC,GAAG,EAAM,OAAQ,CAAK,EAAE,KAAK,CAAC,EAAG,IAAM,EAAI,CAAC,EACnD,MAAO,IAAK,EAAO,QAAO,CAC9B,KACK,MAAO,CACR,IAAM,EAAS,EAAW,QAAQ,CAAC,EAAI,IAAW,EAAK,CAAC,CAAK,EAAI,CAAC,CAAE,EACpE,MAAO,IAAK,EAAO,QAAO,CAC9B,KACK,OACD,MAAO,IAAK,EAAO,OAAQ,CAAC,CAAE,GAKnC,SAAS,EAAe,CAAC,EAAwC,CACpE,IAAM,EAAQ,EAAW,QAAQ,EAAI,EACrC,OAAO,IAAU,GAAK,EAAI",
9
+ "debugId": "E31D406A2454B63464756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{i,Si,As}from"./index-qx3xdk4x.js";import{Text as e}from"ink";import{useEffect as a,useState as c}from"react";import{jsx as f,jsxs as l}from"react/jsx-runtime";function He({label:r}){let[t,n]=c(0);return a(()=>{let o=setInterval(()=>n((p)=>(p+1)%Si.length),As);return()=>clearInterval(o)},[]),l(e,{children:[f(e,{color:i.accent,children:Si[t]})," ",r]})}
3
+ export{He};
4
+
5
+ //# debugId=D7161FDEA142E8DB64756E2164756E21
6
+ //# sourceMappingURL=index-w0s77wfx.js.map
@@ -5,6 +5,6 @@
5
5
  "/**\n * A braille spinner with a label. Ten glyphs from the theme, not a dependency (decision 11.10).\n *\n * The one kit component with its own state — the frame index — because animation is presentation,\n * not application state. Callers pair it with `useElapsed` when a count-up matters (the picker's\n * boot transition); it is deliberately not used in the init wizard, whose write-and-validate\n * completes in single-digit milliseconds and would only flash.\n */\n\nimport { Text } from \"ink\"\nimport { useEffect, useState } from \"react\"\nimport { SPINNER_FRAMES, SPINNER_INTERVAL_MS, THEME } from \"#lib/theme\"\n\nexport interface SpinnerProps {\n readonly label: string\n}\n\nexport function Spinner({ label }: SpinnerProps) {\n const [frame, setFrame] = useState(0)\n useEffect(() => {\n const timer = setInterval(\n () => setFrame((current) => (current + 1) % SPINNER_FRAMES.length),\n SPINNER_INTERVAL_MS,\n )\n return () => clearInterval(timer)\n }, [])\n\n return (\n <Text>\n <Text color={THEME.accent}>{SPINNER_FRAMES[frame]}</Text> {label}\n </Text>\n )\n}\n"
6
6
  ],
7
7
  "mappings": ";yCASA,eAAS,YACT,oBAAS,cAAW,gEAOb,SAAS,EAAO,EAAG,SAAuB,CAC7C,IAAO,EAAO,GAAY,EAAS,CAAC,EASpC,OARA,EAAU,IAAM,CACZ,IAAM,EAAQ,YACV,IAAM,EAAS,CAAC,KAAa,EAAU,GAAK,GAAe,MAAM,EACjE,EACJ,EACA,MAAO,IAAM,cAAc,CAAK,GACjC,CAAC,CAAC,EAGD,EAEE,EAFF,UAEE,CADE,EAAoD,EAApD,CAAM,MAAO,EAAM,OAAnB,SAA4B,GAAe,GAAS,EADxD,IAC+D,GAC7D",
8
- "debugId": "E77E7B6E92961D7C64756E2164756E21",
8
+ "debugId": "D7161FDEA142E8DB64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{A,L,K,J,ie,M}from"./index-a0h0p20f.js";import{G,X}from"./index-v5dmsgpx.js";async function cr(n,s,e){let r=[];if(n.length===0)for(let i of X(s)){if(i.problem!==void 0||i.id===void 0)continue;r.push({agentId:i.id,manifestPath:i.manifestPath})}else for(let i of n){let t=L(i);r.push({agentId:t.id??"",manifestPath:i})}let a=await u(async(i)=>new Map((await i.agentState.list()).filter((t)=>!t.enabled).map((t)=>[t.agentId,t.reason])),e);return r.map((i)=>{let t=a?.get(i.agentId),o=a?.has(i.agentId)===!0;return{...i,enabled:!o,...t===void 0?{}:{reason:t}}})}async function u(n,s){let e;try{return e=await ie.open({path:s??G()}),await n(e)}catch{return}finally{await e?.close()}}async function Bo(n,s,e,r){await u(async(a)=>{if(s)await a.agentState.enable(n);else await a.agentState.disable(n,new Date().toISOString(),e===void 0?void 0:e)},r)}async function po(n,s){return await u(async(e)=>{let r=await e.agentState.get(n);if(r===void 0)return{enabled:!0};return{enabled:r.enabled,...r.reason===void 0?{}:{reason:r.reason}}},s)}async function ke(n,s){return await u(async(e)=>{let r=await e.leases.get(n);if(r===void 0)return;if(r.pid===process.pid||!J(r.pid))return;return r},s)}async function _e(n){return[...(await uA(n)).filter((e)=>e.baseUrl!==void 0)].sort((e,r)=>e.agentId.localeCompare(r.agentId))[0]}async function uA(n){return await u(async(s)=>(await s.leases.all()).filter((e)=>e.pid!==process.pid&&J(e.pid)),n)??[]}function Ie(n){return n===void 0||n===""?"":L(n).id??""}function st(n){let s=process.env[`${A.envPrefix}API_TOKEN`];try{let e=K(n,{env:M([n])}),r=e.env[e.manifest.server.tokenEnv];return r===void 0||r===""?s:r}catch{return s===""?void 0:s}}async function ze(n,s,e,r){let a=n.baseUrl;if(a===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let i=r===void 0?void 0:st(r);try{let t=await fetch(`${a}${s}`,{method:"POST",headers:{"content-type":"application/json",...i===void 0?{}:{authorization:`Bearer ${i}`}},body:JSON.stringify(e),signal:AbortSignal.timeout(f)});if(t.ok){let d=await t.json().catch(()=>{return});return{ok:!0,status:t.status,...d===void 0?{}:{body:d}}}let o=await t.json().catch(()=>{return});return{ok:!1,status:t.status,...o?.error?.message===void 0?{}:{detail:o.error.message},...o?.error?.hint===void 0?{}:{hint:o.error.hint}}}catch(t){return{ok:!1,status:0,detail:t instanceof Error?t.message:String(t)}}}async function _t(n,s,e,r){let a=n.baseUrl;if(a===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let i=r===void 0?void 0:st(r);try{let t=await fetch(`${a}${e}`,{method:s,headers:i===void 0?{}:{authorization:`Bearer ${i}`},signal:AbortSignal.timeout(f)}),o=await t.json().catch(()=>{return});if(t.ok)return{ok:!0,status:t.status,...o===void 0?{}:{body:o}};let d=o;return{ok:!1,status:t.status,...d?.error?.message===void 0?{}:{detail:d.error.message},...d?.error?.hint===void 0?{}:{hint:d.error.hint}}}catch(t){return{ok:!1,status:0,detail:t instanceof Error?t.message:String(t)}}}var f=1e4;function hn(n,s){for(let e of X(s))if(e.id===n)return e.manifestPath;return}
3
+ export{cr,Bo,po,ke,_e,uA,Ie,st,ze,_t,hn};
4
+
5
+ //# debugId=A265DBA254BD202C64756E2164756E21
6
+ //# sourceMappingURL=index-wx1jzjzr.js.map
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * Reaching a running host, and reading the durable on/off switch.\n *\n * Shared by `serve`, `stop` and `start`, because all three ask the same two questions and a second\n * answer to either is a disagreement waiting to happen: *which agents is this sandbox supposed to\n * run*, and *where is the process already running them*.\n *\n * **Why an HTTP request rather than a signal.** Since one process hosts several agents, stopping\n * one by signalling the lease holder takes every other agent in that process down with it. A signal\n * also cannot name an agent. So `stop` posts to the host, which disposes exactly one — and the\n * address comes off the lease row rather than from a manifest, because `--port` overrides the file,\n * `--port 0` picks one at random and a container republishes it. Guessing 7420 is how a second host\n * on 7421 becomes invisible to the one command that must never miss it.\n *\n * **The fallback is the old behaviour, not an error.** A lease with no address is a `run` REPL or an\n * embedded runtime — real states, serving no HTTP — and those are still stopped by signalling the\n * process, which is what `stop` did for every lease before any of this existed.\n */\n\nimport { dirname } from \"node:path\"\nimport {\n BRAND,\n type LeaseRecord,\n loadManifest,\n processAlive,\n readManifestHeader,\n SqliteStore,\n} from \"@dispach/core\"\nimport { ambientEnv } from \"#lib/ambient\"\nimport { listAgents, storePath } from \"#lib/sandbox\"\n\n/** An agent the sandbox holds, with the durable switch resolved. */\nexport interface HostableAgent {\n readonly agentId: string\n readonly manifestPath: string\n readonly enabled: boolean\n /** Why it was switched off, when somebody said. */\n readonly reason?: string\n}\n\n/**\n * The manifests a bare `serve` should host, and the ones it should not.\n *\n * A listing rather than a filter, because the caller has to *report* what it is skipping: an agent\n * missing from a banner with no line explaining it is the \"I set this up and it is not running\"\n * failure the switch exists to make explicable.\n *\n * Broken entries are dropped here rather than surfaced, and that is the one thing this hides: a\n * directory whose header will not parse has no id, so there is nothing to look the state up by and\n * nothing to serve. the agents listing is what shows those, and it shows them already.\n */\nexport async function hostableAgents(\n paths: readonly string[],\n env: Readonly<Record<string, string | undefined>>,\n store?: string,\n): Promise<readonly HostableAgent[]> {\n const found: { agentId: string; manifestPath: string }[] = []\n\n if (paths.length === 0) {\n // The bare form: whatever the sandbox holds. This is what the service unit runs, and it is\n // why `agent_state` exists — \"every agent here\" needs an answer to \"except which\".\n for (const agent of listAgents(env)) {\n if (agent.problem !== undefined || agent.id === undefined) continue\n found.push({ agentId: agent.id, manifestPath: agent.manifestPath })\n }\n } else {\n for (const manifestPath of paths) {\n // The header, not a full load: reading a manifest to learn its id must not depend on\n // the agent's credentials being present, which is the whole reason\n // `readManifestHeader` exists and why the picker is built on it.\n const header = readManifestHeader(manifestPath)\n found.push({ agentId: header.id ?? \"\", manifestPath })\n }\n }\n\n const disabled = await withStore(\n async (db) =>\n new Map(\n (await db.agentState.list())\n .filter((row) => !row.enabled)\n .map((row) => [row.agentId, row.reason]),\n ),\n store,\n )\n\n return found.map((entry) => {\n const reason = disabled?.get(entry.agentId)\n const off = disabled?.has(entry.agentId) === true\n return {\n ...entry,\n enabled: !off,\n ...(reason === undefined ? {} : { reason }),\n }\n })\n}\n\n/**\n * Open the store, ask one question, close it.\n *\n * Deliberately a second, short-lived connection rather than the one `Runtime.create` opens: the\n * answer is needed *before* the runtime exists, because it decides which agents the runtime is\n * asked for. Handing the runtime a caller-owned store would work and would move shutdown ownership\n * into the command, which is a larger change than one sequential read deserves — the migrations are\n * already applied, so this costs a couple of milliseconds.\n *\n * `undefined` on any failure, and the callers treat that as \"nothing is disabled\". A missing store\n * is the ordinary first-run state, and a `serve` that refused to start because it could not read an\n * on/off table would be a worse failure than the one it was guarding against.\n *\n * **The path is threaded rather than defaulted at each call site**, because `serve` honours\n * `--store` and these helpers did not — so a host serving out of one database would have read its\n * on/off switch from another. Invisible in normal use, where both resolve to the sandbox, and\n * wrong in exactly the configuration the tests use.\n */\nasync function withStore<T>(\n work: (store: SqliteStore) => Promise<T>,\n path?: string,\n): Promise<T | undefined> {\n let store: SqliteStore | undefined\n try {\n store = await SqliteStore.open({ path: path ?? storePath() })\n return await work(store)\n } catch {\n return undefined\n } finally {\n await store?.close()\n }\n}\n\n/** The durable switch, written from a command rather than through a host. */\nexport async function writeAgentState(\n agentId: string,\n enabled: boolean,\n reason?: string,\n store?: string,\n): Promise<void> {\n await withStore(async (db) => {\n if (enabled) await db.agentState.enable(agentId)\n else\n await db.agentState.disable(\n agentId,\n new Date().toISOString(),\n reason === undefined ? undefined : reason,\n )\n }, store)\n}\n\n/** Whether this agent is switched off, and why. */\nexport async function agentStateOf(\n agentId: string,\n store?: string,\n): Promise<{ enabled: boolean; reason?: string } | undefined> {\n return await withStore(async (db) => {\n const row = await db.agentState.get(agentId)\n if (row === undefined) return { enabled: true }\n return { enabled: row.enabled, ...(row.reason === undefined ? {} : { reason: row.reason }) }\n }, store)\n}\n\n/**\n * The live process serving this agent, if there is one.\n *\n * Liveness is re-checked here rather than trusted from the row, for the recorded reason: a boot\n * that fails *after* claiming leaves a lease seconds old with no process under it, and anything\n * reading a lease to decide what to do has to probe rather than believe the heartbeat.\n */\nexport async function liveHostOf(\n agentId: string,\n store?: string,\n): Promise<LeaseRecord | undefined> {\n return await withStore(async (db) => {\n const lease = await db.leases.get(agentId)\n if (lease === undefined) return undefined\n if (lease.pid === process.pid || !processAlive(lease.pid)) return undefined\n return lease\n }, store)\n}\n\n/**\n * Any live host with an HTTP address, for `start`.\n *\n * **Not `liveHostOf(agentId)`, and that is the whole reason this exists.** A stopped agent has no\n * lease — `dispose` released it — so looking for \"the host holding this agent\" finds nothing and\n * `start` would report that nothing was running while a host sat there ready to adopt it. Found by\n * running the pair in order rather than by reading either one.\n *\n * With several hosts this asks the first by agent id. Nondeterministic and harmless: any host can\n * serve any agent in the sandbox, and one that cannot look the manifest up answers `501` rather\n * than failing quietly.\n */\nexport async function anyLiveHost(store?: string): Promise<LeaseRecord | undefined> {\n const hosts = (await liveHosts(store)).filter((lease) => lease.baseUrl !== undefined)\n return [...hosts].sort((a, b) => a.agentId.localeCompare(b.agentId))[0]\n}\n\n/** Every live lease, for the commands that report on the whole sandbox. */\nexport async function liveHosts(store?: string): Promise<readonly LeaseRecord[]> {\n return (\n (await withStore(\n async (db) =>\n (\n await db.leases.all()\n ).filter((lease) => lease.pid !== process.pid && processAlive(lease.pid)),\n store,\n )) ?? []\n )\n}\n\n/**\n * The credential a running host will want, best effort.\n *\n * The manifest's live env is the authority — that is where `serve` itself read the token from — so\n * this loads it. When the load fails it falls back to the process environment under the brand's\n * default variable, because the common reason for a failed load is a missing *model* key and\n * refusing to stop an agent over that would be absurd. A wrong or absent token is not silent: the\n * request comes back `401` and the caller says which variable to set.\n */\n/**\n * The agent id a manifest declares, without loading it.\n *\n * `readManifestHeader` rather than `loadManifest` for the reason `lib/sandbox.ts` already records:\n * loading checks that the key variables are set, so a *lookup* built on it fails exactly when the\n * agent is misconfigured — which is when you most need to name it. Here that would mean `run` and\n * `web` refusing to find a host for an agent whose `.env` is incomplete.\n */\nexport function agentIdFor(manifestPath: string | undefined): string {\n return manifestPath === undefined || manifestPath === \"\"\n ? \"\"\n : (readManifestHeader(manifestPath).id ?? \"\")\n}\n\nexport function hostToken(manifestPath: string): string | undefined {\n const fallback = process.env[`${BRAND.envPrefix}API_TOKEN`]\n try {\n const loaded = loadManifest(manifestPath, { env: ambientEnv([manifestPath]) })\n const configured = loaded.env[loaded.manifest.server.tokenEnv]\n return configured === undefined || configured === \"\" ? fallback : configured\n } catch {\n return fallback === \"\" ? undefined : fallback\n }\n}\n\nexport interface HostReply {\n readonly ok: boolean\n readonly status: number\n /** The server's own `error.message`, when it sent one. */\n readonly detail?: string\n /**\n * The parsed success body, for the callers that need one.\n *\n * `stop` and `start` only ever asked whether it worked, so this was discarded. Minting a\n * credential is the first caller that needs what came back — the secret is printed **once** and\n * exists nowhere else, so throwing the body away would make the command useless.\n */\n readonly body?: unknown\n /** The server's `error.hint`, which is the half a person acts on. */\n readonly hint?: string\n}\n\n/**\n * POST to a running host, with a bounded wait.\n *\n * Bounded because the alternative is a stop command that hangs on a wedged host, and the whole\n * brief for `stop` is that a person reaching for it is not in a position to go investigating. A\n * timeout falls through to the process-level stop, which is the thing that works on a host that has\n * stopped answering.\n */\nexport async function postToHost(\n lease: LeaseRecord,\n path: string,\n body: Readonly<Record<string, unknown>>,\n manifestPath?: string,\n): Promise<HostReply> {\n const base = lease.baseUrl\n if (base === undefined) return { ok: false, status: 0, detail: \"this host serves no HTTP\" }\n const token = manifestPath === undefined ? undefined : hostToken(manifestPath)\n\n try {\n const response = await fetch(`${base}${path}`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(token === undefined ? {} : { authorization: `Bearer ${token}` }),\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(HOST_TIMEOUT_MS),\n })\n if (response.ok) {\n const body: unknown = await response.json().catch(() => undefined)\n return {\n ok: true,\n status: response.status,\n ...(body === undefined ? {} : { body }),\n }\n }\n const parsed = (await response.json().catch(() => undefined)) as\n | { error?: { message?: string; hint?: string } }\n | undefined\n return {\n ok: false,\n status: response.status,\n ...(parsed?.error?.message === undefined ? {} : { detail: parsed.error.message }),\n ...(parsed?.error?.hint === undefined ? {} : { hint: parsed.error.hint }),\n }\n } catch (error) {\n return {\n ok: false,\n status: 0,\n detail: error instanceof Error ? error.message : String(error),\n }\n }\n}\n\n/**\n * Any method against a running host, with the same bound and the same error shape.\n *\n * `postToHost` is this with `POST` and a body; both exist because a `GET` with a `content-type` and\n * an empty body is a request some proxies mangle, and because the one-method version read better at\n * the four call sites that had it. This is what `credential list` and `credential revoke` need.\n */\nexport async function callHost(\n lease: LeaseRecord,\n method: string,\n path: string,\n manifestPath?: string,\n): Promise<HostReply> {\n const base = lease.baseUrl\n if (base === undefined) return { ok: false, status: 0, detail: \"this host serves no HTTP\" }\n const token = manifestPath === undefined ? undefined : hostToken(manifestPath)\n try {\n const response = await fetch(`${base}${path}`, {\n method,\n headers: token === undefined ? {} : { authorization: `Bearer ${token}` },\n signal: AbortSignal.timeout(HOST_TIMEOUT_MS),\n })\n const body: unknown = await response.json().catch(() => undefined)\n if (response.ok) {\n return { ok: true, status: response.status, ...(body === undefined ? {} : { body }) }\n }\n const parsed = body as { error?: { message?: string; hint?: string } } | undefined\n return {\n ok: false,\n status: response.status,\n ...(parsed?.error?.message === undefined ? {} : { detail: parsed.error.message }),\n ...(parsed?.error?.hint === undefined ? {} : { hint: parsed.error.hint }),\n }\n } catch (error) {\n return {\n ok: false,\n status: 0,\n detail: error instanceof Error ? error.message : String(error),\n }\n }\n}\n\n/** Long enough for a dispose that waits on a channel to stop, short enough not to read as a hang. */\nconst HOST_TIMEOUT_MS = 10_000\n\n/** The sandbox manifest declaring this id, for the host's `resolveAgent` lookup. */\nexport function manifestForId(\n agentId: string,\n env?: Readonly<Record<string, string | undefined>>,\n): string | undefined {\n for (const agent of listAgents(env)) {\n if (agent.id === agentId) return agent.manifestPath\n }\n return undefined\n}\n\n/** The directory an agent's manifest sits in, for messages that name a `.env`. */\nexport function agentDirOf(manifestPath: string): string {\n return dirname(manifestPath)\n}\n"
6
6
  ],
7
- "mappings": ";kFAmDA,eAAsB,EAAc,CAChC,EACA,EACA,EACiC,CACjC,IAAM,EAAqD,CAAC,EAE5D,GAAI,EAAM,SAAW,EAGjB,Q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AE,OAAQ,EAAO,MAAM,OAAQ,KAC3E,GAAQ,OAAO,OAAS,OAAY,CAAC,EAAI,CAAE,KAAM,EAAO,MAAM,IAAK,CAC3E,EACF,MAAO,EAAO,CACZ,MAAO,CACH,GAAI,GACJ,OAAQ,EACR,OAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CACjE,GAKR,IAAM,EAAkB,IAGjB,SAAS,EAAa,CACzB,EACA,EACkB,CAClB,QAAW,KAAS,EAAW,CAAG,EAC9B,GAAI,EAAM,KAAO,EAAS,OAAO,EAAM,aAE3C",
8
+ "debugId": "A265DBA254BD202C64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ import{A,x,t,v,fe,Ci,K,H,wA,pi,OA,UA,hi,M}from"./index-a0h0p20f.js";import{Ae}from"./index-34p39yfc.js";import{Pr,Fr,Ht}from"./index-qm612hwa.js";import{Oe,Je}from"./index-4ybeefmn.js";import{tA,P,Le,Xe}from"./index-kjgzhf3w.js";import{nA}from"./index-d9c97ver.js";import{_o,On}from"./index-s9va2kmc.js";import{pe,X}from"./index-v5dmsgpx.js";import{E,N,f,p}from"./index-qwntpbwe.js";import{Yn,Jn}from"./index-featyhps.js";import{sA,n,c}from"./index-d0c5abkw.js";import{cpSync as De,existsSync as b,mkdirSync as le,readdirSync as j,readFileSync as Ue,rmSync as Me,statSync as ce,writeFileSync as Ke}from"node:fs";import{basename as ae,isAbsolute as de,join as w,relative as Be,resolve as W}from"node:path";import{existsSync as he,readFileSync as ye,writeFileSync as q}from"node:fs";import{join as $e}from"node:path";var Se=".origins.json",V=1;function D(e){return $e(e,Se)}function T(e){let r=D(e);if(!he(r))return{};try{return JSON.parse(ye(r,"utf8")).origins??{}}catch{return{}}}function z(e,r){let s={...T(e),...r};q(D(e),`${JSON.stringify({version:V,origins:s},null,4)}
3
+ `)}function yo(e,r){let s=T(e);if(s[r]===void 0)return;let a=Object.fromEntries(Object.entries(s).filter(([o])=>o!==r));q(D(e),`${JSON.stringify({version:V,origins:a},null,4)}
4
+ `)}import{existsSync as F,mkdirSync as Ee,readdirSync as ee,readFileSync as te,renameSync as Ie,rmSync as _,statSync as Te,writeFileSync as _e}from"node:fs";import{join as k,relative as Ne}from"node:path";import{existsSync as be,mkdirSync as ke,readFileSync as ve,writeFileSync as Re}from"node:fs";import{join as B}from"node:path";var at=[{name:"anthropic",url:"https://github.com/anthropics/skills",path:"skills",builtin:!0},{name:"github",url:"https://github.com/github/awesome-copilot",path:"skills",builtin:!0,curated:Pr}],xe=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function gt(e){return e.length>0&&e.length<=64&&xe.test(e)}var Y=1;function Qn(e){return B(pe(e),"sources.json")}function L(e){return B(pe(e),"sources")}function C(e,r){return B(L(r),e)}function J(e){let r=Qn(e);if(!be(r))return{};let s;try{s=JSON.parse(ve(r,"utf8"))}catch(a){throw new t({code:"skill_sources_unreadable",message:`${r} is not valid JSON: ${a instanceof Error?a.message:String(a)}`,hint:"Fix the file, or delete it — the built-in sources work with no file at all."})}if(typeof s!=="object"||s===null||Array.isArray(s))throw new t({code:"skill_sources_unreadable",message:`${r} does not hold a JSON object`,hint:`Expected {"version": ${Y}, "sources": [...]}. Delete the file to start from the built-in sources.`});return s}function we(e){let r=J(e),s=(r.sources??[]).filter((l)=>gt(l.name)),a=new Set(r.disabled??[]),o=new Map(s.map((l)=>[l.name,l])),i=[];for(let l of at){if(a.has(l.name))continue;let d=o.get(l.name);i.push(d===void 0?l:{...d,builtin:!1})}for(let l of s){if(at.some((d)=>d.name===l.name))continue;i.push({...l,builtin:!1})}return i}function Q(e,r){let s=Qn(r);ke(pe(r),{recursive:!0});let a={version:Y,sources:e.sources??[],...e.disabled===void 0||e.disabled.length===0?{}:{disabled:e.disabled}};Re(s,`${JSON.stringify(a,null,4)}
5
+ `)}function Ir(e,r){let s=J(r),a=(s.sources??[]).filter((i)=>i.name!==e.name),o=(s.disabled??[]).filter((i)=>i!==e.name);Q({...s,sources:[...a,e],disabled:o},r)}function lr(e,r){let s=J(r),a=(s.sources??[]).filter((g)=>g.name!==e),o=a.length!==(s.sources??[]).length,i=at.some((g)=>g.name===e),l=(s.disabled??[]).includes(e);if(!o&&!i)return!1;if(i&&l&&!o)return!1;let d=i&&!l?[...s.disabled??[],e]:s.disabled??[];return Q({...s,sources:a,disabled:d},r),!0}function fo(e){let r=e.trim();if(r.length===0)throw U(e);if(/^[\w.-]+\/[\w.-]+$/.test(r))return{url:`https://github.com/${r.replace(/\.git$/,"")}`};if(r.startsWith("git@")||r.startsWith("ssh://"))return{url:r};let s;try{s=new URL(r)}catch{throw U(e)}if(s.protocol!=="https:"&&s.protocol!=="http:")throw U(e);let a=s.pathname.split("/").filter((g)=>g.length>0),o=a.findIndex((g)=>g==="tree"||g==="blob");if(o<2)return{url:`${s.origin}/${a.join("/")}`.replace(/\.git$/,"")};let i=a.slice(0,o).join("/"),l=a[o+1],d=a.slice(o+2).join("/");return{url:`${s.origin}/${i}`.replace(/\.git$/,""),...l===void 0?{}:{ref:l},...d.length===0?{}:{path:d}}}function U(e){return new t({code:"skill_source_url_invalid",message:`${JSON.stringify(e)} is not a repository`,hint:"Accepted: owner/repo, an https:// clone URL, a git@ SSH URL, or the page URL you were reading — .../tree/<branch>/<subdir> is understood."})}function Z(e){let r=e.split("/").filter((s)=>s.length>0);if(r.length===1)return{skill:r[0]};if(r.length===2)return{source:r[0],skill:r[1]};throw new t({code:"skill_ref_invalid",message:`${JSON.stringify(e)} is neither a skill name nor <source>/<skill>`,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."})}var ne="SKILL.md",re=180000,ti=async(e,r)=>{let s=await nA({command:"git",args:e,...r===void 0?{}:{cwd:r},timeoutMs:re,maxBuffer:33554432,env:{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_ASKPASS:"",SSH_ASKPASS:"",SSH_ASKPASS_REQUIRE:"never",GIT_SSH_COMMAND:"ssh -oBatchMode=yes -oStrictHostKeyChecking=accept-new"}});if(s.notFound)throw new t({code:"git_missing",message:"git is not on PATH, and a skill source is a git repository",hint:"Install git — on macOS `xcode-select --install` is enough. Until then, clone a repository by hand and use `skills install <agent> <path>`."});return{code:s.code,stdout:s.stdout,stderr:s.stderr,...s.signalled?{timedOut:!0}:{}}};function se(e,r){return k(L(r),`${e}.json`)}function ho(e,r){let s=se(e,r);if(!F(s))return{};try{return JSON.parse(te(s,"utf8"))}catch{return{}}}function Ze(e,r){return F(k(C(e,r),".git"))}function Qo(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||F(e)}async function ct(e,r={}){let s=r.git??ti,a=r.env,o=C(e.name,a),i=`${o}.partial`;Ee(L(a),{recursive:!0}),_(i,{recursive:!0,force:!0});let l=["clone","--depth","1","--single-branch",...e.ref===void 0?[]:["--branch",e.ref]],d=e.path!==void 0,g=!d,u=d?await s([...l,"--filter=blob:none","--sparse",e.url,i]):await s([...l,e.url,i]);if(u.code!==0&&d){_(i,{recursive:!0,force:!0});let h=await s([...l,e.url,i]);if(h.code===0)g=!0,u=h}if(u.code!==0)throw _(i,{recursive:!0,force:!0}),Fe(e,u);if(e.path!==void 0&&!g){let h=await s(["sparse-checkout","set",e.path],i);if(h.code!==0)throw _(i,{recursive:!0,force:!0}),new t({code:"skill_source_path_missing",message:`${e.name}: could not narrow the checkout to ${e.path}`,hint:`Check the path exists in ${e.url}. ${h.stderr.trim()||"git said nothing."}`})}let y=await s(["rev-parse","--short","HEAD"],i),S=y.code===0?y.stdout.trim():"unknown";_(o,{recursive:!0,force:!0}),Ie(i,o);let m=dA(e,a).length;return _e(se(e.name,a),`${JSON.stringify({commit:S,fetchedAt:new Date().toISOString(),skills:m},null,4)}
6
+ `),{commit:S,skills:m,unfiltered:g}}function Fe(e,r){let s=r.stderr.trim().split(`
7
+ `).slice(-3).join(" ");if(r.timedOut===!0)return new t({code:"skill_source_timeout",message:`${e.name}: git did not finish within ${Math.round(re/1000)}s`,hint:`Check the network, then try again — a partly fetched source was discarded, so the previous copy of ${e.name} is untouched.`});return new t({code:"skill_source_fetch_failed",message:`${e.name}: could not clone ${e.url}${s.length===0?"":` — ${s}`}`,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."})}var Ce=4,oe=new Set(["node_modules","dist","build","target","vendor",".git"]);function je(e){let r=[],s=(a,o)=>{if(o>Ce)return;let i;try{i=ee(a,{withFileTypes:!0})}catch{return}if(F(k(a,ne)))r.push(a);for(let l of i){if(!l.isDirectory())continue;if(l.name.startsWith(".")||oe.has(l.name))continue;s(k(a,l.name),o+1)}};return s(e,0),r.sort()}var Pe=[".py",".sh",".js",".ts",".mjs",".rb",".pl"];function ie(e,r=0){if(r>3)return[];let s=[],a;try{a=ee(e,{withFileTypes:!0})}catch{return[]}for(let o of a){let i=k(e,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||oe.has(o.name))continue;s.push(...ie(i,r+1));continue}if(!o.isFile())continue;if((Te(i).mode&73)!==0||Pe.some((d)=>o.name.endsWith(d)))s.push(i)}return s}function dA(e,r){let s=C(e.name,r),a=e.path===void 0?s:k(s,e.path);if(!F(a))return[];let o=[];for(let i of je(a)){let l=te(k(i,ne),"utf8"),d=i.slice(i.lastIndexOf("/")+1),g={source:e.name,dir:i,repoPath:Ne(s,i),scripts:ie(i)};try{let u=OA(d,l);o.push({...g,skill:u.frontmatter.name,description:u.frontmatter.description,tokens:v(u.body)})}catch(u){o.push({...g,skill:d,description:"",tokens:v(l),problem:u instanceof Error?u.message:String(u)})}}return o}var O="SKILL.md";function BA(e){try{let r=K(e.manifestPath,{env:{...M([e.manifestPath]),...e.envOverlay}}),a=e.action==="new"||e.action==="install"?ze(r.path,r.dir,r.manifest.skills):r.manifest.skills;if(a===void 0)return He(e);let o=fe(r.manifest.model.main.id,r.manifest.model.main.capabilities),i=de(a.dir)?a.dir:W(r.dir,a.dir);if(e.action==="new")return Qe(i,e);if(e.action==="remove")return rt(i,e);let l=UA({dir:i,maxActive:a.maxActive,threshold:a.threshold,style:o.promptStyle,agentDir:r.dir,runner:Ae()});switch(e.action){case"list":return We(i,l.skills,l,e);case"show":return Ge(l.skills,e);case"install":return et(i,e);default:return qe(l.skills,e)}}catch(r){if(e.json===!0&&r instanceof t)return process.stdout.write(`${JSON.stringify({ok:!1,error:r.toDetail(),details:r.details},null,2)}
8
+ `),c;throw r}}function He(e){if(e.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,configured:!1,skills:[]},null,2)}
9
+ `),n;return process.stdout.write(`this agent has no skills configured
10
+
11
+ `+` · find one and install it — searches the catalogues, 440+ skills:
12
+ `+` sources search <what it should do>
13
+ skills install ${e.manifestPath} <source>/<skill>
14
+
15
+ `+` · or write your own from a template:
16
+ `+` skills new ${e.manifestPath} <name>
17
+
18
+ either one turns skills on for this agent; neither needs agent.yaml edited by hand
19
+ `),n}function We(e,r,s,a){let o=T(e);if(a.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,configured:!0,cached:s.cached,maxActive:s.maxActive,threshold:s.threshold,skills:r.map((i)=>({...G(i),...o[i.name]===void 0?{}:{origin:o[i.name]}}))},null,2)}
20
+ `),n;if(r.length===0)return process.stdout.write(`no skills in ${e}
21
+
22
+ \`sources search <what it should do>\` ranks 440+ from the configured catalogues, then
23
+ \`skills install <agent> <source>/<skill>\`. \`skills new <agent> <name>\` writes one from a template.
24
+ `),n;process.stdout.write(`${E([{label:"skills",value:String(r.length)},{label:"per turn",value:`at most ${s.maxActive}`},{label:"threshold",value:s.threshold.toFixed(2)},{label:"index",value:s.cached?"cached":"scanned"}])}
25
+ `),process.stdout.write(`${N("catalogue")}
26
+ `);for(let i of r){let l=i.scripts.length===0?"":` ${i.scripts.length} script(s)`,d=i.frontmatter.whenNotToUse===void 0?" no when-not-to-use":"",g=o[i.name],u=g===void 0?"":` ${g.source}@${g.commit}`;process.stdout.write(` ${i.name.padEnd(20)} ${String(i.tokens).padStart(5)} tokens${l}${u}${d}
27
+ `)}return n}function Ge(e,r){let s=r.name;if(s===void 0)return process.stdout.write("skills show needs a skill name — `skills list` names them\n"),c;let a=e.find((l)=>l.name===s);if(a===void 0){let l=e.map((d)=>d.name).join(", ");return process.stdout.write(`no skill named ${s}${l===""?"":`. Known: ${l}`}
28
+ `),c}if(r.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,skill:Ve(a)},null,2)}
29
+ `),n;let{frontmatter:o}=a;if(process.stdout.write(`${E([{label:"name",value:a.name},{label:"directory",value:a.dir},{label:"body",value:`${a.tokens} tokens`},...o.license===void 0?[]:[{label:"license",value:o.license}],...o.compatibility===void 0?[]:[{label:"needs",value:o.compatibility}]])}
30
+ `),process.stdout.write(`${N("description")}
31
+ `),process.stdout.write(`${p(o.description)}
32
+ `),process.stdout.write(`${N("when not to use")}
33
+ `),process.stdout.write(`${p(o.whenNotToUse??`not declared — add metadata.${wA()} to improve routing`)}
34
+ `),a.scripts.length>0){process.stdout.write(`${N("scripts")}
35
+ `);for(let l of a.scripts)process.stdout.write(`${f(`${l.slug} — scripts/${l.file} via ${l.interpreter??"its own shebang"}`)}
36
+ `)}if(a.ignoredScripts.length>0){process.stdout.write(`${N("in scripts/ and not runnable")}
37
+ `);for(let l of a.ignoredScripts)process.stdout.write(`${f(`${l.file} — ${l.reason}`)}
38
+ `)}if(o.allowedTools!==void 0)process.stdout.write(`${N("allowed-tools, declared and not honoured")}
39
+ `),process.stdout.write(`${p(o.allowedTools)}
40
+ `),process.stdout.write(`${p("this runtime reads the field and never acts on it; permissions live in tools.policy")}
41
+ `);let i=Object.entries(o.metadata).filter(([l])=>l!==wA());if(i.length>0)process.stdout.write(`${N("metadata")}
42
+ `),process.stdout.write(`${E(i.map(([l,d])=>({label:l,value:d})))}
43
+ `);return n}function qe(e,r){let s=hi(e);if(r.json===!0)return process.stdout.write(`${JSON.stringify({ok:s.length===0,skills:e.map(G),findings:s},null,2)}
44
+ `),r.strict===!0&&s.length>0?c:n;let a=new Map;for(let o of s){let l=e.find((d)=>o.message.includes(` ${d.name}:`))?.name??"";a.set(l,[...a.get(l)??[],o])}for(let o of e){let i=a.get(o.name)??[];process.stdout.write(` ${o.name.padEnd(20)} ${i.length===0?"ok":`${i.length} warning(s)`}
45
+ `)}if(s.length===0)return process.stdout.write(`
46
+ no findings
47
+ `),n;for(let o of s)process.stdout.write(`
48
+ ${o.code}: ${o.message}
49
+ `),process.stdout.write(` hint: ${o.hint}
50
+ `);return process.stdout.write(`
51
+ ${s.length} finding(s) — warnings, not failures. --strict exits non-zero.
52
+ `),r.strict===!0?c:n}function G(e){return{name:e.name,tokens:e.tokens,hasWhenNotToUse:e.frontmatter.whenNotToUse!==void 0,scripts:e.scripts.map((r)=>r.slug),ignoredScripts:e.ignoredScripts}}function Ve(e){return{...G(e),dir:e.dir,description:e.frontmatter.description,...e.frontmatter.whenNotToUse===void 0?{}:{whenNotToUse:e.frontmatter.whenNotToUse},...e.frontmatter.license===void 0?{}:{license:e.frontmatter.license},...e.frontmatter.compatibility===void 0?{}:{compatibility:e.frontmatter.compatibility},...e.frontmatter.allowedTools===void 0?{}:{allowedToolsDeclaredNotHonoured:e.frontmatter.allowedTools},metadata:e.frontmatter.metadata}}function ze(e,r,s){let a=s?.dir??"./skills",o=de(a)?a:W(r,a);if(le(o,{recursive:!0}),s!==void 0)return s;let i=Ci({file:e,path:["skills"],value:Ye(a)});if(process.stdout.write(`${E([{label:"enabled",value:`skills.dir = ${a}`}])}
53
+ `),i.reflowed)process.stdout.write(`${f("the file was re-serialised to add the block — it is valid, and comments may have moved")}
54
+ `);return{dir:a,...ue}}var ue={maxActive:1,threshold:0.35};function Ye(e){return{dir:e,...ue}}function Qe(e,r){let s=r.name;if(s===void 0)return process.stdout.write("skills new needs a name — `skills new <manifest> <name>`\n"),c;if(!pi(s))return process.stdout.write(`${s} is not a legal skill name: lowercase letters, digits and single hyphens, never leading, trailing or doubled, at most 64 characters.
55
+ `),c;let a=w(e,s);if(b(a))return process.stdout.write(`${a} already exists — nothing was written
56
+ `),c;return le(a,{recursive:!0}),Ke(w(a,"SKILL.md"),On(_o,{SKILL_NAME:s,WHEN_NOT_TO_USE_KEY:wA()}),"utf8"),process.stdout.write(`${E([{label:"created",value:w(a,"SKILL.md")},{label:"name",value:s}])}
57
+ `),process.stdout.write(`${N("next")}
58
+ ${f("edit the description — it is the only thing selection reads, so name the words someone would actually type")}
59
+ ${f("write the steps in place of the placeholder body")}
60
+ ${f("skills validate — it warns until the scaffold is replaced")}
61
+ ${f("restart the agent: the catalogue is scanned once at boot")}
62
+ `),n}function et(e,r){let s=r.name;if(s===void 0)return process.stdout.write("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"),c;let a=Qo(s),o;if(!a){let m=tt(s,r.sandboxEnv);if(m===void 0)return c;o=m}let i=o===void 0?W(s):o.entry.dir;if(o===void 0){if(!b(i)||!ce(i).isDirectory())return process.stdout.write(`${i} is not a directory
63
+ `),c;if(b(s)&&we(r.sandboxEnv).some((m)=>m.name===s))process.stdout.write(`note: ${s} is also a source, and a directory of that name here wins — \`sources search\` to install from the source instead
64
+
65
+ `)}let l={},d=[],u=b(w(i,O))?[i]:j(i,{withFileTypes:!0}).filter((m)=>m.isDirectory()&&b(w(i,m.name,O))).map((m)=>w(i,m.name));if(u.length===0)return process.stdout.write(`no ${O} in ${i} or in any directory directly inside it
66
+ `),c;let y=[],S=[];for(let m of u){let h;try{h=OA(ae(m),Ue(w(m,O),"utf8")).frontmatter.name}catch(R){S.push(`${ae(m)} — ${R instanceof Error?R.message:String(R)}`);continue}let I=w(e,h);if(b(I)){S.push(`${h} — already installed at ${I}`);continue}if(De(m,I,{recursive:!0,preserveTimestamps:!0}),y.push(h),o!==void 0)l[h]={source:o.spec.name,url:o.spec.url,repoPath:o.entry.repoPath,commit:o.commit,...o.spec.ref===void 0?{}:{ref:o.spec.ref},installedAt:new Date().toISOString()};d.push(...me(I).map((R)=>`${h}/${Be(I,R)}`))}if(Object.keys(l).length>0)z(e,l);if(r.collect!==void 0){for(let m of y)r.collect.push({name:m,ok:!0,runnable:d.filter((h)=>h.startsWith(`${m}/`))});for(let m of S){let h=m.indexOf(" — ");r.collect.push({name:h===-1?m:m.slice(0,h),ok:!1,reason:h===-1?m:m.slice(h+3),runnable:[]})}}if(r.quiet===!0)return y.length===0?c:n;process.stdout.write(`${E([{label:"from",value:o===void 0?i:`${o.spec.name} (${o.spec.url}) at ${o.commit}`},{label:"installed",value:y.join(", ")},{label:"skipped",value:S.length===0?"":String(S.length)}])}
67
+ `);for(let m of S)process.stdout.write(`${f(m)}
68
+ `);if(d.length>0){if(process.stdout.write(`${N("this installed code, which the agent can run")}
69
+ ${d.slice(0,12).map((m)=>f(m)).join(`
70
+ `)}
71
+ `),d.length>12)process.stdout.write(`${p(`… and ${d.length-12} more`)}
72
+ `);process.stdout.write(`${p("read them before the agent does; `tools.policy` can name a skill script by slug")}
73
+ `)}if(y.length>0)process.stdout.write(`${N("next")}
74
+ ${f("skills validate — a vendored skill usually has no negative guidance, which is a warning and not a problem")}
75
+ ${f("restart the agent: the catalogue is scanned once at boot")}
76
+ `);return y.length===0?c:n}function tt(e,r){let s;try{s=Z(e)}catch(u){if(!(u instanceof t))throw u;process.stdout.write(`${u.message}
77
+
78
+ ${u.hint}
79
+ `);return}let a=we(r),o=s.source===void 0?a:a.filter((u)=>u.name===s.source);if(o.length===0){let u=x(s.source??"",a.map((y)=>y.name));process.stdout.write(`no source called ${s.source}
80
+
81
+ ${u===void 0?"`sources list` shows them.":`Did you mean ${u}?`}
82
+ `);return}if(o.filter((u)=>!Ze(u.name,r)).length===o.length){process.stdout.write(`${o.length===1?`${o[0]?.name} has not`:"no source has"} been fetched yet, so there is nothing to install from
83
+
84
+ \`sources update${s.source===void 0?"":` ${s.source}`}\` first, or \`sources search ${s.skill}\` which fetches on demand.
85
+ `);return}let l=o.filter((u)=>Ze(u.name,r)).flatMap((u)=>dA(u,r).map((y)=>({entry:y,spec:u}))),d=l.filter((u)=>u.entry.skill===s.skill);if(d.length===0){let u=x(s.skill,l.map((y)=>y.entry.skill));process.stdout.write(`no skill called ${s.skill} in ${o.map((y)=>y.name).join(", ")}
86
+
87
+ ${u===void 0?`\`sources search ${s.skill}\` ranks what is there.`:`Did you mean ${u}? \`sources search ${s.skill}\` ranks the alternatives.`}
88
+ `);return}if(d.length>1){process.stdout.write(`${d.length} sources carry a skill called ${s.skill}
89
+
90
+ ${d.map((u)=>` ${u.spec.name}/${u.entry.skill} — ${u.spec.url}
91
+ `).join("")}
92
+ Name one.
93
+ `);return}let g=d[0];if(g.entry.problem!==void 0){process.stdout.write(`${g.spec.name}/${g.entry.skill} will not load: ${g.entry.problem}
94
+
95
+ Nothing was copied. That is upstream's to fix — installing a hand-edited copy from a path is the way round it.
96
+ `);return}return{entry:g.entry,spec:g.spec,commit:ho(g.spec.name,r).commit??"unknown"}}function me(e,r=0){if(r>3)return[];let s=[];for(let a of j(e,{withFileTypes:!0})){let o=w(e,a.name);if(a.isDirectory()){if(a.name.startsWith("."))continue;s.push(...me(o,r+1));continue}if(!a.isFile())continue;if((ce(o).mode&73)!==0||nt.some((l)=>a.name.endsWith(l)))s.push(o)}return s}var nt=[".py",".sh",".js",".ts",".mjs",".rb",".pl"];function rt(e,r){let s=r.name;if(s===void 0)return process.stdout.write("skills remove needs a name — `skills list` names them\n"),c;let a=w(e,s);if(!b(w(a,O))){let l=b(e)?j(e,{withFileTypes:!0}).filter((d)=>d.isDirectory()&&b(w(e,d.name,O))).map((d)=>d.name).join(", "):"";return process.stdout.write(`no skill named ${s}${l===""?"":`. Known: ${l}`}
97
+ `),c}let o=ge(a),i=T(e)[s];return Me(a,{recursive:!0,force:!0}),yo(e,s),process.stdout.write(`${E([{label:"removed",value:a},{label:"files",value:String(o)},...i===void 0?[]:[{label:"came from",value:`${i.source} (${i.url}) at ${i.commit}`}]])}
98
+ `),process.stdout.write(`${f("restart the agent: the catalogue is scanned once at boot")}
99
+ `),n}function ge(e){let r=0;for(let s of j(e,{withFileTypes:!0}))r+=s.isDirectory()?ge(w(e,s.name)):1;return r}async function It(e){let r=e.onStatus??(()=>{}),s=we(e.env),a=s.filter((i)=>!Ze(i.name,e.env));for(let[i,l]of a.entries()){r(`fetching ${l.name} (${i+1} of ${a.length}) — once per machine, shared by every agent`);try{let d=await ct(l,{...e.env===void 0?{}:{env:e.env},...e.git===void 0?{}:{git:e.git}});r(`${l.name}: ${d.skills} skills`)}catch(d){r(`${l.name} could not be fetched: ${d instanceof t?d.message:String(d)}`)}}let o=s.filter((i)=>Ze(i.name,e.env)).map((i)=>({spec:i,entries:dA(i,e.env)}));return Fr(o)}async function st(e){return await It({...e,onStatus:(r)=>process.stdout.write(`${r}
100
+ `)})}function Er(e,r,s){let a=[];for(let o of e)BA({action:"install",manifestPath:r,name:o,quiet:!0,collect:a,...s.env===void 0?{}:{sandboxEnv:s.env},...s.envOverlay===void 0?{}:{envOverlay:s.envOverlay}});return it(a)}function ot(e,r,s){let a=[];for(let o of e)BA({action:"install",manifestPath:r,name:`${o.source}/${o.skill}`,quiet:!0,collect:a,...s.env===void 0?{}:{sandboxEnv:s.env},...s.envOverlay===void 0?{}:{envOverlay:s.envOverlay}});return a}function it(e){let r=Ht(e);if(process.stdout.write(`${N(`installed ${r.installed.length} of ${r.total} skill${r.total===1?"":"s"}`,!0)}
101
+ `),r.installed.length>0)process.stdout.write(`${p(r.installed.join(", "))}
102
+ `);for(let s of r.failed)process.stdout.write(`${f(`${s.name} — ${s.reason}`)}
103
+ `);if(r.runnable>0)process.stdout.write(`${N("code that came with them")}
104
+ ${p(`${r.runnable} runnable file${r.runnable===1?"":"s"} across ${r.withCode} skill${r.withCode===1?"":"s"} — \`skills show <agent> <skill>\` names them`)}
105
+ `);return r.failed.length}async function Cr(e){if(we(e.env).length===0)return process.stdout.write(`no skill sources are configured
106
+
107
+ \`${A.slug} sources add <url>\` adds one — a repository holding a skills/ directory.
108
+ `),c;if(!(Je({plain:e.plain===!0,json:e.json===!0,oneShot:!1}).mode==="rich"&&e.json!==!0)){let m=await st(e);if(m.length===0)return process.stdout.write(`nothing to show — no catalogue could be read
109
+
110
+ \`${A.slug} sources update\` reports why.
111
+ `),c;if(e.json===!0)return lt(m);return ut(m,X(e.env))}let o=X(e.env);if(o.length===0)return process.stdout.write(`${N("no agent to install into",!0)}
112
+ ${p(`\`${A.slug} init\` creates one, then this command installs into it.`)}
113
+ `),c;let[{render:i},{createElement:l},{SkillBrowser:d}]=await Promise.all([import("ink"),import("react"),import("./SkillBrowser-8s8rjv98.js")]),g,u=()=>{},y=new Promise((m)=>{u=m});tA(),process.stdout.write(sA);let S=i(l(d,{title:ft,agents:o,load:(m)=>It({...e,onStatus:m}),install:async(m,h)=>Ht(ot(m,h,e)),onDone:(m)=>{g=m,u()}}),{exitOnCtrlC:!1,...Oe()});if(P(()=>S.unmount()),await y,S.unmount(),Le(),await Xe(),g===void 0)return n;for(let m of g.failed)process.stderr.write(`${m.name} — ${m.reason}
114
+ `);if(g.installed.length>0)process.stdout.write(`${g.installed.length} skill${g.installed.length===1?"":"s"} installed — \`${A.slug} skills list <agent>\` shows them
115
+ `);return g.failed.length===g.total&&g.total>0?c:n}function lt(e){return process.stdout.write(`${JSON.stringify({skills:e.filter((r)=>r.entry!==void 0).map((r)=>({ref:`${r.entry?.source}/${r.entry?.skill}`,source:r.entry?.source,skill:r.entry?.skill,tokens:r.entry?.tokens,scripts:r.entry?.scripts.length??0,description:r.entry?.description}))},null,2)}
116
+ `),n}function dt(e){let s=e.reduce((i,l)=>l.kind==="item"?Math.max(i,l.label.length):i,0),a=Yn(100,s+12,{nameMax:46}),o=[];for(let i of e){if(i.kind==="source"){o.push(`
117
+ ${i.label}`);continue}if(i.kind==="group"){o.push(` ${i.label}`);continue}let l=Jn({name:`${i.entry?.source}/${i.label}`,meta:i.meta??"",description:i.description??""},a);o.push(` ${l.name} ${l.meta} ${l.description}`.trimEnd())}return o.join(`
118
+ `)}function ut(e,r){process.stdout.write(`${dt(e)}
119
+ `);let s=e.find((o)=>o.entry!==void 0)?.entry,a=r[0]?.ref??"<agent>";return process.stdout.write(`${N("install")}
120
+ ${p(`${A.slug} skills install ${a} ${s?.source??"anthropic"}/${s?.skill??"pdf"}`)}
121
+ ${p(`${A.slug} skills — at a terminal, ticks several at once`,2)}
122
+ `),n}var ft=`${A.name} ${H}`;
123
+ export{at,gt,Qn,we,Ir,lr,fo,ti,ho,Ze,Qo,ct,dA,yo,BA,It,Er,Cr};
124
+
125
+ //# debugId=5608624D61672F1264756E2164756E21
126
+ //# sourceMappingURL=index-xbn26c8g.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/skills.ts", "../src/lib/origins.ts", "../src/lib/source-cache.ts", "../src/lib/sources.ts", "../src/browse.ts"],
4
+ "sourcesContent": [
5
+ "/**\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 HarnessError,\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 && error instanceof HarnessError) {\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 (!(error instanceof HarnessError)) 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",
6
+ "/**\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",
7
+ "/**\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",
8
+ "/**\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",
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, HarnessError, 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: ${error instanceof HarnessError ? 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
+ ],
11
+ "mappings": ";8cAkBA,iBACI,iBACA,eACA,kBACA,kBACA,aACA,eACA,oBACA,iBAEJ,mBAAS,iBAAU,WAAY,cAAM,cAAU,kBCL/C,qBAAS,mBAAY,oBAAc,gBACnC,eAAS,mBAEF,IAAM,GAAe,gBAmBtB,EAAU,EAET,SAAS,CAAW,CAAC,EAA2B,CACnD,OAAO,GAAK,EAAW,EAAY,EAGhC,SAAS,CAAW,CAAC,EAAqD,CAC7E,IAAM,EAAO,EAAY,CAAS,EAClC,GAAI,CAAC,GAAW,CAAI,EAAG,MAAO,CAAC,EAC/B,GAAI,CAEA,OADe,KAAK,MAAM,GAAa,EAAM,MAAM,CAAC,EACtC,SAAW,CAAC,EAC5B,KAAM,CAGJ,MAAO,CAAC,GAIT,SAAS,CAAa,CAAC,EAAmB,EAA+C,CAC5F,IAAM,EAAS,IAAK,EAAY,CAAS,KAAM,CAAM,EACrD,EACI,EAAY,CAAS,EACrB,GAAG,KAAK,UAAU,CAAE,QAAS,EAAS,QAAS,CAAO,EAAG,KAAM,CAAC;AAAA,CACpE,EAIG,SAAS,EAAY,CAAC,EAAmB,EAAoB,CAChE,IAAM,EAAU,EAAY,CAAS,EACrC,GAAI,EAAQ,KAAU,OAAW,OACjC,IAAM,EAAO,OAAO,YAAY,OAAO,QAAQ,CAAO,EAAE,OAAO,EAAE,KAAW,IAAU,CAAI,CAAC,EAC3F,EACI,EAAY,CAAS,EACrB,GAAG,KAAK,UAAU,CAAE,QAAS,EAAS,QAAS,CAAK,EAAG,KAAM,CAAC;AAAA,CAClE,ECjDJ,qBACI,eACA,kBACA,mBACA,iBACA,aACA,cACA,oBACA,iBAEJ,eAAS,cAAM,mBChBf,qBAAS,gBAAY,mBA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