dispach 0.1.2 → 0.1.3

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 (195) hide show
  1. package/README.md +134 -85
  2. package/dist/App-qfqvx9c7.js +11 -0
  3. package/dist/{App-b1yrwrcq.js.map → App-qfqvx9c7.js.map} +6 -7
  4. package/dist/ConfigEditor-apcnj4nj.js +6 -0
  5. package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
  6. package/dist/KeyProbe-ya5t3v3v.js +5 -0
  7. package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
  8. package/dist/Picker-b7mn0mjg.js +5 -0
  9. package/dist/{Picker-hfeh1g6m.js.map → Picker-b7mn0mjg.js.map} +1 -1
  10. package/dist/SessionPicker-vacfwczg.js +5 -0
  11. package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-vacfwczg.js.map} +2 -2
  12. package/dist/SkillBrowser-66ntwaa9.js +5 -0
  13. package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
  14. package/dist/WizardApp-123998yh.js +5 -0
  15. package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-123998yh.js.map} +3 -3
  16. package/dist/agents.d.ts +19 -3
  17. package/dist/agents.d.ts.map +1 -1
  18. package/dist/channels-q4fwqq87.js +31 -0
  19. package/dist/channels-q4fwqq87.js.map +10 -0
  20. package/dist/channels.d.ts +26 -0
  21. package/dist/channels.d.ts.map +1 -0
  22. package/dist/client.js +10 -10
  23. package/dist/client.js.map +3 -3
  24. package/dist/config-64q4mgxc.js +24 -0
  25. package/dist/{config-g7za9x13.js.map → config-64q4mgxc.js.map} +2 -2
  26. package/dist/{credential-npr6z8c8.js → credential-2sj7vsmw.js} +5 -5
  27. package/dist/{credential-npr6z8c8.js.map → credential-2sj7vsmw.js.map} +1 -1
  28. package/dist/daemon.d.ts.map +1 -1
  29. package/dist/index-0k3w2mxf.js +6 -0
  30. package/dist/{index-hwpvhaza.js.map → index-0k3w2mxf.js.map} +1 -1
  31. package/dist/index-1s81qstp.js +6 -0
  32. package/dist/{index-v8e92nfw.js.map → index-1s81qstp.js.map} +1 -1
  33. package/dist/index-2rycma8x.js +12 -0
  34. package/dist/{index-258d8bzg.js.map → index-2rycma8x.js.map} +4 -3
  35. package/dist/index-2zye08c4.js +6 -0
  36. package/dist/{index-vgc3y3rm.js.map → index-2zye08c4.js.map} +2 -2
  37. package/dist/{index-gme2egyq.js → index-3km1jwh7.js} +4 -4
  38. package/dist/{index-gme2egyq.js.map → index-3km1jwh7.js.map} +1 -1
  39. package/dist/index-3mtgcvkq.js +429 -0
  40. package/dist/index-3mtgcvkq.js.map +11 -0
  41. package/dist/index-4knb5vjm.js +90 -0
  42. package/dist/index-4knb5vjm.js.map +13 -0
  43. package/dist/{index-3g3ny01d.js → index-5nwwekk0.js} +4 -4
  44. package/dist/{index-3g3ny01d.js.map → index-5nwwekk0.js.map} +1 -1
  45. package/dist/index-5rm7dwq4.js +6 -0
  46. package/dist/index-5rm7dwq4.js.map +11 -0
  47. package/dist/index-79epttpm.js +6 -0
  48. package/dist/index-79epttpm.js.map +10 -0
  49. package/dist/{index-4cf6v9nb.js → index-7yk1zvds.js} +4 -4
  50. package/dist/{index-4cf6v9nb.js.map → index-7yk1zvds.js.map} +1 -1
  51. package/dist/index-81gb4ey4.js +6 -0
  52. package/dist/{index-4z7axw4r.js.map → index-81gb4ey4.js.map} +1 -1
  53. package/dist/index-8a5d8sfe.js +6 -0
  54. package/dist/{index-0d93hyfc.js.map → index-8a5d8sfe.js.map} +1 -1
  55. package/dist/index-a21zyy54.js +6 -0
  56. package/dist/index-a21zyy54.js.map +9 -0
  57. package/dist/index-b6da6c16.js +92 -0
  58. package/dist/index-b6da6c16.js.map +15 -0
  59. package/dist/index-byxrc961.js +903 -0
  60. package/dist/{index-tv4yv7d2.js.map → index-byxrc961.js.map} +16 -15
  61. package/dist/{index-ammv5st7.js → index-cgfg6t5a.js} +6 -6
  62. package/dist/{index-ammv5st7.js.map → index-cgfg6t5a.js.map} +1 -1
  63. package/dist/{index-s9mbq7h6.js → index-ehzwdnc3.js} +4 -4
  64. package/dist/{index-s9mbq7h6.js.map → index-ehzwdnc3.js.map} +1 -1
  65. package/dist/index-fzmmhmk2.js +7 -0
  66. package/dist/index-fzmmhmk2.js.map +11 -0
  67. package/dist/index-g3pk0kc0.js +6 -0
  68. package/dist/{index-9r0wyj6w.js.map → index-g3pk0kc0.js.map} +2 -2
  69. package/dist/index-h828nk24.js +153 -0
  70. package/dist/index-h828nk24.js.map +20 -0
  71. package/dist/{index-02dn6m2j.js → index-jq999vcw.js} +5 -5
  72. package/dist/{index-02dn6m2j.js.map → index-jq999vcw.js.map} +2 -2
  73. package/dist/index-k2aq5bg0.js +9 -0
  74. package/dist/{index-6p999cx4.js.map → index-k2aq5bg0.js.map} +4 -6
  75. package/dist/{index-cqqb6gaq.js → index-k3y8y3wj.js} +5 -5
  76. package/dist/{index-cqqb6gaq.js.map → index-k3y8y3wj.js.map} +1 -1
  77. package/dist/index-k59wwdgz.js +9 -0
  78. package/dist/{index-ff514z3y.js.map → index-k59wwdgz.js.map} +3 -5
  79. package/dist/index-nmnnwa02.js +6 -0
  80. package/dist/{index-6q4wf8e3.js.map → index-nmnnwa02.js.map} +1 -1
  81. package/dist/index-nn3tk25c.js +6 -0
  82. package/dist/{index-d4x6yvqh.js.map → index-nn3tk25c.js.map} +3 -4
  83. package/dist/index-q0hxh57v.js +126 -0
  84. package/dist/index-q0hxh57v.js.map +14 -0
  85. package/dist/index-srmhk9g5.js +11 -0
  86. package/dist/index-srmhk9g5.js.map +11 -0
  87. package/dist/index-swtyfhha.js +6 -0
  88. package/dist/{index-fex44816.js.map → index-swtyfhha.js.map} +2 -2
  89. package/dist/index-whq42sat.js +6 -0
  90. package/dist/{index-h9mw7b9d.js.map → index-whq42sat.js.map} +1 -1
  91. package/dist/{index-j7gyr5nx.js → index-wzsmh5j0.js} +7 -7
  92. package/dist/{index-j7gyr5nx.js.map → index-wzsmh5j0.js.map} +1 -1
  93. package/dist/{index-j55s3ehk.js → index-x7v1zq89.js} +7 -7
  94. package/dist/{index-j55s3ehk.js.map → index-x7v1zq89.js.map} +2 -2
  95. package/dist/index-xhzmv4dh.js +66 -0
  96. package/dist/index-xhzmv4dh.js.map +12 -0
  97. package/dist/index-xmv47vs0.js +6 -0
  98. package/dist/{index-gz9x25tz.js.map → index-xmv47vs0.js.map} +2 -2
  99. package/dist/index-y4c32wn7.js +6 -0
  100. package/dist/{index-qdbq8crg.js.map → index-y4c32wn7.js.map} +2 -2
  101. package/dist/index-yjcdp72k.js +6 -0
  102. package/dist/{index-tf71ap9v.js.map → index-yjcdp72k.js.map} +1 -1
  103. package/dist/index-zn24991r.js +6 -0
  104. package/dist/index-zn24991r.js.map +10 -0
  105. package/dist/index.js +374 -443
  106. package/dist/index.js.map +23 -27
  107. package/dist/init.d.ts.map +1 -1
  108. package/dist/lib/channel-actions.d.ts +103 -0
  109. package/dist/lib/channel-actions.d.ts.map +1 -0
  110. package/dist/lib/chat-frame.d.ts +12 -1
  111. package/dist/lib/chat-frame.d.ts.map +1 -1
  112. package/dist/lib/commands.d.ts +13 -0
  113. package/dist/lib/commands.d.ts.map +1 -1
  114. package/dist/lib/const.d.ts +1 -1
  115. package/dist/lib/host-actions.d.ts +121 -0
  116. package/dist/lib/host-actions.d.ts.map +1 -0
  117. package/dist/lib/init-flow.d.ts +32 -0
  118. package/dist/lib/init-flow.d.ts.map +1 -1
  119. package/dist/lib/init-whatsapp.d.ts +52 -0
  120. package/dist/lib/init-whatsapp.d.ts.map +1 -0
  121. package/dist/lib/plugin-install.d.ts +120 -0
  122. package/dist/lib/plugin-install.d.ts.map +1 -0
  123. package/dist/lib/providers.d.ts.map +1 -1
  124. package/dist/lib/provision.d.ts.map +1 -1
  125. package/dist/lib/readme-table.d.ts +15 -0
  126. package/dist/lib/readme-table.d.ts.map +1 -0
  127. package/dist/lib/sandbox.d.ts +15 -0
  128. package/dist/lib/sandbox.d.ts.map +1 -1
  129. package/dist/lib/schema.d.ts +34 -1
  130. package/dist/lib/schema.d.ts.map +1 -1
  131. package/dist/lib/subcommand.d.ts.map +1 -1
  132. package/dist/lib/web-url.d.ts +15 -0
  133. package/dist/lib/web-url.d.ts.map +1 -0
  134. package/dist/lib/wizard.d.ts.map +1 -1
  135. package/dist/memory.d.ts.map +1 -1
  136. package/dist/model.d.ts.map +1 -1
  137. package/dist/plugins.d.ts +27 -8
  138. package/dist/plugins.d.ts.map +1 -1
  139. package/dist/restart.d.ts +21 -0
  140. package/dist/restart.d.ts.map +1 -0
  141. package/dist/run.d.ts.map +1 -1
  142. package/dist/schedules.d.ts.map +1 -1
  143. package/dist/serve.d.ts.map +1 -1
  144. package/dist/sessions.d.ts.map +1 -1
  145. package/dist/skills.d.ts.map +1 -1
  146. package/dist/status.d.ts +16 -0
  147. package/dist/status.d.ts.map +1 -0
  148. package/dist/tools.d.ts.map +1 -1
  149. package/dist/validate.d.ts.map +1 -1
  150. package/dist/web-923c7f5e.js +14 -0
  151. package/dist/{web-vkb16r62.js.map → web-923c7f5e.js.map} +3 -3
  152. package/dist/web.d.ts +2 -13
  153. package/dist/web.d.ts.map +1 -1
  154. package/dist/workspace.d.ts.map +1 -1
  155. package/dist/wrapper-0w9b3my0.js +11 -0
  156. package/dist/wrapper-0w9b3my0.js.map +23 -0
  157. package/package.json +6 -3
  158. package/dist/App-b1yrwrcq.js +0 -11
  159. package/dist/ConfigEditor-n8hdw6r7.js +0 -6
  160. package/dist/KeyProbe-9jjeze5r.js +0 -5
  161. package/dist/Picker-hfeh1g6m.js +0 -5
  162. package/dist/SessionPicker-zyqkg4dn.js +0 -5
  163. package/dist/SkillBrowser-3qdp8080.js +0 -5
  164. package/dist/WizardApp-vzpbydy3.js +0 -5
  165. package/dist/config-g7za9x13.js +0 -24
  166. package/dist/index-0d93hyfc.js +0 -6
  167. package/dist/index-1c5113t4.js +0 -66
  168. package/dist/index-1c5113t4.js.map +0 -12
  169. package/dist/index-258d8bzg.js +0 -12
  170. package/dist/index-4z7axw4r.js +0 -6
  171. package/dist/index-6p999cx4.js +0 -9
  172. package/dist/index-6q4wf8e3.js +0 -6
  173. package/dist/index-9r0wyj6w.js +0 -6
  174. package/dist/index-d4x6yvqh.js +0 -6
  175. package/dist/index-fecm8xe7.js +0 -77
  176. package/dist/index-fecm8xe7.js.map +0 -12
  177. package/dist/index-fex44816.js +0 -6
  178. package/dist/index-ff514z3y.js +0 -14
  179. package/dist/index-gz9x25tz.js +0 -6
  180. package/dist/index-h9mw7b9d.js +0 -6
  181. package/dist/index-hwpvhaza.js +0 -6
  182. package/dist/index-mtn0g9vc.js +0 -7
  183. package/dist/index-mtn0g9vc.js.map +0 -11
  184. package/dist/index-qdbq8crg.js +0 -6
  185. package/dist/index-tf71ap9v.js +0 -6
  186. package/dist/index-ttwyrdjs.js +0 -427
  187. package/dist/index-ttwyrdjs.js.map +0 -11
  188. package/dist/index-tv4yv7d2.js +0 -903
  189. package/dist/index-ty24n0jh.js +0 -167
  190. package/dist/index-ty24n0jh.js.map +0 -19
  191. package/dist/index-v8e92nfw.js +0 -6
  192. package/dist/index-vgc3y3rm.js +0 -6
  193. package/dist/index-whaw4b18.js +0 -6
  194. package/dist/index-whaw4b18.js.map +0 -10
  195. package/dist/web-vkb16r62.js +0 -14
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ import{e,S,A,m,q,oo,b,M,He,ro,xe,tA,ao,C}from"./index-byxrc961.js";import{v}from"./index-b6da6c16.js";import{Ii,ui,WA}from"./index-3km1jwh7.js";import{X,ue}from"./index-5rm7dwq4.js";import{he,h,ie,pe}from"./index-k2aq5bg0.js";import{ye}from"./index-ehzwdnc3.js";import{Rn,Dt}from"./index-3mtgcvkq.js";import{z,R}from"./index-fzmmhmk2.js";import{g,B,l,c}from"./index-wzsmh5j0.js";import{Vt,Wt}from"./index-zn24991r.js";import{Me,t,i}from"./index-2zye08c4.js";import{cpSync as qe,existsSync as I,mkdirSync as we,readdirSync as K,readFileSync as Ve,rmSync as ze,statSync as $e,writeFileSync as Ye}from"node:fs";import{basename as ge,isAbsolute as Se,join as x,relative as Qe,resolve as V}from"node:path";import{existsSync as Oe,readFileSync as Ie,writeFileSync as Q}from"node:fs";import{join as Te}from"node:path";var _e=".origins.json",ee=1;function J(n){return Te(n,_e)}function L(n){let r=J(n);if(!Oe(r))return{};try{return JSON.parse(Ie(r,"utf8")).origins??{}}catch{return{}}}function te(n,r){let s={...L(n),...r};Q(J(n),`${JSON.stringify({version:ee,origins:s},null,4)}
3
+ `)}function hn(n,r){let s=L(n);if(s[r]===void 0)return;let d=Object.fromEntries(Object.entries(s).filter(([o])=>o!==r));Q(J(n),`${JSON.stringify({version:ee,origins:d},null,4)}
4
+ `)}import{existsSync as P,mkdirSync as Pe,readdirSync as oe,readFileSync as ae,renameSync as De,rmSync as j,statSync as Ue,writeFileSync as Ke}from"node:fs";import{join as T,relative as Be}from"node:path";import{existsSync as Ae,mkdirSync as Fe,readFileSync as Le,writeFileSync as Ce}from"node:fs";import{join as W}from"node:path";var pA=[{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:Ii}],je=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function QA(n){return n.length>0&&n.length<=64&&je.test(n)}var ne=1;function pt(n){return W(z(n),"sources.json")}function D(n){return W(z(n),"sources")}function U(n,r){return W(D(r),n)}function G(n){let r=pt(n);if(!Ae(r))return{};let s;try{s=JSON.parse(Le(r,"utf8"))}catch(d){throw new A({code:"skill_sources_unreadable",message:`${r} is not valid JSON: ${d instanceof Error?d.message:String(d)}`,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 A({code:"skill_sources_unreadable",message:`${r} does not hold a JSON object`,hint:`Expected {"version": ${ne}, "sources": [...]}. Delete the file to start from the built-in sources.`});return s}function Z(n){let r=G(n),s=(r.sources??[]).filter((u)=>QA(u.name)),d=new Set(r.disabled??[]),o=new Map(s.map((u)=>[u.name,u])),a=[];for(let u of pA){if(d.has(u.name))continue;let f=o.get(u.name);a.push(f===void 0?u:{...f,builtin:!1})}for(let u of s){if(pA.some((f)=>f.name===u.name))continue;a.push({...u,builtin:!1})}return a}function re(n,r){let s=pt(r);Fe(z(r),{recursive:!0});let d={version:ne,sources:n.sources??[],...n.disabled===void 0||n.disabled.length===0?{}:{disabled:n.disabled}};Ce(s,`${JSON.stringify(d,null,4)}
5
+ `)}function xo(n,r){let s=G(r),d=(s.sources??[]).filter((a)=>a.name!==n.name),o=(s.disabled??[]).filter((a)=>a!==n.name);re({...s,sources:[...d,n],disabled:o},r)}function Yo(n,r){let s=G(r),d=(s.sources??[]).filter((w)=>w.name!==n),o=d.length!==(s.sources??[]).length,a=pA.some((w)=>w.name===n),u=(s.disabled??[]).includes(n);if(!o&&!a)return!1;if(a&&u&&!o)return!1;let f=a&&!u?[...s.disabled??[],n]:s.disabled??[];return re({...s,sources:d,disabled:f},r),!0}function En(n){let r=n.trim();if(r.length===0)throw H(n);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 H(n)}if(s.protocol!=="https:"&&s.protocol!=="http:")throw H(n);let d=s.pathname.split("/").filter((w)=>w.length>0),o=d.findIndex((w)=>w==="tree"||w==="blob");if(o<2)return{url:`${s.origin}/${d.join("/")}`.replace(/\.git$/,"")};let a=d.slice(0,o).join("/"),u=d[o+1],f=d.slice(o+2).join("/");return{url:`${s.origin}/${a}`.replace(/\.git$/,""),...u===void 0?{}:{ref:u},...f.length===0?{}:{path:f}}}function H(n){return new A({code:"skill_source_url_invalid",message:`${JSON.stringify(n)} 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 se(n){let r=n.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 A({code:"skill_ref_invalid",message:`${JSON.stringify(n)} 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 le="SKILL.md",ce=180000,zn=async(n,r)=>{let s=await ye({command:"git",args:n,...r===void 0?{}:{cwd:r},timeoutMs:ce,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 A({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 de(n,r){return T(D(r),`${n}.json`)}function pn(n,r){let s=de(n,r);if(!P(s))return{};try{return JSON.parse(ae(s,"utf8"))}catch{return{}}}function Ee(n,r){return P(T(U(n,r),".git"))}function Qn(n){return n.startsWith(".")||n.startsWith("/")||n.startsWith("~")||P(n)}async function hA(n,r={}){let s=r.git??zn,d=r.env,o=U(n.name,d),a=`${o}.partial`;Pe(D(d),{recursive:!0}),j(a,{recursive:!0,force:!0});let u=["clone","--depth","1","--single-branch",...n.ref===void 0?[]:["--branch",n.ref]],f=n.path!==void 0,w=!f,p=f?await s([...u,"--filter=blob:none","--sparse",n.url,a]):await s([...u,n.url,a]);if(p.code!==0&&f){j(a,{recursive:!0,force:!0});let k=await s([...u,n.url,a]);if(k.code===0)w=!0,p=k}if(p.code!==0)throw j(a,{recursive:!0,force:!0}),Je(n,p);if(n.path!==void 0&&!w){let k=await s(["sparse-checkout","set",n.path],a);if(k.code!==0)throw j(a,{recursive:!0,force:!0}),new A({code:"skill_source_path_missing",message:`${n.name}: could not narrow the checkout to ${n.path}`,hint:`Check the path exists in ${n.url}. ${k.stderr.trim()||"git said nothing."}`})}let O=await s(["rev-parse","--short","HEAD"],a),E=O.code===0?O.stdout.trim():"unknown";j(o,{recursive:!0,force:!0}),De(a,o);let y=Ne(n,d).length;return Ke(de(n.name,d),`${JSON.stringify({commit:E,fetchedAt:new Date().toISOString(),skills:y},null,4)}
6
+ `),{commit:E,skills:y,unfiltered:w}}function Je(n,r){let s=r.stderr.trim().split(`
7
+ `).slice(-3).join(" ");if(r.timedOut===!0)return new A({code:"skill_source_timeout",message:`${n.name}: git did not finish within ${Math.round(ce/1000)}s`,hint:`Check the network, then try again — a partly fetched source was discarded, so the previous copy of ${n.name} is untouched.`});return new A({code:"skill_source_fetch_failed",message:`${n.name}: could not clone ${n.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 We=4,fe=new Set(["node_modules","dist","build","target","vendor",".git"]);function Ge(n){let r=[],s=(d,o)=>{if(o>We)return;let a;try{a=oe(d,{withFileTypes:!0})}catch{return}if(P(T(d,le)))r.push(d);for(let u of a){if(!u.isDirectory())continue;if(u.name.startsWith(".")||fe.has(u.name))continue;s(T(d,u.name),o+1)}};return s(n,0),r.sort()}var Xe=[".py",".sh",".js",".ts",".mjs",".rb",".pl"];function me(n,r=0){if(r>3)return[];let s=[],d;try{d=oe(n,{withFileTypes:!0})}catch{return[]}for(let o of d){let a=T(n,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||fe.has(o.name))continue;s.push(...me(a,r+1));continue}if(!o.isFile())continue;if((Ue(a).mode&73)!==0||Xe.some((f)=>o.name.endsWith(f)))s.push(a)}return s}function Ne(n,r){let s=U(n.name,r),d=n.path===void 0?s:T(s,n.path);if(!P(d))return[];let o=[];for(let a of Ge(d)){let u=ae(T(a,le),"utf8"),f=a.slice(a.lastIndexOf("/")+1),w={source:n.name,dir:a,repoPath:Be(s,a),scripts:me(a)};try{let p=xe(f,u);o.push({...w,skill:p.frontmatter.name,description:p.frontmatter.description,tokens:m(p.body)})}catch(p){o.push({...w,skill:f,description:"",tokens:m(u),problem:p instanceof Error?p.message:String(p)})}}return o}var N="SKILL.md";function Re(n){try{let r=b(n.manifestPath,{env:{...C([n.manifestPath]),...n.envOverlay}}),d=n.action==="new"||n.action==="install"?st(r.path,r.dir,r.manifest.skills):r.manifest.skills;if(d===void 0)return Ze(n);let o=q(r.manifest.model.main.id,r.manifest.model.main.capabilities),a=Se(d.dir)?d.dir:V(r.dir,d.dir);if(n.action==="new")return it(a,n);if(n.action==="remove")return dt(a,n);let u=tA({dir:a,maxActive:d.maxActive,threshold:d.threshold,style:o.promptStyle,agentDir:r.dir,runner:v()});switch(n.action){case"list":return et(a,u.skills,u,n);case"show":return tt(u.skills,n);case"install":return at(a,n);default:return nt(u.skills,n)}}catch(r){if(n.json===!0&&r instanceof A)return process.stdout.write(`${JSON.stringify({ok:!1,error:r.toDetail(),details:r.details},null,2)}
8
+ `),i;throw r}}function Ze(n){if(n.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,configured:!1,skills:[]},null,2)}
9
+ `),t;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 ${n.manifestPath} <source>/<skill>
14
+
15
+ `+` · or write your own from a template:
16
+ `+` skills new ${n.manifestPath} <name>
17
+
18
+ either one turns skills on for this agent; neither needs agent.yaml edited by hand
19
+ `),t}function et(n,r,s,d){let o=L(n);if(d.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,configured:!0,cached:s.cached,maxActive:s.maxActive,threshold:s.threshold,skills:r.map((a)=>({...Y(a),...o[a.name]===void 0?{}:{origin:o[a.name]}}))},null,2)}
20
+ `),t;if(r.length===0)return process.stdout.write(`no skills in ${n}
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
+ `),t;process.stdout.write(`${g([{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(`${B("catalogue")}
26
+ `);for(let a of r){let u=a.scripts.length===0?"":` ${a.scripts.length} script(s)`,f=a.frontmatter.whenNotToUse===void 0?" no when-not-to-use":"",w=o[a.name],p=w===void 0?"":` ${w.source}@${w.commit}`;process.stdout.write(` ${a.name.padEnd(20)} ${String(a.tokens).padStart(5)} tokens${u}${p}${f}
27
+ `)}return t}function tt(n,r){let s=r.name;if(s===void 0)return process.stdout.write("skills show needs a skill name — `skills list` names them\n"),i;let d=n.find((u)=>u.name===s);if(d===void 0){let u=n.map((f)=>f.name).join(", ");return process.stdout.write(`no skill named ${s}${u===""?"":`. Known: ${u}`}
28
+ `),i}if(r.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,skill:rt(d)},null,2)}
29
+ `),t;let{frontmatter:o}=d;if(process.stdout.write(`${g([{label:"name",value:d.name},{label:"directory",value:d.dir},{label:"body",value:`${d.tokens} tokens`},...o.license===void 0?[]:[{label:"license",value:o.license}],...o.compatibility===void 0?[]:[{label:"needs",value:o.compatibility}]])}
30
+ `),process.stdout.write(`${B("description")}
31
+ `),process.stdout.write(`${c(o.description)}
32
+ `),process.stdout.write(`${B("when not to use")}
33
+ `),process.stdout.write(`${c(o.whenNotToUse??`not declared — add metadata.${He()} to improve routing`)}
34
+ `),d.scripts.length>0){process.stdout.write(`${B("scripts")}
35
+ `);for(let u of d.scripts)process.stdout.write(`${l(`${u.slug} — scripts/${u.file} via ${u.interpreter??"its own shebang"}`)}
36
+ `)}if(d.ignoredScripts.length>0){process.stdout.write(`${B("in scripts/ and not runnable")}
37
+ `);for(let u of d.ignoredScripts)process.stdout.write(`${l(`${u.file} — ${u.reason}`)}
38
+ `)}if(o.allowedTools!==void 0)process.stdout.write(`${B("allowed-tools, declared and not honoured")}
39
+ `),process.stdout.write(`${c(o.allowedTools)}
40
+ `),process.stdout.write(`${c("this runtime reads the field and never acts on it; permissions live in tools.policy")}
41
+ `);let a=Object.entries(o.metadata).filter(([u])=>u!==He());if(a.length>0)process.stdout.write(`${B("metadata")}
42
+ `),process.stdout.write(`${g(a.map(([u,f])=>({label:u,value:f})))}
43
+ `);return t}function nt(n,r){let s=ao(n);if(r.json===!0)return process.stdout.write(`${JSON.stringify({ok:s.length===0,skills:n.map(Y),findings:s},null,2)}
44
+ `),r.strict===!0&&s.length>0?i:t;let d=new Map;for(let o of s){let u=n.find((f)=>o.message.includes(` ${f.name}:`))?.name??"";d.set(u,[...d.get(u)??[],o])}for(let o of n){let a=d.get(o.name)??[];process.stdout.write(` ${o.name.padEnd(20)} ${a.length===0?"ok":`${a.length} warning(s)`}
45
+ `)}if(s.length===0)return process.stdout.write(`
46
+ no findings
47
+ `),t;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?i:t}function Y(n){return{name:n.name,tokens:n.tokens,hasWhenNotToUse:n.frontmatter.whenNotToUse!==void 0,scripts:n.scripts.map((r)=>r.slug),ignoredScripts:n.ignoredScripts}}function rt(n){return{...Y(n),dir:n.dir,description:n.frontmatter.description,...n.frontmatter.whenNotToUse===void 0?{}:{whenNotToUse:n.frontmatter.whenNotToUse},...n.frontmatter.license===void 0?{}:{license:n.frontmatter.license},...n.frontmatter.compatibility===void 0?{}:{compatibility:n.frontmatter.compatibility},...n.frontmatter.allowedTools===void 0?{}:{allowedToolsDeclaredNotHonoured:n.frontmatter.allowedTools},metadata:n.frontmatter.metadata}}function st(n,r,s){let d=s?.dir??"./skills",o=Se(d)?d:V(r,d);if(we(o,{recursive:!0}),s!==void 0)return s;let a=oo({file:n,path:["skills"],value:ot(d)});if(process.stdout.write(`${g([{label:"enabled",value:`skills.dir = ${d}`}])}
53
+ `),a.reflowed)process.stdout.write(`${l("the file was re-serialised to add the block — it is valid, and comments may have moved")}
54
+ `);return{dir:d,...be}}var be={maxActive:1,threshold:0.35};function ot(n){return{dir:n,...be}}function it(n,r){let s=r.name;if(s===void 0)return process.stdout.write("skills new needs a name — `skills new <manifest> <name>`\n"),i;if(!ro(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
+ `),i;let d=x(n,s);if(I(d))return process.stdout.write(`${d} already exists — nothing was written
56
+ `),i;return we(d,{recursive:!0}),Ye(x(d,"SKILL.md"),Dt(Rn,{SKILL_NAME:s,WHEN_NOT_TO_USE_KEY:He()}),"utf8"),process.stdout.write(`${g([{label:"created",value:x(d,"SKILL.md")},{label:"name",value:s}])}
57
+ `),process.stdout.write(`${B("next")}
58
+ ${l("edit the description — it is the only thing selection reads, so name the words someone would actually type")}
59
+ ${l("write the steps in place of the placeholder body")}
60
+ ${l("skills validate — it warns until the scaffold is replaced")}
61
+ ${l("restart the agent: the catalogue is scanned once at boot")}
62
+ `),t}function at(n,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"),i;let d=Qn(s),o;if(!d){let y=lt(s,r.sandboxEnv);if(y===void 0)return i;o=y}let a=o===void 0?V(s):o.entry.dir;if(o===void 0){if(!I(a)||!$e(a).isDirectory())return process.stdout.write(`${a} is not a directory
63
+ `),i;if(I(s)&&Z(r.sandboxEnv).some((y)=>y.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 u={},f=[],p=I(x(a,N))?[a]:K(a,{withFileTypes:!0}).filter((y)=>y.isDirectory()&&I(x(a,y.name,N))).map((y)=>x(a,y.name));if(p.length===0)return process.stdout.write(`no ${N} in ${a} or in any directory directly inside it
66
+ `),i;let O=[],E=[];for(let y of p){let k;try{k=xe(ge(y),Ve(x(y,N),"utf8")).frontmatter.name}catch(_){E.push(`${ge(y)} — ${_ instanceof Error?_.message:String(_)}`);continue}let F=x(n,k);if(I(F)){E.push(`${k} — already installed at ${F}`);continue}if(qe(y,F,{recursive:!0,preserveTimestamps:!0}),O.push(k),o!==void 0)u[k]={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()};f.push(...ke(F).map((_)=>`${k}/${Qe(F,_)}`))}if(Object.keys(u).length>0)te(n,u);if(r.collect!==void 0){for(let y of O)r.collect.push({name:y,ok:!0,runnable:f.filter((k)=>k.startsWith(`${y}/`))});for(let y of E){let k=y.indexOf(" — ");r.collect.push({name:k===-1?y:y.slice(0,k),ok:!1,reason:k===-1?y:y.slice(k+3),runnable:[]})}}if(r.quiet===!0)return O.length===0?i:t;process.stdout.write(`${g([{label:"from",value:o===void 0?a:`${o.spec.name} (${o.spec.url}) at ${o.commit}`},{label:"installed",value:O.join(", ")},{label:"skipped",value:E.length===0?"":String(E.length)}])}
67
+ `);for(let y of E)process.stdout.write(`${l(y)}
68
+ `);if(f.length>0){if(process.stdout.write(`${B("this installed code, which the agent can run")}
69
+ ${f.slice(0,12).map((y)=>l(y)).join(`
70
+ `)}
71
+ `),f.length>12)process.stdout.write(`${c(`… and ${f.length-12} more`)}
72
+ `);process.stdout.write(`${c("read them before the agent does; `tools.policy` can name a skill script by slug")}
73
+ `)}if(O.length>0)process.stdout.write(`${B("next")}
74
+ ${l("skills validate — a vendored skill usually has no negative guidance, which is a warning and not a problem")}
75
+ ${l("restart the agent: the catalogue is scanned once at boot")}
76
+ `);return O.length===0?i:t}function lt(n,r){let s;try{s=se(n)}catch(p){if(!(p instanceof A))throw p;process.stdout.write(`${p.message}
77
+
78
+ ${p.hint}
79
+ `);return}let d=Z(r),o=s.source===void 0?d:d.filter((p)=>p.name===s.source);if(o.length===0){let p=S(s.source??"",d.map((O)=>O.name));process.stdout.write(`no source called ${s.source}
80
+
81
+ ${p===void 0?"`sources list` shows them.":`Did you mean ${p}?`}
82
+ `);return}if(o.filter((p)=>!Ee(p.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 u=o.filter((p)=>Ee(p.name,r)).flatMap((p)=>Ne(p,r).map((O)=>({entry:O,spec:p}))),f=u.filter((p)=>p.entry.skill===s.skill);if(f.length===0){let p=S(s.skill,u.map((O)=>O.entry.skill));process.stdout.write(`no skill called ${s.skill} in ${o.map((O)=>O.name).join(", ")}
86
+
87
+ ${p===void 0?`\`sources search ${s.skill}\` ranks what is there.`:`Did you mean ${p}? \`sources search ${s.skill}\` ranks the alternatives.`}
88
+ `);return}if(f.length>1){process.stdout.write(`${f.length} sources carry a skill called ${s.skill}
89
+
90
+ ${f.map((p)=>` ${p.spec.name}/${p.entry.skill} — ${p.spec.url}
91
+ `).join("")}
92
+ Name one.
93
+ `);return}let w=f[0];if(w.entry.problem!==void 0){process.stdout.write(`${w.spec.name}/${w.entry.skill} will not load: ${w.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:w.entry,spec:w.spec,commit:pn(w.spec.name,r).commit??"unknown"}}function ke(n,r=0){if(r>3)return[];let s=[];for(let d of K(n,{withFileTypes:!0})){let o=x(n,d.name);if(d.isDirectory()){if(d.name.startsWith("."))continue;s.push(...ke(o,r+1));continue}if(!d.isFile())continue;if(($e(o).mode&73)!==0||ct.some((u)=>d.name.endsWith(u)))s.push(o)}return s}var ct=[".py",".sh",".js",".ts",".mjs",".rb",".pl"];function dt(n,r){let s=r.name;if(s===void 0)return process.stdout.write("skills remove needs a name — `skills list` names them\n"),i;let d=x(n,s);if(!I(x(d,N))){let u=I(n)?K(n,{withFileTypes:!0}).filter((f)=>f.isDirectory()&&I(x(n,f.name,N))).map((f)=>f.name).join(", "):"";return process.stdout.write(`no skill named ${s}${u===""?"":`. Known: ${u}`}
97
+ `),i}let o=ve(d),a=L(n)[s];return ze(d,{recursive:!0,force:!0}),hn(n,s),process.stdout.write(`${g([{label:"removed",value:d},{label:"files",value:String(o)},...a===void 0?[]:[{label:"came from",value:`${a.source} (${a.url}) at ${a.commit}`}]])}
98
+ `),process.stdout.write(`${l("restart the agent: the catalogue is scanned once at boot")}
99
+ `),t}function ve(n){let r=0;for(let s of K(n,{withFileTypes:!0}))r+=s.isDirectory()?ve(x(n,s.name)):1;return r}async function yA(n){let r=n.onStatus??(()=>{}),s=Z(n.env),d=s.filter((a)=>!Ee(a.name,n.env));for(let[a,u]of d.entries()){r(`fetching ${u.name} (${a+1} of ${d.length}) — once per machine, shared by every agent`);try{let f=await hA(u,{...n.env===void 0?{}:{env:n.env},...n.git===void 0?{}:{git:n.git}});r(`${u.name}: ${f.skills} skills`)}catch(f){r(`${u.name} could not be fetched: ${f instanceof A?f.message:String(f)}`)}}let o=s.filter((a)=>Ee(a.name,n.env)).map((a)=>({spec:a,entries:Ne(a,n.env)}));return ui(o)}async function ut(n){return await yA({...n,onStatus:(r)=>process.stdout.write(`${r}
100
+ `)})}function Jo(n,r,s){let d=[];for(let o of n)Re({action:"install",manifestPath:r,name:o,quiet:!0,collect:d,...s.env===void 0?{}:{sandboxEnv:s.env},...s.envOverlay===void 0?{}:{envOverlay:s.envOverlay}});return mt(d)}function ft(n,r,s){let d=[];for(let o of n)Re({action:"install",manifestPath:r,name:`${o.source}/${o.skill}`,quiet:!0,collect:d,...s.env===void 0?{}:{sandboxEnv:s.env},...s.envOverlay===void 0?{}:{envOverlay:s.envOverlay}});return d}function mt(n){let r=WA(n);if(process.stdout.write(`${B(`installed ${r.installed.length} of ${r.total} skill${r.total===1?"":"s"}`,!0)}
101
+ `),r.installed.length>0)process.stdout.write(`${c(r.installed.join(", "))}
102
+ `);for(let s of r.failed)process.stdout.write(`${l(`${s.name} — ${s.reason}`)}
103
+ `);if(r.runnable>0)process.stdout.write(`${B("code that came with them")}
104
+ ${c(`${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 jo(n){if(Z(n.env).length===0)return process.stdout.write(`no skill sources are configured
106
+
107
+ \`${e.slug} sources add <url>\` adds one — a repository holding a skills/ directory.
108
+ `),i;if(!(ue({plain:n.plain===!0,json:n.json===!0,oneShot:!1}).mode==="rich"&&n.json!==!0)){let y=await ut(n);if(y.length===0)return process.stdout.write(`nothing to show — no catalogue could be read
109
+
110
+ \`${e.slug} sources update\` reports why.
111
+ `),i;if(n.json===!0)return gt(y);return yt(y,R(n.env))}let o=R(n.env);if(o.length===0)return process.stdout.write(`${B("no agent to install into",!0)}
112
+ ${c(`\`${e.slug} init\` creates one, then this command installs into it.`)}
113
+ `),i;let[{render:a},{createElement:u},{SkillBrowser:f}]=await Promise.all([import("ink"),import("react"),import("./SkillBrowser-66ntwaa9.js")]),w,p=()=>{},O=new Promise((y)=>{p=y});he(),process.stdout.write(Me);let E=a(u(f,{title:wt,agents:o,load:(y)=>yA({...n,onStatus:y}),install:async(y,k)=>WA(ft(y,k,n)),onDone:(y)=>{w=y,p()}}),{exitOnCtrlC:!1,...X()});if(h(()=>E.unmount()),await O,E.unmount(),ie(),await pe(),w===void 0)return t;for(let y of w.failed)process.stderr.write(`${y.name} — ${y.reason}
114
+ `);if(w.installed.length>0)process.stdout.write(`${w.installed.length} skill${w.installed.length===1?"":"s"} installed — \`${e.slug} skills list <agent>\` shows them
115
+ `);return w.failed.length===w.total&&w.total>0?i:t}function gt(n){return process.stdout.write(`${JSON.stringify({skills:n.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
+ `),t}function ht(n){let s=n.reduce((a,u)=>u.kind==="item"?Math.max(a,u.label.length):a,0),d=Vt(100,s+12,{nameMax:46}),o=[];for(let a of n){if(a.kind==="source"){o.push(`
117
+ ${a.label}`);continue}if(a.kind==="group"){o.push(` ${a.label}`);continue}let u=Wt({name:`${a.entry?.source}/${a.label}`,meta:a.meta??"",description:a.description??""},d);o.push(` ${u.name} ${u.meta} ${u.description}`.trimEnd())}return o.join(`
118
+ `)}function yt(n,r){process.stdout.write(`${ht(n)}
119
+ `);let s=n.find((o)=>o.entry!==void 0)?.entry,d=r[0]?.ref??"<agent>";return process.stdout.write(`${B("install")}
120
+ ${c(`${e.slug} skills install ${d} ${s?.source??"anthropic"}/${s?.skill??"pdf"}`)}
121
+ ${c(`${e.slug} skills — at a terminal, ticks several at once`,2)}
122
+ `),t}var wt=`${e.name} ${M}`;
123
+ export{pA,QA,pt,Z,xo,Yo,En,zn,pn,Ee,Qn,hA,Ne,hn,Re,yA,Jo,jo};
124
+
125
+ //# debugId=1A371287FAF16E4464756E2164756E21
126
+ //# sourceMappingURL=index-q0hxh57v.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": ";0cAkBA,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,GAAU,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,EAAa,CAAC,EAAmB,EAA+C,CAC5F,IAAM,EAAS,IAAK,EAAY,CAAS,KAAM,CAAM,EACrD,EACI,EAA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AAO,EAAM,SAAS,EAAM,SAAS,EAAM,cAAc,QAAQ,CAAC,EAEjF,OAAO,EAAM,KAAK;AAAA,CAAI,EAS1B,SAAS,EAAS,CAAC,EAA4B,EAAyC,CACpF,QAAQ,OAAO,MAAM,GAAG,GAAc,CAAI;AAAA,CAAK,EAC/C,IAAM,EAAU,EAAK,KAAK,CAAC,IAAQ,EAAI,QAAU,MAAS,GAAG,MACvD,EAAQ,EAAO,IAAI,KAAO,UAIhC,OAHA,QAAQ,OAAO,MACX,GAAG,EAAQ,SAAS;AAAA,EAAM,EAAO,GAAG,EAAM,uBAAuB,KAAS,GAAS,QAAU,eAAe,GAAS,OAAS,OAAO;AAAA,EAAM,EAAO,GAAG,EAAM,qDAAsD,CAAC;AAAA,CACtN,EACO,EAIJ,IAAM,GAAe,GAAG,EAAM,QAAQ",
12
+ "debugId": "1A371287FAF16E4464756E2164756E21",
13
+ "names": []
14
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import{A,ae,VA,de}from"./index-byxrc961.js";import{Xn}from"./index-3mtgcvkq.js";import{chmodSync as u,existsSync as y,readFileSync as f,statSync as _,writeFileSync as x}from"node:fs";import{dirname as b,join as E}from"node:path";function w(e){if(!(e===""||/^["']/.test(e)||/\s/.test(e)||e.includes("#")||e!==e.trim()))return e;return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}function g(e,n,r){let t=`${n}=${w(r)}`,o=e.split(`
3
+ `),a=new RegExp(`^\\s*(?:export\\s+)?${n}\\s*=`),s=o.findIndex((c)=>a.test(c));if(s!==-1){let c=o[s]??"",d=/^\s*export\s+/.exec(c)?.[0]??"";return{text:[...o.slice(0,s),`${d}${t}`,...o.slice(s+1)].join(`
4
+ `),replaced:!0}}let l=e.replace(/\n+$/,"");return{text:l===""?`${t}
5
+ `:`${l}
6
+ ${t}
7
+ `,replaced:!1}}function jn(e){return E(b(e),".env")}async function dt(e,n,r){let t=VA(r),o=await ae({file:e,path:n.split("."),value:t});return{note:`${n} is now ${S(t)}`,reflowed:o.reflowed,before:o.before}}async function Ct(e,n,r){let t=f(e,"utf8"),o=de(t,["channels"]);if(!Array.isArray(o))throw new A({code:"cli_config_no_channels",message:"This agent has no channels, so there is nobody to allow.",hint:"`config set <agent> channels '[{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]'` declares one first."});let a=o.filter((i)=>typeof i==="object"&&i!==null&&!Array.isArray(i)),s=a.findIndex((i)=>String(i.id??"")===n);if(s===-1)throw new A({code:"cli_config_channel_unknown",message:`No channel with id "${n}".`,hint:`Declared: ${a.map((i)=>String(i.id??"")).join(", ")}.`,field:"channel"});let l=a[s],c=r.map((i)=>_n(i,String(l.type??""))),d=[...new Set(c)],p=Array.isArray(l.allowFrom)?l.allowFrom.map(String):[],h=await ae({file:e,path:["channels"],value:a.map((i,m)=>m===s?{...i,allowFrom:d}:i)});return{note:d.length===0?`${n} now allows nobody, which refuses every message`:`${n} now allows ${d.join(", ")}`,reflowed:h.reflowed,before:p}}function Ye(e,n,r){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new A({code:"cli_config_env_name_invalid",message:`"${n}" is not an environment variable name.`,hint:"Letters, digits and underscores, not starting with a digit — MODEL_API_KEY, TELEGRAM_BOT_TOKEN.",field:"name"});if(r==="")throw new A({code:"cli_config_env_empty",message:`An empty value for ${n} would not start the agent.`,hint:"A variable set to nothing fails the load exactly as a missing one does. Nothing was written."});let t=jn(e),o=y(t)?f(t,"utf8"):"",a=g(o,n,r);x(t,a.text,{encoding:"utf8",mode:384});let s=(_(t).mode&63)!==0;if(s)u(t,384);return{note:`${n} ${a.replaced?"replaced":"written"} in ${t}${s?" (tightened to 0600)":""}`,reflowed:!1,before:void 0}}function _n(e,n){let r=e.trim();if(r==="")throw new A({code:"cli_config_handle_missing",message:"No handle given.",hint:"On Telegram that is the username, not the display name.",field:"handle"});if(n!=="telegram")return r;let t=Xn(r);if(!t.ok)throw new A({code:"cli_config_handle_invalid",message:`"${r}" ${t.reason}`,hint:"A handle that cannot exist matches nobody, and the only symptom is the bot silently refusing every message from the person it was set up for.",field:"handle"});return t.value}function S(e){if(e==="")return"empty";if(typeof e==="string")return e;return JSON.stringify(e)}
8
+ export{jn,dt,Ct,Ye,_n};
9
+
10
+ //# debugId=026305348889D14364756E2164756E21
11
+ //# sourceMappingURL=index-srmhk9g5.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/config-apply.ts", "../src/lib/dotenv-edit.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The three writes `config` performs, separated from how any surface prints them.\n *\n * The plain actions and the editor both go through here, which is the same argument the phase made one\n * level down: `editManifest` is the only thing that writes `agent.yaml` because three writers meant the\n * guarantee depended on which caller you were. Two *callers* of that writer would have the same problem\n * one step up — the editor validating a handle differently from `config allow`, or writing a secret\n * without tightening the file's mode.\n *\n * Each function does the effect and returns a sentence. Refusals throw `HarnessError`, so a caller that\n * prints to a terminal and a caller that shows a line in a frame both get the same words.\n */\n\nimport { chmodSync, existsSync, readFileSync, statSync, writeFileSync } from \"node:fs\"\nimport { dirname, join } from \"node:path\"\nimport { editManifest, HarnessError, manifestValueAt, parseSettingValue } from \"@dispach/core\"\nimport { upsertEnv } from \"#lib/dotenv-edit\"\nimport { telegramHandle } from \"#lib/init-flow\"\n\nexport interface Applied {\n /** One line saying what happened, for whichever surface asked. */\n readonly note: string\n /** The source editor could not place the path, so the document was re-serialised. */\n readonly reflowed: boolean\n /** What was there before, so a caller can offer the undo. */\n readonly before: unknown\n}\n\n/** The `.env` beside a manifest. */\nexport function envPathOf(manifestPath: string): string {\n return join(dirname(manifestPath), \".env\")\n}\n\nexport async function applySet(manifestPath: string, path: string, raw: string): Promise<Applied> {\n const value = parseSettingValue(raw)\n const result = await editManifest({ file: manifestPath, path: path.split(\".\"), value })\n return {\n note: `${path} is now ${describe(value)}`,\n reflowed: result.reflowed,\n before: result.before,\n }\n}\n\n/**\n * Add, remove or replace a channel's inbound allowlist.\n *\n * `handles` is the whole list, because the whole list is what gets written: the field lives inside a\n * sequence entry and the source editor matches `key:` at an indent, so one entry's key is not\n * addressable. Every handle is checked against the service that issues it first — an impossible one\n * matches nobody, and the only symptom is a bot that is connected, healthy and silently refusing the\n * person it was set up for.\n */\nexport async function applyAllow(\n manifestPath: string,\n channelId: string,\n handles: readonly string[],\n): Promise<Applied> {\n const source = readFileSync(manifestPath, \"utf8\")\n const channels = manifestValueAt(source, [\"channels\"])\n if (!Array.isArray(channels)) {\n throw new HarnessError({\n code: \"cli_config_no_channels\",\n message: \"This agent has no channels, so there is nobody to allow.\",\n hint: \"`config set <agent> channels '[{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]'` declares one first.\",\n })\n }\n\n const entries = channels.filter(\n (entry): entry is Record<string, unknown> =>\n typeof entry === \"object\" && entry !== null && !Array.isArray(entry),\n )\n const at = entries.findIndex((entry) => String(entry.id ?? \"\") === channelId)\n if (at === -1) {\n throw new HarnessError({\n code: \"cli_config_channel_unknown\",\n message: `No channel with id \"${channelId}\".`,\n hint: `Declared: ${entries.map((entry) => String(entry.id ?? \"\")).join(\", \")}.`,\n field: \"channel\",\n })\n }\n\n const target = entries[at] as Record<string, unknown>\n const checked = handles.map((handle) => checkedHandle(handle, String(target.type ?? \"\")))\n const unique = [...new Set(checked)]\n const before = Array.isArray(target.allowFrom) ? target.allowFrom.map(String) : []\n\n const result = await editManifest({\n file: manifestPath,\n path: [\"channels\"],\n value: entries.map((entry, index) =>\n index === at ? { ...entry, allowFrom: unique } : entry,\n ),\n })\n return {\n note:\n unique.length === 0\n ? `${channelId} now allows nobody, which refuses every message`\n : `${channelId} now allows ${unique.join(\", \")}`,\n reflowed: result.reflowed,\n before,\n }\n}\n\n/**\n * Put a value in the `.env` beside the manifest, at 0600.\n *\n * Written 0600 whichever way the file arrived: under a service manager this is the *only* path\n * credentials take — launchd hands a job almost no environment and a plist carries none on purpose — so\n * tightening it is right even when this command did not create it. `writeFileSync`'s mode applies only\n * when it creates the file, which is why the check afterwards is not redundant.\n */\nexport function applySecret(manifestPath: string, name: string, value: string): Applied {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n throw new HarnessError({\n code: \"cli_config_env_name_invalid\",\n message: `\"${name}\" is not an environment variable name.`,\n hint: \"Letters, digits and underscores, not starting with a digit — MODEL_API_KEY, TELEGRAM_BOT_TOKEN.\",\n field: \"name\",\n })\n }\n if (value === \"\") {\n throw new HarnessError({\n code: \"cli_config_env_empty\",\n message: `An empty value for ${name} would not start the agent.`,\n hint: \"A variable set to nothing fails the load exactly as a missing one does. Nothing was written.\",\n })\n }\n\n const path = envPathOf(manifestPath)\n const before = existsSync(path) ? readFileSync(path, \"utf8\") : \"\"\n const upsert = upsertEnv(before, name, value)\n writeFileSync(path, upsert.text, { encoding: \"utf8\", mode: 0o600 })\n const loose = (statSync(path).mode & 0o077) !== 0\n if (loose) chmodSync(path, 0o600)\n\n return {\n note: `${name} ${upsert.replaced ? \"replaced\" : \"written\"} in ${path}${loose ? \" (tightened to 0600)\" : \"\"}`,\n reflowed: false,\n before: undefined,\n }\n}\n\n/**\n * A handle, validated against the service that issues it.\n *\n * Telegram's rule is shared with `init` rather than restated, because a check only one surface performs\n * is a check the two disagree about. An unknown channel type passes through: guessing at another\n * service's identifier format would refuse handles that are perfectly valid.\n */\nexport function checkedHandle(raw: string, type: string): string {\n const given = raw.trim()\n if (given === \"\") {\n throw new HarnessError({\n code: \"cli_config_handle_missing\",\n message: \"No handle given.\",\n hint: \"On Telegram that is the username, not the display name.\",\n field: \"handle\",\n })\n }\n if (type !== \"telegram\") return given\n const checked = telegramHandle(given)\n if (!checked.ok) {\n throw new HarnessError({\n code: \"cli_config_handle_invalid\",\n message: `\"${given}\" ${checked.reason}`,\n hint: \"A handle that cannot exist matches nobody, and the only symptom is the bot silently refusing every message from the person it was set up for.\",\n field: \"handle\",\n })\n }\n return checked.value\n}\n\n/** A value as a short phrase, for a one-line note. */\nfunction describe(value: unknown): string {\n if (value === \"\") return \"empty\"\n if (typeof value === \"string\") return value\n return JSON.stringify(value)\n}\n",
6
+ "/**\n * Setting one variable in a `.env` without disturbing the rest of it. Pure: text in, text out.\n *\n * The same argument as `yaml-edit.ts`, for the same file's neighbour. A generated `.env` carries\n * comments naming what each variable is for and where to get it, and rewriting the file from a parsed\n * map would drop every one of them — which matters more here than in the manifest, because this is the\n * file somebody opens six months later wondering which dashboard a key came from.\n *\n * Deliberately not a `.env` *parser*: reading one is `parseDotEnv` in core, and a second implementation\n * of that would be two things that have to agree about quoting. This only ever finds a line and\n * replaces it, so the two meet at exactly one place — how a value is quoted on the way out, which is\n * written to be read back by that parser and asserted against it in the tests.\n */\n\n/** Whether a value needs quoting to survive `parseDotEnv`, and the quoted form if so. */\nexport function renderEnvValue(value: string): string {\n // Unquoted values stop at ` #`, and a leading quote character would be eaten as an opening quote.\n // Everything else round-trips bare, which keeps a generated file readable.\n const needsQuotes =\n value === \"\" ||\n /^[\"']/.test(value) ||\n /\\s/.test(value) ||\n value.includes(\"#\") ||\n value !== value.trim()\n if (!needsQuotes) return value\n const escaped = value\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\")\n return `\"${escaped}\"`\n}\n\nexport interface EnvUpsert {\n readonly text: string\n /** True when the variable was already there and its line was replaced. */\n readonly replaced: boolean\n}\n\n/**\n * Set `name` to `value`, replacing an existing assignment in place or appending a new one.\n *\n * Replacing **in place** rather than appending is what stops the file growing a second, shadowing\n * assignment on every edit — `parseDotEnv` takes the last one, so an append-only writer would leave a\n * file whose earlier lines are lies. A commented-out assignment is left alone: it is documentation,\n * and uncommenting it would resurrect a value somebody deliberately disabled.\n */\nexport function upsertEnv(source: string, name: string, value: string): EnvUpsert {\n const assignment = `${name}=${renderEnvValue(value)}`\n const lines = source.split(\"\\n\")\n // `export FOO=` counts, because `parseDotEnv` reads it. A `#` first does not.\n const pattern = new RegExp(`^\\\\s*(?:export\\\\s+)?${name}\\\\s*=`)\n const at = lines.findIndex((line) => pattern.test(line))\n\n if (at !== -1) {\n const existing = lines[at] ?? \"\"\n // The `export ` prefix is preserved: it is there because something sources this file rather\n // than reading it, and dropping it would break that quietly.\n const prefix = /^\\s*export\\s+/.exec(existing)?.[0] ?? \"\"\n return {\n text: [...lines.slice(0, at), `${prefix}${assignment}`, ...lines.slice(at + 1)].join(\n \"\\n\",\n ),\n replaced: true,\n }\n }\n\n // Appended with exactly one trailing newline, whatever the file ended with. A `.env` that gains a\n // blank line on every edit is a file that looks edited by a machine, which it is, but it should not\n // look careless about it.\n const body = source.replace(/\\n+$/, \"\")\n return { text: body === \"\" ? `${assignment}\\n` : `${body}\\n${assignment}\\n`, replaced: false }\n}\n"
7
+ ],
8
+ "mappings": ";gFAaA,oBAAS,gBAAW,kBAAY,cAAc,mBAAU,gBACxD,kBAAS,UAAS,kBCCX,SAAS,CAAc,CAAC,EAAuB,CASlD,GAAI,EALA,IAAU,IACV,QAAQ,KAAK,CAAK,GAClB,KAAK,KAAK,CAAK,GACf,EAAM,SAAS,GAAG,GAClB,IAAU,EAAM,KAAK,GACP,OAAO,EAOzB,MAAO,IANS,EACX,QAAQ,MAAO,MAAM,EACrB,QAAQ,KAAM,MAAK,EACnB,QAAQ,MAAO,KAAK,EACpB,QAAQ,MAAO,KAAK,EACpB,QAAQ,MAAO,KAAK,KAkBtB,SAAS,CAAS,CAAC,EAAgB,EAAc,EAA0B,CAC9E,IAAM,EAAa,GAAG,KAAQ,EAAe,CAAK,IAC5C,EAAQ,EAAO,MAAM;AAAA,CAAI,EAEzB,EAAU,IAAI,OAAO,uBAAuB,QAAW,EACvD,EAAK,EAAM,UAAU,CAAC,IAAS,EAAQ,KAAK,CAAI,CA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AAa,gBAAgB,IAAO,EAAQ,uBAAyB,KACxG,SAAU,GACV,OAAQ,MACZ,EAUG,SAAS,EAAa,CAAC,EAAa,EAAsB,CAC7D,IAAM,EAAQ,EAAI,KAAK,EACvB,GAAI,IAAU,GACV,MAAM,IAAI,EAAa,CACnB,KAAM,4BACN,QAAS,mBACT,KAAM,0DACN,MAAO,QACX,CAAC,EAEL,GAAI,IAAS,WAAY,OAAO,EAChC,IAAM,EAAU,GAAe,CAAK,EACpC,GAAI,CAAC,EAAQ,GACT,MAAM,IAAI,EAAa,CACnB,KAAM,4BACN,QAAS,IAAI,MAAU,EAAQ,SAC/B,KAAM,gJACN,MAAO,QACX,CAAC,EAEL,OAAO,EAAQ,MAInB,SAAS,CAAQ,CAAC,EAAwB,CACtC,GAAI,IAAU,GAAI,MAAO,QACzB,GAAI,OAAO,IAAU,SAAU,OAAO,EACtC,OAAO,KAAK,UAAU,CAAK",
9
+ "debugId": "026305348889D14364756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{o,I}from"./index-nn3tk25c.js";import{W}from"./index-xmv47vs0.js";import{Vt,Wt,Zt,G}from"./index-zn24991r.js";import{Box as M,Text as u}from"ink";import{jsx as s,jsxs as a}from"react/jsx-runtime";function Ut({rows:e,index:t,chosen:c,window:n,width:l}){let{from:r,to:d}=G(e.length,t,n),k=new Set(c),b=e.reduce((i,m)=>m.kind==="item"?Math.max(i,m.label.length):i,0),g=Vt(l,b);return a(M,{flexDirection:"column",children:[r>0?a(u,{dimColor:!0,wrap:"truncate",children:[" ",I.ellipsis," ",r," above"]}):null,e.slice(r,d).map((i,m)=>{let p=r+m;if(i.kind!=="item"){let S=i.kind==="source";return a(u,{wrap:"truncate",bold:S,color:S?o.accent:o.muted,children:[S?" ":" ",Zt(i.label,l-(S?2:4))]},p)}let y=p===t,f=k.has(p),x=Wt({name:i.label,meta:i.meta??"",description:i.description??""},g);return a(u,{wrap:"truncate",children:[s(u,{color:o.accent,children:y?I.pointer:" "}),s(u,{color:f?o.success:o.muted,children:f?I.checked:I.unchecked}),s(u,{bold:y,...f?{color:o.success}:{},children:x.name})," ",s(u,{color:o.muted,children:x.meta}),x.description===""?"":" ",s(u,{dimColor:!0,children:x.description})]},p)}),d<e.length?a(u,{dimColor:!0,wrap:"truncate",children:[" ",I.ellipsis," ",e.length-d," below"]}):null]})}function h(e,t,c){let n=e;for(let l=0;l<=t.length;l+=1){if(t[n.index]===!0)return n;let r=W(n,{kind:c?"down":"up"});if(r.index===n.index)return;n=r}return}function T(e,t,c,n){if(c.length===0)return e;return h(t,c,n)??h(t,c,!n)??e}function OA(e,t,c){switch(t.kind){case"move":{if(!c.includes(!0))return e;let n=W(e.cursor,t.move),l=n.index>=e.cursor.index;return{...e,cursor:T(e.cursor,n,c,l)}}case"toggle":{let n=e.cursor.index;if(c[n]!==!0)return e;let l=e.chosen.includes(n)?e.chosen.filter((r)=>r!==n):[...e.chosen,n].sort((r,d)=>r-d);return{...e,chosen:l}}case"all":{let n=c.flatMap((l,r)=>l?[r]:[]);return{...e,chosen:n}}case"none":return{...e,chosen:[]}}}function Kt(e){let t=e.indexOf(!0);return t===-1?0:t}
3
+ export{Ut,OA,Kt};
4
+
5
+ //# debugId=34365CDB1C0ACE9F64756E2164756E21
6
+ //# sourceMappingURL=index-swtyfhha.js.map
@@ -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,CAAM,EACvB,EAAU,EAAK,OACjB,CAAC,EAAK,IAAS,EAAI,OAAS,OAAS,KAAK,IAAI,EAAK,EAAI,MAAM,MAAM,EAAI,EACvE,CACJ,EACM,EAAU,GAAW,EAAO,CAAO,EAEzC,OACI,EAuDE,EAvDF,CAAK,cAAc,SAAnB,SAuDE,CAtDG,EAAO,EACJ,EAGE,EAHF,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,OACA,EAAM,SAFX,IAEsB,EAFtB,UAGE,EACF,KACH,EAAK,MAAM,EAAM,CAAE,EAAE,IAAI,CAAC,EAAK,IAAW,CACvC,IAAM,EAAK,EAAO,EAClB,GAAI,EAAI,OAAS,OAAQ,CACrB,IAAM,EAAS,EAAI,OAAS,SAC5B,OACI,EAQE,EARF,CAEI,KAAK,WACL,KAAM,EACN,MAAO,EAAS,EAAM,O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,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": "34365CDB1C0ACE9F64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{D}from"./index-zn24991r.js";import{tn,nn,aA,gA,cA}from"./index-2zye08c4.js";var s=" · ",l=3;function di(n,e){let t=[{kind:"title",text:D(n.title,e)}],r=n.agent===void 0?n.summary:[`${n.agent.name}${s}${n.agent.model}`,n.summary].filter((a)=>a!=="").join(s);if(r!=="")t.push({kind:"summary",text:D(r,e)});let i=n.state??[];if(i.length>0)t.push({kind:"state",text:D(i.map((a)=>a.label).join(s),e)});let o=n.warnings??[];for(let a of o.slice(0,l))t.push({kind:"warning",text:D(`⚠ ${a}`,e)});if(o.length>l)t.push({kind:"warning",text:D(`⚠ and ${o.length-l} more`,e)});return t}function Ci(n,e){let t=n.map((i)=>`${i.key} ${i.does}`),r="";for(let i of t){let o=r===""?i:`${r}${s}${i}`;if([...o].length>e)break;r=o}return r===""?D(t[0]??"",e):r}function Ln(n,e){let t=[n.title];if(n.summary!=="")t.push(n.summary);if(n.agent!==void 0)t.push(n.agent.name,n.agent.model);let r=n.warnings??[];if(r.length>0)t.push(`⚠ ${r.length} note${r.length===1?"":"s"} at the top`);return D(t.join(s),e)}var Bi={key:"q",does:"back"};function u(n,e){return n===void 0||n<=0?e:n}function V(n,e){return Math.max(tn,Math.min(nn,u(n,e)))}function fi(n,e){return Math.max(aA,Math.min(gA,u(n,e)-cA))}
3
+ export{di,Ci,Ln,Bi,V,fi};
4
+
5
+ //# debugId=7B1D4820D6A9D3AB64756E2164756E21
6
+ //# sourceMappingURL=index-whq42sat.js.map