dispach 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -34
- package/dist/APEv2Parser-etzjd528.js +5 -0
- package/dist/{FlacParser-bf8y3e0w.js.map → APEv2Parser-etzjd528.js.map} +1 -1
- package/dist/{AiffParser-tbx3xkmk.js → AiffParser-y21k3fak.js} +3 -3
- package/dist/{AiffParser-tbx3xkmk.js.map → AiffParser-y21k3fak.js.map} +1 -1
- package/dist/App-4w3qkcs4.js +11 -0
- package/dist/{App-hjn867nc.js.map → App-4w3qkcs4.js.map} +1 -1
- package/dist/{AsfParser-d784ak3y.js → AsfParser-wd98k2h4.js} +3 -3
- package/dist/{AsfParser-d784ak3y.js.map → AsfParser-wd98k2h4.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-cbfaj500.js} +3 -3
- package/dist/{DsdiffParser-vxnfx80c.js.map → DsdiffParser-cbfaj500.js.map} +1 -1
- package/dist/{DsfParser-0xsh0zzk.js → DsfParser-tybrja4x.js} +3 -3
- package/dist/{DsfParser-0xsh0zzk.js.map → DsfParser-tybrja4x.js.map} +1 -1
- package/dist/FlacParser-7t7da7qy.js +5 -0
- package/dist/{APEv2Parser-9wqew3zv.js.map → FlacParser-7t7da7qy.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-gc94h1n9.js} +3 -3
- package/dist/{MP4Parser-tq7r7wd4.js.map → MP4Parser-gc94h1n9.js.map} +1 -1
- package/dist/{MatroskaParser-a79gsmzb.js → MatroskaParser-cy2k4fac.js} +3 -3
- package/dist/{MatroskaParser-a79gsmzb.js.map → MatroskaParser-cy2k4fac.js.map} +1 -1
- package/dist/{MpegParser-zs61b3wq.js → MpegParser-c460fwf0.js} +3 -3
- package/dist/{MpegParser-zs61b3wq.js.map → MpegParser-c460fwf0.js.map} +1 -1
- package/dist/{MusepackParser-bp8dm6nz.js → MusepackParser-8mq2eabg.js} +3 -3
- package/dist/{MusepackParser-bp8dm6nz.js.map → MusepackParser-8mq2eabg.js.map} +1 -1
- package/dist/{OggParser-7pxr1sn9.js → OggParser-7dnc6apg.js} +3 -3
- package/dist/{OggParser-7pxr1sn9.js.map → OggParser-7dnc6apg.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-kt7cds9c.js} +3 -3
- package/dist/{WavPackParser-gpf3r92t.js.map → WavPackParser-kt7cds9c.js.map} +1 -1
- package/dist/{WaveParser-3kcak550.js → WaveParser-g47ja0vy.js} +3 -3
- package/dist/{WaveParser-3kcak550.js.map → WaveParser-g47ja0vy.js.map} +1 -1
- package/dist/WizardApp-q4p979d1.js +5 -0
- package/dist/{WizardApp-494018sk.js.map → WizardApp-q4p979d1.js.map} +3 -3
- package/dist/{channels-yhdvxxrb.js → channels-4t89qpdt.js} +14 -14
- package/dist/{channels-yhdvxxrb.js.map → channels-4t89qpdt.js.map} +1 -1
- package/dist/client.d.ts +242 -1
- package/dist/client.js +11 -11
- package/dist/client.js.map +5 -5
- package/dist/{config-g0ybmm4t.js → config-35r6n1gh.js} +17 -17
- package/dist/{config-g0ybmm4t.js.map → config-35r6n1gh.js.map} +1 -1
- package/dist/{credential-pkme1sfe.js → credential-dpdgg4j6.js} +5 -5
- package/dist/{credential-pkme1sfe.js.map → credential-dpdgg4j6.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-1x8mzvz7.js +6 -0
- package/dist/{index-f056wkb4.js.map → index-1x8mzvz7.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-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-664xcamy.js +110 -0
- package/dist/index-664xcamy.js.map +13 -0
- package/dist/index-7mn8ack9.js +6 -0
- package/dist/{index-xa9crtzq.js.map → index-7mn8ack9.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-9qv87rq7.js → index-8h6kewy1.js} +7 -7
- package/dist/{index-9qv87rq7.js.map → index-8h6kewy1.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-9914wh1d.js +6 -0
- package/dist/index-9914wh1d.js.map +10 -0
- package/dist/{index-ye2yb3xf.js → index-a2eh8dnk.js} +6 -6
- package/dist/{index-ye2yb3xf.js.map → index-a2eh8dnk.js.map} +1 -1
- 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-j20k6k0m.js → index-dzy19wtf.js} +4 -4
- package/dist/{index-j20k6k0m.js.map → index-dzy19wtf.js.map} +1 -1
- package/dist/{index-gqaa06yh.js → index-eqqd4k4f.js} +9 -9
- package/dist/{index-gqaa06yh.js.map → index-eqqd4k4f.js.map} +1 -1
- package/dist/{index-633eqxry.js → index-ew997be5.js} +7 -7
- package/dist/{index-633eqxry.js.map → index-ew997be5.js.map} +1 -1
- package/dist/{index-y34s71qe.js → index-fa9wvpyw.js} +3 -3
- package/dist/{index-y34s71qe.js.map → index-fa9wvpyw.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-x9z2xnct.js → index-fcsg95m5.js} +5 -5
- package/dist/{index-x9z2xnct.js.map → index-fcsg95m5.js.map} +1 -1
- package/dist/{index-zjphh8ch.js → index-gbkma7ds.js} +4 -4
- package/dist/{index-zjphh8ch.js.map → index-gbkma7ds.js.map} +1 -1
- package/dist/{index-ac2wzspd.js → index-gq1npngp.js} +4 -4
- package/dist/{index-ac2wzspd.js.map → index-gq1npngp.js.map} +1 -1
- package/dist/{index-6r9h7ftn.js → index-haypwvzd.js} +85 -85
- package/dist/index-haypwvzd.js.map +21 -0
- 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-kjqksgch.js +429 -0
- package/dist/index-kjqksgch.js.map +12 -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-twcgf73h.js → index-ma6p7bt4.js} +4 -4
- package/dist/{index-twcgf73h.js.map → index-ma6p7bt4.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-psk6q25h.js → index-p1zy871m.js} +4 -4
- package/dist/{index-psk6q25h.js.map → index-p1zy871m.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-6c4p19m1.js → index-pszmnhgq.js} +2 -2
- package/dist/index-qg9bn980.js +1213 -0
- package/dist/{index-26ejkp8q.js.map → index-qg9bn980.js.map} +26 -23
- package/dist/index-qgsdgbk8.js +5 -0
- package/dist/{index-wk6andxq.js.map → index-qgsdgbk8.js.map} +2 -2
- package/dist/index-r4ax3x4d.js +74 -0
- package/dist/index-r4ax3x4d.js.map +13 -0
- 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-twn9bfm2.js +8 -0
- package/dist/{index-0mz7wpbw.js.map → index-twn9bfm2.js.map} +2 -2
- package/dist/{index-3fgq1acj.js → index-wc4entme.js} +10 -10
- package/dist/{index-3fgq1acj.js.map → index-wc4entme.js.map} +1 -1
- package/dist/{index-ad5c9t83.js → index-ynsvkqgb.js} +4 -4
- package/dist/{index-ad5c9t83.js.map → index-ynsvkqgb.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-307qmvb0.js → index-z157at3s.js} +25 -25
- package/dist/{index-307qmvb0.js.map → index-z157at3s.js.map} +1 -1
- package/dist/{index-pdsey1ab.js → index-zce9gy22.js} +62 -62
- package/dist/{index-pdsey1ab.js.map → index-zce9gy22.js.map} +1 -1
- 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 +307 -291
- 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 +17 -0
- package/dist/lib/source.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/{web-f6869dy2.js → web-zph4h3p9.js} +7 -7
- package/dist/{web-f6869dy2.js.map → web-zph4h3p9.js.map} +1 -1
- package/dist/wire.d.ts +31 -0
- package/dist/wire.js +2 -2
- 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/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-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
|
@@ -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,EA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A}from"./index-qg9bn980.js";import{gn,rt,TA,cn,ss}from"./index-9914wh1d.js";class ot extends A{static ERROR_NAME="UsageError"}function S(e,i){let n=Array.from({length:i.length+1},(o,g)=>g);for(let o=1;o<=e.length;o+=1){let g=[o];for(let l=1;l<=i.length;l+=1){let f=(n[l-1]??0)+(e[o-1]===i[l-1]?0:1),d=(g[l-1]??0)+1,_=(n[l]??0)+1;g.push(Math.min(f,d,_))}n=g}return n[i.length]??Math.max(e.length,i.length)}function M(e,i){let n,o=Number.POSITIVE_INFINITY;for(let g of i){let l=S(e,g);if(l<o)o=l,n=g}return n!==void 0&&o<=Math.max(2,Math.floor(e.length/3))?n:void 0}class R{#e;#t;constructor(e,i){this.#e=e,this.#t=i}#n(e,i){let n=this.#t.get(e);if(n===void 0)throw new ot({code:"cli_flag_not_declared",message:`No flag "${e}" is declared for this command.`,hint:"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader."});if(n.kind!==i)throw new ot({code:"cli_flag_kind_mismatch",message:`Flag "${e}" is declared as ${n.kind} but was read as ${i}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(e)}str(e){let i=this.#n(e,"string");return typeof i==="string"?i:void 0}num(e){let i=this.#n(e,"number");return typeof i==="number"?i:void 0}bool(e){return this.#n(e,"boolean")===!0}has(e){return this.#e.has(e)}}function c(e,i,n,o){return o===void 0?{code:e,message:i,hint:n}:{code:e,message:i,hint:n,field:o}}function y(e){let i=e[0];return new ot({code:"cli_usage",message:e.length===1&&i!==void 0?i.message:`${e.length} problems with the command line.`,hint:e.length===1&&i!==void 0?i.hint:"Each problem below names the flag and its fix.",...i?.field===void 0?{}:{field:i.field},details:e})}function D(e,i,n){let o=Number(i);if(i.trim()===""||!Number.isFinite(o))return c("cli_flag_not_a_number",`${n} expects a number, got ${JSON.stringify(i)}.`,`Pass a number, as in ${n} 50. The old parser silently used the default here, which made a typo look like it worked.`,n);if(e.integer===!0&&!Number.isInteger(o))return c("cli_flag_not_an_integer",`${n} expects a whole number, got ${i}.`,`Drop the fractional part: ${n} ${Math.trunc(o)}.`,n);if(e.min!==void 0&&o<e.min)return c("cli_flag_below_min",`${n} must be at least ${e.min}, got ${o}.`,`Pass ${e.min} or more.`,n);return o}function is(e){let i=e[0];if(i===void 0)return{kind:"usage"};if(i.startsWith("-")){let s=new Set(gn.flatMap((a)=>a.short===void 0?[`--${a.name}`]:[`--${a.name}`,`-${a.short}`])),r=e.filter((a)=>!s.has(a));if(r.length>0)throw y([c("cli_no_command","No command given.",`Run \`${t.slug} --help\` for the command list. Commands are ${rt.map((a)=>a.name).join(", ")}.`,r[0])]);if(e.includes("--version")||e.includes("-v"))return{kind:"version"};if(e.includes("--help")||e.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let n=TA(i);if(n===void 0){let s=M(i,rt.map((r)=>r.name));throw y([c("cli_unknown_command",`Unknown command "${i}".`,s===void 0?`Run \`${t.slug} --help\` for the command list.`:`Did you mean "${s}"? Run \`${t.slug} --help\` for the full list.`,i)])}let o=new Map(cn(n).map((s)=>[s.name,s])),g=new Map(cn(n).filter((s)=>s.short!==void 0).map((s)=>[s.short,s])),l=new Map,f=[],d=[],_=!1,w=(s,r,a)=>{if(r===""){d.push(c("cli_flag_empty_value",`${a} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",a));return}if(s.kind==="number"){let u=D(s,r,a);if(typeof u==="number")l.set(s.name,u);else d.push(u);return}l.set(s.name,r)};for(let s=1;s<e.length;s+=1){let r=e[s];if(r===void 0)continue;if(_){f.push(r);continue}if(r==="--"){_=!0;continue}if(r.startsWith("--")){let a=r.slice(2),u=a.indexOf("="),m=u===-1?a:a.slice(0,u),h=o.get(m);if(h===void 0){let k=ss(m,n.name),x=M(m,[...o.keys()]);d.push(c(k.length>0?"cli_flag_wrong_command":"cli_unknown_flag",k.length>0?`${n.name} does not accept --${m}.`:`Unknown flag --${m}.`,k.length>0?`--${m} is accepted by: ${k.join(", ")}.`:x===void 0?`Run \`${t.slug} ${n.name} --help\` for the flags this command accepts.`:`Did you mean --${x}?`,`--${m}`));continue}let p=`--${m}`;if(h.kind==="boolean"){if(u!==-1){d.push(c("cli_flag_takes_no_value",`${p} is a switch and takes no value.`,`Drop the "=${a.slice(u+1)}" — pass ${p} on its own.`,p));continue}l.set(h.name,!0);continue}if(u!==-1){w(h,a.slice(u+1),p);continue}let b=e[s+1];if(h.bare!==void 0&&(b===void 0||b.startsWith("-"))){l.set(h.name,h.bare);continue}if(b===void 0){d.push(c("cli_flag_needs_value",`${p} needs a value.`,`Pass one, as in ${p} <${h.placeholder??"value"}>.`,p));continue}w(h,b,p),s+=1;continue}if(r.startsWith("-")&&r.length>1){for(let a of[...r.slice(1)]){let u=g.get(a);if(u===void 0){d.push(c("cli_unknown_flag",`Unknown flag -${a}.`,`Run \`${t.slug} ${n.name} --help\` for the flags this command accepts.`,`-${a}`));continue}if(u.kind!=="boolean"){d.push(c("cli_short_flag_needs_value",`-${a} takes a value and cannot be bundled.`,`Write it on its own: --${u.name} <${u.placeholder??"value"}>.`,`-${a}`));continue}l.set(u.name,!0)}continue}f.push(r)}let v=new R(l,o);if(v.bool("help"))return{kind:"help",command:n};if(v.bool("version"))return{kind:"version"};let N=n.args.some((s)=>s.variadic===!0),F=n.args.filter((s)=>s.required);if(d.length>0)throw y(d);else if(f.length<F.length){let s=F[f.length];d.push(c("cli_missing_argument",`${n.name} needs ${s===void 0?"another argument":`a ${s.name}`}.`,`Usage: ${t.slug} ${n.name} ${n.args.map((r)=>`<${r.name}${r.variadic===!0?"...":""}>`).join(" ")}`))}else if(!N&&f.length>n.args.length){let s=f.slice(n.args.length);d.push(c("cli_unexpected_argument",`${n.name} takes ${n.args.length} argument(s), got ${f.length}.`,n.unexpectedArgHint??`Unexpected: ${s.join(" ")}. Quote a value containing spaces.`))}if(d.length>0)throw y(d);return{kind:"command",parsed:{command:n,positionals:f,flags:v}}}
|
|
3
|
+
export{ot,is};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
//# debugId=FC827B207626862064756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-ma6p7bt4.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The argument parser. Pure — argv in, a decision out, no I/O and no `process`.\n *\n * It replaces a parser that failed silently in four distinct ways, each of which is now a test:\n *\n * - **A value beginning with `-` was swallowed.** The old rule was \"consume the next token unless\n * it looks like a flag\", so `--input \"-5 degrees\"` set `input` to boolean `true`, the caller's\n * `typeof input === \"string\"` check failed, and the process opened an interactive session instead\n * of running the one turn it was asked for. The rule here has no such hole: whether a flag\n * consumes the next token is a property of the *flag*, declared in `commands.ts`, never a guess\n * about the value.\n * - **Unknown flags were ignored.** `--sesion local:x` ran against the default session silently.\n * - **A non-numeric `--limit` fell back to the default.**\n * - **`--help` with no command exited 1**, reporting failure for the one thing that had succeeded.\n *\n * Every problem found is collected rather than thrown on sight, so a line with two mistakes reports\n * both. `HarnessError.details` already renders that shape.\n */\n\nimport { BRAND, type ErrorDetail, HarnessError } from \"@dispach/core\"\nimport { COMMANDS, commandsAccepting, findCommand, flagsFor, GLOBAL_FLAGS } from \"#lib/commands\"\nimport type { FlagSpec, FlagValue, FlagValues, ParseResult } from \"#lib/schema\"\n\n/** Anything wrong with the command line itself. Distinct from anything wrong with a manifest. */\nexport class UsageError extends HarnessError {\n static override readonly ERROR_NAME = \"UsageError\"\n}\n\n// ─── nearest match ───────────────────────────────────────────────────────────────────────\n\nfunction distance(a: string, b: string): number {\n // Two rows rather than a full matrix; the strings here are flag names.\n let previous = Array.from({ length: b.length + 1 }, (_, i) => i)\n for (let i = 1; i <= a.length; i += 1) {\n const current = [i]\n for (let j = 1; j <= b.length; j += 1) {\n const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1)\n const insertion = (current[j - 1] ?? 0) + 1\n const deletion = (previous[j] ?? 0) + 1\n current.push(Math.min(substitution, insertion, deletion))\n }\n previous = current\n }\n return previous[b.length] ?? Math.max(a.length, b.length)\n}\n\nfunction nearest(word: string, candidates: readonly string[]): string | undefined {\n let best: string | undefined\n let bestScore = Number.POSITIVE_INFINITY\n for (const candidate of candidates) {\n const score = distance(word, candidate)\n if (score < bestScore) {\n bestScore = score\n best = candidate\n }\n }\n // A suggestion has to be plausible. Beyond a third of the word it is noise, and noise in an\n // error message is worse than no suggestion at all.\n return best !== undefined && bestScore <= Math.max(2, Math.floor(word.length / 3))\n ? best\n : undefined\n}\n\n// ─── flag values ─────────────────────────────────────────────────────────────────────────\n\nclass Values implements FlagValues {\n readonly #values: ReadonlyMap<string, FlagValue>\n readonly #specs: ReadonlyMap<string, FlagSpec>\n\n constructor(values: ReadonlyMap<string, FlagValue>, specs: ReadonlyMap<string, FlagSpec>) {\n this.#values = values\n this.#specs = specs\n }\n\n #expect(name: string, kind: FlagSpec[\"kind\"]): FlagValue | undefined {\n const spec = this.#specs.get(name)\n if (spec === undefined) {\n throw new UsageError({\n code: \"cli_flag_not_declared\",\n message: `No flag \"${name}\" is declared for this command.`,\n hint: \"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader.\",\n })\n }\n if (spec.kind !== kind) {\n throw new UsageError({\n code: \"cli_flag_kind_mismatch\",\n message: `Flag \"${name}\" is declared as ${spec.kind} but was read as ${kind}.`,\n hint: \"This is a bug in the CLI. The reader and lib/commands.ts disagree.\",\n })\n }\n return this.#values.get(name)\n }\n\n str(name: string): string | undefined {\n const value = this.#expect(name, \"string\")\n return typeof value === \"string\" ? value : undefined\n }\n\n num(name: string): number | undefined {\n const value = this.#expect(name, \"number\")\n return typeof value === \"number\" ? value : undefined\n }\n\n bool(name: string): boolean {\n return this.#expect(name, \"boolean\") === true\n }\n\n has(name: string): boolean {\n return this.#values.has(name)\n }\n}\n\n// ─── parse ───────────────────────────────────────────────────────────────────────────────\n\nfunction detail(code: string, message: string, hint: string, field?: string): ErrorDetail {\n return field === undefined ? { code, message, hint } : { code, message, hint, field }\n}\n\nfunction usage(details: ErrorDetail[]): UsageError {\n const first = details[0]\n return new UsageError({\n code: \"cli_usage\",\n message:\n details.length === 1 && first !== undefined\n ? first.message\n : `${details.length} problems with the command line.`,\n hint:\n details.length === 1 && first !== undefined\n ? first.hint\n : \"Each problem below names the flag and its fix.\",\n ...(first?.field === undefined ? {} : { field: first.field }),\n details,\n })\n}\n\nfunction readNumber(spec: FlagSpec, raw: string, written: string): number | ErrorDetail {\n const value = Number(raw)\n if (raw.trim() === \"\" || !Number.isFinite(value)) {\n return detail(\n \"cli_flag_not_a_number\",\n `${written} expects a number, got ${JSON.stringify(raw)}.`,\n `Pass a number, as in ${written} 50. The old parser silently used the default here, which made a typo look like it worked.`,\n written,\n )\n }\n if (spec.integer === true && !Number.isInteger(value)) {\n return detail(\n \"cli_flag_not_an_integer\",\n `${written} expects a whole number, got ${raw}.`,\n `Drop the fractional part: ${written} ${Math.trunc(value)}.`,\n written,\n )\n }\n if (spec.min !== undefined && value < spec.min) {\n return detail(\n \"cli_flag_below_min\",\n `${written} must be at least ${spec.min}, got ${value}.`,\n `Pass ${spec.min} or more.`,\n written,\n )\n }\n return value\n}\n\n/**\n * `argv` is everything after the program name.\n *\n * The command comes first, before any flag, as with git and docker. That ordering is what makes the\n * parse unambiguous: flag semantics depend on the command's spec, so the command has to be known\n * before a single flag can be interpreted.\n */\nexport function parse(argv: readonly string[]): ParseResult {\n const head = argv[0]\n\n if (head === undefined) return { kind: \"usage\" }\n\n if (head.startsWith(\"-\")) {\n // No command. Only the global flags can appear here, and only two of them do anything.\n const globals = new Set(\n GLOBAL_FLAGS.flatMap((flag) =>\n flag.short === undefined\n ? [`--${flag.name}`]\n : [`--${flag.name}`, `-${flag.short}`],\n ),\n )\n const unknown = argv.filter((token) => !globals.has(token))\n if (unknown.length > 0) {\n throw usage([\n detail(\n \"cli_no_command\",\n \"No command given.\",\n `Run \\`${BRAND.slug} --help\\` for the command list. Commands are ${COMMANDS.map((c) => c.name).join(\", \")}.`,\n unknown[0],\n ),\n ])\n }\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) return { kind: \"version\" }\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { kind: \"help\", command: undefined }\n }\n return { kind: \"usage\" }\n }\n\n const command = findCommand(head)\n if (command === undefined) {\n const suggestion = nearest(\n head,\n COMMANDS.map((c) => c.name),\n )\n throw usage([\n detail(\n \"cli_unknown_command\",\n `Unknown command \"${head}\".`,\n suggestion === undefined\n ? `Run \\`${BRAND.slug} --help\\` for the command list.`\n : `Did you mean \"${suggestion}\"? Run \\`${BRAND.slug} --help\\` for the full list.`,\n head,\n ),\n ])\n }\n\n const specs = new Map(flagsFor(command).map((flag) => [flag.name, flag]))\n const shorts = new Map(\n flagsFor(command)\n .filter((flag) => flag.short !== undefined)\n .map((flag) => [flag.short as string, flag]),\n )\n\n const values = new Map<string, FlagValue>()\n const positionals: string[] = []\n const errors: ErrorDetail[] = []\n let terminated = false\n\n const setValue = (spec: FlagSpec, raw: string, written: string): void => {\n if (raw === \"\") {\n errors.push(\n detail(\n \"cli_flag_empty_value\",\n `${written} was given an empty value.`,\n \"Pass a value, or drop the flag entirely to use the default.\",\n written,\n ),\n )\n return\n }\n if (spec.kind === \"number\") {\n const result = readNumber(spec, raw, written)\n if (typeof result === \"number\") values.set(spec.name, result)\n else errors.push(result)\n return\n }\n values.set(spec.name, raw)\n }\n\n for (let i = 1; i < argv.length; i += 1) {\n const token = argv[i]\n if (token === undefined) continue\n\n if (terminated) {\n positionals.push(token)\n continue\n }\n if (token === \"--\") {\n terminated = true\n continue\n }\n\n if (token.startsWith(\"--\")) {\n const body = token.slice(2)\n const eq = body.indexOf(\"=\")\n const name = eq === -1 ? body : body.slice(0, eq)\n const spec = specs.get(name)\n\n if (spec === undefined) {\n const elsewhere = commandsAccepting(name, command.name)\n const suggestion = nearest(name, [...specs.keys()])\n errors.push(\n detail(\n elsewhere.length > 0 ? \"cli_flag_wrong_command\" : \"cli_unknown_flag\",\n elsewhere.length > 0\n ? `${command.name} does not accept --${name}.`\n : `Unknown flag --${name}.`,\n elsewhere.length > 0\n ? `--${name} is accepted by: ${elsewhere.join(\", \")}.`\n : suggestion === undefined\n ? `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`\n : `Did you mean --${suggestion}?`,\n `--${name}`,\n ),\n )\n continue\n }\n\n const written = `--${name}`\n\n if (spec.kind === \"boolean\") {\n if (eq !== -1) {\n errors.push(\n detail(\n \"cli_flag_takes_no_value\",\n `${written} is a switch and takes no value.`,\n `Drop the \"=${body.slice(eq + 1)}\" — pass ${written} on its own.`,\n written,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n continue\n }\n\n if (eq !== -1) {\n setValue(spec, body.slice(eq + 1), written)\n continue\n }\n\n // Consume the next token unconditionally. This is the fix for the swallowed-value bug:\n // whether a token is a value is decided by the spec, never by whether it starts with a\n // dash. `--input -5` means the text \"-5\".\n const next = argv[i + 1]\n // Unless the spec declares a bare form, in which case a missing token or one starting with a\n // dash means the flag was written on its own. Opt-in per flag, because the inversion is only\n // safe for a field whose values cannot start with a dash — see `FlagSpec.bare`.\n if (spec.bare !== undefined && (next === undefined || next.startsWith(\"-\"))) {\n values.set(spec.name, spec.bare)\n continue\n }\n if (next === undefined) {\n errors.push(\n detail(\n \"cli_flag_needs_value\",\n `${written} needs a value.`,\n `Pass one, as in ${written} <${spec.placeholder ?? \"value\"}>.`,\n written,\n ),\n )\n continue\n }\n setValue(spec, next, written)\n i += 1\n continue\n }\n\n if (token.startsWith(\"-\") && token.length > 1) {\n // Short flags cluster only when every letter is a switch. Anything else is ambiguous\n // about which flag the trailing text belongs to, and guessing is how values get lost.\n for (const letter of [...token.slice(1)]) {\n const spec = shorts.get(letter)\n if (spec === undefined) {\n errors.push(\n detail(\n \"cli_unknown_flag\",\n `Unknown flag -${letter}.`,\n `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`,\n `-${letter}`,\n ),\n )\n continue\n }\n if (spec.kind !== \"boolean\") {\n errors.push(\n detail(\n \"cli_short_flag_needs_value\",\n `-${letter} takes a value and cannot be bundled.`,\n `Write it on its own: --${spec.name} <${spec.placeholder ?? \"value\"}>.`,\n `-${letter}`,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n }\n continue\n }\n\n positionals.push(token)\n }\n\n // Help wins over argument checking. Asking how to use a command you invoked wrongly is the most\n // likely next thing you want, and refusing to answer would be perverse.\n const flags = new Values(values, specs)\n if (flags.bool(\"help\")) return { kind: \"help\", command }\n if (flags.bool(\"version\")) return { kind: \"version\" }\n\n // Positional counting is only meaningful once every flag parsed. An unknown flag cannot consume\n // its value — the kind is unknown — so the orphan lands here as a positional, and reporting\n // \"takes 1 argument, got 2\" alongside the real mistake sends the reader looking in the wrong\n // place. Report causes, never their consequences.\n const variadic = command.args.some((arg) => arg.variadic === true)\n const required = command.args.filter((arg) => arg.required)\n if (errors.length > 0) {\n throw usage(errors)\n } else if (positionals.length < required.length) {\n const missing = required[positionals.length]\n errors.push(\n detail(\n \"cli_missing_argument\",\n `${command.name} needs ${missing === undefined ? \"another argument\" : `a ${missing.name}`}.`,\n `Usage: ${BRAND.slug} ${command.name} ${command.args.map((a) => `<${a.name}${a.variadic === true ? \"...\" : \"\"}>`).join(\" \")}`,\n ),\n )\n } else if (!variadic && positionals.length > command.args.length) {\n const extra = positionals.slice(command.args.length)\n errors.push(\n detail(\n \"cli_unexpected_argument\",\n `${command.name} takes ${command.args.length} argument(s), got ${positionals.length}.`,\n command.unexpectedArgHint ??\n `Unexpected: ${extra.join(\" \")}. Quote a value containing spaces.`,\n ),\n )\n }\n\n if (errors.length > 0) throw usage(errors)\n\n return { kind: \"command\", parsed: { command, positionals, flags } }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qFAwBO,MAAM,WAAmB,CAAa,QAChB,WAAa,YAC1C,CAIA,SAAS,CAAQ,CAAC,EAAW,EAAmB,CAE5C,IAAI,EAAW,MAAM,K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AAG,MAAO,CAAE,KAAM,SAAU,EAMpD,IAAM,EAAW,EAAQ,KAAK,KAAK,CAAC,IAAQ,EAAI,WAAa,EAAI,EAC3D,EAAW,EAAQ,KAAK,OAAO,CAAC,IAAQ,EAAI,QAAQ,EAC1D,GAAI,EAAO,OAAS,EAChB,MAAM,EAAM,CAAM,EACpB,KAAK,GAAI,EAAY,OAAS,EAAS,OAAQ,CAC7C,IAAM,EAAU,EAAS,EAAY,QACrC,EAAO,KACH,EACI,uBACA,GAAG,EAAQ,cAAc,IAAY,OAAY,mBAAqB,KAAK,EAAQ,UACnF,UAAU,EAAM,QAAQ,EAAQ,QAAQ,EAAQ,KAAK,IAAI,CAAC,IAAM,IAAI,EAAE,OAAO,EAAE,WAAa,GAAO,MAAQ,KAAK,EAAE,KAAK,GAAG,GAC9H,CACJ,EACF,KAAK,GAAI,CAAC,GAAY,EAAY,OAAS,EAAQ,KAAK,OAAQ,CAC9D,IAAM,EAAQ,EAAY,MAAM,EAAQ,KAAK,MAAM,EACnD,EAAO,KACH,EACI,0BACA,GAAG,EAAQ,cAAc,EAAQ,KAAK,2BAA2B,EAAY,UAC7E,EAAQ,mBACJ,eAAe,EAAM,KAAK,GAAG,qCACrC,CACJ,EAGJ,GAAI,EAAO,OAAS,EAAG,MAAM,EAAM,CAAM,EAEzC,MAAO,CAAE,KAAM,UAAW,OAAQ,CAAE,UAAS,cAAa,OAAM,CAAE",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "FC827B207626862064756E2164756E21",
|
|
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 return index === -1 ? 0 : index\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";sHAoBA,cAAS,UAAK,8DAuBP,SAAS,EAAS,EAAG,OAAM,QAAO,SAAQ,SAAQ,SAAyB,CAC9E,IAAQ,OAAM,MAAO,GAAS,EAAK,OAAQ,EAAO,CAAM,EAClD,EAAS,IAAI,IAAI,CAAM,EACvB,EAAU,EAAK,OACjB,CAAC,EAAK,IAAS,EAAI,OAAS,OAAS,KAAK,IAAI,EAAK,EAAI,MAAM,MAAM,EAAI,EACvE,CACJ,EACM,EAAU,GAAW,EAAO,CAAO,EAEzC,OACI,EAAC,EAAD,CAAK,cAAc,SAAnB,SAuDE,CAtDG,EAAO,EACJ,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,OACA,EAAM,SAFX,IAEsB,EAFtB,UAGE,EACF,KACH,EAAK,MAAM,EAAM,CAAE,EAAE,IAAI,CAAC,EAAK,IAAW,CACvC,IAAM,EAAK,EAAO,EAClB,GAAI,EAAI,OAAS,OAAQ,CACrB,IAAM,EAAS,EAAI,OAAS,SAC5B,OACI,EAAC,EAAD,CAEI,KAAK,WACL,KAAM,EACN,MAAO,EAAS,EAAM,OAAS,EAAM,MAJzC,SAQE,CAFG,EAAS,KAAO,OAChB,GAAY,EAAI,MAAO,GAAS,EAAS,EAAI,EAAE,IAN3C,CAOP,EAGV,IAAM,EAAW,IAAO,EAClB,EAAS,EAAO,IAAI,CAAE,EACtB,EAAQ,GACV,CACI,KAAM,EAAI,MACV,KAAM,EAAI,MAAQ,GAClB,YAAa,EAAI,aAAe,EACpC,EACA,CACJ,EACA,OACI,EAAC,EAAD,CAAe,KAAK,WAApB,SAYE,CAXE,E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5C,MAAO,IAAK,EAAO,OAAQ,EAAiB,EAAM,OAAQ,EAAO,EAAY,CAAO,CAAE,CAC1F,CACA,IAAK,SAAU,CACX,IAAM,EAAQ,EAAM,OAAO,MAC3B,GAAI,EAAW,KAAW,GAAM,OAAO,EACvC,IAAM,EAAS,EAAM,OAAO,SAAS,CAAK,EACpC,EAAM,OAAO,OAAO,CAAC,IAAU,IAAU,CAAK,EAC9C,CAAC,GAAG,EAAM,OAAQ,CAAK,EAAE,KAAK,CAAC,EAAG,IAAM,EAAI,CAAC,EACnD,MAAO,IAAK,EAAO,QAAO,CAC9B,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,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B,N
|
|
3
|
-
export{
|
|
2
|
+
import{B,N,tA,P,Gr}from"./index-ew997be5.js";import{Qe}from"./index-fa9wvpyw.js";import{I}from"./index-323jvr1g.js";var r=I(N(),1);var t=r.default("music-metadata:parser:ID3");class gt extends P{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=B4EAF5AA51B3562064756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-p1zy871m.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": "B4EAF5AA51B3562064756E2164756E21",
|
|
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 }\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AA4BA,IAAM,EAA+C,CACjD,CAAC,KAAQ,IAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,MAAQ,KAAM,EACf,CAAC,OAAS,MAAO,EACjB,CAAC,OAAS,MAAO,EACjB,CAAC,OAAS,MAAO,EACjB,CAAC,OAAS,MAAO,EACjB,CAAC,OAAS,MAAO,EACjB,CAAC,OAAS,MAAO,CACrB,EAGM,EAA+C,CACjD,CAAC,IAAQ,GAAM,EACf,CAAC,KAAQ,IAAM,EACf,CAAC,KAAQ,IAAM,EACf,CAAC,KAAQ,IAAM,EACf,CAAC,KAAQ,IAAM,EACf,CAAC,KAAQ,IAAM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