dispach 0.1.0
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 +596 -0
- package/dist/App-dxqm39zx.js +11 -0
- package/dist/App-dxqm39zx.js.map +25 -0
- package/dist/ConfigEditor-7v5nebvy.js +6 -0
- package/dist/ConfigEditor-7v5nebvy.js.map +11 -0
- package/dist/KeyProbe-vjhmdpx6.js +5 -0
- package/dist/KeyProbe-vjhmdpx6.js.map +11 -0
- package/dist/Picker-jxaesaxy.js +5 -0
- package/dist/Picker-jxaesaxy.js.map +10 -0
- package/dist/SessionPicker-z2t0p4b5.js +5 -0
- package/dist/SessionPicker-z2t0p4b5.js.map +11 -0
- package/dist/SkillBrowser-yyf2gy0q.js +5 -0
- package/dist/SkillBrowser-yyf2gy0q.js.map +11 -0
- package/dist/WizardApp-12ndxgqv.js +5 -0
- package/dist/WizardApp-12ndxgqv.js.map +13 -0
- package/dist/agents.d.ts +9 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/browse.d.ts +63 -0
- package/dist/browse.d.ts.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +34 -0
- package/dist/client.js.map +11 -0
- package/dist/components/App.d.ts +28 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/Banner.d.ts +16 -0
- package/dist/components/Banner.d.ts.map +1 -0
- package/dist/components/Brandmark.d.ts +31 -0
- package/dist/components/Brandmark.d.ts.map +1 -0
- package/dist/components/CheckList.d.ts +38 -0
- package/dist/components/CheckList.d.ts.map +1 -0
- package/dist/components/CommandOutput.d.ts +29 -0
- package/dist/components/CommandOutput.d.ts.map +1 -0
- package/dist/components/ConfigEditor.d.ts +64 -0
- package/dist/components/ConfigEditor.d.ts.map +1 -0
- package/dist/components/HistorySearch.d.ts +23 -0
- package/dist/components/HistorySearch.d.ts.map +1 -0
- package/dist/components/KeyProbe.d.ts +36 -0
- package/dist/components/KeyProbe.d.ts.map +1 -0
- package/dist/components/LineCursor.d.ts +55 -0
- package/dist/components/LineCursor.d.ts.map +1 -0
- package/dist/components/Live.d.ts +17 -0
- package/dist/components/Live.d.ts.map +1 -0
- package/dist/components/Palette.d.ts +21 -0
- package/dist/components/Palette.d.ts.map +1 -0
- package/dist/components/Picker.d.ts +23 -0
- package/dist/components/Picker.d.ts.map +1 -0
- package/dist/components/Prompt.d.ts +20 -0
- package/dist/components/Prompt.d.ts.map +1 -0
- package/dist/components/Screen.d.ts +39 -0
- package/dist/components/Screen.d.ts.map +1 -0
- package/dist/components/SelectList.d.ts +34 -0
- package/dist/components/SelectList.d.ts.map +1 -0
- package/dist/components/SessionPicker.d.ts +26 -0
- package/dist/components/SessionPicker.d.ts.map +1 -0
- package/dist/components/SkillBrowser.d.ts +39 -0
- package/dist/components/SkillBrowser.d.ts.map +1 -0
- package/dist/components/Spinner.d.ts +13 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/StatusBar.d.ts +11 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/SummaryCard.d.ts +11 -0
- package/dist/components/SummaryCard.d.ts.map +1 -0
- package/dist/components/TextField.d.ts +39 -0
- package/dist/components/TextField.d.ts.map +1 -0
- package/dist/components/Transcript.d.ts +23 -0
- package/dist/components/Transcript.d.ts.map +1 -0
- package/dist/components/WizardApp.d.ts +18 -0
- package/dist/components/WizardApp.d.ts.map +1 -0
- package/dist/components/WizardFrame.d.ts +19 -0
- package/dist/components/WizardFrame.d.ts.map +1 -0
- package/dist/config-yz0nz51b.js +24 -0
- package/dist/config-yz0nz51b.js.map +10 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/credential-wgt4gvcz.js +19 -0
- package/dist/credential-wgt4gvcz.js.map +10 -0
- package/dist/credential.d.ts +68 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/daemon.d.ts +47 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/editor.d.ts +81 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/hooks/useElapsed.d.ts +10 -0
- package/dist/hooks/useElapsed.d.ts.map +1 -0
- package/dist/hooks/useTerminalSize.d.ts +14 -0
- package/dist/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/hooks/useTurn.d.ts +41 -0
- package/dist/hooks/useTurn.d.ts.map +1 -0
- package/dist/index-2cvtz0fy.js +903 -0
- package/dist/index-2cvtz0fy.js.map +194 -0
- package/dist/index-3nwfz9jq.js +12 -0
- package/dist/index-3nwfz9jq.js.map +11 -0
- package/dist/index-6b7qvh1x.js +6 -0
- package/dist/index-6b7qvh1x.js.map +10 -0
- package/dist/index-6z0yr17z.js +12 -0
- package/dist/index-6z0yr17z.js.map +11 -0
- package/dist/index-7da4fqcr.js +7 -0
- package/dist/index-7da4fqcr.js.map +11 -0
- package/dist/index-8bmhd2hj.js +6 -0
- package/dist/index-8bmhd2hj.js.map +10 -0
- package/dist/index-9d011p3q.js +6 -0
- package/dist/index-9d011p3q.js.map +10 -0
- package/dist/index-9f9pp2ef.js +6 -0
- package/dist/index-9f9pp2ef.js.map +10 -0
- package/dist/index-9nsfs0vy.js +6 -0
- package/dist/index-9nsfs0vy.js.map +10 -0
- package/dist/index-9pj1ws0p.js +77 -0
- package/dist/index-9pj1ws0p.js.map +12 -0
- package/dist/index-b5wwtxzk.js +66 -0
- package/dist/index-b5wwtxzk.js.map +12 -0
- package/dist/index-b8zwg8a3.js +6 -0
- package/dist/index-b8zwg8a3.js.map +10 -0
- package/dist/index-bry9bzt3.js +427 -0
- package/dist/index-bry9bzt3.js.map +11 -0
- package/dist/index-bwckzbf8.js +6 -0
- package/dist/index-bwckzbf8.js.map +10 -0
- package/dist/index-cx3vz7sf.js +6 -0
- package/dist/index-cx3vz7sf.js.map +11 -0
- package/dist/index-e8n70sgj.js +6 -0
- package/dist/index-e8n70sgj.js.map +11 -0
- package/dist/index-fvhg0xyd.js +167 -0
- package/dist/index-fvhg0xyd.js.map +19 -0
- package/dist/index-gbnc99j8.js +14 -0
- package/dist/index-gbnc99j8.js.map +13 -0
- package/dist/index-h2yds678.js +7 -0
- package/dist/index-h2yds678.js.map +11 -0
- package/dist/index-j97vttdt.js +10 -0
- package/dist/index-j97vttdt.js.map +10 -0
- package/dist/index-jk0def33.js +6 -0
- package/dist/index-jk0def33.js.map +12 -0
- package/dist/index-jym27m75.js +6 -0
- package/dist/index-jym27m75.js.map +10 -0
- package/dist/index-mgdgx22q.js +10 -0
- package/dist/index-mgdgx22q.js.map +10 -0
- package/dist/index-mrtb5y08.js +6 -0
- package/dist/index-mrtb5y08.js.map +11 -0
- package/dist/index-my5cjx00.js +6 -0
- package/dist/index-my5cjx00.js.map +10 -0
- package/dist/index-qc2vrq9z.js +7 -0
- package/dist/index-qc2vrq9z.js.map +11 -0
- package/dist/index-rqbtm761.js +6 -0
- package/dist/index-rqbtm761.js.map +10 -0
- package/dist/index-rqzg861g.js +6 -0
- package/dist/index-rqzg861g.js.map +10 -0
- package/dist/index-t1xvacym.js +6 -0
- package/dist/index-t1xvacym.js.map +11 -0
- package/dist/index-xgqzk5cq.js +9 -0
- package/dist/index-xgqzk5cq.js.map +12 -0
- package/dist/index-xqyms08r.js +6 -0
- package/dist/index-xqyms08r.js.map +10 -0
- package/dist/index-yr25dnf5.js +6 -0
- package/dist/index-yr25dnf5.js.map +10 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +527 -0
- package/dist/index.js.map +48 -0
- package/dist/init.d.ts +34 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/keymap.d.ts +126 -0
- package/dist/keymap.d.ts.map +1 -0
- package/dist/keys.d.ts +17 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/lib/ambient.d.ts +69 -0
- package/dist/lib/ambient.d.ts.map +1 -0
- package/dist/lib/args.d.ts +33 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/bootstrap.d.ts +84 -0
- package/dist/lib/bootstrap.d.ts.map +1 -0
- package/dist/lib/browse.d.ts +89 -0
- package/dist/lib/browse.d.ts.map +1 -0
- package/dist/lib/browser.d.ts +55 -0
- package/dist/lib/browser.d.ts.map +1 -0
- package/dist/lib/chat-frame.d.ts +156 -0
- package/dist/lib/chat-frame.d.ts.map +1 -0
- package/dist/lib/clipboard.d.ts +32 -0
- package/dist/lib/clipboard.d.ts.map +1 -0
- package/dist/lib/commands.d.ts +26 -0
- package/dist/lib/commands.d.ts.map +1 -0
- package/dist/lib/composer.d.ts +85 -0
- package/dist/lib/composer.d.ts.map +1 -0
- package/dist/lib/config-apply.d.ts +51 -0
- package/dist/lib/config-apply.d.ts.map +1 -0
- package/dist/lib/config-editor.d.ts +113 -0
- package/dist/lib/config-editor.d.ts.map +1 -0
- package/dist/lib/config-env.d.ts +110 -0
- package/dist/lib/config-env.d.ts.map +1 -0
- package/dist/lib/config-rows.d.ts +37 -0
- package/dist/lib/config-rows.d.ts.map +1 -0
- package/dist/lib/config-view.d.ts +133 -0
- package/dist/lib/config-view.d.ts.map +1 -0
- package/dist/lib/confirm.d.ts +86 -0
- package/dist/lib/confirm.d.ts.map +1 -0
- package/dist/lib/const.d.ts +213 -0
- package/dist/lib/const.d.ts.map +1 -0
- package/dist/lib/csi.d.ts +70 -0
- package/dist/lib/csi.d.ts.map +1 -0
- package/dist/lib/curated.d.ts +44 -0
- package/dist/lib/curated.d.ts.map +1 -0
- package/dist/lib/daemon-plan.d.ts +151 -0
- package/dist/lib/daemon-plan.d.ts.map +1 -0
- package/dist/lib/dotenv-edit.d.ts +30 -0
- package/dist/lib/dotenv-edit.d.ts.map +1 -0
- package/dist/lib/env.d.ts +10 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/exit.d.ts +170 -0
- package/dist/lib/exit.d.ts.map +1 -0
- package/dist/lib/help.d.ts +10 -0
- package/dist/lib/help.d.ts.map +1 -0
- package/dist/lib/init-flow.d.ts +539 -0
- package/dist/lib/init-flow.d.ts.map +1 -0
- package/dist/lib/init-skills.d.ts +46 -0
- package/dist/lib/init-skills.d.ts.map +1 -0
- package/dist/lib/keyboard.d.ts +76 -0
- package/dist/lib/keyboard.d.ts.map +1 -0
- package/dist/lib/keys-view.d.ts +57 -0
- package/dist/lib/keys-view.d.ts.map +1 -0
- package/dist/lib/launchd.d.ts +151 -0
- package/dist/lib/launchd.d.ts.map +1 -0
- package/dist/lib/lifecycle.d.ts +126 -0
- package/dist/lib/lifecycle.d.ts.map +1 -0
- package/dist/lib/log-follow.d.ts +71 -0
- package/dist/lib/log-follow.d.ts.map +1 -0
- package/dist/lib/mouse.d.ts +84 -0
- package/dist/lib/mouse.d.ts.map +1 -0
- package/dist/lib/multiselect.d.ts +37 -0
- package/dist/lib/multiselect.d.ts.map +1 -0
- package/dist/lib/origins.d.ts +40 -0
- package/dist/lib/origins.d.ts.map +1 -0
- package/dist/lib/output.d.ts +29 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/palette.d.ts +69 -0
- package/dist/lib/palette.d.ts.map +1 -0
- package/dist/lib/probe.d.ts +158 -0
- package/dist/lib/probe.d.ts.map +1 -0
- package/dist/lib/providers.d.ts +63 -0
- package/dist/lib/providers.d.ts.map +1 -0
- package/dist/lib/provision.d.ts +163 -0
- package/dist/lib/provision.d.ts.map +1 -0
- package/dist/lib/remove-plan.d.ts +120 -0
- package/dist/lib/remove-plan.d.ts.map +1 -0
- package/dist/lib/render.d.ts +78 -0
- package/dist/lib/render.d.ts.map +1 -0
- package/dist/lib/resume.d.ts +69 -0
- package/dist/lib/resume.d.ts.map +1 -0
- package/dist/lib/rows.d.ts +69 -0
- package/dist/lib/rows.d.ts.map +1 -0
- package/dist/lib/sandbox.d.ts +101 -0
- package/dist/lib/sandbox.d.ts.map +1 -0
- package/dist/lib/schema.d.ts +491 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/screen.d.ts +102 -0
- package/dist/lib/screen.d.ts.map +1 -0
- package/dist/lib/scroll.d.ts +64 -0
- package/dist/lib/scroll.d.ts.map +1 -0
- package/dist/lib/select.d.ts +23 -0
- package/dist/lib/select.d.ts.map +1 -0
- package/dist/lib/service-env.d.ts +38 -0
- package/dist/lib/service-env.d.ts.map +1 -0
- package/dist/lib/service.d.ts +102 -0
- package/dist/lib/service.d.ts.map +1 -0
- package/dist/lib/session-commands.d.ts +229 -0
- package/dist/lib/session-commands.d.ts.map +1 -0
- package/dist/lib/session-key.d.ts +55 -0
- package/dist/lib/session-key.d.ts.map +1 -0
- package/dist/lib/sessions-view.d.ts +31 -0
- package/dist/lib/sessions-view.d.ts.map +1 -0
- package/dist/lib/source-cache.d.ts +105 -0
- package/dist/lib/source-cache.d.ts.map +1 -0
- package/dist/lib/source.d.ts +281 -0
- package/dist/lib/source.d.ts.map +1 -0
- package/dist/lib/sources.d.ts +107 -0
- package/dist/lib/sources.d.ts.map +1 -0
- package/dist/lib/spawn.d.ts +56 -0
- package/dist/lib/spawn.d.ts.map +1 -0
- package/dist/lib/stdin-tap.d.ts +41 -0
- package/dist/lib/stdin-tap.d.ts.map +1 -0
- package/dist/lib/subcommand.d.ts +57 -0
- package/dist/lib/subcommand.d.ts.map +1 -0
- package/dist/lib/systemd.d.ts +60 -0
- package/dist/lib/systemd.d.ts.map +1 -0
- package/dist/lib/templates.d.ts +35 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/terminal.d.ts +98 -0
- package/dist/lib/terminal.d.ts.map +1 -0
- package/dist/lib/text-selection.d.ts +75 -0
- package/dist/lib/text-selection.d.ts.map +1 -0
- package/dist/lib/theme.d.ts +90 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/types.d.ts +467 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/warnings.d.ts +79 -0
- package/dist/lib/warnings.d.ts.map +1 -0
- package/dist/lib/width.d.ts +39 -0
- package/dist/lib/width.d.ts.map +1 -0
- package/dist/lib/wizard.d.ts +95 -0
- package/dist/lib/wizard.d.ts.map +1 -0
- package/dist/lib/wordmark.d.ts +60 -0
- package/dist/lib/wordmark.d.ts.map +1 -0
- package/dist/lib/wrap.d.ts +74 -0
- package/dist/lib/wrap.d.ts.map +1 -0
- package/dist/memory.d.ts +25 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/model.d.ts +47 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/plugins.d.ts +15 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/remove.d.ts +52 -0
- package/dist/remove.d.ts.map +1 -0
- package/dist/run.d.ts +42 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/schedules.d.ts +41 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/serve.d.ts +41 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/sessions.d.ts +13 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/skills.d.ts +80 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/soul.d.ts +19 -0
- package/dist/soul.d.ts.map +1 -0
- package/dist/sources.d.ts +32 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/start.d.ts +26 -0
- package/dist/start.d.ts.map +1 -0
- package/dist/stop.d.ts +58 -0
- package/dist/stop.d.ts.map +1 -0
- package/dist/terminal-setup.d.ts +31 -0
- package/dist/terminal-setup.d.ts.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/transcript.d.ts +124 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/validate.d.ts +36 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/web-w7r68df1.js +14 -0
- package/dist/web-w7r68df1.js.map +11 -0
- package/dist/web.d.ts +36 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +33 -0
- package/dist/wire.js.map +10 -0
- package/dist/workspace.d.ts +19 -0
- package/dist/workspace.d.ts.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/ConfigEditor.tsx", "../src/lib/config-editor.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * An agent's settings, changed in place.\n *\n * A view under the Phase 5.5 contract: it never mounts itself, never calls `useApp().exit()`, and\n * reports through `onDone`. Two hosts use it — `config` mounts it standalone, and the chat opens it as a\n * pane — and neither is visible from here. `focused` gates the `useInput`, because Ink fires **every**\n * active hook: an editor over a live prompt would otherwise have two surfaces reading one keystroke,\n * which is a wrong action rather than a rendering fault.\n *\n * ## Two modes, one keymap\n *\n * Browsing is list navigation; editing a value is the full chat editor. That is exactly the shape\n * `keyToWizardIntent` already describes — `select: true` for the list, `select: false` for the field —\n * so there is no third intent mapper to keep in step. Esc means \"back out of this edit\" while editing\n * and \"close\" while browsing, which is what that mapper calls `back` either way; the component decides\n * which, because only it knows the mode.\n *\n * ## Every confirmed edit is written immediately\n *\n * No staged set, no unsaved state, no cancel-all. Each confirmation goes through the same\n * `applySet`/`applyAllow`/`applySecret` the plain commands use, so every state the file is in is valid\n * and a closed pane cannot discard work. The row list is re-read after each write rather than patched,\n * because a write may normalise a value, an `allowFrom` change rewrites the whole channels list, and a\n * secret changes a row without touching the manifest at all.\n */\n\nimport { Box, Text, useInput } from \"ink\"\nimport { useState } from \"react\"\nimport { TextField } from \"#components/TextField\"\nimport { applyIntent } from \"#editor\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { keyToWizardIntent } from \"#keymap\"\nimport {\n beginEdit,\n beginWrite,\n type ConfigEditorState,\n cancelEdit,\n current,\n type EditorRow,\n moveCursor,\n openEditor,\n refuse,\n rowKey,\n settle,\n typing,\n} from \"#lib/config-editor\"\nimport { FIELD_ROWS, MIN_SCREEN_ROWS, SCREEN_CHROME_ROWS } from \"#lib/const\"\nimport { clip, viewport } from \"#lib/rows\"\nimport type { SelectMove } from \"#lib/select\"\nimport { THEME } from \"#lib/theme\"\n\nexport interface ConfigEditorProps {\n /** The rows as they are now. Read by the host, because reading a file is not a component's job. */\n readonly rows: readonly EditorRow[]\n /**\n * Perform the row's edit and return the sentence to show, or throw with one.\n *\n * The host owns this because it is the only async part, and because the two hosts resolve the\n * manifest differently — a pane already knows which agent it is talking to.\n */\n readonly apply: (row: EditorRow, raw: string) => Promise<string>\n /** Re-read the rows from disk after a write. */\n readonly reload: () => readonly EditorRow[]\n readonly columns: number\n /**\n * The most rows the list may use. A **ceiling**, not the height: the terminal always wins.\n *\n * Passing it as the height put the whole list on screen at once on a 30-row terminal, which is one\n * row too many — Ink's own output then scrolls the buffer, and the `tools` block, the cursor and the\n * footer all went off the top with nothing saying so. An overflowing frame is corruption, not a\n * scrollbar.\n */\n readonly window: number\n readonly focused?: boolean\n /** True when at least one write landed, so a host can offer a restart. */\n readonly onDone: (changed: boolean) => void\n}\n\nexport function ConfigEditor({\n rows,\n apply,\n reload,\n columns,\n window,\n focused = true,\n onDone,\n}: ConfigEditorProps) {\n const size = useTerminalSize()\n // The same clamp `SkillBrowser` uses. Biased low on purpose: a row short of the terminal is a blank\n // line, and a row over it scrolls the whole layout away.\n const visible = Math.max(MIN_SCREEN_ROWS, Math.min(window, size.rows - SCREEN_CHROME_ROWS))\n // Held here, like every other view in this directory: `SkillBrowser` and `SessionPicker` own their\n // state and their single `useInput` too. The alternative put `useState` in `config.ts`, which is a\n // shared command path — and a static React import there is ~170-210 ms paid by every command,\n // including `validate --json`, which is why a boundaries test refuses it.\n const [state, setState] = useState<ConfigEditorState>(() => openEditor(rows))\n const [changed, setChanged] = useState(false)\n const row = current(state)\n\n useInput(\n (input, key) => {\n if (state.busy) return\n\n const intent = keyToWizardIntent(input, key, {\n select: state.mode === \"browse\",\n empty: state.editor.value === \"\",\n })\n\n if (intent.kind === \"abort\") {\n onDone(changed)\n return\n }\n if (intent.kind === \"back\") {\n // The same key, two meanings, decided here because only the component knows the mode:\n // leave the field, or leave the editor.\n if (state.mode === \"editing\") setState(cancelEdit)\n else onDone(changed)\n return\n }\n if (intent.kind === \"list\") {\n if (intent.intent.kind === \"move\") {\n const move = intent.intent.move\n setState((s) => moveCursor(s, targetOf(move, s)))\n }\n return\n }\n if (intent.kind === \"commit\") {\n if (state.mode === \"browse\") {\n setState(beginEdit)\n return\n }\n void confirm()\n return\n }\n // An edit keystroke, applied to the buffer.\n setState((s) => typing(s, applyIntent(s.editor, intent.intent)))\n },\n { isActive: focused },\n )\n\n async function confirm(): Promise<void> {\n const target = current(state)\n if (target === undefined) return\n setState(beginWrite)\n try {\n const note = await apply(target, state.editor.value)\n setChanged(true)\n setState((s) => settle(s, reload(), note))\n } catch (error) {\n setState((s) => refuse(s, error instanceof Error ? error.message : String(error)))\n }\n }\n\n if (state.mode === \"editing\" && row !== undefined) {\n return (\n <Box flexDirection=\"column\">\n <Text color={THEME.muted} wrap=\"truncate\">\n {` ${describeRow(row)}`}\n </Text>\n <TextField\n label={labelFor(row)}\n editor={state.editor}\n secret={row.kind === \"secret\"}\n // Without these the value is clipped at the terminal's edge and the caret sits past\n // the clip: `tools.pinned` is 92 characters in a generated manifest, so the first\n // long row anybody opens is one they cannot see themselves typing in.\n columns={columns}\n // Generous, because while editing this view *is* the screen: it draws a description,\n // the field and a hint, and nothing else. `FIELD_ROWS` is the shared floor for a\n // field sharing space with other content; here the space is free, and a value that\n // scrolled while two-thirds of the terminal sat empty would be a self-inflicted\n // version of the bug this fixes. At 40 columns — the documented floor — eight rows\n // holds about 320 characters, past anything a manifest field contains.\n maxRows={Math.max(FIELD_ROWS, visible - 2)}\n {...(state.note === undefined ? {} : { error: state.note })}\n />\n <Text dimColor wrap=\"truncate\">\n {state.busy ? \" writing…\" : ` enter writes it · ${keepHint(row)} · ^C closes`}\n </Text>\n </Box>\n )\n }\n\n const { from, to } = viewport(state.rows.length, state.cursor, visible)\n return (\n <Box flexDirection=\"column\">\n {from > 0 ? <Text dimColor wrap=\"truncate\">{` ↑ ${from} above`}</Text> : undefined}\n {state.rows.slice(from, to).map((entry, offset) => (\n <Row\n key={rowKey(entry)}\n row={entry}\n selected={from + offset === state.cursor}\n columns={columns}\n />\n ))}\n {to < state.rows.length ? (\n <Text dimColor wrap=\"truncate\">{` ↓ ${state.rows.length - to} below`}</Text>\n ) : undefined}\n <Text color={state.note === undefined ? THEME.muted : THEME.accent} wrap=\"truncate\">\n {state.note === undefined\n ? \" ↑↓ move · enter changes it · esc closes\"\n : ` ${state.note}`}\n </Text>\n </Box>\n )\n}\n\nfunction Row({\n row,\n selected,\n columns,\n}: {\n readonly row: EditorRow\n readonly selected: boolean\n readonly columns: number\n}) {\n if (row.kind === \"heading\") {\n return (\n <Text color={THEME.muted} wrap=\"truncate\">\n {`\\n ${row.label}`}\n </Text>\n )\n }\n // The name column is fixed so the values line up, and clipped rather than wrapped: a row that wraps\n // is a broken list, and the alignment is what makes a column of values readable at all.\n const name = clip(labelFor(row), Math.min(34, Math.max(12, Math.floor(columns * 0.34))))\n const value = clip(valueNow(row), Math.max(8, columns - name.length - 8))\n return (\n <Text wrap=\"truncate\">\n {selected ? <Text color={THEME.accent}>{\" ❯ \"}</Text> : <Text>{\" \"}</Text>}\n <Text>{name.padEnd(Math.min(34, Math.max(12, Math.floor(columns * 0.34))))}</Text>\n <Text color={THEME.muted}>{` ${value}`}</Text>\n </Text>\n )\n}\n\n/**\n * Where a move wants the cursor, before headings are stepped over.\n *\n * A digit jumps to a *row* index, so it can land on a heading — `moveCursor` then walks off it in the\n * direction of travel, which for a jump means whichever way it came from. Handled by asking for the\n * position rather than by the mover knowing about headings, so the skipping lives in one place.\n */\nfunction targetOf(move: SelectMove, state: ConfigEditorState): number {\n switch (move.kind) {\n case \"up\":\n return state.cursor - 1\n case \"down\":\n return state.cursor + 1\n case \"first\":\n return 0\n case \"last\":\n return state.rows.length - 1\n case \"jump\":\n return move.index\n }\n}\n\n/** The name a row is edited under. */\nexport function labelFor(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return row.setting.path\n case \"allow\":\n return `${row.channelId}.allowFrom`\n case \"secret\":\n return row.name\n case \"heading\":\n return row.label\n }\n}\n\n/**\n * What the row currently holds.\n *\n * A secret shows only whether it is **set** — never the value, and not even its length. The point of the\n * masked field is that the value is not on screen, and a listing that leaked it would make the masking\n * decorative.\n */\nexport function valueNow(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return row.value === undefined || row.value === null\n ? \"(not set)\"\n : typeof row.value === \"string\"\n ? row.value\n : JSON.stringify(row.value)\n case \"allow\":\n return row.handles.length === 0 ? \"(nobody)\" : row.handles.join(\" \")\n case \"secret\":\n return row.present ? \"(set)\" : \"(not set)\"\n case \"heading\":\n return \"\"\n }\n}\n\n/**\n * What escape keeps, short enough to be a hint rather than a second copy of the value.\n *\n * Naming the old value is genuinely useful for a scalar — `esc keeps nlt` tells you what backing out\n * gets you. For a list it was a 92-character echo of the line directly above it, truncated by the\n * terminal, which is noise in the one row that should be telling you which keys do what.\n */\nfunction keepHint(row: EditorRow): string {\n const value = valueNow(row)\n return value.length <= KEEP_HINT_CHARS ? `esc keeps ${value}` : \"esc cancels\"\n}\n\n/** Past this, naming the old value is a second copy of it rather than a hint. */\nconst KEEP_HINT_CHARS = 24\n\n/** The one-line explanation shown above the field while editing. */\nfunction describeRow(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return row.setting.means\n case \"allow\":\n return `handles this channel accepts messages from, separated by spaces. Empty refuses everyone`\n case \"secret\":\n return row.why\n case \"heading\":\n return row.label\n }\n}\n",
|
|
6
|
+
"/**\n * The config editor as a pure reducer: what the rows are, where the cursor is, what is being typed.\n *\n * Same grain as `lib/wizard.ts` and `lib/select.ts` — the screen root owns one `useInput` and the\n * arithmetic lives here, so navigating a list and rejecting a bad handle are assertable as data rather\n * than by driving a terminal.\n *\n * ## Why a row is not just a setting\n *\n * The catalogue in core answers \"what fields exist\". An editor has to answer \"what can I change from\n * here\", and three of those are not dotted paths:\n *\n * - **A secret.** `.env` is a protected path precisely so the agent cannot write it, which leaves the\n * person as the only actor who can — and the editor is where they are. Masked as it is typed.\n * - **`allowFrom`, once per channel.** It lives inside a list entry, so `channels[].allowFrom` is one\n * catalogue row and *n* editable ones. Expanded here, keyed by the channel's declared id.\n * - **A heading.** Unselectable, and the cursor must step over it in the direction it was moving —\n * parking on one draws no cursor at all, which reads as a broken keyboard rather than a skipped row.\n *\n * ## Why every confirmed edit is written immediately\n *\n * There is no staged set and no unsaved state. Each confirmation goes through the same `editManifest`\n * call `config set` makes, so every state the file is ever in is valid, a closed pane cannot discard\n * work, and two edits that are individually fine cannot combine into an invalid document nobody\n * reviewed. The cost is stated rather than hidden: there is no cancel-all, and undo is `config set`\n * with the old value, which the row still shows until the write lands.\n */\n\nimport type { Setting } from \"@dispach/core\"\nimport { EMPTY_EDITOR } from \"#editor\"\nimport type { EditorState } from \"#lib/types\"\n\n/** One line of the editor. Only three kinds are selectable. */\nexport type EditorRow =\n /** A dotted path, edited as the text that would appear in the file. */\n | { readonly kind: \"setting\"; readonly setting: Setting; readonly value: unknown }\n /** One channel's inbound allowlist, edited as space-separated handles. */\n | {\n readonly kind: \"allow\"\n readonly channelId: string\n readonly channelType: string\n readonly handles: readonly string[]\n }\n /** An env variable the manifest depends on. Never displays its value, only whether it is set. */\n | {\n readonly kind: \"secret\"\n readonly name: string\n readonly why: string\n readonly present: boolean\n }\n /** A group label. Never selectable. */\n | { readonly kind: \"heading\"; readonly label: string }\n\nexport interface ConfigEditorState {\n readonly rows: readonly EditorRow[]\n readonly cursor: number\n readonly mode: \"browse\" | \"editing\"\n /** The buffer while editing. Empty and unused while browsing. */\n readonly editor: EditorState\n /**\n * The result of the last write, or why one was refused. Cleared as soon as anything is typed.\n *\n * `| undefined` rather than merely optional: under `exactOptionalPropertyTypes` an omitted key and an\n * explicit `undefined` are different types, and this one is *cleared* far more often than it is left\n * out — a spread that had to omit the key to reset it would be unreadable.\n */\n readonly note?: string | undefined\n /** Set while a write is in flight, so the row cannot be confirmed twice. */\n readonly busy: boolean\n}\n\nexport function isSelectable(row: EditorRow | undefined): boolean {\n return row !== undefined && row.kind !== \"heading\"\n}\n\n/** A stable identity for a row, for React keys and for tests. */\nexport function rowKey(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return `setting:${row.setting.path}`\n case \"allow\":\n return `allow:${row.channelId}`\n case \"secret\":\n return `secret:${row.name}`\n case \"heading\":\n return `heading:${row.label}`\n }\n}\n\n/** The path or name a row writes to, for a caller reporting what happened. */\nexport function rowTarget(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return row.setting.path\n case \"allow\":\n return `${row.channelId}.allowFrom`\n case \"secret\":\n return row.name\n case \"heading\":\n return row.label\n }\n}\n\nexport function firstSelectable(rows: readonly EditorRow[]): number {\n const at = rows.findIndex((row) => isSelectable(row))\n return at === -1 ? 0 : at\n}\n\nexport function openEditor(rows: readonly EditorRow[]): ConfigEditorState {\n return {\n rows,\n cursor: firstSelectable(rows),\n mode: \"browse\",\n editor: EMPTY_EDITOR,\n busy: false,\n }\n}\n\n/**\n * Move the cursor, stepping over headings in the direction of travel.\n *\n * Walk that way, then reverse, then stay put — and read the direction off the *indices* rather than the\n * kind of move, because `first` travels backwards to row 0 and must then search forwards. A cursor that\n * runs out of list stays where it is; it never lands on a row where enter does nothing.\n */\nexport function moveCursor(state: ConfigEditorState, to: number): ConfigEditorState {\n const total = state.rows.length\n if (total === 0) return state\n const clamped = Math.max(0, Math.min(total - 1, to))\n const forwards = clamped >= state.cursor\n const step = forwards ? 1 : -1\n\n for (let at = clamped; at >= 0 && at < total; at += step) {\n if (isSelectable(state.rows[at])) return { ...state, cursor: at }\n }\n // Nothing that way. Try the other, which is what makes the ends of the list behave.\n for (let at = clamped; at >= 0 && at < total; at -= step) {\n if (isSelectable(state.rows[at])) return { ...state, cursor: at }\n }\n return state\n}\n\n/** The row the cursor is on, or `undefined` for an empty list. */\nexport function current(state: ConfigEditorState): EditorRow | undefined {\n return state.rows[state.cursor]\n}\n\n/**\n * What a row's value looks like in the buffer when editing starts.\n *\n * A secret starts **empty**, never seeded with what is there: the point of the masked field is that the\n * value is not on screen, and pre-filling it would put it in the frame in every sense that matters.\n */\nexport function seedFor(row: EditorRow): string {\n switch (row.kind) {\n case \"setting\":\n return row.value === undefined || row.value === null\n ? \"\"\n : typeof row.value === \"string\"\n ? row.value\n : JSON.stringify(row.value)\n case \"allow\":\n return row.handles.join(\" \")\n case \"secret\":\n case \"heading\":\n return \"\"\n }\n}\n\nexport function beginEdit(state: ConfigEditorState): ConfigEditorState {\n const row = current(state)\n if (row === undefined || !isSelectable(row) || state.busy) return state\n const seed = seedFor(row)\n return {\n ...state,\n mode: \"editing\",\n editor: { ...EMPTY_EDITOR, value: seed, cursor: [...seed].length },\n note: undefined,\n }\n}\n\nexport function cancelEdit(state: ConfigEditorState): ConfigEditorState {\n if (state.mode !== \"editing\") return state\n return { ...state, mode: \"browse\", editor: EMPTY_EDITOR, note: undefined }\n}\n\n/** Replace the buffer, which is what the host does after applying a keystroke to it. */\nexport function typing(state: ConfigEditorState, editor: EditorState): ConfigEditorState {\n // The note describes the previous write, so the first keystroke of the next edit retires it.\n return { ...state, editor, note: undefined }\n}\n\nexport function beginWrite(state: ConfigEditorState): ConfigEditorState {\n return { ...state, busy: true }\n}\n\n/**\n * A write finished. `rows` is re-read from the file rather than patched in place.\n *\n * Patching would drift: `editManifest` validates and may normalise, an `allowFrom` write rewrites the\n * whole `channels` list, and a secret changes a row's `present` without touching the manifest at all.\n * Re-reading is one source of truth and costs a file read nobody notices.\n */\nexport function settle(\n state: ConfigEditorState,\n rows: readonly EditorRow[],\n note: string,\n): ConfigEditorState {\n return {\n ...state,\n rows,\n cursor: Math.min(state.cursor, Math.max(0, rows.length - 1)),\n mode: \"browse\",\n editor: EMPTY_EDITOR,\n busy: false,\n note,\n }\n}\n\n/** A write was refused. The buffer stays, so the value can be corrected rather than retyped. */\nexport function refuse(state: ConfigEditorState, note: string): ConfigEditorState {\n return { ...state, busy: false, note }\n}\n"
|
|
7
|
+
],
|
|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B,QACD,MAAO,8FACN,SACD,OAAO,EAAI,QACV,UACD,OAAO,EAAI",
|
|
9
|
+
"debugId": "D0C08C3E6307488B64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o,bn}from"./index-jk0def33.js";import{D,mn,Lt}from"./index-6z0yr17z.js";import{Box as x,Text as a,useInput as I}from"ink";import{useState as k}from"react";function P(e){return[...new TextEncoder().encode(e)].map((t)=>t.toString(16).padStart(2,"0")).join(" ")}function E(e){let t=[];if(e.ctrl)t.push("ctrl");if(e.meta)t.push("meta");if(e.super)t.push("super");if(e.shift)t.push("shift");for(let[r,s]of[["up",e.upArrow],["down",e.downArrow],["left",e.leftArrow],["right",e.rightArrow],["pageUp",e.pageUp],["pageDown",e.pageDown],["home",e.home],["end",e.end],["return",e.return],["escape",e.escape],["tab",e.tab],["backspace",e.backspace],["delete",e.delete]])if(s)t.push(r);if(e.eventType!==void 0&&e.eventType!=="press")t.push(e.eventType);return t.length===0?"—":t.join(" ")}function R(e){return e.super||e.eventType!==void 0}function y(e,t){if(!t)return"not requested — the override is set, so cmd chords cannot arrive";if(e.some((r)=>R(r.key)))return"active — a keystroke carried a modifier only the protocol can express";return"requested; nothing pressed yet has proved it — try cmd+left, or option+r"}function m(e){let t=[...e.bytes].map((r)=>{let s=r.codePointAt(0)??0;return s<32||s===127?".":r}).join("");return[`bytes ${P(e.bytes)}${t===""?"":` ${t}`}`,`ink ${E(e.key)}${e.input===""?"":` input ${JSON.stringify(e.input)}`}`,`intent ${e.intent.kind}`]}import{jsx as i,jsxs as d}from"react/jsx-runtime";var A=6,h=0;function H({columns:e,asked:t,terminal:r,takeRaw:s,correctKeys:u,onDone:g}){let[l,b]=k([]);return I((n,c)=>{let w=s?.(),f=c,p=u===void 0?f:u(f,n);if(n==="q"&&!p.ctrl&&!p.meta&&!p.super){g();return}let T=Lt(n,p,mn(D,!1));h+=1;let K=h,S=w??n;b((v)=>[...v,{at:K,bytes:S,input:n,key:p,intent:T}].slice(-A))}),d(x,{flexDirection:"column",children:[d(a,{color:o.accent,bold:!0,wrap:"truncate",children:["key probe · ",r]}),d(a,{color:o.muted,wrap:"truncate",children:["protocol ",y(l,t)]}),i(a,{children:" "}),l.length===0?i(a,{color:o.muted,wrap:"truncate",children:"press any chord — the bytes, Ink's reading of them, and the resolved intent"}):null,l.map((n)=>d(x,{flexDirection:"column",children:[i(a,{color:o.border,wrap:"truncate",children:bn("",e)}),m(n).map((c)=>i(a,{wrap:"truncate",children:c},c))]},`stroke-${n.at}`)),i(a,{children:" "}),i(a,{dimColor:!0,wrap:"truncate",children:" q leaves · every other key is recorded, ^C included"})]})}export{H as KeyProbe};
|
|
3
|
+
|
|
4
|
+
//# debugId=C1F146CC6976C40764756E2164756E21
|
|
5
|
+
//# sourceMappingURL=KeyProbe-vjhmdpx6.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/KeyProbe.tsx", "../src/lib/keys-view.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The key probe: press a chord, see what arrived.\n *\n * A *view* in this repo's sense — it owns its single `useInput` and reports through `onDone`, and never\n * mounts itself or calls `useApp().exit()`. The host command owns the screen.\n *\n * It deliberately claims every key including `^C`, because the whole point is to show what a chord does:\n * a probe that exited on the chord you wanted to inspect would be unable to inspect it. `q` leaves, and\n * the footer says so.\n */\n\nimport { Box, Text, useInput } from \"ink\"\nimport { useState } from \"react\"\nimport { EMPTY_EDITOR } from \"#editor\"\nimport { keyContext, keyToIntent } from \"#keymap\"\nimport { type Keystroke, keystrokeRows, protocolVerdict } from \"#lib/keys-view\"\nimport { headingRule } from \"#lib/rows\"\nimport { THEME } from \"#lib/theme\"\nimport type { KeyState } from \"#lib/types\"\n\nconst KEEP = 6\n\n/**\n * A monotonic id per press, because two presses of the same key are two rows.\n *\n * An array index would key row 0 to whatever is currently oldest, so evicting the top of the window\n * re-keys every row below it and React reconciles the wrong nodes. Held outside the component: it counts\n * *events*, and a remount starting over is fine because the list starts over with it.\n */\nlet pressed = 0\n\n/** A keystroke plus the sequence number that keys its row. */\ninterface Recorded extends Keystroke {\n readonly at: number\n}\n\nexport interface KeyProbeProps {\n readonly columns: number\n /** Whether this process asked the terminal for the protocol, which the verdict needs to be honest. */\n readonly asked: boolean\n readonly terminal: string\n /**\n * The next unread stdin chunk, or `undefined`.\n *\n * Injected rather than read here for the usual reason — a component that attached its own stdin\n * listener would have to care about registration order relative to Ink's, which is the host's\n * business. `undefined` is a real answer: it means nothing was queued, and the row says so.\n */\n readonly takeRaw?: () => string | undefined\n /**\n * The same modifier correction the chat applies.\n *\n * Without it the probe would report Ink's raw reading and the chat would act on a corrected one, so a\n * chord could show `meta` here and resolve as a cmd chord there — a diagnostic disagreeing with the\n * thing it is diagnosing, which is worse than no diagnostic.\n */\n readonly correctKeys?: (key: KeyState, input: string) => KeyState\n readonly onDone: () => void\n}\n\nexport function KeyProbe({\n columns,\n asked,\n terminal,\n takeRaw,\n correctKeys,\n onDone,\n}: KeyProbeProps) {\n const [seen, setSeen] = useState<readonly Recorded[]>([])\n\n useInput((input, reported) => {\n const raw = takeRaw?.()\n const inkState = reported as KeyState\n const state = correctKeys === undefined ? inkState : correctKeys(inkState, input)\n // `q` on its own leaves. Every other key — ^C included — is recorded rather than acted on, which\n // is the one place in this CLI where ^C must not cancel: a probe that exits on the chord being\n // probed cannot report it.\n if (input === \"q\" && !state.ctrl && !state.meta && !state.super) {\n onDone()\n return\n }\n const intent = keyToIntent(input, state, keyContext(EMPTY_EDITOR, false))\n pressed += 1\n const at = pressed\n // The tapped chunk when there is one, and `input` as the fallback — which is right for the test\n // harness, where there is no real stdin to tap and `input` *is* what arrived.\n const bytes = raw ?? input\n setSeen((current) => [...current, { at, bytes, input, key: state, intent }].slice(-KEEP))\n })\n\n return (\n <Box flexDirection=\"column\">\n <Text color={THEME.accent} bold wrap=\"truncate\">\n key probe · {terminal}\n </Text>\n <Text color={THEME.muted} wrap=\"truncate\">\n protocol {protocolVerdict(seen, asked)}\n </Text>\n <Text> </Text>\n {seen.length === 0 ? (\n <Text color={THEME.muted} wrap=\"truncate\">\n press any chord — the bytes, Ink's reading of them, and the resolved intent\n </Text>\n ) : null}\n {seen.map((stroke) => (\n <Box key={`stroke-${stroke.at}`} flexDirection=\"column\">\n <Text color={THEME.border} wrap=\"truncate\">\n {headingRule(\"\", columns)}\n </Text>\n {keystrokeRows(stroke).map((row) => (\n <Text key={row} wrap=\"truncate\">\n {row}\n </Text>\n ))}\n </Box>\n ))}\n <Text> </Text>\n <Text dimColor wrap=\"truncate\">\n {\" q leaves · every other key is recorded, ^C included\"}\n </Text>\n </Box>\n )\n}\n",
|
|
6
|
+
"/**\n * What a keystroke actually was, rendered for a person to paste into a bug report.\n *\n * ## Why this exists\n *\n * CLAUDE.md's rule is that a key chord is verified against a real terminal and never against the parser,\n * and for ten rounds of TUI work there was no way to do that: the only instrument was Ink reporting *a*\n * key, which says nothing about the bytes a terminal sent. So `⌥r` was documented, bound, handled, and\n * silently arriving as the composed character `®`, and every round diagnosed it by guessing.\n *\n * A probe ends that. It prints the bytes, Ink's reading of them, and the intent this repo's own keymap\n * resolved — three layers, so a failure names which one is wrong instead of leaving three suspects.\n *\n * Pure, so every line of it is asserted without a terminal. The component around it does nothing but\n * mount a `useInput` and hand what arrives to these functions.\n */\n\nimport type { Intent, KeyState } from \"#lib/types\"\n\n/** One keystroke, as all three layers saw it. */\nexport interface Keystroke {\n /**\n * What the terminal actually wrote, tapped off stdin.\n *\n * Distinct from `input` because for a special key they differ completely: `CSI 1;9:1D` reaches a\n * handler as `input: \"\"` with flags set, so a probe reporting only `input` prints an empty byte row\n * for every arrow, Home, and cmd chord — the exact keys worth probing. Measured under a pty, not\n * reasoned about.\n */\n readonly bytes: string\n /** What Ink handed the handler. Empty for a special key, which is itself the point. */\n readonly input: string\n readonly key: KeyState\n readonly intent: Intent\n}\n\n/**\n * The bytes, in hex, as UTF-8 — which is what the terminal actually wrote.\n *\n * Not `charCodeAt`: that reports UTF-16 code units, so a composed `®` or an emoji would print a number\n * no terminal ever sent. The point of a byte probe is the bytes.\n */\nexport function hexOf(text: string): string {\n return [...new TextEncoder().encode(text)]\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\" \")\n}\n\n/** The modifier and key flags Ink set, named. Empty when it set none, which is itself information. */\nexport function flagsOf(key: KeyState): string {\n const named: string[] = []\n if (key.ctrl) named.push(\"ctrl\")\n if (key.meta) named.push(\"meta\")\n if (key.super) named.push(\"super\")\n if (key.shift) named.push(\"shift\")\n for (const [name, held] of [\n [\"up\", key.upArrow],\n [\"down\", key.downArrow],\n [\"left\", key.leftArrow],\n [\"right\", key.rightArrow],\n [\"pageUp\", key.pageUp],\n [\"pageDown\", key.pageDown],\n [\"home\", key.home],\n [\"end\", key.end],\n [\"return\", key.return],\n [\"escape\", key.escape],\n [\"tab\", key.tab],\n [\"backspace\", key.backspace],\n [\"delete\", key.delete],\n ] as const) {\n if (held) named.push(name)\n }\n if (key.eventType !== undefined && key.eventType !== \"press\") named.push(key.eventType)\n return named.length === 0 ? \"—\" : named.join(\" \")\n}\n\n/**\n * Whether the keystroke is evidence that the kitty protocol negotiated.\n *\n * Ink does not expose whether its handshake succeeded, and asking the terminal a second time from here\n * would be a different question than the one Ink asked. So this reports *evidence* rather than a claim:\n * `super` cannot be expressed without the protocol, and an `eventType` only arrives under\n * `reportEventTypes`. Either one proves it is on. Neither one appearing proves nothing either way, which\n * the verdict below says in as many words rather than defaulting to \"off\".\n */\nexport function provesProtocol(key: KeyState): boolean {\n return key.super || key.eventType !== undefined\n}\n\n/** What can honestly be said about the protocol, given what has been pressed so far. */\nexport function protocolVerdict(seen: readonly Keystroke[], asked: boolean): string {\n if (!asked) return \"not requested — the override is set, so cmd chords cannot arrive\"\n if (seen.some((stroke) => provesProtocol(stroke.key))) {\n return \"active — a keystroke carried a modifier only the protocol can express\"\n }\n return \"requested; nothing pressed yet has proved it — try cmd+left, or option+r\"\n}\n\n/** One keystroke as three labelled lines, deepest layer last. */\nexport function keystrokeRows(stroke: Keystroke): readonly string[] {\n // Code points rather than a character-class regex: a control character written into a regex is a\n // lint error for a good reason (it is invisible in the source), and `printableOnly` in `keymap.ts`\n // already draws this line the same way.\n const printable = [...stroke.bytes]\n .map((char) => {\n const code = char.codePointAt(0) ?? 0\n return code < 0x20 || code === 0x7f ? \".\" : char\n })\n .join(\"\")\n return [\n `bytes ${hexOf(stroke.bytes)}${printable === \"\" ? \"\" : ` ${printable}`}`,\n `ink ${flagsOf(stroke.key)}${stroke.input === \"\" ? \"\" : ` input ${JSON.stringify(stroke.input)}`}`,\n `intent ${stroke.intent.kind}`,\n ]\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";+EAWA,cAAS,UAAK,cAAM,YACpB,mBAAS,cC8BF,SAAS,CAAK,CAAC,EAAsB,CACxC,MAAO,CAAC,GAAG,IAAI,YAAY,EAAE,OAAO,CAAI,CAAC,EACpC,IAAI,CAAC,IAAS,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAChD,KAAK,GAAG,EAIV,SAAS,CAAO,CAAC,EAAuB,CAC3C,IAAM,EAAkB,CAAC,EACzB,GAAI,EAAI,KAAM,EAAM,KAAK,MAAM,EAC/B,GAAI,EAAI,KAAM,EAAM,KAAK,MAAM,EAC/B,GAAI,EAAI,MAAO,EAAM,KAAK,OAAO,EACjC,GAAI,EAAI,MAAO,EAAM,KAAK,OAAO,EACjC,QAAY,EAAM,IAAS,CACvB,CAAC,KAAM,EAAI,OAAO,EAClB,CAAC,OAAQ,EAAI,SAAS,EACtB,CAAC,OAAQ,EAAI,SAAS,EACtB,CAAC,QAAS,EAAI,UAAU,EACxB,CAAC,SAAU,EAAI,MAAM,EACrB,CAAC,WAAY,EAAI,QAAQ,EACzB,CAAC,OAAQ,EAAI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,CAAK,EAIhF,GAAI,IAAU,KAAO,CAAC,EAAM,MAAQ,CAAC,EAAM,MAAQ,CAAC,EAAM,MAAO,CAC7D,EAAO,EACP,OAEJ,IAAM,EAAS,GAAY,EAAO,EAAO,GAAW,EAAc,EAAK,CAAC,EACxE,GAAW,EACX,IAAM,EAAK,EAGL,EAAQ,GAAO,EACrB,EAAQ,CAAC,IAAY,CAAC,GAAG,EAAS,CAAE,KAAI,QAAO,QAAO,IAAK,EAAO,QAAO,CAAC,EAAE,MAAM,CAAC,CAAI,CAAC,EAC3F,EAGG,EA6BE,EA7BF,CAAK,cAAc,SAAnB,SA6BE,CA5BE,EAEE,EAFF,CAAM,MAAO,EAAM,OAAQ,KAAI,GAAC,KAAK,WAArC,SAEE,CAFF,eACiB,GACf,EACF,EAEE,EAFF,CAAM,MAAO,EAAM,MAAO,KAAK,WAA/B,SAEE,CAFF,YACc,EAAgB,EAAM,CAAK,GACvC,EACF,EAAS,EAAT,cAAS,EACR,EAAK,SAAW,EACb,EAEE,EAFF,CAAM,MAAO,EAAM,MAAO,KAAK,WAA/B,uFAEE,EACF,KACH,EAAK,IAAI,CAAC,IACP,EASE,EATF,CAAiC,cAAc,SAA/C,SASE,CARE,EAEE,EAFF,CAAM,MAAO,EAAM,OAAQ,KAAK,WAAhC,SACK,GAAY,GAAI,CAAO,EAC1B,EACD,EAAc,CAAM,EAAE,IAAI,CAAC,IACxB,EAEE,EAFF,CAAgB,KAAK,WAArB,SACK,GADM,CAET,CACL,IARK,UAAU,EAAO,IASzB,CACL,EACD,EAAS,EAAT,cAAS,EACT,EAEE,EAFF,CAAM,SAAQ,GAAC,KAAK,WAApB,SACK,wDACH,GACJ",
|
|
9
|
+
"debugId": "C1F146CC6976C40764756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{u}from"./index-jk0def33.js";import{rt}from"./index-bwckzbf8.js";import{ae,G}from"./index-mrtb5y08.js";import{ye}from"./index-6z0yr17z.js";import{Box as l,useApp as k,useInput as x}from"ink";import{useCallback as b,useState as y}from"react";import{jsx as r,jsxs as P}from"react/jsx-runtime";function I({title:m,agents:n,onDone:i}){let{exit:o}=k(),[s,d]=y({index:0,count:n.length+1}),a=b((e)=>{i(e),o()},[i,o]);x((e,f)=>{let c=ye(e,f);switch(c.kind){case"move":d((t)=>G(t,c.move));return;case"choose":{let t=n[s.index];a(t===void 0?{kind:"create"}:{kind:"run",manifestPath:t.manifestPath});return}case"back":case"exit":a({kind:"quit"});return;case"none":return}});let p=[...n.map((e)=>({label:e.name??e.ref,hint:e.problem!==void 0?`⚠ ${e.problem}`:`${e.modelId??"?"} ${u.bullet}${e.ref}`})),{label:`${u.create}create a new agent`}];return P(l,{flexDirection:"column",children:[r(rt,{title:m,lines:["pick an agent · enter runs it · esc quits"]}),r(l,{marginTop:1,children:r(ae,{items:p,index:s.index,numbered:!0})})]})}export{I as Picker};
|
|
3
|
+
|
|
4
|
+
//# debugId=FC56054C172521B264756E2164756E21
|
|
5
|
+
//# sourceMappingURL=Picker-jxaesaxy.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Picker.tsx"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The agent picker: bare `run` at a terminal, one keystroke from any sandbox agent.\n *\n * One `useInput` over the pure list keymap and select reducer; the kit renders. Broken agents\n * are listed with their problem — dim, unselectable-looking but still runnable, because a person\n * debugging a manifest wants to reach it, not to be protected from it.\n */\n\nimport { Box, useApp, useInput } from \"ink\"\nimport { useCallback, useState } from \"react\"\nimport { Banner } from \"#components/Banner\"\nimport { SelectList } from \"#components/SelectList\"\nimport { keyToListIntent } from \"#keymap\"\nimport type { SandboxAgent } from \"#lib/sandbox\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport { GLYPH } from \"#lib/theme\"\n\nexport type PickerResult =\n | { readonly kind: \"run\"; readonly manifestPath: string }\n | { readonly kind: \"create\" }\n | { readonly kind: \"quit\" }\n\nexport interface PickerProps {\n readonly title: string\n readonly agents: readonly SandboxAgent[]\n readonly onDone: (result: PickerResult) => void\n}\n\nexport function Picker({ title, agents, onDone }: PickerProps) {\n const { exit } = useApp()\n // The final row is always \"+ create a new agent\".\n const [select, setSelect] = useState<SelectState>({ index: 0, count: agents.length + 1 })\n\n const finish = useCallback(\n (result: PickerResult) => {\n onDone(result)\n exit()\n },\n [onDone, exit],\n )\n\n useInput((input, key) => {\n const intent = keyToListIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n setSelect((current) => moveSelect(current, intent.move))\n return\n case \"choose\": {\n const agent = agents[select.index]\n finish(\n agent === undefined\n ? { kind: \"create\" }\n : { kind: \"run\", manifestPath: agent.manifestPath },\n )\n return\n }\n case \"back\":\n case \"exit\":\n finish({ kind: \"quit\" })\n return\n case \"none\":\n return\n }\n })\n\n const items = [\n ...agents.map((agent) => ({\n label: agent.name ?? agent.ref,\n hint:\n agent.problem !== undefined\n ? `⚠ ${agent.problem}`\n : `${agent.modelId ?? \"?\"} ${GLYPH.bullet}${agent.ref}`,\n })),\n { label: `${GLYPH.create}create a new agent` },\n ]\n\n return (\n <Box flexDirection=\"column\">\n <Banner title={title} lines={[\"pick an agent · enter runs it · esc quits\"]} />\n <Box marginTop={1}>\n <SelectList items={items} index={select.index} numbered />\n </Box>\n </Box>\n )\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";iJAQA,cAAS,YAAK,cAAQ,YACtB,sBAAS,cAAa,gEAmBf,SAAS,CAAM,EAAG,QAAO,SAAQ,UAAuB,CAC3D,IAAQ,QAAS,EAAO,GAEjB,EAAQ,GAAa,EAAsB,CAAE,MAAO,EAAG,MAAO,EAAO,OAAS,CAAE,CAAC,EAElF,EAAS,EACX,CAAC,IAAyB,CACtB,EAAO,CAAM,EACb,EAAK,GAET,CAAC,EAAQ,CAAI,CACjB,EAEA,EAAS,CAAC,EAAO,IAAQ,CACrB,IAAM,EAAS,GAAgB,EAAO,CAAG,EACzC,OAAQ,EAAO,UACN,OACD,EAAU,CAAC,IAAY,EAAW,EAAS,EAAO,IAAI,CAAC,EACvD,WACC,SAAU,CACX,IAAM,EAAQ,EAAO,EAAO,OAC5B,EACI,IAAU,OACJ,CAAE,KAAM,QAAS,EACjB,CAAE,KAAM,MAAO,aAAc,EAAM,YAAa,CAC1D,EACA,MACJ,KACK,WACA,OACD,EAAO,CAAE,KAAM,MAAO,CAAC,EACvB,WACC,OACD,QAEX,EAED,IAAM,EAAQ,CACV,GAAG,EAAO,IAAI,CAAC,KAAW,CACtB,MAAO,EAAM,MAAQ,EAAM,IAC3B,KACI,EAAM,UAAY,OACZ,KAAK,EAAM,UACX,GAAG,EAAM,SAAW,OAAO,EAAM,SAAS,EAAM,KAC9D,EAAE,EACF,CAAE,MAAO,GAAG,EAAM,0BAA2B,CACjD,EAEA,OACI,EAKE,EALF,CAAK,cAAc,SAAnB,SAKE,CAJE,EAAC,GAAD,CAAQ,MAAO,EAAO,MAAO,CAAC,2CAA2C,EAAG,EAC5E,EAEE,EAFF,CAAK,UAAW,EAAhB,SACI,EAAC,GAAD,CAAY,MAAO,EAAO,MAAO,EAAO,MAAO,SAAQ,GAAC,EAC1D,GACJ",
|
|
8
|
+
"debugId": "FC56054C172521B264756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o,S}from"./index-jk0def33.js";import{ae,G}from"./index-mrtb5y08.js";import{so}from"./index-8bmhd2hj.js";import{We}from"./index-mgdgx22q.js";import{ye}from"./index-6z0yr17z.js";import{Box as f,Text as u,useInput as v}from"ink";import{useState as w}from"react";var k=14,R=28;function p(r,i){let m=r.reduce((e,n)=>Math.max(e,n.sessionKey.length),0),t=Math.max(k,Math.min(R,m)),l=Math.max(12,i.columns-(2+t+2));return r.map((e)=>{let n=[`${e.messages} message${e.messages===1?"":"s"}`,`${e.turns} turn${e.turns===1?"":"s"}`,We(e.lastActivityAt,i.now)];if(e.phase!==void 0&&e.phase!=="")n.push(e.phase);if(!so(e.sessionKey))n.push("named");return{key:e.sessionKey,label:S(e.sessionKey,t).padEnd(t),hint:S(n.join(" · "),l)}})}import{jsx as c,jsxs as h}from"react/jsx-runtime";function Y({sessions:r,now:i,columns:m,maxRows:t,current:l,focused:e=!0,onDone:n}){let a=p(r,{now:i,columns:m}),[d,x]=w({index:0,count:a.length});if(v((s,g)=>{let y=ye(s,g);switch(y.kind){case"move":x((b)=>G(b,y.move));return;case"choose":n(a[d.index]?.key);return;case"back":case"exit":n(void 0);return;case"none":return}},{isActive:e}),a.length===0)return h(f,{flexDirection:"column",children:[c(u,{color:o.muted,wrap:"truncate",children:" no stored conversations with this agent yet"}),c(u,{dimColor:!0,wrap:"truncate",children:" esc starts a new one"})]});return h(f,{flexDirection:"column",children:[c(ae,{items:a.map((s)=>({label:s.label,hint:s.key===l?`${s.hint} · in use`:s.hint})),index:d.index,numbered:!0,maxRows:t}),c(u,{dimColor:!0,wrap:"truncate",children:" ↑↓ move · enter opens it · esc keeps the one you are in"})]})}export{Y as SessionPicker};
|
|
3
|
+
|
|
4
|
+
//# debugId=EB41E9321F20A28264756E2164756E21
|
|
5
|
+
//# sourceMappingURL=SessionPicker-z2t0p4b5.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/SessionPicker.tsx", "../src/lib/sessions-view.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Which conversation to pick up — a bare `--session`, and the in-session `/sessions` switcher.\n *\n * A view under the Phase 5.5 contract: it never mounts itself, never calls `useApp().exit()`, and reports\n * through `onDone`. Two hosts use it, which is the point — `run` mounts it before the chat exists, and the\n * chat opens it as a pane — and neither is visible from here.\n *\n * `focused` gates the `useInput`, because Ink fires **every** active hook: a picker over a live prompt\n * would otherwise have two surfaces reading one keystroke, which is a wrong action rather than a\n * rendering fault.\n */\n\nimport { Box, Text, useInput } from \"ink\"\nimport { useState } from \"react\"\nimport { SelectList } from \"#components/SelectList\"\nimport { keyToListIntent } from \"#keymap\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport { type SessionRow, type SessionRowSource, sessionRows } from \"#lib/sessions-view\"\nimport { THEME } from \"#lib/theme\"\n\nexport interface SessionPickerProps {\n readonly sessions: readonly SessionRowSource[]\n /** Injected so the \"3h ago\" column is deterministic in a frame test. */\n readonly now: number\n readonly columns: number\n readonly maxRows: number\n /** The session currently in use, marked so switching away from it is a deliberate choice. */\n readonly current?: string\n readonly focused?: boolean\n /** A key to use, or `undefined` for \"leave things as they are\". */\n readonly onDone: (sessionKey: string | undefined) => void\n}\n\nexport function SessionPicker({\n sessions,\n now,\n columns,\n maxRows,\n current,\n focused = true,\n onDone,\n}: SessionPickerProps) {\n const rows: readonly SessionRow[] = sessionRows(sessions, { now, columns })\n const [select, setSelect] = useState<SelectState>({ index: 0, count: rows.length })\n\n useInput(\n (input, key) => {\n const intent = keyToListIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n setSelect((state) => moveSelect(state, intent.move))\n return\n case \"choose\":\n onDone(rows[select.index]?.key)\n return\n case \"back\":\n case \"exit\":\n onDone(undefined)\n return\n case \"none\":\n return\n }\n },\n { isActive: focused },\n )\n\n if (rows.length === 0) {\n return (\n <Box flexDirection=\"column\">\n <Text color={THEME.muted} wrap=\"truncate\">\n {\" no stored conversations with this agent yet\"}\n </Text>\n <Text dimColor wrap=\"truncate\">\n {\" esc starts a new one\"}\n </Text>\n </Box>\n )\n }\n\n return (\n <Box flexDirection=\"column\">\n <SelectList\n items={rows.map((row) => ({\n label: row.label,\n hint: row.key === current ? `${row.hint} · in use` : row.hint,\n }))}\n index={select.index}\n numbered\n maxRows={maxRows}\n />\n <Text dimColor wrap=\"truncate\">\n {\" ↑↓ move · enter opens it · esc keeps the one you are in\"}\n </Text>\n </Box>\n )\n}\n",
|
|
6
|
+
"/**\n * A stored conversation as a row somebody can pick.\n *\n * Pure, and separate from `sessions.ts` for the reason every layout module here is: the *content* of a\n * row — what identifies a conversation, what makes one worth returning to — is the only interesting part,\n * and it is only observable as strings. The picker renders these; `sessions --plain` keeps its own table,\n * because a listing read by a script and a list navigated with arrows want different shapes.\n *\n * What identifies a conversation is the open question here and the answer is deliberate: the key, because\n * that is what you type back, plus **when it was last touched** and **how much is in it**. Not the first\n * message, tempting as that is — it would need a store read per row, and a session whose first message was\n * \"hey\" is not distinguished by it.\n */\n\nimport { ago } from \"#lib/render\"\nimport { clip } from \"#lib/rows\"\nimport { isGeneratedSessionKey } from \"#lib/session-key\"\n\n/** The narrow slice of a `SessionSummary` this needs. Structural, so no core type is imported. */\nexport interface SessionRowSource {\n readonly sessionKey: string\n readonly messages: number\n readonly turns: number\n readonly lastActivityAt: string\n readonly phase?: string | undefined\n}\n\nexport interface SessionRow {\n readonly key: string\n readonly label: string\n readonly hint: string\n}\n\n/** The key column, wide enough for a generated key and clamped so a hand-written one cannot push the row. */\nconst KEY_MIN = 14\nconst KEY_MAX = 28\n\nexport function sessionRows(\n sessions: readonly SessionRowSource[],\n options: { readonly now: number; readonly columns: number },\n): readonly SessionRow[] {\n const longest = sessions.reduce((widest, row) => Math.max(widest, row.sessionKey.length), 0)\n const keyColumn = Math.max(KEY_MIN, Math.min(KEY_MAX, longest))\n // The gutter the list draws, the key column, and two of gap.\n const room = Math.max(12, options.columns - (2 + keyColumn + 2))\n\n return sessions.map((row) => {\n const parts = [\n `${row.messages} message${row.messages === 1 ? \"\" : \"s\"}`,\n `${row.turns} turn${row.turns === 1 ? \"\" : \"s\"}`,\n ago(row.lastActivityAt, options.now),\n ]\n // A phase is only shown when there is one: an agent with no phases would otherwise spend a column\n // on the word \"none\" in every row.\n if (row.phase !== undefined && row.phase !== \"\") parts.push(row.phase)\n // A key the person chose is worth marking, because it is the one they will recognise — everything\n // else in this list is six characters they have never read before.\n if (!isGeneratedSessionKey(row.sessionKey)) parts.push(\"named\")\n return {\n key: row.sessionKey,\n label: clip(row.sessionKey, keyColumn).padEnd(keyColumn),\n hint: clip(parts.join(\" · \"), room),\n }\n })\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";uLAYA,cAAS,UAAK,cAAM,YACpB,mBAAS,cCqBT,IAAM,EAAU,GACV,EAAU,GAET,SAAS,CAAW,CACvB,EACA,EACqB,CACrB,IAAM,EAAU,EAAS,OAAO,CAAC,EAAQ,IAAQ,KAAK,IAAI,EAAQ,EAAI,WAAW,MAAM,EAAG,CAAC,EACrF,EAAY,KAAK,IAAI,EAAS,KAAK,IAAI,EAAS,CAAO,CAAC,EAExD,EAAO,KAAK,IAAI,GAAI,EAAQ,SAAW,EAAI,EAAY,EAAE,EAE/D,OAAO,EAAS,IAAI,CAAC,IAAQ,CACzB,IAAM,EAAQ,CACV,GAAG,EAAI,mBAAmB,EAAI,WAAa,EAAI,GAAK,MACpD,GAAG,EAAI,aAAa,EAAI,QAAU,EAAI,GAAK,MAC3C,GAAI,EAAI,eAAgB,EAAQ,GAAG,CACvC,EAGA,GAAI,EAAI,QAAU,QAAa,EAAI,QAAU,GAAI,EAAM,KAAK,EAAI,KAAK,EAGrE,GAAI,CAAC,GAAsB,EAAI,UAAU,EAAG,EAAM,KAAK,OAAO,EAC9D,MAAO,CACH,IAAK,EAAI,WACT,MAAO,EAAK,EAAI,WAAY,CAAS,EAAE,OAAO,CAAS,EACvD,KAAM,EAAK,EAAM,KAAK,KAAK,EAAG,CAAI,CACtC,EACH,oDD9BE,SAAS,CAAa,EACzB,WACA,MACA,UACA,UACA,UACA,UAAU,GACV,UACmB,CACnB,IAAM,EAA8B,EAAY,EAAU,CAAE,MAAK,SAAQ,CAAC,GACnE,EAAQ,GAAa,EAAsB,CAAE,MAAO,EAAG,MAAO,EAAK,MAAO,CAAC,EAuBlF,GArBA,EACI,CAAC,EAAO,IAAQ,CACZ,IAAM,EAAS,GAAgB,EAAO,CAAG,EACzC,OAAQ,EAAO,UACN,OACD,EAAU,CAAC,IAAU,EAAW,EAAO,EAAO,IAAI,CAAC,EACnD,WACC,SACD,EAAO,EAAK,EAAO,QAAQ,GAAG,EAC9B,WACC,WACA,OACD,EAAO,MAAS,EAChB,WACC,OACD,SAGZ,CAAE,SAAU,CAAQ,CACxB,EAEI,EAAK,SAAW,EAChB,OACI,EAOE,EAPF,CAAK,cAAc,SAAnB,SAOE,CANE,EAEE,EAFF,CAAM,MAAO,EAAM,MAAO,KAAK,WAA/B,SACK,gDACH,EACF,EAEE,EAFF,CAAM,SAAQ,GAAC,KAAK,WAApB,SACK,yBACH,GACJ,EAIV,OACI,EAaE,EAbF,CAAK,cAAc,SAAnB,SAaE,CAZE,EAAC,GAAD,CACI,MAAO,EAAK,IAAI,CAAC,KAAS,CACtB,MAAO,EAAI,MACX,KAAM,EAAI,MAAQ,EAAU,GAAG,EAAI,gBAAkB,EAAI,IAC7D,EAAE,EACF,MAAO,EAAO,MACd,SAAQ,GACR,QAAS,EACb,EACA,EAEE,EAFF,CAAM,SAAQ,GAAC,KAAK,WAApB,SACK,4DACH,GACJ",
|
|
9
|
+
"debugId": "EB41E9321F20A28264756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o,u,oe}from"./index-jk0def33.js";import{qt,tt,Gt}from"./index-e8n70sgj.js";import{re}from"./index-rqbtm761.js";import{ae,G}from"./index-mrtb5y08.js";import{de}from"./index-b8zwg8a3.js";import{nt,Zt}from"./index-t1xvacym.js";import{Ro,Io,Oo}from"./index-9nsfs0vy.js";import{Dt,ye}from"./index-6z0yr17z.js";import{xn,En,qe,Ge,Ze}from"./index-my5cjx00.js";import{Box as p,Text as f,useInput as U}from"ink";import{useCallback as X,useEffect as Y,useState as L}from"react";import{Box as E,Text as R}from"ink";import{jsx as w,jsxs as H}from"react/jsx-runtime";var W={ok:o.success,warn:o.warning,off:o.muted},B={title:{color:o.accent,bold:!0},summary:{dim:!0},state:{},warning:{color:o.warning}};function D(e){return Math.max(xn,Math.min(En,e))}function g({header:e,footer:l,children:s}){let x=re(),T=D(x.columns),k=T-4,v=Ro(e,k),C=e.state??[];return H(E,{flexDirection:"column",width:T,children:[w(E,{flexDirection:"column",borderStyle:oe,borderColor:o.borderActive,paddingX:1,children:v.map((d)=>d.kind==="state"?w(R,{wrap:"truncate",children:C.map((n,c)=>H(R,{color:W[n.tone],children:[c===0?"":" · ",n.label]},n.label))},d.text):w(R,{wrap:"truncate",bold:B[d.kind].bold===!0,dimColor:B[d.kind].dim===!0,...B[d.kind].color===void 0?{}:{color:B[d.kind].color},children:d.text},d.text))}),w(E,{flexDirection:"column",marginTop:1,children:s}),l===void 0||l.length===0?null:w(E,{marginTop:1,children:H(R,{dimColor:!0,wrap:"truncate",children:[" ",Io(l,k)]})})]})}import{jsx as t,jsxs as S}from"react/jsx-runtime";function xe({load:e,install:l,agents:s,target:x,focused:T=!0,onDone:k,title:v}){let C=re(),d=Math.max(qe,Math.min(Ge,C.rows-Ze)),[n,c]=L({kind:"fetching",status:"reading the catalogue"}),[b,O]=L([]),[y,M]=L({cursor:{index:0,count:0},chosen:[]}),[_,A]=L({index:0,count:s.length});Y(()=>{let r=!0;return e((i)=>{if(r)c((a)=>a.kind==="fetching"?{...a,status:i}:a)}).then((i)=>{if(!r)return;O(i);let a=nt(i);M({cursor:{index:Gt(a),count:i.length},chosen:[]}),c(i.length===0?{kind:"empty"}:{kind:"picking"})}).catch((i)=>{if(!r)return;c({kind:"failed",message:i instanceof Error?i.message:String(i)})}),()=>{r=!1}},[e]);let P=nt(b),I=X((r)=>{let i=Zt(b,y.chosen);c({kind:"installing",count:i.length}),l(i,r).then((a)=>c({kind:"done",report:a})).catch((a)=>c({kind:"failed",message:a instanceof Error?a.message:String(a)}))},[b,y.chosen,l]);U((r,i)=>{if(n.kind==="done"){k(n.report);return}if(n.kind==="failed"||n.kind==="empty"){k(void 0);return}if(n.kind==="fetching"||n.kind==="installing"){if(Dt(r,i).kind==="cancel")k(void 0);return}if(n.kind==="picking"){let m=Dt(r,i);switch(m.kind){case"move":case"toggle":case"all":M((N)=>tt(N,m.kind==="move"?{kind:"move",move:m.move}:{kind:m.kind},P));return;case"none-selected":M((N)=>tt(N,{kind:"none"},P));return;case"confirm":if(y.chosen.length===0)return;if(x!==void 0)return I(x);if(s.length===1)return I(s[0]?.manifestPath??"");c({kind:"agent"});return;case"cancel":k(void 0);return;case"none":return}}let a=ye(r,i);switch(a.kind){case"move":A((m)=>G(m,a.move));return;case"choose":{let m=s[_.index];if(m!==void 0)I(m.manifestPath);return}case"back":c({kind:"picking"});return;case"exit":k(void 0);return;case"none":return}},{isActive:T});let z=y.chosen.length,h={title:v,summary:K(n,b.length,z)};if(n.kind==="fetching")return S(g,{header:h,footer:[{key:"esc",does:"stop waiting"}],children:[t(p,{marginLeft:2,children:t(de,{label:n.status})}),t(p,{marginLeft:2,marginTop:1,children:t(f,{dimColor:!0,children:"once per machine, shared by every agent on it"})})]});if(n.kind==="failed")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(p,{marginLeft:2,children:S(f,{color:o.error,children:[u.error,n.message]})})});if(n.kind==="empty")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:S(p,{marginLeft:2,flexDirection:"column",children:[t(f,{color:o.muted,children:"no catalogue could be read"}),t(f,{dimColor:!0,children:"`sources update` reports why"})]})});if(n.kind==="installing")return t(g,{header:h,children:t(p,{marginLeft:2,children:t(de,{label:`installing ${n.count} skill${n.count===1?"":"s"}`})})});if(n.kind==="done")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(F,{report:n.report})});if(n.kind==="agent")return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"enter",does:"install"},{key:"esc",does:"back"}],children:t(ae,{items:s.map((r)=>({label:r.name??r.ref,hint:r.problem===void 0?`${r.modelId??"?"} ${u.bullet}${r.ref}`:`⚠ ${r.problem}`})),index:_.index,numbered:!0})});return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"space",does:"tick"},{key:"a/n",does:"all/none"},{key:"enter",does:x===void 0?"continue":"install"},Oo],children:t(qt,{rows:b,index:y.cursor.index,chosen:y.chosen,window:d,width:C.columns})})}function K(e,l,s){switch(e.kind){case"fetching":return"fetching the catalogue";case"failed":return"could not be read";case"empty":return"nothing to show";case"installing":return"installing";case"done":return`installed ${e.report.installed.length} of ${e.report.total}`;case"agent":return`${s} to install · pick an agent`;case"picking":return s===0?`${l} rows · nothing ticked yet`:`${s} ticked of ${l} rows`}}function F({report:e}){return S(p,{flexDirection:"column",marginLeft:2,children:[S(f,{color:e.failed.length===0?o.success:o.warning,children:[u.check,`installed ${e.installed.length} of ${e.total} skill${e.total===1?"":"s"}`]}),e.installed.length>0?t(f,{dimColor:!0,wrap:"truncate",children:e.installed.join(", ")}):null,e.failed.map((l)=>S(f,{color:o.error,wrap:"truncate",children:[u.error,l.name," — ",l.reason]},l.name)),e.runnable>0?t(p,{marginTop:1,children:t(f,{dimColor:!0,wrap:"truncate",children:`${e.runnable} runnable file${e.runnable===1?"":"s"} across ${e.withCode} skill${e.withCode===1?"":"s"} — \`skills show <agent> <skill>\` names them`})}):null,t(p,{marginTop:1,children:t(f,{dimColor:!0,children:"restart the agent: the catalogue is scanned once at boot"})})]})}export{xe as SkillBrowser};
|
|
3
|
+
|
|
4
|
+
//# debugId=B0F7820BBD8CF14F64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=SkillBrowser-yyf2gy0q.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/SkillBrowser.tsx", "../src/components/Screen.tsx"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The skills catalogue: fetch, tick, pick an agent, install, and say what happened — in one mount.\n *\n * ## Why the whole lifecycle is in here\n *\n * The first version did only the ticking. The command fetched the catalogue *before* mounting and\n * printed the report *after* unmounting, so four of the five phases of the bare `skills` command were plain\n * `process.stdout.write`: a twenty-second clone with no spinner, then a picker, then a wall of text.\n * termheat's `App.tsx` is the shape this follows instead — mount, then load inside an effect, with the\n * wait rendered rather than printed.\n *\n * `load` and `install` arrive as async props, so the view reaches no filesystem and starts no process.\n * That is what keeps it renderable in a frame test; the host supplies both.\n *\n * ## The view contract\n *\n * It never mounts itself and never calls `useApp().exit()`. It reports through `onDone` and the host\n * decides what that means — unmount, for a command; close the pane, for the chat. `focused` gates the\n * one `useInput`, because Ink delivers input to *every* active hook, so a pane over a live prompt would\n * otherwise have both reading the same keystroke.\n */\n\nimport { Box, Text, useInput } from \"ink\"\nimport { useCallback, useEffect, useState } from \"react\"\nimport { CheckList } from \"#components/CheckList\"\nimport { Screen } from \"#components/Screen\"\nimport { SelectList } from \"#components/SelectList\"\nimport { Spinner } from \"#components/Spinner\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { keyToCheckIntent, keyToListIntent } from \"#keymap\"\nimport type { BrowseRow, InstallReport } from \"#lib/browse\"\nimport { chosenEntries, selectableOf } from \"#lib/browse\"\nimport { MAX_SCREEN_ROWS, MIN_SCREEN_ROWS, SCREEN_CHROME_ROWS } from \"#lib/const\"\nimport { firstSelectable, type MultiSelectState, reduceMultiSelect } from \"#lib/multiselect\"\nimport type { SandboxAgent } from \"#lib/sandbox\"\nimport { QUIT_HINT, type ScreenHeader } from \"#lib/screen\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport type { CatalogueEntry } from \"#lib/source-cache\"\nimport { GLYPH, THEME } from \"#lib/theme\"\n\nexport interface SkillBrowserProps {\n /** Fetch the catalogue, reporting progress. Called once, inside the mount. */\n readonly load: (onStatus: (line: string) => void) => Promise<readonly BrowseRow[]>\n readonly install: (\n skills: readonly CatalogueEntry[],\n manifestPath: string,\n ) => Promise<InstallReport>\n readonly agents: readonly SandboxAgent[]\n /** Install into this manifest and never ask which agent — for a host that already knows. */\n readonly target?: string\n /** Whether this surface has the keyboard. A pane over a live prompt must not share it. */\n readonly focused?: boolean\n /** Nothing left to do here. The host owns the exit. */\n readonly onDone: (report: InstallReport | undefined) => void\n readonly title: string\n}\n\ntype Stage =\n | { readonly kind: \"fetching\"; readonly status: string }\n | { readonly kind: \"failed\"; readonly message: string }\n | { readonly kind: \"empty\" }\n | { readonly kind: \"picking\" }\n | { readonly kind: \"agent\" }\n | { readonly kind: \"installing\"; readonly count: number }\n | { readonly kind: \"done\"; readonly report: InstallReport }\n\nexport function SkillBrowser({\n load,\n install,\n agents,\n target,\n focused = true,\n onDone,\n title,\n}: SkillBrowserProps) {\n const size = useTerminalSize()\n const window = Math.max(\n MIN_SCREEN_ROWS,\n Math.min(MAX_SCREEN_ROWS, size.rows - SCREEN_CHROME_ROWS),\n )\n\n const [stage, setStage] = useState<Stage>({ kind: \"fetching\", status: \"reading the catalogue\" })\n const [rows, setRows] = useState<readonly BrowseRow[]>([])\n const [picked, setPicked] = useState<MultiSelectState>({\n cursor: { index: 0, count: 0 },\n chosen: [],\n })\n const [agent, setAgent] = useState<SelectState>({ index: 0, count: agents.length })\n\n // Inside the mount, so the wait is rendered rather than printed. Progress arrives through a\n // callback for the same reason: writing to stdout while Ink owns the frame paints over it.\n useEffect(() => {\n let live = true\n void load((status) => {\n if (live) {\n setStage((current) =>\n current.kind === \"fetching\" ? { ...current, status } : current,\n )\n }\n })\n .then((fetched) => {\n if (!live) return\n setRows(fetched)\n const selectable = selectableOf(fetched)\n setPicked({\n cursor: { index: firstSelectable(selectable), count: fetched.length },\n chosen: [],\n })\n setStage(fetched.length === 0 ? { kind: \"empty\" } : { kind: \"picking\" })\n })\n .catch((error: unknown) => {\n if (!live) return\n setStage({\n kind: \"failed\",\n message: error instanceof Error ? error.message : String(error),\n })\n })\n return () => {\n live = false\n }\n }, [load])\n\n const selectable = selectableOf(rows)\n\n const begin = useCallback(\n (manifestPath: string) => {\n const skills = chosenEntries(rows, picked.chosen)\n setStage({ kind: \"installing\", count: skills.length })\n void install(skills, manifestPath)\n .then((report) => setStage({ kind: \"done\", report }))\n .catch((error: unknown) =>\n setStage({\n kind: \"failed\",\n message: error instanceof Error ? error.message : String(error),\n }),\n )\n },\n [rows, picked.chosen, install],\n )\n\n useInput(\n (input, key) => {\n if (stage.kind === \"done\") {\n onDone(stage.report)\n return\n }\n if (stage.kind === \"failed\" || stage.kind === \"empty\") {\n onDone(undefined)\n return\n }\n if (stage.kind === \"fetching\" || stage.kind === \"installing\") {\n // Only a way out. Anything else would queue a keystroke against a list that does not\n // exist yet, and a box ticking itself once the fetch lands is a surprise.\n if (keyToCheckIntent(input, key).kind === \"cancel\") onDone(undefined)\n return\n }\n\n if (stage.kind === \"picking\") {\n const intent = keyToCheckIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n case \"toggle\":\n case \"all\":\n setPicked((current) =>\n reduceMultiSelect(\n current,\n intent.kind === \"move\"\n ? { kind: \"move\", move: intent.move }\n : { kind: intent.kind },\n selectable,\n ),\n )\n return\n case \"none-selected\":\n setPicked((current) =>\n reduceMultiSelect(current, { kind: \"none\" }, selectable),\n )\n return\n case \"confirm\":\n // Nothing ticked is not a reason to advance: enter with an empty set lands on an\n // agent picker with nothing to install, one screen too late to notice.\n if (picked.chosen.length === 0) return\n if (target !== undefined) return begin(target)\n if (agents.length === 1) return begin(agents[0]?.manifestPath ?? \"\")\n setStage({ kind: \"agent\" })\n return\n case \"cancel\":\n onDone(undefined)\n return\n case \"none\":\n return\n }\n }\n\n const intent = keyToListIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n setAgent((current) => moveSelect(current, intent.move))\n return\n case \"choose\": {\n const chosen = agents[agent.index]\n if (chosen !== undefined) begin(chosen.manifestPath)\n return\n }\n case \"back\":\n // Back to the skills, keeping what was ticked. The reason both steps are one view.\n setStage({ kind: \"picking\" })\n return\n case \"exit\":\n onDone(undefined)\n return\n case \"none\":\n return\n }\n },\n { isActive: focused },\n )\n\n const count = picked.chosen.length\n const header: ScreenHeader = { title, summary: summaryFor(stage, rows.length, count) }\n\n if (stage.kind === \"fetching\") {\n return (\n <Screen header={header} footer={[{ key: \"esc\", does: \"stop waiting\" }]}>\n <Box marginLeft={2}>\n <Spinner label={stage.status} />\n </Box>\n <Box marginLeft={2} marginTop={1}>\n <Text dimColor>once per machine, shared by every agent on it</Text>\n </Box>\n </Screen>\n )\n }\n\n if (stage.kind === \"failed\") {\n return (\n <Screen header={header} footer={[{ key: \"any key\", does: \"back\" }]}>\n <Box marginLeft={2}>\n <Text color={THEME.error}>\n {GLYPH.error}\n {stage.message}\n </Text>\n </Box>\n </Screen>\n )\n }\n\n if (stage.kind === \"empty\") {\n return (\n <Screen header={header} footer={[{ key: \"any key\", does: \"back\" }]}>\n <Box marginLeft={2} flexDirection=\"column\">\n <Text color={THEME.muted}>no catalogue could be read</Text>\n <Text dimColor>`sources update` reports why</Text>\n </Box>\n </Screen>\n )\n }\n\n if (stage.kind === \"installing\") {\n return (\n <Screen header={header}>\n <Box marginLeft={2}>\n <Spinner\n label={`installing ${stage.count} skill${stage.count === 1 ? \"\" : \"s\"}`}\n />\n </Box>\n </Screen>\n )\n }\n\n if (stage.kind === \"done\") {\n return (\n <Screen header={header} footer={[{ key: \"any key\", does: \"back\" }]}>\n <ResultCard report={stage.report} />\n </Screen>\n )\n }\n\n if (stage.kind === \"agent\") {\n return (\n <Screen\n header={header}\n footer={[\n { key: \"↑↓\", does: \"move\" },\n { key: \"enter\", does: \"install\" },\n { key: \"esc\", does: \"back\" },\n ]}\n >\n <SelectList\n items={agents.map((entry) => ({\n label: entry.name ?? entry.ref,\n hint:\n entry.problem === undefined\n ? `${entry.modelId ?? \"?\"} ${GLYPH.bullet}${entry.ref}`\n : `⚠ ${entry.problem}`,\n }))}\n index={agent.index}\n numbered\n />\n </Screen>\n )\n }\n\n return (\n <Screen\n header={header}\n footer={[\n { key: \"↑↓\", does: \"move\" },\n { key: \"space\", does: \"tick\" },\n { key: \"a/n\", does: \"all/none\" },\n { key: \"enter\", does: target === undefined ? \"continue\" : \"install\" },\n QUIT_HINT,\n ]}\n >\n <CheckList\n rows={rows}\n index={picked.cursor.index}\n chosen={picked.chosen}\n window={window}\n width={size.columns}\n />\n </Screen>\n )\n}\n\n/** What the header says, per stage. Beside the stages, so a new one cannot be silently unlabelled. */\nfunction summaryFor(stage: Stage, rows: number, ticked: number): string {\n switch (stage.kind) {\n case \"fetching\":\n return \"fetching the catalogue\"\n case \"failed\":\n return \"could not be read\"\n case \"empty\":\n return \"nothing to show\"\n case \"installing\":\n return \"installing\"\n case \"done\":\n return `installed ${stage.report.installed.length} of ${stage.report.total}`\n case \"agent\":\n return `${ticked} to install · pick an agent`\n case \"picking\":\n return ticked === 0\n ? `${rows} rows · nothing ticked yet`\n : `${ticked} ticked of ${rows} rows`\n }\n}\n\n/**\n * What happened, rendered from the same `InstallReport` the text path prints.\n *\n * Runnable files are counted rather than named: eleven skills brought 130 script paths, and a count\n * plus a pointer to `skills show` discloses more than 130 lines nobody reads.\n */\nfunction ResultCard({ report }: { readonly report: InstallReport }) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n <Text color={report.failed.length === 0 ? THEME.success : THEME.warning}>\n {GLYPH.check}\n {`installed ${report.installed.length} of ${report.total} skill${report.total === 1 ? \"\" : \"s\"}`}\n </Text>\n {report.installed.length > 0 ? (\n <Text dimColor wrap=\"truncate\">\n {report.installed.join(\", \")}\n </Text>\n ) : null}\n {report.failed.map((failure) => (\n <Text key={failure.name} color={THEME.error} wrap=\"truncate\">\n {GLYPH.error}\n {failure.name} — {failure.reason}\n </Text>\n ))}\n {report.runnable > 0 ? (\n <Box marginTop={1}>\n <Text dimColor wrap=\"truncate\">\n {`${report.runnable} runnable file${report.runnable === 1 ? \"\" : \"s\"} across ${report.withCode} skill${report.withCode === 1 ? \"\" : \"s\"} — \\`skills show <agent> <skill>\\` names them`}\n </Text>\n </Box>\n ) : null}\n <Box marginTop={1}>\n <Text dimColor>restart the agent: the catalogue is scanned once at boot</Text>\n </Box>\n </Box>\n )\n}\n",
|
|
6
|
+
"/**\n * The frame every surface renders inside: header, body, footer.\n *\n * Replaces the three hand-rolled banners that came before it. `Banner` stays for what it is good at —\n * a title and some dim lines — and this composes it with the two things every screen also needed and\n * each solved separately: a live state row, and a footer saying what the keys do.\n *\n * ## It measures the terminal itself\n *\n * Width comes from `useTerminalSize()` rather than from a prop. The alternative was tried and is what\n * shipped in Phase 5: the caller measured once, passed numbers down, and a resized terminal left\n * every row laid out for a width that no longer existed. A component that reads the size cannot\n * forget to, and there is exactly one hook doing it.\n *\n * The clamps stay the kit's rather than the measurement's, because they are policy — 40 columns is\n * where a description column stops being worth having, 140 is where a description stops belonging on\n * the same line as its name. They are applied to the *live* value here.\n *\n * ## No input, no exit\n *\n * Presentational, like every component in this kit: it renders what it is given and owns no keyboard.\n * The focused surface owns the single `useInput`, and this is never it.\n */\n\nimport { Box, Text } from \"ink\"\nimport type { ReactNode } from \"react\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { MAX_SCREEN_COLUMNS, MIN_SCREEN_COLUMNS } from \"#lib/const\"\nimport {\n type HeaderLine,\n headerLines,\n hintLine,\n type KeyHint,\n type ScreenHeader,\n type StateChip,\n} from \"#lib/screen\"\nimport { BORDER_STYLE, THEME } from \"#lib/theme\"\n\nexport interface ScreenProps {\n readonly header: ScreenHeader\n readonly footer?: readonly KeyHint[]\n /**\n * Optional: a screen whose whole content is its header is a real screen — a one-line report, or a\n * list that came back empty. Required, it also made `createElement(Screen, props, body)` a type\n * error, because the third argument is not matched against a mandatory `children` prop.\n */\n readonly children?: ReactNode\n}\n\n/** Chip tone → colour. The pure module names a role; the mapping to a colour lives with the theme. */\nconst TONE: Record<StateChip[\"tone\"], string> = {\n ok: THEME.success,\n warn: THEME.warning,\n off: THEME.muted,\n}\n\n/** Header line kind → how it is drawn. Exhaustive, so a new kind is a type error rather than a plain line. */\nconst LINE_STYLE: Record<\n HeaderLine[\"kind\"],\n { readonly color?: string; readonly dim?: boolean; readonly bold?: boolean }\n> = {\n title: { color: THEME.accent, bold: true },\n summary: { dim: true },\n state: {},\n warning: { color: THEME.warning },\n}\n\n/** The live columns, clamped. Exported so a body lays its rows out against the same number. */\nexport function screenWidth(columns: number): number {\n return Math.max(MIN_SCREEN_COLUMNS, Math.min(MAX_SCREEN_COLUMNS, columns))\n}\n\nexport function Screen({ header, footer, children }: ScreenProps) {\n const size = useTerminalSize()\n const width = screenWidth(size.columns)\n // Two columns for the border, two for the padding: what the header may actually use.\n const inner = width - 4\n const lines = headerLines(header, inner)\n const chips = header.state ?? []\n\n return (\n <Box flexDirection=\"column\" width={width}>\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.borderActive}\n paddingX={1}\n >\n {lines.map((line) =>\n // The state row is the one line whose parts are coloured individually, so it is\n // rendered from the chips rather than from its own already-joined text. The text is\n // still what the tests read, and the two cannot disagree because `headerLines`\n // built that string from the same array.\n line.kind === \"state\" ? (\n <Text key={line.text} wrap=\"truncate\">\n {chips.map((chip, at) => (\n <Text key={chip.label} color={TONE[chip.tone]}>\n {at === 0 ? \"\" : \" · \"}\n {chip.label}\n </Text>\n ))}\n </Text>\n ) : (\n <Text\n key={line.text}\n wrap=\"truncate\"\n bold={LINE_STYLE[line.kind].bold === true}\n dimColor={LINE_STYLE[line.kind].dim === true}\n {...(LINE_STYLE[line.kind].color === undefined\n ? {}\n : { color: LINE_STYLE[line.kind].color })}\n >\n {line.text}\n </Text>\n ),\n )}\n </Box>\n\n <Box flexDirection=\"column\" marginTop={1}>\n {children}\n </Box>\n\n {footer === undefined || footer.length === 0 ? null : (\n <Box marginTop={1}>\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {hintLine(footer, inner)}\n </Text>\n </Box>\n )}\n </Box>\n )\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";wWAsBA,cAAS,UAAK,cAAM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|
2
|
+
import{e}from"./index-2cvtz0fy.js";import{nt,Zt}from"./index-t1xvacym.js";import{o,u,oe}from"./index-jk0def33.js";import"./index-b5wwtxzk.js";import{et}from"./index-fvhg0xyd.js";import{rt}from"./index-bwckzbf8.js";import{Qt,it,en}from"./index-cx3vz7sf.js";import{qt,tt,Gt}from"./index-e8n70sgj.js";import{ae,G}from"./index-mrtb5y08.js";import{de}from"./index-b8zwg8a3.js";import"./index-qc2vrq9z.js";import"./index-h2yds678.js";import{Vt}from"./index-jym27m75.js";import{re}from"./index-rqbtm761.js";import{Me,at,At,It,Le,Ee}from"./index-bry9bzt3.js";import"./index-xgqzk5cq.js";import"./index-7da4fqcr.js";import{Z,No}from"./index-9nsfs0vy.js";import"./index-mgdgx22q.js";import{D,X,Dt,gn}from"./index-6z0yr17z.js";import{U,kn,_n}from"./index-my5cjx00.js";import{Box as m,Text as h,useApp as ue,useInput as pe}from"ink";import{useCallback as me,useEffect as A,useReducer as fe,useState as ke}from"react";import{Box as ie,Text as _}from"ink";import{jsx as N,jsxs as se}from"react/jsx-runtime";function Q({rows:n}){let t=n.reduce((r,c)=>Math.max(r,c.label.length),0);return N(ie,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,children:n.map((r)=>se(_,{children:[N(_,{dimColor:!0,children:r.label.padEnd(t+2)}),r.value]},r.label))})}import{Box as Y,Text as W}from"ink";import{jsx as R,jsxs as E}from"react/jsx-runtime";function H({step:n,total:t,answered:r,hint:c,children:l}){return E(Y,{flexDirection:"column",children:[r.map((p)=>E(W,{children:[R(W,{color:o.success,children:u.check}),R(W,{dimColor:!0,children:p.label.padEnd(18)}),p.value]},p.label)),R(Y,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,marginTop:r.length>0?1:0,children:l}),E(W,{dimColor:!0,children:["step ",n," of ",t," ",u.bullet,c]})]})}function q(n,t){let r={given:n,log:[],phase:"asking",editor:D,select:{index:0,count:Me.length},error:void 0,defaults:t};return f(r)===void 0?P(r):r}function b(n){return{...Object.fromEntries(n.log.map((r)=>[r.step,r.value])),...n.given}}function f(n){return Le(b(n),n.defaults)}function z(n){return n.phase==="asking"&&f(n)?.options!==void 0}function V(n){return f(n)?.options??[]}function j(n){let t=f(n)?.step;return n.phase==="asking"&&t!==void 0&&It.has(t)}function J(n){let t={...b(n)},r=0;for(;;){let l=Le(t,n.defaults);if(l===void 0)break;r+=1,t[l.step]=l.fallback===""?"(x)":l.fallback}let c=n.log.length+Object.keys(n.given).length;return{asked:c+(n.phase==="asking"?1:0),total:c+r}}var le=2;function P(n){return{...n,phase:"confirm",editor:D,select:{index:0,count:le},error:void 0}}function v(n){let t=Le(b(n),n.defaults),r=t?.options;return{editor:D,select:{index:ce(t),count:r===void 0?Me.length:r.length},error:void 0}}function ce(n){let t=n?.options;if(t===void 0)return 0;let r=Number(n?.fallback)-1;return Number.isInteger(r)&&r>=0&&r<t.length?r:0}function T(n,t){if(n.phase==="done"||n.phase==="aborted")return n;switch(t.kind){case"abort":return{...n,phase:"aborted"};case"edit":if(n.phase!=="asking")return n;return{...n,editor:X(n.editor,t.intent),error:void 0};case"list":{let r=t.intent;if(r.kind==="move")return{...n,select:G(n.select,r.move),error:void 0};if(r.kind==="choose")return T(n,{kind:"commit"});if(r.kind==="back")return T(n,{kind:"back"});if(r.kind==="exit")return{...n,phase:"aborted"};return n}case"back":{if(n.phase==="confirm"){if(n.log.length===0)return{...n,phase:"asking",...v(n)};let l=n.log.slice(0,-1),p={...n,phase:"asking",log:l};return{...p,...v(p)}}if(n.log.length===0)return n;let r=n.log.slice(0,-1),c={...n,log:r};return{...c,...v(c)}}case"commit":{if(n.phase==="confirm")return n.select.index===0?{...n,phase:"done"}:T(n,{kind:"back"});let r=f(n);if(r===void 0)return P(n);let c=r.options!==void 0?r.options[n.select.index]?.value??"":n.editor.value.trim()===""?r.fallback:n.editor.value,l=Ee(r.step,c);if(!l.ok)return{...n,error:l.reason};let p={...n,log:[...n.log,{step:r.step,value:l.value}]},d={...p,...v(p)};return f(d)===void 0?P(d):d}}}function ee(n){if(n==="")return"";if(n.length<=8)return"•".repeat(n.length);return`${n.slice(0,3)}${"•".repeat(6)}${n.slice(-2)}`}function ne(n){let t=b(n),r=t.preset===void 0?void 0:at(t.preset),c=`${t.model??""} at ${t.baseUrl??""}`,l=t.apiKeyEnv??r?.apiKeyEnv,p=l===void 0?" (no key)":` (${l}=${t.apiKey===void 0||t.apiKey===""?"not set yet":ee(t.apiKey)})`;return[{label:"agent",value:t.name??""},{label:"for",value:`${t.user??""} — ${t.purpose??""}`},{label:"endpoint",value:`${c}${p}`},{label:"directory",value:t.dir??At(t.dirChoice,t.name,n.defaults)??""}]}function te(n){let t={user:"Your name",name:"Agent name",purpose:"Purpose",preset:"Endpoint",model:"Model",baseUrl:"Base URL",apiKeyEnv:"Key env var",apiKey:"API key",web:"Internet",webBackend:"Search backend",webKey:"Search key",system:"System access",composio:"Other apps",telegram:"Telegram",telegramAllow:"Telegram handle",telegramToken:"Bot token",schedules:"none",server:"HTTP API",skills:"Skills",skillsSearch:"Skill search",skillsPick:"Skills picked",daemon:"Background service",serverToken:"API token",composioKey:"Composio key",dirChoice:"Location",dir:"Directory"};return n.log.map((r)=>({label:t[r.step],value:It.has(r.step)?ee(r.value):r.value}))}import{jsx as s,jsxs as g}from"react/jsx-runtime";var ge=16,he=5;function nn({title:n,given:t,defaults:r,onDone:c}){let{exit:l}=ue(),p=re(),[d,k]=ke({kind:"idle"}),[a,x]=fe((i,y)=>T(i,y),void 0,()=>q(t,r)),B=me((i)=>{c(i),l()},[c,l]),I=a.log.some((i)=>i.step==="skills"&&i.value==="find");if(A(()=>{if(!I||d.kind!=="idle")return;k({kind:"fetching",status:"reading the catalogue"}),(async()=>{try{let i=await et({onStatus:(S)=>k({kind:"fetching",status:S})});if(i.length===0){k({kind:"failed",message:"no catalogue could be read — carrying on without skills"});return}let y=nt(i);k({kind:"picking",rows:i,picked:{cursor:{index:Gt(y),count:i.length},chosen:[]}})}catch(i){k({kind:"failed",message:i instanceof Error?i.message:String(i)})}})()},[I,d.kind]),A(()=>{if(d.kind!=="failed")return;let i=setTimeout(()=>k({kind:"done",refs:[]}),1400);return()=>clearTimeout(i)},[d]),A(()=>{if(a.phase==="done"){let i=d.kind==="done"?d.refs:[];B({...b(a),...i.length===0?{}:{skillsPick:i.join(",")}})}if(a.phase==="aborted")B(void 0)},[a,B,d]),pe((i,y)=>{if(d.kind==="picking"){let M=d.rows,F=nt(M),w=Dt(i,y);switch(w.kind){case"move":case"toggle":case"all":k({...d,picked:tt(d.picked,w.kind==="move"?{kind:"move",move:w.move}:{kind:w.kind},F)});return;case"none-selected":k({...d,picked:tt(d.picked,{kind:"none"},F)});return;case"confirm":case"cancel":k({kind:"done",refs:w.kind==="cancel"?[]:Zt(M,d.picked.chosen).map((K)=>`${K.source}/${K.skill}`)});return;default:return}}if(d.kind==="fetching"||d.kind==="failed")return;let S=gn(i,y,{select:z(a)||a.phase==="confirm",empty:a.editor.value===""});switch(S.kind){case"abort":x({kind:"abort"});return;case"back":x({kind:"back"});return;case"commit":x({kind:"commit"});return;case"list":x({kind:"list",intent:S.intent});return;case"edit":x({kind:"edit",intent:S.intent});return}}),a.phase==="done"||a.phase==="aborted")return null;if(d.kind==="fetching")return g(m,{flexDirection:"column",children:[s(rt,{title:"Skills",lines:["choosing what this agent knows how to do"]}),s(m,{marginTop:1,paddingLeft:2,children:s(de,{label:d.status})})]});if(d.kind==="failed")return g(m,{flexDirection:"column",children:[s(rt,{title:"Skills",lines:["carrying on without them"]}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:o.warning,children:d.message})})]});if(d.kind==="picking"){let i=d.picked.chosen.length;return g(m,{flexDirection:"column",children:[s(rt,{title:"Skills",lines:["space ticks · a all · n none · enter continues · esc skips"]}),s(m,{marginTop:1,children:s(qt,{rows:d.rows,index:d.picked.cursor.index,chosen:d.picked.chosen,window:No(void 0,kn),width:Z(void 0,U)})}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:i===0?o.muted:o.success,children:i===0?"nothing ticked — enter carries on without any":`${i} ticked`})})]})}let L=J(a),C=en(e.name,{columns:Z(p.columns,U)-it,rows:Math.min(he,Math.max(0,p.rows-ge))}),O=a.phase==="confirm"?"enter confirm · esc back · ^C quit — nothing written":"enter accepts · esc back · ^C quit — nothing written";return g(m,{flexDirection:"column",children:[C.lines.length>0?s(Qt,{lines:C.lines}):null,s(m,{marginTop:C.lines.length>0?1:0,children:g(h,{dimColor:!0,wrap:"truncate",children:[n," · a few questions — nothing is written until you confirm"]})}),a.phase==="confirm"?g(m,{flexDirection:"column",marginTop:1,children:[s(Q,{rows:ne(a)}),g(m,{marginTop:1,flexDirection:"column",children:[s(h,{children:"Write the files?"}),s(ae,{items:[{label:"yes"},{label:"no, go back"}],index:a.select.index})]}),s(h,{dimColor:!0,children:O})]}):s(m,{marginTop:1,children:s(H,{step:L.asked,total:L.total,answered:te(a),hint:O,children:z(a)?g(m,{flexDirection:"column",children:[s(h,{children:f(a)?.prompt??""}),s(ae,{items:V(a).map((i)=>({label:i.label,...i.hint===void 0?{}:{hint:i.hint}})),index:a.select.index,numbered:!0})]}):s(Vt,{label:f(a)?.prompt??"",editor:a.editor,columns:Z(p.columns,U)-it,maxRows:_n,placeholder:f(a)?.fallback??"",...a.error===void 0?{}:{error:a.error},...j(a)?{secret:!0}:{}})})}),a.error!==void 0&&(z(a)||a.phase==="confirm")?g(h,{color:o.error,children:[u.error,a.error]}):null]})}export{nn as WizardApp};
|
|
3
|
+
|
|
4
|
+
//# debugId=86D023C3B716A95664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=WizardApp-12ndxgqv.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/WizardApp.tsx", "../src/components/SummaryCard.tsx", "../src/components/WizardFrame.tsx", "../src/lib/wizard.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The init wizard's Ink root: one `useInput`, a pure reducer, and the kit.\n *\n * Deliberately NO `<Static>` anywhere here — answered lines are editable via esc-back, which is\n * incompatible with Static's write-once contract, and the whole wizard is a couple of dozen\n * dynamic rows with no streaming, so full-frame redraw is free. Do not \"optimise\" this into\n * Static; the transcript's constraints do not apply to a form.\n */\n\nimport { BRAND } from \"@dispach/core\"\nimport { Box, Text, useApp, useInput } from \"ink\"\nimport { useCallback, useEffect, useReducer, useState } from \"react\"\nimport { fetchCatalogue } from \"#browse\"\nimport { Banner } from \"#components/Banner\"\nimport { BRAND_INDENT, Brandmark } from \"#components/Brandmark\"\nimport { CheckList } from \"#components/CheckList\"\nimport { SelectList } from \"#components/SelectList\"\nimport { Spinner } from \"#components/Spinner\"\nimport { SummaryCard } from \"#components/SummaryCard\"\nimport { TextField } from \"#components/TextField\"\nimport { WizardFrame } from \"#components/WizardFrame\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { keyToCheckIntent, keyToWizardIntent } from \"#keymap\"\nimport { type BrowseRow, chosenEntries, selectableOf } from \"#lib/browse\"\nimport { FALLBACK_COLUMNS, FALLBACK_ROWS, FIELD_ROWS } from \"#lib/const\"\nimport type { PartialAnswers, QuestionDefaults } from \"#lib/init-flow\"\nimport { firstSelectable, type MultiSelectState, reduceMultiSelect } from \"#lib/multiselect\"\nimport { screenColumns, screenRows } from \"#lib/screen\"\nimport { GLYPH, THEME } from \"#lib/theme\"\nimport {\n answeredRows,\n currentQuestion,\n isSecretStep,\n isSelectStep,\n partialOf,\n reduceWizard,\n selectOptions,\n startWizard,\n stepCounts,\n summaryRows,\n type WizardState,\n} from \"#lib/wizard\"\nimport { wordmark } from \"#lib/wordmark\"\n\n/**\n * Rows the wizard body needs before a wordmark is affordable — the field box, the answered-so-far list as\n * it grows, the step line, and a margin. Measured against the tallest question rather than the current one:\n * a mark that fitted on step 1 and pushed the step line off the screen on step 12 is worse than no mark.\n */\nconst WIZARD_BODY_ROWS = 16\n/** The mark never takes more than the chat's own largest tier, however tall the terminal is. */\nconst WORDMARK_MAX_ROWS = 5\n\nexport interface WizardAppProps {\n readonly title: string\n readonly given: PartialAnswers\n readonly defaults: QuestionDefaults\n /** The collected answers, or undefined when the person backed out. */\n readonly onDone: (answers: PartialAnswers | undefined) => void\n}\n\n/**\n * The catalogue step, which is a *screen* rather than a question.\n *\n * It lives in the root's own state instead of the pure reducer for one reason: it needs a network fetch, and\n * `nextQuestion` is a pure synchronous function over static option tables. That was the excuse for asking a\n * text question instead — \"what does it do often?\" — in a tree that already had a checklist. Wrong: the\n * reducer's shape is a fact about the reducer, and the *flow* is what the person sees. So the answer stays a\n * static three-way choice, and picking happens here, between two questions, with the remaining questions\n * carrying on afterwards.\n *\n * `fetchCatalogue` reports progress through a callback rather than to stdout, because writing to stdout\n * while Ink owns the frame paints over it — and being *async* is what keeps the spinner turning and the\n * keystrokes consumed. A blocking `spawnSync` here froze the app and let the tty echo the arrow keys\n * somebody pressed during a twenty-second clone, straight into the middle of the output.\n */\ntype Catalogue =\n | { readonly kind: \"idle\" }\n | { readonly kind: \"fetching\"; readonly status: string }\n | {\n readonly kind: \"picking\"\n readonly rows: readonly BrowseRow[]\n readonly picked: MultiSelectState\n }\n | { readonly kind: \"failed\"; readonly message: string }\n | { readonly kind: \"done\"; readonly refs: readonly string[] }\n\nexport function WizardApp({ title, given, defaults, onDone }: WizardAppProps) {\n const { exit } = useApp()\n // The live size, so a resize re-picks the wordmark's tier rather than freezing whichever one fitted at\n // launch. `screenColumns` is what handles a stream reporting a width of zero.\n const size = useTerminalSize()\n const [catalogue, setCatalogue] = useState<Catalogue>({ kind: \"idle\" })\n const [state, dispatch] = useReducer(\n (current: WizardState, action: Parameters<typeof reduceWizard>[1]) =>\n reduceWizard(current, action),\n undefined,\n () => startWizard(given, defaults),\n )\n\n const finish = useCallback(\n (answers: PartialAnswers | undefined) => {\n onDone(answers)\n exit()\n },\n [onDone, exit],\n )\n\n // Answered `find`, and the answer came from the *log* rather than from a flag — a `--skills find` run\n // would otherwise open the picker before the first question, which is not \"in the flow\", it is instead\n // of it.\n const wantsCatalogue = state.log.some(\n (entry) => entry.step === \"skills\" && entry.value === \"find\",\n )\n\n useEffect(() => {\n if (!wantsCatalogue || catalogue.kind !== \"idle\") return\n setCatalogue({ kind: \"fetching\", status: \"reading the catalogue\" })\n void (async () => {\n try {\n const rows = await fetchCatalogue({\n onStatus: (status) => setCatalogue({ kind: \"fetching\", status }),\n })\n if (rows.length === 0) {\n setCatalogue({\n kind: \"failed\",\n message: \"no catalogue could be read — carrying on without skills\",\n })\n return\n }\n const selectable = selectableOf(rows)\n setCatalogue({\n kind: \"picking\",\n rows,\n picked: {\n cursor: { index: firstSelectable(selectable), count: rows.length },\n chosen: [],\n },\n })\n } catch (error) {\n // Never fatal. A network that is down must not cost somebody the agent they were setting up.\n setCatalogue({\n kind: \"failed\",\n message: error instanceof Error ? error.message : String(error),\n })\n }\n })()\n }, [wantsCatalogue, catalogue.kind])\n\n // A failure is shown for a moment and then stepped past, rather than blocking on a keypress nobody\n // needs to make: there is no decision left to take.\n useEffect(() => {\n if (catalogue.kind !== \"failed\") return\n const timer = setTimeout(() => setCatalogue({ kind: \"done\", refs: [] }), 1400)\n return () => clearTimeout(timer)\n }, [catalogue])\n\n useEffect(() => {\n if (state.phase === \"done\") {\n const refs = catalogue.kind === \"done\" ? catalogue.refs : []\n finish({\n ...partialOf(state),\n ...(refs.length === 0 ? {} : { skillsPick: refs.join(\",\") }),\n })\n }\n if (state.phase === \"aborted\") finish(undefined)\n }, [state, finish, catalogue])\n\n useInput((input, key) => {\n // While the catalogue owns the screen it owns the keyboard. Routed here rather than by disabling\n // `useInput`: Ink allows one handler per root, and two would race for the same keypress.\n if (catalogue.kind === \"picking\") {\n const rows = catalogue.rows\n const selectable = selectableOf(rows)\n const intent = keyToCheckIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n case \"toggle\":\n case \"all\":\n setCatalogue({\n ...catalogue,\n picked: reduceMultiSelect(\n catalogue.picked,\n intent.kind === \"move\"\n ? { kind: \"move\", move: intent.move }\n : { kind: intent.kind },\n selectable,\n ),\n })\n return\n case \"none-selected\":\n setCatalogue({\n ...catalogue,\n picked: reduceMultiSelect(catalogue.picked, { kind: \"none\" }, selectable),\n })\n return\n case \"confirm\":\n case \"cancel\":\n // Enter with nothing ticked and esc are the same outcome — no skills — and both carry\n // on with the remaining questions rather than ending anything.\n setCatalogue({\n kind: \"done\",\n refs:\n intent.kind === \"cancel\"\n ? []\n : chosenEntries(rows, catalogue.picked.chosen).map(\n (entry) => `${entry.source}/${entry.skill}`,\n ),\n })\n return\n default:\n return\n }\n }\n if (catalogue.kind === \"fetching\" || catalogue.kind === \"failed\") return\n\n const intent = keyToWizardIntent(input, key, {\n select: isSelectStep(state) || state.phase === \"confirm\",\n empty: state.editor.value === \"\",\n })\n switch (intent.kind) {\n case \"abort\":\n dispatch({ kind: \"abort\" })\n return\n case \"back\":\n dispatch({ kind: \"back\" })\n return\n case \"commit\":\n dispatch({ kind: \"commit\" })\n return\n case \"list\":\n dispatch({ kind: \"list\", intent: intent.intent })\n return\n case \"edit\":\n dispatch({ kind: \"edit\", intent: intent.intent })\n return\n }\n })\n\n if (state.phase === \"done\" || state.phase === \"aborted\") return null\n\n if (catalogue.kind === \"fetching\") {\n return (\n <Box flexDirection=\"column\">\n <Banner title=\"Skills\" lines={[\"choosing what this agent knows how to do\"]} />\n <Box marginTop={1} paddingLeft={2}>\n <Spinner label={catalogue.status} />\n </Box>\n </Box>\n )\n }\n\n if (catalogue.kind === \"failed\") {\n return (\n <Box flexDirection=\"column\">\n <Banner title=\"Skills\" lines={[\"carrying on without them\"]} />\n <Box marginTop={1} paddingLeft={2}>\n <Text color={THEME.warning}>{catalogue.message}</Text>\n </Box>\n </Box>\n )\n }\n\n if (catalogue.kind === \"picking\") {\n const ticked = catalogue.picked.chosen.length\n return (\n <Box flexDirection=\"column\">\n <Banner\n title=\"Skills\"\n lines={[\"space ticks · a all · n none · enter continues · esc skips\"]}\n />\n <Box marginTop={1}>\n <CheckList\n rows={catalogue.rows}\n index={catalogue.picked.cursor.index}\n chosen={catalogue.picked.chosen}\n window={screenRows(undefined, FALLBACK_ROWS)}\n width={screenColumns(undefined, FALLBACK_COLUMNS)}\n />\n </Box>\n <Box marginTop={1} paddingLeft={2}>\n <Text color={ticked === 0 ? THEME.muted : THEME.success}>\n {ticked === 0\n ? \"nothing ticked — enter carries on without any\"\n : `${ticked} ticked`}\n </Text>\n </Box>\n </Box>\n )\n }\n\n const counts = stepCounts(state)\n // Rows the wizard body needs before a picture is affordable: the field box, the answered-so-far list,\n // the step line, and a margin. Below that the mark degrades and then goes.\n const mark = wordmark(BRAND.name, {\n columns: screenColumns(size.columns, FALLBACK_COLUMNS) - BRAND_INDENT,\n rows: Math.min(WORDMARK_MAX_ROWS, Math.max(0, size.rows - WIZARD_BODY_ROWS)),\n })\n\n const hint =\n state.phase === \"confirm\"\n ? \"enter confirm · esc back · ^C quit — nothing written\"\n : \"enter accepts · esc back · ^C quit — nothing written\"\n\n return (\n <Box flexDirection=\"column\">\n {/*\n * The wordmark, then a one-line header — the chat's own shape, and the same `wordmark` rather\n * than a second mark for a second surface.\n *\n * It replaces a boxed title rather than sitting above one. Keeping both would put the product\n * name on screen twice, three rows apart, which is the duplication the chat banner had until\n * this phase — a picture of the name above a box that also spells it, three rows apart.\n *\n * The budget is what makes it degrade. `wordmark` walks its tiers down to a single spaced-out\n * line and there is no floor below that, so a short or narrow terminal loses the picture rather\n * than the questions.\n */}\n {mark.lines.length > 0 ? <Brandmark lines={mark.lines} /> : null}\n <Box marginTop={mark.lines.length > 0 ? 1 : 0}>\n <Text dimColor wrap=\"truncate\">\n {title} · a few questions — nothing is written until you confirm\n </Text>\n </Box>\n {state.phase === \"confirm\" ? (\n <Box flexDirection=\"column\" marginTop={1}>\n <SummaryCard rows={summaryRows(state)} />\n <Box marginTop={1} flexDirection=\"column\">\n <Text>Write the files?</Text>\n <SelectList\n items={[{ label: \"yes\" }, { label: \"no, go back\" }]}\n index={state.select.index}\n />\n </Box>\n <Text dimColor>{hint}</Text>\n </Box>\n ) : (\n <Box marginTop={1}>\n <WizardFrame\n step={counts.asked}\n total={counts.total}\n answered={answeredRows(state)}\n hint={hint}\n >\n {isSelectStep(state) ? (\n <Box flexDirection=\"column\">\n <Text>{currentQuestion(state)?.prompt ?? \"\"}</Text>\n <SelectList\n items={selectOptions(state).map((option) => ({\n label: option.label,\n ...(option.hint === undefined ? {} : { hint: option.hint }),\n }))}\n index={state.select.index}\n numbered\n />\n </Box>\n ) : (\n <TextField\n label={currentQuestion(state)?.prompt ?? \"\"}\n editor={state.editor}\n // Not a bug fix here: the bordered frame already bounds the text, so a\n // long answer wrapped without this — measured, rather than assumed after\n // the settings editor turned out to be broken. Passed because the\n // component that owns a bounded window should do its own wrapping, and\n // because `maxRows` is a real bound on the height that did not exist.\n columns={\n screenColumns(size.columns, FALLBACK_COLUMNS) - BRAND_INDENT\n }\n maxRows={FIELD_ROWS}\n placeholder={currentQuestion(state)?.fallback ?? \"\"}\n {...(state.error === undefined ? {} : { error: state.error })}\n {...(isSecretStep(state) ? { secret: true } : {})}\n />\n )}\n </WizardFrame>\n </Box>\n )}\n {state.error !== undefined && (isSelectStep(state) || state.phase === \"confirm\") ? (\n <Text color={THEME.error}>\n {GLYPH.error}\n {state.error}\n </Text>\n ) : null}\n </Box>\n )\n}\n",
|
|
6
|
+
"/**\n * The confirm screen's answer recap: labels dim and right-padded, values plain, in a card.\n */\n\nimport { Box, Text } from \"ink\"\nimport { BORDER_STYLE, THEME } from \"#lib/theme\"\n\nexport interface SummaryCardProps {\n readonly rows: readonly { readonly label: string; readonly value: string }[]\n}\n\nexport function SummaryCard({ rows }: SummaryCardProps) {\n const width = rows.reduce((widest, row) => Math.max(widest, row.label.length), 0)\n return (\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.border}\n paddingX={1}\n paddingY={1}\n >\n {rows.map((row) => (\n <Text key={row.label}>\n <Text dimColor>{row.label.padEnd(width + 2)}</Text>\n {row.value}\n </Text>\n ))}\n </Box>\n )\n}\n",
|
|
7
|
+
"/**\n * The wizard's chrome: answered lines above, the current question in a rounded box, a dim hint\n * footer. The `step m of n` count is honest — a keyless preset shrinks `total`, and the frame\n * shows whatever the reducer computed rather than a number that quietly stops being true.\n */\n\nimport { Box, Text } from \"ink\"\nimport type { ReactNode } from \"react\"\nimport { BORDER_STYLE, GLYPH, THEME } from \"#lib/theme\"\n\nexport interface WizardFrameProps {\n readonly step: number\n readonly total: number\n /** Already-answered questions, rendered ✓ label value. Esc pops the last one. */\n readonly answered: readonly { readonly label: string; readonly value: string }[]\n readonly hint: string\n readonly children: ReactNode\n}\n\nexport function WizardFrame({ step, total, answered, hint, children }: WizardFrameProps) {\n return (\n <Box flexDirection=\"column\">\n {answered.map((entry) => (\n <Text key={entry.label}>\n <Text color={THEME.success}>{GLYPH.check}</Text>\n <Text dimColor>{entry.label.padEnd(18)}</Text>\n {entry.value}\n </Text>\n ))}\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.border}\n paddingX={1}\n paddingY={1}\n marginTop={answered.length > 0 ? 1 : 0}\n >\n {children}\n </Box>\n <Text dimColor>\n step {step} of {total} {GLYPH.bullet}\n {hint}\n </Text>\n </Box>\n )\n}\n",
|
|
8
|
+
"/**\n * The init wizard as a pure reducer — a log of answers over `nextQuestion`'s forward-only flow.\n *\n * `nextQuestion` cannot go backwards, so back-navigation is an *answer log*: esc pops the tail\n * and the next question is recomputed from what remains. Popping the tail is always consistent\n * because the log is a prefix of the asking order — re-answering the preset re-derives every\n * downstream default for free. Flag-given answers live in `given` and are never poppable: they\n * were explicit, and backing over them would silently discard something the person typed into a\n * shell.\n *\n * Renderer-free and process-free (PURE-listed): `WizardApp` is one consumer; a test driving the\n * reducer with the same intents is another, and the two cannot diverge.\n */\n\nimport { applyIntent, EMPTY_EDITOR } from \"#editor\"\nimport type { ListIntent } from \"#keymap\"\nimport {\n dirFor,\n type InitStep,\n nextQuestion,\n type PartialAnswers,\n PRESETS,\n presetById,\n type Question,\n type QuestionDefaults,\n SECRET_STEPS,\n validateAnswer,\n} from \"#lib/init-flow\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport type { EditorState, Intent } from \"#lib/types\"\n\nexport type WizardPhase = \"asking\" | \"confirm\" | \"done\" | \"aborted\"\n\nexport interface WizardState {\n /** Flag answers — explicit, never poppable. */\n readonly given: PartialAnswers\n /** What the wizard collected, in asking order. Esc pops the tail. */\n readonly log: readonly { readonly step: InitStep; readonly value: string }[]\n readonly phase: WizardPhase\n /** The current text answer. Reuses the chat editor's state machine wholesale. */\n readonly editor: EditorState\n /** The current select answer (preset step, and the confirm screen's yes/no). */\n readonly select: SelectState\n /** Last validation failure; cleared on the next edit. */\n readonly error: string | undefined\n readonly defaults: QuestionDefaults\n}\n\nexport function startWizard(given: PartialAnswers, defaults: QuestionDefaults): WizardState {\n const state: WizardState = {\n given,\n log: [],\n phase: \"asking\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: PRESETS.length },\n error: undefined,\n defaults,\n }\n // Flags may already answer everything (`init --user … --name … --preset …` at a TTY): the\n // wizard then opens directly on the confirm screen rather than asking zero questions oddly.\n return currentQuestion(state) === undefined ? enterConfirm(state) : state\n}\n\nexport function partialOf(state: WizardState): PartialAnswers {\n const fromLog = Object.fromEntries(state.log.map((entry) => [entry.step, entry.value]))\n // `given` wins, though overlap cannot occur: nextQuestion never asks an answered step, so the\n // log never contains one.\n return { ...fromLog, ...state.given }\n}\n\nexport function currentQuestion(state: WizardState): Question | undefined {\n return nextQuestion(partialOf(state), state.defaults)\n}\n\n/**\n * Is the current question a fixed set of choices rather than a text field?\n *\n * Read off the question's own `options` rather than compared against a step name. The preset menu was\n * the only select for three phases and \"is this the preset step\" ended up written into the reducer,\n * the renderer and the cursor prefill — so adding a second one had to either repeat all three or\n * generalise them. Generalising is what stops a third repeating them again.\n */\nexport function isSelectStep(state: WizardState): boolean {\n return state.phase === \"asking\" && currentQuestion(state)?.options !== undefined\n}\n\n/** The choices on screen, empty when the question is a text field. */\nexport function selectOptions(state: WizardState): readonly {\n readonly value: string\n readonly label: string\n readonly hint?: string\n}[] {\n return currentQuestion(state)?.options ?? []\n}\n\n/** Whether the question on screen is one whose answer must never be rendered. */\nexport function isSecretStep(state: WizardState): boolean {\n const step = currentQuestion(state)?.step\n return state.phase === \"asking\" && step !== undefined && SECRET_STEPS.has(step)\n}\n\n/**\n * Honest step numbering: walk the flow the same way it will actually be asked, so a keyless\n * preset shrinks the total rather than leaving a count that quietly stops being true.\n */\nexport function stepCounts(state: WizardState): { readonly asked: number; readonly total: number } {\n const walk: Record<string, string> = { ...partialOf(state) }\n let remaining = 0\n for (;;) {\n const question = nextQuestion(walk, state.defaults)\n if (question === undefined) break\n remaining += 1\n walk[question.step] = question.fallback === \"\" ? \"(x)\" : question.fallback\n }\n const asked = state.log.length + Object.keys(state.given).length\n return { asked: asked + (state.phase === \"asking\" ? 1 : 0), total: asked + remaining }\n}\n\nexport type WizardAction =\n | { readonly kind: \"edit\"; readonly intent: Intent }\n | { readonly kind: \"list\"; readonly intent: ListIntent }\n | { readonly kind: \"commit\" }\n | { readonly kind: \"back\" }\n | { readonly kind: \"abort\" }\n\nconst CONFIRM_COUNT = 2 // yes / no\n\nfunction enterConfirm(state: WizardState): WizardState {\n return {\n ...state,\n phase: \"confirm\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: CONFIRM_COUNT },\n error: undefined,\n }\n}\n\nfunction freshFor(state: WizardState): Pick<WizardState, \"editor\" | \"select\" | \"error\"> {\n const question = nextQuestion(partialOf(state), state.defaults)\n const options = question?.options\n return {\n editor: EMPTY_EDITOR,\n select: {\n index: cursorFor(question),\n count: options === undefined ? PRESETS.length : options.length,\n },\n error: undefined,\n }\n}\n\n/** Prefill the cursor from the question's own fallback (\"1\" → 0). */\nfunction cursorFor(question: Question | undefined): number {\n const options = question?.options\n if (options === undefined) return 0\n const index = Number(question?.fallback) - 1\n return Number.isInteger(index) && index >= 0 && index < options.length ? index : 0\n}\n\nexport function reduceWizard(state: WizardState, action: WizardAction): WizardState {\n if (state.phase === \"done\" || state.phase === \"aborted\") return state\n\n switch (action.kind) {\n case \"abort\":\n return { ...state, phase: \"aborted\" }\n\n case \"edit\":\n if (state.phase !== \"asking\") return state\n return { ...state, editor: applyIntent(state.editor, action.intent), error: undefined }\n\n case \"list\": {\n const intent = action.intent\n if (intent.kind === \"move\") {\n return { ...state, select: moveSelect(state.select, intent.move), error: undefined }\n }\n if (intent.kind === \"choose\") return reduceWizard(state, { kind: \"commit\" })\n if (intent.kind === \"back\") return reduceWizard(state, { kind: \"back\" })\n if (intent.kind === \"exit\") return { ...state, phase: \"aborted\" }\n return state\n }\n\n case \"back\": {\n if (state.phase === \"confirm\") {\n // Back to the last asked question, its previous answer discarded so it re-asks\n // with the same defaults it had the first time.\n if (state.log.length === 0) return { ...state, phase: \"asking\", ...freshFor(state) }\n const log = state.log.slice(0, -1)\n const reopened = { ...state, phase: \"asking\" as const, log }\n return { ...reopened, ...freshFor(reopened) }\n }\n if (state.log.length === 0) return state // nothing wizard-asked to go back to\n const log = state.log.slice(0, -1)\n const popped = { ...state, log }\n return { ...popped, ...freshFor(popped) }\n }\n\n case \"commit\": {\n if (state.phase === \"confirm\") {\n // Index 0 is yes — the summary screen's select. \"no\" backs into the last question.\n return state.select.index === 0\n ? { ...state, phase: \"done\" }\n : reduceWizard(state, { kind: \"back\" })\n }\n\n const question = currentQuestion(state)\n if (question === undefined) return enterConfirm(state)\n\n const raw =\n question.options !== undefined\n ? (question.options[state.select.index]?.value ?? \"\")\n : state.editor.value.trim() === \"\"\n ? question.fallback\n : state.editor.value\n\n const checked = validateAnswer(question.step, raw)\n if (!checked.ok) {\n return { ...state, error: checked.reason }\n }\n\n const advanced: WizardState = {\n ...state,\n log: [...state.log, { step: question.step, value: checked.value }],\n }\n const next = { ...advanced, ...freshFor(advanced) }\n return currentQuestion(next) === undefined ? enterConfirm(next) : next\n }\n }\n}\n\n/**\n * What a secret looks like on screen.\n *\n * Enough to recognise a paste went in, never enough to reconstruct. Short values show nothing at\n * all rather than most of themselves.\n */\nexport function maskSecret(value: string): string {\n if (value === \"\") return \"\"\n if (value.length <= 8) return \"•\".repeat(value.length)\n return `${value.slice(0, 3)}${\"•\".repeat(6)}${value.slice(-2)}`\n}\n\n/** The confirm screen's rows, shared with the plain path's wording. */\nexport function summaryRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const partial = partialOf(state)\n const preset = partial.preset === undefined ? undefined : presetById(partial.preset)\n const endpoint = `${partial.model ?? \"\"} at ${partial.baseUrl ?? \"\"}`\n const keyVar = partial.apiKeyEnv ?? preset?.apiKeyEnv\n const key =\n keyVar === undefined\n ? \" (no key)\"\n : ` (${keyVar}=${partial.apiKey === undefined || partial.apiKey === \"\" ? \"not set yet\" : maskSecret(partial.apiKey)})`\n return [\n { label: \"agent\", value: partial.name ?? \"\" },\n { label: \"for\", value: `${partial.user ?? \"\"} — ${partial.purpose ?? \"\"}` },\n { label: \"endpoint\", value: `${endpoint}${key}` },\n // Derived when the answer was `sandbox` or `here`, because the `dir` question is not asked\n // then — and this row is the last thing read before anything is written, so it has to name\n // the directory that will actually exist. `dirFor` is the same function `complete()` calls;\n // a second derivation here is how a confirm screen comes to describe a different path.\n {\n label: \"directory\",\n value: partial.dir ?? dirFor(partial.dirChoice, partial.name, state.defaults) ?? \"\",\n },\n ]\n}\n\n/** The ✓ lines above the current question. */\nexport function answeredRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const labels: Record<InitStep, string> = {\n user: \"Your name\",\n name: \"Agent name\",\n purpose: \"Purpose\",\n preset: \"Endpoint\",\n model: \"Model\",\n baseUrl: \"Base URL\",\n apiKeyEnv: \"Key env var\",\n apiKey: \"API key\",\n web: \"Internet\",\n webBackend: \"Search backend\",\n webKey: \"Search key\",\n system: \"System access\",\n composio: \"Other apps\",\n telegram: \"Telegram\",\n telegramAllow: \"Telegram handle\",\n telegramToken: \"Bot token\",\n schedules: \"none\",\n server: \"HTTP API\",\n // Was literally `\"starter\"` — a value pasted into the label column, so the confirm screen\n // showed \"starter starter\" for the default answer and \"starter none\" for the other one.\n skills: \"Skills\",\n skillsSearch: \"Skill search\",\n skillsPick: \"Skills picked\",\n daemon: \"Background service\",\n serverToken: \"API token\",\n composioKey: \"Composio key\",\n dirChoice: \"Location\",\n dir: \"Directory\",\n }\n return state.log.map((entry) => ({\n label: labels[entry.step],\n // A secret is never echoed back, not even to the person who just typed it: these lines\n // stay on screen for the rest of the wizard and end up in scrollback.\n value: SECRET_STEPS.has(entry.step) ? maskSecret(entry.value) : entry.value,\n }))\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";qvBAUA,cAAS,UAAK,YAAM,eAAQ,aAC5B,sBAAS,gBAAa,gBAAW,eAAY,eCP7C,cAAS,WAAK,+DAOP,SAAS,CAAW,EAAG,QAA0B,CACpD,IAAM,EAAQ,EAAK,OAAO,CAAC,EAAQ,IAAQ,KAAK,IAAI,EAAQ,EAAI,MAAM,MAAM,EAAG,CAAC,EAChF,OACI,EAaE,GAbF,CACI,cAAc,SACd,YAAa,GACb,YAAa,EAAM,OACnB,SAAU,EACV,SAAU,EALd,SAOK,EAAK,IAAI,CAAC,IACP,GAGE,EAHF,UAGE,CAFE,EAA8C,EAA9C,CAAM,SAAQ,GAAd,SAAgB,EAAI,MAAM,OAAO,EAAQ,CAAC,EAAI,EAC7C,EAAI,QAFE,EAAI,KAGb,CACL,EACH,ECrBV,cAAS,UAAK,8DAaP,SAAS,CAAW,EAAG,OAAM,QAAO,WAAU,OAAM,YAA8B,CACrF,OACI,EAsBE,EAtBF,CAAK,cAAc,SAAnB,SAsBE,CArBG,EAAS,IAAI,CAAC,IACX,EAIE,EAJF,UAIE,CAHE,EAA2C,EAA3C,CAAM,MAAO,EAAM,QAAnB,SAA6B,EAAM,MA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AhB,SACI,EAoCE,EApCF,CACI,KAAM,EAAO,MACb,MAAO,EAAO,MACd,SAAU,GAAa,CAAK,EAC5B,KAAM,EAJV,SAMK,EAAa,CAAK,EACf,EAUE,EAVF,CAAK,cAAc,SAAnB,SAUE,CATE,EAA8C,EAA9C,UAAO,EAAgB,CAAK,GAAG,QAAU,GAAK,EAC9C,EAAC,GAAD,CACI,MAAO,EAAc,CAAK,EAAE,IAAI,CAAC,KAAY,CACzC,MAAO,EAAO,SACV,EAAO,OAAS,OAAY,CAAC,EAAI,CAAE,KAAM,EAAO,IAAK,CAC7D,EAAE,EACF,MAAO,EAAM,OAAO,MACpB,SAAQ,GACZ,GACF,EAEF,EAAC,GAAD,CACI,MAAO,EAAgB,CAAK,GAAG,QAAU,GACzC,OAAQ,EAAM,OAMd,QACI,EAAc,EAAK,QAAS,CAAgB,EAAI,GAEpD,QAAS,GACT,YAAa,EAAgB,CAAK,GAAG,UAAY,MAC5C,EAAM,QAAU,OAAY,CAAC,EAAI,CAAE,MAAO,EAAM,KAAM,KACtD,EAAa,CAAK,EAAI,CAAE,OAAQ,EAAK,EAAI,CAAC,EACnD,EAEN,EACJ,EAEL,EAAM,QAAU,SAAc,EAAa,CAAK,GAAK,EAAM,QAAU,WAClE,EAGE,EAHF,CAAM,MAAO,EAAM,MAAnB,SAGE,CAFG,EAAM,MACN,EAAM,OACT,EACF,MACN",
|
|
11
|
+
"debugId": "86D023C3B716A95664756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agents` — what one or more manifests produce.
|
|
3
|
+
*
|
|
4
|
+
* Small, and it proves the runtime hosts N agents from one process. It was inline in the entry point
|
|
5
|
+
* before, which is how it ended up being the one command whose flags the usage text never mentioned.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentsOptions } from "#lib/schema";
|
|
8
|
+
export declare function agentsCommand(options: AgentsOptions): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAyD3E"}
|
package/dist/browse.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bare `skills`, with no arguments: the catalogue, ticked, installed into an agent you pick.
|
|
3
|
+
*
|
|
4
|
+
* This is the entry point the owner asked for and the one the surface was missing. Everything else
|
|
5
|
+
* required knowing something first — `skills list <agent>` needs an agent, `sources search <words>` needs
|
|
6
|
+
* words, and `skills install <agent> <source>/<skill>` needs the name of a skill you have not seen yet.
|
|
7
|
+
* A person who wants skills has none of those, so the command that takes no arguments has to be the one
|
|
8
|
+
* that shows what exists.
|
|
9
|
+
*
|
|
10
|
+
* ## What it does not do
|
|
11
|
+
*
|
|
12
|
+
* It does not fetch on a pipe. `--plain`, a redirect, or CI gets the same list as text, from the same
|
|
13
|
+
* `browseRows`, with the two commands that install a skill non-interactively printed underneath — because
|
|
14
|
+
* a picker is not scriptable and pretending otherwise means somebody's CI job hangs on a keypress.
|
|
15
|
+
*
|
|
16
|
+
* It also does not resolve an agent for you when there are several. Installing somebody else's executable
|
|
17
|
+
* code into whichever agent happened to sort first is not a default worth having, so the second screen
|
|
18
|
+
* asks — and with exactly one agent it does not, because there is nothing to ask.
|
|
19
|
+
*/
|
|
20
|
+
import { type BrowseRow } from "#lib/browse";
|
|
21
|
+
import { type Git } from "#lib/source-cache";
|
|
22
|
+
export interface BrowseOptions {
|
|
23
|
+
readonly plain?: boolean;
|
|
24
|
+
readonly json?: boolean;
|
|
25
|
+
/** Injected by the tests, which never reach a network. */
|
|
26
|
+
readonly git?: Git;
|
|
27
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
28
|
+
/** Both overridden in tests; at a terminal they are measured from the stream. */
|
|
29
|
+
readonly rows?: number;
|
|
30
|
+
readonly width?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetch what is not cached, then build the rows. Shared by the command and by `init`.
|
|
34
|
+
*
|
|
35
|
+
* Announced before the work: the first run pays ~40 MB once per machine and every agent on it shares the
|
|
36
|
+
* result, and a command that pauses for twenty seconds with no output is indistinguishable from one that
|
|
37
|
+
* has hung — the failure this whole area's git wrapper exists to prevent.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Fetch what is not cached, then build the rows — reporting progress through a callback.
|
|
41
|
+
*
|
|
42
|
+
* A callback rather than `process.stdout` because one caller is *inside* a rendered screen, where writing
|
|
43
|
+
* to stdout paints over the frame Ink is managing. The other caller passes a writer and gets the same lines
|
|
44
|
+
* on a pipe. This is the seam that lets the init wizard show a spinner instead of a printed line.
|
|
45
|
+
*/
|
|
46
|
+
export declare function fetchCatalogue(options: BrowseOptions & {
|
|
47
|
+
readonly onStatus?: (line: string) => void;
|
|
48
|
+
}): Promise<readonly BrowseRow[]>;
|
|
49
|
+
/** The same thing for the paths that own the terminal, printing each line as it happens. */
|
|
50
|
+
export declare function catalogueRows(options: BrowseOptions): Promise<readonly BrowseRow[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Install a list of `<source>/<skill>` refs, reporting once.
|
|
53
|
+
*
|
|
54
|
+
* Exported for `init`, whose wizard already collected the refs on its own screen — so it needs the install
|
|
55
|
+
* without the picker.
|
|
56
|
+
*/
|
|
57
|
+
export declare function installRefs(refs: readonly string[], manifestPath: string, options: BrowseOptions & {
|
|
58
|
+
readonly envOverlay?: Readonly<Record<string, string | undefined>>;
|
|
59
|
+
}): number;
|
|
60
|
+
export declare function browseCommand(options: BrowseOptions): Promise<number>;
|
|
61
|
+
/** Kept beside the command so the banner and the picker cannot disagree about the version. */
|
|
62
|
+
export declare const BROWSE_TITLE: string;
|
|
63
|
+
//# sourceMappingURL=browse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browse.d.ts","sourceRoot":"","sources":["../src/browse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAEH,KAAK,SAAS,EAIjB,MAAM,aAAa,CAAA;AAQpB,OAAO,EAGH,KAAK,GAAG,EAGX,MAAM,mBAAmB,CAAA;AAI1B,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAA;IAClB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAC3D,iFAAiF;IACjF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;GAMG;AACH;;;;;;GAMG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GACxE,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAwB/B;AAED,4FAA4F;AAC5F,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAKzF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACvB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;CAAE,GAChG,MAAM,CAcR;AAyDD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA4F3E;AA8ED,8FAA8F;AAC9F,eAAO,MAAM,YAAY,QAA6B,CAAA"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed client, reachable as the `/client` subpath of the one published package.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this file exists at all
|
|
5
|
+
*
|
|
6
|
+
* The runtime is eight workspace packages and **one** npm name. That name is what a person installs
|
|
7
|
+
* to get the CLI, and it is also what an application installs to talk to a running server — so the
|
|
8
|
+
* client needs a subpath rather than a scope of its own. That keeps the registry surface to a single
|
|
9
|
+
* name, which is the whole point: one thing to own, one thing to transfer, and no scoped
|
|
10
|
+
* packages that exist only because a monorepo has directories.
|
|
11
|
+
*
|
|
12
|
+
* ## Why it is a separate build entry
|
|
13
|
+
*
|
|
14
|
+
* The CLI's own bundle is split so that `import("ink")` stays off the startup path. An application
|
|
15
|
+
* importing this must not pull any of that in — Ink and React cost ~170-210 ms under Node, more than
|
|
16
|
+
* the entire runtime of `validate --json`, and an HTTP client has no business paying it. So this is
|
|
17
|
+
* compiled as its own entry with no code splitting, and `boundaries.test.ts` asserts the built file
|
|
18
|
+
* imports neither.
|
|
19
|
+
*
|
|
20
|
+
* What it re-exports is `packages/client` unchanged. There is no wrapper, no re-declaration and no
|
|
21
|
+
* second set of types: a shim that restated the surface would be a second definition of the API, and
|
|
22
|
+
* this repo has paid for that shape often enough to know how it ends.
|
|
23
|
+
*/
|
|
24
|
+
export * from "@dispach/client";
|
|
25
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc,iBAAiB,CAAA"}
|