dispach 0.1.0 → 0.1.2

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 (115) hide show
  1. package/README.md +131 -31
  2. package/dist/App-b1yrwrcq.js +11 -0
  3. package/dist/{App-dxqm39zx.js.map → App-b1yrwrcq.js.map} +1 -1
  4. package/dist/{ConfigEditor-7v5nebvy.js → ConfigEditor-n8hdw6r7.js} +4 -4
  5. package/dist/{ConfigEditor-7v5nebvy.js.map → ConfigEditor-n8hdw6r7.js.map} +1 -1
  6. package/dist/{KeyProbe-vjhmdpx6.js → KeyProbe-9jjeze5r.js} +3 -3
  7. package/dist/{KeyProbe-vjhmdpx6.js.map → KeyProbe-9jjeze5r.js.map} +1 -1
  8. package/dist/{Picker-jxaesaxy.js → Picker-hfeh1g6m.js} +3 -3
  9. package/dist/{Picker-jxaesaxy.js.map → Picker-hfeh1g6m.js.map} +1 -1
  10. package/dist/{SessionPicker-z2t0p4b5.js → SessionPicker-zyqkg4dn.js} +3 -3
  11. package/dist/{SessionPicker-z2t0p4b5.js.map → SessionPicker-zyqkg4dn.js.map} +1 -1
  12. package/dist/{SkillBrowser-yyf2gy0q.js → SkillBrowser-3qdp8080.js} +3 -3
  13. package/dist/{SkillBrowser-yyf2gy0q.js.map → SkillBrowser-3qdp8080.js.map} +1 -1
  14. package/dist/WizardApp-vzpbydy3.js +5 -0
  15. package/dist/{WizardApp-12ndxgqv.js.map → WizardApp-vzpbydy3.js.map} +1 -1
  16. package/dist/client.js +10 -10
  17. package/dist/client.js.map +5 -5
  18. package/dist/{config-yz0nz51b.js → config-g7za9x13.js} +13 -13
  19. package/dist/{config-yz0nz51b.js.map → config-g7za9x13.js.map} +1 -1
  20. package/dist/credential-npr6z8c8.js +19 -0
  21. package/dist/{credential-wgt4gvcz.js.map → credential-npr6z8c8.js.map} +2 -2
  22. package/dist/index-02dn6m2j.js +7 -0
  23. package/dist/{index-h2yds678.js.map → index-02dn6m2j.js.map} +1 -1
  24. package/dist/index-0d93hyfc.js +6 -0
  25. package/dist/{index-rqbtm761.js.map → index-0d93hyfc.js.map} +1 -1
  26. package/dist/index-1c5113t4.js +66 -0
  27. package/dist/index-1c5113t4.js.map +12 -0
  28. package/dist/{index-3nwfz9jq.js → index-258d8bzg.js} +10 -10
  29. package/dist/{index-3nwfz9jq.js.map → index-258d8bzg.js.map} +1 -1
  30. package/dist/{index-9d011p3q.js → index-3g3ny01d.js} +4 -4
  31. package/dist/{index-9d011p3q.js.map → index-3g3ny01d.js.map} +1 -1
  32. package/dist/{index-8bmhd2hj.js → index-4cf6v9nb.js} +4 -4
  33. package/dist/{index-8bmhd2hj.js.map → index-4cf6v9nb.js.map} +1 -1
  34. package/dist/{index-bwckzbf8.js → index-4z7axw4r.js} +4 -4
  35. package/dist/{index-bwckzbf8.js.map → index-4z7axw4r.js.map} +1 -1
  36. package/dist/{index-xgqzk5cq.js → index-6p999cx4.js} +6 -6
  37. package/dist/{index-xgqzk5cq.js.map → index-6p999cx4.js.map} +1 -1
  38. package/dist/index-6q4wf8e3.js +6 -0
  39. package/dist/{index-jym27m75.js.map → index-6q4wf8e3.js.map} +1 -1
  40. package/dist/{index-cx3vz7sf.js → index-9r0wyj6w.js} +4 -4
  41. package/dist/{index-cx3vz7sf.js.map → index-9r0wyj6w.js.map} +1 -1
  42. package/dist/{index-j97vttdt.js → index-ammv5st7.js} +6 -6
  43. package/dist/{index-j97vttdt.js.map → index-ammv5st7.js.map} +1 -1
  44. package/dist/{index-qc2vrq9z.js → index-cqqb6gaq.js} +5 -5
  45. package/dist/{index-qc2vrq9z.js.map → index-cqqb6gaq.js.map} +1 -1
  46. package/dist/{index-jk0def33.js → index-d4x6yvqh.js} +4 -4
  47. package/dist/{index-jk0def33.js.map → index-d4x6yvqh.js.map} +1 -1
  48. package/dist/index-fecm8xe7.js +77 -0
  49. package/dist/index-fecm8xe7.js.map +12 -0
  50. package/dist/{index-e8n70sgj.js → index-fex44816.js} +4 -4
  51. package/dist/{index-e8n70sgj.js.map → index-fex44816.js.map} +1 -1
  52. package/dist/{index-gbnc99j8.js → index-ff514z3y.js} +9 -9
  53. package/dist/{index-gbnc99j8.js.map → index-ff514z3y.js.map} +1 -1
  54. package/dist/{index-t1xvacym.js → index-gme2egyq.js} +4 -4
  55. package/dist/{index-t1xvacym.js.map → index-gme2egyq.js.map} +1 -1
  56. package/dist/{index-mrtb5y08.js → index-gz9x25tz.js} +4 -4
  57. package/dist/{index-mrtb5y08.js.map → index-gz9x25tz.js.map} +1 -1
  58. package/dist/{index-9nsfs0vy.js → index-h9mw7b9d.js} +4 -4
  59. package/dist/{index-9nsfs0vy.js.map → index-h9mw7b9d.js.map} +1 -1
  60. package/dist/{index-6b7qvh1x.js → index-hwpvhaza.js} +4 -4
  61. package/dist/{index-6b7qvh1x.js.map → index-hwpvhaza.js.map} +1 -1
  62. package/dist/{index-6z0yr17z.js → index-j55s3ehk.js} +7 -7
  63. package/dist/{index-6z0yr17z.js.map → index-j55s3ehk.js.map} +1 -1
  64. package/dist/{index-mgdgx22q.js → index-j7gyr5nx.js} +6 -6
  65. package/dist/{index-mgdgx22q.js.map → index-j7gyr5nx.js.map} +1 -1
  66. package/dist/{index-7da4fqcr.js → index-mtn0g9vc.js} +5 -5
  67. package/dist/{index-7da4fqcr.js.map → index-mtn0g9vc.js.map} +1 -1
  68. package/dist/{index-rqzg861g.js → index-qdbq8crg.js} +4 -4
  69. package/dist/{index-rqzg861g.js.map → index-qdbq8crg.js.map} +1 -1
  70. package/dist/{index-xqyms08r.js → index-s9mbq7h6.js} +4 -4
  71. package/dist/{index-xqyms08r.js.map → index-s9mbq7h6.js.map} +1 -1
  72. package/dist/{index-9f9pp2ef.js → index-tf71ap9v.js} +4 -4
  73. package/dist/{index-9f9pp2ef.js.map → index-tf71ap9v.js.map} +1 -1
  74. package/dist/index-ttwyrdjs.js +427 -0
  75. package/dist/index-ttwyrdjs.js.map +11 -0
  76. package/dist/{index-2cvtz0fy.js → index-tv4yv7d2.js} +228 -228
  77. package/dist/{index-2cvtz0fy.js.map → index-tv4yv7d2.js.map} +9 -9
  78. package/dist/{index-fvhg0xyd.js → index-ty24n0jh.js} +79 -79
  79. package/dist/{index-fvhg0xyd.js.map → index-ty24n0jh.js.map} +1 -1
  80. package/dist/index-v8e92nfw.js +6 -0
  81. package/dist/{index-b8zwg8a3.js.map → index-v8e92nfw.js.map} +1 -1
  82. package/dist/index-vgc3y3rm.js +6 -0
  83. package/dist/{index-my5cjx00.js.map → index-vgc3y3rm.js.map} +1 -1
  84. package/dist/index-whaw4b18.js +6 -0
  85. package/dist/index-whaw4b18.js.map +10 -0
  86. package/dist/index.js +202 -198
  87. package/dist/index.js.map +6 -6
  88. package/dist/lib/bootstrap.d.ts +13 -0
  89. package/dist/lib/bootstrap.d.ts.map +1 -1
  90. package/dist/lib/commands.d.ts.map +1 -1
  91. package/dist/lib/init-flow.d.ts +17 -4
  92. package/dist/lib/init-flow.d.ts.map +1 -1
  93. package/dist/lib/provision.d.ts.map +1 -1
  94. package/dist/serve.d.ts.map +1 -1
  95. package/dist/{web-w7r68df1.js → web-vkb16r62.js} +5 -5
  96. package/dist/{web-w7r68df1.js.map → web-vkb16r62.js.map} +1 -1
  97. package/dist/wire.js +10 -10
  98. package/dist/wire.js.map +4 -4
  99. package/package.json +2 -2
  100. package/dist/App-dxqm39zx.js +0 -11
  101. package/dist/WizardApp-12ndxgqv.js +0 -5
  102. package/dist/credential-wgt4gvcz.js +0 -19
  103. package/dist/index-9pj1ws0p.js +0 -77
  104. package/dist/index-9pj1ws0p.js.map +0 -12
  105. package/dist/index-b5wwtxzk.js +0 -66
  106. package/dist/index-b5wwtxzk.js.map +0 -12
  107. package/dist/index-b8zwg8a3.js +0 -6
  108. package/dist/index-bry9bzt3.js +0 -427
  109. package/dist/index-bry9bzt3.js.map +0 -11
  110. package/dist/index-h2yds678.js +0 -7
  111. package/dist/index-jym27m75.js +0 -6
  112. package/dist/index-my5cjx00.js +0 -6
  113. package/dist/index-rqbtm761.js +0 -6
  114. package/dist/index-yr25dnf5.js +0 -6
  115. package/dist/index-yr25dnf5.js.map +0 -10
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{o,u,yn,wn,bn,R}from"./index-jk0def33.js";import{G}from"./index-mrtb5y08.js";import{Box as T,Text as d}from"ink";import{jsx as m,jsxs as s}from"react/jsx-runtime";function qt({rows:e,index:t,chosen:c,window:n,width:l}){let{from:r,to:a}=R(e.length,t,n),b=new Set(c),g=e.reduce((i,p)=>p.kind==="item"?Math.max(i,p.label.length):i,0),M=yn(l,g);return s(T,{flexDirection:"column",children:[r>0?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",r," above"]}):null,e.slice(r,a).map((i,p)=>{let x=r+p;if(i.kind!=="item"){let f=i.kind==="source";return s(d,{wrap:"truncate",bold:f,color:f?o.accent:o.muted,children:[f?" ":" ",bn(i.label,l-(f?2:4))]},x)}let h=x===t,y=b.has(x),S=wn({name:i.label,meta:i.meta??"",description:i.description??""},M);return s(d,{wrap:"truncate",children:[m(d,{color:o.accent,children:h?u.pointer:" "}),m(d,{color:y?o.success:o.muted,children:y?u.checked:u.unchecked}),m(d,{bold:h,...y?{color:o.success}:{},children:S.name})," ",m(d,{color:o.muted,children:S.meta}),S.description===""?"":" ",m(d,{dimColor:!0,children:S.description})]},x)}),a<e.length?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-a," below"]}):null]})}function k(e,t,c){let n=e;for(let l=0;l<=t.length;l+=1){if(t[n.index]===!0)return n;let r=G(n,{kind:c?"down":"up"});if(r.index===n.index)return;n=r}return}function v(e,t,c,n){if(c.length===0)return e;return k(t,c,n)??k(t,c,!n)??e}function tt(e,t,c){switch(t.kind){case"move":{if(!c.includes(!0))return e;let n=G(e.cursor,t.move),l=n.index>=e.cursor.index;return{...e,cursor:v(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,a)=>r-a);return{...e,chosen:l}}case"all":{let n=c.flatMap((l,r)=>l?[r]:[]);return{...e,chosen:n}}case"none":return{...e,chosen:[]}}}function Gt(e){let t=e.indexOf(!0);return t===-1?0:t}
3
- export{qt,tt,Gt};
2
+ import{o,u,xn,En,Tn,I}from"./index-d4x6yvqh.js";import{W}from"./index-gz9x25tz.js";import{Box as T,Text as d}from"ink";import{jsx as m,jsxs as s}from"react/jsx-runtime";function Qt({rows:e,index:t,chosen:c,window:n,width:l}){let{from:r,to:a}=I(e.length,t,n),b=new Set(c),g=e.reduce((i,p)=>p.kind==="item"?Math.max(i,p.label.length):i,0),M=xn(l,g);return s(T,{flexDirection:"column",children:[r>0?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",r," above"]}):null,e.slice(r,a).map((i,p)=>{let x=r+p;if(i.kind!=="item"){let f=i.kind==="source";return s(d,{wrap:"truncate",bold:f,color:f?o.accent:o.muted,children:[f?" ":" ",Tn(i.label,l-(f?2:4))]},x)}let h=x===t,y=b.has(x),S=En({name:i.label,meta:i.meta??"",description:i.description??""},M);return s(d,{wrap:"truncate",children:[m(d,{color:o.accent,children:h?u.pointer:" "}),m(d,{color:y?o.success:o.muted,children:y?u.checked:u.unchecked}),m(d,{bold:h,...y?{color:o.success}:{},children:S.name})," ",m(d,{color:o.muted,children:S.meta}),S.description===""?"":" ",m(d,{dimColor:!0,children:S.description})]},x)}),a<e.length?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-a," below"]}):null]})}function k(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 v(e,t,c,n){if(c.length===0)return e;return k(t,c,n)??k(t,c,!n)??e}function ot(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:v(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,a)=>r-a);return{...e,chosen:l}}case"all":{let n=c.flatMap((l,r)=>l?[r]:[]);return{...e,chosen:n}}case"none":return{...e,chosen:[]}}}function en(e){let t=e.indexOf(!0);return t===-1?0:t}
3
+ export{Qt,ot,en};
4
4
 
5
- //# debugId=9296523BD184D16264756E2164756E21
6
- //# sourceMappingURL=index-e8n70sgj.js.map
5
+ //# debugId=E6CE155E3D3FA44364756E2164756E21
6
+ //# sourceMappingURL=index-fex44816.js.map
@@ -6,6 +6,6 @@
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
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,EA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AO,OAChC,EAAO,EAEX,OAyBJ,SAAS,CAAgB,CACrB,EACA,EACA,EACA,EACW,CACX,GAAI,EAAW,SAAW,EAAG,OAAO,EACpC,OAAO,EAAK,EAAO,EAAY,CAAO,GAAK,EAAK,EAAO,EAAY,CAAC,CAAO,GAAK,EAG7E,SAAS,EAAiB,CAC7B,EACA,EACA,EACgB,CAChB,OAAQ,EAAO,UACN,OAAQ,CAIT,GAAI,CAAC,EAAW,SAAS,EAAI,EAAG,OAAO,EACvC,IAAM,EAAQ,EAAW,EAAM,OAAQ,EAAO,IAAI,EAK5C,EAAU,EAAM,OAAS,EAAM,OAAO,MAC5C,MAAO,IAAK,EAAO,OAAQ,EAAiB,EAAM,OAAQ,EAAO,EAAY,CAAO,CAAE,CAC1F,KACK,SAAU,CACX,IAAM,EAAQ,EAAM,OAAO,MAC3B,GAAI,EAAW,KAAW,GAAM,OAAO,EACvC,IAAM,EAAS,EAAM,OAAO,SAAS,CAAK,EACpC,EAAM,OAAO,OAAO,CAAC,IAAU,IAAU,CAAK,EAC9C,CAAC,GAAG,EAAM,OAAQ,CAAK,EAAE,KAAK,CAAC,EAAG,IAAM,EAAI,CAAC,EACnD,MAAO,IAAK,EAAO,QAAO,CAC9B,KACK,MAAO,CACR,IAAM,EAAS,EAAW,QAAQ,CAAC,EAAI,IAAW,EAAK,CAAC,CAAK,EAAI,CAAC,CAAE,EACpE,MAAO,IAAK,EAAO,QAAO,CAC9B,KACK,OACD,MAAO,IAAK,EAAO,OAAQ,CAAC,CAAE,GAKnC,SAAS,EAAe,CAAC,EAAwC,CACpE,IAAM,EAAQ,EAAW,QAAQ,EAAI,EACrC,OAAO,IAAU,GAAK,EAAI",
9
- "debugId": "9296523BD184D16264756E2164756E21",
9
+ "debugId": "E6CE155E3D3FA44364756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import{t,ut,Pt,fe,ze,Be}from"./index-2cvtz0fy.js";import{hr}from"./index-bry9bzt3.js";import{Et,vo}from"./index-9f9pp2ef.js";import{l,m,d,c}from"./index-mgdgx22q.js";import{chmodSync as E,existsSync as _,readFileSync as b,statSync as R,writeFileSync as N}from"node:fs";import{dirname as j,join as F}from"node:path";function x(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 w(e,n,o){let r=`${n}=${x(o)}`,i=e.split(`
3
- `),s=new RegExp(`^\\s*(?:export\\s+)?${n}\\s*=`),a=i.findIndex((u)=>s.test(u));if(a!==-1){let u=i[a]??"",p=/^\s*export\s+/.exec(u)?.[0]??"";return{text:[...i.slice(0,a),`${p}${r}`,...i.slice(a+1)].join(`
2
+ import{t,pt,Ft,me,Be,Ke}from"./index-tv4yv7d2.js";import{wr}from"./index-ttwyrdjs.js";import{At,To}from"./index-tf71ap9v.js";import{l,p,d,c}from"./index-j7gyr5nx.js";import{chmodSync as E,existsSync as _,readFileSync as b,statSync as R,writeFileSync as N}from"node:fs";import{dirname as j,join as F}from"node:path";function x(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 w(e,n,o){let r=`${n}=${x(o)}`,i=e.split(`
3
+ `),s=new RegExp(`^\\s*(?:export\\s+)?${n}\\s*=`),a=i.findIndex((u)=>s.test(u));if(a!==-1){let u=i[a]??"",h=/^\s*export\s+/.exec(u)?.[0]??"";return{text:[...i.slice(0,a),`${h}${r}`,...i.slice(a+1)].join(`
4
4
  `),replaced:!0}}let f=e.replace(/\n+$/,"");return{text:f===""?`${r}
5
5
  `:`${f}
6
6
  ${r}
7
- `,replaced:!1}}function T(e){return F(j(e),".env")}async function zn(e,n,o){let r=Pt(o),i=await ut({file:e,path:n.split("."),value:r});return{note:`${n} is now ${O(r)}`,reflowed:i.reflowed,before:i.before}}async function Bn(e,n,o){let r=b(e,"utf8"),i=fe(r,["channels"]);if(!Array.isArray(i))throw new t({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 s=i.filter((g)=>typeof g==="object"&&g!==null&&!Array.isArray(g)),a=s.findIndex((g)=>String(g.id??"")===n);if(a===-1)throw new t({code:"cli_config_channel_unknown",message:`No channel with id "${n}".`,hint:`Declared: ${s.map((g)=>String(g.id??"")).join(", ")}.`,field:"channel"});let f=s[a],u=o.map((g)=>ur(g,String(f.type??""))),p=[...new Set(u)],y=Array.isArray(f.allowFrom)?f.allowFrom.map(String):[],A=await ut({file:e,path:["channels"],value:s.map((g,S)=>S===a?{...g,allowFrom:p}:g)});return{note:p.length===0?`${n} now allows nobody, which refuses every message`:`${n} now allows ${p.join(", ")}`,reflowed:A.reflowed,before:y}}function Kn(e,n,o){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new t({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(o==="")throw new t({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 r=T(e),i=_(r)?b(r,"utf8"):"",s=w(i,n,o);N(r,s.text,{encoding:"utf8",mode:384});let a=(R(r).mode&63)!==0;if(a)E(r,384);return{note:`${n} ${s.replaced?"replaced":"written"} in ${r}${a?" (tightened to 0600)":""}`,reflowed:!1,before:void 0}}function ur(e,n){let o=e.trim();if(o==="")throw new t({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 o;let r=hr(o);if(!r.ok)throw new t({code:"cli_config_handle_invalid",message:`"${o}" ${r.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 r.value}function O(e){if(e==="")return"empty";if(typeof e==="string")return e;return JSON.stringify(e)}function kt(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 V(e){return e.split(/[.[]/)[0]??e}function io(e,n){let o=[`${n}`,""],r=new Map;for(let s of e){let a=V(s.setting.path);r.set(a,[...r.get(a)??[],s])}let i=!0;for(let[s,a]of r){o.push(m(s,i)),i=!1;for(let f of a){let u=f.setting.agentListed?"":" · yours only",p=f.setting.via===void 0?"":` · set with \`${f.setting.via}\``,y=f.setting.confirm===void 0?"":" · asks first";o.push(l([{label:f.setting.path,value:kt(f.value)}]),c(`${f.setting.means}${u}${p}${y}`,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(`
8
- `)}function ao(e,n){return[l([{label:e.path,value:kt(n)}]),c(e.means,4),...e.toAgent===void 0?[]:[c(`to the agent: ${e.toAgent}`,4)]].join(`
9
- `)}function lo(e,n){if(e.confirm===void 0)return;if(e.path==="tools.untrusted.onMutate"&&String(n).toLowerCase()!=="allow")return;return e.confirm}function co(e){let n=[l([{label:"set",value:`${e.path} = ${kt(e.after)}`},{label:"was",value:e.before===void 0?"(not set)":kt(e.before)},{label:"file",value:e.file}])];if(e.reflowed)n.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)n.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)n.push(d(`${o.name} is not set — ${o.why}`)),n.push(d(`fill it in with \`config env <agent> ${o.name}\``));return n.join(`
10
- `)}function uo(){return Be.filter((e)=>e.via===void 0&&!/[[<]/.test(e.path)).map((e)=>e.path)}function St(e){if(typeof e!=="object"||e===null)return[];let n=e,o=[],r=(f,u)=>{if(typeof f==="string"&&f!=="")o.push({name:f,why:u})},i=h(n.model);for(let f of["main","selector","compactor"]){let u=h(i?.[f]);r(u?.apiKeyEnv,"the manifest will not load until it is set")}if(Array.isArray(n.channels))for(let f of n.channels){let u=h(f);if(u===void 0||u.enabled===!1)continue;r(u.tokenEnv,`the ${String(u.id??u.type??"channel")} channel is read at boot, so the agent will not start until it is set`)}let s=h(n.server);if(s?.enabled===!0)r(s.tokenEnv,"the HTTP API would accept unauthenticated requests. This does not stop the agent starting");let a=h(h(n.tools)?.providers);for(let[f,u]of Object.entries(a??{}))r(h(u)?.apiKeyEnv,`the ${f} provider's tools will not work until it is set`);return o}function h(e){if(typeof e!=="object"||e===null||Array.isArray(e))return;return e}function Hn(e,n){return e.filter((o)=>n[o.name]===void 0||n[o.name]==="")}function k(e,n){let o=[],r=new Map;for(let i of e){if(i.setting.via!==void 0||/[[<]/.test(i.setting.path))continue;let s=i.setting.path.split(".")[0]??i.setting.path;r.set(s,[...r.get(s)??[],i])}for(let[i,s]of r){o.push({kind:"heading",label:i});for(let a of s)o.push({kind:"setting",setting:a.setting,value:a.value})}if(n.channels.length>0){o.push({kind:"heading",label:"who may reach it"});for(let i of n.channels)o.push({kind:"allow",channelId:i.id,channelType:i.type,handles:i.allowFrom})}if(n.secrets.length>0){o.push({kind:"heading",label:"secrets — written to the .env, never shown"});for(let i of n.secrets)o.push({kind:"secret",name:i.name,why:i.why,present:n.present(i.name)})}return o}import{readFileSync as v}from"node:fs";function Wn(e){let n=v(e,"utf8");return Be.map((o)=>{if(o.path==="channels[].allowFrom"){let r=fe(n,["channels"]);if(!Array.isArray(r))return{setting:o,value:void 0};let i={};for(let s of r){if(typeof s!=="object"||s===null)continue;let a=s;if(typeof a.id!=="string")continue;i[a.id]=a.allowFrom??[]}return{setting:o,value:Object.keys(i).length===0?void 0:i}}if(o.path==="tools.providers.<id>.writeRoots"){let r=fe(n,["tools","providers"]);if(typeof r!=="object"||r===null||Array.isArray(r))return{setting:o,value:void 0};let i={};for(let[s,a]of Object.entries(r)){if(typeof a!=="object"||a===null)continue;let f=a.writeRoots;if(f!==void 0)i[s]=f}return{setting:o,value:Object.keys(i).length===0?void 0:i}}return{setting:o,value:fe(n,o.path.split("."))}})}function ot(e){let n=v(e,"utf8"),o=ze(n),r=Et(e),i=fe(n,["channels"]);return k(Wn(e),{channels:(Array.isArray(i)?i:[]).filter((s)=>typeof s==="object"&&s!==null&&!Array.isArray(s)).map((s)=>({id:String(s.id??""),type:String(s.type??""),allowFrom:Array.isArray(s.allowFrom)?s.allowFrom.map(String):[]})).filter((s)=>s.id!==""),secrets:St(o),present:(s)=>vo(r,s)})}async function Yt(e,n,o){switch(n.kind){case"setting":{if(o.trim()==="")throw new t({code:"cli_config_value_missing",message:`No value given for ${n.setting.path}.`,hint:'A bare word, a number, a list as ["a", "b"], or a map as {k: v}.',field:"value"});return(await zn(e,n.setting.path,o)).note}case"allow":{let r=o.trim()===""?[]:o.trim().split(/\s+/);return(await Bn(e,n.channelId,r)).note}case"secret":return Kn(e,n.name,o).note;case"heading":return""}}
11
- export{zn,Bn,Kn,ur,kt,io,ao,lo,co,uo,St,Hn,Wn,ot,Yt};
7
+ `,replaced:!1}}function T(e){return F(j(e),".env")}async function Wn(e,n,o){let r=Ft(o),i=await pt({file:e,path:n.split("."),value:r});return{note:`${n} is now ${O(r)}`,reflowed:i.reflowed,before:i.before}}async function qn(e,n,o){let r=b(e,"utf8"),i=me(r,["channels"]);if(!Array.isArray(i))throw new t({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 s=i.filter((g)=>typeof g==="object"&&g!==null&&!Array.isArray(g)),a=s.findIndex((g)=>String(g.id??"")===n);if(a===-1)throw new t({code:"cli_config_channel_unknown",message:`No channel with id "${n}".`,hint:`Declared: ${s.map((g)=>String(g.id??"")).join(", ")}.`,field:"channel"});let f=s[a],u=o.map((g)=>gr(g,String(f.type??""))),h=[...new Set(u)],m=Array.isArray(f.allowFrom)?f.allowFrom.map(String):[],A=await pt({file:e,path:["channels"],value:s.map((g,S)=>S===a?{...g,allowFrom:h}:g)});return{note:h.length===0?`${n} now allows nobody, which refuses every message`:`${n} now allows ${h.join(", ")}`,reflowed:A.reflowed,before:m}}function Gn(e,n,o){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new t({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(o==="")throw new t({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 r=T(e),i=_(r)?b(r,"utf8"):"",s=w(i,n,o);N(r,s.text,{encoding:"utf8",mode:384});let a=(R(r).mode&63)!==0;if(a)E(r,384);return{note:`${n} ${s.replaced?"replaced":"written"} in ${r}${a?" (tightened to 0600)":""}`,reflowed:!1,before:void 0}}function gr(e,n){let o=e.trim();if(o==="")throw new t({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 o;let r=wr(o);if(!r.ok)throw new t({code:"cli_config_handle_invalid",message:`"${o}" ${r.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 r.value}function O(e){if(e==="")return"empty";if(typeof e==="string")return e;return JSON.stringify(e)}function Tt(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 V(e){return e.split(/[.[]/)[0]??e}function fo(e,n){let o=[`${n}`,""],r=new Map;for(let s of e){let a=V(s.setting.path);r.set(a,[...r.get(a)??[],s])}let i=!0;for(let[s,a]of r){o.push(p(s,i)),i=!1;for(let f of a){let u=f.setting.agentListed?"":" · yours only",h=f.setting.via===void 0?"":` · set with \`${f.setting.via}\``,m=f.setting.confirm===void 0?"":" · asks first";o.push(l([{label:f.setting.path,value:Tt(f.value)}]),c(`${f.setting.means}${u}${h}${m}`,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(`
8
+ `)}function ho(e,n){return[l([{label:e.path,value:Tt(n)}]),c(e.means,4),...e.toAgent===void 0?[]:[c(`to the agent: ${e.toAgent}`,4)]].join(`
9
+ `)}function mo(e,n){if(e.confirm===void 0)return;if(e.path==="tools.untrusted.onMutate"&&String(n).toLowerCase()!=="allow")return;return e.confirm}function po(e){let n=[l([{label:"set",value:`${e.path} = ${Tt(e.after)}`},{label:"was",value:e.before===void 0?"(not set)":Tt(e.before)},{label:"file",value:e.file}])];if(e.reflowed)n.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)n.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)n.push(d(`${o.name} is not set — ${o.why}`)),n.push(d(`fill it in with \`config env <agent> ${o.name}\``));return n.join(`
10
+ `)}function go(){return Ke.filter((e)=>e.via===void 0&&!/[[<]/.test(e.path)).map((e)=>e.path)}function _t(e){if(typeof e!=="object"||e===null)return[];let n=e,o=[],r=(f,u)=>{if(typeof f==="string"&&f!=="")o.push({name:f,why:u})},i=y(n.model);for(let f of["main","selector","compactor"]){let u=y(i?.[f]);r(u?.apiKeyEnv,"the manifest will not load until it is set")}if(Array.isArray(n.channels))for(let f of n.channels){let u=y(f);if(u===void 0||u.enabled===!1)continue;r(u.tokenEnv,`the ${String(u.id??u.type??"channel")} channel is read at boot, so the agent will not start until it is set`)}let s=y(n.server);if(s?.enabled===!0)r(s.tokenEnv,"the HTTP API would accept unauthenticated requests. This does not stop the agent starting");let a=y(y(n.tools)?.providers);for(let[f,u]of Object.entries(a??{}))r(y(u)?.apiKeyEnv,`the ${f} provider's tools will not work until it is set`);return o}function y(e){if(typeof e!=="object"||e===null||Array.isArray(e))return;return e}function Zn(e,n){return e.filter((o)=>n[o.name]===void 0||n[o.name]==="")}function k(e,n){let o=[],r=new Map;for(let i of e){if(i.setting.via!==void 0||/[[<]/.test(i.setting.path))continue;let s=i.setting.path.split(".")[0]??i.setting.path;r.set(s,[...r.get(s)??[],i])}for(let[i,s]of r){o.push({kind:"heading",label:i});for(let a of s)o.push({kind:"setting",setting:a.setting,value:a.value})}if(n.channels.length>0){o.push({kind:"heading",label:"who may reach it"});for(let i of n.channels)o.push({kind:"allow",channelId:i.id,channelType:i.type,handles:i.allowFrom})}if(n.secrets.length>0){o.push({kind:"heading",label:"secrets — written to the .env, never shown"});for(let i of n.secrets)o.push({kind:"secret",name:i.name,why:i.why,present:n.present(i.name)})}return o}import{readFileSync as v}from"node:fs";function Vn(e){let n=v(e,"utf8");return Ke.map((o)=>{if(o.path==="channels[].allowFrom"){let r=me(n,["channels"]);if(!Array.isArray(r))return{setting:o,value:void 0};let i={};for(let s of r){if(typeof s!=="object"||s===null)continue;let a=s;if(typeof a.id!=="string")continue;i[a.id]=a.allowFrom??[]}return{setting:o,value:Object.keys(i).length===0?void 0:i}}if(o.path==="tools.providers.<id>.writeRoots"){let r=me(n,["tools","providers"]);if(typeof r!=="object"||r===null||Array.isArray(r))return{setting:o,value:void 0};let i={};for(let[s,a]of Object.entries(r)){if(typeof a!=="object"||a===null)continue;let f=a.writeRoots;if(f!==void 0)i[s]=f}return{setting:o,value:Object.keys(i).length===0?void 0:i}}return{setting:o,value:me(n,o.path.split("."))}})}function at(e){let n=v(e,"utf8"),o=Be(n),r=At(e),i=me(n,["channels"]);return k(Vn(e),{channels:(Array.isArray(i)?i:[]).filter((s)=>typeof s==="object"&&s!==null&&!Array.isArray(s)).map((s)=>({id:String(s.id??""),type:String(s.type??""),allowFrom:Array.isArray(s.allowFrom)?s.allowFrom.map(String):[]})).filter((s)=>s.id!==""),secrets:_t(o),present:(s)=>To(r,s)})}async function rn(e,n,o){switch(n.kind){case"setting":{if(o.trim()==="")throw new t({code:"cli_config_value_missing",message:`No value given for ${n.setting.path}.`,hint:'A bare word, a number, a list as ["a", "b"], or a map as {k: v}.',field:"value"});return(await Wn(e,n.setting.path,o)).note}case"allow":{let r=o.trim()===""?[]:o.trim().split(/\s+/);return(await qn(e,n.channelId,r)).note}case"secret":return Gn(e,n.name,o).note;case"heading":return""}}
11
+ export{Wn,qn,Gn,gr,Tt,fo,ho,mo,po,go,_t,Zn,Vn,at,rn};
12
12
 
13
- //# debugId=8D1CF32587D9259F64756E2164756E21
14
- //# sourceMappingURL=index-gbnc99j8.js.map
13
+ //# debugId=D81357B6476A51F364756E2164756E21
14
+ //# sourceMappingURL=index-ff514z3y.js.map
@@ -8,6 +8,6 @@
8
8
  "/**\n * What the config editor shows, and what one confirmed row does. Reads files; no Ink.\n *\n * Its own module because **both hosts import it statically** — `config.ts` for the standalone editor and\n * `App.tsx` for the pane — while `index.ts` imports `config.ts` *dynamically* to keep Ink off the\n * startup path. A module reached both ways makes `bun build --splitting` emit its exports twice and the\n * binary refuses to parse, and `bun test` sails straight through it because tests import source. So the\n * shared half lives where nothing has to be lazy about it.\n */\n\nimport { readFileSync } from \"node:fs\"\nimport { HarnessError, manifestDocument, manifestValueAt, SETTINGS } from \"@dispach/core\"\nimport { applyAllow, applySecret, applySet } from \"#lib/config-apply\"\nimport type { EditorRow } from \"#lib/config-editor\"\nimport { agentEnv, isSet } from \"#lib/config-env\"\nimport { editorRows, envNeeds, type SettingValue } from \"#lib/config-view\"\n\n/**\n * Every setting with whatever the file currently holds.\n *\n * Two rows do not have a readable dotted path — `allowFrom` lives inside a list entry and `writeRoots`\n * inside a provider — so they are gathered by walking the block instead. Shown rather than omitted: a\n * field missing from a listing reads as \"no such concept\", which is the same reasoning that puts a\n * `none` row in slot 2 instead of leaving the line out.\n */\nexport function currentValues(manifestPath: string): readonly SettingValue[] {\n const source = readFileSync(manifestPath, \"utf8\")\n return SETTINGS.map((setting) => {\n if (setting.path === \"channels[].allowFrom\") {\n const channels = manifestValueAt(source, [\"channels\"])\n if (!Array.isArray(channels)) return { setting, value: undefined }\n const byId: Record<string, unknown> = {}\n for (const entry of channels) {\n if (typeof entry !== \"object\" || entry === null) continue\n const row = entry as { id?: unknown; allowFrom?: unknown }\n if (typeof row.id !== \"string\") continue\n byId[row.id] = row.allowFrom ?? []\n }\n return { setting, value: Object.keys(byId).length === 0 ? undefined : byId }\n }\n if (setting.path === \"tools.providers.<id>.writeRoots\") {\n const providers = manifestValueAt(source, [\"tools\", \"providers\"])\n if (typeof providers !== \"object\" || providers === null || Array.isArray(providers)) {\n return { setting, value: undefined }\n }\n const roots: Record<string, unknown> = {}\n for (const [id, config] of Object.entries(providers as Record<string, unknown>)) {\n if (typeof config !== \"object\" || config === null) continue\n const found = (config as { writeRoots?: unknown }).writeRoots\n if (found !== undefined) roots[id] = found\n }\n return { setting, value: Object.keys(roots).length === 0 ? undefined : roots }\n }\n return { setting, value: manifestValueAt(source, setting.path.split(\".\")) }\n })\n}\n\n/**\n * The rows the editor shows, read fresh from the manifest and its `.env`.\n *\n * Exported because both hosts build them: this command mounts the editor standalone, and the chat opens\n * it as a pane. Two builders would drift on the first row either one grew.\n */\nexport function editorRowsFor(manifestPath: string): readonly EditorRow[] {\n const source = readFileSync(manifestPath, \"utf8\")\n const document = manifestDocument(source)\n const env = agentEnv(manifestPath)\n const channels = manifestValueAt(source, [\"channels\"])\n\n return editorRows(currentValues(manifestPath), {\n channels: (Array.isArray(channels) ? channels : [])\n .filter(\n (entry): entry is Record<string, unknown> =>\n typeof entry === \"object\" && entry !== null && !Array.isArray(entry),\n )\n .map((entry) => ({\n id: String(entry.id ?? \"\"),\n type: String(entry.type ?? \"\"),\n allowFrom: Array.isArray(entry.allowFrom) ? entry.allowFrom.map(String) : [],\n }))\n .filter((entry) => entry.id !== \"\"),\n secrets: envNeeds(document),\n // The agent's layered environment, not this process's — `ambientEnv` alone never adds the file\n // beside the manifest, which made a row read `(not set)` right after somebody set it.\n present: (name: string) => isSet(env, name),\n })\n}\n\n/**\n * Perform one row's edit. The editor's only asynchronous part, and the plain commands' path too.\n *\n * A blank buffer means different things per row and each is the useful reading: no handles is \"allow\n * nobody\", which is a real thing to want; an empty *setting* would be a value nobody typed on purpose;\n * and an empty secret is refused by `applySecret`, because a variable set to nothing fails the load\n * exactly as a missing one does.\n */\nexport async function applyEditorRow(\n manifestPath: string,\n row: EditorRow,\n raw: string,\n): Promise<string> {\n switch (row.kind) {\n case \"setting\": {\n if (raw.trim() === \"\") {\n throw new HarnessError({\n code: \"cli_config_value_missing\",\n message: `No value given for ${row.setting.path}.`,\n hint: 'A bare word, a number, a list as [\"a\", \"b\"], or a map as {k: v}.',\n field: \"value\",\n })\n }\n return (await applySet(manifestPath, row.setting.path, raw)).note\n }\n case \"allow\": {\n const handles = raw.trim() === \"\" ? [] : raw.trim().split(/\\s+/)\n return (await applyAllow(manifestPath, row.channelId, handles)).note\n }\n case \"secret\":\n return applySecret(manifestPath, row.name, raw).note\n case \"heading\":\n return \"\"\n }\n}\n"
9
9
  ],
10
10
  "mappings": ";sKAaA,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,CA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AC/C,UACD,MAAO",
11
- "debugId": "8D1CF32587D9259F64756E2164756E21",
11
+ "debugId": "D81357B6476A51F364756E2164756E21",
12
12
  "names": []
13
13
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{Wo}from"./index-jk0def33.js";var c=[{title:"Specs and planning",skills:["prd","breakdown-feature-prd","breakdown-epic-pm","breakdown-feature-implementation","breakdown-plan","create-implementation-plan","create-specification","create-architectural-decision-record","create-technical-spike"]},{title:"Documents",skills:["create-readme","create-tldr-page","documentation-writer","convert-plaintext-to-md","markdown-to-html"]},{title:"Communications",skills:["meeting-minutes","email-drafter","linkedin-post-formatter","daily-prep"]},{title:"Go to market",skills:["gtm-0-to-1-launch","gtm-board-and-investor-communication","gtm-enterprise-account-planning","gtm-enterprise-onboarding","gtm-operating-cadence","gtm-partnership-architecture","gtm-positioning-strategy","gtm-product-led-growth","gtm-technical-product-pricing","gtm-developer-ecosystem"]},{title:"Team and process",skills:["mentoring-juniors","impediment-prioritization","quality-playbook"]},{title:"Diagrams",skills:["napkin","excalidraw-diagram-generator","draw-io-diagram-generator","plantuml-ascii"]},{title:"Prompt craft and research",skills:["boost-prompt","autoresearch"]}],ro=c.flatMap((e)=>e.skills);function u(e){return c.find((n)=>n.skills.includes(e))?.title}function m(e,n){let t=n.filter((a)=>a.problem===void 0);if(e.curated===void 0)return t;let r=new Set(e.curated);return t.filter((a)=>r.has(a.skill)||r.has(g(a.repoPath)))}function g(e){let n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function oo(e){let n=[];for(let t of e){let r=m(t.spec,t.entries);if(r.length===0)continue;let a=new Set(t.installed??[]);n.push({kind:"source",label:`${t.spec.name} ${r.length} skill${r.length===1?"":"s"}`});let s=new Map,d=[];for(let o of r){let i=t.spec.curated===void 0?void 0:u(o.skill);if(i===void 0)d.push(o);else{let l=s.get(i);if(l===void 0)s.set(i,[o]);else l.push(o)}}for(let o of d)n.push(p(o,a));for(let[o,i]of s){n.push({kind:"group",label:o});for(let l of i)n.push(p(l,a))}}return n}function p(e,n){return{kind:"item",label:e.skill,meta:Wo(e.tokens,e.scripts.length,n.has(e.skill)),description:f(e.description),entry:e}}function f(e){let n=e.replace(/\s+/g," ").trim(),t=n.search(/\.\s/);return t===-1?n:n.slice(0,t+1)}function nt(e){return e.map((n)=>n.kind==="item")}function Zt(e,n){return n.map((t)=>e[t]?.entry).filter((t)=>t!==void 0)}function vt(e){let n=e.filter((t)=>t.ok);return{installed:n.map((t)=>t.name),failed:e.filter((t)=>!t.ok).map((t)=>({name:t.name,reason:t.reason??"not installed"})),runnable:n.reduce((t,r)=>t+r.runnable.length,0),withCode:n.filter((t)=>t.runnable.length>0).length,total:e.length}}
3
- export{ro,oo,nt,Zt,vt};
2
+ import{Yo}from"./index-d4x6yvqh.js";var c=[{title:"Specs and planning",skills:["prd","breakdown-feature-prd","breakdown-epic-pm","breakdown-feature-implementation","breakdown-plan","create-implementation-plan","create-specification","create-architectural-decision-record","create-technical-spike"]},{title:"Documents",skills:["create-readme","create-tldr-page","documentation-writer","convert-plaintext-to-md","markdown-to-html"]},{title:"Communications",skills:["meeting-minutes","email-drafter","linkedin-post-formatter","daily-prep"]},{title:"Go to market",skills:["gtm-0-to-1-launch","gtm-board-and-investor-communication","gtm-enterprise-account-planning","gtm-enterprise-onboarding","gtm-operating-cadence","gtm-partnership-architecture","gtm-positioning-strategy","gtm-product-led-growth","gtm-technical-product-pricing","gtm-developer-ecosystem"]},{title:"Team and process",skills:["mentoring-juniors","impediment-prioritization","quality-playbook"]},{title:"Diagrams",skills:["napkin","excalidraw-diagram-generator","draw-io-diagram-generator","plantuml-ascii"]},{title:"Prompt craft and research",skills:["boost-prompt","autoresearch"]}],lo=c.flatMap((e)=>e.skills);function u(e){return c.find((n)=>n.skills.includes(e))?.title}function m(e,n){let t=n.filter((a)=>a.problem===void 0);if(e.curated===void 0)return t;let r=new Set(e.curated);return t.filter((a)=>r.has(a.skill)||r.has(g(a.repoPath)))}function g(e){let n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function co(e){let n=[];for(let t of e){let r=m(t.spec,t.entries);if(r.length===0)continue;let a=new Set(t.installed??[]);n.push({kind:"source",label:`${t.spec.name} ${r.length} skill${r.length===1?"":"s"}`});let s=new Map,d=[];for(let o of r){let i=t.spec.curated===void 0?void 0:u(o.skill);if(i===void 0)d.push(o);else{let l=s.get(i);if(l===void 0)s.set(i,[o]);else l.push(o)}}for(let o of d)n.push(p(o,a));for(let[o,i]of s){n.push({kind:"group",label:o});for(let l of i)n.push(p(l,a))}}return n}function p(e,n){return{kind:"item",label:e.skill,meta:Yo(e.tokens,e.scripts.length,n.has(e.skill)),description:f(e.description),entry:e}}function f(e){let n=e.replace(/\s+/g," ").trim(),t=n.search(/\.\s/);return t===-1?n:n.slice(0,t+1)}function st(e){return e.map((n)=>n.kind==="item")}function tn(e,n){return n.map((t)=>e[t]?.entry).filter((t)=>t!==void 0)}function Et(e){let n=e.filter((t)=>t.ok);return{installed:n.map((t)=>t.name),failed:e.filter((t)=>!t.ok).map((t)=>({name:t.name,reason:t.reason??"not installed"})),runnable:n.reduce((t,r)=>t+r.runnable.length,0),withCode:n.filter((t)=>t.runnable.length>0).length,total:e.length}}
3
+ export{lo,co,st,tn,Et};
4
4
 
5
- //# debugId=EA611634A87ED1D664756E2164756E21
6
- //# sourceMappingURL=index-t1xvacym.js.map
5
+ //# debugId=1752D5B0B669A9A864756E2164756E21
6
+ //# sourceMappingURL=index-gme2egyq.js.map
@@ -6,6 +6,6 @@
6
6
  "/**\n * The browse list: a curated catalogue turned into rows, and rows turned back into skills.\n *\n * Pure and PURE-listed. The screen root renders it and the plain path prints it, so the *shape* of the\n * list — which sources appear, in what order, under which headings, with what shown beside each entry —\n * is decided once here and asserted without mounting Ink or reaching a network.\n *\n * Keeping this separate from the component is what makes `--plain` honest: a terminal and a pipe print\n * the same list because both read the same rows, rather than the plain path reimplementing the ordering\n * and drifting the first time a group is added.\n */\n\nimport { curatedGroupOf } from \"#lib/curated\"\nimport { metaOf } from \"#lib/rows\"\nimport type { CatalogueEntry } from \"#lib/source-cache\"\nimport type { SourceSpec } from \"#lib/sources\"\n\nexport interface BrowseRow {\n /** `source` is a top-level heading, `group` a subheading; neither is selectable. */\n readonly kind: \"source\" | \"group\" | \"item\"\n readonly label: string\n /** Its own column, not appended to the label — the row is laid out, not concatenated. */\n readonly meta?: string\n readonly description?: string\n /** The skill this row installs. Absent on a heading. */\n readonly entry?: CatalogueEntry\n}\n\n/**\n * A source's entries, filtered by its curation and grouped for display.\n *\n * Curation is applied *here* rather than in `readCatalogue`, so `sources search` keeps seeing everything.\n * A curated list is a recommendation; a search that could not find a named skill would be a restriction.\n */\nexport function curatedEntries(\n spec: SourceSpec,\n entries: readonly CatalogueEntry[],\n): readonly CatalogueEntry[] {\n const usable = entries.filter((entry) => entry.problem === undefined)\n if (spec.curated === undefined) return usable\n const allowed = new Set(spec.curated)\n // Matched on the *folder* name, which is what a curated list is written in terms of — and which the\n // spec requires to equal the frontmatter name, so either would work today and the folder is the one\n // that stays true if upstream renames the skill inside the file.\n return usable.filter(\n (entry) => allowed.has(entry.skill) || allowed.has(basename(entry.repoPath)),\n )\n}\n\nfunction basename(path: string): string {\n const cut = path.lastIndexOf(\"/\")\n return cut === -1 ? path : path.slice(cut + 1)\n}\n\nexport interface BrowseInput {\n readonly spec: SourceSpec\n readonly entries: readonly CatalogueEntry[]\n /** Already installed in the target agent, shown as such rather than offered twice. */\n readonly installed?: readonly string[]\n}\n\n/**\n * Every row, in display order: one heading per source, then per curated group where the source has them.\n *\n * An installed skill is listed with a note rather than removed, because a list whose contents change\n * depending on which agent you picked is one you cannot learn.\n */\nexport function browseRows(inputs: readonly BrowseInput[]): readonly BrowseRow[] {\n const rows: BrowseRow[] = []\n for (const input of inputs) {\n const entries = curatedEntries(input.spec, input.entries)\n if (entries.length === 0) continue\n const installed = new Set(input.installed ?? [])\n\n rows.push({\n kind: \"source\",\n label: `${input.spec.name} ${entries.length} skill${entries.length === 1 ? \"\" : \"s\"}`,\n })\n\n // Grouped where the curation defines groups, flat otherwise. `anthropics/skills` is 17 broadly\n // useful entries and inventing categories for it would be editorialising about somebody else's\n // catalogue; `awesome-copilot` is 425 and the groups are why it is legible at all.\n const grouped = new Map<string, CatalogueEntry[]>()\n const ungrouped: CatalogueEntry[] = []\n for (const entry of entries) {\n const group = input.spec.curated === undefined ? undefined : curatedGroupOf(entry.skill)\n if (group === undefined) ungrouped.push(entry)\n else {\n const bucket = grouped.get(group)\n if (bucket === undefined) grouped.set(group, [entry])\n else bucket.push(entry)\n }\n }\n\n for (const entry of ungrouped) rows.push(itemRow(entry, installed))\n for (const [title, bucket] of grouped) {\n rows.push({ kind: \"group\", label: title })\n for (const entry of bucket) rows.push(itemRow(entry, installed))\n }\n }\n return rows\n}\n\nfunction itemRow(entry: CatalogueEntry, installed: ReadonlySet<string>): BrowseRow {\n return {\n kind: \"item\",\n label: entry.skill,\n // The script count is on the row because it is the one fact that should change somebody's mind\n // before ticking a box: a skill with runnable files is code that will run on this machine.\n meta: metaOf(entry.tokens, entry.scripts.length, installed.has(entry.skill)),\n description: summarise(entry.description),\n entry,\n }\n}\n\n/**\n * First sentence, uncapped.\n *\n * The *column* decides the visible width now, in `lib/rows.ts`, so capping here as well would truncate\n * twice — once at 96 characters and again at whatever the terminal has left, which is how a wide terminal\n * ends up showing a short description with an ellipsis and empty space after it.\n */\nexport function summarise(description: string): string {\n const flat = description.replace(/\\s+/g, \" \").trim()\n const stop = flat.search(/\\.\\s/)\n return stop === -1 ? flat : flat.slice(0, stop + 1)\n}\n\n/** Which rows the cursor may land on, for the multi-select reducer. */\nexport function selectableOf(rows: readonly BrowseRow[]): readonly boolean[] {\n return rows.map((row) => row.kind === \"item\")\n}\n\n/** The skills behind a set of chosen row indices, in the order they appear on screen. */\nexport function chosenEntries(\n rows: readonly BrowseRow[],\n chosen: readonly number[],\n): readonly CatalogueEntry[] {\n return chosen\n .map((index) => rows[index]?.entry)\n .filter((entry): entry is CatalogueEntry => entry !== undefined)\n}\n\n// ─── what an install did ─────────────────────────────────────────────────────────────────\n\n/**\n * The structural half of `skills.ts`'s `InstallOutcome`.\n *\n * Declared here rather than imported so this module stays free of the command that produces it —\n * `skills.ts` reaches the filesystem, and importing it would drag that into every consumer of the row\n * layout, including the pure tests.\n */\nexport interface InstallOutcomeLike {\n readonly name: string\n readonly ok: boolean\n readonly reason?: string\n readonly runnable: readonly string[]\n}\n\nexport interface InstallReport {\n readonly installed: readonly string[]\n readonly failed: readonly { readonly name: string; readonly reason: string }[]\n /** Runnable files across every successful install, and how many skills brought them. */\n readonly runnable: number\n readonly withCode: number\n readonly total: number\n}\n\n/**\n * One report for a batch, as data.\n *\n * Both renderings read this — the text one the pipe and `init` print, and the card the browser shows\n * inside its own frame. The alternative was each composing its own summary from the outcomes, and a\n * terminal and a pipe disagreeing about what happened is exactly the class of failure the shared\n * `browseRows` was introduced to end.\n */\nexport function installReport(outcomes: readonly InstallOutcomeLike[]): InstallReport {\n const ok = outcomes.filter((outcome) => outcome.ok)\n return {\n installed: ok.map((outcome) => outcome.name),\n failed: outcomes\n .filter((outcome) => !outcome.ok)\n .map((outcome) => ({ name: outcome.name, reason: outcome.reason ?? \"not installed\" })),\n runnable: ok.reduce((count, outcome) => count + outcome.runnable.length, 0),\n withCode: ok.filter((outcome) => outcome.runnable.length > 0).length,\n total: outcomes.length,\n }\n}\n"
7
7
  ],
8
8
  "mappings": ";oCAmCO,IAAM,EAA6C,CACtD,CACI,MAAO,qBACP,OAAQ,CACJ,MACA,wBACA,oBACA,mCACA,iBACA,6BACA,uBACA,uCACA,wBACJ,CACJ,EACA,CACI,MAAO,YACP,OAAQ,CACJ,gBACA,mBACA,uBACA,0BACA,kBACJ,CACJ,EACA,CACI,MAAO,iBACP,OAAQ,CAAC,kBAAmB,gBAAiB,0BAA2B,YAAY,CACxF,EACA,CACI,MAAO,eACP,OAAQ,CACJ,oBACA,uCACA,kCACA,4BACA,wBACA,+BACA,2BACA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/B,IAAI,CAAC,KAAa,CAAE,KAAM,EAAQ,KAAM,OAAQ,EAAQ,QAAU,eAAgB,EAAE,EACzF,SAAU,EAAG,OAAO,CAAC,EAAO,IAAY,EAAQ,EAAQ,SAAS,OAAQ,CAAC,EAC1E,SAAU,EAAG,OAAO,CAAC,IAAY,EAAQ,SAAS,OAAS,CAAC,EAAE,OAC9D,MAAO,EAAS,MACpB",
9
- "debugId": "EA611634A87ED1D664756E2164756E21",
9
+ "debugId": "1752D5B0B669A9A864756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{o,u,R}from"./index-jk0def33.js";import{Box as f,Text as d}from"ink";import{jsxs as r}from"react/jsx-runtime";function ae({items:e,index:n,numbered:t,maxRows:p}){let m=p===void 0?e.length:Math.max(1,p),{from:c,to:x}=R(e.length,n,m),s=e.slice(c,x).map((l,i)=>({at:c+i,item:l}));return r(f,{flexDirection:"column",children:[c>0?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",c," above"]}):null,s.map(({at:l,item:i})=>{let a=l===n,y=t===!0?`${l+1}. `:"";return r(d,{wrap:"truncate",...a?{color:o.accent}:{},children:[a?u.pointer:" ",r(d,{bold:a,children:[y,i.label]}),i.hint===void 0?"":r(d,{dimColor:!0,...a?{color:o.muted}:{},children:[" ",i.hint]})]},`row-${l}`)}),x<e.length?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-x," below"]}):null]})}function G(e,n){if(e.count===0)return e;let t=e.count-1;switch(n.kind){case"up":return{...e,index:Math.max(0,e.index-1)};case"down":return{...e,index:Math.min(t,e.index+1)};case"first":return{...e,index:0};case"last":return{...e,index:t};case"jump":return n.index<0||n.index>t?e:{...e,index:n.index}}}
3
- export{ae,G};
2
+ import{o,u,I}from"./index-d4x6yvqh.js";import{Box as f,Text as d}from"ink";import{jsxs as r}from"react/jsx-runtime";function ae({items:e,index:n,numbered:t,maxRows:p}){let m=p===void 0?e.length:Math.max(1,p),{from:c,to:x}=I(e.length,n,m),s=e.slice(c,x).map((l,i)=>({at:c+i,item:l}));return r(f,{flexDirection:"column",children:[c>0?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",c," above"]}):null,s.map(({at:l,item:i})=>{let a=l===n,y=t===!0?`${l+1}. `:"";return r(d,{wrap:"truncate",...a?{color:o.accent}:{},children:[a?u.pointer:" ",r(d,{bold:a,children:[y,i.label]}),i.hint===void 0?"":r(d,{dimColor:!0,...a?{color:o.muted}:{},children:[" ",i.hint]})]},`row-${l}`)}),x<e.length?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-x," below"]}):null]})}function W(e,n){if(e.count===0)return e;let t=e.count-1;switch(n.kind){case"up":return{...e,index:Math.max(0,e.index-1)};case"down":return{...e,index:Math.min(t,e.index+1)};case"first":return{...e,index:0};case"last":return{...e,index:t};case"jump":return n.index<0||n.index>t?e:{...e,index:n.index}}}
3
+ export{ae,W};
4
4
 
5
- //# debugId=2E8E37B85694559F64756E2164756E21
6
- //# sourceMappingURL=index-mrtb5y08.js.map
5
+ //# debugId=2BA8171202239BF664756E2164756E21
6
+ //# sourceMappingURL=index-gz9x25tz.js.map
@@ -6,6 +6,6 @@
6
6
  "/**\n * List-cursor state: an index and the moves that change it. Pure, like every reducer here.\n */\n\nexport interface SelectState {\n readonly index: number\n readonly count: number\n}\n\nexport type SelectMove =\n | { readonly kind: \"up\" }\n | { readonly kind: \"down\" }\n | { readonly kind: \"first\" }\n | { readonly kind: \"last\" }\n /** 0-based. A digit key jumps the cursor — visibly and reversibly; it never chooses. */\n | { readonly kind: \"jump\"; readonly index: number }\n\nexport function moveSelect(state: SelectState, move: SelectMove): SelectState {\n if (state.count === 0) return state\n const last = state.count - 1\n switch (move.kind) {\n case \"up\":\n return { ...state, index: Math.max(0, state.index - 1) }\n case \"down\":\n return { ...state, index: Math.min(last, state.index + 1) }\n case \"first\":\n return { ...state, index: 0 }\n case \"last\":\n return { ...state, index: last }\n case \"jump\":\n return move.index < 0 || move.index > last ? state : { ...state, index: move.index }\n }\n}\n"
7
7
  ],
8
8
  "mappings": ";uCAoBA,cAAS,UAAK,qDAmBP,SAAS,EAAU,EAAG,QAAO,QAAO,WAAU,WAA4B,CAC7E,IAAM,EAAS,IAAY,OAAY,EAAM,OAAS,KAAK,IAAI,EAAG,CAAO,GACjE,OAAM,MAAO,EAAS,EAAM,OAAQ,EAAO,CAAM,EAGnD,EAAU,EAAM,MAAM,EAAM,CAAE,EAAE,IAAI,CAAC,EAAM,KAAY,CAAE,GAAI,EAAO,EAAQ,MAAK,EAAE,EAEzF,OACI,EA0CE,EA1CF,CAAK,cAAc,SAAnB,SA0CE,CAzCG,EAAO,EACJ,EAGE,EAHF,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,KACA,EAAM,SAFX,IAEsB,EAFtB,UAGE,EACF,KACH,EAAQ,IAAI,EAAG,KAAI,UAAW,CAC3B,IAAM,EAAW,IAAO,EAClB,EAAS,IAAa,GAAO,GAAG,EAAK,MAAQ,GACnD,OAKI,EAkBE,EAlBF,CAEI,KAAK,cACA,EAAW,CAAE,MAAO,EAAM,MAAO,EAAI,CAAC,EAH/C,SAkBE,CAbG,EAAW,EAAM,QAAU,KAC5B,EAGE,EAHF,CAAM,KAAM,EAAZ,SAGE,CAFG,EACA,EAAK,OACR,EACD,EAAK,OAAS,OACX,GAEA,EAGE,EAHF,CAAM,SAAQ,MAAM,EAAW,CAAE,MAAO,EAAM,KAAM,EAAI,CAAC,EAAzD,SAGE,CAFG,KACA,EAAK,MACR,IAfD,OAAO,GAiBd,EAET,EACA,EAAK,EAAM,OACR,EAGE,EAHF,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,KACA,EAAM,SAFX,IAEsB,EAAM,OAAS,EAFrC,UAGE,EACF,MACN,ECxEH,SAAS,CAAU,CAAC,EAAoB,EAA+B,CAC1E,GAAI,EAAM,QAAU,EAAG,OAAO,EAC9B,IAAM,EAAO,EAAM,MAAQ,EAC3B,OAAQ,EAAK,UACJ,KACD,MAAO,IAAK,EAAO,MAAO,KAAK,IAAI,EAAG,EAAM,MAAQ,CAAC,CAAE,MACtD,OACD,MAAO,IAAK,EAAO,MAAO,KAAK,IAAI,EAAM,EAAM,MAAQ,CAAC,CAAE,MACzD,QACD,MAAO,IAAK,EAAO,MAAO,CAAE,MAC3B,OACD,MAAO,IAAK,EAAO,MAAO,CAAK,MAC9B,OACD,OAAO,EAAK,MAAQ,GAAK,EAAK,MAAQ,EAAO,EAAQ,IAAK,EAAO,MAAO,EAAK,KAAM",
9
- "debugId": "2E8E37B85694559F64756E2164756E21",
9
+ "debugId": "2BA8171202239BF664756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{S}from"./index-jk0def33.js";import{xn,En,qe,Ge,Ze}from"./index-my5cjx00.js";var s=" · ",l=3;function Ro(n,e){let t=[{kind:"title",text:S(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:S(r,e)});let i=n.state??[];if(i.length>0)t.push({kind:"state",text:S(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:S(`⚠ ${a}`,e)});if(o.length>l)t.push({kind:"warning",text:S(`⚠ and ${o.length-l} more`,e)});return t}function Io(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===""?S(t[0]??"",e):r}function Jn(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 S(t.join(s),e)}var Oo={key:"q",does:"back"};function u(n,e){return n===void 0||n<=0?e:n}function Z(n,e){return Math.max(xn,Math.min(En,u(n,e)))}function No(n,e){return Math.max(qe,Math.min(Ge,u(n,e)-Ze))}
3
- export{Ro,Io,Jn,Oo,Z,No};
2
+ import{S}from"./index-d4x6yvqh.js";import{Rn,In,Ge,Ze,Ve}from"./index-vgc3y3rm.js";var s=" · ",l=3;function Po(n,e){let t=[{kind:"title",text:S(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:S(r,e)});let i=n.state??[];if(i.length>0)t.push({kind:"state",text:S(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:S(`⚠ ${a}`,e)});if(o.length>l)t.push({kind:"warning",text:S(`⚠ and ${o.length-l} more`,e)});return t}function Mo(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===""?S(t[0]??"",e):r}function rr(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 S(t.join(s),e)}var Lo={key:"q",does:"back"};function u(n,e){return n===void 0||n<=0?e:n}function q(n,e){return Math.max(Rn,Math.min(In,u(n,e)))}function Do(n,e){return Math.max(Ge,Math.min(Ze,u(n,e)-Ve))}
3
+ export{Po,Mo,rr,Lo,q,Do};
4
4
 
5
- //# debugId=E778705D26BA7DC464756E2164756E21
6
- //# sourceMappingURL=index-9nsfs0vy.js.map
5
+ //# debugId=CCA62814AD4503FC64756E2164756E21
6
+ //# sourceMappingURL=index-h9mw7b9d.js.map
@@ -5,6 +5,6 @@
5
5
  "/**\n * What every screen has in common, as data: the header block and the footer's key hints.\n *\n * ## Why this is a module and not a component\n *\n * Three surfaces had a banner before this existed — chat, the wizard, the agent picker — and each\n * decided its own title, its own context lines and its own key hints, in JSX. So the *content* of a\n * header was only observable by mounting a renderer, and the one thing worth asserting about it is\n * exactly that content: whether the agent in scope is named, whether a session-wide warning is still\n * visible after the screen scrolls, whether the footer fits.\n *\n * Everything here is text in, text out. `Screen.tsx` is one consumer; a test asserting a header names\n * the right agent is another, and neither can drift from the other because there is one derivation.\n *\n * ## The rule the header exists to enforce\n *\n * CLAUDE.md: anything true for the whole session belongs where a person still sees it after\n * scrolling. On an inline surface that could be a line printed at the top; on the alternate screen\n * there *is* no scrolling past, so it has to be the header or nowhere. `warnings` is therefore part\n * of the header's shape rather than something each screen remembers to render.\n *\n * Colour is not decided here, for `render.ts`'s reason: this module has no idea whether it is being\n * read from a terminal or a log file, and that is `resolveMode`'s question.\n */\n\nimport {\n MAX_SCREEN_COLUMNS,\n MAX_SCREEN_ROWS,\n MIN_SCREEN_COLUMNS,\n MIN_SCREEN_ROWS,\n SCREEN_CHROME_ROWS,\n} from \"#lib/const\"\nimport { clip } from \"#lib/rows\"\n\n/**\n * A live fact about the runtime, shown as a word rather than a sentence.\n *\n * `tone` is a role, never a colour — the component maps it. A literal colour name here would put\n * appearance in a pure module and break the one-home rule `theme.ts` exists for.\n */\nexport interface StateChip {\n readonly label: string\n readonly tone: \"ok\" | \"warn\" | \"off\"\n}\n\nexport interface ScreenHeader {\n /** Product identity — `BRAND.name` and the version. The one line that is the same everywhere. */\n readonly title: string\n /** What this screen is, and the counts that make it worth looking at. */\n readonly summary: string\n /**\n * The agent this screen acts on, when it acts on one.\n *\n * Present so it is impossible to install a skill into, or stop, an agent you did not mean.\n * Absent — not blank — on the machine-level screens: `sources` is a registry shared by every\n * agent on the machine, and naming one there would be a lie about the scope of what you are\n * changing.\n */\n readonly agent?: { readonly name: string; readonly model: string }\n readonly state?: readonly StateChip[]\n /** True for the whole session, so it stays in the frame rather than scrolling away. */\n readonly warnings?: readonly string[]\n}\n\nexport interface KeyHint {\n /** As a reader sees it: `↑↓`, `enter`, `^C`, `⌥⏎`. */\n readonly key: string\n readonly does: string\n}\n\nconst SEPARATOR = \" · \"\n/** Warnings past this many are counted rather than listed — a header is not a log. */\nconst WARNINGS_SHOWN = 3\n\n/**\n * One rendered line, tagged with what it is.\n *\n * Tagged rather than returned as plain strings because the component styles each kind differently and\n * the alternative is worse in both directions: a flat list of strings forces the renderer to guess by\n * index (which broke the first time a header had no state row), and having the renderer rebuild the\n * summary from `header.agent` itself would be a second derivation of the one thing this module exists\n * to derive once. The kind travels with the text; appearance stays in `theme.ts`.\n */\nexport interface HeaderLine {\n readonly kind: \"title\" | \"summary\" | \"state\" | \"warning\"\n readonly text: string\n}\n\n/** The header, as tagged lines, each already clipped to the width. */\nexport function headerLines(header: ScreenHeader, width: number): readonly HeaderLine[] {\n const lines: HeaderLine[] = [{ kind: \"title\", text: clip(header.title, width) }]\n\n // The agent rides on the summary line rather than taking one of its own. It is the same fact —\n // \"what am I looking at, and whose\" — and a separate line for it pushes the body down on every\n // screen to say something the summary was already the place for.\n const scope =\n header.agent === undefined\n ? header.summary\n : [`${header.agent.name}${SEPARATOR}${header.agent.model}`, header.summary]\n .filter((part) => part !== \"\")\n .join(SEPARATOR)\n if (scope !== \"\") lines.push({ kind: \"summary\", text: clip(scope, width) })\n\n const chips = header.state ?? []\n if (chips.length > 0) {\n lines.push({\n kind: \"state\",\n text: clip(chips.map((chip) => chip.label).join(SEPARATOR), width),\n })\n }\n\n const warnings = header.warnings ?? []\n for (const warning of warnings.slice(0, WARNINGS_SHOWN)) {\n lines.push({ kind: \"warning\", text: clip(`⚠ ${warning}`, width) })\n }\n // Counted, not dropped. A header that silently showed three of five warnings would be the\n // trimmed-catalogue failure again: true of what is on screen, false of what is the case.\n if (warnings.length > WARNINGS_SHOWN) {\n lines.push({\n kind: \"warning\",\n text: clip(`⚠ and ${warnings.length - WARNINGS_SHOWN} more`, width),\n })\n }\n\n return lines\n}\n\n/**\n * The footer: what the keys do, on one line, clipped.\n *\n * One line and never two. A footer that wraps moves the body every time the hints change, and the\n * hints change per screen state — so a two-line footer means the list jumps as you use it. Hints are\n * dropped from the end when they do not fit, which is why the caller orders them by how likely\n * somebody is to need reminding: movement first, the destructive one last.\n */\nexport function hintLine(hints: readonly KeyHint[], width: number): string {\n const rendered = hints.map((hint) => `${hint.key} ${hint.does}`)\n // Longest prefix that fits. Built up rather than clipped down, so the line never ends in half a\n // hint — `enter inst…` reads as a different key than the one it is.\n let line = \"\"\n for (const hint of rendered) {\n const next = line === \"\" ? hint : `${line}${SEPARATOR}${hint}`\n if ([...next].length > width) break\n line = next\n }\n // Nothing fit: one clipped hint beats an empty footer, because a screen with no visible way out\n // is the worst thing a full-screen surface can be.\n return line === \"\" ? clip(rendered[0] ?? \"\", width) : line\n}\n\n/**\n * The whole header on one line, for a surface that cannot spare three.\n *\n * The chat is that surface. Its opening banner already says the version, the store, the session and every\n * load warning — and on the alternate screen that banner scrolls out of the window, taking the\n * session-wide facts with it. `headerLines`' three-to-six rows would fix that and cost a fifth of a short\n * terminal permanently, so this is the compromise the rule actually asks for: identity and scope always\n * visible, warnings reduced to a count that says where the detail is.\n *\n * A count rather than the text, deliberately. One warning wrapped over two lines is a header that changes\n * height, which is the one thing a fixed-height frame cannot have.\n */\nexport function titleLine(header: ScreenHeader, width: number): string {\n const parts = [header.title]\n // The summary was dropped here while `Screen` renders it on its own dim line, so a surface using the\n // one-line variant silently lost its label: the conversation switcher passed \"pick a conversation\"\n // and the settings editor \"settings\", and neither ever appeared. Empty adds nothing, which is what\n // the chat header passes.\n if (header.summary !== \"\") parts.push(header.summary)\n if (header.agent !== undefined) parts.push(header.agent.name, header.agent.model)\n const warnings = header.warnings ?? []\n if (warnings.length > 0) {\n parts.push(`\\u26a0 ${warnings.length} note${warnings.length === 1 ? \"\" : \"s\"} at the top`)\n }\n return clip(parts.join(SEPARATOR), width)\n}\n\n/** The hint every alternate-screen surface carries, so no screen invents its own word for leaving. */\nexport const QUIT_HINT: KeyHint = { key: \"q\", does: \"back\" }\n\n/**\n * Terminal columns and rows a screen may use, clamped.\n *\n * Here rather than beside the one command that first needed them. They were exported from `browse.ts`,\n * which is imported both statically (by the wizard) and dynamically (by the command) — and the bundler\n * emitted the export twice, producing a `Duplicate export of 'windowFor'` that every test passed straight\n * through because tests import source, not the bundle. Screen arithmetic belongs with the screen.\n */\n/**\n * Zero means unknown, not zero.\n *\n * A pty genuinely reports a width of 0 — recorded in `lib/const.ts` beside `FALLBACK_COLUMNS`, measured\n * under `script -q`, and handled correctly in `useTerminalSize` since it was written. It was *not* handled\n * here, so a caller passing the stream's own measurement clamped to the 40-column floor and laid its rows\n * out for half the terminal. Found in a real capture: the session picker's rows came out 43 characters wide\n * on an 80-column screen, uniformly — which reads as a design choice rather than as a bug.\n *\n * `?? fallback` alone does not cover it, because 0 is not nullish. The same trap, one operator away.\n */\nfunction known(measured: number | undefined, fallback: number): number {\n return measured === undefined || measured <= 0 ? fallback : measured\n}\n\nexport function screenColumns(columns: number | undefined, fallback: number): number {\n return Math.max(MIN_SCREEN_COLUMNS, Math.min(MAX_SCREEN_COLUMNS, known(columns, fallback)))\n}\n\nexport function screenRows(rows: number | undefined, fallback: number): number {\n return Math.max(\n MIN_SCREEN_ROWS,\n Math.min(MAX_SCREEN_ROWS, known(rows, fallback) - SCREEN_CHROME_ROWS),\n )\n}\n"
6
6
  ],
7
7
  "mappings": ";mFAsEA,IAAM,EAAY,MAEZ,EAAiB,EAiBhB,SAAS,EAAW,CAAC,EAAsB,EAAsC,CACpF,IAAM,EAAsB,CAAC,CAAE,KAAM,QAAS,KAAM,EAAK,EAAO,MAAO,CAAK,CAAE,CAAC,EAKzE,EACF,EAAO,QAAU,OACX,EAAO,QACP,CAAC,GAAG,EAAO,MAAM,OAAO,IAAY,EAAO,MAAM,QAAS,EAAO,OAAO,EACnE,OAAO,CAAC,IAAS,IAAS,EAAE,EAC5B,KAAK,CAAS,EAC7B,GAAI,IAAU,GAAI,EAAM,KAAK,CAAE,KAAM,UAAW,K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AAqB,CAAE,IAAK,IAAK,KAAM,MAAO,EAqB3D,SAAS,CAAK,CAAC,EAA8B,EAA0B,CACnE,OAAO,IAAa,QAAa,GAAY,EAAI,EAAW,EAGzD,SAAS,CAAa,CAAC,EAA6B,EAA0B,CACjF,OAAO,KAAK,IAAI,GAAoB,KAAK,IAAI,GAAoB,EAAM,EAAS,CAAQ,CAAC,CAAC,EAGvF,SAAS,EAAU,CAAC,EAA0B,EAA0B,CAC3E,OAAO,KAAK,IACR,GACA,KAAK,IAAI,GAAiB,EAAM,EAAM,CAAQ,EAAI,EAAkB,CACxE",
8
- "debugId": "E778705D26BA7DC464756E2164756E21",
8
+ "debugId": "CCA62814AD4503FC64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{e,t}from"./index-2cvtz0fy.js";import{Tt,le,_t,$t,xo}from"./index-yr25dnf5.js";class se extends t{static ERROR_NAME="UsageError"}function D(n,s){let i=Array.from({length:s.length+1},(r,f)=>f);for(let r=1;r<=n.length;r+=1){let f=[r];for(let u=1;u<=s.length;u+=1){let h=(i[u-1]??0)+(n[r-1]===s[u-1]?0:1),c=(f[u-1]??0)+1,b=(i[u]??0)+1;f.push(Math.min(h,c,b))}i=f}return i[s.length]??Math.max(n.length,s.length)}function R(n,s){let i,r=Number.POSITIVE_INFINITY;for(let f of s){let u=D(n,f);if(u<r)r=u,i=f}return i!==void 0&&r<=Math.max(2,Math.floor(n.length/3))?i:void 0}class N{#e;#t;constructor(n,s){this.#e=n,this.#t=s}#n(n,s){let i=this.#t.get(n);if(i===void 0)throw new se({code:"cli_flag_not_declared",message:`No flag "${n}" 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(i.kind!==s)throw new se({code:"cli_flag_kind_mismatch",message:`Flag "${n}" is declared as ${i.kind} but was read as ${s}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(n)}str(n){let s=this.#n(n,"string");return typeof s==="string"?s:void 0}num(n){let s=this.#n(n,"number");return typeof s==="number"?s:void 0}bool(n){return this.#n(n,"boolean")===!0}has(n){return this.#e.has(n)}}function g(n,s,i,r){return r===void 0?{code:n,message:s,hint:i}:{code:n,message:s,hint:i,field:r}}function v(n){let s=n[0];return new se({code:"cli_usage",message:n.length===1&&s!==void 0?s.message:`${n.length} problems with the command line.`,hint:n.length===1&&s!==void 0?s.hint:"Each problem below names the flag and its fix.",...s?.field===void 0?{}:{field:s.field},details:n})}function E(n,s,i){let r=Number(s);if(s.trim()===""||!Number.isFinite(r))return g("cli_flag_not_a_number",`${i} expects a number, got ${JSON.stringify(s)}.`,`Pass a number, as in ${i} 50. The old parser silently used the default here, which made a typo look like it worked.`,i);if(n.integer===!0&&!Number.isInteger(r))return g("cli_flag_not_an_integer",`${i} expects a whole number, got ${s}.`,`Drop the fractional part: ${i} ${Math.trunc(r)}.`,i);if(n.min!==void 0&&r<n.min)return g("cli_flag_below_min",`${i} must be at least ${n.min}, got ${r}.`,`Pass ${n.min} or more.`,i);return r}function Mr(n){let s=n[0];if(s===void 0)return{kind:"usage"};if(s.startsWith("-")){let a=new Set(Tt.flatMap((o)=>o.short===void 0?[`--${o.name}`]:[`--${o.name}`,`-${o.short}`])),l=n.filter((o)=>!a.has(o));if(l.length>0)throw v([g("cli_no_command","No command given.",`Run \`${e.slug} --help\` for the command list. Commands are ${le.map((o)=>o.name).join(", ")}.`,l[0])]);if(n.includes("--version")||n.includes("-v"))return{kind:"version"};if(n.includes("--help")||n.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let i=_t(s);if(i===void 0){let a=R(s,le.map((l)=>l.name));throw v([g("cli_unknown_command",`Unknown command "${s}".`,a===void 0?`Run \`${e.slug} --help\` for the command list.`:`Did you mean "${a}"? Run \`${e.slug} --help\` for the full list.`,s)])}let r=new Map($t(i).map((a)=>[a.name,a])),f=new Map($t(i).filter((a)=>a.short!==void 0).map((a)=>[a.short,a])),u=new Map,h=[],c=[],b=!1,F=(a,l,o)=>{if(l===""){c.push(g("cli_flag_empty_value",`${o} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",o));return}if(a.kind==="number"){let d=E(a,l,o);if(typeof d==="number")u.set(a.name,d);else c.push(d);return}u.set(a.name,l)};for(let a=1;a<n.length;a+=1){let l=n[a];if(l===void 0)continue;if(b){h.push(l);continue}if(l==="--"){b=!0;continue}if(l.startsWith("--")){let o=l.slice(2),d=o.indexOf("="),p=d===-1?o:o.slice(0,d),m=r.get(p);if(m===void 0){let y=xo(p,i.name),M=R(p,[...r.keys()]);c.push(g(y.length>0?"cli_flag_wrong_command":"cli_unknown_flag",y.length>0?`${i.name} does not accept --${p}.`:`Unknown flag --${p}.`,y.length>0?`--${p} is accepted by: ${y.join(", ")}.`:M===void 0?`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`:`Did you mean --${M}?`,`--${p}`));continue}let _=`--${p}`;if(m.kind==="boolean"){if(d!==-1){c.push(g("cli_flag_takes_no_value",`${_} is a switch and takes no value.`,`Drop the "=${o.slice(d+1)}" — pass ${_} on its own.`,_));continue}u.set(m.name,!0);continue}if(d!==-1){F(m,o.slice(d+1),_);continue}let k=n[a+1];if(m.bare!==void 0&&(k===void 0||k.startsWith("-"))){u.set(m.name,m.bare);continue}if(k===void 0){c.push(g("cli_flag_needs_value",`${_} needs a value.`,`Pass one, as in ${_} <${m.placeholder??"value"}>.`,_));continue}F(m,k,_),a+=1;continue}if(l.startsWith("-")&&l.length>1){for(let o of[...l.slice(1)]){let d=f.get(o);if(d===void 0){c.push(g("cli_unknown_flag",`Unknown flag -${o}.`,`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`,`-${o}`));continue}if(d.kind!=="boolean"){c.push(g("cli_short_flag_needs_value",`-${o} takes a value and cannot be bundled.`,`Write it on its own: --${d.name} <${d.placeholder??"value"}>.`,`-${o}`));continue}u.set(d.name,!0)}continue}h.push(l)}let w=new N(u,r);if(w.bool("help"))return{kind:"help",command:i};if(w.bool("version"))return{kind:"version"};let S=i.args.some((a)=>a.variadic===!0),x=i.args.filter((a)=>a.required);if(c.length>0)throw v(c);else if(h.length<x.length){let a=x[h.length];c.push(g("cli_missing_argument",`${i.name} needs ${a===void 0?"another argument":`a ${a.name}`}.`,`Usage: ${e.slug} ${i.name} ${i.args.map((l)=>`<${l.name}${l.variadic===!0?"...":""}>`).join(" ")}`))}else if(!S&&h.length>i.args.length){let a=h.slice(i.args.length);c.push(g("cli_unexpected_argument",`${i.name} takes ${i.args.length} argument(s), got ${h.length}.`,i.unexpectedArgHint??`Unexpected: ${a.join(" ")}. Quote a value containing spaces.`))}if(c.length>0)throw v(c);return{kind:"command",parsed:{command:i,positionals:h,flags:w}}}
3
- export{se,Mr};
2
+ import{e,t}from"./index-tv4yv7d2.js";import{Rt,le,It,Ot,Ao}from"./index-whaw4b18.js";class se extends t{static ERROR_NAME="UsageError"}function D(n,s){let i=Array.from({length:s.length+1},(r,f)=>f);for(let r=1;r<=n.length;r+=1){let f=[r];for(let u=1;u<=s.length;u+=1){let h=(i[u-1]??0)+(n[r-1]===s[u-1]?0:1),c=(f[u-1]??0)+1,b=(i[u]??0)+1;f.push(Math.min(h,c,b))}i=f}return i[s.length]??Math.max(n.length,s.length)}function R(n,s){let i,r=Number.POSITIVE_INFINITY;for(let f of s){let u=D(n,f);if(u<r)r=u,i=f}return i!==void 0&&r<=Math.max(2,Math.floor(n.length/3))?i:void 0}class N{#e;#t;constructor(n,s){this.#e=n,this.#t=s}#n(n,s){let i=this.#t.get(n);if(i===void 0)throw new se({code:"cli_flag_not_declared",message:`No flag "${n}" 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(i.kind!==s)throw new se({code:"cli_flag_kind_mismatch",message:`Flag "${n}" is declared as ${i.kind} but was read as ${s}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(n)}str(n){let s=this.#n(n,"string");return typeof s==="string"?s:void 0}num(n){let s=this.#n(n,"number");return typeof s==="number"?s:void 0}bool(n){return this.#n(n,"boolean")===!0}has(n){return this.#e.has(n)}}function g(n,s,i,r){return r===void 0?{code:n,message:s,hint:i}:{code:n,message:s,hint:i,field:r}}function v(n){let s=n[0];return new se({code:"cli_usage",message:n.length===1&&s!==void 0?s.message:`${n.length} problems with the command line.`,hint:n.length===1&&s!==void 0?s.hint:"Each problem below names the flag and its fix.",...s?.field===void 0?{}:{field:s.field},details:n})}function E(n,s,i){let r=Number(s);if(s.trim()===""||!Number.isFinite(r))return g("cli_flag_not_a_number",`${i} expects a number, got ${JSON.stringify(s)}.`,`Pass a number, as in ${i} 50. The old parser silently used the default here, which made a typo look like it worked.`,i);if(n.integer===!0&&!Number.isInteger(r))return g("cli_flag_not_an_integer",`${i} expects a whole number, got ${s}.`,`Drop the fractional part: ${i} ${Math.trunc(r)}.`,i);if(n.min!==void 0&&r<n.min)return g("cli_flag_below_min",`${i} must be at least ${n.min}, got ${r}.`,`Pass ${n.min} or more.`,i);return r}function jr(n){let s=n[0];if(s===void 0)return{kind:"usage"};if(s.startsWith("-")){let a=new Set(Rt.flatMap((o)=>o.short===void 0?[`--${o.name}`]:[`--${o.name}`,`-${o.short}`])),l=n.filter((o)=>!a.has(o));if(l.length>0)throw v([g("cli_no_command","No command given.",`Run \`${e.slug} --help\` for the command list. Commands are ${le.map((o)=>o.name).join(", ")}.`,l[0])]);if(n.includes("--version")||n.includes("-v"))return{kind:"version"};if(n.includes("--help")||n.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let i=It(s);if(i===void 0){let a=R(s,le.map((l)=>l.name));throw v([g("cli_unknown_command",`Unknown command "${s}".`,a===void 0?`Run \`${e.slug} --help\` for the command list.`:`Did you mean "${a}"? Run \`${e.slug} --help\` for the full list.`,s)])}let r=new Map(Ot(i).map((a)=>[a.name,a])),f=new Map(Ot(i).filter((a)=>a.short!==void 0).map((a)=>[a.short,a])),u=new Map,h=[],c=[],b=!1,F=(a,l,o)=>{if(l===""){c.push(g("cli_flag_empty_value",`${o} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",o));return}if(a.kind==="number"){let d=E(a,l,o);if(typeof d==="number")u.set(a.name,d);else c.push(d);return}u.set(a.name,l)};for(let a=1;a<n.length;a+=1){let l=n[a];if(l===void 0)continue;if(b){h.push(l);continue}if(l==="--"){b=!0;continue}if(l.startsWith("--")){let o=l.slice(2),d=o.indexOf("="),p=d===-1?o:o.slice(0,d),m=r.get(p);if(m===void 0){let y=Ao(p,i.name),M=R(p,[...r.keys()]);c.push(g(y.length>0?"cli_flag_wrong_command":"cli_unknown_flag",y.length>0?`${i.name} does not accept --${p}.`:`Unknown flag --${p}.`,y.length>0?`--${p} is accepted by: ${y.join(", ")}.`:M===void 0?`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`:`Did you mean --${M}?`,`--${p}`));continue}let _=`--${p}`;if(m.kind==="boolean"){if(d!==-1){c.push(g("cli_flag_takes_no_value",`${_} is a switch and takes no value.`,`Drop the "=${o.slice(d+1)}" — pass ${_} on its own.`,_));continue}u.set(m.name,!0);continue}if(d!==-1){F(m,o.slice(d+1),_);continue}let k=n[a+1];if(m.bare!==void 0&&(k===void 0||k.startsWith("-"))){u.set(m.name,m.bare);continue}if(k===void 0){c.push(g("cli_flag_needs_value",`${_} needs a value.`,`Pass one, as in ${_} <${m.placeholder??"value"}>.`,_));continue}F(m,k,_),a+=1;continue}if(l.startsWith("-")&&l.length>1){for(let o of[...l.slice(1)]){let d=f.get(o);if(d===void 0){c.push(g("cli_unknown_flag",`Unknown flag -${o}.`,`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`,`-${o}`));continue}if(d.kind!=="boolean"){c.push(g("cli_short_flag_needs_value",`-${o} takes a value and cannot be bundled.`,`Write it on its own: --${d.name} <${d.placeholder??"value"}>.`,`-${o}`));continue}u.set(d.name,!0)}continue}h.push(l)}let w=new N(u,r);if(w.bool("help"))return{kind:"help",command:i};if(w.bool("version"))return{kind:"version"};let S=i.args.some((a)=>a.variadic===!0),x=i.args.filter((a)=>a.required);if(c.length>0)throw v(c);else if(h.length<x.length){let a=x[h.length];c.push(g("cli_missing_argument",`${i.name} needs ${a===void 0?"another argument":`a ${a.name}`}.`,`Usage: ${e.slug} ${i.name} ${i.args.map((l)=>`<${l.name}${l.variadic===!0?"...":""}>`).join(" ")}`))}else if(!S&&h.length>i.args.length){let a=h.slice(i.args.length);c.push(g("cli_unexpected_argument",`${i.name} takes ${i.args.length} argument(s), got ${h.length}.`,i.unexpectedArgHint??`Unexpected: ${a.join(" ")}. Quote a value containing spaces.`))}if(c.length>0)throw v(c);return{kind:"command",parsed:{command:i,positionals:h,flags:w}}}
3
+ export{se,jr};
4
4
 
5
- //# debugId=551D946DD0BBD8DC64756E2164756E21
6
- //# sourceMappingURL=index-6b7qvh1x.js.map
5
+ //# debugId=EAE3DB2145C6B8F464756E2164756E21
6
+ //# sourceMappingURL=index-hwpvhaza.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,OAChB,YAAa,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,CAAC,EAC3E,EACA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AAG,MAAM,EAAM,CAAM,EAEzC,MAAO,CAAE,KAAM,UAAW,OAAQ,CAAE,UAAS,cAAa,OAAM,CAAE",
8
- "debugId": "551D946DD0BBD8DC64756E2164756E21",
8
+ "debugId": "EAE3DB2145C6B8F464756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{Lo}from"./index-9d011p3q.js";import{jo}from"./index-jk0def33.js";import{Yo,Ar}from"./index-my5cjx00.js";var D={value:"",cursor:0,history:[],historyOffset:0,draft:"",past:[],future:[],search:void 0,anchor:void 0};function c(r){return[...r]}function u(r,e){return Math.max(0,Math.min(r,e))}function h(r){return{value:r.value,cursor:r.cursor}}function d(r,e){let n=r.past.at(-1);if(e.coalesce&&n!==void 0&&r.future.length===0)return{...r,future:[]};if(n!==void 0&&n.value===r.value)return{...r,future:[]};return{...r,past:[...r.past,h(r)].slice(-Ar),future:[]}}function a(r,e){return{...r,value:e,cursor:c(e).length}}function k(r,e){let n=d(r,{coalesce:!e.includes(`
2
+ import{zo}from"./index-3g3ny01d.js";import{Wo}from"./index-d4x6yvqh.js";import{ts,Cr}from"./index-vgc3y3rm.js";var D={value:"",cursor:0,history:[],historyOffset:0,draft:"",past:[],future:[],search:void 0,anchor:void 0};function c(r){return[...r]}function u(r,e){return Math.max(0,Math.min(r,e))}function h(r){return{value:r.value,cursor:r.cursor}}function d(r,e){let n=r.past.at(-1);if(e.coalesce&&n!==void 0&&r.future.length===0)return{...r,future:[]};if(n!==void 0&&n.value===r.value)return{...r,future:[]};return{...r,past:[...r.past,h(r)].slice(-Cr),future:[]}}function a(r,e){return{...r,value:e,cursor:c(e).length}}function k(r,e){let n=d(r,{coalesce:!e.includes(`
3
3
  `)}),o=c(n.value),t=u(n.cursor,o.length),i=[...o.slice(0,t),...c(e),...o.slice(t)];return{...n,value:i.join(""),cursor:t+c(e).length}}function E(r){let e=c(r.value),n=u(r.cursor,e.length);if(n===0)return r;let o=d(r,{coalesce:!1}),t=[...e.slice(0,n-1),...e.slice(n)];return{...o,value:t.join(""),cursor:n-1}}function y(r){let e=c(r.value),n=u(r.cursor,e.length);if(n>=e.length)return r;return{...d(r,{coalesce:!1}),value:[...e.slice(0,n),...e.slice(n+1)].join("")}}function f(r){return r===void 0||/\s/.test(r)}function v(r,e){let n=e;while(n>0&&f(r[n-1]))n-=1;while(n>0&&!f(r[n-1]))n-=1;return n}function b(r,e){let n=e;while(n<r.length&&f(r[n]))n+=1;while(n<r.length&&!f(r[n]))n+=1;return n}function x(r){let e=c(r.value),n=v(e,u(r.cursor,e.length));if(n===r.cursor)return r;return{...d(r,{coalesce:!1}),value:[...e.slice(0,n),...e.slice(r.cursor)].join(""),cursor:n}}function A(r){let e=c(r.value),n=u(r.cursor,e.length),o=b(e,n);if(o===n)return r;return{...d(r,{coalesce:!1}),value:[...e.slice(0,n),...e.slice(o)].join("")}}function l(r,e){let n=c(r),o=u(e,n.length),t=o;while(t>0&&n[t-1]!==`
4
4
  `)t-=1;let i=o;while(i<n.length&&n[i]!==`
5
- `)i+=1;return{start:t,end:i}}function nr(r){let e=c(r.value),n=u(r.cursor,e.length),o=e.slice(0,n),{start:t}=l(r.value,n);return{line:o.filter((i)=>i===`
5
+ `)i+=1;return{start:t,end:i}}function ar(r){let e=c(r.value),n=u(r.cursor,e.length),o=e.slice(0,n),{start:t}=l(r.value,n);return{line:o.filter((i)=>i===`
6
6
  `).length,lines:e.filter((i)=>i===`
7
- `).length+1,column:n-t}}function p(r,e){let n=c(r.value),o=u(r.cursor,n.length),t=l(r.value,o),i=o-t.start;if(e<0){if(t.start===0)return r;let m=l(r.value,t.start-1);return{...r,cursor:Math.min(m.start+i,m.end)}}if(t.end>=n.length)return r;let s=l(r.value,t.end+1);return{...r,cursor:Math.min(s.start+i,s.end)}}function L(r){if(r.history.length===0)return r;let e=Math.min(r.historyOffset+1,r.history.length),n=r.history[r.history.length-e];if(n===void 0)return r;return a({...d(r,{coalesce:!1}),historyOffset:e,draft:r.historyOffset===0?r.value:r.draft},n)}function I(r){if(r.historyOffset===0)return r;let e=r.historyOffset-1,n=d(r,{coalesce:!1});if(e===0)return a({...n,historyOffset:0},r.draft);let o=r.history[r.history.length-e];return o===void 0?r:a({...n,historyOffset:e},o)}function Mt(r){let e=(r.search?.query??"").toLowerCase(),n=new Set,o=[];for(let t=r.history.length-1;t>=0;t-=1){let i=r.history[t];if(i===void 0||n.has(i))continue;if(e===""||i.toLowerCase().includes(e))n.add(i),o.push(i)}return o}function C(r){let e=Mt(r);return e[u(r.search?.index??0,Math.max(0,e.length-1))]}function g(r,e){let n=r.search;if(n===void 0)return r;let o=Mt(r);if(o.length===0)return r;return{...r,search:{...n,index:u(n.index+e,o.length-1)}}}function T(r,e){let n=r.search;if(n===void 0)return r;return{...r,search:{query:n.query+e,index:0}}}function M(r){let e=r.search;if(e===void 0)return r;let n=c(e.query).slice(0,-1).join("");return{...r,search:{query:n,index:0}}}function O(r){let e=C(r);if(e===void 0)return{...r,search:void 0};return a({...d(r,{coalesce:!1}),search:void 0},e)}function K(r){let e=r.past.at(-1);if(e===void 0)return r;return{...r,value:e.value,cursor:u(e.cursor,c(e.value).length),past:r.past.slice(0,-1),future:[h(r),...r.future],historyOffset:0}}function j(r){let e=r.future[0];if(e===void 0)return r;return{...r,value:e.value,cursor:u(e.cursor,c(e.value).length),past:[...r.past,h(r)].slice(-Ar),future:r.future.slice(1)}}function gt(r){if(r.anchor===void 0||r.anchor===r.cursor)return;return r.anchor<r.cursor?{start:r.anchor,end:r.cursor}:{start:r.cursor,end:r.anchor}}function w(r){let e=gt(r);if(e===void 0)return{...r,anchor:void 0};let n=c(r.value);return{...d(r,{coalesce:!1}),value:[...n.slice(0,e.start),...n.slice(e.end)].join(""),cursor:e.start,anchor:void 0}}function R(r){return r.kind==="insert"||r.kind==="newline"||r.kind==="backspace"||r.kind==="delete"}function X(r,e){if(r.search===void 0&&R(e)&&gt(r)!==void 0){let o=w(r);if(e.kind==="backspace"||e.kind==="delete")return o;return X(o,e)}if(e.kind==="extend"){let o=r.anchor??r.cursor;return{...X({...r,anchor:void 0},{kind:e.to}),anchor:o}}if(e.kind==="cutSelection")return w(r);if(e.kind==="copySelection")return r;if(e.kind==="selectAll")return{...r,anchor:0,cursor:c(r.value).length};let n=W(r,e);return n.anchor===void 0?n:{...n,anchor:void 0}}function W(r,e){if(r.search!==void 0)switch(e.kind){case"insert":return T(r,e.text);case"backspace":return M(r);case"historyPrev":case"lineUp":return g(r,1);case"historyNext":case"lineDown":return g(r,-1);case"searchAccept":return O(r);case"searchCancel":return{...r,search:void 0};case"searchOpen":return r;default:return{...r,search:void 0}}switch(e.kind){case"insert":return k(r,e.text);case"newline":return k(r,`
8
- `);case"backspace":return E(r);case"delete":return y(r);case"cursorLeft":return{...r,cursor:u(r.cursor-1,c(r.value).length)};case"cursorRight":return{...r,cursor:u(r.cursor+1,c(r.value).length)};case"cursorHome":return{...r,cursor:l(r.value,r.cursor).start};case"cursorEnd":return{...r,cursor:l(r.value,r.cursor).end};case"bufferStart":return{...r,cursor:0};case"bufferEnd":return{...r,cursor:c(r.value).length};case"wordLeft":return{...r,cursor:v(c(r.value),r.cursor)};case"wordRight":return{...r,cursor:b(c(r.value),r.cursor)};case"lineUp":return p(r,-1);case"lineDown":return p(r,1);case"killToStart":{let{start:n}=l(r.value,r.cursor);if(n===r.cursor)return r;let o=c(r.value);return{...d(r,{coalesce:!1}),value:[...o.slice(0,n),...o.slice(r.cursor)].join(""),cursor:n}}case"killToEnd":{let{end:n}=l(r.value,r.cursor);if(n===r.cursor)return r;let o=c(r.value);return{...d(r,{coalesce:!1}),value:[...o.slice(0,r.cursor),...o.slice(n)].join("")}}case"killWord":return x(r);case"killWordForward":return A(r);case"historyPrev":return L(r);case"historyNext":return I(r);case"undo":return K(r);case"redo":return j(r);case"searchOpen":return{...r,search:{query:"",index:0}};case"searchAccept":case"searchCancel":case"submit":case"cancel":case"exit":case"arm":case"scroll":case"pointer":case"reasoning":case"paste":case"none":return r;case"extend":case"selectAll":case"copySelection":case"cutSelection":return r}}function Po(r){let e=r.value.trim();if(e==="")return{text:"",state:{...D,history:r.history}};let o=r.history.at(-1)===e?r.history:[...r.history,e].slice(-Yo);return{text:e,state:{...D,history:o}}}function mn(r,e,n={}){let{line:o,lines:t}=nr(r);return{busy:e,empty:r.value==="",firstLine:o===0,lastLine:o===t-1,searching:r.search!==void 0,armed:n.armed??!1,scrolled:n.scrolled??!1}}function H(r,e){switch(r){case"c":if(e.searching)return{kind:"searchCancel"};if(e.busy)return{kind:"cancel"};return e.armed?{kind:"exit"}:{kind:"arm"};case"d":return e.empty?{kind:"exit"}:{kind:"delete"};case"a":return{kind:"cursorHome"};case"e":return{kind:"cursorEnd"};case"b":return{kind:"cursorLeft"};case"f":return{kind:"cursorRight"};case"u":return{kind:"killToStart"};case"k":return{kind:"killToEnd"};case"w":return{kind:"killWord"};case"p":return{kind:"historyPrev"};case"n":return{kind:"historyNext"};case"r":return{kind:"searchOpen"};case"o":return{kind:"reasoning"};case"z":return{kind:"undo"};case"y":return{kind:"redo"};default:return{kind:"none"}}}function Lt(r,e,n){let o=jo(r);if(o!==void 0){if(o.rows!==0)return{kind:"scroll",move:o.rows<0?"up":"down",times:Math.abs(o.rows)};if(o.at!==void 0&&o.kind!==void 0&&o.kind!=="wheel")return{kind:"pointer",gesture:o.kind,column:o.at.column,row:o.at.row,shift:o.shift===!0};return{kind:"none"}}if(e.eventType==="release")return{kind:"none"};if(e.shift){let i=B(e);if(i!==void 0)return{kind:"extend",to:i}}if(e.super){if(e.leftArrow)return{kind:"cursorHome"};if(e.rightArrow)return{kind:"cursorEnd"};if(e.upArrow)return{kind:"bufferStart"};if(e.downArrow)return{kind:"bufferEnd"};if(e.backspace)return{kind:"killToStart"};if(e.delete)return{kind:"killToEnd"};if(r==="z")return e.shift?{kind:"redo"}:{kind:"undo"};if(r==="a")return{kind:"selectAll"};if(r==="c")return{kind:"copySelection"};if(r==="x")return{kind:"cutSelection"};return{kind:"none"}}if(Lo(r))return{kind:"none"};if(e.ctrl&&e.leftArrow)return{kind:"wordLeft"};if(e.ctrl&&e.rightArrow)return{kind:"wordRight"};if(e.ctrl&&e.backspace)return{kind:"killWord"};if(e.ctrl)return H(r.toLowerCase(),n);if(e.meta){if(e.return)return{kind:"newline"};if(e.pageUp)return{kind:"scroll",move:"top"};if(e.pageDown)return{kind:"scroll",move:"bottom"};if(e.upArrow)return{kind:"scroll",move:"up"};if(e.downArrow)return{kind:"scroll",move:"down"};if(e.leftArrow||r==="b")return{kind:"wordLeft"};if(e.rightArrow||r==="f")return{kind:"wordRight"};if(e.backspace)return{kind:"killWord"};if(r==="d")return{kind:"killWordForward"};if(r==="r")return{kind:"reasoning"};return{kind:"none"}}if(e.return&&e.shift)return{kind:"newline"};if(e.pageUp)return{kind:"scroll",move:"pageUp"};if(e.pageDown)return{kind:"scroll",move:"pageDown"};if(e.home)return{kind:"cursorHome"};if(e.end)return{kind:"cursorEnd"};if(e.return)return n.searching?{kind:"searchAccept"}:{kind:"submit"};if(e.backspace)return{kind:"backspace"};if(e.delete)return{kind:"delete"};if(e.leftArrow)return{kind:"cursorLeft"};if(e.rightArrow)return{kind:"cursorRight"};if(e.upArrow)return n.searching||n.firstLine?{kind:"historyPrev"}:{kind:"lineUp"};if(e.downArrow)return n.searching||n.lastLine?{kind:"historyNext"}:{kind:"lineDown"};if(e.escape){if(n.searching)return{kind:"searchCancel"};return n.scrolled?{kind:"scroll",move:"bottom"}:{kind:"none"}}if(e.tab)return{kind:"none"};if(r==="")return{kind:"none"};if(r==="\x1B[H"||r==="\x1B[1~")return{kind:"cursorHome"};if(r==="\x1B[F"||r==="\x1B[4~")return{kind:"cursorEnd"};if(/[\r\n]/.test(r)){let i=r.split(/\r\n|[\r\n]/).map(S),s=i.at(-1)===""&&i.length>1;return{kind:"paste",lines:s?i.slice(0,-1):i,complete:s}}let t=S(r);return t===""?{kind:"none"}:{kind:"insert",text:t}}function B(r){if(r.super){if(r.leftArrow)return"cursorHome";if(r.rightArrow)return"cursorEnd";if(r.upArrow)return"bufferStart";if(r.downArrow)return"bufferEnd";return}if(r.meta||r.ctrl){if(r.leftArrow)return"wordLeft";if(r.rightArrow)return"wordRight";return}if(r.home)return"cursorHome";if(r.end)return"cursorEnd";if(r.leftArrow)return"cursorLeft";if(r.rightArrow)return"cursorRight";if(r.upArrow)return"lineUp";if(r.downArrow)return"lineDown";return}function S(r){return[...r].filter((e)=>{let n=e.codePointAt(0)??0;return n>=32&&n!==127}).join("")}function Dt(r,e){if(e.ctrl)return r.toLowerCase()==="c"||r.toLowerCase()==="d"?{kind:"cancel"}:{kind:"none"};if(e.return)return{kind:"confirm"};if(e.escape)return{kind:"cancel"};if(r===" ")return{kind:"toggle"};if(r==="a")return{kind:"all"};if(r==="n")return{kind:"none-selected"};let n=ye(r,e);return n.kind==="move"?n:{kind:"none"}}function ye(r,e){if(e.ctrl)return r.toLowerCase()==="c"||r.toLowerCase()==="d"?{kind:"exit"}:{kind:"none"};if(e.return)return{kind:"choose"};if(e.escape)return{kind:"back"};if(e.upArrow)return{kind:"move",move:{kind:"up"}};if(e.downArrow)return{kind:"move",move:{kind:"down"}};switch(r){case"k":return{kind:"move",move:{kind:"up"}};case"j":return{kind:"move",move:{kind:"down"}};case"g":return{kind:"move",move:{kind:"first"}};case"G":return{kind:"move",move:{kind:"last"}};default:break}if(/^[1-9]$/.test(r))return{kind:"move",move:{kind:"jump",index:Number(r)-1}};return{kind:"none"}}function gn(r,e,n){if(e.ctrl&&r.toLowerCase()==="c")return{kind:"abort"};if(e.escape)return{kind:"back"};if(e.return)return{kind:"commit"};if(n.select)return{kind:"list",intent:ye(r,e)};let o=Lt(r,e,{busy:!1,empty:n.empty,firstLine:!0,lastLine:!0,searching:!1,armed:!1,scrolled:!1});switch(o.kind){case"submit":return{kind:"commit"};case"exit":return{kind:"abort"};case"arm":case"scroll":return{kind:"edit",intent:{kind:"none"}};case"historyPrev":case"historyNext":return{kind:"edit",intent:{kind:"none"}};case"paste":return{kind:"edit",intent:{kind:"insert",text:o.lines[0]??""}};default:return{kind:"edit",intent:o}}}
9
- export{D,nr,Mt,gt,X,Po,mn,Lt,Dt,ye,gn};
7
+ `).length+1,column:n-t}}function p(r,e){let n=c(r.value),o=u(r.cursor,n.length),t=l(r.value,o),i=o-t.start;if(e<0){if(t.start===0)return r;let m=l(r.value,t.start-1);return{...r,cursor:Math.min(m.start+i,m.end)}}if(t.end>=n.length)return r;let s=l(r.value,t.end+1);return{...r,cursor:Math.min(s.start+i,s.end)}}function L(r){if(r.history.length===0)return r;let e=Math.min(r.historyOffset+1,r.history.length),n=r.history[r.history.length-e];if(n===void 0)return r;return a({...d(r,{coalesce:!1}),historyOffset:e,draft:r.historyOffset===0?r.value:r.draft},n)}function I(r){if(r.historyOffset===0)return r;let e=r.historyOffset-1,n=d(r,{coalesce:!1});if(e===0)return a({...n,historyOffset:0},r.draft);let o=r.history[r.history.length-e];return o===void 0?r:a({...n,historyOffset:e},o)}function Ut(r){let e=(r.search?.query??"").toLowerCase(),n=new Set,o=[];for(let t=r.history.length-1;t>=0;t-=1){let i=r.history[t];if(i===void 0||n.has(i))continue;if(e===""||i.toLowerCase().includes(e))n.add(i),o.push(i)}return o}function C(r){let e=Ut(r);return e[u(r.search?.index??0,Math.max(0,e.length-1))]}function g(r,e){let n=r.search;if(n===void 0)return r;let o=Ut(r);if(o.length===0)return r;return{...r,search:{...n,index:u(n.index+e,o.length-1)}}}function T(r,e){let n=r.search;if(n===void 0)return r;return{...r,search:{query:n.query+e,index:0}}}function M(r){let e=r.search;if(e===void 0)return r;let n=c(e.query).slice(0,-1).join("");return{...r,search:{query:n,index:0}}}function O(r){let e=C(r);if(e===void 0)return{...r,search:void 0};return a({...d(r,{coalesce:!1}),search:void 0},e)}function K(r){let e=r.past.at(-1);if(e===void 0)return r;return{...r,value:e.value,cursor:u(e.cursor,c(e.value).length),past:r.past.slice(0,-1),future:[h(r),...r.future],historyOffset:0}}function j(r){let e=r.future[0];if(e===void 0)return r;return{...r,value:e.value,cursor:u(e.cursor,c(e.value).length),past:[...r.past,h(r)].slice(-Cr),future:r.future.slice(1)}}function kt(r){if(r.anchor===void 0||r.anchor===r.cursor)return;return r.anchor<r.cursor?{start:r.anchor,end:r.cursor}:{start:r.cursor,end:r.anchor}}function w(r){let e=kt(r);if(e===void 0)return{...r,anchor:void 0};let n=c(r.value);return{...d(r,{coalesce:!1}),value:[...n.slice(0,e.start),...n.slice(e.end)].join(""),cursor:e.start,anchor:void 0}}function R(r){return r.kind==="insert"||r.kind==="newline"||r.kind==="backspace"||r.kind==="delete"}function V(r,e){if(r.search===void 0&&R(e)&&kt(r)!==void 0){let o=w(r);if(e.kind==="backspace"||e.kind==="delete")return o;return V(o,e)}if(e.kind==="extend"){let o=r.anchor??r.cursor;return{...V({...r,anchor:void 0},{kind:e.to}),anchor:o}}if(e.kind==="cutSelection")return w(r);if(e.kind==="copySelection")return r;if(e.kind==="selectAll")return{...r,anchor:0,cursor:c(r.value).length};let n=W(r,e);return n.anchor===void 0?n:{...n,anchor:void 0}}function W(r,e){if(r.search!==void 0)switch(e.kind){case"insert":return T(r,e.text);case"backspace":return M(r);case"historyPrev":case"lineUp":return g(r,1);case"historyNext":case"lineDown":return g(r,-1);case"searchAccept":return O(r);case"searchCancel":return{...r,search:void 0};case"searchOpen":return r;default:return{...r,search:void 0}}switch(e.kind){case"insert":return k(r,e.text);case"newline":return k(r,`
8
+ `);case"backspace":return E(r);case"delete":return y(r);case"cursorLeft":return{...r,cursor:u(r.cursor-1,c(r.value).length)};case"cursorRight":return{...r,cursor:u(r.cursor+1,c(r.value).length)};case"cursorHome":return{...r,cursor:l(r.value,r.cursor).start};case"cursorEnd":return{...r,cursor:l(r.value,r.cursor).end};case"bufferStart":return{...r,cursor:0};case"bufferEnd":return{...r,cursor:c(r.value).length};case"wordLeft":return{...r,cursor:v(c(r.value),r.cursor)};case"wordRight":return{...r,cursor:b(c(r.value),r.cursor)};case"lineUp":return p(r,-1);case"lineDown":return p(r,1);case"killToStart":{let{start:n}=l(r.value,r.cursor);if(n===r.cursor)return r;let o=c(r.value);return{...d(r,{coalesce:!1}),value:[...o.slice(0,n),...o.slice(r.cursor)].join(""),cursor:n}}case"killToEnd":{let{end:n}=l(r.value,r.cursor);if(n===r.cursor)return r;let o=c(r.value);return{...d(r,{coalesce:!1}),value:[...o.slice(0,r.cursor),...o.slice(n)].join("")}}case"killWord":return x(r);case"killWordForward":return A(r);case"historyPrev":return L(r);case"historyNext":return I(r);case"undo":return K(r);case"redo":return j(r);case"searchOpen":return{...r,search:{query:"",index:0}};case"searchAccept":case"searchCancel":case"submit":case"cancel":case"exit":case"arm":case"scroll":case"pointer":case"reasoning":case"paste":case"none":return r;case"extend":case"selectAll":case"copySelection":case"cutSelection":return r}}function Uo(r){let e=r.value.trim();if(e==="")return{text:"",state:{...D,history:r.history}};let o=r.history.at(-1)===e?r.history:[...r.history,e].slice(-ts);return{text:e,state:{...D,history:o}}}function kn(r,e,n={}){let{line:o,lines:t}=ar(r);return{busy:e,empty:r.value==="",firstLine:o===0,lastLine:o===t-1,searching:r.search!==void 0,armed:n.armed??!1,scrolled:n.scrolled??!1}}function H(r,e){switch(r){case"c":if(e.searching)return{kind:"searchCancel"};if(e.busy)return{kind:"cancel"};return e.armed?{kind:"exit"}:{kind:"arm"};case"d":return e.empty?{kind:"exit"}:{kind:"delete"};case"a":return{kind:"cursorHome"};case"e":return{kind:"cursorEnd"};case"b":return{kind:"cursorLeft"};case"f":return{kind:"cursorRight"};case"u":return{kind:"killToStart"};case"k":return{kind:"killToEnd"};case"w":return{kind:"killWord"};case"p":return{kind:"historyPrev"};case"n":return{kind:"historyNext"};case"r":return{kind:"searchOpen"};case"o":return{kind:"reasoning"};case"z":return{kind:"undo"};case"y":return{kind:"redo"};default:return{kind:"none"}}}function jt(r,e,n){let o=Wo(r);if(o!==void 0){if(o.rows!==0)return{kind:"scroll",move:o.rows<0?"up":"down",times:Math.abs(o.rows)};if(o.at!==void 0&&o.kind!==void 0&&o.kind!=="wheel")return{kind:"pointer",gesture:o.kind,column:o.at.column,row:o.at.row,shift:o.shift===!0};return{kind:"none"}}if(e.eventType==="release")return{kind:"none"};if(e.shift){let i=B(e);if(i!==void 0)return{kind:"extend",to:i}}if(e.super){if(e.leftArrow)return{kind:"cursorHome"};if(e.rightArrow)return{kind:"cursorEnd"};if(e.upArrow)return{kind:"bufferStart"};if(e.downArrow)return{kind:"bufferEnd"};if(e.backspace)return{kind:"killToStart"};if(e.delete)return{kind:"killToEnd"};if(r==="z")return e.shift?{kind:"redo"}:{kind:"undo"};if(r==="a")return{kind:"selectAll"};if(r==="c")return{kind:"copySelection"};if(r==="x")return{kind:"cutSelection"};return{kind:"none"}}if(zo(r))return{kind:"none"};if(e.ctrl&&e.leftArrow)return{kind:"wordLeft"};if(e.ctrl&&e.rightArrow)return{kind:"wordRight"};if(e.ctrl&&e.backspace)return{kind:"killWord"};if(e.ctrl)return H(r.toLowerCase(),n);if(e.meta){if(e.return)return{kind:"newline"};if(e.pageUp)return{kind:"scroll",move:"top"};if(e.pageDown)return{kind:"scroll",move:"bottom"};if(e.upArrow)return{kind:"scroll",move:"up"};if(e.downArrow)return{kind:"scroll",move:"down"};if(e.leftArrow||r==="b")return{kind:"wordLeft"};if(e.rightArrow||r==="f")return{kind:"wordRight"};if(e.backspace)return{kind:"killWord"};if(r==="d")return{kind:"killWordForward"};if(r==="r")return{kind:"reasoning"};return{kind:"none"}}if(e.return&&e.shift)return{kind:"newline"};if(e.pageUp)return{kind:"scroll",move:"pageUp"};if(e.pageDown)return{kind:"scroll",move:"pageDown"};if(e.home)return{kind:"cursorHome"};if(e.end)return{kind:"cursorEnd"};if(e.return)return n.searching?{kind:"searchAccept"}:{kind:"submit"};if(e.backspace)return{kind:"backspace"};if(e.delete)return{kind:"delete"};if(e.leftArrow)return{kind:"cursorLeft"};if(e.rightArrow)return{kind:"cursorRight"};if(e.upArrow)return n.searching||n.firstLine?{kind:"historyPrev"}:{kind:"lineUp"};if(e.downArrow)return n.searching||n.lastLine?{kind:"historyNext"}:{kind:"lineDown"};if(e.escape){if(n.searching)return{kind:"searchCancel"};return n.scrolled?{kind:"scroll",move:"bottom"}:{kind:"none"}}if(e.tab)return{kind:"none"};if(r==="")return{kind:"none"};if(r==="\x1B[H"||r==="\x1B[1~")return{kind:"cursorHome"};if(r==="\x1B[F"||r==="\x1B[4~")return{kind:"cursorEnd"};if(/[\r\n]/.test(r)){let i=r.split(/\r\n|[\r\n]/).map(S),s=i.at(-1)===""&&i.length>1;return{kind:"paste",lines:s?i.slice(0,-1):i,complete:s}}let t=S(r);return t===""?{kind:"none"}:{kind:"insert",text:t}}function B(r){if(r.super){if(r.leftArrow)return"cursorHome";if(r.rightArrow)return"cursorEnd";if(r.upArrow)return"bufferStart";if(r.downArrow)return"bufferEnd";return}if(r.meta||r.ctrl){if(r.leftArrow)return"wordLeft";if(r.rightArrow)return"wordRight";return}if(r.home)return"cursorHome";if(r.end)return"cursorEnd";if(r.leftArrow)return"cursorLeft";if(r.rightArrow)return"cursorRight";if(r.upArrow)return"lineUp";if(r.downArrow)return"lineDown";return}function S(r){return[...r].filter((e)=>{let n=e.codePointAt(0)??0;return n>=32&&n!==127}).join("")}function zt(r,e){if(e.ctrl)return r.toLowerCase()==="c"||r.toLowerCase()==="d"?{kind:"cancel"}:{kind:"none"};if(e.return)return{kind:"confirm"};if(e.escape)return{kind:"cancel"};if(r===" ")return{kind:"toggle"};if(r==="a")return{kind:"all"};if(r==="n")return{kind:"none-selected"};let n=be(r,e);return n.kind==="move"?n:{kind:"none"}}function be(r,e){if(e.ctrl)return r.toLowerCase()==="c"||r.toLowerCase()==="d"?{kind:"exit"}:{kind:"none"};if(e.return)return{kind:"choose"};if(e.escape)return{kind:"back"};if(e.upArrow)return{kind:"move",move:{kind:"up"}};if(e.downArrow)return{kind:"move",move:{kind:"down"}};switch(r){case"k":return{kind:"move",move:{kind:"up"}};case"j":return{kind:"move",move:{kind:"down"}};case"g":return{kind:"move",move:{kind:"first"}};case"G":return{kind:"move",move:{kind:"last"}};default:break}if(/^[1-9]$/.test(r))return{kind:"move",move:{kind:"jump",index:Number(r)-1}};return{kind:"none"}}function Sn(r,e,n){if(e.ctrl&&r.toLowerCase()==="c")return{kind:"abort"};if(e.escape)return{kind:"back"};if(e.return)return{kind:"commit"};if(n.select)return{kind:"list",intent:be(r,e)};let o=jt(r,e,{busy:!1,empty:n.empty,firstLine:!0,lastLine:!0,searching:!1,armed:!1,scrolled:!1});switch(o.kind){case"submit":return{kind:"commit"};case"exit":return{kind:"abort"};case"arm":case"scroll":return{kind:"edit",intent:{kind:"none"}};case"historyPrev":case"historyNext":return{kind:"edit",intent:{kind:"none"}};case"paste":return{kind:"edit",intent:{kind:"insert",text:o.lines[0]??""}};default:return{kind:"edit",intent:o}}}
9
+ export{D,ar,Ut,kt,V,Uo,kn,jt,zt,be,Sn};
10
10
 
11
- //# debugId=812607596C82DE7364756E2164756E21
12
- //# sourceMappingURL=index-6z0yr17z.js.map
11
+ //# debugId=D74D8516B55F9B6964756E2164756E21
12
+ //# sourceMappingURL=index-j55s3ehk.js.map