dispach 0.2.3 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.md +46 -43
  2. package/dist/APEv2Parser-rt8hyadd.js +5 -0
  3. package/dist/{AiffParser-9hj6fpmy.js → AiffParser-gvpmtb2e.js} +3 -3
  4. package/dist/{AiffParser-9hj6fpmy.js.map → AiffParser-gvpmtb2e.js.map} +1 -1
  5. package/dist/App-18dvbyev.js +11 -0
  6. package/dist/{App-2f72vhjv.js.map → App-18dvbyev.js.map} +1 -1
  7. package/dist/AsfParser-h9zyh6cx.js +5 -0
  8. package/dist/{AsfParser-7emspn04.js.map → AsfParser-h9zyh6cx.js.map} +1 -1
  9. package/dist/ConfigEditor-444m13ta.js +6 -0
  10. package/dist/{ConfigEditor-vk7vxaa6.js.map → ConfigEditor-444m13ta.js.map} +1 -1
  11. package/dist/DsdiffParser-gxqv4gn1.js +5 -0
  12. package/dist/{DsdiffParser-dz88pnnr.js.map → DsdiffParser-gxqv4gn1.js.map} +1 -1
  13. package/dist/{DsfParser-qgh63tbs.js → DsfParser-sndt4jbk.js} +3 -3
  14. package/dist/{DsfParser-qgh63tbs.js.map → DsfParser-sndt4jbk.js.map} +1 -1
  15. package/dist/FlacParser-rmkpvf9e.js +5 -0
  16. package/dist/{KeyProbe-5anphmb7.js → KeyProbe-6t531sy6.js} +3 -3
  17. package/dist/{KeyProbe-5anphmb7.js.map → KeyProbe-6t531sy6.js.map} +1 -1
  18. package/dist/MP4Parser-87xfsck4.js +5 -0
  19. package/dist/{MP4Parser-yr7p3z12.js.map → MP4Parser-87xfsck4.js.map} +2 -2
  20. package/dist/{MatroskaParser-jkbsbsk3.js → MatroskaParser-7krspfgx.js} +3 -3
  21. package/dist/{MatroskaParser-jkbsbsk3.js.map → MatroskaParser-7krspfgx.js.map} +1 -1
  22. package/dist/{MpegParser-t93vwnew.js → MpegParser-jcs35q0h.js} +3 -3
  23. package/dist/{MpegParser-t93vwnew.js.map → MpegParser-jcs35q0h.js.map} +1 -1
  24. package/dist/MusepackParser-d4zfnzk3.js +5 -0
  25. package/dist/{MusepackParser-6e8kbh2d.js.map → MusepackParser-d4zfnzk3.js.map} +2 -2
  26. package/dist/OggParser-fbspjs7v.js +5 -0
  27. package/dist/{OggParser-ggcypmag.js.map → OggParser-fbspjs7v.js.map} +1 -1
  28. package/dist/Picker-x6aj42tc.js +5 -0
  29. package/dist/{Picker-j7txnm7w.js.map → Picker-x6aj42tc.js.map} +1 -1
  30. package/dist/SessionPicker-pngdv97x.js +5 -0
  31. package/dist/{SessionPicker-hpv2ncsb.js.map → SessionPicker-pngdv97x.js.map} +1 -1
  32. package/dist/SkillBrowser-3mnzkakr.js +5 -0
  33. package/dist/{SkillBrowser-qc542n71.js.map → SkillBrowser-3mnzkakr.js.map} +1 -1
  34. package/dist/WavPackParser-0x9z4466.js +5 -0
  35. package/dist/{WavPackParser-jw9stzqp.js.map → WavPackParser-0x9z4466.js.map} +1 -1
  36. package/dist/WaveParser-31b6qtef.js +5 -0
  37. package/dist/{WaveParser-epmncs9w.js.map → WaveParser-31b6qtef.js.map} +1 -1
  38. package/dist/WizardApp-c42wc116.js +5 -0
  39. package/dist/{WizardApp-pgzcz9zq.js.map → WizardApp-c42wc116.js.map} +1 -1
  40. package/dist/channels-nf6d8fvx.js +31 -0
  41. package/dist/{channels-m8nambmm.js.map → channels-nf6d8fvx.js.map} +1 -1
  42. package/dist/client.d.ts +1 -1
  43. package/dist/client.js +11 -11
  44. package/dist/client.js.map +4 -4
  45. package/dist/config-sx40rg8m.js +24 -0
  46. package/dist/{config-hmgrqgf2.js.map → config-sx40rg8m.js.map} +2 -2
  47. package/dist/credential-vdbkfk65.js +19 -0
  48. package/dist/{credential-nkb2ya59.js.map → credential-vdbkfk65.js.map} +1 -1
  49. package/dist/daemon.d.ts.map +1 -1
  50. package/dist/{index-51x0n5z0.js → index-0dcpsfet.js} +4 -4
  51. package/dist/{index-51x0n5z0.js.map → index-0dcpsfet.js.map} +1 -1
  52. package/dist/{index-yw3fby4n.js → index-1h8s50d9.js} +3 -3
  53. package/dist/{index-yw3fby4n.js.map → index-1h8s50d9.js.map} +1 -1
  54. package/dist/index-1hbvhrsj.js +6 -0
  55. package/dist/{index-dzy19wtf.js.map → index-1hbvhrsj.js.map} +1 -1
  56. package/dist/index-1hfece7s.js +10 -0
  57. package/dist/{index-22fzzn7z.js.map → index-1hfece7s.js.map} +2 -2
  58. package/dist/index-2h566rtg.js +6 -0
  59. package/dist/{index-jc4kmfwa.js.map → index-2h566rtg.js.map} +1 -1
  60. package/dist/index-4g4smpkk.js +11 -0
  61. package/dist/{index-sh44ymqz.js.map → index-4g4smpkk.js.map} +1 -1
  62. package/dist/index-4gfsf9n8.js +6 -0
  63. package/dist/{index-8tmv33mr.js.map → index-4gfsf9n8.js.map} +1 -1
  64. package/dist/{index-dv9pdjy4.js → index-5ptbytze.js} +10 -10
  65. package/dist/{index-dv9pdjy4.js.map → index-5ptbytze.js.map} +1 -1
  66. package/dist/index-5s1cq8np.js +8 -0
  67. package/dist/{index-9t4dz145.js.map → index-5s1cq8np.js.map} +1 -1
  68. package/dist/{index-2zjh5zd5.js → index-659ggfbf.js} +2 -2
  69. package/dist/index-6ebppx3t.js +6 -0
  70. package/dist/{index-1x8mzvz7.js.map → index-6ebppx3t.js.map} +1 -1
  71. package/dist/index-6pym9p8h.js +9 -0
  72. package/dist/{index-38gs9anh.js.map → index-6pym9p8h.js.map} +1 -1
  73. package/dist/index-9ejax6hp.js +6 -0
  74. package/dist/{index-8edck2pr.js.map → index-9ejax6hp.js.map} +1 -1
  75. package/dist/{index-zw6wyas6.js → index-9hw9j1qg.js} +4 -4
  76. package/dist/{index-zw6wyas6.js.map → index-9hw9j1qg.js.map} +1 -1
  77. package/dist/{index-bqdkm3de.js → index-9xhresrg.js} +4 -4
  78. package/dist/{index-bqdkm3de.js.map → index-9xhresrg.js.map} +1 -1
  79. package/dist/{index-hgm2gchq.js → index-abm0zyc0.js} +12 -12
  80. package/dist/{index-hgm2gchq.js.map → index-abm0zyc0.js.map} +1 -1
  81. package/dist/index-ar5c9d2f.js +7 -0
  82. package/dist/{index-3826kf9t.js.map → index-ar5c9d2f.js.map} +1 -1
  83. package/dist/index-bhj4pmrx.js +74 -0
  84. package/dist/index-bhj4pmrx.js.map +13 -0
  85. package/dist/index-brt17yfr.js +6 -0
  86. package/dist/{index-hrwakb11.js.map → index-brt17yfr.js.map} +2 -2
  87. package/dist/index-bysnsdkd.js +6 -0
  88. package/dist/{index-nxhqf597.js.map → index-bysnsdkd.js.map} +1 -1
  89. package/dist/index-c74wx9pv.js +6 -0
  90. package/dist/{index-323jvr1g.js.map → index-c74wx9pv.js.map} +1 -1
  91. package/dist/index-cm3g4t3r.js +14 -0
  92. package/dist/{index-y7dxq4a4.js.map → index-cm3g4t3r.js.map} +2 -2
  93. package/dist/index-dzp6mc5h.js +6 -0
  94. package/dist/{index-42e29zs4.js.map → index-dzp6mc5h.js.map} +1 -1
  95. package/dist/index-fad09b8c.js +6 -0
  96. package/dist/{index-836hc2h1.js.map → index-fad09b8c.js.map} +2 -2
  97. package/dist/{index-0444sh6x.js → index-fvb2dxzn.js} +4 -4
  98. package/dist/{index-0444sh6x.js.map → index-fvb2dxzn.js.map} +1 -1
  99. package/dist/{index-2bsardvh.js → index-gpq4agva.js} +3 -3
  100. package/dist/{index-2bsardvh.js.map → index-gpq4agva.js.map} +1 -1
  101. package/dist/{index-qgsdgbk8.js → index-hcpvk5de.js} +3 -3
  102. package/dist/{index-qgsdgbk8.js.map → index-hcpvk5de.js.map} +1 -1
  103. package/dist/{index-pqw1n1pv.js → index-jv5t63tp.js} +4 -4
  104. package/dist/{index-pqw1n1pv.js.map → index-jv5t63tp.js.map} +1 -1
  105. package/dist/index-kyz4t0j0.js +126 -0
  106. package/dist/{index-ry6a4bqh.js.map → index-kyz4t0j0.js.map} +2 -2
  107. package/dist/{index-ytxbw8py.js → index-m6r2sxcw.js} +33 -33
  108. package/dist/{index-ytxbw8py.js.map → index-m6r2sxcw.js.map} +1 -1
  109. package/dist/{index-snz49ndn.js → index-mhw3d7af.js} +3 -3
  110. package/dist/{index-snz49ndn.js.map → index-mhw3d7af.js.map} +1 -1
  111. package/dist/{index-1mbdz3f7.js → index-mk7hrzq7.js} +9 -9
  112. package/dist/{index-1mbdz3f7.js.map → index-mk7hrzq7.js.map} +1 -1
  113. package/dist/index-n0hqgwad.js +6 -0
  114. package/dist/{index-xg7s813b.js.map → index-n0hqgwad.js.map} +2 -2
  115. package/dist/index-ncb840sk.js +6 -0
  116. package/dist/{index-mjfv7k5w.js.map → index-ncb840sk.js.map} +1 -1
  117. package/dist/{index-fbsrhcga.js → index-ntczmwnf.js} +4 -4
  118. package/dist/{index-fbsrhcga.js.map → index-ntczmwnf.js.map} +1 -1
  119. package/dist/{index-095hrkyr.js → index-p5gy5s7p.js} +4 -4
  120. package/dist/{index-095hrkyr.js.map → index-p5gy5s7p.js.map} +1 -1
  121. package/dist/{index-3c5jt6by.js → index-p86w0qjw.js} +3 -3
  122. package/dist/{index-3c5jt6by.js.map → index-p86w0qjw.js.map} +1 -1
  123. package/dist/index-qhh30m9p.js +6 -0
  124. package/dist/{index-nvc24414.js.map → index-qhh30m9p.js.map} +1 -1
  125. package/dist/{index-p6ya59m6.js → index-rerdsr3d.js} +4 -4
  126. package/dist/{index-p6ya59m6.js.map → index-rerdsr3d.js.map} +1 -1
  127. package/dist/{index-k8e9f466.js → index-s0mfq8t7.js} +19 -19
  128. package/dist/index-s0mfq8t7.js.map +11 -0
  129. package/dist/{index-3vzf253k.js → index-s9ybp2r1.js} +7 -7
  130. package/dist/{index-3vzf253k.js.map → index-s9ybp2r1.js.map} +1 -1
  131. package/dist/index-ss77hvwy.js +1246 -0
  132. package/dist/{index-hpvfqq6r.js.map → index-ss77hvwy.js.map} +32 -31
  133. package/dist/{index-jff5q27j.js → index-t9bnt6a1.js} +4 -4
  134. package/dist/{index-jff5q27j.js.map → index-t9bnt6a1.js.map} +1 -1
  135. package/dist/index-w2ss9hn5.js +9 -0
  136. package/dist/{index-eztfverw.js.map → index-w2ss9hn5.js.map} +1 -1
  137. package/dist/{index-pszmnhgq.js → index-w80shmpv.js} +9 -9
  138. package/dist/{index-pszmnhgq.js.map → index-w80shmpv.js.map} +1 -1
  139. package/dist/index-w8e8qxd4.js +337 -0
  140. package/dist/index-w8e8qxd4.js.map +21 -0
  141. package/dist/{index-308y9xt0.js → index-z9r4e0yq.js} +4 -4
  142. package/dist/{index-308y9xt0.js.map → index-z9r4e0yq.js.map} +1 -1
  143. package/dist/index-zj87j4j2.js +6 -0
  144. package/dist/index-zj87j4j2.js.map +10 -0
  145. package/dist/{index-m6fqx0ch.js → index-zmerx9rc.js} +6 -6
  146. package/dist/{index-m6fqx0ch.js.map → index-zmerx9rc.js.map} +1 -1
  147. package/dist/index-zqjtjs7c.js +153 -0
  148. package/dist/{index-dpcm1j62.js.map → index-zqjtjs7c.js.map} +2 -2
  149. package/dist/index.js +381 -368
  150. package/dist/index.js.map +7 -6
  151. package/dist/lib/launchd.d.ts.map +1 -1
  152. package/dist/lib/service-env.d.ts.map +1 -1
  153. package/dist/lib/templates.d.ts.map +1 -1
  154. package/dist/lib/theme.d.ts.map +1 -1
  155. package/dist/lib/watchdog.d.ts +20 -0
  156. package/dist/lib/watchdog.d.ts.map +1 -0
  157. package/dist/serve.d.ts.map +1 -1
  158. package/dist/skills.d.ts.map +1 -1
  159. package/dist/sources.d.ts.map +1 -1
  160. package/dist/web-zvf80ns1.js +14 -0
  161. package/dist/{web-gfv0mzgs.js.map → web-zvf80ns1.js.map} +1 -1
  162. package/dist/wire.js +11 -11
  163. package/dist/wire.js.map +4 -4
  164. package/dist/wrapper-5zhcdmnk.js +5 -0
  165. package/package.json +4 -4
  166. package/dist/APEv2Parser-ysjr6adv.js +0 -5
  167. package/dist/App-2f72vhjv.js +0 -11
  168. package/dist/AsfParser-7emspn04.js +0 -5
  169. package/dist/ConfigEditor-vk7vxaa6.js +0 -6
  170. package/dist/DsdiffParser-dz88pnnr.js +0 -5
  171. package/dist/FlacParser-drm5wq0p.js +0 -5
  172. package/dist/MP4Parser-yr7p3z12.js +0 -5
  173. package/dist/MusepackParser-6e8kbh2d.js +0 -5
  174. package/dist/OggParser-ggcypmag.js +0 -5
  175. package/dist/Picker-j7txnm7w.js +0 -5
  176. package/dist/SessionPicker-hpv2ncsb.js +0 -5
  177. package/dist/SkillBrowser-qc542n71.js +0 -5
  178. package/dist/WavPackParser-jw9stzqp.js +0 -5
  179. package/dist/WaveParser-epmncs9w.js +0 -5
  180. package/dist/WizardApp-pgzcz9zq.js +0 -5
  181. package/dist/channels-m8nambmm.js +0 -31
  182. package/dist/config-hmgrqgf2.js +0 -24
  183. package/dist/credential-nkb2ya59.js +0 -19
  184. package/dist/index-1x8mzvz7.js +0 -6
  185. package/dist/index-22fzzn7z.js +0 -10
  186. package/dist/index-323jvr1g.js +0 -6
  187. package/dist/index-3826kf9t.js +0 -7
  188. package/dist/index-38gs9anh.js +0 -9
  189. package/dist/index-42e29zs4.js +0 -6
  190. package/dist/index-836hc2h1.js +0 -6
  191. package/dist/index-8edck2pr.js +0 -6
  192. package/dist/index-8tmv33mr.js +0 -6
  193. package/dist/index-9t4dz145.js +0 -8
  194. package/dist/index-djeqvfms.js +0 -74
  195. package/dist/index-djeqvfms.js.map +0 -13
  196. package/dist/index-dpcm1j62.js +0 -153
  197. package/dist/index-dzy19wtf.js +0 -6
  198. package/dist/index-eztfverw.js +0 -9
  199. package/dist/index-fxpmx6cr.js +0 -308
  200. package/dist/index-fxpmx6cr.js.map +0 -21
  201. package/dist/index-hpvfqq6r.js +0 -1252
  202. package/dist/index-hrwakb11.js +0 -6
  203. package/dist/index-jc4kmfwa.js +0 -6
  204. package/dist/index-k8e9f466.js.map +0 -13
  205. package/dist/index-mjfv7k5w.js +0 -6
  206. package/dist/index-nvc24414.js +0 -6
  207. package/dist/index-nxhqf597.js +0 -6
  208. package/dist/index-qv6ktepc.js +0 -6
  209. package/dist/index-qv6ktepc.js.map +0 -10
  210. package/dist/index-ry6a4bqh.js +0 -126
  211. package/dist/index-sh44ymqz.js +0 -11
  212. package/dist/index-xg7s813b.js +0 -6
  213. package/dist/index-y7dxq4a4.js +0 -14
  214. package/dist/web-gfv0mzgs.js +0 -14
  215. package/dist/wrapper-f662ny3r.js +0 -5
  216. /package/dist/{APEv2Parser-ysjr6adv.js.map → APEv2Parser-rt8hyadd.js.map} +0 -0
  217. /package/dist/{FlacParser-drm5wq0p.js.map → FlacParser-rmkpvf9e.js.map} +0 -0
  218. /package/dist/{index-2zjh5zd5.js.map → index-659ggfbf.js.map} +0 -0
  219. /package/dist/{wrapper-f662ny3r.js.map → wrapper-5zhcdmnk.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{t,A}from"./index-hpvfqq6r.js";import{gn,rt,TA,cn,ss}from"./index-qv6ktepc.js";class ot extends A{static ERROR_NAME="UsageError"}function S(e,i){let n=Array.from({length:i.length+1},(o,g)=>g);for(let o=1;o<=e.length;o+=1){let g=[o];for(let l=1;l<=i.length;l+=1){let f=(n[l-1]??0)+(e[o-1]===i[l-1]?0:1),d=(g[l-1]??0)+1,_=(n[l]??0)+1;g.push(Math.min(f,d,_))}n=g}return n[i.length]??Math.max(e.length,i.length)}function M(e,i){let n,o=Number.POSITIVE_INFINITY;for(let g of i){let l=S(e,g);if(l<o)o=l,n=g}return n!==void 0&&o<=Math.max(2,Math.floor(e.length/3))?n:void 0}class R{#e;#t;constructor(e,i){this.#e=e,this.#t=i}#n(e,i){let n=this.#t.get(e);if(n===void 0)throw new ot({code:"cli_flag_not_declared",message:`No flag "${e}" is declared for this command.`,hint:"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader."});if(n.kind!==i)throw new ot({code:"cli_flag_kind_mismatch",message:`Flag "${e}" is declared as ${n.kind} but was read as ${i}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(e)}str(e){let i=this.#n(e,"string");return typeof i==="string"?i:void 0}num(e){let i=this.#n(e,"number");return typeof i==="number"?i:void 0}bool(e){return this.#n(e,"boolean")===!0}has(e){return this.#e.has(e)}}function c(e,i,n,o){return o===void 0?{code:e,message:i,hint:n}:{code:e,message:i,hint:n,field:o}}function y(e){let i=e[0];return new ot({code:"cli_usage",message:e.length===1&&i!==void 0?i.message:`${e.length} problems with the command line.`,hint:e.length===1&&i!==void 0?i.hint:"Each problem below names the flag and its fix.",...i?.field===void 0?{}:{field:i.field},details:e})}function D(e,i,n){let o=Number(i);if(i.trim()===""||!Number.isFinite(o))return c("cli_flag_not_a_number",`${n} expects a number, got ${JSON.stringify(i)}.`,`Pass a number, as in ${n} 50. The old parser silently used the default here, which made a typo look like it worked.`,n);if(e.integer===!0&&!Number.isInteger(o))return c("cli_flag_not_an_integer",`${n} expects a whole number, got ${i}.`,`Drop the fractional part: ${n} ${Math.trunc(o)}.`,n);if(e.min!==void 0&&o<e.min)return c("cli_flag_below_min",`${n} must be at least ${e.min}, got ${o}.`,`Pass ${e.min} or more.`,n);return o}function is(e){let i=e[0];if(i===void 0)return{kind:"usage"};if(i.startsWith("-")){let s=new Set(gn.flatMap((a)=>a.short===void 0?[`--${a.name}`]:[`--${a.name}`,`-${a.short}`])),r=e.filter((a)=>!s.has(a));if(r.length>0)throw y([c("cli_no_command","No command given.",`Run \`${t.slug} --help\` for the command list. Commands are ${rt.map((a)=>a.name).join(", ")}.`,r[0])]);if(e.includes("--version")||e.includes("-v"))return{kind:"version"};if(e.includes("--help")||e.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let n=TA(i);if(n===void 0){let s=M(i,rt.map((r)=>r.name));throw y([c("cli_unknown_command",`Unknown command "${i}".`,s===void 0?`Run \`${t.slug} --help\` for the command list.`:`Did you mean "${s}"? Run \`${t.slug} --help\` for the full list.`,i)])}let o=new Map(cn(n).map((s)=>[s.name,s])),g=new Map(cn(n).filter((s)=>s.short!==void 0).map((s)=>[s.short,s])),l=new Map,f=[],d=[],_=!1,w=(s,r,a)=>{if(r===""){d.push(c("cli_flag_empty_value",`${a} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",a));return}if(s.kind==="number"){let u=D(s,r,a);if(typeof u==="number")l.set(s.name,u);else d.push(u);return}l.set(s.name,r)};for(let s=1;s<e.length;s+=1){let r=e[s];if(r===void 0)continue;if(_){f.push(r);continue}if(r==="--"){_=!0;continue}if(r.startsWith("--")){let a=r.slice(2),u=a.indexOf("="),m=u===-1?a:a.slice(0,u),h=o.get(m);if(h===void 0){let k=ss(m,n.name),x=M(m,[...o.keys()]);d.push(c(k.length>0?"cli_flag_wrong_command":"cli_unknown_flag",k.length>0?`${n.name} does not accept --${m}.`:`Unknown flag --${m}.`,k.length>0?`--${m} is accepted by: ${k.join(", ")}.`:x===void 0?`Run \`${t.slug} ${n.name} --help\` for the flags this command accepts.`:`Did you mean --${x}?`,`--${m}`));continue}let p=`--${m}`;if(h.kind==="boolean"){if(u!==-1){d.push(c("cli_flag_takes_no_value",`${p} is a switch and takes no value.`,`Drop the "=${a.slice(u+1)}" — pass ${p} on its own.`,p));continue}l.set(h.name,!0);continue}if(u!==-1){w(h,a.slice(u+1),p);continue}let b=e[s+1];if(h.bare!==void 0&&(b===void 0||b.startsWith("-"))){l.set(h.name,h.bare);continue}if(b===void 0){d.push(c("cli_flag_needs_value",`${p} needs a value.`,`Pass one, as in ${p} <${h.placeholder??"value"}>.`,p));continue}w(h,b,p),s+=1;continue}if(r.startsWith("-")&&r.length>1){for(let a of[...r.slice(1)]){let u=g.get(a);if(u===void 0){d.push(c("cli_unknown_flag",`Unknown flag -${a}.`,`Run \`${t.slug} ${n.name} --help\` for the flags this command accepts.`,`-${a}`));continue}if(u.kind!=="boolean"){d.push(c("cli_short_flag_needs_value",`-${a} takes a value and cannot be bundled.`,`Write it on its own: --${u.name} <${u.placeholder??"value"}>.`,`-${a}`));continue}l.set(u.name,!0)}continue}f.push(r)}let v=new R(l,o);if(v.bool("help"))return{kind:"help",command:n};if(v.bool("version"))return{kind:"version"};let N=n.args.some((s)=>s.variadic===!0),F=n.args.filter((s)=>s.required);if(d.length>0)throw y(d);else if(f.length<F.length){let s=F[f.length];d.push(c("cli_missing_argument",`${n.name} needs ${s===void 0?"another argument":`a ${s.name}`}.`,`Usage: ${t.slug} ${n.name} ${n.args.map((r)=>`<${r.name}${r.variadic===!0?"...":""}>`).join(" ")}`))}else if(!N&&f.length>n.args.length){let s=f.slice(n.args.length);d.push(c("cli_unexpected_argument",`${n.name} takes ${n.args.length} argument(s), got ${f.length}.`,n.unexpectedArgHint??`Unexpected: ${s.join(" ")}. Quote a value containing spaces.`))}if(d.length>0)throw y(d);return{kind:"command",parsed:{command:n,positionals:f,flags:v}}}
3
- export{ot,is};
2
+ import{A,n}from"./index-ss77hvwy.js";import{gn,st,TA,cn,is}from"./index-zj87j4j2.js";class it extends n{static ERROR_NAME="UsageError"}function S(e,i){let t=Array.from({length:i.length+1},(o,g)=>g);for(let o=1;o<=e.length;o+=1){let g=[o];for(let l=1;l<=i.length;l+=1){let f=(t[l-1]??0)+(e[o-1]===i[l-1]?0:1),d=(g[l-1]??0)+1,_=(t[l]??0)+1;g.push(Math.min(f,d,_))}t=g}return t[i.length]??Math.max(e.length,i.length)}function M(e,i){let t,o=Number.POSITIVE_INFINITY;for(let g of i){let l=S(e,g);if(l<o)o=l,t=g}return t!==void 0&&o<=Math.max(2,Math.floor(e.length/3))?t:void 0}class R{#e;#t;constructor(e,i){this.#e=e,this.#t=i}#n(e,i){let t=this.#t.get(e);if(t===void 0)throw new it({code:"cli_flag_not_declared",message:`No flag "${e}" is declared for this command.`,hint:"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader."});if(t.kind!==i)throw new it({code:"cli_flag_kind_mismatch",message:`Flag "${e}" is declared as ${t.kind} but was read as ${i}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(e)}str(e){let i=this.#n(e,"string");return typeof i==="string"?i:void 0}num(e){let i=this.#n(e,"number");return typeof i==="number"?i:void 0}bool(e){return this.#n(e,"boolean")===!0}has(e){return this.#e.has(e)}}function c(e,i,t,o){return o===void 0?{code:e,message:i,hint:t}:{code:e,message:i,hint:t,field:o}}function y(e){let i=e[0];return new it({code:"cli_usage",message:e.length===1&&i!==void 0?i.message:`${e.length} problems with the command line.`,hint:e.length===1&&i!==void 0?i.hint:"Each problem below names the flag and its fix.",...i?.field===void 0?{}:{field:i.field},details:e})}function D(e,i,t){let o=Number(i);if(i.trim()===""||!Number.isFinite(o))return c("cli_flag_not_a_number",`${t} expects a number, got ${JSON.stringify(i)}.`,`Pass a number, as in ${t} 50. The old parser silently used the default here, which made a typo look like it worked.`,t);if(e.integer===!0&&!Number.isInteger(o))return c("cli_flag_not_an_integer",`${t} expects a whole number, got ${i}.`,`Drop the fractional part: ${t} ${Math.trunc(o)}.`,t);if(e.min!==void 0&&o<e.min)return c("cli_flag_below_min",`${t} must be at least ${e.min}, got ${o}.`,`Pass ${e.min} or more.`,t);return o}function rs(e){let i=e[0];if(i===void 0)return{kind:"usage"};if(i.startsWith("-")){let s=new Set(gn.flatMap((a)=>a.short===void 0?[`--${a.name}`]:[`--${a.name}`,`-${a.short}`])),r=e.filter((a)=>!s.has(a));if(r.length>0)throw y([c("cli_no_command","No command given.",`Run \`${A.slug} --help\` for the command list. Commands are ${st.map((a)=>a.name).join(", ")}.`,r[0])]);if(e.includes("--version")||e.includes("-v"))return{kind:"version"};if(e.includes("--help")||e.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let t=TA(i);if(t===void 0){let s=M(i,st.map((r)=>r.name));throw y([c("cli_unknown_command",`Unknown command "${i}".`,s===void 0?`Run \`${A.slug} --help\` for the command list.`:`Did you mean "${s}"? Run \`${A.slug} --help\` for the full list.`,i)])}let o=new Map(cn(t).map((s)=>[s.name,s])),g=new Map(cn(t).filter((s)=>s.short!==void 0).map((s)=>[s.short,s])),l=new Map,f=[],d=[],_=!1,w=(s,r,a)=>{if(r===""){d.push(c("cli_flag_empty_value",`${a} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",a));return}if(s.kind==="number"){let u=D(s,r,a);if(typeof u==="number")l.set(s.name,u);else d.push(u);return}l.set(s.name,r)};for(let s=1;s<e.length;s+=1){let r=e[s];if(r===void 0)continue;if(_){f.push(r);continue}if(r==="--"){_=!0;continue}if(r.startsWith("--")){let a=r.slice(2),u=a.indexOf("="),m=u===-1?a:a.slice(0,u),h=o.get(m);if(h===void 0){let k=is(m,t.name),x=M(m,[...o.keys()]);d.push(c(k.length>0?"cli_flag_wrong_command":"cli_unknown_flag",k.length>0?`${t.name} does not accept --${m}.`:`Unknown flag --${m}.`,k.length>0?`--${m} is accepted by: ${k.join(", ")}.`:x===void 0?`Run \`${A.slug} ${t.name} --help\` for the flags this command accepts.`:`Did you mean --${x}?`,`--${m}`));continue}let p=`--${m}`;if(h.kind==="boolean"){if(u!==-1){d.push(c("cli_flag_takes_no_value",`${p} is a switch and takes no value.`,`Drop the "=${a.slice(u+1)}" — pass ${p} on its own.`,p));continue}l.set(h.name,!0);continue}if(u!==-1){w(h,a.slice(u+1),p);continue}let b=e[s+1];if(h.bare!==void 0&&(b===void 0||b.startsWith("-"))){l.set(h.name,h.bare);continue}if(b===void 0){d.push(c("cli_flag_needs_value",`${p} needs a value.`,`Pass one, as in ${p} <${h.placeholder??"value"}>.`,p));continue}w(h,b,p),s+=1;continue}if(r.startsWith("-")&&r.length>1){for(let a of[...r.slice(1)]){let u=g.get(a);if(u===void 0){d.push(c("cli_unknown_flag",`Unknown flag -${a}.`,`Run \`${A.slug} ${t.name} --help\` for the flags this command accepts.`,`-${a}`));continue}if(u.kind!=="boolean"){d.push(c("cli_short_flag_needs_value",`-${a} takes a value and cannot be bundled.`,`Write it on its own: --${u.name} <${u.placeholder??"value"}>.`,`-${a}`));continue}l.set(u.name,!0)}continue}f.push(r)}let v=new R(l,o);if(v.bool("help"))return{kind:"help",command:t};if(v.bool("version"))return{kind:"version"};let N=t.args.some((s)=>s.variadic===!0),F=t.args.filter((s)=>s.required);if(d.length>0)throw y(d);else if(f.length<F.length){let s=F[f.length];d.push(c("cli_missing_argument",`${t.name} needs ${s===void 0?"another argument":`a ${s.name}`}.`,`Usage: ${A.slug} ${t.name} ${t.args.map((r)=>`<${r.name}${r.variadic===!0?"...":""}>`).join(" ")}`))}else if(!N&&f.length>t.args.length){let s=f.slice(t.args.length);d.push(c("cli_unexpected_argument",`${t.name} takes ${t.args.length} argument(s), got ${f.length}.`,t.unexpectedArgHint??`Unexpected: ${s.join(" ")}. Quote a value containing spaces.`))}if(d.length>0)throw y(d);return{kind:"command",parsed:{command:t,positionals:f,flags:v}}}
3
+ export{it,rs};
4
4
 
5
- //# debugId=FC827B207626862064756E2164756E21
6
- //# sourceMappingURL=index-jff5q27j.js.map
5
+ //# debugId=B1158EA43F6C46A664756E2164756E21
6
+ //# sourceMappingURL=index-t9bnt6a1.js.map
@@ -5,6 +5,6 @@
5
5
  "/**\n * The argument parser. Pure — argv in, a decision out, no I/O and no `process`.\n *\n * It replaces a parser that failed silently in four distinct ways, each of which is now a test:\n *\n * - **A value beginning with `-` was swallowed.** The old rule was \"consume the next token unless\n * it looks like a flag\", so `--input \"-5 degrees\"` set `input` to boolean `true`, the caller's\n * `typeof input === \"string\"` check failed, and the process opened an interactive session instead\n * of running the one turn it was asked for. The rule here has no such hole: whether a flag\n * consumes the next token is a property of the *flag*, declared in `commands.ts`, never a guess\n * about the value.\n * - **Unknown flags were ignored.** `--sesion local:x` ran against the default session silently.\n * - **A non-numeric `--limit` fell back to the default.**\n * - **`--help` with no command exited 1**, reporting failure for the one thing that had succeeded.\n *\n * Every problem found is collected rather than thrown on sight, so a line with two mistakes reports\n * both. `HarnessError.details` already renders that shape.\n */\n\nimport { BRAND, type ErrorDetail, HarnessError } from \"@dispach/core\"\nimport { COMMANDS, commandsAccepting, findCommand, flagsFor, GLOBAL_FLAGS } from \"#lib/commands\"\nimport type { FlagSpec, FlagValue, FlagValues, ParseResult } from \"#lib/schema\"\n\n/** Anything wrong with the command line itself. Distinct from anything wrong with a manifest. */\nexport class UsageError extends HarnessError {\n static override readonly ERROR_NAME = \"UsageError\"\n}\n\n// ─── nearest match ───────────────────────────────────────────────────────────────────────\n\nfunction distance(a: string, b: string): number {\n // Two rows rather than a full matrix; the strings here are flag names.\n let previous = Array.from({ length: b.length + 1 }, (_, i) => i)\n for (let i = 1; i <= a.length; i += 1) {\n const current = [i]\n for (let j = 1; j <= b.length; j += 1) {\n const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1)\n const insertion = (current[j - 1] ?? 0) + 1\n const deletion = (previous[j] ?? 0) + 1\n current.push(Math.min(substitution, insertion, deletion))\n }\n previous = current\n }\n return previous[b.length] ?? Math.max(a.length, b.length)\n}\n\nfunction nearest(word: string, candidates: readonly string[]): string | undefined {\n let best: string | undefined\n let bestScore = Number.POSITIVE_INFINITY\n for (const candidate of candidates) {\n const score = distance(word, candidate)\n if (score < bestScore) {\n bestScore = score\n best = candidate\n }\n }\n // A suggestion has to be plausible. Beyond a third of the word it is noise, and noise in an\n // error message is worse than no suggestion at all.\n return best !== undefined && bestScore <= Math.max(2, Math.floor(word.length / 3))\n ? best\n : undefined\n}\n\n// ─── flag values ─────────────────────────────────────────────────────────────────────────\n\nclass Values implements FlagValues {\n readonly #values: ReadonlyMap<string, FlagValue>\n readonly #specs: ReadonlyMap<string, FlagSpec>\n\n constructor(values: ReadonlyMap<string, FlagValue>, specs: ReadonlyMap<string, FlagSpec>) {\n this.#values = values\n this.#specs = specs\n }\n\n #expect(name: string, kind: FlagSpec[\"kind\"]): FlagValue | undefined {\n const spec = this.#specs.get(name)\n if (spec === undefined) {\n throw new UsageError({\n code: \"cli_flag_not_declared\",\n message: `No flag \"${name}\" is declared for this command.`,\n hint: \"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader.\",\n })\n }\n if (spec.kind !== kind) {\n throw new UsageError({\n code: \"cli_flag_kind_mismatch\",\n message: `Flag \"${name}\" is declared as ${spec.kind} but was read as ${kind}.`,\n hint: \"This is a bug in the CLI. The reader and lib/commands.ts disagree.\",\n })\n }\n return this.#values.get(name)\n }\n\n str(name: string): string | undefined {\n const value = this.#expect(name, \"string\")\n return typeof value === \"string\" ? value : undefined\n }\n\n num(name: string): number | undefined {\n const value = this.#expect(name, \"number\")\n return typeof value === \"number\" ? value : undefined\n }\n\n bool(name: string): boolean {\n return this.#expect(name, \"boolean\") === true\n }\n\n has(name: string): boolean {\n return this.#values.has(name)\n }\n}\n\n// ─── parse ───────────────────────────────────────────────────────────────────────────────\n\nfunction detail(code: string, message: string, hint: string, field?: string): ErrorDetail {\n return field === undefined ? { code, message, hint } : { code, message, hint, field }\n}\n\nfunction usage(details: ErrorDetail[]): UsageError {\n const first = details[0]\n return new UsageError({\n code: \"cli_usage\",\n message:\n details.length === 1 && first !== undefined\n ? first.message\n : `${details.length} problems with the command line.`,\n hint:\n details.length === 1 && first !== undefined\n ? first.hint\n : \"Each problem below names the flag and its fix.\",\n ...(first?.field === undefined ? {} : { field: first.field }),\n details,\n })\n}\n\nfunction readNumber(spec: FlagSpec, raw: string, written: string): number | ErrorDetail {\n const value = Number(raw)\n if (raw.trim() === \"\" || !Number.isFinite(value)) {\n return detail(\n \"cli_flag_not_a_number\",\n `${written} expects a number, got ${JSON.stringify(raw)}.`,\n `Pass a number, as in ${written} 50. The old parser silently used the default here, which made a typo look like it worked.`,\n written,\n )\n }\n if (spec.integer === true && !Number.isInteger(value)) {\n return detail(\n \"cli_flag_not_an_integer\",\n `${written} expects a whole number, got ${raw}.`,\n `Drop the fractional part: ${written} ${Math.trunc(value)}.`,\n written,\n )\n }\n if (spec.min !== undefined && value < spec.min) {\n return detail(\n \"cli_flag_below_min\",\n `${written} must be at least ${spec.min}, got ${value}.`,\n `Pass ${spec.min} or more.`,\n written,\n )\n }\n return value\n}\n\n/**\n * `argv` is everything after the program name.\n *\n * The command comes first, before any flag, as with git and docker. That ordering is what makes the\n * parse unambiguous: flag semantics depend on the command's spec, so the command has to be known\n * before a single flag can be interpreted.\n */\nexport function parse(argv: readonly string[]): ParseResult {\n const head = argv[0]\n\n if (head === undefined) return { kind: \"usage\" }\n\n if (head.startsWith(\"-\")) {\n // No command. Only the global flags can appear here, and only two of them do anything.\n const globals = new Set(\n GLOBAL_FLAGS.flatMap((flag) =>\n flag.short === undefined\n ? [`--${flag.name}`]\n : [`--${flag.name}`, `-${flag.short}`],\n ),\n )\n const unknown = argv.filter((token) => !globals.has(token))\n if (unknown.length > 0) {\n throw usage([\n detail(\n \"cli_no_command\",\n \"No command given.\",\n `Run \\`${BRAND.slug} --help\\` for the command list. Commands are ${COMMANDS.map((c) => c.name).join(\", \")}.`,\n unknown[0],\n ),\n ])\n }\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) return { kind: \"version\" }\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { kind: \"help\", command: undefined }\n }\n return { kind: \"usage\" }\n }\n\n const command = findCommand(head)\n if (command === undefined) {\n const suggestion = nearest(\n head,\n COMMANDS.map((c) => c.name),\n )\n throw usage([\n detail(\n \"cli_unknown_command\",\n `Unknown command \"${head}\".`,\n suggestion === undefined\n ? `Run \\`${BRAND.slug} --help\\` for the command list.`\n : `Did you mean \"${suggestion}\"? Run \\`${BRAND.slug} --help\\` for the full list.`,\n head,\n ),\n ])\n }\n\n const specs = new Map(flagsFor(command).map((flag) => [flag.name, flag]))\n const shorts = new Map(\n flagsFor(command)\n .filter((flag) => flag.short !== undefined)\n .map((flag) => [flag.short as string, flag]),\n )\n\n const values = new Map<string, FlagValue>()\n const positionals: string[] = []\n const errors: ErrorDetail[] = []\n let terminated = false\n\n const setValue = (spec: FlagSpec, raw: string, written: string): void => {\n if (raw === \"\") {\n errors.push(\n detail(\n \"cli_flag_empty_value\",\n `${written} was given an empty value.`,\n \"Pass a value, or drop the flag entirely to use the default.\",\n written,\n ),\n )\n return\n }\n if (spec.kind === \"number\") {\n const result = readNumber(spec, raw, written)\n if (typeof result === \"number\") values.set(spec.name, result)\n else errors.push(result)\n return\n }\n values.set(spec.name, raw)\n }\n\n for (let i = 1; i < argv.length; i += 1) {\n const token = argv[i]\n if (token === undefined) continue\n\n if (terminated) {\n positionals.push(token)\n continue\n }\n if (token === \"--\") {\n terminated = true\n continue\n }\n\n if (token.startsWith(\"--\")) {\n const body = token.slice(2)\n const eq = body.indexOf(\"=\")\n const name = eq === -1 ? body : body.slice(0, eq)\n const spec = specs.get(name)\n\n if (spec === undefined) {\n const elsewhere = commandsAccepting(name, command.name)\n const suggestion = nearest(name, [...specs.keys()])\n errors.push(\n detail(\n elsewhere.length > 0 ? \"cli_flag_wrong_command\" : \"cli_unknown_flag\",\n elsewhere.length > 0\n ? `${command.name} does not accept --${name}.`\n : `Unknown flag --${name}.`,\n elsewhere.length > 0\n ? `--${name} is accepted by: ${elsewhere.join(\", \")}.`\n : suggestion === undefined\n ? `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`\n : `Did you mean --${suggestion}?`,\n `--${name}`,\n ),\n )\n continue\n }\n\n const written = `--${name}`\n\n if (spec.kind === \"boolean\") {\n if (eq !== -1) {\n errors.push(\n detail(\n \"cli_flag_takes_no_value\",\n `${written} is a switch and takes no value.`,\n `Drop the \"=${body.slice(eq + 1)}\" — pass ${written} on its own.`,\n written,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n continue\n }\n\n if (eq !== -1) {\n setValue(spec, body.slice(eq + 1), written)\n continue\n }\n\n // Consume the next token unconditionally. This is the fix for the swallowed-value bug:\n // whether a token is a value is decided by the spec, never by whether it starts with a\n // dash. `--input -5` means the text \"-5\".\n const next = argv[i + 1]\n // Unless the spec declares a bare form, in which case a missing token or one starting with a\n // dash means the flag was written on its own. Opt-in per flag, because the inversion is only\n // safe for a field whose values cannot start with a dash — see `FlagSpec.bare`.\n if (spec.bare !== undefined && (next === undefined || next.startsWith(\"-\"))) {\n values.set(spec.name, spec.bare)\n continue\n }\n if (next === undefined) {\n errors.push(\n detail(\n \"cli_flag_needs_value\",\n `${written} needs a value.`,\n `Pass one, as in ${written} <${spec.placeholder ?? \"value\"}>.`,\n written,\n ),\n )\n continue\n }\n setValue(spec, next, written)\n i += 1\n continue\n }\n\n if (token.startsWith(\"-\") && token.length > 1) {\n // Short flags cluster only when every letter is a switch. Anything else is ambiguous\n // about which flag the trailing text belongs to, and guessing is how values get lost.\n for (const letter of [...token.slice(1)]) {\n const spec = shorts.get(letter)\n if (spec === undefined) {\n errors.push(\n detail(\n \"cli_unknown_flag\",\n `Unknown flag -${letter}.`,\n `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`,\n `-${letter}`,\n ),\n )\n continue\n }\n if (spec.kind !== \"boolean\") {\n errors.push(\n detail(\n \"cli_short_flag_needs_value\",\n `-${letter} takes a value and cannot be bundled.`,\n `Write it on its own: --${spec.name} <${spec.placeholder ?? \"value\"}>.`,\n `-${letter}`,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n }\n continue\n }\n\n positionals.push(token)\n }\n\n // Help wins over argument checking. Asking how to use a command you invoked wrongly is the most\n // likely next thing you want, and refusing to answer would be perverse.\n const flags = new Values(values, specs)\n if (flags.bool(\"help\")) return { kind: \"help\", command }\n if (flags.bool(\"version\")) return { kind: \"version\" }\n\n // Positional counting is only meaningful once every flag parsed. An unknown flag cannot consume\n // its value — the kind is unknown — so the orphan lands here as a positional, and reporting\n // \"takes 1 argument, got 2\" alongside the real mistake sends the reader looking in the wrong\n // place. Report causes, never their consequences.\n const variadic = command.args.some((arg) => arg.variadic === true)\n const required = command.args.filter((arg) => arg.required)\n if (errors.length > 0) {\n throw usage(errors)\n } else if (positionals.length < required.length) {\n const missing = required[positionals.length]\n errors.push(\n detail(\n \"cli_missing_argument\",\n `${command.name} needs ${missing === undefined ? \"another argument\" : `a ${missing.name}`}.`,\n `Usage: ${BRAND.slug} ${command.name} ${command.args.map((a) => `<${a.name}${a.variadic === true ? \"...\" : \"\"}>`).join(\" \")}`,\n ),\n )\n } else if (!variadic && positionals.length > command.args.length) {\n const extra = positionals.slice(command.args.length)\n errors.push(\n detail(\n \"cli_unexpected_argument\",\n `${command.name} takes ${command.args.length} argument(s), got ${positionals.length}.`,\n command.unexpectedArgHint ??\n `Unexpected: ${extra.join(\" \")}. Quote a value containing spaces.`,\n ),\n )\n }\n\n if (errors.length > 0) throw usage(errors)\n\n return { kind: \"command\", parsed: { command, positionals, flags } }\n}\n"
6
6
  ],
7
7
  "mappings": ";qFAwBO,MAAM,WAAmB,CAAa,QAChB,WAAa,YAC1C,CAIA,SAAS,CAAQ,CAAC,EAAW,EAAmB,CAE5C,IAAI,EAAW,MAAM,KAAK,CAAE,OAAQ,EAAE,OAAS,CAAE,EAAG,CAAC,EAAG,IAAM,CAAC,EAC/D,QAAS,EAAI,EAAG,GAAK,EAAE,OAAQ,GAAK,EAAG,CACnC,IAAM,EAAU,CAAC,CAAC,EAClB,QAAS,EAAI,EAAG,GAAK,EAAE,OAAQ,GAAK,EAAG,CACnC,IAAM,GAAgB,EAAS,EAAI,IAAM,IAAM,EAAE,EAAI,KAAO,EAAE,EAAI,GAAK,EAAI,GACrE,GAAa,EAAQ,EAAI,IAAM,GAAK,EACpC,GAAY,EAAS,IAAM,GAAK,EACtC,EAAQ,KAAK,KAAK,IAAI,EAAc,EAAW,CAAQ,CAAC,EAE5D,EAAW,EAEf,OAAO,EAAS,EAAE,SAAW,KAAK,IAAI,EAAE,OAAQ,EAAE,MAAM,EAG5D,SAAS,CAAO,CAAC,EAAc,EAAmD,CAC9E,IAAI,EACA,EAAY,OAAO,kBACvB,QAAW,KAAa,EAAY,CAChC,IAAM,EAAQ,EAAS,EAAM,CAAS,EACtC,GAAI,EAAQ,EACR,EAAY,EACZ,EAAO,EAKf,OAAO,IAAS,QAAa,GAAa,KAAK,IAAI,EAAG,KAAK,MAAM,EAAK,OAAS,CAAC,CAA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,CACJ,EAGJ,GAAI,EAAO,OAAS,EAAG,MAAM,EAAM,CAAM,EAEzC,MAAO,CAAE,KAAM,UAAW,OAAQ,CAAE,UAAS,cAAa,OAAM,CAAE",
8
- "debugId": "FC827B207626862064756E2164756E21",
8
+ "debugId": "B1158EA43F6C46A664756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{n,Re,lA,IA}from"./index-ss77hvwy.js";import{Gt,on}from"./index-ncb840sk.js";import{$n,Xn,Ve}from"./index-4g4smpkk.js";import{p,L,D,w}from"./index-s9ybp2r1.js";import{readFileSync as u}from"node:fs";function WA(e){if(e===void 0||e===null)return"(not set)";if(typeof e==="string")return e===""?'""':e;if(typeof e==="boolean"||typeof e==="number")return String(e);return JSON.stringify(e)}function y(e){return e.split(/[.[]/)[0]??e}function vi(e,t){let o=[`${t}`,""],s=new Map;for(let i of e){let l=y(i.setting.path);s.set(l,[...s.get(l)??[],i])}let r=!0;for(let[i,l]of s){o.push(L(i,r)),r=!1;for(let a of l){let d=a.setting.agentListed?"":" · yours only",g=a.setting.via===void 0?"":` · set with \`${a.setting.via}\``,h=a.setting.confirm===void 0?"":" · asks first";o.push(p([{label:a.setting.path,value:WA(a.value)}]),w(`${a.setting.means}${d}${g}${h}`,4))}}return o.push("","A change takes effect the next time the agent starts. `yours only` marks a field the agent is","refused: what it may do is its to ask for, where it writes and who may reach it are yours."),o.join(`
3
+ `)}function Li(e,t){return[p([{label:e.path,value:WA(t)}]),w(e.means,4),...e.toAgent===void 0?[]:[w(`to the agent: ${e.toAgent}`,4)]].join(`
4
+ `)}function Pi(e,t){if(e.confirm===void 0)return;if(e.path==="tools.untrusted.onMutate"&&String(t).toLowerCase()!=="allow")return;return e.confirm}function Gi(e){let t=[p([{label:"set",value:`${e.path} = ${WA(e.after)}`},{label:"was",value:e.before===void 0?"(not set)":WA(e.before)},{label:"file",value:e.file}])];if(e.reflowed)t.push("",D("the block could not be edited in place, so the file was re-serialised — it is valid, and comments may have moved"));if(e.running!==void 0)t.push("",D(`this agent is running (pid ${e.running.pid}, ${e.running.mode}) and holds its settings for its lifetime — the change applies after ${e.restartHint}`));for(let o of e.pending)t.push(D(`${o.name} is not set — ${o.why}`)),t.push(D(`fill it in with \`config env <agent> ${o.name}\``));return t.join(`
5
+ `)}function Fi(){return IA.filter((e)=>e.via===void 0&&!/[[<]/.test(e.path)).map((e)=>e.path)}function zA(e){if(typeof e!=="object"||e===null)return[];let t=e,o=[],s=(a,d)=>{if(typeof a==="string"&&a!=="")o.push({name:a,why:d})},r=f(t.model);for(let a of["main","selector","compactor"]){let d=f(r?.[a]);s(d?.apiKeyEnv,"the manifest will not load until it is set")}if(Array.isArray(t.channels))for(let a of t.channels){let d=f(a);if(d===void 0||d.enabled===!1)continue;s(d.tokenEnv,`the ${String(d.id??d.type??"channel")} channel is read at boot, so the agent will not start until it is set`)}let i=f(t.server);if(i?.enabled===!0)s(i.tokenEnv,"the HTTP API would accept unauthenticated requests. This does not stop the agent starting");let l=f(f(t.tools)?.providers);for(let[a,d]of Object.entries(l??{}))s(f(d)?.apiKeyEnv,`the ${a} provider's tools will not work until it is set`);return o}function f(e){if(typeof e!=="object"||e===null||Array.isArray(e))return;return e}function qo(e,t){return e.filter((o)=>t[o.name]===void 0||t[o.name]==="")}function c(e,t){let o=[],s=new Map;for(let r of e){if(r.setting.via!==void 0||/[[<]/.test(r.setting.path))continue;let i=r.setting.path.split(".")[0]??r.setting.path;s.set(i,[...s.get(i)??[],r])}for(let[r,i]of s){o.push({kind:"heading",label:r});for(let l of i)o.push({kind:"setting",setting:l.setting,value:l.value})}if(t.channels.length>0){o.push({kind:"heading",label:"who may reach it"});for(let r of t.channels)o.push({kind:"allow",channelId:r.id,channelType:r.type,handles:r.allowFrom})}if(t.secrets.length>0){o.push({kind:"heading",label:"secrets — written to the .env, never shown"});for(let r of t.secrets)o.push({kind:"secret",name:r.name,why:r.why,present:t.present(r.name)})}return o}function Vo(e){let t=u(e,"utf8");return IA.map((o)=>{if(o.path==="channels[].allowFrom"){let s=Re(t,["channels"]);if(!Array.isArray(s))return{setting:o,value:void 0};let r={};for(let i of s){if(typeof i!=="object"||i===null)continue;let l=i;if(typeof l.id!=="string")continue;r[l.id]=l.allowFrom??[]}return{setting:o,value:Object.keys(r).length===0?void 0:r}}if(o.path==="tools.providers.<id>.writeRoots"){let s=Re(t,["tools","providers"]);if(typeof s!=="object"||s===null||Array.isArray(s))return{setting:o,value:void 0};let r={};for(let[i,l]of Object.entries(s)){if(typeof l!=="object"||l===null)continue;let a=l.writeRoots;if(a!==void 0)r[i]=a}return{setting:o,value:Object.keys(r).length===0?void 0:r}}return{setting:o,value:Re(t,o.path.split("."))}})}function BA(e){let t=u(e,"utf8"),o=lA(t),s=Gt(e),r=Re(t,["channels"]);return c(Vo(e),{channels:(Array.isArray(r)?r:[]).filter((i)=>typeof i==="object"&&i!==null&&!Array.isArray(i)).map((i)=>({id:String(i.id??""),type:String(i.type??""),allowFrom:Array.isArray(i.allowFrom)?i.allowFrom.map(String):[]})).filter((i)=>i.id!==""),secrets:zA(o),present:(i)=>on(s,i)})}async function Nn(e,t,o){switch(t.kind){case"setting":{if(o.trim()==="")throw new n({code:"cli_config_value_missing",message:`No value given for ${t.setting.path}.`,hint:'A bare word, a number, a list as ["a", "b"], or a map as {k: v}.',field:"value"});return(await $n(e,t.setting.path,o)).note}case"allow":{let s=o.trim()===""?[]:o.trim().split(/\s+/);return(await Xn(e,t.channelId,s)).note}case"secret":return Ve(e,t.name,o).note;case"heading":return""}}
6
+ export{WA,vi,Li,Pi,Gi,Fi,zA,qo,Vo,BA,Nn};
7
+
8
+ //# debugId=EE5B81C64E57903164756E2164756E21
9
+ //# sourceMappingURL=index-w2ss9hn5.js.map
@@ -6,6 +6,6 @@
6
6
  "/**\n * What `config` prints, and what a person has to confirm. Pure, so both are asserted as strings.\n *\n * The policy lives here rather than in the command for the same reason `remove-plan.ts` does: this\n * surface can disable the write gate and open a bind address to the network, and \"which edits need a\n * confirmation\" is exactly the thing that must be checkable without performing one.\n *\n * ## Why the person's policy is not the agent's\n *\n * Decision 11.29: *enabling a capability answers \"what may I do\"; a write root, an allowlist and a\n * bind address answer \"who and where\", and those are the person's by definition.* The agent's floor\n * exists because an agent that could widen its own inbound gate could be **talked into** widening it\n * by the very message it is reading — `config_set` sits in `policy.allow` on a real manifest, so the\n * write gate would not stop that. A person typing at a terminal is not that threat, and refusing them\n * is what left the fields reserved for them with the worst ergonomics in the system.\n *\n * So nothing here is floored. Two edits are confirmed, both from decision 4.50, and only those two:\n * a confirmation that fires on `limits.maxSteps` is one nobody reads by the time it fires on the\n * write gate.\n */\n\nimport { SETTINGS, type Setting } from \"@dispach/core\"\nimport type { EditorRow } from \"#lib/config-editor\"\nimport { bullet, indent, keyValue, section } from \"#lib/render\"\n\n/** A setting with whatever the manifest currently has in it. */\nexport interface SettingValue {\n readonly setting: Setting\n /** Plain JS, or `undefined` when the field is absent from the file. */\n readonly value: unknown\n}\n\n/**\n * How a value appears in a listing.\n *\n * Lists and maps as JSON rather than flattened YAML, which is the lesson from `config_read`: collapsing\n * a block's newlines rendered `[type: telegram id: tg tokenEnv: …]`, one run-on string where the reader\n * needed fields. A sequence of maps went through `String(entry)` and wrote `[object Object]` — the same\n * defect, three times, in three renderers.\n */\nexport function showValue(value: unknown): string {\n if (value === undefined || value === null) return \"(not set)\"\n if (typeof value === \"string\") return value === \"\" ? '\"\"' : value\n if (typeof value === \"boolean\" || typeof value === \"number\") return String(value)\n return JSON.stringify(value)\n}\n\n/** The top-level key a path belongs under, for grouping. */\nfunction group(path: string): string {\n return path.split(/[.[]/)[0] ?? path\n}\n\n/**\n * The whole catalogue, grouped by the block it lives in, each row carrying who owns it.\n *\n * Grouped by manifest block rather than by owner, because the question a reader arrives with is \"what\n * can I change about tools\" far more often than \"what is mine versus the agent's\" — and the ownership\n * still shows on every row that is not the default.\n */\nexport function renderSettings(rows: readonly SettingValue[], file: string): string {\n const out: string[] = [`${file}`, \"\"]\n\n // Collected by block rather than emitted in catalogue order. Printing a heading whenever the block\n // *changes* looks equivalent and is not: the person-only rows sit at the end of the catalogue, so a\n // real listing came out with `server` and `tools` as two sections each, reading as though there\n // were two of them. Grouping here rather than reordering the catalogue keeps the render correct\n // whatever order the rows arrive in, which is the property worth having.\n const blocks = new Map<string, SettingValue[]>()\n for (const row of rows) {\n const block = group(row.setting.path)\n blocks.set(block, [...(blocks.get(block) ?? []), row])\n }\n\n let first = true\n for (const [block, members] of blocks) {\n out.push(section(block, first))\n first = false\n for (const row of members) {\n const owner = row.setting.agentListed ? \"\" : \" · yours only\"\n const via = row.setting.via === undefined ? \"\" : ` · set with \\`${row.setting.via}\\``\n const guard = row.setting.confirm === undefined ? \"\" : \" · asks first\"\n out.push(\n keyValue([{ label: row.setting.path, value: showValue(row.value) }]),\n indent(`${row.setting.means}${owner}${via}${guard}`, 4),\n )\n }\n }\n out.push(\n \"\",\n \"A change takes effect the next time the agent starts. `yours only` marks a field the agent is\",\n \"refused: what it may do is its to ask for, where it writes and who may reach it are yours.\",\n )\n return out.join(\"\\n\")\n}\n\n/** One field, for `config get`. */\nexport function renderOne(setting: Setting, value: unknown): string {\n return [\n keyValue([{ label: setting.path, value: showValue(value) }]),\n indent(setting.means, 4),\n ...(setting.toAgent === undefined ? [] : [indent(`to the agent: ${setting.toAgent}`, 4)]),\n ].join(\"\\n\")\n}\n\n/**\n * What a confirmation says before a guard-weakening edit, or `undefined` when none is needed.\n *\n * The value matters, not only the path: `onMutate: confirm` tightens the gate and `allow` removes it,\n * and asking about both would teach people to agree to the one that matters. Same asymmetry the agent's\n * floor has, where `confirm` is settable and `allow` is refused.\n */\nexport function confirmationFor(setting: Setting, value: unknown): string | undefined {\n if (setting.confirm === undefined) return undefined\n if (setting.path === \"tools.untrusted.onMutate\" && String(value).toLowerCase() !== \"allow\") {\n return undefined\n }\n return setting.confirm\n}\n\n/**\n * The report after a successful set.\n *\n * `reflowed` is surfaced rather than swallowed: the file is correct and its comments have moved, which\n * is a surprise better heard from the command than found later in a diff.\n */\nexport function renderChange(input: {\n readonly path: string\n readonly before: unknown\n readonly after: unknown\n readonly file: string\n readonly reflowed: boolean\n /** A live process holding this agent, if there is one. */\n readonly running?: { readonly pid: number; readonly mode: string }\n /**\n * Env variables this edit has *newly* made load-bearing and that are not set.\n *\n * Newly, not \"all of them\": a note about tokens printed on every `limits.maxSteps` change is a note\n * nobody reads by the time it matters — the same reasoning that makes `config_set` report a pending\n * secret only for a write that could have introduced one. What is already missing is `config list`'s\n * to report, because that is the command whose job is the overview.\n */\n readonly pending: readonly EnvNeed[]\n readonly restartHint: string\n}): string {\n const out: string[] = [\n keyValue([\n { label: \"set\", value: `${input.path} = ${showValue(input.after)}` },\n {\n label: \"was\",\n value: input.before === undefined ? \"(not set)\" : showValue(input.before),\n },\n { label: \"file\", value: input.file },\n ]),\n ]\n if (input.reflowed) {\n out.push(\n \"\",\n bullet(\n \"the block could not be edited in place, so the file was re-serialised — it is valid, and comments may have moved\",\n ),\n )\n }\n if (input.running !== undefined) {\n // Never a refusal. Fixing a misconfiguration while it is running and broken is the main use of\n // this command, so the state it would refuse in is the state somebody is trying to get out of.\n out.push(\n \"\",\n bullet(\n `this agent is running (pid ${input.running.pid}, ${input.running.mode}) and holds its settings for its lifetime — the change applies after ${input.restartHint}`,\n ),\n )\n }\n for (const need of input.pending) {\n out.push(bullet(`${need.name} is not set — ${need.why}`))\n out.push(bullet(`fill it in with \\`config env <agent> ${need.name}\\``))\n }\n return out.join(\"\\n\")\n}\n\n/** Every setting with a real dotted path, in catalogue order. `config set`'s accepted list. */\nexport function settablePaths(): readonly string[] {\n return SETTINGS.filter((entry) => entry.via === undefined && !/[[<]/.test(entry.path)).map(\n (entry) => entry.path,\n )\n}\n\n/** An env variable this manifest depends on, and what actually happens without it. */\nexport interface EnvNeed {\n readonly name: string\n /** The real consequence, which differs per source and is not interchangeable. */\n readonly why: string\n}\n\n/**\n * The env variables a manifest depends on, each with the consequence of it being unset.\n *\n * One message for all of them was wrong, and a live run showed it: the API token variable reported as\n * \"read at boot — the agent will refuse to start until it is filled in\", printed for an agent with\n * `server.enabled: false` that starts perfectly well. Three sources, three different outcomes:\n *\n * - `model.<role>.apiKeyEnv` — a **load failure**. `validateApiKeyEnv` refuses the manifest outright.\n * - an enabled channel's `tokenEnv` — a **boot failure**, because the factory reads it inside\n * `Runtime.create`. A channel with `enabled: false` is never constructed, so it needs nothing.\n * - `server.tokenEnv` — **no failure at all**. The API serves unauthenticated and the banner says so,\n * which is worth telling somebody and is not the same sentence as \"will not start\".\n * - a provider's `apiKeyEnv` — that provider's tools do not work; the agent runs.\n *\n * A disabled block contributes nothing. Claiming a dependency that does not exist is worse than\n * claiming none, because it is the kind of warning that teaches people to ignore this line.\n */\nexport function envNeeds(document: unknown): readonly EnvNeed[] {\n if (typeof document !== \"object\" || document === null) return []\n const doc = document as Record<string, unknown>\n const needs: EnvNeed[] = []\n const add = (name: unknown, why: string) => {\n if (typeof name === \"string\" && name !== \"\") needs.push({ name, why })\n }\n\n const model = asRecord(doc.model)\n for (const role of [\"main\", \"selector\", \"compactor\"]) {\n const config = asRecord(model?.[role])\n add(config?.apiKeyEnv, \"the manifest will not load until it is set\")\n }\n\n if (Array.isArray(doc.channels)) {\n for (const entry of doc.channels) {\n const channel = asRecord(entry)\n if (channel === undefined || channel.enabled === false) continue\n add(\n channel.tokenEnv,\n `the ${String(channel.id ?? channel.type ?? \"channel\")} channel is read at boot, so the agent will not start until it is set`,\n )\n }\n }\n\n const server = asRecord(doc.server)\n if (server?.enabled === true) {\n add(\n server.tokenEnv,\n \"the HTTP API would accept unauthenticated requests. This does not stop the agent starting\",\n )\n }\n\n const providers = asRecord(asRecord(doc.tools)?.providers)\n for (const [id, config] of Object.entries(providers ?? {})) {\n add(asRecord(config)?.apiKeyEnv, `the ${id} provider's tools will not work until it is set`)\n }\n\n return needs\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined\n return value as Record<string, unknown>\n}\n\n/** Those of `needs` the environment does not supply. */\nexport function unmet(\n needs: readonly EnvNeed[],\n env: Readonly<Record<string, string | undefined>>,\n): readonly EnvNeed[] {\n return needs.filter((need) => env[need.name] === undefined || env[need.name] === \"\")\n}\n\n/**\n * The editor's rows for a manifest: every setting, one `allowFrom` per channel, and every secret.\n *\n * Here rather than in the component because it is the whole shape of the surface and it is pure — what\n * appears, in what order, under which heading — and because both hosts build it the same way.\n *\n * The two catalogue rows that are not dotted paths are *replaced* by their expansions rather than shown\n * beside them: `channels[].allowFrom` becomes one row per declared channel, and\n * `tools.providers.<id>.writeRoots` is left as a listing-only row, because writing it means naming a\n * provider and the editor has no way to ask which. A row nobody can act on would be the dead end this\n * surface exists to remove, so it is not offered at all — `config list` still shows it.\n */\nexport function editorRows(\n settings: readonly SettingValue[],\n input: {\n readonly channels: readonly {\n readonly id: string\n readonly type: string\n readonly allowFrom: readonly string[]\n }[]\n readonly secrets: readonly EnvNeed[]\n readonly present: (name: string) => boolean\n },\n): readonly EditorRow[] {\n const out: EditorRow[] = []\n\n // Collected by block, not emitted when the block *changes* — the same distinction `renderSettings`\n // records above, which this renderer had never been given. The two are not equivalent: the\n // person-only rows sit at the end of the catalogue, so `server.host` and `server.tokenEnv` were\n // already a second `server` section here, and inserting any row between `server.port` and them\n // made it visible. `schedules` was that row. Grouping keeps the render correct whatever order the\n // catalogue arrives in, which is the property worth having and the reason not to fix it by\n // reordering the table.\n const blocks = new Map<string, SettingValue[]>()\n for (const row of settings) {\n if (row.setting.via !== undefined || /[[<]/.test(row.setting.path)) continue\n const key = row.setting.path.split(\".\")[0] ?? row.setting.path\n blocks.set(key, [...(blocks.get(key) ?? []), row])\n }\n for (const [label, members] of blocks) {\n out.push({ kind: \"heading\", label })\n for (const row of members) {\n out.push({ kind: \"setting\", setting: row.setting, value: row.value })\n }\n }\n\n if (input.channels.length > 0) {\n out.push({ kind: \"heading\", label: \"who may reach it\" })\n for (const channel of input.channels) {\n out.push({\n kind: \"allow\",\n channelId: channel.id,\n channelType: channel.type,\n handles: channel.allowFrom,\n })\n }\n }\n\n if (input.secrets.length > 0) {\n out.push({ kind: \"heading\", label: \"secrets — written to the .env, never shown\" })\n for (const need of input.secrets) {\n out.push({\n kind: \"secret\",\n name: need.name,\n why: need.why,\n present: input.present(need.name),\n })\n }\n }\n\n return out\n}\n"
7
7
  ],
8
8
  "mappings": ";sKAUA,uBAAS,gBC8BF,SAAS,EAAS,CAAC,EAAwB,CAC9C,GAAI,IAAU,QAAa,IAAU,KAAM,MAAO,YAClD,GAAI,OAAO,IAAU,SAAU,OAAO,IAAU,GAAK,KAAO,EAC5D,GAAI,OAAO,IAAU,WAAa,OAAO,IAAU,SAAU,OAAO,OAAO,CAAK,EAChF,OAAO,KAAK,UAAU,CAAK,EAI/B,SAAS,CAAK,CAAC,EAAsB,CACjC,OAAO,EAAK,MAAM,MAAM,EAAE,IAAM,EAU7B,SAAS,EAAc,CAAC,EAA+B,EAAsB,CAChF,IAAM,EAAgB,CAAC,GAAG,IAAQ,EAAE,EAO9B,EAAS,IAAI,IACnB,QAAW,KAAO,EAAM,CACpB,IAAM,EAAQ,EAAM,EAAI,QAAQ,IAAI,EACpC,EAAO,IAAI,EAAO,CAAC,GAAI,EAAO,IAAI,CAAK,GAAK,CAAC,EAAI,CAAG,CAAC,EAGzD,IAAI,EAAQ,GACZ,QAAY,EAAO,KAAY,EAAQ,CACnC,EAAI,KAAK,EAAQ,EAAO,CAAK,CAAC,EAC9B,EAAQ,GACR,QAAW,KAAO,EAAS,CACvB,IAAM,EAAQ,EAAI,QAAQ,YAAc,GAAK,iBACvC,EAAM,EAAI,QAAQ,MAAQ,OAAY,GAAK,kBAAkB,EAAI,QAAQ,QACzE,EAAQ,EAAI,QAAQ,UAAY,OAAY,GAAK,iBACvD,EAAI,KACA,EAAS,CAAC,CAAE,MAAO,EAAI,QAAQ,KAAM,MAAO,GAAU,EAAI,KAAK,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