dispach 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -36
- package/dist/APEv2Parser-ysjr6adv.js +5 -0
- package/dist/{FlacParser-bf8y3e0w.js.map → APEv2Parser-ysjr6adv.js.map} +1 -1
- package/dist/{AiffParser-tbx3xkmk.js → AiffParser-9hj6fpmy.js} +3 -3
- package/dist/{AiffParser-tbx3xkmk.js.map → AiffParser-9hj6fpmy.js.map} +1 -1
- package/dist/App-2f72vhjv.js +11 -0
- package/dist/{App-hjn867nc.js.map → App-2f72vhjv.js.map} +3 -3
- package/dist/{AsfParser-d784ak3y.js → AsfParser-7emspn04.js} +3 -3
- package/dist/{AsfParser-d784ak3y.js.map → AsfParser-7emspn04.js.map} +1 -1
- package/dist/{ConfigEditor-g7eb2wsm.js → ConfigEditor-vk7vxaa6.js} +3 -3
- package/dist/{ConfigEditor-g7eb2wsm.js.map → ConfigEditor-vk7vxaa6.js.map} +1 -1
- package/dist/{DsdiffParser-vxnfx80c.js → DsdiffParser-dz88pnnr.js} +3 -3
- package/dist/{DsdiffParser-vxnfx80c.js.map → DsdiffParser-dz88pnnr.js.map} +1 -1
- package/dist/{DsfParser-0xsh0zzk.js → DsfParser-qgh63tbs.js} +3 -3
- package/dist/{DsfParser-0xsh0zzk.js.map → DsfParser-qgh63tbs.js.map} +1 -1
- package/dist/FlacParser-drm5wq0p.js +5 -0
- package/dist/{APEv2Parser-9wqew3zv.js.map → FlacParser-drm5wq0p.js.map} +1 -1
- package/dist/{KeyProbe-w8c37s9q.js → KeyProbe-5anphmb7.js} +3 -3
- package/dist/{KeyProbe-w8c37s9q.js.map → KeyProbe-5anphmb7.js.map} +1 -1
- package/dist/{MP4Parser-tq7r7wd4.js → MP4Parser-yr7p3z12.js} +3 -3
- package/dist/{MP4Parser-tq7r7wd4.js.map → MP4Parser-yr7p3z12.js.map} +1 -1
- package/dist/{MatroskaParser-a79gsmzb.js → MatroskaParser-jkbsbsk3.js} +3 -3
- package/dist/{MatroskaParser-a79gsmzb.js.map → MatroskaParser-jkbsbsk3.js.map} +1 -1
- package/dist/{MpegParser-zs61b3wq.js → MpegParser-t93vwnew.js} +3 -3
- package/dist/{MpegParser-zs61b3wq.js.map → MpegParser-t93vwnew.js.map} +1 -1
- package/dist/{MusepackParser-bp8dm6nz.js → MusepackParser-6e8kbh2d.js} +3 -3
- package/dist/{MusepackParser-bp8dm6nz.js.map → MusepackParser-6e8kbh2d.js.map} +1 -1
- package/dist/OggParser-ggcypmag.js +5 -0
- package/dist/{OggParser-7pxr1sn9.js.map → OggParser-ggcypmag.js.map} +1 -1
- package/dist/Picker-j7txnm7w.js +5 -0
- package/dist/{Picker-b09hr4tk.js.map → Picker-j7txnm7w.js.map} +1 -1
- package/dist/SessionPicker-hpv2ncsb.js +5 -0
- package/dist/{SessionPicker-wtfxwdxg.js.map → SessionPicker-hpv2ncsb.js.map} +3 -3
- package/dist/SkillBrowser-qc542n71.js +5 -0
- package/dist/{SkillBrowser-p9ht63c7.js.map → SkillBrowser-qc542n71.js.map} +1 -1
- package/dist/{WavPackParser-gpf3r92t.js → WavPackParser-jw9stzqp.js} +3 -3
- package/dist/{WavPackParser-gpf3r92t.js.map → WavPackParser-jw9stzqp.js.map} +1 -1
- package/dist/{WaveParser-3kcak550.js → WaveParser-epmncs9w.js} +3 -3
- package/dist/{WaveParser-3kcak550.js.map → WaveParser-epmncs9w.js.map} +1 -1
- package/dist/WizardApp-pgzcz9zq.js +5 -0
- package/dist/{WizardApp-494018sk.js.map → WizardApp-pgzcz9zq.js.map} +3 -3
- package/dist/{channels-yhdvxxrb.js → channels-m8nambmm.js} +14 -14
- package/dist/{channels-yhdvxxrb.js.map → channels-m8nambmm.js.map} +1 -1
- package/dist/client.d.ts +285 -1
- package/dist/client.js +11 -11
- package/dist/client.js.map +5 -5
- package/dist/components/App.d.ts.map +1 -1
- package/dist/{config-g0ybmm4t.js → config-hmgrqgf2.js} +17 -17
- package/dist/{config-g0ybmm4t.js.map → config-hmgrqgf2.js.map} +1 -1
- package/dist/{credential-pkme1sfe.js → credential-nkb2ya59.js} +5 -5
- package/dist/{credential-pkme1sfe.js.map → credential-nkb2ya59.js.map} +1 -1
- package/dist/{index-q8b1fc3k.js → index-0444sh6x.js} +4 -4
- package/dist/{index-q8b1fc3k.js.map → index-0444sh6x.js.map} +1 -1
- package/dist/{index-ec101x93.js → index-095hrkyr.js} +6 -6
- package/dist/{index-ec101x93.js.map → index-095hrkyr.js.map} +1 -1
- package/dist/index-1mbdz3f7.js +12 -0
- package/dist/{index-3fgq1acj.js.map → index-1mbdz3f7.js.map} +3 -3
- package/dist/index-1x8mzvz7.js +6 -0
- package/dist/{index-f056wkb4.js.map → index-1x8mzvz7.js.map} +1 -1
- package/dist/{index-633eqxry.js → index-22fzzn7z.js} +7 -7
- package/dist/{index-633eqxry.js.map → index-22fzzn7z.js.map} +1 -1
- package/dist/index-2bsardvh.js +5 -0
- package/dist/{index-9dmgk6d3.js.map → index-2bsardvh.js.map} +2 -2
- package/dist/{index-thmq816c.js → index-2zjh5zd5.js} +4 -4
- package/dist/{index-thmq816c.js.map → index-2zjh5zd5.js.map} +1 -1
- package/dist/{index-ad5c9t83.js → index-308y9xt0.js} +4 -4
- package/dist/{index-ad5c9t83.js.map → index-308y9xt0.js.map} +1 -1
- package/dist/{index-t6xnecdx.js → index-323jvr1g.js} +4 -4
- package/dist/{index-t6xnecdx.js.map → index-323jvr1g.js.map} +1 -1
- package/dist/{index-mn34kj95.js → index-3826kf9t.js} +5 -5
- package/dist/{index-mn34kj95.js.map → index-3826kf9t.js.map} +1 -1
- package/dist/index-38gs9anh.js +9 -0
- package/dist/{index-akv6e7ge.js.map → index-38gs9anh.js.map} +1 -1
- package/dist/index-3c5jt6by.js +5 -0
- package/dist/{index-3b3h8kyh.js.map → index-3c5jt6by.js.map} +2 -2
- package/dist/{index-a6mtqkth.js → index-3vzf253k.js} +7 -7
- package/dist/{index-a6mtqkth.js.map → index-3vzf253k.js.map} +1 -1
- package/dist/{index-5m9wydxb.js → index-42e29zs4.js} +4 -4
- package/dist/{index-5m9wydxb.js.map → index-42e29zs4.js.map} +1 -1
- package/dist/{index-v7mz396x.js → index-4fj1k64j.js} +4 -4
- package/dist/{index-v7mz396x.js.map → index-4fj1k64j.js.map} +1 -1
- package/dist/{index-s2tzq27a.js → index-51x0n5z0.js} +5 -5
- package/dist/{index-s2tzq27a.js.map → index-51x0n5z0.js.map} +1 -1
- package/dist/index-836hc2h1.js +6 -0
- package/dist/{index-xa9crtzq.js.map → index-836hc2h1.js.map} +2 -2
- package/dist/index-8edck2pr.js +6 -0
- package/dist/{index-7gsbzvnc.js.map → index-8edck2pr.js.map} +1 -1
- package/dist/index-8tmv33mr.js +6 -0
- package/dist/{index-vw2hf4d8.js.map → index-8tmv33mr.js.map} +1 -1
- package/dist/index-9t4dz145.js +8 -0
- package/dist/{index-0mz7wpbw.js.map → index-9t4dz145.js.map} +2 -2
- package/dist/{index-81vj1bxe.js → index-bqdkm3de.js} +4 -4
- package/dist/{index-81vj1bxe.js.map → index-bqdkm3de.js.map} +1 -1
- package/dist/index-djeqvfms.js +74 -0
- package/dist/index-djeqvfms.js.map +13 -0
- package/dist/{index-307qmvb0.js → index-dpcm1j62.js} +28 -28
- package/dist/{index-307qmvb0.js.map → index-dpcm1j62.js.map} +1 -1
- package/dist/index-dv9pdjy4.js +429 -0
- package/dist/index-dv9pdjy4.js.map +12 -0
- package/dist/{index-j20k6k0m.js → index-dzy19wtf.js} +4 -4
- package/dist/{index-j20k6k0m.js.map → index-dzy19wtf.js.map} +1 -1
- package/dist/{index-9qv87rq7.js → index-eztfverw.js} +7 -7
- package/dist/{index-9qv87rq7.js.map → index-eztfverw.js.map} +1 -1
- package/dist/{index-myg5enf5.js → index-fbsrhcga.js} +4 -4
- package/dist/{index-myg5enf5.js.map → index-fbsrhcga.js.map} +1 -1
- package/dist/{index-6r9h7ftn.js → index-fxpmx6cr.js} +117 -117
- package/dist/index-fxpmx6cr.js.map +21 -0
- package/dist/{index-ye2yb3xf.js → index-hgm2gchq.js} +6 -6
- package/dist/{index-ye2yb3xf.js.map → index-hgm2gchq.js.map} +1 -1
- package/dist/index-hpvfqq6r.js +1252 -0
- package/dist/{index-26ejkp8q.js.map → index-hpvfqq6r.js.map} +30 -26
- package/dist/{index-y34s71qe.js → index-hrwakb11.js} +3 -3
- package/dist/{index-y34s71qe.js.map → index-hrwakb11.js.map} +1 -1
- package/dist/{index-qh82wtpa.js → index-jc4kmfwa.js} +4 -4
- package/dist/{index-qh82wtpa.js.map → index-jc4kmfwa.js.map} +1 -1
- package/dist/{index-twcgf73h.js → index-jff5q27j.js} +4 -4
- package/dist/{index-twcgf73h.js.map → index-jff5q27j.js.map} +1 -1
- package/dist/index-k8e9f466.js +110 -0
- package/dist/index-k8e9f466.js.map +13 -0
- package/dist/{index-trx9xb59.js → index-m6fqx0ch.js} +7 -7
- package/dist/{index-trx9xb59.js.map → index-m6fqx0ch.js.map} +1 -1
- package/dist/{index-ac2wzspd.js → index-mjfv7k5w.js} +4 -4
- package/dist/{index-ac2wzspd.js.map → index-mjfv7k5w.js.map} +1 -1
- package/dist/index-nvc24414.js +6 -0
- package/dist/{index-1f1erzfx.js.map → index-nvc24414.js.map} +1 -1
- package/dist/index-nxhqf597.js +6 -0
- package/dist/{index-w97gprre.js.map → index-nxhqf597.js.map} +1 -1
- package/dist/{index-jh2az41t.js → index-p6ya59m6.js} +5 -5
- package/dist/{index-jh2az41t.js.map → index-p6ya59m6.js.map} +1 -1
- package/dist/{index-psk6q25h.js → index-pqw1n1pv.js} +4 -4
- package/dist/{index-psk6q25h.js.map → index-pqw1n1pv.js.map} +1 -1
- package/dist/{index-6c4p19m1.js → index-pszmnhgq.js} +2 -2
- package/dist/index-qgsdgbk8.js +5 -0
- package/dist/{index-wk6andxq.js.map → index-qgsdgbk8.js.map} +2 -2
- package/dist/index-qv6ktepc.js +6 -0
- package/dist/index-qv6ktepc.js.map +10 -0
- package/dist/{index-pdsey1ab.js → index-ry6a4bqh.js} +62 -62
- package/dist/{index-pdsey1ab.js.map → index-ry6a4bqh.js.map} +1 -1
- package/dist/{index-x9z2xnct.js → index-sh44ymqz.js} +5 -5
- package/dist/{index-x9z2xnct.js.map → index-sh44ymqz.js.map} +1 -1
- package/dist/{index-zg89tq04.js → index-snz49ndn.js} +4 -4
- package/dist/{index-zg89tq04.js.map → index-snz49ndn.js.map} +1 -1
- package/dist/{index-zjphh8ch.js → index-xg7s813b.js} +4 -4
- package/dist/{index-zjphh8ch.js.map → index-xg7s813b.js.map} +1 -1
- package/dist/{index-gqaa06yh.js → index-y7dxq4a4.js} +9 -9
- package/dist/{index-gqaa06yh.js.map → index-y7dxq4a4.js.map} +1 -1
- package/dist/index-ytxbw8py.js +63 -0
- package/dist/{index-0pddq849.js.map → index-ytxbw8py.js.map} +2 -2
- package/dist/index-yw3fby4n.js +6 -0
- package/dist/{index-4emtktc0.js.map → index-yw3fby4n.js.map} +2 -2
- package/dist/{index-skkddg44.js → index-zw6wyas6.js} +4 -4
- package/dist/{index-skkddg44.js.map → index-zw6wyas6.js.map} +1 -1
- package/dist/index.js +304 -288
- package/dist/index.js.map +15 -12
- package/dist/init.d.ts.map +1 -1
- package/dist/lib/agent-template.d.ts +5 -0
- package/dist/lib/agent-template.d.ts.map +1 -1
- package/dist/lib/commands.d.ts.map +1 -1
- package/dist/lib/init-flow.d.ts +7 -30
- package/dist/lib/init-flow.d.ts.map +1 -1
- package/dist/lib/owner.d.ts +49 -0
- package/dist/lib/owner.d.ts.map +1 -0
- package/dist/lib/presets.d.ts +44 -0
- package/dist/lib/presets.d.ts.map +1 -0
- package/dist/lib/provision.d.ts +8 -1
- package/dist/lib/provision.d.ts.map +1 -1
- package/dist/lib/relay-client.d.ts +17 -0
- package/dist/lib/relay-client.d.ts.map +1 -0
- package/dist/lib/schema.d.ts +2 -0
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/sessions-view.d.ts +2 -0
- package/dist/lib/sessions-view.d.ts.map +1 -1
- package/dist/lib/source.d.ts +25 -0
- package/dist/lib/source.d.ts.map +1 -1
- package/dist/lib/types.d.ts +8 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/wizard.d.ts.map +1 -1
- package/dist/owner.d.ts +16 -0
- package/dist/owner.d.ts.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/transcript.d.ts.map +1 -1
- package/dist/{web-f6869dy2.js → web-gfv0mzgs.js} +7 -7
- package/dist/{web-f6869dy2.js.map → web-gfv0mzgs.js.map} +1 -1
- package/dist/wire.d.ts +50 -0
- package/dist/wire.js +5 -5
- package/dist/wire.js.map +4 -4
- package/dist/wrapper-f662ny3r.js +5 -0
- package/dist/{wrapper-52c0vacs.js.map → wrapper-f662ny3r.js.map} +1 -1
- package/package.json +4 -1
- package/dist/APEv2Parser-9wqew3zv.js +0 -5
- package/dist/App-hjn867nc.js +0 -11
- package/dist/FlacParser-bf8y3e0w.js +0 -5
- package/dist/OggParser-7pxr1sn9.js +0 -5
- package/dist/Picker-b09hr4tk.js +0 -5
- package/dist/SessionPicker-wtfxwdxg.js +0 -5
- package/dist/SkillBrowser-p9ht63c7.js +0 -5
- package/dist/WizardApp-494018sk.js +0 -5
- package/dist/index-0mz7wpbw.js +0 -8
- package/dist/index-0pddq849.js +0 -63
- package/dist/index-1f1erzfx.js +0 -6
- package/dist/index-26ejkp8q.js +0 -1194
- package/dist/index-3b3h8kyh.js +0 -5
- package/dist/index-3fgq1acj.js +0 -12
- package/dist/index-4emtktc0.js +0 -6
- package/dist/index-4t3p7vm9.js +0 -6
- package/dist/index-4t3p7vm9.js.map +0 -10
- package/dist/index-6r9h7ftn.js.map +0 -21
- package/dist/index-7gsbzvnc.js +0 -6
- package/dist/index-94k4mh6s.js +0 -96
- package/dist/index-94k4mh6s.js.map +0 -13
- package/dist/index-9dmgk6d3.js +0 -5
- package/dist/index-akv6e7ge.js +0 -9
- package/dist/index-f056wkb4.js +0 -6
- package/dist/index-s57ztjhq.js +0 -74
- package/dist/index-s57ztjhq.js.map +0 -13
- package/dist/index-vw2hf4d8.js +0 -6
- package/dist/index-w97gprre.js +0 -6
- package/dist/index-wk6andxq.js +0 -5
- package/dist/index-xa9crtzq.js +0 -6
- package/dist/index-z0dgxd7d.js +0 -429
- package/dist/index-z0dgxd7d.js.map +0 -11
- package/dist/wrapper-52c0vacs.js +0 -5
- /package/dist/{index-6c4p19m1.js.map → index-pszmnhgq.js.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{ea}from"./index-4fj1k64j.js";import{ia}from"./index-dzy19wtf.js";import{Ea,mi}from"./index-8tmv33mr.js";var he={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(-mi),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
|
|
5
|
+
`)i+=1;return{start:t,end:i}}function zo(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
|
|
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
|
|
9
|
-
export{he,
|
|
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 en(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=en(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=en(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(-mi),future:r.future.slice(1)}}function wA(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=wA(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 Ge(r,e){if(r.search===void 0&&R(e)&&wA(r)!==void 0){let o=w(r);if(e.kind==="backspace"||e.kind==="delete")return o;return Ge(o,e)}if(e.kind==="extend"){let o=r.anchor??r.cursor;return{...Ge({...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 xi(r){let e=r.value.trim();if(e==="")return{text:"",state:{...he,history:r.history}};let o=r.history.at(-1)===e?r.history:[...r.history,e].slice(-Ea);return{text:e,state:{...he,history:o}}}function Gn(r,e,n={}){let{line:o,lines:t}=zo(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 D(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 tn(r,e,n){let o=ia(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=H(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(ea(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 D(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 H(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 An(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=mt(r,e);return n.kind==="move"?n:{kind:"none"}}function mt(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 Fn(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:mt(r,e)};let o=tn(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{he,zo,en,wA,Ge,xi,Gn,tn,An,mt,Fn};
|
|
10
10
|
|
|
11
|
-
//# debugId=
|
|
12
|
-
//# sourceMappingURL=index-
|
|
11
|
+
//# debugId=1DB124110DBD055F64756E2164756E21
|
|
12
|
+
//# sourceMappingURL=index-m6fqx0ch.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"/**\n * Keystrokes in, intents out. Pure, and free of any Ink import.\n *\n * The one contract worth stating explicitly, because Phase 1 established and measured it:\n * **Ctrl-C cancels the turn, not the process.** Whether a keystroke means \"cancel\" or \"exit\"\n * depends on whether a turn is in flight, so that decision belongs here — in a function that can be\n * tested against both states — rather than in a component where it can only be tested by hand.\n */\n\nimport { lineInfo } from \"#editor\"\nimport { isTerminalReply } from \"#lib/csi\"\nimport { mouseInput } from \"#lib/mouse\"\nimport type { EditorState, Intent, KeyState, MotionKind } from \"#lib/types\"\n\nexport interface KeyContext {\n /** A turn is in flight. */\n readonly busy: boolean\n /** The input buffer is empty. */\n readonly empty: boolean\n /**\n * The cursor is on the first line, so ↑ means history rather than a line up.\n *\n * Position decides, because a multi-line buffer wants both and every editor resolves it this way:\n * at the top of what you are composing there is nothing above to move to, so the arrow is free to\n * mean the other thing. `^P`/`^N` stay unconditional history for anyone who would rather not think\n * about where the cursor is.\n */\n readonly firstLine: boolean\n readonly lastLine: boolean\n /** `^R` is open, so enter accepts a match and escape closes it. */\n readonly searching: boolean\n /**\n * A first ^C has already been pressed at an idle prompt, so the next one leaves.\n *\n * Held by the caller rather than derived, because it is the one piece of keyboard state with a\n * *clock* attached — it expires — and a pure function cannot own that. What it must not do is\n * decide what an armed ^C means, which is why the flag comes in here and the decision stays below.\n */\n readonly armed: boolean\n /**\n * The transcript window is parked above the newest row, so escape means \"come back down\".\n *\n * Escape had nothing to do at an idle prompt and was claimed as `none` to keep control characters\n * out of the buffer. A scrolled-away view is the one state where a reader plainly wants a way out\n * of where they are, and escape is the key they will press.\n */\n readonly scrolled: boolean\n}\n\n/**\n * The context for a given editor state.\n *\n * Exported and derived in one place so no renderer computes it by hand. `empty` was already this shape\n * — editor state passed to the keymap as context — and the two line flags are the same idea; a caller\n * that got `firstLine` wrong would make the arrows misbehave in a way no test of this module would see.\n */\nexport function keyContext(\n editor: EditorState,\n busy: boolean,\n session: { readonly armed?: boolean; readonly scrolled?: boolean } = {},\n): KeyContext {\n const { line, lines } = lineInfo(editor)\n return {\n busy,\n empty: editor.value === \"\",\n firstLine: line === 0,\n lastLine: line === lines - 1,\n searching: editor.search !== undefined,\n armed: session.armed ?? false,\n scrolled: session.scrolled ?? false,\n }\n}\n\n/** Ctrl-key chords arrive as `key.ctrl` plus the letter in `input`. */\nfunction ctrlIntent(letter: string, context: KeyContext): Intent {\n switch (letter) {\n case \"c\":\n // While a search is open, ^C dismisses it rather than the session: the search is the\n // foreground thing, and quitting the whole session from it would lose a message somebody\n // is part-way through composing.\n if (context.searching) return { kind: \"searchCancel\" }\n // The whole point. Busy means a turn is generating; interrupting it must leave the\n // prompt behind, not the shell.\n if (context.busy) return { kind: \"cancel\" }\n // At an idle prompt it takes two, and the first one says so.\n //\n // One press used to exit, which was defensible while the session left its conversation in\n // the scrollback: ^C landed you back in a shell with the transcript still above it. On the\n // alternate screen the buffer is discarded on the way out, so the same keystroke now throws\n // the visible conversation away — and it is one press away from the chord that means\n // \"cancel this turn\", pressed reflexively when a reply runs long. ^D still leaves in one,\n // for anyone who wants that, and the status line names whichever is live.\n return context.armed ? { kind: \"exit\" } : { kind: \"arm\" }\n case \"d\":\n // Ctrl-D is end-of-input, so it only ends the session when there is nothing to submit.\n // On a line with text it is a forward delete, as in a shell.\n return context.empty ? { kind: \"exit\" } : { kind: \"delete\" }\n case \"a\":\n return { kind: \"cursorHome\" }\n case \"e\":\n return { kind: \"cursorEnd\" }\n case \"b\":\n return { kind: \"cursorLeft\" }\n case \"f\":\n return { kind: \"cursorRight\" }\n case \"u\":\n return { kind: \"killToStart\" }\n case \"k\":\n return { kind: \"killToEnd\" }\n case \"w\":\n return { kind: \"killWord\" }\n case \"p\":\n return { kind: \"historyPrev\" }\n case \"n\":\n return { kind: \"historyNext\" }\n case \"r\":\n return { kind: \"searchOpen\" }\n case \"o\":\n // The same thing ⌥r does, on a chord that cannot fail to arrive.\n //\n // ⌥r needs either the kitty protocol or the terminal's option-as-meta setting; a ctrl letter\n // needs neither, because it is a single control byte every terminal has always sent. Reported\n // as \"⌥r doesn't do anything\", and while the immediate cause was a fold with nothing in it,\n // the standing cause is that a view toggle should not depend on a terminal handshake at all.\n // ^O is what the reference CLI binds its own transcript toggle to, so the habit transfers.\n return { kind: \"reasoning\" }\n case \"z\":\n // Undo, not SIGTSTP. Ink puts stdin in raw mode, so the terminal never generates the\n // signal and the byte arrives here — which makes this a choice rather than an accident.\n // Suspending a chat you can leave with ^D is worth little; undo is worth a lot, and the\n // footer says so, which is what keeps the trade visible.\n return { kind: \"undo\" }\n case \"y\":\n return { kind: \"redo\" }\n default:\n return { kind: \"none\" }\n }\n}\n\nexport function keyToIntent(input: string, key: KeyState, context: KeyContext): Intent {\n // The mouse, before anything else, and unconditionally.\n //\n // Ink has no idea what a mouse report is and hands it over as text: with tracking on, one wheel notch\n // reached the insert branch and typed the report into the message. So every report is claimed here —\n // the wheel becomes a scroll and everything else becomes nothing at all, because a click that falls\n // through is the same bug with a different button.\n const mouse = mouseInput(input)\n if (mouse !== undefined) {\n if (mouse.rows !== 0) {\n return {\n kind: \"scroll\",\n move: mouse.rows < 0 ? \"up\" : \"down\",\n times: Math.abs(mouse.rows),\n }\n }\n // A press, drag or release. Reported rather than resolved: which row of the conversation a cell\n // sits on is a question about the frame, and this function has no frame. Still claimed either way —\n // a report that fell through would be typed into the message, which is the bug this branch exists\n // for and does not stop being one because the gesture is now useful.\n if (mouse.at !== undefined && mouse.kind !== undefined && mouse.kind !== \"wheel\") {\n return {\n kind: \"pointer\",\n gesture: mouse.kind,\n column: mouse.at.column,\n row: mouse.at.row,\n shift: mouse.shift === true,\n }\n }\n return { kind: \"none\" }\n }\n\n // A key *release* is not a keystroke. `reportEventTypes` is on so that `super` survives on an arrow\n // key (Ink's kitty branch requires the `:eventType` field), and the cost is that Ink hands the type\n // through without filtering — so every enhanced key arrives twice, down and up, and every chord would\n // fire twice. Repeats are kept: holding a key down is a real thing to do.\n if (key.eventType === \"release\") return { kind: \"none\" }\n\n // ─── shift extends a selection ───────────────────────────────────────────────────────\n //\n // Before the cmd, ctrl and option blocks, because every one of them would otherwise claim the chord\n // and drop the shift: `cmd+shift+←` arrives as `CSI 1;10D` — one plus shift plus super — and the\n // super block below matches on `key.super` without looking at shift at all.\n //\n // Only the motion keys are recognised, which is what keeps this from swallowing ordinary typing:\n // `key.shift` is true for every capital letter, and a letter matches none of the tests in\n // `shiftMotion`. Return is not a motion either, so `⇧⏎` still reaches the newline branch.\n if (key.shift) {\n const to = shiftMotion(key)\n if (to !== undefined) return { kind: \"extend\", to }\n }\n\n // ─── command chords ──────────────────────────────────────────────────────────────────\n //\n // `super` is Cmd, and it is only ever true once the kitty keyboard protocol has been negotiated —\n // no legacy sequence can express it, and Ink's legacy path folds it into `meta`, which is why\n // `cmd+←` used to word-move like `⌥←` instead of jumping to the start of the line.\n //\n // Horizontal is the line, vertical is the whole message: that is what macOS binds and what every\n // editor on the platform does. Before the ctrl and meta blocks because a chord can carry more than\n // one modifier, and cmd is the most specific claim.\n if (key.super) {\n if (key.leftArrow) return { kind: \"cursorHome\" }\n if (key.rightArrow) return { kind: \"cursorEnd\" }\n if (key.upArrow) return { kind: \"bufferStart\" }\n if (key.downArrow) return { kind: \"bufferEnd\" }\n if (key.backspace) return { kind: \"killToStart\" }\n if (key.delete) return { kind: \"killToEnd\" }\n if (input === \"z\") return key.shift ? { kind: \"redo\" } : { kind: \"undo\" }\n if (input === \"a\") return { kind: \"selectAll\" }\n // Reachable only where the protocol delivers `super`, and the terminal may claim them first for\n // its own copy — which is exactly why a *selection* in the composer does not auto-copy: the\n // fallback for a chord that may not arrive is retyping, not a surprise clipboard write.\n if (input === \"c\") return { kind: \"copySelection\" }\n if (input === \"x\") return { kind: \"cutSelection\" }\n // Unclaimed, and deliberately swallowed for the same reason an unclaimed option chord is: the\n // insert branch would type the bare letter, so cmd+s would put an \"s\" in the message.\n return { kind: \"none\" }\n }\n\n // Ctrl with an arrow or a backspace is the other spelling of a word operation — Linux and Windows\n // convention, and the reference honours `ctrl || meta || fn` for exactly one action because a\n // physical chord reaches a terminal in more than one encoding. Before `ctrlIntent`, which dispatches\n // on a *letter* and would see an empty string here.\n // A terminal's answer to a question this process asked is not a keystroke. Claimed next to the mouse\n // for the same reason: Ink hands it over as text, and text reaches the insert branch.\n if (isTerminalReply(input)) return { kind: \"none\" }\n\n if (key.ctrl && key.leftArrow) return { kind: \"wordLeft\" }\n if (key.ctrl && key.rightArrow) return { kind: \"wordRight\" }\n if (key.ctrl && key.backspace) return { kind: \"killWord\" }\n\n if (key.ctrl) return ctrlIntent(input.toLowerCase(), context)\n\n // ─── option chords ───────────────────────────────────────────────────────────────────\n //\n // Every one of these is measured against Ink's parser rather than assumed, because a terminal has\n // more than one way to send them and the parser reporting *a* key says nothing about which:\n //\n // ⌥← Apple Terminal `ESC b` → input \"b\" + meta iTerm2 `CSI 1;3D` → leftArrow + meta\n // ⌥→ Apple Terminal `ESC f` → input \"f\" + meta iTerm2 `CSI 1;3C` → rightArrow + meta\n // ⌥⌫ `ESC DEL` → backspace + meta\n // ⌥d `ESC d` → input \"d\" + meta\n // ⌥r `ESC r` → input \"r\" + meta\n // ⌥⏎ `ESC CR` → return + meta\n // ⇧⏎ kitty protocol `CSI 13;2u` → return + shift (only once the terminal is taught)\n //\n // Both spellings of each are honoured, so the same binding works in both families of terminal.\n //\n // Under the kitty protocol these arrive as `CSI <codepoint>;3u` instead — `⌥r` is `CSI 114;3u`, and\n // Ink reports it as `input \"r\"` with `meta` set, which is the same shape the table above describes.\n // That is why negotiating the protocol needed no change here: these bindings were always right and\n // simply never arrived, because Warp's Option-as-Meta setting is off by default and `⌥r` was\n // reaching us as the composed character `®`.\n if (key.meta) {\n if (key.return) return { kind: \"newline\" }\n // ⌥↑/⌥↓ walk the conversation a row at a time, and ⌥PgUp/⌥PgDn go to its ends. Bare ↑/↓ cannot\n // do this: they already mean line movement inside a message and history at its edges, and a\n // third meaning on one key is how a keyboard stops being predictable.\n if (key.pageUp) return { kind: \"scroll\", move: \"top\" }\n if (key.pageDown) return { kind: \"scroll\", move: \"bottom\" }\n if (key.upArrow) return { kind: \"scroll\", move: \"up\" }\n if (key.downArrow) return { kind: \"scroll\", move: \"down\" }\n if (key.leftArrow || input === \"b\") return { kind: \"wordLeft\" }\n if (key.rightArrow || input === \"f\") return { kind: \"wordRight\" }\n if (key.backspace) return { kind: \"killWord\" }\n if (input === \"d\") return { kind: \"killWordForward\" }\n // Reasoning is folded to a few rows by default, and this is how the rest of it is read. Same\n // shape as ⌥d — a letter with meta — so it works wherever the chords above already do.\n if (input === \"r\") return { kind: \"reasoning\" }\n // An unclaimed option chord does nothing. Falling through would reach the insert branch and\n // type the bare letter, so ⌥s would silently put an \"s\" in the message. Composed characters\n // (é, ∆) are unaffected: macOS sends those as the character itself, with no meta flag.\n return { kind: \"none\" }\n }\n\n // Shift+enter is a newline where the terminal can express it — `terminal-setup` is what teaches\n // iTerm2, VS Code, Ghostty and Kitty to send the sequence Ink already understands. Where it\n // cannot, this is never true and ⏎ submits, which is why ⌥⏎ is the documented chord.\n if (key.return && key.shift) return { kind: \"newline\" }\n\n // Paging the conversation, unmodified.\n //\n // Deliberately not ^U/^D, which the plan named: both are already taken by the editor — ^U deletes to\n // the start of the line and ^D leaves an empty one — and they are documented, shell-standard, and\n // reached by muscle memory. A scroll key that silently deleted half a message would be a worse bug\n // than no scroll key.\n if (key.pageUp) return { kind: \"scroll\", move: \"pageUp\" }\n if (key.pageDown) return { kind: \"scroll\", move: \"pageDown\" }\n\n // Home and End. Ink has always parsed them; `KeyState` never declared the fields, so both keys did\n // nothing whatsoever until now. The raw-sequence fallback further down catches the terminals that\n // send a spelling Ink does not flag.\n if (key.home) return { kind: \"cursorHome\" }\n if (key.end) return { kind: \"cursorEnd\" }\n\n if (key.return) return context.searching ? { kind: \"searchAccept\" } : { kind: \"submit\" }\n if (key.backspace) return { kind: \"backspace\" }\n if (key.delete) return { kind: \"delete\" }\n if (key.leftArrow) return { kind: \"cursorLeft\" }\n if (key.rightArrow) return { kind: \"cursorRight\" }\n // History at the edges of the buffer, line movement inside it. While searching both walk the match\n // list, which the reducer routes — the arrows mean \"previous\" and \"next\" either way.\n if (key.upArrow) {\n return context.searching || context.firstLine ? { kind: \"historyPrev\" } : { kind: \"lineUp\" }\n }\n if (key.downArrow) {\n return context.searching || context.lastLine\n ? { kind: \"historyNext\" }\n : { kind: \"lineDown\" }\n }\n\n // Escape closes a search; otherwise it is claimed deliberately and does nothing, rather than\n // falling through to the insert branch where it would put a control character into the buffer and\n // be sent to a model. Tab is claimed for the same reason.\n if (key.escape) {\n if (context.searching) return { kind: \"searchCancel\" }\n return context.scrolled ? { kind: \"scroll\", move: \"bottom\" } : { kind: \"none\" }\n }\n if (key.tab) return { kind: \"none\" }\n\n // A paste arrives as one large `input` with no key flags, so insert has to accept many\n // characters at once rather than assuming a single keypress.\n if (input === \"\") return { kind: \"none\" }\n\n // Home and End again, by raw sequence. There are four spellings in the wild and Ink flags only some\n // of them — the reference keeps the same fallback for the same reason (`useTextInput.ts:385-389`).\n // After the empty-input check and before the printable filter, which would otherwise strip the\n // escape and insert `[H` into the message.\n if (input === \"\\u001B[H\" || input === \"\\u001B[1~\") return { kind: \"cursorHome\" }\n if (input === \"\\u001B[F\" || input === \"\\u001B[4~\") return { kind: \"cursorEnd\" }\n\n // Newlines inside that chunk are line breaks, not control noise. Stripping them — which the\n // printable filter below would do — silently joins the last word of one line to the first word\n // of the next and submits nothing, so a pasted multi-line prompt arrives mangled with no error.\n if (/[\\r\\n]/.test(input)) {\n const lines = input.split(/\\r\\n|[\\r\\n]/).map(printableOnly)\n // A trailing newline means the final line is finished too; without one, the tail is still\n // being typed.\n const complete = lines.at(-1) === \"\" && lines.length > 1\n return { kind: \"paste\", lines: complete ? lines.slice(0, -1) : lines, complete }\n }\n\n const printable = printableOnly(input)\n return printable === \"\" ? { kind: \"none\" } : { kind: \"insert\", text: printable }\n}\n\n/**\n * Which motion a shift chord extends by, or `undefined` when the key is not a motion at all.\n *\n * Modifier first, then the bare keys, so `shift+cmd+←` is a line and `shift+⌥←` is a word rather than both\n * being a character. `shift+↑` extends a line up even on the first line, where the unshifted arrow means\n * history: selecting upward is unambiguous, and a history chord that also grew a selection would be one\n * key doing two unrelated things.\n *\n * `input` is deliberately not consulted. The `ESC b` spelling of `⌥←` would arrive shifted as `ESC B`, and\n * matching a capital letter here is how `shift+B` would start selecting words. Terminals send the CSI form\n * for a shifted arrow, which carries the flags this reads.\n */\nfunction shiftMotion(key: KeyState): MotionKind | undefined {\n if (key.super) {\n if (key.leftArrow) return \"cursorHome\"\n if (key.rightArrow) return \"cursorEnd\"\n if (key.upArrow) return \"bufferStart\"\n if (key.downArrow) return \"bufferEnd\"\n return undefined\n }\n if (key.meta || key.ctrl) {\n if (key.leftArrow) return \"wordLeft\"\n if (key.rightArrow) return \"wordRight\"\n return undefined\n }\n if (key.home) return \"cursorHome\"\n if (key.end) return \"cursorEnd\"\n if (key.leftArrow) return \"cursorLeft\"\n if (key.rightArrow) return \"cursorRight\"\n if (key.upArrow) return \"lineUp\"\n if (key.downArrow) return \"lineDown\"\n return undefined\n}\n\n/**\n * Drop C0 controls and DEL. A bracketed-paste marker or a stray escape sequence reaching the buffer\n * would be invisible on screen and sent to the model as if it had been typed.\n */\nfunction printableOnly(text: string): string {\n return [...text]\n .filter((char) => {\n const code = char.codePointAt(0) ?? 0\n return code >= 0x20 && code !== 0x7f\n })\n .join(\"\")\n}\n\n// ─── screen keymaps ──────────────────────────────────────────────────────────────────────\n//\n// The wizard and picker differ from the chat input in what Esc means — a *context*, not a new\n// module, which is why they live here beside `keyToIntent` rather than in per-screen files: one\n// keyboard home, closed by the same drift tests.\n\nimport type { SelectMove } from \"#lib/select\"\n\nexport type ListIntent =\n | { readonly kind: \"move\"; readonly move: SelectMove }\n | { readonly kind: \"choose\" }\n | { readonly kind: \"back\" }\n | { readonly kind: \"exit\" }\n | { readonly kind: \"none\" }\n\n/**\n * A checklist adds two verbs a single-select list does not have: tick a row, and finish.\n *\n * Space ticks and enter finishes, which is the convention every multi-select in a terminal uses — and\n * getting it the other way round is the mistake that makes a picker feel broken, because enter on a\n * highlighted row is such a strong habit that people submit with one thing ticked and never see the rest.\n * `a` and `n` are all/none, worth having when the list is fifty rows long.\n */\nexport type CheckIntent =\n | { readonly kind: \"move\"; readonly move: SelectMove }\n | { readonly kind: \"toggle\" }\n | { readonly kind: \"all\" }\n | { readonly kind: \"none-selected\" }\n | { readonly kind: \"confirm\" }\n | { readonly kind: \"cancel\" }\n | { readonly kind: \"none\" }\n\nexport function keyToCheckIntent(input: string, key: KeyState): CheckIntent {\n if (key.ctrl) {\n return input.toLowerCase() === \"c\" || input.toLowerCase() === \"d\"\n ? { kind: \"cancel\" }\n : { kind: \"none\" }\n }\n if (key.return) return { kind: \"confirm\" }\n if (key.escape) return { kind: \"cancel\" }\n // Ink reports the space bar as the input string \" \" with no flag of its own.\n if (input === \" \") return { kind: \"toggle\" }\n if (input === \"a\") return { kind: \"all\" }\n if (input === \"n\") return { kind: \"none-selected\" }\n\n const list = keyToListIntent(input, key)\n // Movement is shared so the two lists cannot drift apart; `choose` cannot arrive, because `key.return`\n // is handled above, and the remaining kinds are not this screen's.\n return list.kind === \"move\" ? list : { kind: \"none\" }\n}\n\n/**\n * List navigation: arrows or j/k, g/G for ends, enter chooses, esc backs out, ^C/^D leave.\n *\n * A digit jumps the cursor — visibly and reversibly — and deliberately does not choose: a stray\n * number must never launch an agent.\n */\nexport function keyToListIntent(input: string, key: KeyState): ListIntent {\n if (key.ctrl) {\n return input.toLowerCase() === \"c\" || input.toLowerCase() === \"d\"\n ? { kind: \"exit\" }\n : { kind: \"none\" }\n }\n if (key.return) return { kind: \"choose\" }\n if (key.escape) return { kind: \"back\" }\n if (key.upArrow) return { kind: \"move\", move: { kind: \"up\" } }\n if (key.downArrow) return { kind: \"move\", move: { kind: \"down\" } }\n\n switch (input) {\n case \"k\":\n return { kind: \"move\", move: { kind: \"up\" } }\n case \"j\":\n return { kind: \"move\", move: { kind: \"down\" } }\n case \"g\":\n return { kind: \"move\", move: { kind: \"first\" } }\n case \"G\":\n return { kind: \"move\", move: { kind: \"last\" } }\n default:\n break\n }\n if (/^[1-9]$/.test(input)) {\n return { kind: \"move\", move: { kind: \"jump\", index: Number(input) - 1 } }\n }\n return { kind: \"none\" }\n}\n\nexport type WizardKeyIntent =\n | { readonly kind: \"back\" }\n | { readonly kind: \"abort\" }\n | { readonly kind: \"commit\" }\n | { readonly kind: \"list\"; readonly intent: ListIntent }\n | { readonly kind: \"edit\"; readonly intent: Intent }\n\n/**\n * The wizard's chrome keys are checked before delegation — Esc means \"back a question\" here,\n * which is exactly why chat's `keyToIntent` (which claims Esc as none) is not reused raw.\n *\n * Text steps then get the full chat editor treatment (^A/^E, ^W, code-point cursor); select steps\n * get the list navigation. A pasted blob collapses to its first line — a wizard answer is one\n * line — and history chords mean nothing inside a question.\n */\nexport function keyToWizardIntent(\n input: string,\n key: KeyState,\n context: { readonly select: boolean; readonly empty: boolean },\n): WizardKeyIntent {\n if (key.ctrl && input.toLowerCase() === \"c\") return { kind: \"abort\" }\n if (key.escape) return { kind: \"back\" }\n if (key.return) return { kind: \"commit\" }\n\n if (context.select) {\n return { kind: \"list\", intent: keyToListIntent(input, key) }\n }\n\n // A wizard answer is one line — a pasted blob collapses to its first — so the cursor is always on\n // both the first and the last line, and ↑/↓ mean history rather than line movement. There is no\n // search here either.\n const intent = keyToIntent(input, key, {\n busy: false,\n empty: context.empty,\n firstLine: true,\n lastLine: true,\n searching: false,\n // A question is not a conversation: there is nothing to scroll and nothing to arm, and Esc is\n // claimed above as \"back a question\" before this is ever reached.\n armed: false,\n scrolled: false,\n })\n switch (intent.kind) {\n case \"submit\":\n return { kind: \"commit\" }\n case \"exit\":\n // ^D on an empty question line reads as \"get me out\", same as ^C.\n return { kind: \"abort\" }\n case \"arm\":\n case \"scroll\":\n // Unreachable in practice — ^C is claimed as `abort` above and there is nothing to scroll —\n // and listed rather than left to the default, so adding a session-only intent cannot\n // silently become an edit the wizard applies to a field.\n return { kind: \"edit\", intent: { kind: \"none\" } }\n case \"historyPrev\":\n case \"historyNext\":\n return { kind: \"edit\", intent: { kind: \"none\" } }\n case \"paste\":\n return {\n kind: \"edit\",\n intent: { kind: \"insert\", text: intent.lines[0] ?? \"\" },\n }\n default:\n return { kind: \"edit\", intent }\n }\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";+GA2BO,IAAM,GAA4B,CACrC,MAAO,GACP,OAAQ,EACR,QAAS,CAAC,EACV,cAAe,EACf,MAAO,GACP,KAAM,CAAC,EACP,OAAQ,CAAC,EACT,OAAQ,OACR,OAAQ,MACZ,EAEA,SAAS,CAAK,CAAC,EAAyB,CACpC,MAAO,CAAC,GAAG,CAAK,EAGpB,SAAS,CAAK,CAAC,EAAgB,EAAwB,CACnD,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAQ,CAAM,CAAC,EAG/C,SAAS,CAAQ,CAAC,EAAoC,CAClD,MAAO,CAAE,MAAO,EAAM,MAAO,OAAQ,EAAM,MAAO,EAYtD,SAAS,CAAQ,CAAC,EAAoB,EAAsD,CACxF,IAAM,EAAM,EAAM,KAAK,GAAG,EAAE,EAG5B,GAAI,EAAQ,UAAY,IAAQ,QAAa,EAAM,OAAO,SAAW,EACjE,MAAO,IAAK,EAAO,OAAQ,CAAC,CAAE,EAElC,GAAI,IAAQ,QAAa,EAAI,QAAU,EAAM,MAAO,MAAO,IAAK,EAAO,OAAQ,CAAC,CAAE,EAClF,MAAO,IAAK,EAAO,KAAM,CAAC,GAAG,EAAM,KAAM,EAAS,CAAK,CAAC,EAAE,MAAM,CAAC,EAAU,EAAG,OAAQ,CAAC,CAAE,EAI7F,SA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pB,MAAO,CAAE,KAAM,OAAQ,KAAM,CAAE,KAAM,OAAQ,MAAO,OAAO,CAAK,EAAI,CAAE,CAAE,EAE5E,MAAO,CAAE,KAAM,MAAO,EAkBnB,SAAS,EAAiB,CAC7B,EACA,EACA,EACe,CACf,GAAI,EAAI,MAAQ,EAAM,YAAY,IAAM,IAAK,MAAO,CAAE,KAAM,OAAQ,EACpE,GAAI,EAAI,OAAQ,MAAO,CAAE,KAAM,MAAO,EACtC,GAAI,EAAI,OAAQ,MAAO,CAAE,KAAM,QAAS,EAExC,GAAI,EAAQ,OACR,MAAO,CAAE,KAAM,OAAQ,OAAQ,GAAgB,EAAO,CAAG,CAAE,EAM/D,IAAM,EAAS,GAAY,EAAO,EAAK,CACnC,KAAM,GACN,MAAO,EAAQ,MACf,UAAW,GACX,SAAU,GACV,UAAW,GAGX,MAAO,GACP,SAAU,EACd,CAAC,EACD,OAAQ,EAAO,MACX,IAAK,SACD,MAAO,CAAE,KAAM,QAAS,EAC5B,IAAK,OAED,MAAO,CAAE,KAAM,OAAQ,EAC3B,IAAK,MACL,IAAK,SAID,MAAO,CAAE,KAAM,OAAQ,OAAQ,CAAE,KAAM,MAAO,CAAE,EACpD,IAAK,cACL,IAAK,cACD,MAAO,CAAE,KAAM,OAAQ,OAAQ,CAAE,KAAM,MAAO,CAAE,EACpD,IAAK,QACD,MAAO,CACH,KAAM,OACN,OAAQ,CAAE,KAAM,SAAU,KAAM,EAAO,MAAM,IAAM,EAAG,CAC1D,EACJ,QACI,MAAO,CAAE,KAAM,OAAQ,QAAO",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "1DB124110DBD055F64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Tt,
|
|
3
|
-
export{Gt,
|
|
2
|
+
import{Tt,mo,Qn,k}from"./index-hpvfqq6r.js";import{existsSync as b,readFileSync as E}from"node:fs";import{dirname as l,join as o,resolve as u}from"node:path";function Gt(n){let e=o(l(n),".env"),r={};if(b(e))try{r=Tt(E(e,"utf8"))}catch{}return mo(r,k([n]))}function on(n,e){let r=n[e];return r!==void 0&&r!==""}function f(n,e,r={}){let i=l(n),t=u(r.cwd??process.cwd()),d=r.readDir??Qn,v=r.env??process.env,g=k([n],r),m=d(i),p=d(t),a=g[e];if(a!==void 0&&a!==""){let y=u(i)===t,c=p[e];if(!y&&c!==void 0&&v[e]===c)return{kind:"ambiguous",path:o(t,".env")};return{kind:"export"}}let s=m[e];if(s!==void 0&&s!=="")return{kind:"agent",path:o(i,".env")};return{kind:"unset"}}function $i(n){switch(n.kind){case"export":return"from the environment, not a .env file";case"ambiguous":return"from the environment or ./.env — indistinguishable";case"agent":return;case"unset":return"not set"}}function Xi(n){let e=[],r=h(n.rawModelId);if(r!==void 0)e.push({field:"model.main.id",variable:r,origin:f(n.manifestPath,r,n.options??{})});if(n.apiKeyEnv!==void 0)e.push({field:"model.main.apiKeyEnv",variable:n.apiKeyEnv,origin:f(n.manifestPath,n.apiKeyEnv,n.options??{})});return e}function h(n){if(n===void 0)return;return/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(n.trim())?.[1]}
|
|
3
|
+
export{Gt,on,$i,Xi};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
//# debugId=69FBAB302779551D64756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-mjfv7k5w.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Whether a variable an agent depends on is actually set, from that agent's point of view.\n *\n * `ambientEnv` is **not** this. It layers the *cwd*'s `.env` against an agent's — demoting a colliding\n * variable so a project checkout cannot silently change which model a sandbox agent runs on — and it\n * returns `process.env` unchanged whenever nothing is in tension. It never *adds* the agent's own file.\n *\n * The agent's `.env` is merged by `loadManifest`, through core's `layeredEnv`, and that is the answer a\n * question about this agent needs. Reading `process.env` alone reported a variable as unset while the\n * file beside the manifest plainly had it — the same class of mistake `serve` made once, reporting\n * \"unauthenticated\" for a token sitting next to the manifest. It showed up here as an editor row that\n * still read `(not set)` immediately after somebody set it, which is the \"did that work?\" failure this\n * whole surface exists to remove.\n *\n * Precedence is core's, unchanged: the real environment wins, because an operator's export has to beat\n * a file for a container to be able to configure the agent it runs.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { type EnvSource, layeredEnv, parseDotEnv } from \"@dispach/core\"\nimport { type AmbientOptions, ambientEnv, readDotEnv } from \"#lib/ambient\"\n\n/** The environment this agent will actually see: its own `.env` under the ambient one. */\nexport function agentEnv(manifestPath: string): EnvSource {\n const path = join(dirname(manifestPath), \".env\")\n let beside: Record<string, string> = {}\n if (existsSync(path)) {\n try {\n beside = parseDotEnv(readFileSync(path, \"utf8\"))\n } catch {\n // An unreadable `.env` is reported by the loader, in the words the loader uses. Here it\n // simply means nothing is known to be set, which is the safe reading for a \"is it set?\"\n // question — claiming a variable is present when the file cannot be read would be worse.\n }\n }\n return layeredEnv(beside, ambientEnv([manifestPath]))\n}\n\n/** Whether `name` has a non-empty value. Empty counts as unset: it fails a load exactly as absent does. */\nexport function isSet(env: EnvSource, name: string): boolean {\n const value = env[name]\n return value !== undefined && value !== \"\"\n}\n\n/**\n * Where a value came from, which is a different question from whether it is set.\n *\n * Three layers can supply one variable and the winner is not obvious from any of them:\n *\n * 1. the real environment — an operator's export, or a container's `environment:` block\n * 2. the `.env` beside the agent's manifest\n * 3. a `.env` in the directory the command was run from, demoted beneath (2) by `ambientEnv`\n *\n * Every one of those is correct on its own, and the composition is unreadable. It produced a real\n * confusion in a container: `docker compose` passes `MODEL_ID` and friends as process environment,\n * so an agent scaffolded inside that container silently ran on the *mounted*\n * agent's model, and the `0600` `.env` that `init` had just written was ignored for exactly those\n * keys — with nothing anywhere saying so.\n *\n * The precedence is not the bug and is not changed here. What was missing is a sentence, and the\n * recorded lesson from the last time this surfaced is that *a warning explained the surprise and\n * did not remove it* — so this reports rather than intervenes.\n */\nexport type EnvOrigin =\n /** The real environment won: an export, or a container's own configuration. */\n | { readonly kind: \"export\" }\n /** The `.env` beside the manifest won. */\n | { readonly kind: \"agent\"; readonly path: string }\n /**\n * Either an export or the cwd's `.env`, and **they cannot be told apart**.\n *\n * Bun auto-loads a `.env` from the current directory into `process.env` before any of this code\n * runs, so once the two agree on a string there is no evidence left distinguishing them. Said\n * rather than guessed: naming one would be a coin toss printed as a fact.\n */\n | { readonly kind: \"ambiguous\"; readonly path: string }\n | { readonly kind: \"unset\" }\n\n/**\n * Which layer supplies `name` for this agent.\n *\n * Mirrors `ambientEnv`'s precedence by *calling* it rather than by restating it — the demotion rule\n * is subtle (a cwd variable is demoted only when the agent's own file also sets it *and* the values\n * match), and a second implementation of that would drift on the first edit.\n */\nexport function sourceOf(\n manifestPath: string,\n name: string,\n options: AmbientOptions = {},\n): EnvOrigin {\n const agentDir = dirname(manifestPath)\n const cwd = resolve(options.cwd ?? process.cwd())\n const read = options.readDir ?? readDotEnv\n const raw = options.env ?? process.env\n\n const ambient = ambientEnv([manifestPath], options)\n const beside = read(agentDir)\n const inCwd = read(cwd)\n\n const fromAmbient = ambient[name]\n if (fromAmbient !== undefined && fromAmbient !== \"\") {\n // The cwd file is only a candidate when it is a *different* directory from the agent's: when\n // they are the same directory, that file **is** the agent's own and `ambientEnv` says so.\n const sameDir = resolve(agentDir) === cwd\n const cwdValue = inCwd[name]\n if (!sameDir && cwdValue !== undefined && raw[name] === cwdValue) {\n return { kind: \"ambiguous\", path: join(cwd, \".env\") }\n }\n return { kind: \"export\" }\n }\n\n const fromFile = beside[name]\n if (fromFile !== undefined && fromFile !== \"\") {\n return { kind: \"agent\", path: join(agentDir, \".env\") }\n }\n\n return { kind: \"unset\" }\n}\n\n/**\n * The phrase for a status line — short, because it rides after a value somebody is already reading.\n *\n * Returns `undefined` for the ordinary case, which is the whole point: a line that always carries a\n * provenance note is a line nobody reads it on. The agent's own `.env` winning is what an author\n * expects, so only the surprising sources say anything.\n */\nexport function describeOrigin(origin: EnvOrigin): string | undefined {\n switch (origin.kind) {\n case \"export\":\n return \"from the environment, not a .env file\"\n case \"ambiguous\":\n return \"from the environment or ./.env — indistinguishable\"\n case \"agent\":\n return undefined\n case \"unset\":\n return \"not set\"\n }\n}\n\n/** One env-backed field, the variable behind it, and where the value came from. */\nexport interface Provenance {\n readonly field: string\n readonly variable: string\n readonly origin: EnvOrigin\n}\n\n/**\n * The env-backed fields worth saying something about, and only when there is something to say.\n *\n * Two fields, chosen because they are the two that produced a real confusion in a container:\n * `docker compose` passes `MODEL_ID` and `MODEL_API_KEY` as process environment, and the ambient\n * environment deliberately beats the agent's own file so an operator can configure the agent their\n * container runs. So an agent scaffolded in that container ran on the *mounted*\n * agent's model and ignored the `0600` `.env` init had just written.\n *\n * The model id is included **only when the manifest writes it as a variable**. A generated manifest\n * carries it literally (which is why `readManifestHeader` can list agents without credentials), and\n * a literal has no provenance to report — printing \"from the environment\" about a value nothing read\n * from the environment would be worse than silence. `apiKeyEnv` is always a variable name by hard\n * rule 10, so it is always askable.\n */\nexport function envProvenance(input: {\n readonly manifestPath: string\n /** The raw, unexpanded `model.main.id` — `readManifestHeader().modelId`. */\n readonly rawModelId: string | undefined\n readonly apiKeyEnv: string | undefined\n readonly options?: AmbientOptions\n}): readonly Provenance[] {\n const rows: Provenance[] = []\n const variable = soleVariable(input.rawModelId)\n if (variable !== undefined) {\n rows.push({\n field: \"model.main.id\",\n variable,\n origin: sourceOf(input.manifestPath, variable, input.options ?? {}),\n })\n }\n if (input.apiKeyEnv !== undefined) {\n rows.push({\n field: \"model.main.apiKeyEnv\",\n variable: input.apiKeyEnv,\n origin: sourceOf(input.manifestPath, input.apiKeyEnv, input.options ?? {}),\n })\n }\n return rows\n}\n\n/**\n * The variable name when a value is exactly one `${VAR}` reference, and nothing otherwise.\n *\n * Deliberately narrow. `prefix-${VAR}` expands from the environment too, but its provenance is a\n * sentence about part of a string, and a half-true note on a compound value is the kind of detail\n * that gets believed whole.\n */\nfunction soleVariable(raw: string | undefined): string | undefined {\n if (raw === undefined) return undefined\n const match = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/.exec(raw.trim())\n return match?.[1]\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";4CAkBA,qBAAS,kBAAY,gBACrB,kBAAS,UAAS,aAAM,kBAKjB,SAAS,EAAQ,CAAC,EAAiC,CACtD,IAAM,EAAO,EAAK,EAAQ,CAAY,EAAG,MAAM,EAC3C,EAAiC,CAAC,EACtC,GAAI,EAAW,CAAI,EACf,GAAI,CACA,EAAS,GAAY,EAAa,EAAM,MAAM,CAAC,EACjD,KAAM,EAMZ,OAAO,GAAW,EAAQ,EAAW,CAAC,CAAY,CAAC,CAAC,EAIjD,SAAS,EAAK,CAAC,EAAgB,EAAuB,CACzD,IAAM,EAAQ,EAAI,GAClB,OAAO,IAAU,QAAa,IAAU,GA4CrC,SAAS,CAAQ,CACpB,EACA,EACA,EAA0B,CAAC,EAClB,CACT,IAAM,EAAW,EAAQ,CAAY,EAC/B,EAAM,EAAQ,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAC1C,EAAO,EAAQ,SAAW,GAC1B,EAAM,EAAQ,KAAO,QAAQ,IAE7B,EAAU,EAAW,CAAC,CAAY,EAAG,CAAO,EAC5C,EAAS,EAAK,CAAQ,EACtB,EAAQ,EAAK,CAAG,EAEhB,EAAc,EAAQ,GAC5B,GAAI,IAAgB,QAAa,IAAgB,GAAI,CAGjD,IAAM,EAAU,EAAQ,CAAQ,IAAM,EAChC,EAAW,EAAM,GACvB,GAAI,CAAC,GAAW,IAAa,QAAa,EAAI,KAAU,EACpD,MAAO,CAAE,KAAM,YAAa,KAAM,EAAK,EAAK,MAAM,CAAE,EAExD,MAAO,CAAE,KAAM,QAAS,EAG5B,IAAM,EAAW,EAAO,GACxB,GAAI,IAAa,QAAa,IAAa,GACvC,MAAO,CAAE,KAAM,QAAS,KAAM,EAAK,EAAU,MAAM,CAAE,EAGzD,MAAO,CAAE,KAAM,OAAQ,EAUpB,SAAS,EAAc,CAAC,EAAuC,CAClE,OAAQ,EAAO,MACX,IAAK,SACD,MAAO,wCACX,IAAK,YACD,MAAO,qDACX,IAAK,QACD,OACJ,IAAK,QACD,MAAO,WA0BZ,SAAS,EAAa,CAAC,EAMJ,CACtB,IAAM,EAAqB,CAAC,EACtB,EAAW,EAAa,EAAM,UAAU,EAC9C,GAAI,IAAa,OACb,EAAK,KAAK,CACN,MAAO,gBACP,WACA,OAAQ,EAAS,EAAM,aAAc,EAAU,EAAM,SAAW,CAAC,CAAC,CACtE,CAAC,EAEL,GAAI,EAAM,YAAc,OACpB,EAAK,KAAK,CACN,MAAO,uBACP,SAAU,EAAM,UAChB,OAAQ,EAAS,EAAM,aAAc,EAAM,UAAW,EAAM,SAAW,CAAC,CAAC,CAC7E,CAAC,EAEL,OAAO,EAUX,SAAS,CAAY,CAAC,EAA6C,CAC/D,GAAI,IAAQ,OAAW,OAEvB,MADc,mCAAmC,KAAK,EAAI,KAAK,CAAC,IACjD",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "69FBAB302779551D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{i,b}from"./index-dzy19wtf.js";import{_e}from"./index-42e29zs4.js";import{To,Ro,_o,De}from"./index-0444sh6x.js";import{Box as T,Text as u}from"ink";import{jsx as s,jsxs as a}from"react/jsx-runtime";function Ln({rows:e,index:t,chosen:r,window:n,width:c}){let{from:o,to:d}=De(e.length,t,n),k=new Set(r),g=e.reduce((l,m)=>m.kind==="item"?Math.max(l,m.label.length):l,0),M=To(c,g);return a(T,{flexDirection:"column",children:[o>0?a(u,{dimColor:!0,wrap:"truncate",children:[" ",b.ellipsis," ",o," above"]}):null,e.slice(o,d).map((l,m)=>{let p=o+m;if(l.kind!=="item"){let S=l.kind==="source";return a(u,{wrap:"truncate",bold:S,color:S?i.accent:i.muted,children:[S?" ":" ",_o(l.label,c-(S?2:4))]},p)}let y=p===t,f=k.has(p),x=Ro({name:l.label,meta:l.meta??"",description:l.description??""},M);return a(u,{wrap:"truncate",children:[s(u,{color:i.accent,children:y?b.pointer:" "}),s(u,{color:f?i.success:i.muted,children:f?b.checked:b.unchecked}),s(u,{bold:y,...f?{color:i.success}:{},children:x.name})," ",s(u,{color:i.muted,children:x.meta}),x.description===""?"":" ",s(u,{dimColor:!0,children:x.description})]},p)}),d<e.length?a(u,{dimColor:!0,wrap:"truncate",children:[" ",b.ellipsis," ",e.length-d," below"]}):null]})}function h(e,t,r){let n=e;for(let c=0;c<=t.length;c+=1){if(t[n.index]===!0)return n;let o=_e(n,{kind:r?"down":"up"});if(o.index===n.index)return;n=o}return}function v(e,t,r,n){if(r.length===0)return e;return h(t,r,n)??h(t,r,!n)??e}function SA(e,t,r){switch(t.kind){case"move":{if(!r.includes(!0))return e;let n=_e(e.cursor,t.move),c=n.index>=e.cursor.index;return{...e,cursor:v(e.cursor,n,r,c)}}case"toggle":{let n=e.cursor.index;if(r[n]!==!0)return e;let c=e.chosen.includes(n)?e.chosen.filter((o)=>o!==n):[...e.chosen,n].sort((o,d)=>o-d);return{...e,chosen:c}}case"all":{let n=r.flatMap((c,o)=>c?[o]:[]);return{...e,chosen:n}}case"none":return{...e,chosen:[]}}}function Pn(e){let t=e.indexOf(!0);return t===-1?0:t}
|
|
3
|
+
export{Ln,SA,Pn};
|
|
4
|
+
|
|
5
|
+
//# debugId=274683CF31115BA064756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-nvc24414.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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C,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,CACA,IAAK,MAAO,CACR,IAAM,EAAS,EAAW,QAAQ,CAAC,EAAI,IAAW,EAAK,CAAC,CAAK,EAAI,CAAC,CAAE,EACpE,MAAO,IAAK,EAAO,QAAO,CAC9B,CACA,IAAK,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": "
|
|
9
|
+
"debugId": "274683CF31115BA064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{i,$e}from"./index-dzy19wtf.js";import{Box as l,Text as o}from"ink";import{jsx as e,jsxs as d}from"react/jsx-runtime";function QA({title:n,lines:t}){return d(l,{flexDirection:"column",borderStyle:$e,borderColor:i.borderActive,paddingX:1,children:[e(o,{bold:!0,color:i.accent,children:n}),t.map((r)=>e(o,{dimColor:!0,children:r},r))]})}
|
|
3
|
+
export{QA};
|
|
4
|
+
|
|
5
|
+
//# debugId=716D1860FFB46E1F64756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-nxhqf597.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The welcome box: product identity in a rounded frame, context lines dim beneath it.\n *\n * Purely presentational — the caller supplies the title (usually `BRAND.name + version`) and the\n * lines, so this renders identically at the top of a chat session, a wizard, or the picker.\n *\n * Every boxed surface stretches to the full terminal width — no `alignSelf`. Content-fit boxes\n * next to full-width ones read as different components; one rule everywhere is what makes the\n * screens look like one product.\n */\n\nimport { Box, Text } from \"ink\"\nimport { BORDER_STYLE, THEME } from \"#lib/theme\"\n\nexport interface BannerProps {\n readonly title: string\n readonly lines: readonly string[]\n}\n\nexport function Banner({ title, lines }: BannerProps) {\n return (\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.borderActive}\n paddingX={1}\n >\n <Text bold color={THEME.accent}>\n {title}\n </Text>\n {lines.map((line) => (\n <Text key={line} dimColor>\n {line}\n </Text>\n ))}\n </Box>\n )\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";sCAWA,cAAS,UAAK,8DAQP,SAAS,EAAM,EAAG,QAAO,SAAsB,CAClD,OACI,EAAC,EAAD,CACI,cAAc,SACd,YAAa,GACb,YAAa,EAAM,aACnB,SAAU,EAJd,SAcE,CARE,EAAC,EAAD,CAAM,KAAI,GAAC,MAAO,EAAM,OAAxB,SACK,EACH,EACD,EAAM,IAAI,CAAC,IACR,EAAC,EAAD,CAAiB,SAAQ,GAAzB,SACK,GADM,CAET,CACL,GACH",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "716D1860FFB46E1F64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var y=[[4352,4447],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[43360,43391],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65280,65376],[65504,65510],[127744,128591],[128640,128767],[129280,129535],[129648,129791],[131072,196605],[196608,262141]],w=[[768,879],[1155,1161],[1425,1469],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[2304,2307],[2362,2362],[3633,3633],[3636,3642],[6832,6911],[7616,7679],[8203,8207],[8400,8447],[65024,65039],[65056,65071],[65279,65279]];function m(n,t){for(let[f,e]of t){if(n<f)return!1;if(n<=e)return!0}return!1}function W(n){if(n<32||n>=127&&n<160)return 0;if(m(n,w))return 0;if(m(n,y))return 2;return 1}function g(n){return n.map((t)=>W(t.codePointAt(0)??0))}var T=" ".repeat(8);function
|
|
3
|
-
`).flatMap((f)=>A(f,t))}function
|
|
4
|
-
export{
|
|
2
|
+
var y=[[4352,4447],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[43360,43391],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65280,65376],[65504,65510],[127744,128591],[128640,128767],[129280,129535],[129648,129791],[131072,196605],[196608,262141]],w=[[768,879],[1155,1161],[1425,1469],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[2304,2307],[2362,2362],[3633,3633],[3636,3642],[6832,6911],[7616,7679],[8203,8207],[8400,8447],[65024,65039],[65056,65071],[65279,65279]];function m(n,t){for(let[f,e]of t){if(n<f)return!1;if(n<=e)return!0}return!1}function W(n){if(n<32||n>=127&&n<160)return 0;if(m(n,w))return 0;if(m(n,y))return 2;return 1}function g(n){return n.map((t)=>W(t.codePointAt(0)??0))}var T=" ".repeat(8);function Ao(n,t){let f=n.replaceAll("\t",T),e=[...f],s=g(e),b=(x,u)=>{let r=0;for(let l=x;l<u;l+=1)r+=s[l]??0;return r};if(t<=0||b(0,e.length)<=t)return[{text:f,lead:0,from:0,to:e.length}];let o=0;while(o<e.length&&(e[o]===" "||e[o]===" "))o+=1;if(o>0){let x=e.slice(o).join("");if(o>=t)return Ao(x,t).map((r)=>({...r,from:r.from+o,to:r.to+o}));let u=" ".repeat(o);return Ao(x,t-o).map((r)=>({text:`${u}${r.text}`,lead:r.lead+o,from:r.from+o,to:r.to+o}))}let h=[],d=0,i=0,p=(x)=>{h.push({text:e.slice(d,x).join(""),lead:0,from:d,to:x})},a=0;while(a<=e.length){let x=a;while(x<e.length&&e[x]!==" ")x+=1;let u=b(a,x);if(u>t){if(i>0)p(a===d?a:a-1),d=a,i=0;let r=a;while(b(r,x)>t){let l=r,c=0;while(l<x&&c+(s[l]??0)<=t)c+=s[l]??0,l+=1;if(l===r)l=r+1;d=r,p(l),r=l,d=r}d=r,i=b(r,x)}else if(i>0&&i+1+u>t)p(a-1),d=a,i=u;else i=i===0?u:i+1+u;if(x>=e.length)break;a=x+1}return p(e.length),h}function A(n,t){return Ao(n,t).map((f)=>f.text)}function Es(n,t){let f=0;for(let[e,s]of[...n].entries()){if(e>=t)break;f+=s==="\t"?8:1}return f}function In(n,t){return n.split(`
|
|
3
|
+
`).flatMap((f)=>A(f,t))}function no(n,t,f){if(n===""||f<=0)return{lines:[],rows:0,hidden:0};let e=In(n,t);if(e.length<=f)return{lines:e,rows:e.length,hidden:0};return{lines:e.slice(e.length-f),rows:f+1,hidden:e.length-f}}
|
|
4
|
+
export{Ao,Es,In,no};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
7
|
-
//# sourceMappingURL=index-
|
|
6
|
+
//# debugId=3F9E348E9E24AF4164756E2164756E21
|
|
7
|
+
//# sourceMappingURL=index-p6ya59m6.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"/**\n * Breaking text into the rows a fixed-width window will draw.\n *\n * ## One wrapping, ours\n *\n * This module used to count rows the way a terminal does — divide the character count by the width — and\n * hand the text to Ink to wrap. Those are two different answers to one question, and the difference is not\n * academic: Ink breaks at spaces, so 240 characters at 80 columns is **four** rows to Ink and three to a\n * division. Every cap built on the division was therefore one row short of what appeared on screen, which\n * on the alternate buffer is a frame taller than the terminal.\n *\n * So the rule is that whoever owns a bounded window wraps the text itself and renders each row with\n * `wrap=\"truncate\"`. The count is then the count, by construction, and a frame test asserts it against a\n * real render rather than trusting the arithmetic.\n *\n * Tabs are expanded to spaces on the way through. A tab's width is the terminal's business and not ours,\n * so a row containing one cannot be measured — expanding it is the only way the number we counted is the\n * number drawn. It changes bytes, never meaning, which is the line decision 4.27 draws.\n */\n\nconst TAB_WIDTH = 8\nconst TAB = \" \".repeat(TAB_WIDTH)\n\nimport { cellWidths } from \"#lib/width\"\n\n/**\n * One drawn row, and which source characters it drew.\n *\n * The offsets exist because a row's text is **not** a slice of its line. Breaking at a space consumes\n * the space, a word longer than the window is cut, and a hanging indent is re-applied to rows that never\n * contained it — so \"which row is source offset 41 on, and at what column\" cannot be recovered from the\n * strings afterwards. Anything that draws a caret over wrapped text needs exactly that, and computing it\n * a second time from the finished rows is how a cursor ends up a column out on the lines that wrapped.\n */\nexport interface WrappedRow {\n /** Exactly what is painted, the re-applied indent included. */\n readonly text: string\n /** Columns of `text` that are indent. A caret never lands to the left of this. */\n readonly lead: number\n /** Source code-point offset of this row's first drawn character. */\n readonly from: number\n /** One past this row's last drawn character. A break at a space leaves a gap before the next `from`. */\n readonly to: number\n}\n\n/**\n * One logical line, broken at spaces to fit `columns`, with the source offsets kept.\n *\n * A word longer than the whole width is cut rather than allowed to overflow — a URL or a base64 blob is\n * the normal case for that, and there is nowhere better to break it. Returns one row for an empty line,\n * because a blank line in a reply is a blank row on screen and dropping it would close up paragraphs the\n * model deliberately separated.\n */\nexport function wrapRows(line: string, columns: number): readonly WrappedRow[] {\n // Tabs are expanded before anything is measured, so offsets are into the *expanded* line. A caller\n // placing a caret has to expand its own column the same way, which `expandColumn` is for.\n const flat = line.replaceAll(\"\\t\", TAB)\n const all = [...flat]\n // Widths per cell, computed once. Every measurement below is a sum over this rather than a count of\n // code points: an emoji is one code point and two columns, so counting made `\"👍\".repeat(10)` measure\n // ten and draw twenty. Offsets stay in code points, because that is what a caller slices with.\n const w = cellWidths(all)\n const span = (from: number, to: number): number => {\n let total = 0\n for (let at = from; at < to; at += 1) total += w[at] ?? 0\n return total\n }\n if (columns <= 0 || span(0, all.length) <= columns) {\n return [{ text: flat, lead: 0, from: 0, to: all.length }]\n }\n\n // Leading whitespace is structure, and splitting on spaces destroys it.\n //\n // Found live: `/help`'s output indents each entry by two spaces, and every line short enough to fit kept\n // them while every line that wrapped lost them — so one list came out at two different indents depending\n // on how long each summary happened to be. Held aside here and re-applied to every row, which also gives\n // a wrapped indented block a hanging indent rather than a ragged left edge.\n let indent = 0\n while (indent < all.length && (all[indent] === \" \" || all[indent] === \"\\u00a0\")) indent += 1\n if (indent > 0) {\n const body = all.slice(indent).join(\"\")\n // An indent as wide as the window is dropped rather than honoured: keeping it would leave no room\n // for the text, and shrinking the width to fit it recurses forever. The recursion terminates either\n // way, because `body` cannot begin with a space.\n if (indent >= columns) {\n return wrapRows(body, columns).map((row) => ({\n ...row,\n from: row.from + indent,\n to: row.to + indent,\n }))\n }\n const pad = \" \".repeat(indent)\n return wrapRows(body, columns - indent).map((row) => ({\n text: `${pad}${row.text}`,\n lead: row.lead + indent,\n from: row.from + indent,\n to: row.to + indent,\n }))\n }\n\n const rows: WrappedRow[] = []\n // `at` is where the pending row starts in the source; `width` is how much of it is drawn so far.\n let at = 0\n let width = 0\n const push = (to: number) => {\n rows.push({ text: all.slice(at, to).join(\"\"), lead: 0, from: at, to })\n }\n let cursor = 0\n while (cursor <= all.length) {\n // The next word, and the single space that introduced it. A run of spaces is not collapsed —\n // only the one space a break consumes is, which is what keeps the offsets honest.\n let end = cursor\n while (end < all.length && all[end] !== \" \") end += 1\n const word = span(cursor, end)\n\n if (word > columns) {\n // Longer than any row can hold. Flush what is pending, then cut it into full rows.\n if (width > 0) {\n push(cursor === at ? cursor : cursor - 1)\n at = cursor\n width = 0\n }\n let take = cursor\n while (span(take, end) > columns) {\n // Advance by *columns*, not by cells. A cut that would land inside a double-width\n // character stops before it, which is why the row can come out one column short: half an\n // emoji is not a thing a terminal can draw, and drawing it anyway is how a row overflows.\n let stop = take\n let filled = 0\n while (stop < end && filled + (w[stop] ?? 0) <= columns) {\n filled += w[stop] ?? 0\n stop += 1\n }\n // A single character wider than the whole window would otherwise loop forever taking\n // nothing. Emit it alone and overflow by one column, which is the only option left.\n if (stop === take) stop = take + 1\n at = take\n push(stop)\n take = stop\n at = take\n }\n at = take\n width = span(take, end)\n } else if (width > 0 && width + 1 + word > columns) {\n // Does not fit beside what is already on this row. The space before it is the break and is\n // drawn by neither row, which is why `to` and the next `from` are not the same number.\n push(cursor - 1)\n at = cursor\n width = word\n } else {\n width = width === 0 ? word : width + 1 + word\n }\n\n if (end >= all.length) break\n cursor = end + 1\n }\n push(all.length)\n return rows\n}\n\nfunction wrapLine(line: string, columns: number): readonly string[] {\n return wrapRows(line, columns).map((row) => row.text)\n}\n\n/** A code-point column in `line` translated into the tab-expanded coordinates `wrapRows` reports. */\nexport function expandColumn(line: string, column: number): number {\n let out = 0\n for (const [at, ch] of [...line].entries()) {\n if (at >= column) break\n out += ch === \"\\t\" ? TAB_WIDTH : 1\n }\n return out\n}\n\n/** Every row `text` occupies at `columns`, newlines respected and long lines broken. */\nexport function wrapText(text: string, columns: number): readonly string[] {\n return text.split(\"\\n\").flatMap((line) => wrapLine(line, columns))\n}\n\n/**\n * The live pane: the rows to draw, how tall that makes it, and how much was dropped.\n *\n * Height-capped on purpose. Ink erases and redraws its whole dynamic tree per frame, so an uncapped pane\n * means redrawing the entire reply on every token — a cost that grows with the length of the answer,\n * precisely when the terminal is busiest. The newest rows are the ones kept, because they are what the\n * reader is looking at, and nothing is lost: the finished reply joins the transcript at `turn.end`.\n *\n * All three numbers from one wrap, because they were computed separately and disagreed. The component\n * needs the rows and the dropped count; the chat frame needs the height to subtract from the terminal\n * *before* the pane renders. Deriving them apart meant the notice's own row was counted by one caller and\n * not the other, which is a layout one row taller than the screen.\n */\nexport interface LivePane {\n /** What to draw, newest last. Already wrapped, so each is one row. */\n readonly lines: readonly string[]\n /** Rows the pane occupies, the \"… n hidden\" notice included. Zero when there is nothing to show. */\n readonly rows: number\n /** Rows dropped off the top. Non-zero is exactly the condition for drawing the notice. */\n readonly hidden: number\n}\n\nexport function livePane(text: string, columns: number, maxRows: number): LivePane {\n if (text === \"\" || maxRows <= 0) return { lines: [], rows: 0, hidden: 0 }\n const all = wrapText(text, columns)\n if (all.length <= maxRows) return { lines: all, rows: all.length, hidden: 0 }\n // The extra row is the notice itself.\n return {\n lines: all.slice(all.length - maxRows),\n rows: maxRows + 1,\n hidden: all.length - maxRows,\n }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,EAAoC,CACvE,OAAO,EAAK,MAAM;AAAA,CAAI,EAAE,QAAQ,CAAC,IAAS,EAAS,EAAM,CAAO,CAAC,EAyB9D,SAAS,EAAQ,CAAC,EAAc,EAAiB,EAA2B,CAC/E,GAAI,IAAS,IAAM,GAAW,EAAG,MAAO,CAAE,MAAO,CAAC,EAAG,KAAM,EAAG,OAAQ,CAAE,EACxE,IAAM,EAAM,GAAS,EAAM,CAAO,EAClC,GAAI,EAAI,QAAU,EAAS,MAAO,CAAE,MAAO,EAAK,KAAM,EAAI,OAAQ,OAAQ,CAAE,EAE5E,MAAO,CACH,MAAO,EAAI,MAAM,EAAI,OAAS,CAAO,EACrC,KAAM,EAAU,EAChB,OAAQ,EAAI,OAAS,CACzB",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "3F9E348E9E24AF4164756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B,N
|
|
3
|
-
export{
|
|
2
|
+
import{B,N,tA,G,Gr}from"./index-22fzzn7z.js";import{Qe}from"./index-hrwakb11.js";import{I}from"./index-323jvr1g.js";var r=I(N(),1);var t=r.default("music-metadata:parser:ID3");class gt extends G{constructor(){super(...arguments);this.id3parser=new Qe}static async startsWithID3v2Header(e){return(await e.peekToken(tA)).fileIdentifier==="ID3"}async parse(){try{await this.parseID3v2()}catch(e){if(e instanceof B)t("End-of-stream");else throw e}}finalize(){return}async parseID3v2(){if(await this.tryReadId3v2Headers(),t("End of ID3v2 header, go to MPEG-parser: pos=%s",this.tokenizer.position),await this.postId3v2Parse(),this.options.skipPostHeaders&&this.metadata.hasAny())this.finalize();else await new Gr(this.metadata,this.tokenizer,this.options).parse(),this.finalize()}async tryReadId3v2Headers(){if((await this.tokenizer.peekToken(tA)).fileIdentifier==="ID3")return t("Found ID3v2 header, pos=%s",this.tokenizer.position),await this.id3parser.parse(this.metadata,this.tokenizer,this.options),this.tryReadId3v2Headers()}}
|
|
3
|
+
export{gt};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
//# debugId=367F059FBB810F0464756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-pqw1n1pv.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { EndOfStreamError } from 'strtok3';\nimport initDebug from 'debug';\nimport { ID3v2Header } from './ID3v2Token.js';\nimport { ID3v2Parser } from './ID3v2Parser.js';\nimport { ID3v1Parser } from '../id3v1/ID3v1Parser.js';\nimport { BasicParser } from '../common/BasicParser.js';\nconst debug = initDebug('music-metadata:parser:ID3');\n/**\n * Abstract parser which tries take ID3v2 and ID3v1 headers.\n */\nexport class AbstractID3Parser extends BasicParser {\n constructor() {\n super(...arguments);\n this.id3parser = new ID3v2Parser();\n }\n static async startsWithID3v2Header(tokenizer) {\n return (await tokenizer.peekToken(ID3v2Header)).fileIdentifier === 'ID3';\n }\n async parse() {\n try {\n await this.parseID3v2();\n }\n catch (err) {\n if (err instanceof EndOfStreamError) {\n debug(\"End-of-stream\");\n }\n else {\n throw err;\n }\n }\n }\n finalize() {\n return;\n }\n async parseID3v2() {\n await this.tryReadId3v2Headers();\n debug('End of ID3v2 header, go to MPEG-parser: pos=%s', this.tokenizer.position);\n await this.postId3v2Parse();\n if (this.options.skipPostHeaders && this.metadata.hasAny()) {\n this.finalize();\n }\n else {\n const id3v1parser = new ID3v1Parser(this.metadata, this.tokenizer, this.options);\n await id3v1parser.parse();\n this.finalize();\n }\n }\n async tryReadId3v2Headers() {\n const id3Header = await this.tokenizer.peekToken(ID3v2Header);\n if (id3Header.fileIdentifier === 'ID3') {\n debug('Found ID3v2 header, pos=%s', this.tokenizer.position);\n await this.id3parser.parse(this.metadata, this.tokenizer, this.options);\n return this.tryReadId3v2Headers();\n }\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";oHACA,eAKA,IAAM,EAAQ,UAAU,2BAA2B,EAI5C,MAAM,WAA0B,CAAY,CAC/C,WAAW,EAAG,CACV,MAAM,GAAG,SAAS,EAClB,KAAK,UAAY,IAAI,gBAEZ,qBAAqB,CAAC,EAAW,CAC1C,OAAQ,MAAM,EAAU,UAAU,EAAW,GAAG,iBAAmB,YAEjE,KAAK,EAAG,CACV,GAAI,CACA,MAAM,KAAK,WAAW,EAE1B,MAAO,EAAK,CACR,GAAI,aAAe,EACf,EAAM,eAAe,EAEzB,KACI,MAAM,GAIlB,QAAQ,EAAG,CACP,aAEE,UAAU,EAAG,CAIf,GAHA,MAAM,KAAK,oBAAoB,EAC/B,EAAM,iDAAkD,KAAK,UAAU,QAAQ,EAC/E,MAAM,KAAK,eAAe,EACtB,KAAK,QAAQ,iBAAmB,KAAK,SAAS,OAAO,EACrD,KAAK,SAAS,EAElB,KAEI,MADoB,IAAI,GAAY,KAAK,SAAU,KAAK,UAAW,KAAK,OAAO,EAC7D,MAAM,EACxB,KAAK,SAAS,QAGhB,mBAAmB,EAAG,CAExB,IADkB,MAAM,KAAK,UAAU,UAAU,EAAW,GAC9C,iBAAmB,MAG7B,OAFA,EAAM,6BAA8B,KAAK,UAAU,QAAQ,EAC3D,MAAM,KAAK,UAAU,MAAM,KAAK,SAAU,KAAK,UAAW,KAAK,OAAO,EAC/D,KAAK,oBAAoB,EAG5C",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "367F059FBB810F0464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|