dispach 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -85
- package/dist/App-qfqvx9c7.js +11 -0
- package/dist/{App-b1yrwrcq.js.map → App-qfqvx9c7.js.map} +6 -7
- package/dist/ConfigEditor-apcnj4nj.js +6 -0
- package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
- package/dist/KeyProbe-ya5t3v3v.js +5 -0
- package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
- package/dist/Picker-b7mn0mjg.js +5 -0
- package/dist/{Picker-hfeh1g6m.js.map → Picker-b7mn0mjg.js.map} +1 -1
- package/dist/SessionPicker-vacfwczg.js +5 -0
- package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-vacfwczg.js.map} +2 -2
- package/dist/SkillBrowser-66ntwaa9.js +5 -0
- package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
- package/dist/WizardApp-123998yh.js +5 -0
- package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-123998yh.js.map} +3 -3
- package/dist/agents.d.ts +19 -3
- package/dist/agents.d.ts.map +1 -1
- package/dist/channels-q4fwqq87.js +31 -0
- package/dist/channels-q4fwqq87.js.map +10 -0
- package/dist/channels.d.ts +26 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/client.js +10 -10
- package/dist/client.js.map +3 -3
- package/dist/config-64q4mgxc.js +24 -0
- package/dist/{config-g7za9x13.js.map → config-64q4mgxc.js.map} +2 -2
- package/dist/{credential-npr6z8c8.js → credential-2sj7vsmw.js} +5 -5
- package/dist/{credential-npr6z8c8.js.map → credential-2sj7vsmw.js.map} +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/index-0k3w2mxf.js +6 -0
- package/dist/{index-hwpvhaza.js.map → index-0k3w2mxf.js.map} +1 -1
- package/dist/index-1s81qstp.js +6 -0
- package/dist/{index-v8e92nfw.js.map → index-1s81qstp.js.map} +1 -1
- package/dist/index-2rycma8x.js +12 -0
- package/dist/{index-258d8bzg.js.map → index-2rycma8x.js.map} +4 -3
- package/dist/index-2zye08c4.js +6 -0
- package/dist/{index-vgc3y3rm.js.map → index-2zye08c4.js.map} +2 -2
- package/dist/{index-gme2egyq.js → index-3km1jwh7.js} +4 -4
- package/dist/{index-gme2egyq.js.map → index-3km1jwh7.js.map} +1 -1
- package/dist/index-3mtgcvkq.js +429 -0
- package/dist/index-3mtgcvkq.js.map +11 -0
- package/dist/index-4knb5vjm.js +90 -0
- package/dist/index-4knb5vjm.js.map +13 -0
- package/dist/{index-3g3ny01d.js → index-5nwwekk0.js} +4 -4
- package/dist/{index-3g3ny01d.js.map → index-5nwwekk0.js.map} +1 -1
- package/dist/index-5rm7dwq4.js +6 -0
- package/dist/index-5rm7dwq4.js.map +11 -0
- package/dist/index-79epttpm.js +6 -0
- package/dist/index-79epttpm.js.map +10 -0
- package/dist/{index-4cf6v9nb.js → index-7yk1zvds.js} +4 -4
- package/dist/{index-4cf6v9nb.js.map → index-7yk1zvds.js.map} +1 -1
- package/dist/index-81gb4ey4.js +6 -0
- package/dist/{index-4z7axw4r.js.map → index-81gb4ey4.js.map} +1 -1
- package/dist/index-8a5d8sfe.js +6 -0
- package/dist/{index-0d93hyfc.js.map → index-8a5d8sfe.js.map} +1 -1
- package/dist/index-a21zyy54.js +6 -0
- package/dist/index-a21zyy54.js.map +9 -0
- package/dist/index-b6da6c16.js +92 -0
- package/dist/index-b6da6c16.js.map +15 -0
- package/dist/index-byxrc961.js +903 -0
- package/dist/{index-tv4yv7d2.js.map → index-byxrc961.js.map} +16 -15
- package/dist/{index-ammv5st7.js → index-cgfg6t5a.js} +6 -6
- package/dist/{index-ammv5st7.js.map → index-cgfg6t5a.js.map} +1 -1
- package/dist/{index-s9mbq7h6.js → index-ehzwdnc3.js} +4 -4
- package/dist/{index-s9mbq7h6.js.map → index-ehzwdnc3.js.map} +1 -1
- package/dist/index-fzmmhmk2.js +7 -0
- package/dist/index-fzmmhmk2.js.map +11 -0
- package/dist/index-g3pk0kc0.js +6 -0
- package/dist/{index-9r0wyj6w.js.map → index-g3pk0kc0.js.map} +2 -2
- package/dist/index-h828nk24.js +153 -0
- package/dist/index-h828nk24.js.map +20 -0
- package/dist/{index-02dn6m2j.js → index-jq999vcw.js} +5 -5
- package/dist/{index-02dn6m2j.js.map → index-jq999vcw.js.map} +2 -2
- package/dist/index-k2aq5bg0.js +9 -0
- package/dist/{index-6p999cx4.js.map → index-k2aq5bg0.js.map} +4 -6
- package/dist/{index-cqqb6gaq.js → index-k3y8y3wj.js} +5 -5
- package/dist/{index-cqqb6gaq.js.map → index-k3y8y3wj.js.map} +1 -1
- package/dist/index-k59wwdgz.js +9 -0
- package/dist/{index-ff514z3y.js.map → index-k59wwdgz.js.map} +3 -5
- package/dist/index-nmnnwa02.js +6 -0
- package/dist/{index-6q4wf8e3.js.map → index-nmnnwa02.js.map} +1 -1
- package/dist/index-nn3tk25c.js +6 -0
- package/dist/{index-d4x6yvqh.js.map → index-nn3tk25c.js.map} +3 -4
- package/dist/index-q0hxh57v.js +126 -0
- package/dist/index-q0hxh57v.js.map +14 -0
- package/dist/index-srmhk9g5.js +11 -0
- package/dist/index-srmhk9g5.js.map +11 -0
- package/dist/index-swtyfhha.js +6 -0
- package/dist/{index-fex44816.js.map → index-swtyfhha.js.map} +2 -2
- package/dist/index-whq42sat.js +6 -0
- package/dist/{index-h9mw7b9d.js.map → index-whq42sat.js.map} +1 -1
- package/dist/{index-j7gyr5nx.js → index-wzsmh5j0.js} +7 -7
- package/dist/{index-j7gyr5nx.js.map → index-wzsmh5j0.js.map} +1 -1
- package/dist/{index-j55s3ehk.js → index-x7v1zq89.js} +7 -7
- package/dist/{index-j55s3ehk.js.map → index-x7v1zq89.js.map} +2 -2
- package/dist/index-xhzmv4dh.js +66 -0
- package/dist/index-xhzmv4dh.js.map +12 -0
- package/dist/index-xmv47vs0.js +6 -0
- package/dist/{index-gz9x25tz.js.map → index-xmv47vs0.js.map} +2 -2
- package/dist/index-y4c32wn7.js +6 -0
- package/dist/{index-qdbq8crg.js.map → index-y4c32wn7.js.map} +2 -2
- package/dist/index-yjcdp72k.js +6 -0
- package/dist/{index-tf71ap9v.js.map → index-yjcdp72k.js.map} +1 -1
- package/dist/index-zn24991r.js +6 -0
- package/dist/index-zn24991r.js.map +10 -0
- package/dist/index.js +374 -443
- package/dist/index.js.map +23 -27
- package/dist/init.d.ts.map +1 -1
- package/dist/lib/channel-actions.d.ts +103 -0
- package/dist/lib/channel-actions.d.ts.map +1 -0
- package/dist/lib/chat-frame.d.ts +12 -1
- package/dist/lib/chat-frame.d.ts.map +1 -1
- package/dist/lib/commands.d.ts +13 -0
- package/dist/lib/commands.d.ts.map +1 -1
- package/dist/lib/const.d.ts +1 -1
- package/dist/lib/host-actions.d.ts +121 -0
- package/dist/lib/host-actions.d.ts.map +1 -0
- package/dist/lib/init-flow.d.ts +32 -0
- package/dist/lib/init-flow.d.ts.map +1 -1
- package/dist/lib/init-whatsapp.d.ts +52 -0
- package/dist/lib/init-whatsapp.d.ts.map +1 -0
- package/dist/lib/plugin-install.d.ts +120 -0
- package/dist/lib/plugin-install.d.ts.map +1 -0
- package/dist/lib/providers.d.ts.map +1 -1
- package/dist/lib/provision.d.ts.map +1 -1
- package/dist/lib/readme-table.d.ts +15 -0
- package/dist/lib/readme-table.d.ts.map +1 -0
- package/dist/lib/sandbox.d.ts +15 -0
- package/dist/lib/sandbox.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +34 -1
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/subcommand.d.ts.map +1 -1
- package/dist/lib/web-url.d.ts +15 -0
- package/dist/lib/web-url.d.ts.map +1 -0
- package/dist/lib/wizard.d.ts.map +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/plugins.d.ts +27 -8
- package/dist/plugins.d.ts.map +1 -1
- package/dist/restart.d.ts +21 -0
- package/dist/restart.d.ts.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/schedules.d.ts.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/sessions.d.ts.map +1 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/status.d.ts +16 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/web-923c7f5e.js +14 -0
- package/dist/{web-vkb16r62.js.map → web-923c7f5e.js.map} +3 -3
- package/dist/web.d.ts +2 -13
- package/dist/web.d.ts.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/wrapper-0w9b3my0.js +11 -0
- package/dist/wrapper-0w9b3my0.js.map +23 -0
- package/package.json +6 -3
- package/dist/App-b1yrwrcq.js +0 -11
- package/dist/ConfigEditor-n8hdw6r7.js +0 -6
- package/dist/KeyProbe-9jjeze5r.js +0 -5
- package/dist/Picker-hfeh1g6m.js +0 -5
- package/dist/SessionPicker-zyqkg4dn.js +0 -5
- package/dist/SkillBrowser-3qdp8080.js +0 -5
- package/dist/WizardApp-vzpbydy3.js +0 -5
- package/dist/config-g7za9x13.js +0 -24
- package/dist/index-0d93hyfc.js +0 -6
- package/dist/index-1c5113t4.js +0 -66
- package/dist/index-1c5113t4.js.map +0 -12
- package/dist/index-258d8bzg.js +0 -12
- package/dist/index-4z7axw4r.js +0 -6
- package/dist/index-6p999cx4.js +0 -9
- package/dist/index-6q4wf8e3.js +0 -6
- package/dist/index-9r0wyj6w.js +0 -6
- package/dist/index-d4x6yvqh.js +0 -6
- package/dist/index-fecm8xe7.js +0 -77
- package/dist/index-fecm8xe7.js.map +0 -12
- package/dist/index-fex44816.js +0 -6
- package/dist/index-ff514z3y.js +0 -14
- package/dist/index-gz9x25tz.js +0 -6
- package/dist/index-h9mw7b9d.js +0 -6
- package/dist/index-hwpvhaza.js +0 -6
- package/dist/index-mtn0g9vc.js +0 -7
- package/dist/index-mtn0g9vc.js.map +0 -11
- package/dist/index-qdbq8crg.js +0 -6
- package/dist/index-tf71ap9v.js +0 -6
- package/dist/index-ttwyrdjs.js +0 -427
- package/dist/index-ttwyrdjs.js.map +0 -11
- package/dist/index-tv4yv7d2.js +0 -903
- package/dist/index-ty24n0jh.js +0 -167
- package/dist/index-ty24n0jh.js.map +0 -19
- package/dist/index-v8e92nfw.js +0 -6
- package/dist/index-vgc3y3rm.js +0 -6
- package/dist/index-whaw4b18.js +0 -6
- package/dist/index-whaw4b18.js.map +0 -10
- package/dist/web-vkb16r62.js +0 -14
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{e,
|
|
2
|
+
import{e,Tn}from"./index-byxrc961.js";import"./index-3mtgcvkq.js";import"./index-79epttpm.js";import{le}from"./index-0k3w2mxf.js";import{oe,fe,YA,Bt}from"./index-y4c32wn7.js";import"./index-fzmmhmk2.js";function g(n){let t=/^(\d+)\s*(s|m|h|d)?$/.exec(n.trim());if(t===null)throw new le({code:"credential_usage",message:`--expires ${JSON.stringify(n)} is not a duration.`,hint:"Write it as 30s, 15m, 2h or 7d — or as a plain number of seconds."});let i=Number(t[1]);if(i===0)throw new le({code:"credential_usage",message:"--expires 0 would mint a credential that has already expired.",hint:"Leave the flag off for a key that never expires, or give it a real duration like 1h."});let s={s:1,m:60,h:3600,d:86400}[t[2]??"s"]??1;return i*s}function y(n){let t=n.split(",").map((s)=>s.trim().toLowerCase()).filter((s)=>s!==""),i=t.filter((s)=>!Tn.includes(s));if(i.length>0)throw new le({code:"credential_usage",message:`--can names ${i.map((s)=>JSON.stringify(s)).join(", ")}, which is not a capability.`,hint:`The four are: ${Tn.join(", ")}. read is every GET; chat sends a message, answers an approval and stops a turn; write covers schedules, phase and clearing a session; admin covers credentials, provisioning and start/stop.`});return t}function f(n){return n.split(",").map((t)=>t.trim()).filter((t)=>t!=="")}function l(n){let t=[];if(t.push(n.scope?.agents===void 0?"every agent":n.scope.agents.join(", ")),n.scope?.sessions!==void 0)t.push(`sessions ${n.scope.sessions}`);if(t.push(n.scope?.can===void 0?"all capabilities":n.scope.can.join("+")),n.expiresAt!==void 0)t.push(`until ${n.expiresAt}`);return t.join(" · ")}async function d(n){let t=await oe(n);if(t===void 0)throw new le({code:"credential_usage",message:"No server is running, so there is nothing to mint a credential on.",hint:`A credential belongs to a server rather than to a file, so this command is an API client. Start one with \`${e.slug} serve\`, or use POST /v1/keys directly against a server you can already reach.`});return{lease:t,manifest:Bt(t.agentId)}}async function v(n){if(n.action==="create")return await h(n);if(n.action==="list")return await p(n);if(n.action==="revoke")return await m(n);throw new le({code:"credential_usage",message:`Unknown action ${JSON.stringify(n.action)}.`,hint:"The actions are create, list and revoke."})}async function h(n){let t=n.label?.trim();if(t===void 0||t==="")throw new le({code:"credential_usage",message:"--label is required.",hint:'A label is the only thing distinguishing two credentials in a listing, and "key 2" is a name nobody can act on when deciding which to revoke.'});let i={...n.agents===void 0?{}:{agents:f(n.agents)},...n.sessions===void 0?{}:{sessions:n.sessions},...n.can===void 0?{}:{can:y(n.can)},...n.expires===void 0?{}:{expiresIn:g(n.expires)}},{lease:s,manifest:o}=await d(n.store),a=await fe(s,"/v1/keys",{label:t,...Object.keys(i).length===0?{}:{scope:i}},o);if(!a.ok)return c(a,"mint a credential");let r=a.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(r,null,2)}
|
|
3
3
|
`),0;return process.stdout.write(`${r.secret}
|
|
4
4
|
`),process.stderr.write(` ${r.label} · ${r.keyId}
|
|
5
5
|
`),process.stderr.write(` reaches ${l(r)}
|
|
6
6
|
`),process.stderr.write(` This is the only time the secret is shown. It is stored as a fingerprint and no route returns it.
|
|
7
|
-
`),0}async function p(n){let{lease:t,manifest:i}=await d(n.store),s=await
|
|
7
|
+
`),0}async function p(n){let{lease:t,manifest:i}=await d(n.store),s=await YA(t,"GET","/v1/keys",i);if(!s.ok)return c(s,"list credentials");let o=s.body,a=o.keys??[];if(n.json===!0)return process.stdout.write(`${JSON.stringify(o,null,2)}
|
|
8
8
|
`),0;if(a.length===0)return process.stdout.write(`No credentials. The server token is the only way in.
|
|
9
9
|
`),0;for(let r of a){let u=r.revokedAt===void 0?"live":"revoked";process.stdout.write(`${r.keyId} ${u.padEnd(7)} ${r.label}
|
|
10
10
|
`),process.stdout.write(` reaches ${l(r)}
|
|
11
11
|
`),process.stdout.write(` created ${r.createdAt}${r.lastUsedAt===void 0?" · never used":` · last used ${r.lastUsedAt}`}
|
|
12
|
-
`)}return 0}async function m(n){let t=n.keyId?.trim();if(t===void 0||t==="")throw new
|
|
12
|
+
`)}return 0}async function m(n){let t=n.keyId?.trim();if(t===void 0||t==="")throw new le({code:"credential_usage",message:"Which credential?",hint:`\`${e.slug} credential list\` prints the ids. Revoking is permanent — a revoked secret can never be re-presented.`});let{lease:i,manifest:s}=await d(n.store),o=await YA(i,"DELETE",`/v1/keys/${encodeURIComponent(t)}`,s);if(!o.ok)return c(o,"revoke that credential");let a=o.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(a,null,2)}
|
|
13
13
|
`),0;return process.stdout.write(`revoked ${a.keyId} · ${a.label}
|
|
14
14
|
`),0}function c(n,t){if(process.stderr.write(`Could not ${t}${n.status===0?"":` (${n.status})`}: ${n.detail??"the host did not answer"}
|
|
15
15
|
`),n.hint!==void 0)process.stderr.write(` hint: ${n.hint}
|
|
16
16
|
`);return 1}export{v as credentialCommand};
|
|
17
17
|
|
|
18
|
-
//# debugId=
|
|
19
|
-
//# sourceMappingURL=credential-
|
|
18
|
+
//# debugId=23A49E882CF7D41564756E2164756E21
|
|
19
|
+
//# sourceMappingURL=credential-2sj7vsmw.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Operator credentials from a terminal: mint one, list them, revoke one.\n *\n * ## Why this is not called `keys`\n *\n * The `keys` command already exists and prints the bytes a terminal sends for a chord — a keyboard\n * diagnostic, nothing to do with credentials. Two unrelated meanings under one verb is the kind of\n * collision that costs somebody a confused minute every time they reach for either, so the new\n * surface takes the word the code and the spec already use for the thing: a **credential**.\n * `token` was the other candidate and loses to `server.tokenEnv`, which is a different credential\n * this command cannot mint or revoke.\n *\n * ## Why it talks to a running server rather than the store\n *\n * A key is a fingerprint in the shared store, so writing one directly would work — and would\n * bypass every check `POST /v1/keys` performs: the label rule, the scope validation, and the\n * refusal of a scope naming an agent that does not exist. That is the *\"a check only one surface\n * performs is a check the two disagree about\"* shape, on the surface where disagreeing means a\n * credential that the API would never have issued. So this is an HTTP client, and it says so when\n * there is no server to talk to.\n */\n\nimport { BRAND, CAPABILITIES, type Capability } from \"@dispach/core\"\nimport { UsageError } from \"#lib/args\"\nimport { anyLiveHost, callHost, manifestForId, postToHost } from \"#lib/lifecycle\"\n\nexport interface CredentialOptions {\n readonly action: string\n readonly keyId?: string\n readonly label?: string\n readonly agents?: string\n readonly sessions?: string\n readonly can?: string\n readonly expires?: string\n readonly json?: boolean\n readonly store?: string\n}\n\n/**\n * `1h`, `30m`, `7d`, `90s`, or plain seconds — into whole seconds.\n *\n * A suffix because \"how long should this credential live\" is a question people answer in hours and\n * days, and `3600` is a number somebody has to compute and can get wrong by a factor of sixty. Bare\n * digits stay accepted, since that is what the wire takes and a script already has the number.\n */\nexport function parseDuration(raw: string): number {\n const match = /^(\\d+)\\s*(s|m|h|d)?$/.exec(raw.trim())\n if (match === null) {\n throw new UsageError({\n code: \"credential_usage\",\n message: `--expires ${JSON.stringify(raw)} is not a duration.`,\n hint: \"Write it as 30s, 15m, 2h or 7d — or as a plain number of seconds.\",\n })\n }\n const value = Number(match[1])\n if (value === 0) {\n throw new UsageError({\n code: \"credential_usage\",\n message: \"--expires 0 would mint a credential that has already expired.\",\n hint: \"Leave the flag off for a key that never expires, or give it a real duration like 1h.\",\n })\n }\n const unit = { s: 1, m: 60, h: 3600, d: 86_400 }[match[2] ?? \"s\"] ?? 1\n return value * unit\n}\n\n/** `chat,read` → the capabilities, refusing anything that is not one rather than dropping it. */\nexport function parseCapabilities(raw: string): readonly Capability[] {\n const names = raw\n .split(\",\")\n .map((entry) => entry.trim().toLowerCase())\n .filter((entry) => entry !== \"\")\n const unknown = names.filter((name) => !(CAPABILITIES as readonly string[]).includes(name))\n if (unknown.length > 0) {\n throw new UsageError({\n code: \"credential_usage\",\n message: `--can names ${unknown.map((name) => JSON.stringify(name)).join(\", \")}, which is not a capability.`,\n hint: `The four are: ${CAPABILITIES.join(\", \")}. read is every GET; chat sends a message, answers an approval and stops a turn; write covers schedules, phase and clearing a session; admin covers credentials, provisioning and start/stop.`,\n })\n }\n // An empty list is *not* silently promoted to \"everything\": `--can \"\"` is a key that may do\n // nothing, which is a coherent thing to ask for and a confusing thing to be given instead.\n return names as readonly Capability[]\n}\n\n/** A comma list into ids, with the empty entries dropped rather than sent as `\"\"`. */\nfunction parseList(raw: string): readonly string[] {\n return raw\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry !== \"\")\n}\n\ninterface KeyLike {\n readonly keyId: string\n readonly label: string\n readonly createdAt: string\n readonly lastUsedAt?: string\n readonly revokedAt?: string\n readonly expiresAt?: string\n readonly scope?: {\n readonly agents?: readonly string[]\n readonly sessions?: string\n readonly can?: readonly string[]\n }\n}\n\n/**\n * One line describing what a key reaches, for a listing.\n *\n * **Printed back after minting too**, which is the half that matters: a prefix is not a namespace —\n * `team_4` also matches `team_42:x` — so showing what the scope *says* at the moment it is created\n * is the only cheap place to notice that it says something other than what was meant. The same\n * argument `telegramHandle` makes about a username that cannot exist.\n */\nexport function describeScope(key: KeyLike): string {\n const parts: string[] = []\n parts.push(key.scope?.agents === undefined ? \"every agent\" : key.scope.agents.join(\", \"))\n if (key.scope?.sessions !== undefined) parts.push(`sessions ${key.scope.sessions}`)\n parts.push(key.scope?.can === undefined ? \"all capabilities\" : key.scope.can.join(\"+\"))\n if (key.expiresAt !== undefined) parts.push(`until ${key.expiresAt}`)\n return parts.join(\" · \")\n}\n\n/** The host to ask, or a refusal naming why there is none. */\nasync function host(store?: string) {\n const lease = await anyLiveHost(store)\n if (lease === undefined) {\n throw new UsageError({\n code: \"credential_usage\",\n message: \"No server is running, so there is nothing to mint a credential on.\",\n hint: `A credential belongs to a server rather than to a file, so this command is an API client. Start one with \\`${BRAND.slug} serve\\`, or use POST /v1/keys directly against a server you can already reach.`,\n })\n }\n return { lease, manifest: manifestForId(lease.agentId) }\n}\n\nexport async function credentialCommand(options: CredentialOptions): Promise<number> {\n if (options.action === \"create\") return await create(options)\n if (options.action === \"list\") return await list(options)\n if (options.action === \"revoke\") return await revoke(options)\n throw new UsageError({\n code: \"credential_usage\",\n message: `Unknown action ${JSON.stringify(options.action)}.`,\n hint: \"The actions are create, list and revoke.\",\n })\n}\n\nasync function create(options: CredentialOptions): Promise<number> {\n const label = options.label?.trim()\n if (label === undefined || label === \"\") {\n throw new UsageError({\n code: \"credential_usage\",\n message: \"--label is required.\",\n hint: 'A label is the only thing distinguishing two credentials in a listing, and \"key 2\" is a name nobody can act on when deciding which to revoke.',\n })\n }\n const scope = {\n ...(options.agents === undefined ? {} : { agents: parseList(options.agents) }),\n ...(options.sessions === undefined ? {} : { sessions: options.sessions }),\n ...(options.can === undefined ? {} : { can: parseCapabilities(options.can) }),\n ...(options.expires === undefined ? {} : { expiresIn: parseDuration(options.expires) }),\n }\n\n const { lease, manifest } = await host(options.store)\n const reply = await postToHost(\n lease,\n \"/v1/keys\",\n { label, ...(Object.keys(scope).length === 0 ? {} : { scope }) },\n manifest,\n )\n if (!reply.ok) return refused(reply, \"mint a credential\")\n\n const key = reply.body as KeyLike & { readonly secret: string }\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify(key, null, 2)}\\n`)\n return 0\n }\n /**\n * The secret, on its own line, **once**.\n *\n * It is not stored anywhere in a readable form and no route returns it again, so this is the\n * only moment it exists outside the caller's memory. Printed bare rather than inside a sentence\n * so that copying the line copies the credential and nothing else.\n */\n process.stdout.write(`${key.secret}\\n`)\n process.stderr.write(` ${key.label} · ${key.keyId}\\n`)\n process.stderr.write(` reaches ${describeScope(key)}\\n`)\n process.stderr.write(\n \" This is the only time the secret is shown. It is stored as a fingerprint and no route returns it.\\n\",\n )\n return 0\n}\n\nasync function list(options: CredentialOptions): Promise<number> {\n const { lease, manifest } = await host(options.store)\n const reply = await callHost(lease, \"GET\", \"/v1/keys\", manifest)\n if (!reply.ok) return refused(reply, \"list credentials\")\n\n const body = reply.body as { readonly keys?: readonly KeyLike[]; readonly scope?: string }\n const keys = body.keys ?? []\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify(body, null, 2)}\\n`)\n return 0\n }\n if (keys.length === 0) {\n process.stdout.write(\"No credentials. The server token is the only way in.\\n\")\n return 0\n }\n for (const key of keys) {\n // Revoked ones are shown rather than hidden, the same as the API's listing: the row is the\n // only record a credential ever existed, and hiding it makes a revocation unverifiable.\n const state = key.revokedAt === undefined ? \"live\" : \"revoked\"\n process.stdout.write(`${key.keyId} ${state.padEnd(7)} ${key.label}\\n`)\n process.stdout.write(` reaches ${describeScope(key)}\\n`)\n process.stdout.write(\n ` created ${key.createdAt}${key.lastUsedAt === undefined ? \" · never used\" : ` · last used ${key.lastUsedAt}`}\\n`,\n )\n }\n return 0\n}\n\nasync function revoke(options: CredentialOptions): Promise<number> {\n const keyId = options.keyId?.trim()\n if (keyId === undefined || keyId === \"\") {\n throw new UsageError({\n code: \"credential_usage\",\n message: \"Which credential?\",\n hint: `\\`${BRAND.slug} credential list\\` prints the ids. Revoking is permanent — a revoked secret can never be re-presented.`,\n })\n }\n const { lease, manifest } = await host(options.store)\n const reply = await callHost(lease, \"DELETE\", `/v1/keys/${encodeURIComponent(keyId)}`, manifest)\n if (!reply.ok) return refused(reply, \"revoke that credential\")\n const key = reply.body as KeyLike\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify(key, null, 2)}\\n`)\n return 0\n }\n process.stdout.write(`revoked ${key.keyId} · ${key.label}\\n`)\n return 0\n}\n\n/** The server's own words, not a paraphrase — it knows why far better than this command does. */\nfunction refused(reply: { status: number; detail?: string; hint?: string }, what: string): number {\n process.stderr.write(\n `Could not ${what}${reply.status === 0 ? \"\" : ` (${reply.status})`}: ${reply.detail ?? \"the host did not answer\"}\\n`,\n )\n if (reply.hint !== undefined) process.stderr.write(` hint: ${reply.hint}\\n`)\n return 1\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";2MA6CO,SAAS,CAAa,CAAC,EAAqB,CAC/C,IAAM,EAAQ,uBAAuB,KAAK,EAAI,KAAK,CAAC,EACpD,GAAI,IAAU,KACV,MAAM,IAAI,GAAW,CACjB,KAAM,mBACN,QAAS,aAAa,KAAK,UAAU,CAAG,uBACxC,KAAM,mEACV,CAAC,EAEL,IAAM,EAAQ,OAAO,EAAM,EAAE,EAC7B,GAAI,IAAU,EACV,MAAM,IAAI,GAAW,CACjB,KAAM,mBACN,QAAS,gEACT,KAAM,sFACV,CAAC,EAEL,IAAM,EAAO,CAAE,EAAG,EAAG,EAAG,GAAI,EAAG,KAAM,EAAG,KAAO,EAAE,EAAM,IAAM,MAAQ,EACrE,OAAO,EAAQ,EAIZ,SAAS,CAAiB,CAAC,EAAoC,CAClE,IAAM,EAAQ,EACT,MAAM,GAAG,EACT,IAAI,CAAC,IAAU,EAAM,KAAK,EAAE,YAAY,CAAC,EACzC,OAAO,CAAC,IAAU,IAAU,EAAE,EAC7B,EAAU,EAAM,OAAO,CAAC,IAAS,CAAE,GAAmC,SAAS,CAAI,CAAC,EAC1F,GAAI,EAAQ,OAAS,EACjB,MAAM,IAAI,GAAW,CACjB,KAAM,mBACN,QAAS,eAAe,EAAQ,IAAI,CAAC,IAAS,KAAK,UAAU,CAAI,CAAC,EAAE,KAAK,IAAI,gCAC7E,KAAM,iBAAiB,GAAa,KAAK,IAAI,gMACjD,CAAC,EAIL,OAAO,EAIX,SAAS,CAAS,CAAC,EAAgC,CAC/C,OAAO,EACF,MAAM,GAAG,EACT,IAAI,CAAC,IAAU,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O,MAAM,eAAe,uBAAiB,CAAA;AAC7C,eAAO,MAAM,YAAY,cAAQ,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{e,A}from"./index-byxrc961.js";import{HA,Ie,BA,xA,Uo}from"./index-79epttpm.js";class le extends A{static ERROR_NAME="UsageError"}function S(n,i){let t=Array.from({length:i.length+1},(o,g)=>g);for(let o=1;o<=n.length;o+=1){let g=[o];for(let l=1;l<=i.length;l+=1){let f=(t[l-1]??0)+(n[o-1]===i[l-1]?0:1),d=(g[l-1]??0)+1,_=(t[l]??0)+1;g.push(Math.min(f,d,_))}t=g}return t[i.length]??Math.max(n.length,i.length)}function M(n,i){let t,o=Number.POSITIVE_INFINITY;for(let g of i){let l=S(n,g);if(l<o)o=l,t=g}return t!==void 0&&o<=Math.max(2,Math.floor(n.length/3))?t:void 0}class R{#e;#t;constructor(n,i){this.#e=n,this.#t=i}#n(n,i){let t=this.#t.get(n);if(t===void 0)throw new le({code:"cli_flag_not_declared",message:`No flag "${n}" is declared for this command.`,hint:"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader."});if(t.kind!==i)throw new le({code:"cli_flag_kind_mismatch",message:`Flag "${n}" is declared as ${t.kind} but was read as ${i}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(n)}str(n){let i=this.#n(n,"string");return typeof i==="string"?i:void 0}num(n){let i=this.#n(n,"number");return typeof i==="number"?i:void 0}bool(n){return this.#n(n,"boolean")===!0}has(n){return this.#e.has(n)}}function c(n,i,t,o){return o===void 0?{code:n,message:i,hint:t}:{code:n,message:i,hint:t,field:o}}function y(n){let i=n[0];return new le({code:"cli_usage",message:n.length===1&&i!==void 0?i.message:`${n.length} problems with the command line.`,hint:n.length===1&&i!==void 0?i.hint:"Each problem below names the flag and its fix.",...i?.field===void 0?{}:{field:i.field},details:n})}function D(n,i,t){let o=Number(i);if(i.trim()===""||!Number.isFinite(o))return c("cli_flag_not_a_number",`${t} expects a number, got ${JSON.stringify(i)}.`,`Pass a number, as in ${t} 50. The old parser silently used the default here, which made a typo look like it worked.`,t);if(n.integer===!0&&!Number.isInteger(o))return c("cli_flag_not_an_integer",`${t} expects a whole number, got ${i}.`,`Drop the fractional part: ${t} ${Math.trunc(o)}.`,t);if(n.min!==void 0&&o<n.min)return c("cli_flag_below_min",`${t} must be at least ${n.min}, got ${o}.`,`Pass ${n.min} or more.`,t);return o}function Po(n){let i=n[0];if(i===void 0)return{kind:"usage"};if(i.startsWith("-")){let s=new Set(HA.flatMap((a)=>a.short===void 0?[`--${a.name}`]:[`--${a.name}`,`-${a.short}`])),r=n.filter((a)=>!s.has(a));if(r.length>0)throw y([c("cli_no_command","No command given.",`Run \`${e.slug} --help\` for the command list. Commands are ${Ie.map((a)=>a.name).join(", ")}.`,r[0])]);if(n.includes("--version")||n.includes("-v"))return{kind:"version"};if(n.includes("--help")||n.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let t=BA(i);if(t===void 0){let s=M(i,Ie.map((r)=>r.name));throw y([c("cli_unknown_command",`Unknown command "${i}".`,s===void 0?`Run \`${e.slug} --help\` for the command list.`:`Did you mean "${s}"? Run \`${e.slug} --help\` for the full list.`,i)])}let o=new Map(xA(t).map((s)=>[s.name,s])),g=new Map(xA(t).filter((s)=>s.short!==void 0).map((s)=>[s.short,s])),l=new Map,f=[],d=[],_=!1,w=(s,r,a)=>{if(r===""){d.push(c("cli_flag_empty_value",`${a} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",a));return}if(s.kind==="number"){let u=D(s,r,a);if(typeof u==="number")l.set(s.name,u);else d.push(u);return}l.set(s.name,r)};for(let s=1;s<n.length;s+=1){let r=n[s];if(r===void 0)continue;if(_){f.push(r);continue}if(r==="--"){_=!0;continue}if(r.startsWith("--")){let a=r.slice(2),u=a.indexOf("="),m=u===-1?a:a.slice(0,u),h=o.get(m);if(h===void 0){let k=Uo(m,t.name),x=M(m,[...o.keys()]);d.push(c(k.length>0?"cli_flag_wrong_command":"cli_unknown_flag",k.length>0?`${t.name} does not accept --${m}.`:`Unknown flag --${m}.`,k.length>0?`--${m} is accepted by: ${k.join(", ")}.`:x===void 0?`Run \`${e.slug} ${t.name} --help\` for the flags this command accepts.`:`Did you mean --${x}?`,`--${m}`));continue}let p=`--${m}`;if(h.kind==="boolean"){if(u!==-1){d.push(c("cli_flag_takes_no_value",`${p} is a switch and takes no value.`,`Drop the "=${a.slice(u+1)}" — pass ${p} on its own.`,p));continue}l.set(h.name,!0);continue}if(u!==-1){w(h,a.slice(u+1),p);continue}let b=n[s+1];if(h.bare!==void 0&&(b===void 0||b.startsWith("-"))){l.set(h.name,h.bare);continue}if(b===void 0){d.push(c("cli_flag_needs_value",`${p} needs a value.`,`Pass one, as in ${p} <${h.placeholder??"value"}>.`,p));continue}w(h,b,p),s+=1;continue}if(r.startsWith("-")&&r.length>1){for(let a of[...r.slice(1)]){let u=g.get(a);if(u===void 0){d.push(c("cli_unknown_flag",`Unknown flag -${a}.`,`Run \`${e.slug} ${t.name} --help\` for the flags this command accepts.`,`-${a}`));continue}if(u.kind!=="boolean"){d.push(c("cli_short_flag_needs_value",`-${a} takes a value and cannot be bundled.`,`Write it on its own: --${u.name} <${u.placeholder??"value"}>.`,`-${a}`));continue}l.set(u.name,!0)}continue}f.push(r)}let v=new R(l,o);if(v.bool("help"))return{kind:"help",command:t};if(v.bool("version"))return{kind:"version"};let N=t.args.some((s)=>s.variadic===!0),F=t.args.filter((s)=>s.required);if(d.length>0)throw y(d);else if(f.length<F.length){let s=F[f.length];d.push(c("cli_missing_argument",`${t.name} needs ${s===void 0?"another argument":`a ${s.name}`}.`,`Usage: ${e.slug} ${t.name} ${t.args.map((r)=>`<${r.name}${r.variadic===!0?"...":""}>`).join(" ")}`))}else if(!N&&f.length>t.args.length){let s=f.slice(t.args.length);d.push(c("cli_unexpected_argument",`${t.name} takes ${t.args.length} argument(s), got ${f.length}.`,t.unexpectedArgHint??`Unexpected: ${s.join(" ")}. Quote a value containing spaces.`))}if(d.length>0)throw y(d);return{kind:"command",parsed:{command:t,positionals:f,flags:v}}}
|
|
3
|
+
export{le,Po};
|
|
4
|
+
|
|
5
|
+
//# debugId=705CE8F8B1BD93E464756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-0k3w2mxf.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The argument parser. Pure — argv in, a decision out, no I/O and no `process`.\n *\n * It replaces a parser that failed silently in four distinct ways, each of which is now a test:\n *\n * - **A value beginning with `-` was swallowed.** The old rule was \"consume the next token unless\n * it looks like a flag\", so `--input \"-5 degrees\"` set `input` to boolean `true`, the caller's\n * `typeof input === \"string\"` check failed, and the process opened an interactive session instead\n * of running the one turn it was asked for. The rule here has no such hole: whether a flag\n * consumes the next token is a property of the *flag*, declared in `commands.ts`, never a guess\n * about the value.\n * - **Unknown flags were ignored.** `--sesion local:x` ran against the default session silently.\n * - **A non-numeric `--limit` fell back to the default.**\n * - **`--help` with no command exited 1**, reporting failure for the one thing that had succeeded.\n *\n * Every problem found is collected rather than thrown on sight, so a line with two mistakes reports\n * both. `HarnessError.details` already renders that shape.\n */\n\nimport { BRAND, type ErrorDetail, HarnessError } from \"@dispach/core\"\nimport { COMMANDS, commandsAccepting, findCommand, flagsFor, GLOBAL_FLAGS } from \"#lib/commands\"\nimport type { FlagSpec, FlagValue, FlagValues, ParseResult } from \"#lib/schema\"\n\n/** Anything wrong with the command line itself. Distinct from anything wrong with a manifest. */\nexport class UsageError extends HarnessError {\n static override readonly ERROR_NAME = \"UsageError\"\n}\n\n// ─── nearest match ───────────────────────────────────────────────────────────────────────\n\nfunction distance(a: string, b: string): number {\n // Two rows rather than a full matrix; the strings here are flag names.\n let previous = Array.from({ length: b.length + 1 }, (_, i) => i)\n for (let i = 1; i <= a.length; i += 1) {\n const current = [i]\n for (let j = 1; j <= b.length; j += 1) {\n const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1)\n const insertion = (current[j - 1] ?? 0) + 1\n const deletion = (previous[j] ?? 0) + 1\n current.push(Math.min(substitution, insertion, deletion))\n }\n previous = current\n }\n return previous[b.length] ?? Math.max(a.length, b.length)\n}\n\nfunction nearest(word: string, candidates: readonly string[]): string | undefined {\n let best: string | undefined\n let bestScore = Number.POSITIVE_INFINITY\n for (const candidate of candidates) {\n const score = distance(word, candidate)\n if (score < bestScore) {\n bestScore = score\n best = candidate\n }\n }\n // A suggestion has to be plausible. Beyond a third of the word it is noise, and noise in an\n // error message is worse than no suggestion at all.\n return best !== undefined && bestScore <= Math.max(2, Math.floor(word.length / 3))\n ? best\n : undefined\n}\n\n// ─── flag values ─────────────────────────────────────────────────────────────────────────\n\nclass Values implements FlagValues {\n readonly #values: ReadonlyMap<string, FlagValue>\n readonly #specs: ReadonlyMap<string, FlagSpec>\n\n constructor(values: ReadonlyMap<string, FlagValue>, specs: ReadonlyMap<string, FlagSpec>) {\n this.#values = values\n this.#specs = specs\n }\n\n #expect(name: string, kind: FlagSpec[\"kind\"]): FlagValue | undefined {\n const spec = this.#specs.get(name)\n if (spec === undefined) {\n throw new UsageError({\n code: \"cli_flag_not_declared\",\n message: `No flag \"${name}\" is declared for this command.`,\n hint: \"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader.\",\n })\n }\n if (spec.kind !== kind) {\n throw new UsageError({\n code: \"cli_flag_kind_mismatch\",\n message: `Flag \"${name}\" is declared as ${spec.kind} but was read as ${kind}.`,\n hint: \"This is a bug in the CLI. The reader and lib/commands.ts disagree.\",\n })\n }\n return this.#values.get(name)\n }\n\n str(name: string): string | undefined {\n const value = this.#expect(name, \"string\")\n return typeof value === \"string\" ? value : undefined\n }\n\n num(name: string): number | undefined {\n const value = this.#expect(name, \"number\")\n return typeof value === \"number\" ? value : undefined\n }\n\n bool(name: string): boolean {\n return this.#expect(name, \"boolean\") === true\n }\n\n has(name: string): boolean {\n return this.#values.has(name)\n }\n}\n\n// ─── parse ───────────────────────────────────────────────────────────────────────────────\n\nfunction detail(code: string, message: string, hint: string, field?: string): ErrorDetail {\n return field === undefined ? { code, message, hint } : { code, message, hint, field }\n}\n\nfunction usage(details: ErrorDetail[]): UsageError {\n const first = details[0]\n return new UsageError({\n code: \"cli_usage\",\n message:\n details.length === 1 && first !== undefined\n ? first.message\n : `${details.length} problems with the command line.`,\n hint:\n details.length === 1 && first !== undefined\n ? first.hint\n : \"Each problem below names the flag and its fix.\",\n ...(first?.field === undefined ? {} : { field: first.field }),\n details,\n })\n}\n\nfunction readNumber(spec: FlagSpec, raw: string, written: string): number | ErrorDetail {\n const value = Number(raw)\n if (raw.trim() === \"\" || !Number.isFinite(value)) {\n return detail(\n \"cli_flag_not_a_number\",\n `${written} expects a number, got ${JSON.stringify(raw)}.`,\n `Pass a number, as in ${written} 50. The old parser silently used the default here, which made a typo look like it worked.`,\n written,\n )\n }\n if (spec.integer === true && !Number.isInteger(value)) {\n return detail(\n \"cli_flag_not_an_integer\",\n `${written} expects a whole number, got ${raw}.`,\n `Drop the fractional part: ${written} ${Math.trunc(value)}.`,\n written,\n )\n }\n if (spec.min !== undefined && value < spec.min) {\n return detail(\n \"cli_flag_below_min\",\n `${written} must be at least ${spec.min}, got ${value}.`,\n `Pass ${spec.min} or more.`,\n written,\n )\n }\n return value\n}\n\n/**\n * `argv` is everything after the program name.\n *\n * The command comes first, before any flag, as with git and docker. That ordering is what makes the\n * parse unambiguous: flag semantics depend on the command's spec, so the command has to be known\n * before a single flag can be interpreted.\n */\nexport function parse(argv: readonly string[]): ParseResult {\n const head = argv[0]\n\n if (head === undefined) return { kind: \"usage\" }\n\n if (head.startsWith(\"-\")) {\n // No command. Only the global flags can appear here, and only two of them do anything.\n const globals = new Set(\n GLOBAL_FLAGS.flatMap((flag) =>\n flag.short === undefined\n ? [`--${flag.name}`]\n : [`--${flag.name}`, `-${flag.short}`],\n ),\n )\n const unknown = argv.filter((token) => !globals.has(token))\n if (unknown.length > 0) {\n throw usage([\n detail(\n \"cli_no_command\",\n \"No command given.\",\n `Run \\`${BRAND.slug} --help\\` for the command list. Commands are ${COMMANDS.map((c) => c.name).join(\", \")}.`,\n unknown[0],\n ),\n ])\n }\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) return { kind: \"version\" }\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { kind: \"help\", command: undefined }\n }\n return { kind: \"usage\" }\n }\n\n const command = findCommand(head)\n if (command === undefined) {\n const suggestion = nearest(\n head,\n COMMANDS.map((c) => c.name),\n )\n throw usage([\n detail(\n \"cli_unknown_command\",\n `Unknown command \"${head}\".`,\n suggestion === undefined\n ? `Run \\`${BRAND.slug} --help\\` for the command list.`\n : `Did you mean \"${suggestion}\"? Run \\`${BRAND.slug} --help\\` for the full list.`,\n head,\n ),\n ])\n }\n\n const specs = new Map(flagsFor(command).map((flag) => [flag.name, flag]))\n const shorts = new Map(\n flagsFor(command)\n .filter((flag) => flag.short !== undefined)\n .map((flag) => [flag.short as string, flag]),\n )\n\n const values = new Map<string, FlagValue>()\n const positionals: string[] = []\n const errors: ErrorDetail[] = []\n let terminated = false\n\n const setValue = (spec: FlagSpec, raw: string, written: string): void => {\n if (raw === \"\") {\n errors.push(\n detail(\n \"cli_flag_empty_value\",\n `${written} was given an empty value.`,\n \"Pass a value, or drop the flag entirely to use the default.\",\n written,\n ),\n )\n return\n }\n if (spec.kind === \"number\") {\n const result = readNumber(spec, raw, written)\n if (typeof result === \"number\") values.set(spec.name, result)\n else errors.push(result)\n return\n }\n values.set(spec.name, raw)\n }\n\n for (let i = 1; i < argv.length; i += 1) {\n const token = argv[i]\n if (token === undefined) continue\n\n if (terminated) {\n positionals.push(token)\n continue\n }\n if (token === \"--\") {\n terminated = true\n continue\n }\n\n if (token.startsWith(\"--\")) {\n const body = token.slice(2)\n const eq = body.indexOf(\"=\")\n const name = eq === -1 ? body : body.slice(0, eq)\n const spec = specs.get(name)\n\n if (spec === undefined) {\n const elsewhere = commandsAccepting(name, command.name)\n const suggestion = nearest(name, [...specs.keys()])\n errors.push(\n detail(\n elsewhere.length > 0 ? \"cli_flag_wrong_command\" : \"cli_unknown_flag\",\n elsewhere.length > 0\n ? `${command.name} does not accept --${name}.`\n : `Unknown flag --${name}.`,\n elsewhere.length > 0\n ? `--${name} is accepted by: ${elsewhere.join(\", \")}.`\n : suggestion === undefined\n ? `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`\n : `Did you mean --${suggestion}?`,\n `--${name}`,\n ),\n )\n continue\n }\n\n const written = `--${name}`\n\n if (spec.kind === \"boolean\") {\n if (eq !== -1) {\n errors.push(\n detail(\n \"cli_flag_takes_no_value\",\n `${written} is a switch and takes no value.`,\n `Drop the \"=${body.slice(eq + 1)}\" — pass ${written} on its own.`,\n written,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n continue\n }\n\n if (eq !== -1) {\n setValue(spec, body.slice(eq + 1), written)\n continue\n }\n\n // Consume the next token unconditionally. This is the fix for the swallowed-value bug:\n // whether a token is a value is decided by the spec, never by whether it starts with a\n // dash. `--input -5` means the text \"-5\".\n const next = argv[i + 1]\n // Unless the spec declares a bare form, in which case a missing token or one starting with a\n // dash means the flag was written on its own. Opt-in per flag, because the inversion is only\n // safe for a field whose values cannot start with a dash — see `FlagSpec.bare`.\n if (spec.bare !== undefined && (next === undefined || next.startsWith(\"-\"))) {\n values.set(spec.name, spec.bare)\n continue\n }\n if (next === undefined) {\n errors.push(\n detail(\n \"cli_flag_needs_value\",\n `${written} needs a value.`,\n `Pass one, as in ${written} <${spec.placeholder ?? \"value\"}>.`,\n written,\n ),\n )\n continue\n }\n setValue(spec, next, written)\n i += 1\n continue\n }\n\n if (token.startsWith(\"-\") && token.length > 1) {\n // Short flags cluster only when every letter is a switch. Anything else is ambiguous\n // about which flag the trailing text belongs to, and guessing is how values get lost.\n for (const letter of [...token.slice(1)]) {\n const spec = shorts.get(letter)\n if (spec === undefined) {\n errors.push(\n detail(\n \"cli_unknown_flag\",\n `Unknown flag -${letter}.`,\n `Run \\`${BRAND.slug} ${command.name} --help\\` for the flags this command accepts.`,\n `-${letter}`,\n ),\n )\n continue\n }\n if (spec.kind !== \"boolean\") {\n errors.push(\n detail(\n \"cli_short_flag_needs_value\",\n `-${letter} takes a value and cannot be bundled.`,\n `Write it on its own: --${spec.name} <${spec.placeholder ?? \"value\"}>.`,\n `-${letter}`,\n ),\n )\n continue\n }\n values.set(spec.name, true)\n }\n continue\n }\n\n positionals.push(token)\n }\n\n // Help wins over argument checking. Asking how to use a command you invoked wrongly is the most\n // likely next thing you want, and refusing to answer would be perverse.\n const flags = new Values(values, specs)\n if (flags.bool(\"help\")) return { kind: \"help\", command }\n if (flags.bool(\"version\")) return { kind: \"version\" }\n\n // Positional counting is only meaningful once every flag parsed. An unknown flag cannot consume\n // its value — the kind is unknown — so the orphan lands here as a positional, and reporting\n // \"takes 1 argument, got 2\" alongside the real mistake sends the reader looking in the wrong\n // place. Report causes, never their consequences.\n const variadic = command.args.some((arg) => arg.variadic === true)\n const required = command.args.filter((arg) => arg.required)\n if (errors.length > 0) {\n throw usage(errors)\n } else if (positionals.length < required.length) {\n const missing = required[positionals.length]\n errors.push(\n detail(\n \"cli_missing_argument\",\n `${command.name} needs ${missing === undefined ? \"another argument\" : `a ${missing.name}`}.`,\n `Usage: ${BRAND.slug} ${command.name} ${command.args.map((a) => `<${a.name}${a.variadic === true ? \"...\" : \"\"}>`).join(\" \")}`,\n ),\n )\n } else if (!variadic && positionals.length > command.args.length) {\n const extra = positionals.slice(command.args.length)\n errors.push(\n detail(\n \"cli_unexpected_argument\",\n `${command.name} takes ${command.args.length} argument(s), got ${positionals.length}.`,\n command.unexpectedArgHint ??\n `Unexpected: ${extra.join(\" \")}. Quote a value containing spaces.`,\n ),\n )\n }\n\n if (errors.length > 0) throw usage(errors)\n\n return { kind: \"command\", parsed: { command, positionals, flags } }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qFAwBO,MAAM,W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,EAAM,KAAK,MAAM,EAAG,MAAO,CAAE,KAAM,OAAQ,SAAQ,EACvD,GAAI,EAAM,KAAK,SAAS,EAAG,MAAO,CAAE,KAAM,SAAU,EAMpD,IAAM,EAAW,EAAQ,KAAK,KAAK,CAAC,IAAQ,EAAI,WAAa,EAAI,EAC3D,EAAW,EAAQ,KAAK,OAAO,CAAC,IAAQ,EAAI,QAAQ,EAC1D,GAAI,EAAO,OAAS,EAChB,MAAM,EAAM,CAAM,EACf,QAAI,EAAY,OAAS,EAAS,OAAQ,CAC7C,IAAM,EAAU,EAAS,EAAY,QACrC,EAAO,KACH,EACI,uBACA,GAAG,EAAQ,cAAc,IAAY,OAAY,mBAAqB,KAAK,EAAQ,UACnF,UAAU,EAAM,QAAQ,EAAQ,QAAQ,EAAQ,KAAK,IAAI,CAAC,IAAM,IAAI,EAAE,OAAO,EAAE,WAAa,GAAO,MAAQ,KAAK,EAAE,KAAK,GAAG,GAC9H,CACJ,EACG,QAAI,CAAC,GAAY,EAAY,OAAS,EAAQ,KAAK,OAAQ,CAC9D,IAAM,EAAQ,EAAY,MAAM,EAAQ,KAAK,MAAM,EACnD,EAAO,KACH,EACI,0BACA,GAAG,EAAQ,cAAc,EAAQ,KAAK,2BAA2B,EAAY,UAC7E,EAAQ,mBACJ,eAAe,EAAM,KAAK,GAAG,qCACrC,CACJ,EAGJ,GAAI,EAAO,OAAS,EAAG,MAAM,EAAM,CAAM,EAEzC,MAAO,CAAE,KAAM,UAAW,OAAQ,CAAE,UAAS,cAAa,OAAM,CAAE",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "705CE8F8B1BD93E464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o,Io,Ni}from"./index-nn3tk25c.js";import{Text as e}from"ink";import{useEffect as i,useState as c}from"react";import{jsx as f,jsxs as l}from"react/jsx-runtime";function Ce({label:r}){let[t,n]=c(0);return i(()=>{let p=setInterval(()=>n((a)=>(a+1)%Io.length),Ni);return()=>clearInterval(p)},[]),l(e,{children:[f(e,{color:o.accent,children:Io[t]})," ",r]})}
|
|
3
|
+
export{Ce};
|
|
4
|
+
|
|
5
|
+
//# debugId=6A3F60D89C178EEC64756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-1s81qstp.js.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * A braille spinner with a label. Ten glyphs from the theme, not a dependency (decision 11.10).\n *\n * The one kit component with its own state — the frame index — because animation is presentation,\n * not application state. Callers pair it with `useElapsed` when a count-up matters (the picker's\n * boot transition); it is deliberately not used in the init wizard, whose write-and-validate\n * completes in single-digit milliseconds and would only flash.\n */\n\nimport { Text } from \"ink\"\nimport { useEffect, useState } from \"react\"\nimport { SPINNER_FRAMES, SPINNER_INTERVAL_MS, THEME } from \"#lib/theme\"\n\nexport interface SpinnerProps {\n readonly label: string\n}\n\nexport function Spinner({ label }: SpinnerProps) {\n const [frame, setFrame] = useState(0)\n useEffect(() => {\n const timer = setInterval(\n () => setFrame((current) => (current + 1) % SPINNER_FRAMES.length),\n SPINNER_INTERVAL_MS,\n )\n return () => clearInterval(timer)\n }, [])\n\n return (\n <Text>\n <Text color={THEME.accent}>{SPINNER_FRAMES[frame]}</Text> {label}\n </Text>\n )\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";yCASA,eAAS,YACT,oBAAS,cAAW,gEAOb,SAAS,EAAO,EAAG,SAAuB,CAC7C,IAAO,EAAO,GAAY,EAAS,CAAC,EASpC,OARA,EAAU,IAAM,CACZ,IAAM,EAAQ,YACV,IAAM,EAAS,CAAC,KAAa,EAAU,GAAK,GAAe,MAAM,EACjE,EACJ,EACA,MAAO,IAAM,cAAc,CAAK,GACjC,CAAC,CAAC,EAGD,EAEE,EAFF,UAEE,CADE,EAAoD,EAApD,CAAM,MAAO,EAAM,OAAnB,SAA4B,GAAe,GAAS,EADxD,IAC+D,GAC7D",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "6A3F60D89C178EEC64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{S,$e}from"./index-byxrc961.js";import{Oi}from"./index-nn3tk25c.js";import{Ie}from"./index-79epttpm.js";import{Un}from"./index-k3y8y3wj.js";import{g}from"./index-wzsmh5j0.js";import{Li,Ui}from"./index-2zye08c4.js";var f=[{kind:"help",word:"/help",aliases:[],summary:"this list"},{kind:"status",word:"/status",aliases:[],summary:"model, channels, server, store — what this agent is and what is actually running"},{kind:"context",word:"/context",aliases:[],summary:"what is in the prompt right now, per slot, and what the percentage is a percentage of"},{kind:"restart",word:"/restart",aliases:[],summary:"restart the agent, for any configuration changes to take effect (memory files on disk are untouched)"},{kind:"tools",word:"/tools",aliases:[],summary:"what the model may call, and what the catalogue costs every turn"},{kind:"new",word:"/new",aliases:[],summary:"start a fresh conversation — this one stays in the store under its own key, and /sessions goes back to it"},{kind:"reset",word:"/reset",aliases:[],summary:"clear this conversation's history in place, keeping its key — memory files on disk are untouched"},{kind:"exit",word:"/exit",aliases:["/quit",":q"],summary:"leave — asks first, because the screen goes with it"}],Qo="⌥⏎ or a trailing \\ for a new line · ⏎ sends",ho="/ commands · ⏎ sends · ⇧⏎ new line · ^C twice leaves",x=[{chord:"^C",summary:"cancel the turn in flight — at an idle prompt, press it twice to leave (the screen goes with it)"},{chord:"^D",summary:"leave when the line is empty; delete forward when it is not"},{chord:"^A / ^E",summary:"start of line / end of line"},{chord:"^B / ^F",summary:"back one character / forward one"},{chord:"^U / ^K",summary:"delete to the start of the line / to the end"},{chord:"^W",summary:"delete the word before the cursor"},{chord:"^P / ^N",summary:"previous / next of what you have already sent"},{chord:"↑ / ↓",summary:"a line up or down inside the message — the same history at its first and last line"},{chord:"⌥⏎ / ⇧⏎",summary:"a new line in the message — ⌥⏎ everywhere, ⇧⏎ where the terminal can tell it apart (`keys` says); a trailing \\ does the same; ⏎ sends it"},{chord:"⌥← / ⌥→",summary:"back one word / forward one — ^← / ^→ do the same"},{chord:"⌥⌫ / ⌥d",summary:"delete the word before the cursor / after it"},{chord:"Home / End",summary:"start of line / end of line, the same as ^A / ^E"},{chord:"cmd← / cmd→",summary:"start of line / end of line, where the terminal reports cmd (else ^A / ^E)"},{chord:"cmd↑ / cmd↓",summary:"the start / end of the whole message, however many lines it has"},{chord:"cmd⌫ / cmd⌦",summary:"delete to the start of the line / to the end"},{chord:"cmdz / cmd⇧z",summary:"undo / redo, the same as ^Z / ^Y"},{chord:"⇧ + any motion",summary:"select as the cursor moves — ⇧← a character, ⇧⌥← a word, ⇧cmd← to the line start, ⇧cmd↑ to the top; typing or ⌫ replaces what is selected"},{chord:"cmda",summary:"select the whole message"},{chord:"^R",summary:"search what you have already sent — ↑↓ to pick, ⏎ to use it, esc to cancel"},{chord:"^Z / ^Y",summary:"undo / redo the last edit — suspend is not available inside a session"},{chord:"PgUp / PgDn",summary:"back and forward through the conversation a screen at a time"},{chord:"⌥↑ / ⌥↓",summary:"the same, one row at a time"},{chord:"⌥PgUp / ⌥PgDn",summary:"the start of the conversation / back to the newest reply"},{chord:"^O / ⌥r",summary:"show the model's reasoning whole — folded to a few rows so the reply stays findable; ^O works on every terminal, ⌥r needs one that reports it"},{chord:"drag",summary:"select text — in the conversation it goes to the clipboard when you let go, so ⌘V works; in the input box it does not, because you are usually about to type over it (⌘C copies, ⌘X cuts). Double-click a word, triple-click a line, esc clears"},{chord:"esc",summary:"return to the newest reply when you have scrolled away"}],D=x.flatMap((e)=>[...e.chord.matchAll(/\^([A-Za-z])/g)].map((t)=>(t[1]??"").toLowerCase())),F=x.flatMap((e)=>[...e.chord.matchAll(/⌥([a-z])(?![A-Za-z])/g)].map((t)=>t[1]??""));var b=/^\/[A-Za-z][\w-]*$/,A=/^(\/[A-Za-z][\w-]*)\s+(.*)$/,w=new Map(f.flatMap((e)=>[e.word,...e.aliases].map((t)=>[t.toLowerCase(),e.kind])));function nt(e,t=[]){let n=e.trim(),r=w.get(n.toLowerCase());if(r!==void 0)return{kind:r};let o=new Set(t);if(o.has(n.slice(1).toLowerCase())&&b.test(n))return{kind:"command",name:n.slice(1).toLowerCase(),rest:""};let c=A.exec(n);if(c!==null){let d=(c[1]??"").toLowerCase(),a=c[2]??"",i=w.get(d);if(i!==void 0)return{kind:i,rest:a};if(o.has(d.slice(1)))return{kind:"command",name:d.slice(1),rest:a};return}if(!b.test(n))return;let s=S(n.toLowerCase(),[...w.keys(),...t.map((d)=>`/${d}`)]);return{kind:"unknown",word:n,...s===void 0?{}:{nearest:s}}}var E=20;function I(e){return` ${[e.word,...e.aliases].join(" / ").padEnd(E)}${e.summary}`}function N(e){return` ${e.chord.padEnd(E)}${e.summary}`}function ot(){return["commands:",...f.map(I),"","keys:",...x.map(N)].join(`
|
|
3
|
+
`)}function TA(e){let t=e.nearest===void 0?"":` Did you mean ${e.nearest}?`;return`${e.word} is not a command.${t} Type /help for the list — or add a space if you meant to say it to the model.`}function cn(e){let t=e.describe();return{dialect:t.dialect,catalogueTokens:t.catalogueTokens,tools:e.tools.specs().map((n)=>({slug:n.slug,mutating:n.mutating,trust:n.trust??"trusted",...n.trustReason===void 0?{}:{trustReason:n.trustReason},summary:n.summary}))}}function IA(e){if(e.tools.length===0)return`no tools — this agent pinned none, so the model can only reply. Add them under tools.local or tools.pinned. (call format ${e.dialect})`;let t=e.tools.reduce((r,o)=>Math.max(r,o.slug.length),0),n=e.tools.flatMap((r)=>[` ${r.slug.padEnd(t)} ${r.mutating?"write":"read "} ${r.trust==="untrusted"?"untrusted":"trusted "} ${r.summary}`,...r.trustReason===void 0?[]:[`${" ".repeat(2+t+2+5+2+9+2)}trusted: ${r.trustReason}`]]);return[`${e.tools.length} tool${e.tools.length===1?"":"s"} · call format ${e.dialect} · catalogue ${e.catalogueTokens} tokens, on every turn`,...n].join(`
|
|
4
|
+
`)}function yo(e){let t=Math.max(1,e.window-e.wireTokens-e.reserveOutput),n=(e.total/t*100).toFixed(1),r=e.calibration.samples===0?"estimated — the estimator runs low on tool-heavy prompts":`corrected ×${e.calibration.ratio.toFixed(2)} from ${e.calibration.samples} reported ${e.calibration.samples===1?"figure":"figures"}`,o=e.slots.reduce((a,i)=>Math.max(a,i.label.length),0),c=e.slots.map((a)=>` ${String(a.slot).padStart(2)} ${a.label.padEnd(o)} ${String(a.tokens).padStart(6)}${a.pinned?" pinned":""}`),s=e.history.reduce((a,i)=>Math.max(a,i.label.length),0),d=e.history.length===0?[]:e.history.map((a)=>` ${a.label.padEnd(s)} ${String(a.tokens).padStart(6)} ${T(a.tokens,e.total).padStart(6)} ${String(a.messages).padStart(3)} msg`);return[g([{label:"window",value:`${e.window} (${e.windowSource})`},{label:"budget",value:`${t} = window ${e.window} − wire ${e.wireTokens} − reserveOutput ${e.reserveOutput}`},{label:"prompt",value:`${e.total} tokens · ${n}% of budget`},{label:"counted",value:r},{label:"compaction",value:e.lastCompaction??"none this session"},{label:"cache",value:e.cache===void 0?"not reported by this endpoint":`${e.cache.cached} of ${e.cache.prompt} prompt tokens (${T(e.cache.cached,e.cache.prompt)}) over ${e.cache.turns} turn${e.cache.turns===1?"":"s"} · ${e.cache.source}`}]),""," slots",...c,...d.length===0?[]:[""," history, by kind — share of the whole prompt",...d]].join(`
|
|
5
|
+
`)}function T(e,t){return t<=0?"—":`${(e/t*100).toFixed(1)}%`}function ln(){let e=f.map((r)=>({word:r.word,summary:r.summary,kind:"session"})),t=new Set(e.map((r)=>r.word)),n=Ie.filter((r)=>r.inSession!=="hidden").filter((r)=>!t.has(`/${r.name}`)).map((r)=>({word:`/${r.name}`,summary:r.summary,kind:r.inSession==="view"?"view":"output",spec:r}));return[...e,...n]}function wo(e,t=ln()){if(!/^\/[A-Za-z-]*$/.test(e))return;let n=e.slice(1).toLowerCase(),r=t.filter((o)=>o.word.slice(1).toLowerCase().startsWith(n));return{query:n,matches:r}}function xn(e,t){if(e.matches.length===0)return;return e.matches[Math.max(0,Math.min(t,e.matches.length-1))]}function it(){return ln().filter((e)=>e.kind!=="session").map((e)=>e.word.slice(1))}var C={items:[],live:void 0,status:"idle",nextId:0,turnFrom:void 0};function l(e,t,n,r={}){let o={id:`t${e.nextId}`,role:t,text:n,...r.stats===void 0?{}:{stats:r.stats},...r.callId===void 0?{}:{callId:r.callId},...r.pending===void 0?{}:{pending:r.pending}};return{...e,items:[...e.items,o],nextId:e.nextId+1}}function k(e){let t=e.live;if(t===void 0)return e;let n=e;if(t.reasoning!=="")n=l(n,"reasoning",t.reasoning);if(t.text!=="")n=l(n,"assistant",t.text);return{...n,live:void 0}}function mo(e,t){switch(t.kind){case"user":return l(e,"user",t.text);case"note":return l(e,"note",t.text);case"cancelling":return e.status==="idle"?e:{...e,status:"cancelling"};case"delta":return M(e,t.of,t.text);case"event":return P(e,t.event);case"trim":return O(e)}}function O(e){let t=e.items.length-Ui;return t<=0?e:{...e,items:e.items.slice(t)}}function M(e,t,n){if(n==="")return e;let r=e.live??{text:"",reasoning:"",last:void 0};return{...e,live:{text:t==="text"?r.text+n:r.text,reasoning:t==="reasoning"?r.reasoning+n:r.reasoning,last:t},status:e.status==="cancelling"?"cancelling":"streaming"}}function P(e,t){switch(t.type){case"turn.start":return{...e,live:{text:"",reasoning:"",last:void 0},status:"thinking",turnFrom:e.items.length};case"model.result":return k(e);case"model.chunk":return M(e,t.data.kind,t.data.delta);case"tool.call":return{...l(k(e),"tool",`${t.data.slug}${t.data.mutating?" (changes state)":""}`,{callId:t.data.callId,pending:!0}),status:e.status==="cancelling"?"cancelling":"working"};case"tool.result":{let{slug:n,callId:r,ok:o,latencyMs:c,truncated:s}=t.data,d=`${n} — ${o?"ok":"failed"} · ${c} ms${s?" · observation trimmed":""}`,a=e.items.findIndex((u)=>u.callId===r&&u.pending===!0);if(a===-1)return l(e,o?"tool":"error",d);let i=[...e.items],m=i[a];return i[a]={id:m.id,role:o?"tool":"error",text:d,callId:r},{...e,items:i}}case"tool.gated":return l(e,"note",`${t.data.slug} — blocked: ${t.data.reason}`);case"tool.repair":return l(e,"note",`${t.data.slugs.join(", ")} — could not be used, asking the model again`);case"model.retry":{let{status:n,attempt:r,delayMs:o}=t.data;return l(e,"note",`retrying after HTTP ${n} — attempt ${r}, waiting ${o} ms`)}case"turn.end":{let{reason:n,steps:r,tokens:o,durationMs:c}=t.data,s={promptTokens:o.prompt,outputTokens:o.output,durationMs:c,steps:r,reason:n},d=k(e),a=e.turnFrom??0,i=-1;for(let p=d.items.length-1;p>=a;p-=1)if(d.items[p]?.role==="assistant"){i=p;break}let m=$e(n,{steps:r,durationMs:c});if(i===-1)return{...l(d,"note",m??(n==="final"?"the model returned no text":""),{stats:s}),live:void 0,status:"idle",turnFrom:void 0};let u=[...d.items],y=u[i];u[i]={...y,stats:s};let h={...d,items:u,live:void 0,status:"idle",turnFrom:void 0};return m===void 0?h:l(h,"note",m)}case"error":{let{code:n,message:r,hint:o}=t.data;return l(e,"error",`${n}: ${r}
|
|
6
|
+
hint: ${o}`)}case"context.dropped":{let{messages:n,budget:r}=t.data;return l(e,"note",`context: ${n} older message(s) did not fit the ${r}-token budget and were left out`)}case"agent.warning":{let{code:n,message:r}=t.data;return l(e,"note",`${n}: ${r}`)}case"context.pressure":return{...e,pressure:t.data.fraction};case"compaction.stage":{let{stage:n,changed:r,before:o,after:c}=t.data;if(!r||n!=="collapse"&&n!=="reset")return e;return l(e,"note",`context: ${n==="reset"?"the conversation so far was replaced by a summary":"earlier turns were replaced by a summary"} (${o} → ${c} tokens)`)}case"phase.changed":{let{to:n,tools:r}=t.data;return{...l(e,"note",`phase: now in ${n} · ${r} tool${r===1?"":"s"} available`),phase:n}}case"context.reset":{let{warning:n}=t.data;return n===void 0?e:l(e,"note",`context: ${n}`)}default:return e}}function Yn(e){return`${e.promptTokens} prompt · ${e.outputTokens} output · ${e.durationMs} ms`}function Do(e){if(e.length===0)return C;return l(C,"banner",e.join(`
|
|
7
|
+
`))}function bo(e,t){let n=e;for(let r of t){if(r.text.trim()==="")continue;n=l(n,r.role,r.text)}return n}function So(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t]?.stats;if(n!==void 0)return n}return}function Mo(e,t){let n=[],r=e.filter((c)=>c.role!=="reasoning"||t.showReasoning),o=(c)=>({...c,lead:0,continuation:!1});for(let[c,s]of r.entries()){if(c>0)n.push(o({key:`${s.id}:gap`,role:s.role,text:""}));if(s.role==="banner"){let[m="",...u]=s.text.split(`
|
|
8
|
+
`);n.push(o({key:`${s.id}:title`,role:"banner",text:m,bold:!0}));for(let[y,h]of u.entries())for(let[p,R]of Un(h,t.columns).entries())n.push({key:`${s.id}:note-${y}-${p}`,role:"banner",text:R,dim:!0,lead:0,continuation:p>0});continue}let d=Oi[s.role],a=" ".repeat([...d].length),i=Un(s.text,Math.max(1,t.columns-[...d].length));if(s.role==="reasoning"){let m=t.expandReasoning===!0?i.length:Math.min(i.length,Li),u=i.length-m;n.push(o({key:`${s.id}:label`,role:"reasoning",dim:!0,text:u>0?`· reasoning · ${i.length} rows · ⌥r expands`:`· reasoning · ${i.length} row${i.length===1?"":"s"}`}));for(let[y,h]of i.slice(0,m).entries())n.push({key:`${s.id}:${y}`,role:"reasoning",text:`${a}${h}`,lead:a.length,continuation:y>0});if(u>0)n.push(o({key:`${s.id}:folded`,role:"reasoning",dim:!0,text:`${a}… ${u} more row${u===1?"":"s"}`}));continue}for(let[m,u]of i.entries())n.push({key:`${s.id}:${m}`,role:s.role,text:`${m===0?d:a}${u}`,lead:[...d].length,continuation:m>0});if(s.stats!==void 0&&!t.quiet)n.push(o({key:`${s.id}:stats`,role:s.role,text:` ${Yn(s.stats)}`,dim:!0}))}return n}
|
|
9
|
+
export{Qo,ho,nt,ot,TA,cn,IA,yo,ln,wo,xn,it,mo,Yn,Do,bo,So,Mo};
|
|
10
|
+
|
|
11
|
+
//# debugId=64216A5BEE43809F64756E2164756E21
|
|
12
|
+
//# sourceMappingURL=index-2rycma8x.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/session-commands.ts", "../src/transcript.ts"],
|
|
3
|
+
"sources": ["../src/lib/session-commands.ts", "../src/lib/palette.ts", "../src/transcript.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * What you can type at a running prompt, as data.\n *\n * The outer CLI's help is generated from `COMMANDS`, so a flag the parser honours cannot be missing\n * from `--help`. The in-session help had no such link: it was a string in a component, and the two\n * drifted in both directions — `/help` was advertised by the banner and unhandled on the plain path,\n * where it was sent to the model as a prompt, while five working key chords went undocumented.\n *\n * So the same discipline applies here. One table drives dispatch *and* the help text, which closes\n * the drift for commands. Key bindings cannot be generated the same way, because they live in a\n * function rather than a table — `keyToIntent` decides what `^C` means from whether a turn is in\n * flight. The loop is closed by tests instead: every documented chord is walked through the real\n * `keyToIntent`, and every chord it honours is required to appear here.\n *\n * Pure, and free of Ink: both renderers dispatch through this, which is what keeps `--plain` and the\n * rich path from answering the same keystroke differently.\n */\n\nimport { nearest } from \"@dispach/core\"\nimport { keyValue } from \"#lib/render\"\n\nexport type SessionCommandKind =\n | \"help\"\n | \"status\"\n | \"context\"\n | \"restart\"\n | \"new\"\n | \"tools\"\n | \"reset\"\n | \"exit\"\n\nexport interface SessionCommandSpec {\n readonly kind: SessionCommandKind\n readonly word: string\n /** Accepted and not advertised individually; they appear beside the canonical word. */\n readonly aliases: readonly string[]\n readonly summary: string\n}\n\nexport const SESSION_COMMANDS: readonly SessionCommandSpec[] = [\n { kind: \"help\", word: \"/help\", aliases: [], summary: \"this list\" },\n {\n // The human twin of context slot 2. Until this existed, the *model* was told its model,\n // window, channels, server and permissions on every turn — and the person at the prompt\n // had no way to see any of it. An agent that knows more about the runtime than its operator\n // does is the same asymmetry, pointed the other way, that slot 2 was added to fix.\n kind: \"status\",\n word: \"/status\",\n aliases: [],\n summary: \"model, channels, server, store — what this agent is and what is actually running\",\n },\n {\n // The status line has carried `ctx 61%` since Phase 7A and has never said what the denominator\n // is — it is not the window, and two of its three terms are invisible from outside the\n // assembler. This is where they are written down.\n kind: \"context\",\n word: \"/context\",\n aliases: [],\n summary:\n \"what is in the prompt right now, per slot, and what the percentage is a percentage of\",\n },\n {\n kind: \"restart\",\n word: \"/restart\",\n aliases: [],\n summary:\n \"restart the agent, for any configuration changes to take effect (memory files on disk are untouched)\",\n },\n {\n kind: \"tools\",\n word: \"/tools\",\n aliases: [],\n summary: \"what the model may call, and what the catalogue costs every turn\",\n },\n {\n // Next to `/reset` deliberately: they are the pair a person picks between, and picking wrong\n // is destructive in one direction only. The summaries carry the distinction rather than the\n // names, because \"new\" and \"reset\" do not tell you which one keeps the conversation.\n kind: \"new\",\n word: \"/new\",\n aliases: [],\n summary:\n \"start a fresh conversation — this one stays in the store under its own key, and /sessions goes back to it\",\n },\n {\n kind: \"reset\",\n word: \"/reset\",\n aliases: [],\n summary:\n \"clear this conversation's history in place, keeping its key — memory files on disk are untouched\",\n },\n {\n kind: \"exit\",\n word: \"/exit\",\n aliases: [\"/quit\", \":q\"],\n // Says that it asks, because it does. The session takes the whole terminal and its buffer is\n // discarded on the way out, so leaving is not a keystroke to make by accident — the same reasoning\n // that made ^C take two presses.\n summary: \"leave — asks first, because the screen goes with it\",\n },\n]\n\nexport interface KeyBindingSpec {\n /** As shown to a reader. Ctrl chords are written `^X`, and the drift test reads them back out. */\n readonly chord: string\n readonly summary: string\n}\n\n/**\n * How to put a line break in a message, as one line of hint text.\n *\n * ⌥⏎ leads because it is the chord that works everywhere: it arrives as ESC then carriage return, which\n * is a sequence every terminal can send and Ink already parses. The backslash is the fallback for anyone\n * whose Option key is bound to something else.\n *\n * Shift+⏎ is deliberately absent. It requires the terminal to send a distinguishable sequence — kitty's\n * `CSI 13;2u`, which `terminal-setup` installs for the terminals that can be taught — and whether it\n * reaches this process cannot be detected from inside it. A hint naming a chord that silently *sends*\n * the message instead is worse than one naming only what always works.\n */\nexport const NEWLINE_HINT = \"⌥⏎ or a trailing \\\\ for a new line · ⏎ sends\"\n\n/**\n * The one line of guidance a brand-new conversation carries.\n *\n * Everything on it is true of this runtime, which is the whole reason it is written here rather than\n * copied from a screenshot of another tool: `/` really does open the palette, and `^C` really does take\n * two presses. A hint naming a chord that does something else — or nothing — is worse than no hint, and\n * this is the one screen where a person has no conversation to learn the keys from.\n */\nexport const NEW_SESSION_HINT = \"/ commands · ⏎ sends · ⇧⏎ new line · ^C twice leaves\"\n\nexport const KEY_BINDINGS: readonly KeyBindingSpec[] = [\n {\n chord: \"^C\",\n summary:\n \"cancel the turn in flight — at an idle prompt, press it twice to leave (the screen goes with it)\",\n },\n { chord: \"^D\", summary: \"leave when the line is empty; delete forward when it is not\" },\n { chord: \"^A / ^E\", summary: \"start of line / end of line\" },\n { chord: \"^B / ^F\", summary: \"back one character / forward one\" },\n { chord: \"^U / ^K\", summary: \"delete to the start of the line / to the end\" },\n { chord: \"^W\", summary: \"delete the word before the cursor\" },\n { chord: \"^P / ^N\", summary: \"previous / next of what you have already sent\" },\n {\n chord: \"↑ / ↓\",\n summary:\n \"a line up or down inside the message — the same history at its first and last line\",\n },\n {\n // Both, and the qualification belongs here rather than in the composer hint. ⌥⏎ arrives as `ESC`\n // then carriage return and works in every terminal; ⇧⏎ needs one that can distinguish it, which\n // the kitty keyboard protocol delivers where it negotiates — and where it does not, ⇧⏎ *is* ⏎ and\n // silently sends the message. A permanently-visible hint cannot carry that condition; this line\n // can, which is the split `Prompt.tsx` documents.\n chord: \"⌥⏎ / ⇧⏎\",\n summary:\n \"a new line in the message — ⌥⏎ everywhere, ⇧⏎ where the terminal can tell it apart (`keys` says); a trailing \\\\ does the same; ⏎ sends it\",\n },\n { chord: \"⌥← / ⌥→\", summary: \"back one word / forward one — ^← / ^→ do the same\" },\n { chord: \"⌥⌫ / ⌥d\", summary: \"delete the word before the cursor / after it\" },\n { chord: \"Home / End\", summary: \"start of line / end of line, the same as ^A / ^E\" },\n {\n // Cmd chords need the kitty keyboard protocol, which is negotiated at mount and simply does not\n // arrive on a terminal that declines it — so this row names the readline equivalent alongside,\n // rather than describing a chord that silently does nothing on half the terminals in use.\n chord: \"cmd← / cmd→\",\n summary: \"start of line / end of line, where the terminal reports cmd (else ^A / ^E)\",\n },\n {\n chord: \"cmd↑ / cmd↓\",\n summary: \"the start / end of the whole message, however many lines it has\",\n },\n { chord: \"cmd⌫ / cmd⌦\", summary: \"delete to the start of the line / to the end\" },\n { chord: \"cmdz / cmd⇧z\", summary: \"undo / redo, the same as ^Z / ^Y\" },\n {\n // One row for the whole family, because the rule is one sentence: shift turns any motion above\n // into a selection. Listing ten shifted chords separately would be ten rows saying that once each.\n chord: \"⇧ + any motion\",\n summary:\n \"select as the cursor moves — ⇧← a character, ⇧⌥← a word, ⇧cmd← to the line start, ⇧cmd↑ to the top; typing or ⌫ replaces what is selected\",\n },\n { chord: \"cmda\", summary: \"select the whole message\" },\n {\n chord: \"^R\",\n summary: \"search what you have already sent — ↑↓ to pick, ⏎ to use it, esc to cancel\",\n },\n {\n // Not SIGTSTP: Ink puts stdin in raw mode, so the terminal never generates the signal. Suspend\n // is genuinely gone here, which is why it is written down rather than left to be discovered.\n chord: \"^Z / ^Y\",\n summary: \"undo / redo the last edit — suspend is not available inside a session\",\n },\n {\n // Deliberately not ^U/^D, which would be the shell habit: both are already taken above, both are\n // documented, and a scroll key that silently deleted half a message is the worse bug by far.\n chord: \"PgUp / PgDn\",\n summary: \"back and forward through the conversation a screen at a time\",\n },\n { chord: \"⌥↑ / ⌥↓\", summary: \"the same, one row at a time\" },\n { chord: \"⌥PgUp / ⌥PgDn\", summary: \"the start of the conversation / back to the newest reply\" },\n {\n chord: \"^O / ⌥r\",\n summary:\n \"show the model's reasoning whole — folded to a few rows so the reply stays findable; ^O works on every terminal, ⌥r needs one that reports it\",\n },\n {\n // The one entry that is not a keystroke, and it earns its place: mouse tracking is what makes the\n // wheel scroll, and the same tracking is what stops the *terminal* selecting text — so without a\n // line here, a person reasonably concludes selection is broken rather than reimplemented.\n chord: \"drag\",\n summary:\n \"select text — in the conversation it goes to the clipboard when you let go, so ⌘V works; in the input box it does not, because you are usually about to type over it (⌘C copies, ⌘X cuts). Double-click a word, triple-click a line, esc clears\",\n },\n { chord: \"esc\", summary: \"return to the newest reply when you have scrolled away\" },\n]\n\n/**\n * Every Ctrl letter the table documents, read back out of the chord strings rather than listed\n * again — a second list is one more thing that can disagree with the first. The drift test walks\n * these through `keyToIntent` and requires every letter it honours to appear here.\n */\nexport const DOCUMENTED_CTRL_LETTERS: readonly string[] = KEY_BINDINGS.flatMap((spec) =>\n [...spec.chord.matchAll(/\\^([A-Za-z])/g)].map((match) => (match[1] ?? \"\").toLowerCase()),\n)\n\n/**\n * Every option-letter chord the table documents, read back the same way.\n *\n * The ctrl list above has had a two-way drift test since Phase 2 and the option chords never did — so\n * `⌥r` was documented, bound, handled, and reaching nothing, with no test anywhere able to say so. The\n * asymmetry was not a decision: `^` is one character to match and `⌥` is one the regex simply never\n * learned about.\n */\nexport const DOCUMENTED_META_LETTERS: readonly string[] = KEY_BINDINGS.flatMap((spec) =>\n // A *lowercase* letter that no other letter follows, which is narrower than the ctrl regex for two\n // reasons the first version of this got wrong. `⌥PgUp` starts with a capital and is a key name, so\n // a `[A-Za-z]` class extracted a phantom `⌥p` and the test failed against a chord that does not\n // exist. And a letter chord is always one letter here, so requiring nothing after it keeps a future\n // `⌥Home` out of the list too.\n [...spec.chord.matchAll(/⌥([a-z])(?![A-Za-z])/g)].map((match) => match[1] ?? \"\"),\n)\n\n/**\n * Letters a terminal sends *as* an option chord without anybody pressing them.\n *\n * `⌥←` reaches us as `ESC b` from Apple Terminal and as `CSI 1;3D` from iTerm2, so `keyToIntent` honours\n * `meta` plus the letter `b` — and that is an encoding, not a binding. Documenting `⌥b` would advertise a\n * chord nobody uses to mean a thing they already have an arrow key for. Listed here rather than dropped\n * from the check, so the exemption is a decision with a reason on it instead of a hole in the test.\n */\nexport const META_LETTERS_THAT_ARE_ARROWS: readonly string[] = [\"b\", \"f\"]\n\nexport type SessionCommand =\n | { readonly kind: SessionCommandKind; readonly rest?: string }\n /**\n * A slash command this table does not own — a CLI command, offered in a session.\n *\n * Resolved here rather than in the renderer so both paths agree about what a typed line means, and\n * carried with its arguments intact for whichever host runs it.\n */\n | { readonly kind: \"command\"; readonly name: string; readonly rest: string }\n /** Looked like a command and was not one. Refused rather than billed as a prompt. */\n | { readonly kind: \"unknown\"; readonly word: string; readonly nearest?: string }\n\n/**\n * One word starting with a slash, and nothing else on the line.\n *\n * Deliberately narrow, because the alternative costs real messages. `/etc/passwd is world-readable`\n * and `and/or` are things a person says to an agent; a second slash or a space means this is prose\n * and goes to the model untouched. What remains — a lone `/word` — can only have been meant as a\n * command, so getting it wrong is worth reporting.\n */\nconst COMMAND_SHAPE = /^\\/[A-Za-z][\\w-]*$/\n\n/**\n * The same word, followed by arguments.\n *\n * The narrow rule above still decides everything it can, and this only adds a case it cannot reach:\n * `/logs 200` and `/skills validate` need a space, which the narrow rule reads as prose. The escape is\n * **the first token being exactly a known command** — decidable from the tables alone, with no\n * heuristic. So `/etc/passwd is world-readable` still goes to the model, because `/etc` is not a\n * command; and a mistyped `/skils validate` is prose rather than a refusal, which is the one thing this\n * loosening costs and the cheaper of the two errors.\n */\nconst COMMAND_WITH_ARGS = /^(\\/[A-Za-z][\\w-]*)\\s+(.*)$/\n\nconst KNOWN = new Map<string, SessionCommandKind>(\n SESSION_COMMANDS.flatMap((spec) =>\n [spec.word, ...spec.aliases].map((word) => [word.toLowerCase(), spec.kind] as const),\n ),\n)\n\n/**\n * `undefined` means \"this is a prompt\" — the overwhelming majority of lines.\n *\n * `offered` is the set of CLI command names a session exposes, passed in rather than imported: this\n * module is dispatch and `commands.ts` is the table, and importing one into the other would put the\n * whole command surface behind every consumer of `resolveSessionCommand`, including the plain path.\n */\nexport function resolveSessionCommand(\n text: string,\n offered: readonly string[] = [],\n): SessionCommand | undefined {\n const trimmed = text.trim()\n const kind = KNOWN.get(trimmed.toLowerCase())\n if (kind !== undefined) return { kind }\n\n const names = new Set(offered)\n if (names.has(trimmed.slice(1).toLowerCase()) && COMMAND_SHAPE.test(trimmed)) {\n return { kind: \"command\", name: trimmed.slice(1).toLowerCase(), rest: \"\" }\n }\n\n const withArgs = COMMAND_WITH_ARGS.exec(trimmed)\n if (withArgs !== null) {\n const head = (withArgs[1] ?? \"\").toLowerCase()\n const rest = withArgs[2] ?? \"\"\n const known = KNOWN.get(head)\n if (known !== undefined) return { kind: known, rest }\n if (names.has(head.slice(1))) {\n return { kind: \"command\", name: head.slice(1), rest }\n }\n // Not a known first token, so the narrow rule stands and this is prose.\n return undefined\n }\n\n if (!COMMAND_SHAPE.test(trimmed)) return undefined\n\n const suggestion = nearest(trimmed.toLowerCase(), [\n ...KNOWN.keys(),\n ...offered.map((name) => `/${name}`),\n ])\n return {\n kind: \"unknown\",\n word: trimmed,\n ...(suggestion === undefined ? {} : { nearest: suggestion }),\n }\n}\n\nconst COMMAND_COLUMN = 20\n\nfunction commandLine(spec: SessionCommandSpec): string {\n const forms = [spec.word, ...spec.aliases].join(\" / \")\n return ` ${forms.padEnd(COMMAND_COLUMN)}${spec.summary}`\n}\n\nfunction keyLine(spec: KeyBindingSpec): string {\n return ` ${spec.chord.padEnd(COMMAND_COLUMN)}${spec.summary}`\n}\n\n/** Generated, so a command the prompt honours cannot be missing from it. */\nexport function sessionHelpText(): string {\n return [\n \"commands:\",\n ...SESSION_COMMANDS.map(commandLine),\n \"\",\n \"keys:\",\n ...KEY_BINDINGS.map(keyLine),\n ].join(\"\\n\")\n}\n\nexport function unknownCommandText(command: {\n readonly word: string\n readonly nearest?: string\n}): string {\n const suggestion = command.nearest === undefined ? \"\" : ` Did you mean ${command.nearest}?`\n return `${command.word} is not a command.${suggestion} Type /help for the list — or add a space if you meant to say it to the model.`\n}\n\n/** The narrow slice of an agent `/tools` reports on. Structural, so core owns no CLI shapes. */\nexport interface ToolsView {\n readonly dialect: string\n readonly catalogueTokens: number\n readonly tools: readonly {\n readonly slug: string\n readonly mutating: boolean\n /**\n * Whether this tool's output may carry text a stranger wrote.\n *\n * Shown because it is not cosmetic: an untrusted tool taints the turn, and after it has run\n * a mutating call needs an explicit rule or a live approval. \"Why did my second `exec` get\n * blocked?\" is answered by this column and by nothing else on this surface.\n */\n readonly trust: string\n /**\n * Why a tool declares itself trusted when a provider tool defaults to untrusted.\n *\n * Shown here rather than warned about at boot. The warning fired on every start of every agent\n * using the system provider — four tools whose output the runtime composed — and a warning that\n * is always present for a correct configuration is one people stop reading. The reason belongs\n * where someone is already looking at the catalogue.\n */\n readonly trustReason?: string\n readonly summary: string\n }[]\n}\n\n/**\n * The part of an agent this needs, stated structurally.\n *\n * `Agent` satisfies it without being named, which keeps the projection below testable with a plain\n * object rather than a live runtime — and a projection nobody can test is one that quietly stops\n * matching what it projects.\n */\nexport interface AgentToolsSource {\n describe(): { readonly dialect: string; readonly catalogueTokens: number }\n readonly tools: {\n specs(): readonly {\n readonly slug: string\n readonly mutating: boolean\n /** Optional here because it is optional on `ToolSpec`; the registry settles it. */\n readonly trust?: string\n readonly trustReason?: string\n readonly summary: string\n }[]\n }\n}\n\n/** Here rather than in each renderer, so the two cannot show different things. */\nexport function toolsView(agent: AgentToolsSource): ToolsView {\n const described = agent.describe()\n return {\n dialect: described.dialect,\n catalogueTokens: described.catalogueTokens,\n tools: agent.tools.specs().map((spec) => ({\n slug: spec.slug,\n mutating: spec.mutating,\n // Already normalised by the registry, so the fallback is unreachable for anything that\n // came through one — but `ToolSpec.trust` is optional in the type, and a view that\n // silently printed nothing would be the wrong way to find that out.\n trust: spec.trust ?? \"trusted\",\n ...(spec.trustReason === undefined ? {} : { trustReason: spec.trustReason }),\n summary: spec.summary,\n })),\n }\n}\n\n/**\n * What the model can actually call.\n *\n * Worth a command because the catalogue is resolved once at load and is otherwise invisible: when a\n * model will not call a tool you believe is pinned, whether it is *in* the catalogue is the first\n * question, and `catalogueTokens` is the recurring cost of every turn in the session.\n */\nexport function toolsReport(view: ToolsView): string {\n if (view.tools.length === 0) {\n return `no tools — this agent pinned none, so the model can only reply. Add them under tools.local or tools.pinned. (call format ${view.dialect})`\n }\n\n const pad = view.tools.reduce((longest, tool) => Math.max(longest, tool.slug.length), 0)\n const rows = view.tools.flatMap((tool) => [\n ` ${tool.slug.padEnd(pad)} ${tool.mutating ? \"write\" : \"read \"} ${\n tool.trust === \"untrusted\" ? \"untrusted\" : \"trusted \"\n } ${tool.summary}`,\n // Only a tool that opted out of the untrusted default has one, so this is rare and worth the\n // line when it appears: it is the difference between a fence someone removed on purpose and one\n // a package forgot.\n // Aligned under the summary column: 2 leading spaces, the slug, and the two fixed columns\n // with their separators. Computed rather than hardcoded, or it drifts the first time a column\n // changes width.\n ...(tool.trustReason === undefined\n ? []\n : [`${\" \".repeat(2 + pad + 2 + 5 + 2 + 9 + 2)}trusted: ${tool.trustReason}`]),\n ])\n return [\n // \"dialect nlt\" led the line once and read as a third tool — and asked about it, the model\n // guessed NLTK, because the dialect is harness plumbing it is never told the name of. The\n // count leads; the protocol is labelled as what it is.\n `${view.tools.length} tool${view.tools.length === 1 ? \"\" : \"s\"} · call format ${view.dialect} · catalogue ${view.catalogueTokens} tokens, on every turn`,\n ...rows,\n ].join(\"\\n\")\n}\n\n/**\n * Everything `/context` needs, gathered by the host.\n *\n * A view rather than the agent itself, for the reason every view in this file is one: the report is a\n * pure function of these numbers, and a test that has to boot a runtime to check an arithmetic line\n * is a test nobody writes.\n */\nexport interface ContextView {\n readonly slots: readonly {\n readonly slot: number\n readonly label: string\n readonly tokens: number\n readonly pinned: boolean\n }[]\n /** What the history slot is made of, largest first. Empty on a conversation with no history. */\n readonly history: readonly {\n readonly label: string\n readonly tokens: number\n readonly messages: number\n }[]\n readonly total: number\n readonly window: number\n /** Already rendered by `describeWindowSource` — the CLI owns no second wording for it. */\n readonly windowSource: string\n readonly wireTokens: number\n readonly reserveOutput: number\n readonly calibration: { readonly ratio: number; readonly samples: number }\n /** The last compaction stage this session ran, if any. */\n readonly lastCompaction: string | undefined\n /** Undefined when no turn's endpoint reported a cache figure — not the same as nothing cached. */\n readonly cache:\n | {\n readonly cached: number\n readonly prompt: number\n readonly turns: number\n readonly source: string\n }\n | undefined\n}\n\n/**\n * `/context` — what is in the prompt right now, and what the percentage is a percentage *of*.\n *\n * The status line has carried `ctx 61%` since Phase 7A without ever saying what the denominator is,\n * and it is not the window: `assembleContext` is handed `window − wireTokens` and then subtracts\n * `reserveOutput` from that. Three terms, two of them invisible. So the budget line is written out as\n * the subtraction rather than as a result — a reader who disagrees with the number can see which term\n * they disagree with.\n *\n * `estimated` versus `corrected` is the other thing worth a line. The estimator runs **16–20% low**\n * on the prompts that matter (`evals/budget`, measured over a session filling with tool results),\n * which is the overflow direction exactly when the window is tight; a percentage from a session with\n * no samples yet is that raw estimate, and the reader deserves to know which one they are reading.\n */\nexport function contextReport(view: ContextView): string {\n const budget = Math.max(1, view.window - view.wireTokens - view.reserveOutput)\n const percent = ((view.total / budget) * 100).toFixed(1)\n const trust =\n view.calibration.samples === 0\n ? // Deliberately short: at 100 columns the longer version wrapped, and a wrapped value in a\n // `keyValue` block loses its alignment. \"estimated\" already carries \"no figure yet\"; what\n // it does not carry is the direction of the error, and that is the half worth the words.\n \"estimated — the estimator runs low on tool-heavy prompts\"\n : `corrected ×${view.calibration.ratio.toFixed(2)} from ${view.calibration.samples} reported ${view.calibration.samples === 1 ? \"figure\" : \"figures\"}`\n // Widest label decides the column, so a slot named later cannot push the numbers out of line.\n const pad = view.slots.reduce((longest, entry) => Math.max(longest, entry.label.length), 0)\n const slots = view.slots.map(\n (entry) =>\n ` ${String(entry.slot).padStart(2)} ${entry.label.padEnd(pad)} ${String(entry.tokens).padStart(6)}${entry.pinned ? \" pinned\" : \"\"}`,\n )\n // Indented under the history slot it decomposes, and only when there is something to decompose:\n // a fresh session's empty breakdown would be a heading with nothing under it.\n const historyPad = view.history.reduce((longest, e) => Math.max(longest, e.label.length), 0)\n const historyRows =\n view.history.length === 0\n ? []\n : view.history.map(\n (entry) =>\n ` ${entry.label.padEnd(historyPad)} ${String(entry.tokens).padStart(6)} ${percentOf(entry.tokens, view.total).padStart(6)} ${String(entry.messages).padStart(3)} msg`,\n )\n\n return [\n keyValue([\n { label: \"window\", value: `${view.window} (${view.windowSource})` },\n {\n label: \"budget\",\n // Written as the subtraction on purpose. `wireTokens` is zero under `nlt` and the term\n // is still printed: a zero that is shown is a term a reader can rule out, and a term\n // that is absent is one they have to know about to miss.\n value: `${budget} = window ${view.window} − wire ${view.wireTokens} − reserveOutput ${view.reserveOutput}`,\n },\n { label: \"prompt\", value: `${view.total} tokens · ${percent}% of budget` },\n { label: \"counted\", value: trust },\n {\n label: \"compaction\",\n value: view.lastCompaction ?? \"none this session\",\n },\n // Absent rather than \"0%\" when nothing reported: an endpoint that caches nothing and one\n // that declines to say are the same bill and opposite conclusions, and only one of them\n // is a reason to go looking at the prefix.\n {\n label: \"cache\",\n value:\n view.cache === undefined\n ? \"not reported by this endpoint\"\n : `${view.cache.cached} of ${view.cache.prompt} prompt tokens (${percentOf(view.cache.cached, view.cache.prompt)}) over ${view.cache.turns} turn${view.cache.turns === 1 ? \"\" : \"s\"} · ${view.cache.source}`,\n },\n ]),\n \"\",\n \" slots\",\n ...slots,\n // The heading names the denominator, because these are shares of the *whole prompt* and not of\n // the history — so they do not sum to 100 and, unlabelled, read as an arithmetic bug. Total is\n // the right denominator anyway: the question is what fraction of the bill each kind is, which\n // makes these directly comparable with the slot figures above.\n ...(historyRows.length === 0\n ? []\n : [\"\", \" history, by kind — share of the whole prompt\", ...historyRows]),\n ].join(\"\\n\")\n}\n\n/** A share, to one decimal, with the degenerate denominator handled rather than printed as NaN. */\nfunction percentOf(part: number, whole: number): string {\n return whole <= 0 ? \"—\" : `${((part / whole) * 100).toFixed(1)}%`\n}\n",
|
|
6
|
+
"/**\n * The slash-command palette: what a partially typed `/word` could mean.\n *\n * ## Generated, not listed\n *\n * The entries come from two tables that already exist. `SESSION_COMMANDS` holds the verbs that only make\n * sense inside a session — `/help`, `/reset`, `/exit` — and `COMMANDS` holds the whole CLI, with every\n * flag, every `choices` value and every summary already written down for `--help`.\n *\n * Reading `COMMANDS` rather than a second list is the load-bearing decision. A flag added to the CLI\n * appears in the TUI with nothing to remember, which is the discipline `session-commands.ts`'s own header\n * argues for after watching `/help` drift in both directions when it was a string in a component. A\n * command that should not be offered in a session declares `inSession: \"hidden\"` — hiding by omission\n * from a hand-written list is the same drift wearing a different hat, and a required field means a new\n * command cannot be silently absent instead.\n *\n * ## Pure\n *\n * Derived from the editor's value, so the only state the renderer adds is a cursor index. No filesystem,\n * no process, no renderer — PURE-listed, and the matching rules are asserted as data.\n */\n\nimport { COMMANDS } from \"#lib/commands\"\nimport type { CommandSpec } from \"#lib/schema\"\nimport { SESSION_COMMANDS } from \"#lib/session-commands\"\n\nexport interface PaletteEntry {\n /** With the slash, as it would be typed. */\n readonly word: string\n readonly summary: string\n /**\n * `session` — dispatched by `resolveSessionCommand`.\n * `view` — a bespoke screen.\n * `output` — run the command and show what it printed.\n */\n readonly kind: \"session\" | \"view\" | \"output\"\n /** Present for a CLI command, so a host can read its flags and actions. */\n readonly spec?: CommandSpec\n}\n\n/**\n * Every entry a session offers, session verbs first.\n *\n * Session verbs lead because they are the ones with no shell equivalent and the ones typed most: `/help`\n * and `/exit` at the top of an unfiltered list is what makes the palette answer \"what can I do here\"\n * rather than \"what commands exist\".\n */\nexport function paletteEntries(): readonly PaletteEntry[] {\n const session: PaletteEntry[] = SESSION_COMMANDS.map((spec) => ({\n word: spec.word,\n summary: spec.summary,\n kind: \"session\" as const,\n }))\n const own = new Set(session.map((entry) => entry.word))\n const commands: PaletteEntry[] = COMMANDS.filter((spec) => spec.inSession !== \"hidden\")\n // A CLI command whose name collides with a session verb loses: `/tools` inside a session means\n // the running agent's catalogue, not a fresh load of the manifest from disk.\n .filter((spec) => !own.has(`/${spec.name}`))\n .map((spec) => ({\n word: `/${spec.name}`,\n summary: spec.summary,\n kind: spec.inSession === \"view\" ? (\"view\" as const) : (\"output\" as const),\n spec,\n }))\n return [...session, ...commands]\n}\n\nexport interface Palette {\n /** What has been typed after the slash, lowercased. */\n readonly query: string\n readonly matches: readonly PaletteEntry[]\n}\n\n/**\n * The palette for a buffer, or `undefined` when the buffer is not a slash command being typed.\n *\n * Open only while the *whole* buffer is one `/word` under construction. Two consequences, both\n * deliberate: a message that merely mentions a path never opens it, and once arguments are being typed\n * the list closes, because there is nothing left to complete and a list covering the line would hide\n * what is being written.\n */\nexport function paletteFor(\n value: string,\n entries: readonly PaletteEntry[] = paletteEntries(),\n): Palette | undefined {\n if (!/^\\/[A-Za-z-]*$/.test(value)) return undefined\n const query = value.slice(1).toLowerCase()\n const matches = entries.filter((entry) => entry.word.slice(1).toLowerCase().startsWith(query))\n // Prefix, not fuzzy. A palette that offers `/sessions` for `/st` reads as noise, and the words are\n // short enough that a prefix always reaches them in two or three characters.\n return { query, matches }\n}\n\n/** The entry a cursor is on, clamped, or `undefined` when nothing matches. */\nexport function paletteSelection(palette: Palette, index: number): PaletteEntry | undefined {\n if (palette.matches.length === 0) return undefined\n return palette.matches[Math.max(0, Math.min(index, palette.matches.length - 1))]\n}\n\n/**\n * The command names a typed slash line may use, without the leading slash.\n *\n * `resolveSessionCommand` takes this list, and it defaulted to empty at the one call site that mattered\n * — so a typed `/config get x` was prose and the same command chosen from the palette ran. Derived from\n * the palette rather than from `COMMANDS` directly, because the palette is what the person was just\n * shown: anything offered there has to be typeable, and anything typeable has to be offered.\n */\nexport function offeredCommands(): readonly string[] {\n return paletteEntries()\n .filter((entry) => entry.kind !== \"session\")\n .map((entry) => entry.word.slice(1))\n}\n",
|
|
6
7
|
"/**\n * Events in, view state out. Pure, and the only place that decides what a turn looks like.\n *\n * The CLI has always been a `runtime.bus` subscriber; this makes it a *reducer* over that bus\n * instead of a set of callbacks writing to stdout. Three things follow from that:\n *\n * - \"What does the reader see when a turn errors mid-stream?\" is a unit test rather than something\n * reproduced by hand against a live endpoint.\n * - Finished items are append-only and immutable, which is exactly the contract Ink's `<Static>`\n * needs: a node written once and never re-rendered. The still-moving reply lives in `live`, so\n * the dynamic region stays one item regardless of how long the conversation gets.\n * - Phase 4's SSE client and Phase 12's TUI client can consume the same reduction instead of\n * re-deriving it.\n *\n * No clock and no randomness: ids come from a counter in the state, so the same events always\n * produce the same output and the tests need no fakes.\n */\n\nimport { type AnyEvent, endNote } from \"@dispach/core\"\nimport { MAX_TRANSCRIPT_ITEMS, REASONING_FOLD_ROWS } from \"#lib/const\"\nimport { ROLE_PREFIX } from \"#lib/theme\"\nimport type {\n TranscriptItem,\n TranscriptRole,\n TranscriptRow,\n TranscriptState,\n TurnStats,\n} from \"#lib/types\"\nimport { wrapText } from \"#lib/wrap\"\n\n/**\n * The transcript is driven by more than the bus — a typed line and a cancellation request are not\n * events — so the reducer takes an action union rather than an event directly.\n */\nexport type TranscriptAction =\n | { readonly kind: \"user\"; readonly text: string }\n | { readonly kind: \"event\"; readonly event: AnyEvent }\n | { readonly kind: \"note\"; readonly text: string }\n | { readonly kind: \"cancelling\" }\n /**\n * A model delta that has already been through the dialect's stream filter.\n *\n * Filtering cannot happen in here: a filter is stateful and this reducer is pure. So the caller\n * owns one per step and dispatches what is left. A caller that dispatches the raw `model.chunk`\n * event instead still works — it just shows the invocation blocks, which is right for a dialect\n * with no in-band protocol and wrong for NLT.\n */\n | { readonly kind: \"delta\"; readonly of: \"text\" | \"reasoning\"; readonly text: string }\n /**\n * Drop the oldest items if the buffer is over `MAX_TRANSCRIPT_ITEMS`.\n *\n * An action rather than something `append` does on its own, because whether it is *safe* depends on\n * a fact this reducer cannot see: rows are addressed by position, so dropping any from the front\n * moves every offset below them. A reader parked twelve turns back would keep their offset and\n * silently start reading different text — the appearance of a live session that is not one, which is\n * the failure `ScrollState.pinned` exists to make impossible. Only the layer holding that flag knows\n * when eviction is allowed, so only it can ask.\n */\n | { readonly kind: \"trim\" }\n\nexport const EMPTY_TRANSCRIPT: TranscriptState = {\n items: [],\n live: undefined,\n status: \"idle\",\n nextId: 0,\n turnFrom: undefined,\n}\n\nfunction append(\n state: TranscriptState,\n role: TranscriptRole,\n text: string,\n extra: {\n readonly stats?: TurnStats\n readonly callId?: string\n readonly pending?: boolean\n } = {},\n): TranscriptState {\n const item: TranscriptItem = {\n id: `t${state.nextId}`,\n role,\n text,\n ...(extra.stats === undefined ? {} : { stats: extra.stats }),\n ...(extra.callId === undefined ? {} : { callId: extra.callId }),\n ...(extra.pending === undefined ? {} : { pending: extra.pending }),\n }\n return { ...state, items: [...state.items, item], nextId: state.nextId + 1 }\n}\n\n/**\n * Commit whatever the model has streamed so far, and clear it.\n *\n * Called at each step boundary rather than once at the end of the turn, which is what puts the\n * transcript back in the order things happened. Committing at `turn.end` alone produced a turn shaped\n * \"every tool row, then all the reasoning, then all the text\" — so the reasoning that *decided* to call\n * a tool was printed below the tool's result, and step one's reasoning was concatenated onto step two's\n * with no break between them. Live output on a real turn read `…look for it in my workspace.The user is\n * asking me to…`, two sentences from two steps with nothing marking the join.\n *\n * Reasoning goes in ahead of the text it produced. Whether it is *shown* is the view's business — the\n * item is written either way, so `--show-reasoning` can be honoured after the fact.\n */\nfunction flushLive(state: TranscriptState): TranscriptState {\n const live = state.live\n if (live === undefined) return state\n let next = state\n if (live.reasoning !== \"\") next = append(next, \"reasoning\", live.reasoning)\n if (live.text !== \"\") next = append(next, \"assistant\", live.text)\n return { ...next, live: undefined }\n}\n\n/** `data` is typed per event in core's map; narrowing by `type` first is what makes this safe. */\nexport function reduce(state: TranscriptState, action: TranscriptAction): TranscriptState {\n switch (action.kind) {\n case \"user\":\n return append(state, \"user\", action.text)\n\n case \"note\":\n return append(state, \"note\", action.text)\n\n case \"cancelling\":\n // A state, not an item. Cancellation that produced partial text still ends in a\n // `turn.end`, and that is what commits the text.\n return state.status === \"idle\" ? state : { ...state, status: \"cancelling\" }\n\n case \"delta\":\n return applyDelta(state, action.of, action.text)\n\n case \"event\":\n return reduceEvent(state, action.event)\n\n case \"trim\":\n return trim(state)\n }\n}\n\n/**\n * The oldest items above the cap, dropped. Identity when there is nothing to do.\n *\n * Returning the same object rather than a copy is what makes this cheap to ask about: `useReducer`\n * compares by reference and skips the render, so the caller can dispatch on every change without\n * checking first — and a caller that has to check first is a caller that eventually forgets.\n *\n * The banner is an ordinary item and goes with the rest. It is four hundred turns of scrollback above\n * the reader by then, and exempting it would leave the session's opening line pinned above a\n * conversation it no longer describes.\n */\nfunction trim(state: TranscriptState): TranscriptState {\n const over = state.items.length - MAX_TRANSCRIPT_ITEMS\n return over <= 0 ? state : { ...state, items: state.items.slice(over) }\n}\n\nfunction applyDelta(\n state: TranscriptState,\n kind: \"text\" | \"reasoning\",\n delta: string,\n): TranscriptState {\n if (delta === \"\") return state\n const live = state.live ?? { text: \"\", reasoning: \"\", last: undefined }\n return {\n ...state,\n live: {\n text: kind === \"text\" ? live.text + delta : live.text,\n reasoning: kind === \"reasoning\" ? live.reasoning + delta : live.reasoning,\n last: kind,\n },\n // A cancellation already asked for is not undone by another token arriving in flight; the\n // request stands until the turn actually ends.\n status: state.status === \"cancelling\" ? \"cancelling\" : \"streaming\",\n }\n}\n\nfunction reduceEvent(state: TranscriptState, event: AnyEvent): TranscriptState {\n switch (event.type) {\n case \"turn.start\":\n return {\n ...state,\n live: { text: \"\", reasoning: \"\", last: undefined },\n status: \"thinking\",\n turnFrom: state.items.length,\n }\n\n case \"model.result\":\n // The step boundary. `model.result` is emitted once per model call, so this is where a step's\n // reasoning and text stop growing — no new event was needed to find it.\n return flushLive(state)\n\n case \"model.chunk\":\n return applyDelta(state, event.data.kind, event.data.delta)\n\n case \"tool.call\":\n // Committed the moment the call starts, not when it returns: a tool that takes eight\n // seconds must not leave the screen looking like a stalled model. Anything the model\n // streamed before deciding to call it is flushed first, so the reasoning sits above the\n // call it explains rather than below the call's result.\n return {\n ...append(\n flushLive(state),\n \"tool\",\n `${event.data.slug}${event.data.mutating ? \" (changes state)\" : \"\"}`,\n { callId: event.data.callId, pending: true },\n ),\n status: state.status === \"cancelling\" ? \"cancelling\" : \"working\",\n }\n\n case \"tool.result\": {\n const { slug, callId, ok, latencyMs, truncated } = event.data\n const text = `${slug} — ${ok ? \"ok\" : \"failed\"} · ${latencyMs} ms${truncated ? \" · observation trimmed\" : \"\"}`\n // The call's own row, completed. Matched on `callId` rather than on position, because calls\n // can overlap and \"the last tool row\" is then not the row this result belongs to.\n const at = state.items.findIndex(\n (item) => item.callId === callId && item.pending === true,\n )\n if (at === -1) {\n // No row to complete — a result for a call this transcript never saw. Appended rather\n // than dropped: an observation nobody can account for is exactly the thing worth seeing.\n return append(state, ok ? \"tool\" : \"error\", text)\n }\n const items = [...state.items]\n const item = items[at] as TranscriptItem\n items[at] = { id: item.id, role: ok ? \"tool\" : \"error\", text, callId }\n return { ...state, items }\n }\n\n case \"tool.gated\":\n // Deliberately visible. A blocked write is the one tool outcome a person must not have\n // to go looking for — and it is a `note` rather than an `error` because the wire spec is\n // explicit that this is not one: the turn continues and the model reports back.\n return append(state, \"note\", `${event.data.slug} — blocked: ${event.data.reason}`)\n\n case \"tool.repair\":\n // A silent repair is indistinguishable from a slow turn, and it costs a whole step.\n return append(\n state,\n \"note\",\n `${event.data.slugs.join(\", \")} — could not be used, asking the model again`,\n )\n\n case \"model.retry\": {\n const { status, attempt, delayMs } = event.data\n return append(\n state,\n \"note\",\n `retrying after HTTP ${status} — attempt ${attempt}, waiting ${delayMs} ms`,\n )\n }\n\n case \"turn.end\": {\n const { reason, steps, tokens, durationMs } = event.data\n const stats: TurnStats = {\n promptTokens: tokens.prompt,\n outputTokens: tokens.output,\n durationMs,\n steps,\n reason,\n }\n\n // Whatever the last step streamed but never got a `model.result` for — a cancelled turn, or\n // one that ended on an error mid-stream. On a clean turn this is a no-op, because each step\n // committed itself as it finished.\n const next = flushLive(state)\n const from = state.turnFrom ?? 0\n // The reply this turn produced, which is where its cost belongs. Searched from the turn's own\n // first item: without that floor, a turn that produced no text would hang its statistics on\n // the *previous* turn's reply, which reads as that reply having cost twice.\n let reply = -1\n for (let at = next.items.length - 1; at >= from; at -= 1) {\n if (next.items[at]?.role === \"assistant\") {\n reply = at\n break\n }\n }\n // Why the turn stopped, from the formatter the plain path uses. Until this existed\n // `stats.reason` reached the reducer and was rendered nowhere, so a turn the step budget\n // cut off looked exactly like a completed one — which is how an agent came to stop\n // mid-task on \"Let me install it\" with nothing on screen explaining it.\n const why = endNote(reason, { steps, durationMs })\n\n if (reply === -1) {\n // A turn that produced nothing is not a normal outcome and must not look like one.\n const said = append(\n next,\n \"note\",\n why ?? (reason === \"final\" ? \"the model returned no text\" : \"\"),\n { stats },\n )\n return { ...said, live: undefined, status: \"idle\", turnFrom: undefined }\n }\n const items = [...next.items]\n const item = items[reply] as TranscriptItem\n items[reply] = { ...item, stats }\n const settled: TranscriptState = {\n ...next,\n items,\n live: undefined,\n status: \"idle\",\n turnFrom: undefined,\n }\n // Below the reply, not attached to it: the reply is what the model said, and this is what\n // the runtime did. Attaching it to the item would put a harness sentence in the model's\n // voice — the distinction `note` exists for.\n return why === undefined ? settled : append(settled, \"note\", why)\n }\n\n // `agent.error` used to fall through to here. It was declared in Phase 1, carried a\n // hint, and was emitted by **nothing, ever** — so this label was reachable only from a\n // test that constructed one by hand. Deleted rather than wired up: `error` already\n // carries every uncaught failure, and a second error event with no emitter is vocabulary\n // that makes the catalogue look richer than it is.\n case \"error\": {\n const { code, message, hint } = event.data\n return append(state, \"error\", `${code}: ${message}\\nhint: ${hint}`)\n }\n\n case \"context.dropped\": {\n const { messages, budget } = event.data\n // A note, not a stage line: the ladder decided what to compact and this is the budget\n // running out regardless. Worth saying because the agent is now answering without part of\n // the conversation, and nothing else on any surface would mention it.\n return append(\n state,\n \"note\",\n `context: ${messages} older message(s) did not fit the ${budget}-token budget and were left out`,\n )\n }\n\n case \"agent.warning\": {\n const { code, message } = event.data\n return append(state, \"note\", `${code}: ${message}`)\n }\n\n case \"context.pressure\":\n // A gauge, so it replaces rather than accumulates. `source` is deliberately not shown: it\n // is diagnostic and the status line has no room for a word that changes nothing a person\n // would do — it is on the event for whoever is reading events.\n return { ...state, pressure: event.data.fraction }\n\n case \"compaction.stage\": {\n const { stage, changed, before, after } = event.data\n // Only the stages that destroy detail get a line. trim, snip and micro are recoverable —\n // the conversation is still in the store and a snipped observation keeps a pointer — while\n // collapse and reset replace a span of the conversation with a summary, and a person who\n // was not watching the gauge still needs to know that happened.\n if (!changed || (stage !== \"collapse\" && stage !== \"reset\")) return state\n const what =\n stage === \"reset\"\n ? \"the conversation so far was replaced by a summary\"\n : \"earlier turns were replaced by a summary\"\n return append(state, \"note\", `context: ${what} (${before} → ${after} tokens)`)\n }\n\n case \"phase.changed\": {\n const { to, tools } = event.data\n // A line *and* the gauge. The line because a phase change is the reason the agent's\n // abilities changed mid-conversation, and a person scrolling back needs it where it\n // happened; the gauge because \"which phase am I in\" is a current-state question.\n const next = append(\n state,\n \"note\",\n `phase: now in ${to} · ${tools} tool${tools === 1 ? \"\" : \"s\"} available`,\n )\n return { ...next, phase: to }\n }\n\n case \"context.reset\": {\n const { warning } = event.data\n // The count itself is not shown — the note above already said what happened. A *second*\n // reset is a configuration problem rather than a busy session, and that is worth a line.\n return warning === undefined ? state : append(state, \"note\", `context: ${warning}`)\n }\n\n default:\n // Boot and bookkeeping events — `runtime.ready`, `store.ready`, `model.call`,\n // `context.assembled`. They belong to the banner and the status bar, not the transcript. Ignored explicitly so that a new event type added in a later\n // phase is inert here rather than a crash.\n return state\n }\n}\n\n/** What a renderer writes for a turn's cost. Kept here so the plain and rich paths agree. */\nexport function formatStats(stats: TurnStats): string {\n return `${stats.promptTokens} prompt · ${stats.outputTokens} output · ${stats.durationMs} ms`\n}\n\n/**\n * Opening banner — version, session, store, any turn a previous process left unfinished.\n *\n * One `banner` item rather than N notes, so the rich renderer can box it as a unit. The plain\n * path never calls this — it writes the lines directly — so plain output is unchanged by the\n * boxing.\n */\nexport function seed(notes: readonly string[]): TranscriptState {\n if (notes.length === 0) return EMPTY_TRANSCRIPT\n return append(EMPTY_TRANSCRIPT, \"banner\", notes.join(\"\\n\"))\n}\n\n/** One earlier message, as much of it as a transcript row needs. */\nexport interface PriorMessage {\n readonly role: \"user\" | \"assistant\"\n readonly text: string\n}\n\n/**\n * Put the conversation that already happened on the screen.\n *\n * Resuming used to paint an empty transcript over a full history: the messages reached the *model* and\n * never the person, so the banner said `17 message(s)` above a blank screen and the only honest reading\n * was that something had been lost. Rendering them is what makes that count verifiable.\n *\n * A separate function rather than a second argument to `seed`, because an optional parameter here would\n * have to distinguish \"no history\" from \"not asked for\" — and under `exactOptionalPropertyTypes` a\n * default parameter fires on an explicitly passed `undefined`, which has already cost this repo a\n * debugging round. `seedHistory(seed(banner), prior)` composes with nothing to remember.\n *\n * **Prose only.** Tool calls and observations are left out for the same reason they are left out of the\n * memory index: an observation is a wall of text a stranger wrote, and replaying forty of them above the\n * composer buries the conversation the person came back for. The turn statistics are left off too — they\n * were true of a process that has exited, and a cost line under a resumed reply reads as this session's.\n */\nexport function seedHistory(\n state: TranscriptState,\n messages: readonly PriorMessage[],\n): TranscriptState {\n let next = state\n for (const message of messages) {\n if (message.text.trim() === \"\") continue\n next = append(next, message.role, message.text)\n }\n return next\n}\n\n/** The most recent completed turn's cost, for the status bar. */\nexport function lastStats(items: readonly TranscriptItem[]): TurnStats | undefined {\n for (let i = items.length - 1; i >= 0; i -= 1) {\n const stats = items[i]?.stats\n if (stats !== undefined) return stats\n }\n return undefined\n}\n\n// ─── the finished conversation, as rows ──────────────────────────────────────────────────\n\n/**\n * Flatten items into the rows a windowed transcript scrolls through.\n *\n * ## Why rows rather than items\n *\n * Scrolling by item is the cheaper thing to build and the wrong unit. One assistant reply is a single\n * item and forty rows on screen, so an item-indexed window either shows the whole answer or none of it —\n * page-up from the bottom of a long reply would jump over the entire thing and land on the question\n * before it. Rows are what a reader moves through, so rows are what the offset counts.\n *\n * Wrapping happens here, not in Ink. A window has to know its content's height before it draws any of\n * it, and a count Ink might disagree with is a window off by however many lines wrapped — which shows up\n * as the last line of a reply hidden under the composer, intermittently, depending on the text.\n *\n * Pure, and one derivation for both halves of the frame: the component renders these rows and the layout\n * asks how many there are.\n */\nexport function transcriptRows(\n items: readonly TranscriptItem[],\n options: {\n readonly showReasoning: boolean\n readonly quiet: boolean\n readonly columns: number\n /** Reasoning blocks are shown whole rather than folded to `REASONING_FOLD_ROWS`. */\n readonly expandReasoning?: boolean\n },\n): readonly TranscriptRow[] {\n const rows: TranscriptRow[] = []\n const visible = items.filter((item) => item.role !== \"reasoning\" || options.showReasoning)\n\n /**\n * A row this renderer invented: a gap, a label, a fold notice, a stats line.\n *\n * `lead: 0` because there is no prefix to exclude, and `continuation: false` because it starts a line of\n * its own. Selectable, deliberately — a stats line or a banner note is text somebody may well want to\n * copy, and the cells worth excluding are the role prefixes, which are per-row and handled below.\n */\n const chrome = (row: Omit<TranscriptRow, \"lead\" | \"continuation\">): TranscriptRow => ({\n ...row,\n lead: 0,\n continuation: false,\n })\n\n for (const [at, item] of visible.entries()) {\n // A blank row between items, and never a trailing one. The rich transcript is read rather than\n // grepped, and two turns that touch each other read as one wall of text; a blank row at the end\n // would instead be a permanent gap above the composer.\n if (at > 0) rows.push(chrome({ key: `${item.id}:gap`, role: item.role, text: \"\" }))\n\n if (item.role === \"banner\") {\n // The banner keeps its content and loses its border. A bordered box inside a windowed list\n // costs two rows this module cannot count — Ink measures the frame, not us — and the frame\n // was decoration on a surface that is now itself a frame.\n const [title = \"\", ...lines] = item.text.split(\"\\n\")\n rows.push(chrome({ key: `${item.id}:title`, role: \"banner\", text: title, bold: true }))\n for (const [n, line] of lines.entries()) {\n for (const [w, wrapped] of wrapText(line, options.columns).entries()) {\n rows.push({\n key: `${item.id}:note-${n}-${w}`,\n role: \"banner\",\n text: wrapped,\n dim: true,\n lead: 0,\n // Only rows the *wrap* invented continue; a fresh source line does not.\n continuation: w > 0,\n })\n }\n }\n continue\n }\n\n const prefix = ROLE_PREFIX[item.role]\n const pad = \" \".repeat([...prefix].length)\n // The prefix is part of the first row's width and an indent on every row after it, so a reply\n // that wraps stays in one column instead of reading as a second message.\n const body = wrapText(item.text, Math.max(1, options.columns - [...prefix].length))\n\n if (item.role === \"reasoning\") {\n // A header row and an indented body, rather than a label wide enough to be the indent. Folded\n // unless asked for: the block is secondary, and at full length it routinely fills the screen\n // and pushes the reply it produced out of sight.\n const shown =\n options.expandReasoning === true\n ? body.length\n : Math.min(body.length, REASONING_FOLD_ROWS)\n const folded = body.length - shown\n rows.push(\n chrome({\n key: `${item.id}:label`,\n role: \"reasoning\",\n dim: true,\n text:\n folded > 0\n ? `· reasoning · ${body.length} rows · ⌥r expands`\n : `· reasoning · ${body.length} row${body.length === 1 ? \"\" : \"s\"}`,\n }),\n )\n for (const [n, line] of body.slice(0, shown).entries()) {\n rows.push({\n key: `${item.id}:${n}`,\n role: \"reasoning\",\n text: `${pad}${line}`,\n lead: pad.length,\n continuation: n > 0,\n })\n }\n if (folded > 0) {\n rows.push(\n chrome({\n key: `${item.id}:folded`,\n role: \"reasoning\",\n dim: true,\n text: `${pad}… ${folded} more row${folded === 1 ? \"\" : \"s\"}`,\n }),\n )\n }\n continue\n }\n\n for (const [n, line] of body.entries()) {\n rows.push({\n key: `${item.id}:${n}`,\n role: item.role,\n text: `${n === 0 ? prefix : pad}${line}`,\n // The prefix on the first row and its hanging indent on every row after it are the same\n // width, so one number covers both — and it is exactly the span a copy must drop.\n lead: [...prefix].length,\n continuation: n > 0,\n })\n }\n\n if (item.stats !== undefined && !options.quiet) {\n rows.push(\n chrome({\n key: `${item.id}:stats`,\n role: item.role,\n text: ` ${formatStats(item.stats)}`,\n dim: true,\n }),\n )\n }\n }\n\n return rows\n}\n"
|
|
7
8
|
],
|
|
8
|
-
"mappings": ";wLAuCO,IAAM,GAAkD,CAC3D,CAAE,KAAM,OAAQ,KAAM,QAAS,QAAS,CAAC,EAAG,QAAS,WAAY,EACjE,CAKI,KAAM,SACN,KAAM,UACN,QAAS,CAAC,EACV,Q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L,EAIR,OAAO",
|
|
10
|
+
"debugId": "64216A5BEE43809F64756E2164756E21",
|
|
10
11
|
"names": []
|
|
11
12
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var Ri="\x1B[?25h",Xt="\x1B[0m",vi="\x1B[2m",Me="\x1B[?1049h",Gi="\x1B[?1049l",Fi="\x1B[<u",J=80,$t=24,en=12,An="› ",tn=40,nn=140,aA=8,gA=40,cA=8,Ti=200,uo=100,on=10,Li=4,Pi=6,rn=3,Ui=2000,sn=50,Ki=1,t=0,i=1,Hi=143;var xi=3,Yi=23,Ji=8,ji=400,Hn=1,At=12,_i=300,qi=2000;
|
|
3
|
+
export{Ri,Xt,vi,Me,Gi,Fi,J,$t,en,An,tn,nn,aA,gA,cA,Ti,uo,on,Li,Pi,rn,Ui,sn,Ki,t,i,Hi,xi,Yi,Ji,ji,Hn,At,_i,qi};
|
|
4
|
+
|
|
5
|
+
//# debugId=3045ED20F41AFFDF64756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-2zye08c4.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/lib/const.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Every constant the CLI uses, in one place.\n *\n * The rule is the one termheat follows: no magic number inline. A width, a limit, or a control\n * sequence buried in a component is invisible to anyone tuning behaviour later, and two copies of\n * the same number drift.\n */\n\n// ─── terminal ────────────────────────────────────────────────────────────────────────────\n\nexport const SHOW_CURSOR = \"\\u001B[?25h\"\nexport const RESET_STYLE = \"\\u001B[0m\"\n/**\n * Faint text, for the one thing written outside Ink that is not the point of the output.\n *\n * SGR 2 rather than a grey foreground: a fixed colour is wrong on half the terminals in existence,\n * and dim is the terminal's own opinion about what recedes on the theme in use. It persists across a\n * newline, so a multi-line note opens it once and resets once — and the reset lands before the final\n * newline, or the shell prompt that follows inherits it.\n */\nexport const DIM_STYLE = \"\\u001B[2m\"\n\n/**\n * The alternate screen buffer — a second, empty screen the terminal swaps in, discards on the way\n * out, and never adds to the scrollback.\n *\n * `1049` rather than the older `47`: it saves the cursor position and clears the new buffer in one\n * sequence, which is what lands the shell prompt back where it was rather than wherever the app left\n * the cursor.\n *\n * The order on the way out is easy to get backwards. A style reset applies to whichever buffer is\n * *current*, so it has to be written before the swap away — reset afterwards and any colour the app\n * left on lands on the shell's screen instead of the one being discarded. `restoreTerminal` does them\n * in that order and says so there too.\n */\nexport const ENTER_ALT_SCREEN = \"\\u001B[?1049h\"\nexport const LEAVE_ALT_SCREEN = \"\\u001B[?1049l\"\n\n/**\n * Pop the kitty keyboard protocol: `CSI < u`, the counterpart to the `CSI > flags u` Ink pushes.\n *\n * Here rather than in `lib/keyboard.ts` so the dependency runs one way — `lib/exit.ts` needs the\n * sequence and `lib/keyboard.ts` needs `markEnhancedKeys`, and only one of those two can import the\n * other. Terminal-mode sequences already live in this module, which makes this the side that moves.\n */\nexport const DISABLE_ENHANCED_KEYS = \"\\u001B[<u\"\n\n/**\n * Fallback width. A pty can genuinely report `columns === 0` — measured, under `script -q`, which\n * is how this repo drives a real TTY in a test harness. Any layout maths that divides by the\n * terminal width has to survive that.\n */\nexport const FALLBACK_COLUMNS = 80\nexport const FALLBACK_ROWS = 24\n\n/**\n * Rows the live pane may occupy before it starts showing only its tail.\n *\n * Ink erases and redraws its whole dynamic tree every frame, so an unbounded live region means\n * redrawing hundreds of lines per token. Finished messages move into `<Static>`, which is written\n * once and never touched again; this cap is what keeps the *unfinished* one cheap.\n */\nexport const LIVE_PANE_MAX_ROWS = 12\n\nexport const PROMPT = \"› \"\n\n/**\n * The width a screen is laid out for, clamped at both ends.\n *\n * The floor is where the row layout drops its description column rather than wrapping — below it\n * nothing sensible is possible, and a wrapped row is what made the first skills list unreadable. The\n * ceiling stops a 300-column window putting a description a screen away from the name it belongs to.\n *\n * Here rather than in the one command that first needed them, because every screen now shares a frame\n * and two screens clamping differently is the drift `render.ts` was written to end.\n */\nexport const MIN_SCREEN_COLUMNS = 40\nexport const MAX_SCREEN_COLUMNS = 140\n\n/** Rows a scrolling list may occupy, before and after the frame takes its share. */\nexport const MIN_SCREEN_ROWS = 8\nexport const MAX_SCREEN_ROWS = 40\n/** Header, footer, margins and the counter — what the frame costs a list. */\nexport const SCREEN_CHROME_ROWS = 8\n\n// ─── commands and input ──────────────────────────────────────────────────────────────────\n\n// The command words themselves live in `session-commands.ts`, beside the summary that documents\n// each one and the dispatch that honours it. Three bare string constants here is how the help text\n// and the parser came to disagree in the first place.\n\n/** Lines of input history kept for the up/down arrows. */\nexport const HISTORY_LIMIT = 200\n\n/**\n * Undo points kept for the input buffer.\n *\n * Bounded because a snapshot holds a whole copy of the text, and a long composing session with a\n * pasted document in it would otherwise keep every intermediate version alive for the life of the\n * process. A run of typing is one point, not one per keystroke, so this is deeper than it looks.\n */\nexport const UNDO_LIMIT = 100\n\n/**\n * Rows the input box may grow to before it scrolls internally.\n *\n * The same reasoning as `LIVE_PANE_MAX_ROWS`: the input is in Ink's dynamic region, which is erased and\n * redrawn every frame, so an unbounded box means redrawing a pasted document on every keystroke. It\n * also stops a long paste pushing the conversation off the screen.\n */\nexport const MAX_INPUT_ROWS = 10\n\n/**\n * Rows of a reasoning block shown before it folds to a count.\n *\n * Reasoning is secondary and routinely the longest item in a conversation — a real turn produced a\n * twenty-three-row block for a one-sentence answer, which filled a thirty-row terminal on its own and made\n * the reply itself something you had to scroll to find. Four rows is enough to see what it was thinking\n * about; `⌥r` shows the rest.\n *\n * Folding is a *view* decision, applied when items become rows. The whole text is always in the item, so\n * expanding needs no re-derivation and nothing is lost.\n */\nexport const REASONING_FOLD_ROWS = 4\n\n/** Matches `^R` shows at once. Enough to recognise one, few enough to leave the prompt on screen. */\nexport const SEARCH_ROWS = 6\n\n/**\n * Rows a single-value field may wrap to before it scrolls to follow the caret.\n *\n * Smaller than `MAX_INPUT_ROWS`, because a *value* is not a message: a wizard answer and a manifest\n * setting are one line of intent that happens to be long. Three is enough for the longest thing a\n * generated manifest holds — `tools.pinned` at 92 characters is two rows on an 80-column terminal — and\n * few enough that the field never pushes the rest of the screen around.\n *\n * There was no bound at all before, because the field passed no width: in the settings editor a long\n * value was clipped at the terminal's edge with the caret past the clip, and you could not see what you\n * were typing. The wizard escaped it — a bordered box bounds its text whatever the field passes.\n */\nexport const FIELD_ROWS = 3\n\n/**\n * Transcript items kept before the oldest are dropped.\n *\n * Load-bearing rather than prudent, and it was missing for three phases. While the conversation lived\n * in `<Static>` a finished item was written once and cost nothing afterwards; the alternate screen took\n * that away, so every item is now re-derived and re-wrapped on every frame — an unbounded buffer means\n * unbounded work per keystroke, and the case that reaches it is an agent looping tool calls overnight\n * rather than anybody typing.\n *\n * Counted in **items**, not rows, because the row count depends on the terminal width and the reducer\n * that owns the buffer is pure and has none. That does not contradict the scroll layer's rule that the\n * unit is a row: that rule is about addressing an *offset*, where paging by item steps over a forty-row\n * reply in one keystroke.\n *\n * Deliberately far past any session a person reads end to end — roughly four hundred turns — so the cap\n * is a backstop nobody meets rather than a limit that shapes ordinary use. Eviction is also gated on the\n * reader following the tail; see `TRIM` in `transcript.ts` for why that gate is not optional.\n */\nexport const MAX_TRANSCRIPT_ITEMS = 2000\n\n// ─── defaults ────────────────────────────────────────────────────────────────────────────\n\nexport const DEFAULT_ROW_LIMIT = 50\nexport const MIN_ROW_LIMIT = 1\n\n// ─── exit codes ──────────────────────────────────────────────────────────────────────────\n\nexport const EXIT_OK = 0\nexport const EXIT_FAILURE = 1\n/** 128 + SIGTERM, the shell convention. */\nexport const EXIT_SIGTERM = 143\n\n/** Rows a pane over the conversation may use — a command's output, or a hosted view. */\nexport const PANE_ROWS = 16\n\n/**\n * The fewest rows a scrolling body is ever given.\n *\n * A floor rather than a target. At eight terminal rows the chrome alone — header, composer, status —\n * accounts for most of the screen, and the alternative to a floor is a body of zero rows: a session\n * that shows the prompt and no conversation at all, which reads as a broken renderer rather than as a\n * window somebody should make taller.\n */\nexport const MIN_BODY_ROWS = 3\n\n/**\n * Rows a list may take while landing — before anything has been sent.\n *\n * Deliberately larger than `SEARCH_ROWS`, which is tuned for a live conversation where every row of list is a\n * row of conversation hidden. There is no conversation yet on the landing screen and its whole job is\n * discovery: showing six of fifteen commands behind a `… 9 below` is the wrong trade on the screen somebody\n * opens before they know what the commands are. The brand mark gives up a tier to pay for it, which the tier\n * ladder already knows how to do.\n *\n * **This tracks the size of the in-session command table**, so a phase that adds a command has to raise it —\n * which is why `commands.test.ts` asserts the relationship rather than leaving it to whoever notices the\n * `… 1 below`. It is not derived from `COMMANDS` directly because `commands.ts` reads this module, and the\n * cycle would cost more than the assertion does.\n */\nexport const LANDING_LIST_ROWS = 22\n\n/**\n * Rows of conversation the landing screen keeps, whatever the brand mark would like.\n *\n * The banner is written into the transcript, so a wordmark that squeezed it to nothing would hide the boot\n * notes and every load warning behind a picture — which is the trimmed-catalogue failure with better\n * typography: true of what is on screen, false of what is the case.\n *\n * Eight rather than four, measured against a real banner: four left the window showing the *tail* of it, so\n * the first thing on screen was the second half of a wrapped store path. The banner runs six to eight rows\n * depending on how many load warnings there are.\n */\nexport const MIN_LANDING_TRANSCRIPT = 8\n\n/**\n * How long after a press a second one still counts as a double-click.\n *\n * A terminal reports three presses and never a \"double click\", so the grouping is ours to infer — from time\n * *and* position, because two clicks 300 ms apart on different words are two clicks. 400 ms is the common\n * platform default; longer makes a deliberate second selection turn into a word-select, shorter makes a\n * real double-click fail on a slow hand.\n */\nexport const MULTI_CLICK_MS = 400\n\n/** The blank row between the brand mark and the one-line header under it. */\nexport const BRAND_GAP_ROWS = 1\n\n/** Conversations the session picker shows at once. The list scrolls inside this. */\nexport const SESSION_PICKER_ROWS = 12\n\n/**\n * How often `daemon logs --follow` checks a service log for new bytes.\n *\n * Polled rather than watched: `fs.watch` on macOS reports another process's appends unreliably, and a\n * follower that misses the line somebody is waiting for is worse than one that arrives a third of a\n * second late — the reason to watch a log live is not trusting what you have been told. Ctrl-C wakes the\n * pending sleep rather than waiting it out, so this interval never delays a stop.\n */\nexport const LOG_POLL_MS = 300\n\n/**\n * How long a ^C at an idle prompt stays armed.\n *\n * The chord is doubled rather than immediate because a single ^C means \"cancel the turn\" everywhere\n * else in this session, and the two are one keystroke apart. Long enough to be a deliberate second\n * press, short enough that an armed prompt left alone goes back to being safe.\n */\nexport const EXIT_ARM_MS = 2000\n"
|
|
5
|
+
"/**\n * Every constant the CLI uses, in one place.\n *\n * The rule is the one termheat follows: no magic number inline. A width, a limit, or a control\n * sequence buried in a component is invisible to anyone tuning behaviour later, and two copies of\n * the same number drift.\n */\n\n// ─── terminal ────────────────────────────────────────────────────────────────────────────\n\nexport const SHOW_CURSOR = \"\\u001B[?25h\"\nexport const RESET_STYLE = \"\\u001B[0m\"\n/**\n * Faint text, for the one thing written outside Ink that is not the point of the output.\n *\n * SGR 2 rather than a grey foreground: a fixed colour is wrong on half the terminals in existence,\n * and dim is the terminal's own opinion about what recedes on the theme in use. It persists across a\n * newline, so a multi-line note opens it once and resets once — and the reset lands before the final\n * newline, or the shell prompt that follows inherits it.\n */\nexport const DIM_STYLE = \"\\u001B[2m\"\n\n/**\n * The alternate screen buffer — a second, empty screen the terminal swaps in, discards on the way\n * out, and never adds to the scrollback.\n *\n * `1049` rather than the older `47`: it saves the cursor position and clears the new buffer in one\n * sequence, which is what lands the shell prompt back where it was rather than wherever the app left\n * the cursor.\n *\n * The order on the way out is easy to get backwards. A style reset applies to whichever buffer is\n * *current*, so it has to be written before the swap away — reset afterwards and any colour the app\n * left on lands on the shell's screen instead of the one being discarded. `restoreTerminal` does them\n * in that order and says so there too.\n */\nexport const ENTER_ALT_SCREEN = \"\\u001B[?1049h\"\nexport const LEAVE_ALT_SCREEN = \"\\u001B[?1049l\"\n\n/**\n * Pop the kitty keyboard protocol: `CSI < u`, the counterpart to the `CSI > flags u` Ink pushes.\n *\n * Here rather than in `lib/keyboard.ts` so the dependency runs one way — `lib/exit.ts` needs the\n * sequence and `lib/keyboard.ts` needs `markEnhancedKeys`, and only one of those two can import the\n * other. Terminal-mode sequences already live in this module, which makes this the side that moves.\n */\nexport const DISABLE_ENHANCED_KEYS = \"\\u001B[<u\"\n\n/**\n * Fallback width. A pty can genuinely report `columns === 0` — measured, under `script -q`, which\n * is how this repo drives a real TTY in a test harness. Any layout maths that divides by the\n * terminal width has to survive that.\n */\nexport const FALLBACK_COLUMNS = 80\nexport const FALLBACK_ROWS = 24\n\n/**\n * Rows the live pane may occupy before it starts showing only its tail.\n *\n * Ink erases and redraws its whole dynamic tree every frame, so an unbounded live region means\n * redrawing hundreds of lines per token. Finished messages move into `<Static>`, which is written\n * once and never touched again; this cap is what keeps the *unfinished* one cheap.\n */\nexport const LIVE_PANE_MAX_ROWS = 12\n\nexport const PROMPT = \"› \"\n\n/**\n * The width a screen is laid out for, clamped at both ends.\n *\n * The floor is where the row layout drops its description column rather than wrapping — below it\n * nothing sensible is possible, and a wrapped row is what made the first skills list unreadable. The\n * ceiling stops a 300-column window putting a description a screen away from the name it belongs to.\n *\n * Here rather than in the one command that first needed them, because every screen now shares a frame\n * and two screens clamping differently is the drift `render.ts` was written to end.\n */\nexport const MIN_SCREEN_COLUMNS = 40\nexport const MAX_SCREEN_COLUMNS = 140\n\n/** Rows a scrolling list may occupy, before and after the frame takes its share. */\nexport const MIN_SCREEN_ROWS = 8\nexport const MAX_SCREEN_ROWS = 40\n/** Header, footer, margins and the counter — what the frame costs a list. */\nexport const SCREEN_CHROME_ROWS = 8\n\n// ─── commands and input ──────────────────────────────────────────────────────────────────\n\n// The command words themselves live in `session-commands.ts`, beside the summary that documents\n// each one and the dispatch that honours it. Three bare string constants here is how the help text\n// and the parser came to disagree in the first place.\n\n/** Lines of input history kept for the up/down arrows. */\nexport const HISTORY_LIMIT = 200\n\n/**\n * Undo points kept for the input buffer.\n *\n * Bounded because a snapshot holds a whole copy of the text, and a long composing session with a\n * pasted document in it would otherwise keep every intermediate version alive for the life of the\n * process. A run of typing is one point, not one per keystroke, so this is deeper than it looks.\n */\nexport const UNDO_LIMIT = 100\n\n/**\n * Rows the input box may grow to before it scrolls internally.\n *\n * The same reasoning as `LIVE_PANE_MAX_ROWS`: the input is in Ink's dynamic region, which is erased and\n * redrawn every frame, so an unbounded box means redrawing a pasted document on every keystroke. It\n * also stops a long paste pushing the conversation off the screen.\n */\nexport const MAX_INPUT_ROWS = 10\n\n/**\n * Rows of a reasoning block shown before it folds to a count.\n *\n * Reasoning is secondary and routinely the longest item in a conversation — a real turn produced a\n * twenty-three-row block for a one-sentence answer, which filled a thirty-row terminal on its own and made\n * the reply itself something you had to scroll to find. Four rows is enough to see what it was thinking\n * about; `⌥r` shows the rest.\n *\n * Folding is a *view* decision, applied when items become rows. The whole text is always in the item, so\n * expanding needs no re-derivation and nothing is lost.\n */\nexport const REASONING_FOLD_ROWS = 4\n\n/** Matches `^R` shows at once. Enough to recognise one, few enough to leave the prompt on screen. */\nexport const SEARCH_ROWS = 6\n\n/**\n * Rows a single-value field may wrap to before it scrolls to follow the caret.\n *\n * Smaller than `MAX_INPUT_ROWS`, because a *value* is not a message: a wizard answer and a manifest\n * setting are one line of intent that happens to be long. Three is enough for the longest thing a\n * generated manifest holds — `tools.pinned` at 92 characters is two rows on an 80-column terminal — and\n * few enough that the field never pushes the rest of the screen around.\n *\n * There was no bound at all before, because the field passed no width: in the settings editor a long\n * value was clipped at the terminal's edge with the caret past the clip, and you could not see what you\n * were typing. The wizard escaped it — a bordered box bounds its text whatever the field passes.\n */\nexport const FIELD_ROWS = 3\n\n/**\n * Transcript items kept before the oldest are dropped.\n *\n * Load-bearing rather than prudent, and it was missing for three phases. While the conversation lived\n * in `<Static>` a finished item was written once and cost nothing afterwards; the alternate screen took\n * that away, so every item is now re-derived and re-wrapped on every frame — an unbounded buffer means\n * unbounded work per keystroke, and the case that reaches it is an agent looping tool calls overnight\n * rather than anybody typing.\n *\n * Counted in **items**, not rows, because the row count depends on the terminal width and the reducer\n * that owns the buffer is pure and has none. That does not contradict the scroll layer's rule that the\n * unit is a row: that rule is about addressing an *offset*, where paging by item steps over a forty-row\n * reply in one keystroke.\n *\n * Deliberately far past any session a person reads end to end — roughly four hundred turns — so the cap\n * is a backstop nobody meets rather than a limit that shapes ordinary use. Eviction is also gated on the\n * reader following the tail; see `TRIM` in `transcript.ts` for why that gate is not optional.\n */\nexport const MAX_TRANSCRIPT_ITEMS = 2000\n\n// ─── defaults ────────────────────────────────────────────────────────────────────────────\n\nexport const DEFAULT_ROW_LIMIT = 50\nexport const MIN_ROW_LIMIT = 1\n\n// ─── exit codes ──────────────────────────────────────────────────────────────────────────\n\nexport const EXIT_OK = 0\nexport const EXIT_FAILURE = 1\n/** 128 + SIGTERM, the shell convention. */\nexport const EXIT_SIGTERM = 143\n\n/** Rows a pane over the conversation may use — a command's output, or a hosted view. */\nexport const PANE_ROWS = 16\n\n/**\n * The fewest rows a scrolling body is ever given.\n *\n * A floor rather than a target. At eight terminal rows the chrome alone — header, composer, status —\n * accounts for most of the screen, and the alternative to a floor is a body of zero rows: a session\n * that shows the prompt and no conversation at all, which reads as a broken renderer rather than as a\n * window somebody should make taller.\n */\nexport const MIN_BODY_ROWS = 3\n\n/**\n * Rows a list may take while landing — before anything has been sent.\n *\n * Deliberately larger than `SEARCH_ROWS`, which is tuned for a live conversation where every row of list is a\n * row of conversation hidden. There is no conversation yet on the landing screen and its whole job is\n * discovery: showing six of fifteen commands behind a `… 9 below` is the wrong trade on the screen somebody\n * opens before they know what the commands are. The brand mark gives up a tier to pay for it, which the tier\n * ladder already knows how to do.\n *\n * **This tracks the size of the in-session command table**, so a phase that adds a command has to raise it —\n * which is why `commands.test.ts` asserts the relationship rather than leaving it to whoever notices the\n * `… 1 below`. It is not derived from `COMMANDS` directly because `commands.ts` reads this module, and the\n * cycle would cost more than the assertion does.\n */\nexport const LANDING_LIST_ROWS = 23\n\n/**\n * Rows of conversation the landing screen keeps, whatever the brand mark would like.\n *\n * The banner is written into the transcript, so a wordmark that squeezed it to nothing would hide the boot\n * notes and every load warning behind a picture — which is the trimmed-catalogue failure with better\n * typography: true of what is on screen, false of what is the case.\n *\n * Eight rather than four, measured against a real banner: four left the window showing the *tail* of it, so\n * the first thing on screen was the second half of a wrapped store path. The banner runs six to eight rows\n * depending on how many load warnings there are.\n */\nexport const MIN_LANDING_TRANSCRIPT = 8\n\n/**\n * How long after a press a second one still counts as a double-click.\n *\n * A terminal reports three presses and never a \"double click\", so the grouping is ours to infer — from time\n * *and* position, because two clicks 300 ms apart on different words are two clicks. 400 ms is the common\n * platform default; longer makes a deliberate second selection turn into a word-select, shorter makes a\n * real double-click fail on a slow hand.\n */\nexport const MULTI_CLICK_MS = 400\n\n/** The blank row between the brand mark and the one-line header under it. */\nexport const BRAND_GAP_ROWS = 1\n\n/** Conversations the session picker shows at once. The list scrolls inside this. */\nexport const SESSION_PICKER_ROWS = 12\n\n/**\n * How often `daemon logs --follow` checks a service log for new bytes.\n *\n * Polled rather than watched: `fs.watch` on macOS reports another process's appends unreliably, and a\n * follower that misses the line somebody is waiting for is worse than one that arrives a third of a\n * second late — the reason to watch a log live is not trusting what you have been told. Ctrl-C wakes the\n * pending sleep rather than waiting it out, so this interval never delays a stop.\n */\nexport const LOG_POLL_MS = 300\n\n/**\n * How long a ^C at an idle prompt stays armed.\n *\n * The chord is doubled rather than immediate because a single ^C means \"cancel the turn\" everywhere\n * else in this session, and the two are one keystroke apart. Long enough to be a deliberate second\n * press, short enough that an armed prompt left alone goes back to being safe.\n */\nexport const EXIT_ARM_MS = 2000\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAUO,IAAM,GAAc,YACd,GAAc,UASd,GAAY,UAeZ,GAAmB,cACnB,GAAmB,cASnB,GAAwB,UAOxB,EAAmB,GACnB,GAAgB,GAShB,GAAqB,GAErB,GAAS,KAYT,GAAqB,GACrB,GAAqB,IAGrB,GAAkB,EAClB,GAAkB,GAElB,GAAqB,EASrB,GAAgB,IAShB,GAAa,IASb,GAAiB,GAajB,GAAsB,EAGtB,GAAc,EAcd,GAAa,EAoBb,GAAuB,KAIvB,GAAoB,GACpB,GAAgB,EAIhB,EAAU,EACV,EAAe,EAEf,GAAe,IAarB,IAAM,GAAgB,EAgBhB,GAAoB,GAapB,GAAyB,EAUzB,GAAiB,IAGjB,GAAiB,EAGjB,GAAsB,GAUtB,GAAc,IASd,GAAc",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "3045ED20F41AFFDF64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{mi}from"./index-zn24991r.js";var c=[{title:"Specs and planning",skills:["prd","breakdown-feature-prd","breakdown-epic-pm","breakdown-feature-implementation","breakdown-plan","create-implementation-plan","create-specification","create-architectural-decision-record","create-technical-spike"]},{title:"Documents",skills:["create-readme","create-tldr-page","documentation-writer","convert-plaintext-to-md","markdown-to-html"]},{title:"Communications",skills:["meeting-minutes","email-drafter","linkedin-post-formatter","daily-prep"]},{title:"Go to market",skills:["gtm-0-to-1-launch","gtm-board-and-investor-communication","gtm-enterprise-account-planning","gtm-enterprise-onboarding","gtm-operating-cadence","gtm-partnership-architecture","gtm-positioning-strategy","gtm-product-led-growth","gtm-technical-product-pricing","gtm-developer-ecosystem"]},{title:"Team and process",skills:["mentoring-juniors","impediment-prioritization","quality-playbook"]},{title:"Diagrams",skills:["napkin","excalidraw-diagram-generator","draw-io-diagram-generator","plantuml-ascii"]},{title:"Prompt craft and research",skills:["boost-prompt","autoresearch"]}],Ii=c.flatMap((e)=>e.skills);function u(e){return c.find((n)=>n.skills.includes(e))?.title}function m(e,n){let t=n.filter((a)=>a.problem===void 0);if(e.curated===void 0)return t;let r=new Set(e.curated);return t.filter((a)=>r.has(a.skill)||r.has(g(a.repoPath)))}function g(e){let n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function ui(e){let n=[];for(let t of e){let r=m(t.spec,t.entries);if(r.length===0)continue;let a=new Set(t.installed??[]);n.push({kind:"source",label:`${t.spec.name} ${r.length} skill${r.length===1?"":"s"}`});let s=new Map,d=[];for(let o of r){let i=t.spec.curated===void 0?void 0:u(o.skill);if(i===void 0)d.push(o);else{let l=s.get(i);if(l===void 0)s.set(i,[o]);else l.push(o)}}for(let o of d)n.push(p(o,a));for(let[o,i]of s){n.push({kind:"group",label:o});for(let l of i)n.push(p(l,a))}}return n}function p(e,n){return{kind:"item",label:e.skill,meta:mi(e.tokens,e.scripts.length,n.has(e.skill)),description:f(e.description),entry:e}}function f(e){let n=e.replace(/\s+/g," ").trim(),t=n.search(/\.\s/);return t===-1?n:n.slice(0,t+1)}function NA(e){return e.map((n)=>n.kind==="item")}function Ht(e,n){return n.map((t)=>e[t]?.entry).filter((t)=>t!==void 0)}function WA(e){let n=e.filter((t)=>t.ok);return{installed:n.map((t)=>t.name),failed:e.filter((t)=>!t.ok).map((t)=>({name:t.name,reason:t.reason??"not installed"})),runnable:n.reduce((t,r)=>t+r.runnable.length,0),withCode:n.filter((t)=>t.runnable.length>0).length,total:e.length}}
|
|
3
|
+
export{Ii,ui,NA,Ht,WA};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
//# debugId=EDA564BA3D24761264756E2164756E21
|
|
6
|
+
//# sourceMappingURL=index-3km1jwh7.js.map
|