dispach 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +596 -0
- package/dist/App-dxqm39zx.js +11 -0
- package/dist/App-dxqm39zx.js.map +25 -0
- package/dist/ConfigEditor-7v5nebvy.js +6 -0
- package/dist/ConfigEditor-7v5nebvy.js.map +11 -0
- package/dist/KeyProbe-vjhmdpx6.js +5 -0
- package/dist/KeyProbe-vjhmdpx6.js.map +11 -0
- package/dist/Picker-jxaesaxy.js +5 -0
- package/dist/Picker-jxaesaxy.js.map +10 -0
- package/dist/SessionPicker-z2t0p4b5.js +5 -0
- package/dist/SessionPicker-z2t0p4b5.js.map +11 -0
- package/dist/SkillBrowser-yyf2gy0q.js +5 -0
- package/dist/SkillBrowser-yyf2gy0q.js.map +11 -0
- package/dist/WizardApp-12ndxgqv.js +5 -0
- package/dist/WizardApp-12ndxgqv.js.map +13 -0
- package/dist/agents.d.ts +9 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/browse.d.ts +63 -0
- package/dist/browse.d.ts.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +34 -0
- package/dist/client.js.map +11 -0
- package/dist/components/App.d.ts +28 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/Banner.d.ts +16 -0
- package/dist/components/Banner.d.ts.map +1 -0
- package/dist/components/Brandmark.d.ts +31 -0
- package/dist/components/Brandmark.d.ts.map +1 -0
- package/dist/components/CheckList.d.ts +38 -0
- package/dist/components/CheckList.d.ts.map +1 -0
- package/dist/components/CommandOutput.d.ts +29 -0
- package/dist/components/CommandOutput.d.ts.map +1 -0
- package/dist/components/ConfigEditor.d.ts +64 -0
- package/dist/components/ConfigEditor.d.ts.map +1 -0
- package/dist/components/HistorySearch.d.ts +23 -0
- package/dist/components/HistorySearch.d.ts.map +1 -0
- package/dist/components/KeyProbe.d.ts +36 -0
- package/dist/components/KeyProbe.d.ts.map +1 -0
- package/dist/components/LineCursor.d.ts +55 -0
- package/dist/components/LineCursor.d.ts.map +1 -0
- package/dist/components/Live.d.ts +17 -0
- package/dist/components/Live.d.ts.map +1 -0
- package/dist/components/Palette.d.ts +21 -0
- package/dist/components/Palette.d.ts.map +1 -0
- package/dist/components/Picker.d.ts +23 -0
- package/dist/components/Picker.d.ts.map +1 -0
- package/dist/components/Prompt.d.ts +20 -0
- package/dist/components/Prompt.d.ts.map +1 -0
- package/dist/components/Screen.d.ts +39 -0
- package/dist/components/Screen.d.ts.map +1 -0
- package/dist/components/SelectList.d.ts +34 -0
- package/dist/components/SelectList.d.ts.map +1 -0
- package/dist/components/SessionPicker.d.ts +26 -0
- package/dist/components/SessionPicker.d.ts.map +1 -0
- package/dist/components/SkillBrowser.d.ts +39 -0
- package/dist/components/SkillBrowser.d.ts.map +1 -0
- package/dist/components/Spinner.d.ts +13 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/StatusBar.d.ts +11 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/SummaryCard.d.ts +11 -0
- package/dist/components/SummaryCard.d.ts.map +1 -0
- package/dist/components/TextField.d.ts +39 -0
- package/dist/components/TextField.d.ts.map +1 -0
- package/dist/components/Transcript.d.ts +23 -0
- package/dist/components/Transcript.d.ts.map +1 -0
- package/dist/components/WizardApp.d.ts +18 -0
- package/dist/components/WizardApp.d.ts.map +1 -0
- package/dist/components/WizardFrame.d.ts +19 -0
- package/dist/components/WizardFrame.d.ts.map +1 -0
- package/dist/config-yz0nz51b.js +24 -0
- package/dist/config-yz0nz51b.js.map +10 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/credential-wgt4gvcz.js +19 -0
- package/dist/credential-wgt4gvcz.js.map +10 -0
- package/dist/credential.d.ts +68 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/daemon.d.ts +47 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/editor.d.ts +81 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/hooks/useElapsed.d.ts +10 -0
- package/dist/hooks/useElapsed.d.ts.map +1 -0
- package/dist/hooks/useTerminalSize.d.ts +14 -0
- package/dist/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/hooks/useTurn.d.ts +41 -0
- package/dist/hooks/useTurn.d.ts.map +1 -0
- package/dist/index-2cvtz0fy.js +903 -0
- package/dist/index-2cvtz0fy.js.map +194 -0
- package/dist/index-3nwfz9jq.js +12 -0
- package/dist/index-3nwfz9jq.js.map +11 -0
- package/dist/index-6b7qvh1x.js +6 -0
- package/dist/index-6b7qvh1x.js.map +10 -0
- package/dist/index-6z0yr17z.js +12 -0
- package/dist/index-6z0yr17z.js.map +11 -0
- package/dist/index-7da4fqcr.js +7 -0
- package/dist/index-7da4fqcr.js.map +11 -0
- package/dist/index-8bmhd2hj.js +6 -0
- package/dist/index-8bmhd2hj.js.map +10 -0
- package/dist/index-9d011p3q.js +6 -0
- package/dist/index-9d011p3q.js.map +10 -0
- package/dist/index-9f9pp2ef.js +6 -0
- package/dist/index-9f9pp2ef.js.map +10 -0
- package/dist/index-9nsfs0vy.js +6 -0
- package/dist/index-9nsfs0vy.js.map +10 -0
- package/dist/index-9pj1ws0p.js +77 -0
- package/dist/index-9pj1ws0p.js.map +12 -0
- package/dist/index-b5wwtxzk.js +66 -0
- package/dist/index-b5wwtxzk.js.map +12 -0
- package/dist/index-b8zwg8a3.js +6 -0
- package/dist/index-b8zwg8a3.js.map +10 -0
- package/dist/index-bry9bzt3.js +427 -0
- package/dist/index-bry9bzt3.js.map +11 -0
- package/dist/index-bwckzbf8.js +6 -0
- package/dist/index-bwckzbf8.js.map +10 -0
- package/dist/index-cx3vz7sf.js +6 -0
- package/dist/index-cx3vz7sf.js.map +11 -0
- package/dist/index-e8n70sgj.js +6 -0
- package/dist/index-e8n70sgj.js.map +11 -0
- package/dist/index-fvhg0xyd.js +167 -0
- package/dist/index-fvhg0xyd.js.map +19 -0
- package/dist/index-gbnc99j8.js +14 -0
- package/dist/index-gbnc99j8.js.map +13 -0
- package/dist/index-h2yds678.js +7 -0
- package/dist/index-h2yds678.js.map +11 -0
- package/dist/index-j97vttdt.js +10 -0
- package/dist/index-j97vttdt.js.map +10 -0
- package/dist/index-jk0def33.js +6 -0
- package/dist/index-jk0def33.js.map +12 -0
- package/dist/index-jym27m75.js +6 -0
- package/dist/index-jym27m75.js.map +10 -0
- package/dist/index-mgdgx22q.js +10 -0
- package/dist/index-mgdgx22q.js.map +10 -0
- package/dist/index-mrtb5y08.js +6 -0
- package/dist/index-mrtb5y08.js.map +11 -0
- package/dist/index-my5cjx00.js +6 -0
- package/dist/index-my5cjx00.js.map +10 -0
- package/dist/index-qc2vrq9z.js +7 -0
- package/dist/index-qc2vrq9z.js.map +11 -0
- package/dist/index-rqbtm761.js +6 -0
- package/dist/index-rqbtm761.js.map +10 -0
- package/dist/index-rqzg861g.js +6 -0
- package/dist/index-rqzg861g.js.map +10 -0
- package/dist/index-t1xvacym.js +6 -0
- package/dist/index-t1xvacym.js.map +11 -0
- package/dist/index-xgqzk5cq.js +9 -0
- package/dist/index-xgqzk5cq.js.map +12 -0
- package/dist/index-xqyms08r.js +6 -0
- package/dist/index-xqyms08r.js.map +10 -0
- package/dist/index-yr25dnf5.js +6 -0
- package/dist/index-yr25dnf5.js.map +10 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +527 -0
- package/dist/index.js.map +48 -0
- package/dist/init.d.ts +34 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/keymap.d.ts +126 -0
- package/dist/keymap.d.ts.map +1 -0
- package/dist/keys.d.ts +17 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/lib/ambient.d.ts +69 -0
- package/dist/lib/ambient.d.ts.map +1 -0
- package/dist/lib/args.d.ts +33 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/bootstrap.d.ts +84 -0
- package/dist/lib/bootstrap.d.ts.map +1 -0
- package/dist/lib/browse.d.ts +89 -0
- package/dist/lib/browse.d.ts.map +1 -0
- package/dist/lib/browser.d.ts +55 -0
- package/dist/lib/browser.d.ts.map +1 -0
- package/dist/lib/chat-frame.d.ts +156 -0
- package/dist/lib/chat-frame.d.ts.map +1 -0
- package/dist/lib/clipboard.d.ts +32 -0
- package/dist/lib/clipboard.d.ts.map +1 -0
- package/dist/lib/commands.d.ts +26 -0
- package/dist/lib/commands.d.ts.map +1 -0
- package/dist/lib/composer.d.ts +85 -0
- package/dist/lib/composer.d.ts.map +1 -0
- package/dist/lib/config-apply.d.ts +51 -0
- package/dist/lib/config-apply.d.ts.map +1 -0
- package/dist/lib/config-editor.d.ts +113 -0
- package/dist/lib/config-editor.d.ts.map +1 -0
- package/dist/lib/config-env.d.ts +110 -0
- package/dist/lib/config-env.d.ts.map +1 -0
- package/dist/lib/config-rows.d.ts +37 -0
- package/dist/lib/config-rows.d.ts.map +1 -0
- package/dist/lib/config-view.d.ts +133 -0
- package/dist/lib/config-view.d.ts.map +1 -0
- package/dist/lib/confirm.d.ts +86 -0
- package/dist/lib/confirm.d.ts.map +1 -0
- package/dist/lib/const.d.ts +213 -0
- package/dist/lib/const.d.ts.map +1 -0
- package/dist/lib/csi.d.ts +70 -0
- package/dist/lib/csi.d.ts.map +1 -0
- package/dist/lib/curated.d.ts +44 -0
- package/dist/lib/curated.d.ts.map +1 -0
- package/dist/lib/daemon-plan.d.ts +151 -0
- package/dist/lib/daemon-plan.d.ts.map +1 -0
- package/dist/lib/dotenv-edit.d.ts +30 -0
- package/dist/lib/dotenv-edit.d.ts.map +1 -0
- package/dist/lib/env.d.ts +10 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/exit.d.ts +170 -0
- package/dist/lib/exit.d.ts.map +1 -0
- package/dist/lib/help.d.ts +10 -0
- package/dist/lib/help.d.ts.map +1 -0
- package/dist/lib/init-flow.d.ts +539 -0
- package/dist/lib/init-flow.d.ts.map +1 -0
- package/dist/lib/init-skills.d.ts +46 -0
- package/dist/lib/init-skills.d.ts.map +1 -0
- package/dist/lib/keyboard.d.ts +76 -0
- package/dist/lib/keyboard.d.ts.map +1 -0
- package/dist/lib/keys-view.d.ts +57 -0
- package/dist/lib/keys-view.d.ts.map +1 -0
- package/dist/lib/launchd.d.ts +151 -0
- package/dist/lib/launchd.d.ts.map +1 -0
- package/dist/lib/lifecycle.d.ts +126 -0
- package/dist/lib/lifecycle.d.ts.map +1 -0
- package/dist/lib/log-follow.d.ts +71 -0
- package/dist/lib/log-follow.d.ts.map +1 -0
- package/dist/lib/mouse.d.ts +84 -0
- package/dist/lib/mouse.d.ts.map +1 -0
- package/dist/lib/multiselect.d.ts +37 -0
- package/dist/lib/multiselect.d.ts.map +1 -0
- package/dist/lib/origins.d.ts +40 -0
- package/dist/lib/origins.d.ts.map +1 -0
- package/dist/lib/output.d.ts +29 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/palette.d.ts +69 -0
- package/dist/lib/palette.d.ts.map +1 -0
- package/dist/lib/probe.d.ts +158 -0
- package/dist/lib/probe.d.ts.map +1 -0
- package/dist/lib/providers.d.ts +63 -0
- package/dist/lib/providers.d.ts.map +1 -0
- package/dist/lib/provision.d.ts +163 -0
- package/dist/lib/provision.d.ts.map +1 -0
- package/dist/lib/remove-plan.d.ts +120 -0
- package/dist/lib/remove-plan.d.ts.map +1 -0
- package/dist/lib/render.d.ts +78 -0
- package/dist/lib/render.d.ts.map +1 -0
- package/dist/lib/resume.d.ts +69 -0
- package/dist/lib/resume.d.ts.map +1 -0
- package/dist/lib/rows.d.ts +69 -0
- package/dist/lib/rows.d.ts.map +1 -0
- package/dist/lib/sandbox.d.ts +101 -0
- package/dist/lib/sandbox.d.ts.map +1 -0
- package/dist/lib/schema.d.ts +491 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/screen.d.ts +102 -0
- package/dist/lib/screen.d.ts.map +1 -0
- package/dist/lib/scroll.d.ts +64 -0
- package/dist/lib/scroll.d.ts.map +1 -0
- package/dist/lib/select.d.ts +23 -0
- package/dist/lib/select.d.ts.map +1 -0
- package/dist/lib/service-env.d.ts +38 -0
- package/dist/lib/service-env.d.ts.map +1 -0
- package/dist/lib/service.d.ts +102 -0
- package/dist/lib/service.d.ts.map +1 -0
- package/dist/lib/session-commands.d.ts +229 -0
- package/dist/lib/session-commands.d.ts.map +1 -0
- package/dist/lib/session-key.d.ts +55 -0
- package/dist/lib/session-key.d.ts.map +1 -0
- package/dist/lib/sessions-view.d.ts +31 -0
- package/dist/lib/sessions-view.d.ts.map +1 -0
- package/dist/lib/source-cache.d.ts +105 -0
- package/dist/lib/source-cache.d.ts.map +1 -0
- package/dist/lib/source.d.ts +281 -0
- package/dist/lib/source.d.ts.map +1 -0
- package/dist/lib/sources.d.ts +107 -0
- package/dist/lib/sources.d.ts.map +1 -0
- package/dist/lib/spawn.d.ts +56 -0
- package/dist/lib/spawn.d.ts.map +1 -0
- package/dist/lib/stdin-tap.d.ts +41 -0
- package/dist/lib/stdin-tap.d.ts.map +1 -0
- package/dist/lib/subcommand.d.ts +57 -0
- package/dist/lib/subcommand.d.ts.map +1 -0
- package/dist/lib/systemd.d.ts +60 -0
- package/dist/lib/systemd.d.ts.map +1 -0
- package/dist/lib/templates.d.ts +35 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/terminal.d.ts +98 -0
- package/dist/lib/terminal.d.ts.map +1 -0
- package/dist/lib/text-selection.d.ts +75 -0
- package/dist/lib/text-selection.d.ts.map +1 -0
- package/dist/lib/theme.d.ts +90 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/types.d.ts +467 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/warnings.d.ts +79 -0
- package/dist/lib/warnings.d.ts.map +1 -0
- package/dist/lib/width.d.ts +39 -0
- package/dist/lib/width.d.ts.map +1 -0
- package/dist/lib/wizard.d.ts +95 -0
- package/dist/lib/wizard.d.ts.map +1 -0
- package/dist/lib/wordmark.d.ts +60 -0
- package/dist/lib/wordmark.d.ts.map +1 -0
- package/dist/lib/wrap.d.ts +74 -0
- package/dist/lib/wrap.d.ts.map +1 -0
- package/dist/memory.d.ts +25 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/model.d.ts +47 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/plugins.d.ts +15 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/remove.d.ts +52 -0
- package/dist/remove.d.ts.map +1 -0
- package/dist/run.d.ts +42 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/schedules.d.ts +41 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/serve.d.ts +41 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/sessions.d.ts +13 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/skills.d.ts +80 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/soul.d.ts +19 -0
- package/dist/soul.d.ts.map +1 -0
- package/dist/sources.d.ts +32 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/start.d.ts +26 -0
- package/dist/start.d.ts.map +1 -0
- package/dist/stop.d.ts +58 -0
- package/dist/stop.d.ts.map +1 -0
- package/dist/terminal-setup.d.ts +31 -0
- package/dist/terminal-setup.d.ts.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/transcript.d.ts +124 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/validate.d.ts +36 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/web-w7r68df1.js +14 -0
- package/dist/web-w7r68df1.js.map +11 -0
- package/dist/web.d.ts +36 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +33 -0
- package/dist/wire.js.map +10 -0
- package/dist/workspace.d.ts +19 -0
- package/dist/workspace.d.ts.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetching a source, and reading the skills out of it. The only place in the CLI that reaches a network.
|
|
3
|
+
*
|
|
4
|
+
* ## Git, and the two-minute hang that shaped this file
|
|
5
|
+
*
|
|
6
|
+
* `git ls-remote https://github.com/github/skills` — a repository that does not exist — did not fail.
|
|
7
|
+
* It sat for two minutes waiting for a credential prompt on a terminal nobody was watching, because a
|
|
8
|
+
* 404 on a private-or-absent repo is indistinguishable from "you are not logged in yet". So every
|
|
9
|
+
* invocation here runs with prompting switched off in all four ways git can be asked
|
|
10
|
+
* (`GIT_TERMINAL_PROMPT`, `GIT_ASKPASS`, `SSH_ASKPASS`, `BatchMode`) **and** under a wall-clock
|
|
11
|
+
* timeout. A command that cannot fail is worse than one that fails slowly.
|
|
12
|
+
*
|
|
13
|
+
* The user's own git config is deliberately left alone — `GIT_CONFIG_NOSYSTEM` would drop the
|
|
14
|
+
* credential helper, which is exactly how a private source is meant to work.
|
|
15
|
+
*
|
|
16
|
+
* ## Blobless and sparse, measured
|
|
17
|
+
*
|
|
18
|
+
* `git clone --depth 1 --single-branch --filter=blob:none --sparse` then `sparse-checkout set <path>`.
|
|
19
|
+
* On `github/awesome-copilot`: 100 MB of repository becomes 22 MB on disk in 9 s, with all 425 skills
|
|
20
|
+
* present. A plain shallow clone of the same repo is the full 100 MB, for the same 425 files. The
|
|
21
|
+
* filter is refused by some servers, so a failure retries without it rather than reporting one.
|
|
22
|
+
*
|
|
23
|
+
* ## Update is re-clone, on purpose
|
|
24
|
+
*
|
|
25
|
+
* One code path instead of `fetch` + `reset --hard` + reconciling sparse state, and one thing that
|
|
26
|
+
* cannot happen: a cache in a half-updated shape nobody can reason about. Every fetch lands in
|
|
27
|
+
* `<name>.partial` and is renamed into place only once it has worked, so an interrupted update leaves
|
|
28
|
+
* the previous catalogue intact and searchable — and an interrupted *first* fetch leaves no directory
|
|
29
|
+
* at all, rather than an empty repo that looks like a source with no skills in it.
|
|
30
|
+
*/
|
|
31
|
+
import { type SourceSpec } from "#lib/sources";
|
|
32
|
+
/** Long enough for a 100 MB repository on a slow link; short enough to be a failure, not a hang. */
|
|
33
|
+
export declare const FETCH_TIMEOUT_MS = 180000;
|
|
34
|
+
export interface GitResult {
|
|
35
|
+
readonly code: number;
|
|
36
|
+
readonly stdout: string;
|
|
37
|
+
readonly stderr: string;
|
|
38
|
+
/** True when the process was killed by the timeout rather than exiting on its own. */
|
|
39
|
+
readonly timedOut?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Injected by the tests, which never reach a network.
|
|
43
|
+
*
|
|
44
|
+
* Async, and that is load-bearing rather than stylistic: `spawnSync` inside a rendered screen freezes the
|
|
45
|
+
* whole app — no spinner frame advances, and the keys pressed during a twenty-second clone are echoed by
|
|
46
|
+
* the tty instead of being consumed, which is how `^[[B^[[A` was printed into a fetch progress line.
|
|
47
|
+
*/
|
|
48
|
+
export type Git = (args: readonly string[], cwd?: string) => Promise<GitResult>;
|
|
49
|
+
export declare const realGit: Git;
|
|
50
|
+
/** One skill as it exists in a source, before anything is copied. */
|
|
51
|
+
export interface CatalogueEntry {
|
|
52
|
+
readonly source: string;
|
|
53
|
+
/** The frontmatter `name`, which is what it will be installed as. */
|
|
54
|
+
readonly skill: string;
|
|
55
|
+
/** Absolute path in the cache. */
|
|
56
|
+
readonly dir: string;
|
|
57
|
+
/** Path inside the repository, recorded as provenance on install. */
|
|
58
|
+
readonly repoPath: string;
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly tokens: number;
|
|
61
|
+
/** Files that would run: an executable bit, or a script extension. A trust signal, not a count. */
|
|
62
|
+
readonly scripts: readonly string[];
|
|
63
|
+
/** Present when the folder holds a `SKILL.md` that will not load. Listed anyway, honestly. */
|
|
64
|
+
readonly problem?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface SourceMeta {
|
|
67
|
+
readonly commit?: string;
|
|
68
|
+
readonly fetchedAt?: string;
|
|
69
|
+
readonly skills?: number;
|
|
70
|
+
}
|
|
71
|
+
export declare function readMeta(name: string, env?: Readonly<Record<string, string | undefined>>): SourceMeta;
|
|
72
|
+
export declare function isCached(name: string, env?: Readonly<Record<string, string | undefined>>): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* True when a skill reference should be read as a path on disk instead.
|
|
75
|
+
*
|
|
76
|
+
* Filesystem-first, which is git's pathspec rule and the one `resolveAgentRef` already follows. The three
|
|
77
|
+
* prefixes are checked *before* existence so a mistyped `./skils/pdf` is reported as a missing directory
|
|
78
|
+
* rather than as an unknown skill — the two failures have completely different remedies.
|
|
79
|
+
*/
|
|
80
|
+
export declare function looksLikePath(ref: string): boolean;
|
|
81
|
+
export interface FetchResult {
|
|
82
|
+
readonly commit: string;
|
|
83
|
+
readonly skills: number;
|
|
84
|
+
/** True when the partial-clone filter was refused and a full shallow clone was used instead. */
|
|
85
|
+
readonly unfiltered: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Clone or re-clone a source into the cache.
|
|
89
|
+
*
|
|
90
|
+
* Failure throws with git's own stderr attached: it is almost always the useful part — a wrong branch
|
|
91
|
+
* name, a repository that needs credentials, a host that is down — and paraphrasing it would lose the
|
|
92
|
+
* one sentence that says which.
|
|
93
|
+
*/
|
|
94
|
+
export declare function fetchSource(spec: SourceSpec, options?: {
|
|
95
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
96
|
+
readonly git?: Git;
|
|
97
|
+
}): Promise<FetchResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Every skill in a fetched source.
|
|
100
|
+
*
|
|
101
|
+
* Reads whole files rather than only frontmatter, because the token count is a property of the body and
|
|
102
|
+
* it is the number that decides whether a skill can be installed at all. 425 skills is a few megabytes.
|
|
103
|
+
*/
|
|
104
|
+
export declare function readCatalogue(spec: SourceSpec, env?: Readonly<Record<string, string | undefined>>): readonly CatalogueEntry[];
|
|
105
|
+
//# sourceMappingURL=source-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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
|
5
|
+
*
|
|
6
|
+
* `run` built a `Runtime` in its own process and handed the resulting `Agent` and `EventBus`
|
|
7
|
+
* straight to the screen. That was right while the CLI *was* the product; it stopped being right
|
|
8
|
+
* the moment a server is always on, because `run` then starts a **second** runtime for an agent
|
|
9
|
+
* something else is already hosting. Two processes on one SQLite file is not two views of one
|
|
10
|
+
* conversation — it is two writers, and slot 2 told the model as much (`declined`, decision 5.17),
|
|
11
|
+
* which is the runtime being honest about a situation nobody wanted.
|
|
12
|
+
*
|
|
13
|
+
* So the screen takes an `AgentSource` instead. `embeddedSource` is today's behaviour, for the
|
|
14
|
+
* cases where nothing else is hosting: a container, CI, `--ephemeral`, a machine whose bootstrap
|
|
15
|
+
* was suppressed. `remoteSource` is the same shape over `/v1`, and is what a terminal gets when a
|
|
16
|
+
* live host holds the agent.
|
|
17
|
+
*
|
|
18
|
+
* ## Why the two implementations are small
|
|
19
|
+
*
|
|
20
|
+
* Because the *views* were already projections. `toolsView` takes a structural `AgentToolsSource`
|
|
21
|
+
* rather than an `Agent`, `ContextView` and `SessionRowSource` are plain data, and `endNote` lives
|
|
22
|
+
* in core precisely so four callers cannot word a turn's ending four ways. Almost nothing here
|
|
23
|
+
* formats anything; it fetches, and hands back the shapes the formatters already read.
|
|
24
|
+
*
|
|
25
|
+
* ## The one thing that is genuinely different
|
|
26
|
+
*
|
|
27
|
+
* **Cancellation.** Embedded, a turn is an in-process promise and an `AbortController` reaches it.
|
|
28
|
+
* Attached, the turn belongs to the server — the recorded rule is that turns are detached from the
|
|
29
|
+
* client connection and are never cancelled on disconnect — so stopping one is a *request*, naming
|
|
30
|
+
* the turn. `send` takes a signal on both paths and each honours it its own way, so the caller
|
|
31
|
+
* keeps one contract and `useTurn` never learns which it is talking to.
|
|
32
|
+
*/
|
|
33
|
+
import type { AnyEvent, ErrorDetail, StreamFilter, TurnEndReason } from "@dispach/core";
|
|
34
|
+
import { type ContextView, type ToolsView } from "#lib/session-commands";
|
|
35
|
+
import type { PriorMessage } from "#transcript";
|
|
36
|
+
/** The facts a banner, a status line and a reasoning decision are made from. */
|
|
37
|
+
export interface SourceDescription {
|
|
38
|
+
readonly agentId: string;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly model: string;
|
|
41
|
+
readonly dialect: string;
|
|
42
|
+
readonly window: number;
|
|
43
|
+
/** What the catalogue costs per turn — the figure `/tools` reports and a person trims against. */
|
|
44
|
+
readonly catalogueTokens: number;
|
|
45
|
+
/** `"none"` when the model does not reason, which is what decides streaming it by default. */
|
|
46
|
+
readonly thinking: string;
|
|
47
|
+
readonly warnings: readonly ErrorDetail[];
|
|
48
|
+
}
|
|
49
|
+
/** One conversation, as the session picker reads it. */
|
|
50
|
+
export interface SourceSession {
|
|
51
|
+
readonly sessionKey: string;
|
|
52
|
+
readonly channel: string;
|
|
53
|
+
readonly turns: number;
|
|
54
|
+
readonly messages: number;
|
|
55
|
+
readonly lastActivityAt: string;
|
|
56
|
+
readonly phase?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface SendOptions {
|
|
59
|
+
readonly sessionKey: string;
|
|
60
|
+
readonly signal: AbortSignal;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* How a turn ended, in the shape both renderers already read.
|
|
64
|
+
*
|
|
65
|
+
* `send` resolves with this rather than `void` because the plain path needs it: `endNote` takes a
|
|
66
|
+
* reason and a step count, `endedBadly` decides the exit status, and the stats line is the one
|
|
67
|
+
* thing a scripted run prints that is not the reply. Attached, every field comes off `turn.end`
|
|
68
|
+
* and the `error` event rather than out of a returned object — which is the same information, and
|
|
69
|
+
* is why this is a shape rather than core's `TurnResult`.
|
|
70
|
+
*/
|
|
71
|
+
export interface TurnOutcome {
|
|
72
|
+
/** The reply. Empty on the streaming path, where it has already been written out. */
|
|
73
|
+
readonly text: string;
|
|
74
|
+
readonly reason: TurnEndReason;
|
|
75
|
+
readonly steps: number;
|
|
76
|
+
readonly durationMs: number;
|
|
77
|
+
readonly tokens: {
|
|
78
|
+
readonly prompt: number;
|
|
79
|
+
readonly output: number;
|
|
80
|
+
};
|
|
81
|
+
readonly error?: ErrorDetail;
|
|
82
|
+
}
|
|
83
|
+
export interface AgentSource {
|
|
84
|
+
/**
|
|
85
|
+
* Which of the two this is.
|
|
86
|
+
*
|
|
87
|
+
* Read by the banner and by `/status`, never to choose behaviour — a caller branching on this
|
|
88
|
+
* is a caller that should have been given a method. The one legitimate use is telling somebody
|
|
89
|
+
* what they are looking at, and that is exactly the sentence a person needs when the same
|
|
90
|
+
* command does two things.
|
|
91
|
+
*/
|
|
92
|
+
readonly kind: "embedded" | "attached";
|
|
93
|
+
readonly agentId: string;
|
|
94
|
+
/** Where the agent actually runs, when it is somewhere else. */
|
|
95
|
+
readonly host?: {
|
|
96
|
+
readonly baseUrl: string;
|
|
97
|
+
readonly pid: number;
|
|
98
|
+
};
|
|
99
|
+
describe(): SourceDescription;
|
|
100
|
+
/**
|
|
101
|
+
* Every event for this runtime, chunks included. Returns the unsubscribe.
|
|
102
|
+
*
|
|
103
|
+
* Chunks are not optional and never have been: this is the one wildcard subscriber in the tree
|
|
104
|
+
* that genuinely wants per-token frames, which is why they are opt-in everywhere else. Dropping
|
|
105
|
+
* the flag does not break anything loudly — the TUI simply stops streaming.
|
|
106
|
+
*/
|
|
107
|
+
subscribe(handler: (event: AnyEvent) => void): () => void;
|
|
108
|
+
/** Resolves when the turn has ended, on both paths, so `busy` means the same thing. */
|
|
109
|
+
send(text: string, options: SendOptions): Promise<TurnOutcome>;
|
|
110
|
+
/**
|
|
111
|
+
* A fresh filter for the dialect in use.
|
|
112
|
+
*
|
|
113
|
+
* The wire carries **unfiltered** chunks — deliberately, since a stream nobody has filtered is
|
|
114
|
+
* the one a debugger wants and the tool block is what the next model call sees. So an attached
|
|
115
|
+
* view does the same work the embedded one does, from the dialect its description already
|
|
116
|
+
* carries. Without it a chat bubble shows `ACTION: now / format: human / END`.
|
|
117
|
+
*/
|
|
118
|
+
streamFilter(): StreamFilter;
|
|
119
|
+
history(sessionKey: string): Promise<readonly PriorMessage[]>;
|
|
120
|
+
sessions(): Promise<readonly SourceSession[]>;
|
|
121
|
+
clearSession(sessionKey: string): Promise<void>;
|
|
122
|
+
tools(): Promise<ToolsView>;
|
|
123
|
+
context(sessionKey: string): Promise<ContextView>;
|
|
124
|
+
/**
|
|
125
|
+
* Ask the **host** to replace this agent. Present only when attached.
|
|
126
|
+
*
|
|
127
|
+
* Absent means the caller owns the runtime and rebuilds it itself, which is what `/restart` has
|
|
128
|
+
* always done — the optional method is the capability, the same way `AppProps.catalogue` and
|
|
129
|
+
* `status` are. Resolves with every agent that came back: replacing a supervisor replaces its
|
|
130
|
+
* team, because they load from one manifest as one unit.
|
|
131
|
+
*/
|
|
132
|
+
readonly reload?: () => Promise<readonly string[]>;
|
|
133
|
+
/** Release whatever this holds. Never stops the agent — an attached view owns nothing. */
|
|
134
|
+
close(): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/** The parts of a live `Agent` this needs, structurally, so a test needs no runtime. */
|
|
137
|
+
export interface EmbeddedAgent {
|
|
138
|
+
readonly id: string;
|
|
139
|
+
describe(): {
|
|
140
|
+
readonly dialect: string;
|
|
141
|
+
readonly catalogueTokens: number;
|
|
142
|
+
};
|
|
143
|
+
readonly tools: {
|
|
144
|
+
specs(): readonly {
|
|
145
|
+
readonly slug: string;
|
|
146
|
+
readonly mutating: boolean;
|
|
147
|
+
readonly trust?: string;
|
|
148
|
+
readonly trustReason?: string;
|
|
149
|
+
readonly summary: string;
|
|
150
|
+
}[];
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** The bus half, equally narrow. */
|
|
154
|
+
export interface EmbeddedBus {
|
|
155
|
+
on(type: "*", handler: (event: AnyEvent) => void, options?: {
|
|
156
|
+
readonly chunks?: boolean;
|
|
157
|
+
}): () => void;
|
|
158
|
+
}
|
|
159
|
+
/** `createNltStreamFilter` for `nlt`, a pass-through otherwise. One place decides it. */
|
|
160
|
+
export declare function filterFor(dialect: string): StreamFilter;
|
|
161
|
+
/**
|
|
162
|
+
* Today's behaviour, unchanged, behind the interface.
|
|
163
|
+
*
|
|
164
|
+
* Everything here is a one-liner over an object this process already holds, which is the point: the
|
|
165
|
+
* embedded path must not get slower or subtler for the sake of the remote one, and a reader should
|
|
166
|
+
* be able to see at a glance that nothing was smuggled in.
|
|
167
|
+
*/
|
|
168
|
+
export declare function embeddedSource(input: {
|
|
169
|
+
readonly agent: EmbeddedAgent;
|
|
170
|
+
readonly bus: EmbeddedBus;
|
|
171
|
+
/** `agent.send`, narrowed — the loop's own signature, not re-declared here. */
|
|
172
|
+
readonly send: (text: string, options: SendOptions & {
|
|
173
|
+
source: "repl";
|
|
174
|
+
}) => Promise<TurnOutcome>;
|
|
175
|
+
readonly history: (sessionKey: string) => Promise<readonly PriorMessage[]>;
|
|
176
|
+
readonly sessions: () => Promise<readonly SourceSession[]>;
|
|
177
|
+
readonly clearSession: (sessionKey: string) => Promise<void>;
|
|
178
|
+
readonly context: (sessionKey: string) => Promise<ContextView>;
|
|
179
|
+
readonly streamFilter: () => StreamFilter;
|
|
180
|
+
readonly description: SourceDescription;
|
|
181
|
+
}): AgentSource;
|
|
182
|
+
/**
|
|
183
|
+
* The same shape over `/v1`, for an agent something else is already hosting.
|
|
184
|
+
*
|
|
185
|
+
* Three things here are not translations of the embedded path, and each is a decision.
|
|
186
|
+
*
|
|
187
|
+
* **One subscription, not two.** The events come from `GET /v1/events` and the turn is followed on
|
|
188
|
+
* that same stream. Using a turn's own `/stream` as well would deliver every chunk twice, because
|
|
189
|
+
* the firehose already carries them — so `send` resolves by watching for its own `turn.end` rather
|
|
190
|
+
* than by draining a second stream.
|
|
191
|
+
*
|
|
192
|
+
* **Cancellation is a request.** Turns are detached from the client connection by design and are
|
|
193
|
+
* never cancelled on disconnect, so an abort here POSTs a stop naming the turn. It is best-effort
|
|
194
|
+
* in one specific way worth knowing: the turn id only exists once the send has been accepted, so an
|
|
195
|
+
* abort in the window before that is remembered and applied when the id arrives, rather than lost.
|
|
196
|
+
*
|
|
197
|
+
* **Filtering is ours.** The wire carries unfiltered chunks — deliberately, per the wire entry's
|
|
198
|
+
* own docstring — so this rebuilds the dialect's filter from the description it already fetched.
|
|
199
|
+
* Without it a reply renders as `ACTION: now / format: human / END`.
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* The parts of the API client this needs, structurally.
|
|
203
|
+
*
|
|
204
|
+
* Narrow for the same two reasons `EmbeddedAgent` is — a fake is a plain object, and anything else
|
|
205
|
+
* reached for is a type error rather than a surprise — and for a third: naming the client's own
|
|
206
|
+
* exported type would put the product name in a `packages/cli` source file, which hard rule 3 and
|
|
207
|
+
* a boundaries test both forbid. The real client satisfies this without being named.
|
|
208
|
+
*/
|
|
209
|
+
export interface ApiClient {
|
|
210
|
+
agent(id: string): {
|
|
211
|
+
send(text: string, options?: {
|
|
212
|
+
readonly sessionKey?: string;
|
|
213
|
+
}): Promise<{
|
|
214
|
+
readonly turnId: string;
|
|
215
|
+
}>;
|
|
216
|
+
turn(turnId: string): {
|
|
217
|
+
stop(): Promise<void>;
|
|
218
|
+
};
|
|
219
|
+
messages(sessionKey: string): Promise<{
|
|
220
|
+
readonly messages: readonly {
|
|
221
|
+
readonly role: string;
|
|
222
|
+
readonly content: string;
|
|
223
|
+
readonly origin?: string;
|
|
224
|
+
}[];
|
|
225
|
+
}>;
|
|
226
|
+
clearSession(sessionKey: string): Promise<unknown>;
|
|
227
|
+
reload(): Promise<{
|
|
228
|
+
readonly adopted: readonly string[];
|
|
229
|
+
}>;
|
|
230
|
+
tools(): Promise<readonly {
|
|
231
|
+
readonly slug: string;
|
|
232
|
+
readonly summary: string;
|
|
233
|
+
readonly mutating: boolean;
|
|
234
|
+
readonly trust: string;
|
|
235
|
+
readonly trustReason?: string;
|
|
236
|
+
}[]>;
|
|
237
|
+
sessions(): Promise<readonly SourceSession[]>;
|
|
238
|
+
context(options: {
|
|
239
|
+
readonly sessionKey: string;
|
|
240
|
+
}): Promise<unknown>;
|
|
241
|
+
};
|
|
242
|
+
events(options: {
|
|
243
|
+
readonly agentId?: string;
|
|
244
|
+
readonly chunks?: boolean;
|
|
245
|
+
readonly signal?: AbortSignal;
|
|
246
|
+
}): AsyncGenerator<{
|
|
247
|
+
readonly kind: string;
|
|
248
|
+
readonly event?: AnyEvent;
|
|
249
|
+
}>;
|
|
250
|
+
}
|
|
251
|
+
export declare function remoteSource(input: {
|
|
252
|
+
readonly client: ApiClient;
|
|
253
|
+
readonly agentId: string;
|
|
254
|
+
/** Fetched once at attach, so `describe()` can stay synchronous like the embedded one. */
|
|
255
|
+
readonly description: SourceDescription;
|
|
256
|
+
readonly host: {
|
|
257
|
+
readonly baseUrl: string;
|
|
258
|
+
readonly pid: number;
|
|
259
|
+
};
|
|
260
|
+
}): AgentSource;
|
|
261
|
+
/**
|
|
262
|
+
* Whether something else is already hosting this agent, and where.
|
|
263
|
+
*
|
|
264
|
+
* Both halves matter and neither is guessable. A lease says **who** is serving an agent right now;
|
|
265
|
+
* its `base_url` — published after the bind, cleared on takeover — says where, because a manifest's
|
|
266
|
+
* `server.port` is only what the file asked for and `--port 0` means the port does not exist until
|
|
267
|
+
* the socket does. A host serving no HTTP has a lease and no address, and cannot be attached to.
|
|
268
|
+
*
|
|
269
|
+
* `processAlive` is checked inside `liveHostOf` for the recorded reason: a lease row is a claim,
|
|
270
|
+
* not a fact, and a boot that failed *after* claiming leaves a fresh heartbeat with no process
|
|
271
|
+
* under it. A dead pid outranks a recent timestamp.
|
|
272
|
+
*/
|
|
273
|
+
export interface LiveHost {
|
|
274
|
+
readonly baseUrl: string;
|
|
275
|
+
readonly pid: number;
|
|
276
|
+
}
|
|
277
|
+
export declare function hostFrom(lease: {
|
|
278
|
+
readonly pid: number;
|
|
279
|
+
readonly baseUrl?: string;
|
|
280
|
+
} | undefined): LiveHost | undefined;
|
|
281
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.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F,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;IACvC,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CACpE,GAAG,WAAW,CAyKd;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,QAAQ,CACpB,KAAK,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACvE,QAAQ,GAAG,SAAS,CAGtB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where skills come from: a named list of repositories, machine-level and the person's.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this is not in `agent.yaml`
|
|
5
|
+
*
|
|
6
|
+
* A source is a place *you* trust, not a property of one agent. Put it in the manifest and you add a
|
|
7
|
+
* repository once per agent, and — worse — you put a fetchable URL inside the document the runtime
|
|
8
|
+
* loads at boot, which is an invitation to resolve it there. Hard rule 4 exists because the runtime
|
|
9
|
+
* this replaces spent four minutes on network calls during initialisation. Nothing here is reachable
|
|
10
|
+
* from `Runtime.create`: this module lives in the CLI, every fetch is an explicit command a person
|
|
11
|
+
* typed, and the runtime's only relationship with a source is that a directory was copied before it
|
|
12
|
+
* ever started.
|
|
13
|
+
*
|
|
14
|
+
* `skills.sources` was a manifest field reserved for this and is deliberately gone (decision 11.46).
|
|
15
|
+
* A field only a CLI reads is a field the runtime will eventually be asked to read.
|
|
16
|
+
*
|
|
17
|
+
* ## Built-ins are compiled in, never written to the file
|
|
18
|
+
*
|
|
19
|
+
* `DEFAULT_SOURCES` ships in the binary. If it were seeded into `sources.json` on first run, a repo
|
|
20
|
+
* that moves would stay broken until every user hand-edited a file, and an upgrade could not fix it.
|
|
21
|
+
* A user entry with a built-in's name overrides it; `sources remove <builtin>` records the name in
|
|
22
|
+
* `disabled` instead, because a default is an endorsement and refusing to let someone drop one would
|
|
23
|
+
* make the endorsement mandatory.
|
|
24
|
+
*/
|
|
25
|
+
/** A repository to look for skills in. */
|
|
26
|
+
export interface SourceSpec {
|
|
27
|
+
/**
|
|
28
|
+
* The nickname you install by — `install <agent> <name>/<skill>`.
|
|
29
|
+
*
|
|
30
|
+
* One path segment, so it can be a directory name in the cache and cannot be confused with the
|
|
31
|
+
* `owner/repo` shorthand a URL uses.
|
|
32
|
+
*/
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Anything `git clone` accepts. */
|
|
35
|
+
readonly url: string;
|
|
36
|
+
/**
|
|
37
|
+
* Subdirectory holding the skill folders, if the repo does not keep them at the root.
|
|
38
|
+
*
|
|
39
|
+
* Load-bearing for more than tidiness: it is what `git sparse-checkout` narrows to, and narrowing
|
|
40
|
+
* took `github/awesome-copilot` from 100 MB to 22 MB (measured). With no path the whole repository
|
|
41
|
+
* is checked out, so a source without one is a source that costs its full size.
|
|
42
|
+
*/
|
|
43
|
+
readonly path?: string;
|
|
44
|
+
/** Branch or tag. Omitted means whatever the remote's HEAD points at. */
|
|
45
|
+
readonly ref?: string;
|
|
46
|
+
/** Shipped rather than added. Never written to the registry file. */
|
|
47
|
+
readonly builtin?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Folder names to show when *browsing*, or absent to show everything.
|
|
50
|
+
*
|
|
51
|
+
* A filter on the catalogue rather than on the checkout. Narrowing the clone was the obvious
|
|
52
|
+
* optimisation and does not work: `git sparse-checkout set` given twenty `skills/<name>` paths in cone
|
|
53
|
+
* mode (git 2.55) writes them as root-level patterns and materialises one folder out of twenty. The
|
|
54
|
+
* whole `skills/` tree is 22 MB fetched once per machine and shared by every agent on it, which is not
|
|
55
|
+
* worth a git edge case.
|
|
56
|
+
*
|
|
57
|
+
* Never applied to `sources search`. Curation is a recommendation, and a search that refused to find a
|
|
58
|
+
* skill somebody named would make it a restriction.
|
|
59
|
+
*/
|
|
60
|
+
readonly curated?: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The two sources every install starts with.
|
|
64
|
+
*
|
|
65
|
+
* Both verified to exist, to use `skills/<name>/SKILL.md`, and to be readable without credentials on
|
|
66
|
+
* 2026-08-17: `anthropics/skills` carries 18 skills, `github/awesome-copilot` 425. Deliberately short
|
|
67
|
+
* — a default is an endorsement of somebody else's executable code, so the list holds the spec's own
|
|
68
|
+
* authors and one large community catalogue, and everything else is `sources add`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const DEFAULT_SOURCES: readonly SourceSpec[];
|
|
71
|
+
export declare function isSourceName(name: string): boolean;
|
|
72
|
+
export declare function registryPath(env?: Readonly<Record<string, string | undefined>>): string;
|
|
73
|
+
/** Where a source's working copy is cached. One directory per source name. */
|
|
74
|
+
export declare function cacheRoot(env?: Readonly<Record<string, string | undefined>>): string;
|
|
75
|
+
export declare function cacheDir(name: string, env?: Readonly<Record<string, string | undefined>>): string;
|
|
76
|
+
/**
|
|
77
|
+
* Every source `search` and `install` will look in: built-ins minus disabled, then user entries.
|
|
78
|
+
*
|
|
79
|
+
* Order is the resolution order for a bare skill name, so built-ins are first and a user's own
|
|
80
|
+
* additions are tried after — which is also why an overriding entry keeps the built-in's position
|
|
81
|
+
* rather than moving to the end.
|
|
82
|
+
*/
|
|
83
|
+
export declare function loadSources(env?: Readonly<Record<string, string | undefined>>): readonly SourceSpec[];
|
|
84
|
+
export declare function addSource(spec: SourceSpec, env?: Readonly<Record<string, string | undefined>>): void;
|
|
85
|
+
/** Returns false when there was nothing by that name to remove. */
|
|
86
|
+
export declare function removeSource(name: string, env?: Readonly<Record<string, string | undefined>>): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* What a person types for a repository, turned into a clone URL and — where the URL says so — a ref
|
|
89
|
+
* and a path.
|
|
90
|
+
*
|
|
91
|
+
* The browser URL case is the one that has to work: someone finding a skill collection pastes
|
|
92
|
+
* `https://github.com/anthropics/skills/tree/main/skills`, which is not a clone URL and carries two
|
|
93
|
+
* fields inside its path. Refusing it would mean the documented way to add a source is to hand-edit
|
|
94
|
+
* what GitHub put in the address bar.
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseSourceUrl(input: string): {
|
|
97
|
+
readonly url: string;
|
|
98
|
+
readonly ref?: string;
|
|
99
|
+
readonly path?: string;
|
|
100
|
+
};
|
|
101
|
+
/** A skill reference as typed: `pdf`, or `anthropic/pdf`. */
|
|
102
|
+
export interface SkillRef {
|
|
103
|
+
readonly source?: string;
|
|
104
|
+
readonly skill: string;
|
|
105
|
+
}
|
|
106
|
+
export declare function parseSkillRef(input: string): SkillRef;
|
|
107
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/lib/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,oCAAoC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,UAAU,EAehD,CAAA;AAKD,wBAAgB,YAAY,CAAC,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AAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACzB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CASrD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place in this package that starts a process.
|
|
3
|
+
*
|
|
4
|
+
* There were two callers before this file existed and the second one is what created it: `lib/service.ts`
|
|
5
|
+
* ran `launchctl`, and fetching a skill source needs `git`. The rule the boundaries test enforces is
|
|
6
|
+
* "exactly one module imports `node:child_process`", and its stated reason is that a second call site is a
|
|
7
|
+
* second place a test has to intercept — the first one that forgets reaches somebody's real machine. Two
|
|
8
|
+
* callers of one seam keeps that property; an allowlist with two entries in it loses it, and would go on
|
|
9
|
+
* losing it once per phase.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately thin, and deliberately not clever. Everything specific to a tool — git's four ways of
|
|
12
|
+
* being told not to prompt, launchd's exit-status decoding — belongs to the caller that knows about it.
|
|
13
|
+
* What lives here is "run this, capture what it said, and tell me honestly how it ended".
|
|
14
|
+
*
|
|
15
|
+
* `notFound` is a field rather than an exception because the two callers want different sentences for it:
|
|
16
|
+
* a missing `git` has a remedy the person can act on, and a missing `launchctl` means this is not the
|
|
17
|
+
* operating system the caller thought it was. A shared error message would be wrong for both.
|
|
18
|
+
*/
|
|
19
|
+
export interface SpawnRequest {
|
|
20
|
+
readonly command: string;
|
|
21
|
+
readonly args: readonly string[];
|
|
22
|
+
readonly cwd?: string;
|
|
23
|
+
/** Replaces the environment entirely when given. Callers spread `process.env` themselves. */
|
|
24
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
readonly maxBuffer?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Text to write to the child's stdin, which is then closed.
|
|
29
|
+
*
|
|
30
|
+
* Added for the clipboard: `pbcopy` reads what it copies from stdin and there is no argument form. The
|
|
31
|
+
* alternative was a temporary file, which puts whatever was selected on disk — and a selection is
|
|
32
|
+
* routinely the most sensitive thing on the screen. The seam grows rather than the caller working
|
|
33
|
+
* around it, per the rule about first-party code not getting private escape hatches.
|
|
34
|
+
*/
|
|
35
|
+
readonly input?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SpawnResult {
|
|
38
|
+
readonly code: number;
|
|
39
|
+
readonly stdout: string;
|
|
40
|
+
readonly stderr: string;
|
|
41
|
+
/** True when a timeout or a signal ended it, rather than the process choosing to exit. */
|
|
42
|
+
readonly signalled: boolean;
|
|
43
|
+
/** True when the command is not on PATH at all. */
|
|
44
|
+
readonly notFound: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function spawnCapture(request: SpawnRequest): SpawnResult;
|
|
47
|
+
/**
|
|
48
|
+
* The same thing, without blocking the event loop.
|
|
49
|
+
*
|
|
50
|
+
* Exists because `spawnSync` inside an Ink app freezes the whole terminal: no spinner frame advances, and
|
|
51
|
+
* the keypresses that arrive during a twenty-second `git clone` are echoed by the tty instead of being
|
|
52
|
+
* consumed by the app — which is how `^[[B^[[A` ended up printed in the middle of a fetch progress line.
|
|
53
|
+
* Anything a rendered screen waits on has to be awaited, not blocked on.
|
|
54
|
+
*/
|
|
55
|
+
export declare function spawnCaptureAsync(request: SpawnRequest): Promise<SpawnResult>;
|
|
56
|
+
//# sourceMappingURL=spawn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/lib/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAC3D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAC7B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAiB/D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAuD7E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-only tap on stdin, opened before Ink attaches.
|
|
3
|
+
*
|
|
4
|
+
* ## Why a tap at all
|
|
5
|
+
*
|
|
6
|
+
* `useInput` cannot tell you what the terminal sent. Two independent things need that fact:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Modifier correction.** Ink folds the super bit into `meta` on its legacy path, so `cmd+left` and
|
|
9
|
+
* `option+left` arrive as the same keystroke. `lib/csi.ts` decodes the modifier from the bytes; this is
|
|
10
|
+
* what gets the bytes to it.
|
|
11
|
+
* 2. **The `keys` probe.** For a special key Ink reports `input: ""`, so a probe built on `input` printed
|
|
12
|
+
* an empty byte row for every arrow, Home and cmd chord — the exact keys worth probing.
|
|
13
|
+
*
|
|
14
|
+
* ## Why it is safe
|
|
15
|
+
*
|
|
16
|
+
* Two listeners on one `data` event both receive the chunk; this consumes nothing from Ink. Ordering is
|
|
17
|
+
* registration order, which is why `openTap` has to be called **before** `render` — that is what
|
|
18
|
+
* guarantees a chunk is parsed and queued by the time `useInput` fires for it. Opened by the host rather
|
|
19
|
+
* than by a component for exactly that reason: a component cannot register before the renderer that mounts
|
|
20
|
+
* it.
|
|
21
|
+
*
|
|
22
|
+
* The queue is drained by *identity*, not by position (`withRealModifiers`), so an unmatched record waits
|
|
23
|
+
* for the keystroke it belongs to instead of being applied to the wrong one. A record nothing ever claims
|
|
24
|
+
* is dropped once the queue passes `MAX_QUEUED`, which keeps a terminal that emits sequences we do not
|
|
25
|
+
* recognise from growing an array for the life of the session.
|
|
26
|
+
*/
|
|
27
|
+
import type { KeyState } from "#lib/types";
|
|
28
|
+
export interface StdinTap {
|
|
29
|
+
/** The key Ink reported, with its modifiers read off the wire where they could be. */
|
|
30
|
+
correct(key: KeyState, input: string): KeyState;
|
|
31
|
+
/** The oldest unread chunk, for a probe that wants to print bytes. */
|
|
32
|
+
takeRaw(): string | undefined;
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
interface DataStream {
|
|
36
|
+
on(event: "data", listener: (chunk: Buffer | string) => void): unknown;
|
|
37
|
+
off(event: "data", listener: (chunk: Buffer | string) => void): unknown;
|
|
38
|
+
}
|
|
39
|
+
export declare function openTap(stdin?: DataStream): StdinTap;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=stdin-tap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-tap.d.ts","sourceRoot":"","sources":["../../src/lib/stdin-tap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAW1C,MAAM,WAAW,QAAQ;IACrB,sFAAsF;IACtF,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC/C,sEAAsE;IACtE,OAAO,IAAI,MAAM,GAAG,SAAS,CAAA;IAC7B,KAAK,IAAI,IAAI,CAAA;CAChB;AAED,UAAU,UAAU;IAChB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,OAAO,CAAA;IACtE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,OAAO,CAAA;CAC1E;AAED,wBAAgB,OAAO,CAAC,KAAK,GAAE,UAA0B,GAAG,QAAQ,CAqBnE"}
|