@valni/cli-darwin-x64 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +53 -0
- package/package.json +18 -5
- package/runtime/LICENSE +53 -0
- package/runtime/README.md +674 -0
- package/runtime/assets/clankolas.png +0 -0
- package/runtime/docs/extensions.md +2910 -0
- package/runtime/docs/json.md +82 -0
- package/runtime/docs/models.md +540 -0
- package/runtime/docs/packages.md +228 -0
- package/runtime/docs/rpc.md +1480 -0
- package/runtime/docs/sdk.md +1183 -0
- package/runtime/docs/session-format.md +422 -0
- package/runtime/docs/settings.md +315 -0
- package/runtime/docs/shell-aliases.md +13 -0
- package/runtime/docs/terminal-setup.md +142 -0
- package/runtime/docs/termux.md +127 -0
- package/runtime/docs/tmux.md +63 -0
- package/runtime/docs/tui.md +927 -0
- package/runtime/docs/windows.md +17 -0
- package/runtime/examples/README.md +25 -0
- package/runtime/examples/extensions/README.md +212 -0
- package/runtime/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/runtime/examples/extensions/bash-spawn-hook.ts +30 -0
- package/runtime/examples/extensions/bookmark.ts +50 -0
- package/runtime/examples/extensions/border-status-editor.ts +145 -0
- package/runtime/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/runtime/examples/extensions/claude-rules.ts +86 -0
- package/runtime/examples/extensions/commands.ts +72 -0
- package/runtime/examples/extensions/confirm-destructive.ts +59 -0
- package/runtime/examples/extensions/custom-footer.ts +64 -0
- package/runtime/examples/extensions/custom-header.ts +73 -0
- package/runtime/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/runtime/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/runtime/examples/extensions/dirty-repo-guard.ts +56 -0
- package/runtime/examples/extensions/doom-overlay/README.md +46 -0
- package/runtime/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/runtime/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/runtime/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/runtime/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/runtime/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/runtime/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/runtime/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/runtime/examples/extensions/doom-overlay/index.ts +74 -0
- package/runtime/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/runtime/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/runtime/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/runtime/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/runtime/examples/extensions/dynamic-resources/index.ts +15 -0
- package/runtime/examples/extensions/dynamic-tools.ts +74 -0
- package/runtime/examples/extensions/entry-renderer.ts +41 -0
- package/runtime/examples/extensions/event-bus.ts +43 -0
- package/runtime/examples/extensions/file-trigger.ts +41 -0
- package/runtime/examples/extensions/git-checkpoint.ts +53 -0
- package/runtime/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/runtime/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/runtime/examples/extensions/gondolin/index.ts +531 -0
- package/runtime/examples/extensions/gondolin/package-lock.json +185 -0
- package/runtime/examples/extensions/gondolin/package.json +19 -0
- package/runtime/examples/extensions/hello.ts +26 -0
- package/runtime/examples/extensions/hidden-thinking-label.ts +53 -0
- package/runtime/examples/extensions/inline-bash.ts +94 -0
- package/runtime/examples/extensions/input-transform-streaming.ts +39 -0
- package/runtime/examples/extensions/input-transform.ts +43 -0
- package/runtime/examples/extensions/interactive-shell.ts +196 -0
- package/runtime/examples/extensions/mac-system-theme.ts +47 -0
- package/runtime/examples/extensions/message-renderer.ts +59 -0
- package/runtime/examples/extensions/minimal-mode.ts +426 -0
- package/runtime/examples/extensions/modal-editor.ts +85 -0
- package/runtime/examples/extensions/model-status.ts +31 -0
- package/runtime/examples/extensions/notify.ts +55 -0
- package/runtime/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/runtime/examples/extensions/overlay-test.ts +153 -0
- package/runtime/examples/extensions/permission-gate.ts +34 -0
- package/runtime/examples/extensions/pirate.ts +47 -0
- package/runtime/examples/extensions/plan-mode/README.md +66 -0
- package/runtime/examples/extensions/plan-mode/index.ts +390 -0
- package/runtime/examples/extensions/plan-mode/utils.ts +168 -0
- package/runtime/examples/extensions/preset.ts +436 -0
- package/runtime/examples/extensions/project-trust.ts +64 -0
- package/runtime/examples/extensions/prompt-customizer.ts +97 -0
- package/runtime/examples/extensions/protected-paths.ts +30 -0
- package/runtime/examples/extensions/provider-payload.ts +18 -0
- package/runtime/examples/extensions/question.ts +278 -0
- package/runtime/examples/extensions/questionnaire.ts +440 -0
- package/runtime/examples/extensions/rainbow-editor.ts +88 -0
- package/runtime/examples/extensions/reload-runtime.ts +37 -0
- package/runtime/examples/extensions/rpc-demo.ts +118 -0
- package/runtime/examples/extensions/sandbox/index.ts +321 -0
- package/runtime/examples/extensions/sandbox/package-lock.json +92 -0
- package/runtime/examples/extensions/sandbox/package.json +19 -0
- package/runtime/examples/extensions/send-user-message.ts +97 -0
- package/runtime/examples/extensions/session-name.ts +27 -0
- package/runtime/examples/extensions/shutdown-command.ts +63 -0
- package/runtime/examples/extensions/snake.ts +343 -0
- package/runtime/examples/extensions/space-invaders.ts +560 -0
- package/runtime/examples/extensions/ssh.ts +220 -0
- package/runtime/examples/extensions/status-line.ts +32 -0
- package/runtime/examples/extensions/structured-output.ts +65 -0
- package/runtime/examples/extensions/subagent/README.md +175 -0
- package/runtime/examples/extensions/subagent/agents/planner.md +37 -0
- package/runtime/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/runtime/examples/extensions/subagent/agents/scout.md +50 -0
- package/runtime/examples/extensions/subagent/agents/worker.md +24 -0
- package/runtime/examples/extensions/subagent/agents.ts +126 -0
- package/runtime/examples/extensions/subagent/index.ts +1009 -0
- package/runtime/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/runtime/examples/extensions/subagent/prompts/implement.md +10 -0
- package/runtime/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/runtime/examples/extensions/system-prompt-header.ts +17 -0
- package/runtime/examples/extensions/tic-tac-toe.ts +1008 -0
- package/runtime/examples/extensions/timed-confirm.ts +70 -0
- package/runtime/examples/extensions/titlebar-spinner.ts +58 -0
- package/runtime/examples/extensions/todo.ts +297 -0
- package/runtime/examples/extensions/tool-override.ts +144 -0
- package/runtime/examples/extensions/tools.ts +146 -0
- package/runtime/examples/extensions/trigger-compact.ts +50 -0
- package/runtime/examples/extensions/truncated-tool.ts +195 -0
- package/runtime/examples/extensions/widget-placement.ts +9 -0
- package/runtime/examples/extensions/with-deps/index.ts +32 -0
- package/runtime/examples/extensions/with-deps/package-lock.json +31 -0
- package/runtime/examples/extensions/with-deps/package.json +22 -0
- package/runtime/examples/extensions/working-indicator.ts +123 -0
- package/runtime/examples/extensions/working-message-test.ts +25 -0
- package/runtime/examples/rpc-extension-ui.ts +632 -0
- package/runtime/examples/sdk/01-minimal.ts +26 -0
- package/runtime/examples/sdk/02-custom-model.ts +43 -0
- package/runtime/examples/sdk/03-custom-prompt.ts +70 -0
- package/runtime/examples/sdk/04-skills.ts +55 -0
- package/runtime/examples/sdk/05-tools.ts +48 -0
- package/runtime/examples/sdk/06-extensions.ts +94 -0
- package/runtime/examples/sdk/07-context-files.ts +42 -0
- package/runtime/examples/sdk/08-prompt-templates.ts +51 -0
- package/runtime/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/runtime/examples/sdk/10-settings.ts +53 -0
- package/runtime/examples/sdk/11-sessions.ts +52 -0
- package/runtime/examples/sdk/12-full-control.ts +71 -0
- package/runtime/examples/sdk/13-session-runtime.ts +67 -0
- package/runtime/examples/sdk/README.md +140 -0
- package/runtime/export-html/ansi-to-html.js +249 -0
- package/runtime/export-html/index.js +226 -0
- package/runtime/export-html/template.css +1066 -0
- package/runtime/export-html/template.html +55 -0
- package/runtime/export-html/template.js +1864 -0
- package/runtime/export-html/tool-renderer.js +108 -0
- package/runtime/export-html/vendor/highlight.min.js +1213 -0
- package/runtime/export-html/vendor/marked.min.js +78 -0
- package/runtime/extensions/pi-switchboard/.github/workflows/ci.yml +51 -0
- package/runtime/extensions/pi-switchboard/LICENSE +22 -0
- package/runtime/extensions/pi-switchboard/README.md +85 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/catalog.ts +183 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/config.ts +97 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/connections.ts +386 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/constants.ts +12 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/device-auth.ts +127 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/envelope.ts +199 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/errors.ts +180 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/index.ts +125 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/participant.ts +17 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/sessionStream.ts +131 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/toolProxy.ts +136 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/tools.ts +16 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/types.ts +37 -0
- package/runtime/extensions/pi-switchboard/package.json +30 -0
- package/runtime/extensions/pi-switchboard/tsconfig.json +13 -0
- package/runtime/extensions/switchboard-local/.github/workflows/ci.yml +80 -0
- package/runtime/extensions/switchboard-local/.github/workflows/release.yml +46 -0
- package/runtime/extensions/switchboard-local/README.md +98 -0
- package/runtime/extensions/switchboard-local/extensions/local/engine.ts +28 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/gguf.ts +324 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/llamaBuild.ts +62 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/mlx.ts +245 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/select.ts +38 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/support.ts +151 -0
- package/runtime/extensions/switchboard-local/extensions/local/hf.ts +106 -0
- package/runtime/extensions/switchboard-local/extensions/local/index.ts +67 -0
- package/runtime/extensions/switchboard-local/extensions/local/nativeStream.ts +602 -0
- package/runtime/extensions/switchboard-local/extensions/local/paths.ts +44 -0
- package/runtime/extensions/switchboard-local/extensions/local/provider.ts +57 -0
- package/runtime/extensions/switchboard-local/extensions/local/store.ts +82 -0
- package/runtime/extensions/switchboard-local/extensions/local/ui.ts +60 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/apiTypes.js +74 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/client.js +292 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/deviceAuth.js +155 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/errors.js +95 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/index.js +8 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/messages.js +253 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/models.js +19 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/native.js +886 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/wire.js +85 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/package.json +39 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/package.json +29 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/anthropic.ts +127 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/google.ts +111 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/index.ts +8 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.test.ts +25 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.ts +57 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiGeneric.ts +103 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiPro.ts +89 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/profile.ts +120 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.test.ts +82 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.ts +74 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.google.test.ts +137 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.openai.test.ts +241 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.test.ts +174 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.ts +438 -0
- package/runtime/extensions/switchboard-local/package.json +34 -0
- package/runtime/extensions/switchboard-local/tsconfig.json +13 -0
- package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/.yarnrc.yml +1 -0
- package/runtime/node_modules/@mariozechner/clipboard/Cargo.toml +45 -0
- package/runtime/node_modules/@mariozechner/clipboard/README.md +60 -0
- package/runtime/node_modules/@mariozechner/clipboard/build.rs +5 -0
- package/runtime/node_modules/@mariozechner/clipboard/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/exp.ts +12 -0
- package/runtime/node_modules/@mariozechner/clipboard/index.js +606 -0
- package/runtime/node_modules/@mariozechner/clipboard/package.json +56 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +307 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +93 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +313 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +471 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +252 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +431 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +712 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +916 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/lib.rs +194 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/README.md +3 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/package.json +22 -0
- package/runtime/package.json +104 -0
- package/runtime/photon_rs_bg.wasm +0 -0
- package/runtime/theme/dark.json +87 -0
- package/runtime/theme/light.json +86 -0
- package/runtime/theme/theme-schema.json +340 -0
- package/runtime/valni +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-extension-gondolin",
|
|
3
|
+
"version": "0.80.10",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "pi-extension-gondolin",
|
|
9
|
+
"version": "0.80.10",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@earendil-works/gondolin": "0.12.0"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"node_modules/@cto.af/wtf8": {
|
|
15
|
+
"version": "0.0.5",
|
|
16
|
+
"resolved": "https://registry.npmjs.org/@cto.af/wtf8/-/wtf8-0.0.5.tgz",
|
|
17
|
+
"integrity": "sha512-LfUFi+Vv4eDzj+XAtR89e3wwjXA/NZjUSwU5NhwbBrLecxPaBYFy3exCuc1j+D4UZeOVdqlsl8G7LmOt18V0tg==",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"node_modules/@earendil-works/gondolin": {
|
|
24
|
+
"version": "0.12.0",
|
|
25
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/gondolin/-/gondolin-0.12.0.tgz",
|
|
26
|
+
"integrity": "sha512-BXbvzQKb5QmxY5NtthRDONJTu7+IDKbzqWGrJyyNXMP7N681Tx0Q9TK8pK1ba8nUvYQTipNJyGZOsJfYiZll1A==",
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"cbor2": "^2.3.0",
|
|
30
|
+
"node-forge": "^1.3.3",
|
|
31
|
+
"ssh2": "^1.17.0",
|
|
32
|
+
"undici": "^6.21.0"
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"gondolin": "dist/bin/gondolin.js"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=23.6.0"
|
|
39
|
+
},
|
|
40
|
+
"optionalDependencies": {
|
|
41
|
+
"@earendil-works/gondolin-krun-runner-darwin-arm64": "0.12.0",
|
|
42
|
+
"@earendil-works/gondolin-krun-runner-linux-x64": "0.12.0"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"node_modules/@earendil-works/gondolin-krun-runner-darwin-arm64": {
|
|
46
|
+
"version": "0.12.0",
|
|
47
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/gondolin-krun-runner-darwin-arm64/-/gondolin-krun-runner-darwin-arm64-0.12.0.tgz",
|
|
48
|
+
"integrity": "sha512-ftDlusht4PcT7Y3TuPrZIKrCXy3isiBTVMvlXYK0pcud2uXY6uwFTGeunYgP+8ND/60ddb+MImqbfmkcK8B84A==",
|
|
49
|
+
"cpu": [
|
|
50
|
+
"arm64"
|
|
51
|
+
],
|
|
52
|
+
"license": "Apache-2.0",
|
|
53
|
+
"optional": true,
|
|
54
|
+
"os": [
|
|
55
|
+
"darwin"
|
|
56
|
+
],
|
|
57
|
+
"bin": {
|
|
58
|
+
"gondolin-krun-runner": "bin/gondolin-krun-runner"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"node_modules/@earendil-works/gondolin-krun-runner-linux-x64": {
|
|
62
|
+
"version": "0.12.0",
|
|
63
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/gondolin-krun-runner-linux-x64/-/gondolin-krun-runner-linux-x64-0.12.0.tgz",
|
|
64
|
+
"integrity": "sha512-RRYsgwe2r5ApKmFNy469QgwnyjAHpAs9XANdWpTd9ol4iUYOY3sX7e0xIooAKxd+ktxGI4N/xRWicwGen3D/Ow==",
|
|
65
|
+
"cpu": [
|
|
66
|
+
"x64"
|
|
67
|
+
],
|
|
68
|
+
"license": "Apache-2.0",
|
|
69
|
+
"optional": true,
|
|
70
|
+
"os": [
|
|
71
|
+
"linux"
|
|
72
|
+
],
|
|
73
|
+
"bin": {
|
|
74
|
+
"gondolin-krun-runner": "bin/gondolin-krun-runner"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"node_modules/asn1": {
|
|
78
|
+
"version": "0.2.6",
|
|
79
|
+
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
|
|
80
|
+
"integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==",
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"safer-buffer": "~2.1.0"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"node_modules/bcrypt-pbkdf": {
|
|
87
|
+
"version": "1.0.2",
|
|
88
|
+
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
|
89
|
+
"integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==",
|
|
90
|
+
"license": "BSD-3-Clause",
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"tweetnacl": "^0.14.3"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"node_modules/buildcheck": {
|
|
96
|
+
"version": "0.0.7",
|
|
97
|
+
"resolved": "https://registry.npmjs.org/buildcheck/-/buildcheck-0.0.7.tgz",
|
|
98
|
+
"integrity": "sha512-lHblz4ahamxpTmnsk+MNTRWsjYKv965MwOrSJyeD588rR3Jcu7swE+0wN5F+PbL5cjgu/9ObkhfzEPuofEMwLA==",
|
|
99
|
+
"optional": true,
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=10.0.0"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"node_modules/cbor2": {
|
|
105
|
+
"version": "2.3.0",
|
|
106
|
+
"resolved": "https://registry.npmjs.org/cbor2/-/cbor2-2.3.0.tgz",
|
|
107
|
+
"integrity": "sha512-76WB3hq8BoaGkMkBVJ27fW5LJU+qqDLEpgRNCG/SYKhODWXpVPOTD4UcUto3IEzYLA52nsvbhb0wabhHDn3qXg==",
|
|
108
|
+
"license": "MIT",
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"@cto.af/wtf8": "0.0.5"
|
|
111
|
+
},
|
|
112
|
+
"engines": {
|
|
113
|
+
"node": ">=20"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"node_modules/cpu-features": {
|
|
117
|
+
"version": "0.0.10",
|
|
118
|
+
"resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.10.tgz",
|
|
119
|
+
"integrity": "sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==",
|
|
120
|
+
"hasInstallScript": true,
|
|
121
|
+
"optional": true,
|
|
122
|
+
"dependencies": {
|
|
123
|
+
"buildcheck": "~0.0.6",
|
|
124
|
+
"nan": "^2.19.0"
|
|
125
|
+
},
|
|
126
|
+
"engines": {
|
|
127
|
+
"node": ">=10.0.0"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"node_modules/nan": {
|
|
131
|
+
"version": "2.27.0",
|
|
132
|
+
"resolved": "https://registry.npmjs.org/nan/-/nan-2.27.0.tgz",
|
|
133
|
+
"integrity": "sha512-hC+0LidcL3XE4rp1C4H54KujgXKzbfyTngZTwBByQxsOxCEKZT0MPQ4hOKUH2jU1OYstqdDH4onyHPDzcV0XdQ==",
|
|
134
|
+
"license": "MIT",
|
|
135
|
+
"optional": true
|
|
136
|
+
},
|
|
137
|
+
"node_modules/node-forge": {
|
|
138
|
+
"version": "1.4.0",
|
|
139
|
+
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.0.tgz",
|
|
140
|
+
"integrity": "sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==",
|
|
141
|
+
"license": "(BSD-3-Clause OR GPL-2.0)",
|
|
142
|
+
"engines": {
|
|
143
|
+
"node": ">= 6.13.0"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"node_modules/safer-buffer": {
|
|
147
|
+
"version": "2.1.2",
|
|
148
|
+
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
|
149
|
+
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
|
150
|
+
"license": "MIT"
|
|
151
|
+
},
|
|
152
|
+
"node_modules/ssh2": {
|
|
153
|
+
"version": "1.17.0",
|
|
154
|
+
"resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.17.0.tgz",
|
|
155
|
+
"integrity": "sha512-wPldCk3asibAjQ/kziWQQt1Wh3PgDFpC0XpwclzKcdT1vql6KeYxf5LIt4nlFkUeR8WuphYMKqUA56X4rjbfgQ==",
|
|
156
|
+
"hasInstallScript": true,
|
|
157
|
+
"dependencies": {
|
|
158
|
+
"asn1": "^0.2.6",
|
|
159
|
+
"bcrypt-pbkdf": "^1.0.2"
|
|
160
|
+
},
|
|
161
|
+
"engines": {
|
|
162
|
+
"node": ">=10.16.0"
|
|
163
|
+
},
|
|
164
|
+
"optionalDependencies": {
|
|
165
|
+
"cpu-features": "~0.0.10",
|
|
166
|
+
"nan": "^2.23.0"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"node_modules/tweetnacl": {
|
|
170
|
+
"version": "0.14.5",
|
|
171
|
+
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
|
172
|
+
"integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==",
|
|
173
|
+
"license": "Unlicense"
|
|
174
|
+
},
|
|
175
|
+
"node_modules/undici": {
|
|
176
|
+
"version": "6.26.0",
|
|
177
|
+
"resolved": "https://registry.npmjs.org/undici/-/undici-6.26.0.tgz",
|
|
178
|
+
"integrity": "sha512-4yqz8a3n5HmGTlsbADNtr/dJlhkh/55Rq798G6ibiULcXbDtaLpTl1pvdqcbFfeoj3iSi52lePFM7h9H21cw/A==",
|
|
179
|
+
"license": "MIT",
|
|
180
|
+
"engines": {
|
|
181
|
+
"node": ">=18.17"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-extension-gondolin",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.80.10",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"clean": "echo 'nothing to clean'",
|
|
8
|
+
"build": "echo 'nothing to build'",
|
|
9
|
+
"check": "echo 'nothing to check'"
|
|
10
|
+
},
|
|
11
|
+
"pi": {
|
|
12
|
+
"extensions": [
|
|
13
|
+
"./index.ts"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@earendil-works/gondolin": "0.12.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hello Tool - Minimal custom tool example
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Type } from "@valni/ai";
|
|
6
|
+
import { defineTool, type ExtensionAPI } from "@valni/cli";
|
|
7
|
+
|
|
8
|
+
const helloTool = defineTool({
|
|
9
|
+
name: "hello",
|
|
10
|
+
label: "Hello",
|
|
11
|
+
description: "A simple greeting tool",
|
|
12
|
+
parameters: Type.Object({
|
|
13
|
+
name: Type.String({ description: "Name to greet" }),
|
|
14
|
+
}),
|
|
15
|
+
|
|
16
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: "text", text: `Hello, ${params.name}!` }],
|
|
19
|
+
details: { greeted: params.name },
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export default function (pi: ExtensionAPI) {
|
|
25
|
+
pi.registerTool(helloTool);
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hidden Thinking Label Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates `ctx.ui.setHiddenThinkingLabel()` for customizing the label shown
|
|
5
|
+
* when thinking blocks are hidden.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pi --extension examples/extensions/hidden-thinking-label.ts
|
|
9
|
+
*
|
|
10
|
+
* Test:
|
|
11
|
+
* 1. Load this extension
|
|
12
|
+
* 2. Hide thinking blocks with Ctrl+T
|
|
13
|
+
* 3. Ask for something that produces reasoning output
|
|
14
|
+
* 4. The collapsed thinking block label will show the custom text
|
|
15
|
+
*
|
|
16
|
+
* Commands:
|
|
17
|
+
* /thinking-label <text> Set a custom hidden thinking label
|
|
18
|
+
* /thinking-label Reset to the default label
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ExtensionAPI, ExtensionContext } from "@valni/cli";
|
|
22
|
+
|
|
23
|
+
const DEFAULT_LABEL = "Pondering...";
|
|
24
|
+
|
|
25
|
+
export default function (pi: ExtensionAPI) {
|
|
26
|
+
let label = DEFAULT_LABEL;
|
|
27
|
+
|
|
28
|
+
const applyLabel = (ctx: ExtensionContext) => {
|
|
29
|
+
ctx.ui.setHiddenThinkingLabel(label);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
33
|
+
applyLabel(ctx);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
pi.registerCommand("thinking-label", {
|
|
37
|
+
description: "Set the hidden thinking label. Use without args to reset.",
|
|
38
|
+
handler: async (args, ctx) => {
|
|
39
|
+
const nextLabel = args.trim();
|
|
40
|
+
|
|
41
|
+
if (!nextLabel) {
|
|
42
|
+
label = DEFAULT_LABEL;
|
|
43
|
+
ctx.ui.setHiddenThinkingLabel();
|
|
44
|
+
ctx.ui.notify(`Hidden thinking label reset to: ${DEFAULT_LABEL}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
label = nextLabel;
|
|
49
|
+
ctx.ui.setHiddenThinkingLabel(label);
|
|
50
|
+
ctx.ui.notify(`Hidden thinking label set to: ${label}`);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Bash Extension - expands inline bash commands in user prompts.
|
|
3
|
+
*
|
|
4
|
+
* Start pi with this extension:
|
|
5
|
+
* pi -e ./examples/extensions/inline-bash.ts
|
|
6
|
+
*
|
|
7
|
+
* Then type prompts with inline bash:
|
|
8
|
+
* What's in !{pwd}?
|
|
9
|
+
* The current branch is !{git branch --show-current} and status: !{git status --short}
|
|
10
|
+
* My node version is !{node --version}
|
|
11
|
+
*
|
|
12
|
+
* The !{command} patterns are executed and replaced with their output before
|
|
13
|
+
* the prompt is sent to the agent.
|
|
14
|
+
*
|
|
15
|
+
* Note: Regular !command syntax (whole-line bash) is preserved and works as before.
|
|
16
|
+
*/
|
|
17
|
+
import type { ExtensionAPI } from "@valni/cli";
|
|
18
|
+
|
|
19
|
+
export default function (pi: ExtensionAPI) {
|
|
20
|
+
const PATTERN = /!\{([^}]+)\}/g;
|
|
21
|
+
const TIMEOUT_MS = 30000;
|
|
22
|
+
|
|
23
|
+
pi.on("input", async (event, ctx) => {
|
|
24
|
+
const text = event.text;
|
|
25
|
+
|
|
26
|
+
// Don't process if it's a whole-line bash command (starts with !)
|
|
27
|
+
// This preserves the existing !command behavior
|
|
28
|
+
if (text.trimStart().startsWith("!") && !text.trimStart().startsWith("!{")) {
|
|
29
|
+
return { action: "continue" };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check if there are any inline bash patterns
|
|
33
|
+
if (!PATTERN.test(text)) {
|
|
34
|
+
return { action: "continue" };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Reset regex state after test()
|
|
38
|
+
PATTERN.lastIndex = 0;
|
|
39
|
+
|
|
40
|
+
let result = text;
|
|
41
|
+
const expansions: Array<{ command: string; output: string; error?: string }> = [];
|
|
42
|
+
|
|
43
|
+
// Find all matches first (to avoid issues with replacing while iterating)
|
|
44
|
+
const matches: Array<{ full: string; command: string }> = [];
|
|
45
|
+
let match = PATTERN.exec(text);
|
|
46
|
+
while (match) {
|
|
47
|
+
matches.push({ full: match[0], command: match[1] });
|
|
48
|
+
match = PATTERN.exec(text);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Execute each command and collect results
|
|
52
|
+
for (const { full, command } of matches) {
|
|
53
|
+
try {
|
|
54
|
+
const bashResult = await pi.exec("bash", ["-c", command], {
|
|
55
|
+
timeout: TIMEOUT_MS,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const output = bashResult.stdout || bashResult.stderr || "";
|
|
59
|
+
const trimmed = output.trim();
|
|
60
|
+
|
|
61
|
+
if (bashResult.code !== 0 && bashResult.stderr) {
|
|
62
|
+
expansions.push({
|
|
63
|
+
command,
|
|
64
|
+
output: trimmed,
|
|
65
|
+
error: `exit code ${bashResult.code}`,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
expansions.push({ command, output: trimmed });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
result = result.replace(full, trimmed);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
74
|
+
expansions.push({ command, output: "", error: errorMsg });
|
|
75
|
+
result = result.replace(full, `[error: ${errorMsg}]`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Show what was expanded (if UI available)
|
|
80
|
+
if (ctx.hasUI && expansions.length > 0) {
|
|
81
|
+
const summary = expansions
|
|
82
|
+
.map((e) => {
|
|
83
|
+
const status = e.error ? ` (${e.error})` : "";
|
|
84
|
+
const preview = e.output.length > 50 ? `${e.output.slice(0, 50)}...` : e.output;
|
|
85
|
+
return `!{${e.command}}${status} -> "${preview}"`;
|
|
86
|
+
})
|
|
87
|
+
.join("\n");
|
|
88
|
+
|
|
89
|
+
ctx.ui.notify(`Expanded ${expansions.length} inline command(s):\n${summary}`, "info");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { action: "transform", text: result, images: event.images };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming-Aware Input Gate
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates `event.streamingBehavior` to skip expensive pre-processing
|
|
5
|
+
* during mid-stream steering, where low latency matters.
|
|
6
|
+
*
|
|
7
|
+
* This extension prepends `git diff --stat` output when the user mentions
|
|
8
|
+
* file changes, giving the model immediate context. During steering the
|
|
9
|
+
* exec call is skipped so the correction reaches the model without delay.
|
|
10
|
+
*
|
|
11
|
+
* Start pi with this extension:
|
|
12
|
+
* pi -e ./examples/extensions/input-transform-streaming.ts
|
|
13
|
+
*/
|
|
14
|
+
import type { ExtensionAPI } from "@valni/cli";
|
|
15
|
+
|
|
16
|
+
const TRIGGER = /\b(changes?|diff|modified)\b/i;
|
|
17
|
+
|
|
18
|
+
export default function (pi: ExtensionAPI) {
|
|
19
|
+
pi.on("input", async (event) => {
|
|
20
|
+
// During steering, skip the exec call — corrections should be fast
|
|
21
|
+
if (event.streamingBehavior === "steer") {
|
|
22
|
+
return { action: "continue" };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!TRIGGER.test(event.text)) {
|
|
26
|
+
return { action: "continue" };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { stdout, code } = await pi.exec("git", ["diff", "--stat"]);
|
|
30
|
+
if (code !== 0 || !stdout.trim()) {
|
|
31
|
+
return { action: "continue" };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
action: "transform",
|
|
36
|
+
text: `${event.text}\n\nCurrent uncommitted changes:\n\`\`\`\n${stdout.trim()}\n\`\`\``,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Transform Example - demonstrates the `input` event for intercepting user input.
|
|
3
|
+
*
|
|
4
|
+
* Start pi with this extension:
|
|
5
|
+
* pi -e ./examples/extensions/input-transform.ts
|
|
6
|
+
*
|
|
7
|
+
* Then type these inside pi:
|
|
8
|
+
* ?quick What is TypeScript? → "Respond briefly: What is TypeScript?"
|
|
9
|
+
* ping → "pong" (instant, no LLM)
|
|
10
|
+
* time → current time (instant, no LLM)
|
|
11
|
+
*/
|
|
12
|
+
import type { ExtensionAPI } from "@valni/cli";
|
|
13
|
+
|
|
14
|
+
export default function (pi: ExtensionAPI) {
|
|
15
|
+
pi.on("input", async (event, ctx) => {
|
|
16
|
+
// Source-based logic: skip processing for extension-injected messages
|
|
17
|
+
if (event.source === "extension") {
|
|
18
|
+
return { action: "continue" };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Transform: ?quick prefix for brief responses
|
|
22
|
+
if (event.text.startsWith("?quick ")) {
|
|
23
|
+
const query = event.text.slice(7).trim();
|
|
24
|
+
if (!query) {
|
|
25
|
+
ctx.ui.notify("Usage: ?quick <question>", "warning");
|
|
26
|
+
return { action: "handled" };
|
|
27
|
+
}
|
|
28
|
+
return { action: "transform", text: `Respond briefly in 1-2 sentences: ${query}` };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Handle: instant responses without LLM (extension shows its own feedback)
|
|
32
|
+
if (event.text.toLowerCase() === "ping") {
|
|
33
|
+
ctx.ui.notify("pong", "info");
|
|
34
|
+
return { action: "handled" };
|
|
35
|
+
}
|
|
36
|
+
if (event.text.toLowerCase() === "time") {
|
|
37
|
+
ctx.ui.notify(new Date().toLocaleString(), "info");
|
|
38
|
+
return { action: "handled" };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { action: "continue" };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Shell Commands Extension
|
|
3
|
+
*
|
|
4
|
+
* Enables running interactive commands (vim, git rebase -i, htop, etc.)
|
|
5
|
+
* with full terminal access. The TUI suspends while they run.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pi -e examples/extensions/interactive-shell.ts
|
|
9
|
+
*
|
|
10
|
+
* !vim file.txt # Auto-detected as interactive
|
|
11
|
+
* !i any-command # Force interactive mode with !i prefix
|
|
12
|
+
* !git rebase -i HEAD~3
|
|
13
|
+
* !htop
|
|
14
|
+
*
|
|
15
|
+
* Configuration via environment variables:
|
|
16
|
+
* INTERACTIVE_COMMANDS - Additional commands (comma-separated)
|
|
17
|
+
* INTERACTIVE_EXCLUDE - Commands to exclude (comma-separated)
|
|
18
|
+
*
|
|
19
|
+
* Note: This only intercepts user `!` commands, not agent bash tool calls.
|
|
20
|
+
* If the agent runs an interactive command, it will fail (which is fine).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { spawnSync } from "node:child_process";
|
|
24
|
+
import type { ExtensionAPI } from "@valni/cli";
|
|
25
|
+
|
|
26
|
+
// Default interactive commands - editors, pagers, git ops, TUIs
|
|
27
|
+
const DEFAULT_INTERACTIVE_COMMANDS = [
|
|
28
|
+
// Editors
|
|
29
|
+
"vim",
|
|
30
|
+
"nvim",
|
|
31
|
+
"vi",
|
|
32
|
+
"nano",
|
|
33
|
+
"emacs",
|
|
34
|
+
"pico",
|
|
35
|
+
"micro",
|
|
36
|
+
"helix",
|
|
37
|
+
"hx",
|
|
38
|
+
"kak",
|
|
39
|
+
// Pagers
|
|
40
|
+
"less",
|
|
41
|
+
"more",
|
|
42
|
+
"most",
|
|
43
|
+
// Git interactive
|
|
44
|
+
"git commit",
|
|
45
|
+
"git rebase",
|
|
46
|
+
"git merge",
|
|
47
|
+
"git cherry-pick",
|
|
48
|
+
"git revert",
|
|
49
|
+
"git add -p",
|
|
50
|
+
"git add --patch",
|
|
51
|
+
"git add -i",
|
|
52
|
+
"git add --interactive",
|
|
53
|
+
"git stash -p",
|
|
54
|
+
"git stash --patch",
|
|
55
|
+
"git reset -p",
|
|
56
|
+
"git reset --patch",
|
|
57
|
+
"git checkout -p",
|
|
58
|
+
"git checkout --patch",
|
|
59
|
+
"git difftool",
|
|
60
|
+
"git mergetool",
|
|
61
|
+
// System monitors
|
|
62
|
+
"htop",
|
|
63
|
+
"top",
|
|
64
|
+
"btop",
|
|
65
|
+
"glances",
|
|
66
|
+
// File managers
|
|
67
|
+
"ranger",
|
|
68
|
+
"nnn",
|
|
69
|
+
"lf",
|
|
70
|
+
"mc",
|
|
71
|
+
"vifm",
|
|
72
|
+
// Git TUIs
|
|
73
|
+
"tig",
|
|
74
|
+
"lazygit",
|
|
75
|
+
"gitui",
|
|
76
|
+
// Fuzzy finders
|
|
77
|
+
"fzf",
|
|
78
|
+
"sk",
|
|
79
|
+
// Remote sessions
|
|
80
|
+
"ssh",
|
|
81
|
+
"telnet",
|
|
82
|
+
"mosh",
|
|
83
|
+
// Database clients
|
|
84
|
+
"psql",
|
|
85
|
+
"mysql",
|
|
86
|
+
"sqlite3",
|
|
87
|
+
"mongosh",
|
|
88
|
+
"redis-cli",
|
|
89
|
+
// Kubernetes/Docker
|
|
90
|
+
"kubectl edit",
|
|
91
|
+
"kubectl exec -it",
|
|
92
|
+
"docker exec -it",
|
|
93
|
+
"docker run -it",
|
|
94
|
+
// Other
|
|
95
|
+
"tmux",
|
|
96
|
+
"screen",
|
|
97
|
+
"ncdu",
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
function getInteractiveCommands(): string[] {
|
|
101
|
+
const additional =
|
|
102
|
+
process.env.INTERACTIVE_COMMANDS?.split(",")
|
|
103
|
+
.map((s) => s.trim())
|
|
104
|
+
.filter(Boolean) ?? [];
|
|
105
|
+
const excluded = new Set(process.env.INTERACTIVE_EXCLUDE?.split(",").map((s) => s.trim().toLowerCase()) ?? []);
|
|
106
|
+
return [...DEFAULT_INTERACTIVE_COMMANDS, ...additional].filter((cmd) => !excluded.has(cmd.toLowerCase()));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isInteractiveCommand(command: string): boolean {
|
|
110
|
+
const trimmed = command.trim().toLowerCase();
|
|
111
|
+
const commands = getInteractiveCommands();
|
|
112
|
+
|
|
113
|
+
for (const cmd of commands) {
|
|
114
|
+
const cmdLower = cmd.toLowerCase();
|
|
115
|
+
// Match at start
|
|
116
|
+
if (trimmed === cmdLower || trimmed.startsWith(`${cmdLower} `) || trimmed.startsWith(`${cmdLower}\t`)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
// Match after pipe: "cat file | less"
|
|
120
|
+
const pipeIdx = trimmed.lastIndexOf("|");
|
|
121
|
+
if (pipeIdx !== -1) {
|
|
122
|
+
const afterPipe = trimmed.slice(pipeIdx + 1).trim();
|
|
123
|
+
if (afterPipe === cmdLower || afterPipe.startsWith(`${cmdLower} `)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default function (pi: ExtensionAPI) {
|
|
132
|
+
pi.on("user_bash", async (event, ctx) => {
|
|
133
|
+
let command = event.command;
|
|
134
|
+
let forceInteractive = false;
|
|
135
|
+
|
|
136
|
+
// Check for !i prefix (command comes without the leading !)
|
|
137
|
+
// The prefix parsing happens before this event, so we check if command starts with "i "
|
|
138
|
+
if (command.startsWith("i ") || command.startsWith("i\t")) {
|
|
139
|
+
forceInteractive = true;
|
|
140
|
+
command = command.slice(2).trim();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const shouldBeInteractive = forceInteractive || isInteractiveCommand(command);
|
|
144
|
+
if (!shouldBeInteractive) {
|
|
145
|
+
return; // Let normal handling proceed
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// No UI available (print mode, RPC, etc.)
|
|
149
|
+
if (ctx.mode !== "tui") {
|
|
150
|
+
return {
|
|
151
|
+
result: { output: "(interactive commands require TUI)", exitCode: 1, cancelled: false, truncated: false },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Use ctx.ui.custom() to get TUI access, then run the command
|
|
156
|
+
const exitCode = await ctx.ui.custom<number | null>((tui, _theme, _kb, done) => {
|
|
157
|
+
// Stop TUI to release terminal
|
|
158
|
+
tui.stop();
|
|
159
|
+
|
|
160
|
+
// Clear screen
|
|
161
|
+
process.stdout.write("\x1b[2J\x1b[H");
|
|
162
|
+
|
|
163
|
+
// Run command with full terminal access
|
|
164
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
165
|
+
const result = spawnSync(shell, ["-c", command], {
|
|
166
|
+
stdio: "inherit",
|
|
167
|
+
env: process.env,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Restart TUI
|
|
171
|
+
tui.start();
|
|
172
|
+
tui.requestRender(true);
|
|
173
|
+
|
|
174
|
+
// Signal completion
|
|
175
|
+
done(result.status);
|
|
176
|
+
|
|
177
|
+
// Return empty component (immediately disposed since done() was called)
|
|
178
|
+
return { render: () => [], invalidate: () => {} };
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Return result to prevent default bash handling
|
|
182
|
+
const output =
|
|
183
|
+
exitCode === 0
|
|
184
|
+
? "(interactive command completed successfully)"
|
|
185
|
+
: `(interactive command exited with code ${exitCode})`;
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
result: {
|
|
189
|
+
output,
|
|
190
|
+
exitCode: exitCode ?? 1,
|
|
191
|
+
cancelled: false,
|
|
192
|
+
truncated: false,
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
}
|