@mrquake/quakecode-cli 0.64.0 → 0.64.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.
Files changed (180) hide show
  1. package/dist/bun/cli.d.ts.map +1 -1
  2. package/dist/bun/cli.js +1 -1
  3. package/dist/bun/cli.js.map +1 -1
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +7 -10
  6. package/dist/config.js.map +1 -1
  7. package/dist/core/extensions/loader.d.ts.map +1 -1
  8. package/dist/core/extensions/loader.js +21 -7
  9. package/dist/core/extensions/loader.js.map +1 -1
  10. package/dist/core/settings-manager.d.ts.map +1 -1
  11. package/dist/core/settings-manager.js +2 -2
  12. package/dist/core/settings-manager.js.map +1 -1
  13. package/dist/core/slash-commands.d.ts.map +1 -1
  14. package/dist/core/slash-commands.js +1 -1
  15. package/dist/core/slash-commands.js.map +1 -1
  16. package/dist/core/system-prompt.d.ts.map +1 -1
  17. package/dist/core/system-prompt.js +5 -5
  18. package/dist/core/system-prompt.js.map +1 -1
  19. package/dist/main.d.ts.map +1 -1
  20. package/dist/main.js +7 -7
  21. package/dist/main.js.map +1 -1
  22. package/dist/migrations.d.ts.map +1 -1
  23. package/dist/migrations.js +2 -2
  24. package/dist/migrations.js.map +1 -1
  25. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  26. package/dist/modes/interactive/components/config-selector.js +1 -1
  27. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  28. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  29. package/dist/modes/interactive/components/session-selector.js +82 -105
  30. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  31. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  32. package/dist/modes/interactive/interactive-mode.js +10 -5
  33. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  34. package/dist/utils/clipboard-image.d.ts.map +1 -1
  35. package/dist/utils/clipboard-image.js +3 -3
  36. package/dist/utils/clipboard-image.js.map +1 -1
  37. package/package.json +14 -7
  38. package/docs/compaction.md +0 -394
  39. package/docs/custom-provider.md +0 -596
  40. package/docs/development.md +0 -71
  41. package/docs/extensions.md +0 -2286
  42. package/docs/images/doom-extension.png +0 -0
  43. package/docs/images/exy.png +0 -0
  44. package/docs/images/interactive-mode.png +0 -0
  45. package/docs/images/tree-view.png +0 -0
  46. package/docs/json.md +0 -82
  47. package/docs/keybindings.md +0 -175
  48. package/docs/models.md +0 -341
  49. package/docs/packages.md +0 -218
  50. package/docs/prompt-templates.md +0 -67
  51. package/docs/providers.md +0 -195
  52. package/docs/rpc.md +0 -1377
  53. package/docs/sdk.md +0 -1064
  54. package/docs/session.md +0 -412
  55. package/docs/settings.md +0 -246
  56. package/docs/shell-aliases.md +0 -13
  57. package/docs/skills.md +0 -232
  58. package/docs/terminal-setup.md +0 -106
  59. package/docs/termux.md +0 -127
  60. package/docs/themes.md +0 -295
  61. package/docs/tmux.md +0 -61
  62. package/docs/tree.md +0 -231
  63. package/docs/tui.md +0 -887
  64. package/docs/windows.md +0 -17
  65. package/examples/README.md +0 -25
  66. package/examples/extensions/README.md +0 -206
  67. package/examples/extensions/antigravity-image-gen.ts +0 -418
  68. package/examples/extensions/auto-commit-on-exit.ts +0 -49
  69. package/examples/extensions/bash-spawn-hook.ts +0 -30
  70. package/examples/extensions/bookmark.ts +0 -50
  71. package/examples/extensions/built-in-tool-renderer.ts +0 -246
  72. package/examples/extensions/claude-rules.ts +0 -86
  73. package/examples/extensions/commands.ts +0 -72
  74. package/examples/extensions/confirm-destructive.ts +0 -59
  75. package/examples/extensions/custom-compaction.ts +0 -127
  76. package/examples/extensions/custom-footer.ts +0 -64
  77. package/examples/extensions/custom-header.ts +0 -73
  78. package/examples/extensions/custom-provider-anthropic/index.ts +0 -604
  79. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  80. package/examples/extensions/custom-provider-anthropic/package.json +0 -19
  81. package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
  82. package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
  83. package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
  84. package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
  85. package/examples/extensions/custom-provider-qwen-cli/package.json +0 -16
  86. package/examples/extensions/dirty-repo-guard.ts +0 -56
  87. package/examples/extensions/doom-overlay/README.md +0 -46
  88. package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
  89. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  90. package/examples/extensions/doom-overlay/doom/build.sh +0 -152
  91. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
  92. package/examples/extensions/doom-overlay/doom-component.ts +0 -132
  93. package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
  94. package/examples/extensions/doom-overlay/doom-keys.ts +0 -104
  95. package/examples/extensions/doom-overlay/index.ts +0 -74
  96. package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
  97. package/examples/extensions/dynamic-resources/SKILL.md +0 -8
  98. package/examples/extensions/dynamic-resources/dynamic.json +0 -79
  99. package/examples/extensions/dynamic-resources/dynamic.md +0 -5
  100. package/examples/extensions/dynamic-resources/index.ts +0 -15
  101. package/examples/extensions/dynamic-tools.ts +0 -74
  102. package/examples/extensions/event-bus.ts +0 -43
  103. package/examples/extensions/file-trigger.ts +0 -41
  104. package/examples/extensions/git-checkpoint.ts +0 -53
  105. package/examples/extensions/handoff.ts +0 -153
  106. package/examples/extensions/hello.ts +0 -26
  107. package/examples/extensions/hidden-thinking-label.ts +0 -53
  108. package/examples/extensions/inline-bash.ts +0 -94
  109. package/examples/extensions/input-transform.ts +0 -43
  110. package/examples/extensions/interactive-shell.ts +0 -196
  111. package/examples/extensions/mac-system-theme.ts +0 -47
  112. package/examples/extensions/message-renderer.ts +0 -59
  113. package/examples/extensions/minimal-mode.ts +0 -426
  114. package/examples/extensions/modal-editor.ts +0 -85
  115. package/examples/extensions/model-status.ts +0 -31
  116. package/examples/extensions/notify.ts +0 -55
  117. package/examples/extensions/overlay-qa-tests.ts +0 -1348
  118. package/examples/extensions/overlay-test.ts +0 -150
  119. package/examples/extensions/permission-gate.ts +0 -34
  120. package/examples/extensions/pirate.ts +0 -47
  121. package/examples/extensions/plan-mode/README.md +0 -65
  122. package/examples/extensions/plan-mode/index.ts +0 -340
  123. package/examples/extensions/plan-mode/utils.ts +0 -168
  124. package/examples/extensions/preset.ts +0 -397
  125. package/examples/extensions/protected-paths.ts +0 -30
  126. package/examples/extensions/provider-payload.ts +0 -14
  127. package/examples/extensions/qna.ts +0 -122
  128. package/examples/extensions/question.ts +0 -264
  129. package/examples/extensions/questionnaire.ts +0 -427
  130. package/examples/extensions/rainbow-editor.ts +0 -88
  131. package/examples/extensions/reload-runtime.ts +0 -37
  132. package/examples/extensions/rpc-demo.ts +0 -118
  133. package/examples/extensions/sandbox/index.ts +0 -321
  134. package/examples/extensions/sandbox/package-lock.json +0 -92
  135. package/examples/extensions/sandbox/package.json +0 -19
  136. package/examples/extensions/send-user-message.ts +0 -97
  137. package/examples/extensions/session-name.ts +0 -27
  138. package/examples/extensions/shutdown-command.ts +0 -63
  139. package/examples/extensions/snake.ts +0 -343
  140. package/examples/extensions/space-invaders.ts +0 -560
  141. package/examples/extensions/ssh.ts +0 -220
  142. package/examples/extensions/status-line.ts +0 -32
  143. package/examples/extensions/subagent/README.md +0 -172
  144. package/examples/extensions/subagent/agents/planner.md +0 -37
  145. package/examples/extensions/subagent/agents/reviewer.md +0 -35
  146. package/examples/extensions/subagent/agents/scout.md +0 -50
  147. package/examples/extensions/subagent/agents/worker.md +0 -24
  148. package/examples/extensions/subagent/agents.ts +0 -126
  149. package/examples/extensions/subagent/index.ts +0 -986
  150. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  151. package/examples/extensions/subagent/prompts/implement.md +0 -10
  152. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
  153. package/examples/extensions/summarize.ts +0 -206
  154. package/examples/extensions/system-prompt-header.ts +0 -17
  155. package/examples/extensions/timed-confirm.ts +0 -70
  156. package/examples/extensions/titlebar-spinner.ts +0 -58
  157. package/examples/extensions/todo.ts +0 -297
  158. package/examples/extensions/tool-override.ts +0 -144
  159. package/examples/extensions/tools.ts +0 -141
  160. package/examples/extensions/trigger-compact.ts +0 -50
  161. package/examples/extensions/truncated-tool.ts +0 -195
  162. package/examples/extensions/widget-placement.ts +0 -9
  163. package/examples/extensions/with-deps/index.ts +0 -32
  164. package/examples/extensions/with-deps/package-lock.json +0 -31
  165. package/examples/extensions/with-deps/package.json +0 -22
  166. package/examples/rpc-extension-ui.ts +0 -632
  167. package/examples/sdk/01-minimal.ts +0 -22
  168. package/examples/sdk/02-custom-model.ts +0 -49
  169. package/examples/sdk/03-custom-prompt.ts +0 -55
  170. package/examples/sdk/04-skills.ts +0 -52
  171. package/examples/sdk/05-tools.ts +0 -56
  172. package/examples/sdk/06-extensions.ts +0 -88
  173. package/examples/sdk/07-context-files.ts +0 -40
  174. package/examples/sdk/08-prompt-templates.ts +0 -48
  175. package/examples/sdk/09-api-keys-and-oauth.ts +0 -48
  176. package/examples/sdk/10-settings.ts +0 -51
  177. package/examples/sdk/11-sessions.ts +0 -48
  178. package/examples/sdk/12-full-control.ts +0 -81
  179. package/examples/sdk/13-session-runtime.ts +0 -49
  180. package/examples/sdk/README.md +0 -145
@@ -1,321 +0,0 @@
1
- /**
2
- * Sandbox Extension - OS-level sandboxing for bash commands
3
- *
4
- * Uses @anthropic-ai/sandbox-runtime to enforce filesystem and network
5
- * restrictions on bash commands at the OS level (sandbox-exec on macOS,
6
- * bubblewrap on Linux).
7
- *
8
- * Note: this example intentionally overrides the built-in `bash` tool to show
9
- * how built-in tools can be replaced. Alternatively, you could sandbox `bash`
10
- * via `tool_call` input mutation without replacing the tool.
11
- *
12
- * Config files (merged, project takes precedence):
13
- * - ~/.pi/agent/sandbox.json (global)
14
- * - <cwd>/.pi/sandbox.json (project-local)
15
- *
16
- * Example .pi/sandbox.json:
17
- * ```json
18
- * {
19
- * "enabled": true,
20
- * "network": {
21
- * "allowedDomains": ["github.com", "*.github.com"],
22
- * "deniedDomains": []
23
- * },
24
- * "filesystem": {
25
- * "denyRead": ["~/.ssh", "~/.aws"],
26
- * "allowWrite": [".", "/tmp"],
27
- * "denyWrite": [".env"]
28
- * }
29
- * }
30
- * ```
31
- *
32
- * Usage:
33
- * - `pi -e ./sandbox` - sandbox enabled with default/config settings
34
- * - `pi -e ./sandbox --no-sandbox` - disable sandboxing
35
- * - `/sandbox` - show current sandbox configuration
36
- *
37
- * Setup:
38
- * 1. Copy sandbox/ directory to ~/.pi/agent/extensions/
39
- * 2. Run `npm install` in ~/.pi/agent/extensions/sandbox/
40
- *
41
- * Linux also requires: bubblewrap, socat, ripgrep
42
- */
43
-
44
- import { spawn } from "node:child_process";
45
- import { existsSync, readFileSync } from "node:fs";
46
- import { join } from "node:path";
47
- import { SandboxManager, type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
48
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
49
- import { type BashOperations, createBashTool, getAgentDir } from "@mariozechner/pi-coding-agent";
50
-
51
- interface SandboxConfig extends SandboxRuntimeConfig {
52
- enabled?: boolean;
53
- }
54
-
55
- const DEFAULT_CONFIG: SandboxConfig = {
56
- enabled: true,
57
- network: {
58
- allowedDomains: [
59
- "npmjs.org",
60
- "*.npmjs.org",
61
- "registry.npmjs.org",
62
- "registry.yarnpkg.com",
63
- "pypi.org",
64
- "*.pypi.org",
65
- "github.com",
66
- "*.github.com",
67
- "api.github.com",
68
- "raw.githubusercontent.com",
69
- ],
70
- deniedDomains: [],
71
- },
72
- filesystem: {
73
- denyRead: ["~/.ssh", "~/.aws", "~/.gnupg"],
74
- allowWrite: [".", "/tmp"],
75
- denyWrite: [".env", ".env.*", "*.pem", "*.key"],
76
- },
77
- };
78
-
79
- function loadConfig(cwd: string): SandboxConfig {
80
- const projectConfigPath = join(cwd, ".pi", "sandbox.json");
81
- const globalConfigPath = join(getAgentDir(), "extensions", "sandbox.json");
82
-
83
- let globalConfig: Partial<SandboxConfig> = {};
84
- let projectConfig: Partial<SandboxConfig> = {};
85
-
86
- if (existsSync(globalConfigPath)) {
87
- try {
88
- globalConfig = JSON.parse(readFileSync(globalConfigPath, "utf-8"));
89
- } catch (e) {
90
- console.error(`Warning: Could not parse ${globalConfigPath}: ${e}`);
91
- }
92
- }
93
-
94
- if (existsSync(projectConfigPath)) {
95
- try {
96
- projectConfig = JSON.parse(readFileSync(projectConfigPath, "utf-8"));
97
- } catch (e) {
98
- console.error(`Warning: Could not parse ${projectConfigPath}: ${e}`);
99
- }
100
- }
101
-
102
- return deepMerge(deepMerge(DEFAULT_CONFIG, globalConfig), projectConfig);
103
- }
104
-
105
- function deepMerge(base: SandboxConfig, overrides: Partial<SandboxConfig>): SandboxConfig {
106
- const result: SandboxConfig = { ...base };
107
-
108
- if (overrides.enabled !== undefined) result.enabled = overrides.enabled;
109
- if (overrides.network) {
110
- result.network = { ...base.network, ...overrides.network };
111
- }
112
- if (overrides.filesystem) {
113
- result.filesystem = { ...base.filesystem, ...overrides.filesystem };
114
- }
115
-
116
- const extOverrides = overrides as {
117
- ignoreViolations?: Record<string, string[]>;
118
- enableWeakerNestedSandbox?: boolean;
119
- };
120
- const extResult = result as { ignoreViolations?: Record<string, string[]>; enableWeakerNestedSandbox?: boolean };
121
-
122
- if (extOverrides.ignoreViolations) {
123
- extResult.ignoreViolations = extOverrides.ignoreViolations;
124
- }
125
- if (extOverrides.enableWeakerNestedSandbox !== undefined) {
126
- extResult.enableWeakerNestedSandbox = extOverrides.enableWeakerNestedSandbox;
127
- }
128
-
129
- return result;
130
- }
131
-
132
- function createSandboxedBashOps(): BashOperations {
133
- return {
134
- async exec(command, cwd, { onData, signal, timeout }) {
135
- if (!existsSync(cwd)) {
136
- throw new Error(`Working directory does not exist: ${cwd}`);
137
- }
138
-
139
- const wrappedCommand = await SandboxManager.wrapWithSandbox(command);
140
-
141
- return new Promise((resolve, reject) => {
142
- const child = spawn("bash", ["-c", wrappedCommand], {
143
- cwd,
144
- detached: true,
145
- stdio: ["ignore", "pipe", "pipe"],
146
- });
147
-
148
- let timedOut = false;
149
- let timeoutHandle: NodeJS.Timeout | undefined;
150
-
151
- if (timeout !== undefined && timeout > 0) {
152
- timeoutHandle = setTimeout(() => {
153
- timedOut = true;
154
- if (child.pid) {
155
- try {
156
- process.kill(-child.pid, "SIGKILL");
157
- } catch {
158
- child.kill("SIGKILL");
159
- }
160
- }
161
- }, timeout * 1000);
162
- }
163
-
164
- child.stdout?.on("data", onData);
165
- child.stderr?.on("data", onData);
166
-
167
- child.on("error", (err) => {
168
- if (timeoutHandle) clearTimeout(timeoutHandle);
169
- reject(err);
170
- });
171
-
172
- const onAbort = () => {
173
- if (child.pid) {
174
- try {
175
- process.kill(-child.pid, "SIGKILL");
176
- } catch {
177
- child.kill("SIGKILL");
178
- }
179
- }
180
- };
181
-
182
- signal?.addEventListener("abort", onAbort, { once: true });
183
-
184
- child.on("close", (code) => {
185
- if (timeoutHandle) clearTimeout(timeoutHandle);
186
- signal?.removeEventListener("abort", onAbort);
187
-
188
- if (signal?.aborted) {
189
- reject(new Error("aborted"));
190
- } else if (timedOut) {
191
- reject(new Error(`timeout:${timeout}`));
192
- } else {
193
- resolve({ exitCode: code });
194
- }
195
- });
196
- });
197
- },
198
- };
199
- }
200
-
201
- export default function (pi: ExtensionAPI) {
202
- pi.registerFlag("no-sandbox", {
203
- description: "Disable OS-level sandboxing for bash commands",
204
- type: "boolean",
205
- default: false,
206
- });
207
-
208
- const localCwd = process.cwd();
209
- const localBash = createBashTool(localCwd);
210
-
211
- let sandboxEnabled = false;
212
- let sandboxInitialized = false;
213
-
214
- pi.registerTool({
215
- ...localBash,
216
- label: "bash (sandboxed)",
217
- async execute(id, params, signal, onUpdate, _ctx) {
218
- if (!sandboxEnabled || !sandboxInitialized) {
219
- return localBash.execute(id, params, signal, onUpdate);
220
- }
221
-
222
- const sandboxedBash = createBashTool(localCwd, {
223
- operations: createSandboxedBashOps(),
224
- });
225
- return sandboxedBash.execute(id, params, signal, onUpdate);
226
- },
227
- });
228
-
229
- pi.on("user_bash", () => {
230
- if (!sandboxEnabled || !sandboxInitialized) return;
231
- return { operations: createSandboxedBashOps() };
232
- });
233
-
234
- pi.on("session_start", async (_event, ctx) => {
235
- const noSandbox = pi.getFlag("no-sandbox") as boolean;
236
-
237
- if (noSandbox) {
238
- sandboxEnabled = false;
239
- ctx.ui.notify("Sandbox disabled via --no-sandbox", "warning");
240
- return;
241
- }
242
-
243
- const config = loadConfig(ctx.cwd);
244
-
245
- if (!config.enabled) {
246
- sandboxEnabled = false;
247
- ctx.ui.notify("Sandbox disabled via config", "info");
248
- return;
249
- }
250
-
251
- const platform = process.platform;
252
- if (platform !== "darwin" && platform !== "linux") {
253
- sandboxEnabled = false;
254
- ctx.ui.notify(`Sandbox not supported on ${platform}`, "warning");
255
- return;
256
- }
257
-
258
- try {
259
- const configExt = config as unknown as {
260
- ignoreViolations?: Record<string, string[]>;
261
- enableWeakerNestedSandbox?: boolean;
262
- };
263
-
264
- await SandboxManager.initialize({
265
- network: config.network,
266
- filesystem: config.filesystem,
267
- ignoreViolations: configExt.ignoreViolations,
268
- enableWeakerNestedSandbox: configExt.enableWeakerNestedSandbox,
269
- });
270
-
271
- sandboxEnabled = true;
272
- sandboxInitialized = true;
273
-
274
- const networkCount = config.network?.allowedDomains?.length ?? 0;
275
- const writeCount = config.filesystem?.allowWrite?.length ?? 0;
276
- ctx.ui.setStatus(
277
- "sandbox",
278
- ctx.ui.theme.fg("accent", `🔒 Sandbox: ${networkCount} domains, ${writeCount} write paths`),
279
- );
280
- ctx.ui.notify("Sandbox initialized", "info");
281
- } catch (err) {
282
- sandboxEnabled = false;
283
- ctx.ui.notify(`Sandbox initialization failed: ${err instanceof Error ? err.message : err}`, "error");
284
- }
285
- });
286
-
287
- pi.on("session_shutdown", async () => {
288
- if (sandboxInitialized) {
289
- try {
290
- await SandboxManager.reset();
291
- } catch {
292
- // Ignore cleanup errors
293
- }
294
- }
295
- });
296
-
297
- pi.registerCommand("sandbox", {
298
- description: "Show sandbox configuration",
299
- handler: async (_args, ctx) => {
300
- if (!sandboxEnabled) {
301
- ctx.ui.notify("Sandbox is disabled", "info");
302
- return;
303
- }
304
-
305
- const config = loadConfig(ctx.cwd);
306
- const lines = [
307
- "Sandbox Configuration:",
308
- "",
309
- "Network:",
310
- ` Allowed: ${config.network?.allowedDomains?.join(", ") || "(none)"}`,
311
- ` Denied: ${config.network?.deniedDomains?.join(", ") || "(none)"}`,
312
- "",
313
- "Filesystem:",
314
- ` Deny Read: ${config.filesystem?.denyRead?.join(", ") || "(none)"}`,
315
- ` Allow Write: ${config.filesystem?.allowWrite?.join(", ") || "(none)"}`,
316
- ` Deny Write: ${config.filesystem?.denyWrite?.join(", ") || "(none)"}`,
317
- ];
318
- ctx.ui.notify(lines.join("\n"), "info");
319
- },
320
- });
321
- }
@@ -1,92 +0,0 @@
1
- {
2
- "name": "pi-extension-sandbox",
3
- "version": "1.0.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "pi-extension-sandbox",
9
- "version": "1.0.0",
10
- "dependencies": {
11
- "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
- }
13
- },
14
- "node_modules/@anthropic-ai/sandbox-runtime": {
15
- "version": "0.0.26",
16
- "resolved": "https://registry.npmjs.org/@anthropic-ai/sandbox-runtime/-/sandbox-runtime-0.0.26.tgz",
17
- "integrity": "sha512-DYV5LSsVMnzq0lbfaYMSpxZPUMAx4+hy343dRss+pVCLIfF62qOhxpYfZ5TmOk1GTDQm5f9wPprMNSStmnsV4w==",
18
- "license": "Apache-2.0",
19
- "dependencies": {
20
- "@pondwader/socks5-server": "^1.0.10",
21
- "@types/lodash-es": "^4.17.12",
22
- "commander": "^12.1.0",
23
- "lodash-es": "^4.17.21",
24
- "shell-quote": "^1.8.3",
25
- "zod": "^3.24.1"
26
- },
27
- "bin": {
28
- "srt": "dist/cli.js"
29
- },
30
- "engines": {
31
- "node": ">=18.0.0"
32
- }
33
- },
34
- "node_modules/@pondwader/socks5-server": {
35
- "version": "1.0.10",
36
- "resolved": "https://registry.npmjs.org/@pondwader/socks5-server/-/socks5-server-1.0.10.tgz",
37
- "integrity": "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg==",
38
- "license": "MIT"
39
- },
40
- "node_modules/@types/lodash": {
41
- "version": "4.17.23",
42
- "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.23.tgz",
43
- "integrity": "sha512-RDvF6wTulMPjrNdCoYRC8gNR880JNGT8uB+REUpC2Ns4pRqQJhGz90wh7rgdXDPpCczF3VGktDuFGVnz8zP7HA==",
44
- "license": "MIT"
45
- },
46
- "node_modules/@types/lodash-es": {
47
- "version": "4.17.12",
48
- "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz",
49
- "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
50
- "license": "MIT",
51
- "dependencies": {
52
- "@types/lodash": "*"
53
- }
54
- },
55
- "node_modules/commander": {
56
- "version": "12.1.0",
57
- "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
58
- "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
59
- "license": "MIT",
60
- "engines": {
61
- "node": ">=18"
62
- }
63
- },
64
- "node_modules/lodash-es": {
65
- "version": "4.17.22",
66
- "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.22.tgz",
67
- "integrity": "sha512-XEawp1t0gxSi9x01glktRZ5HDy0HXqrM0x5pXQM98EaI0NxO6jVM7omDOxsuEo5UIASAnm2bRp1Jt/e0a2XU8Q==",
68
- "license": "MIT"
69
- },
70
- "node_modules/shell-quote": {
71
- "version": "1.8.3",
72
- "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
73
- "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
74
- "license": "MIT",
75
- "engines": {
76
- "node": ">= 0.4"
77
- },
78
- "funding": {
79
- "url": "https://github.com/sponsors/ljharb"
80
- }
81
- },
82
- "node_modules/zod": {
83
- "version": "3.25.76",
84
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
85
- "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
86
- "license": "MIT",
87
- "funding": {
88
- "url": "https://github.com/sponsors/colinhacks"
89
- }
90
- }
91
- }
92
- }
@@ -1,19 +0,0 @@
1
- {
2
- "name": "pi-extension-sandbox",
3
- "private": true,
4
- "version": "1.0.0",
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
- "@anthropic-ai/sandbox-runtime": "^0.0.26"
18
- }
19
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * Send User Message Example
3
- *
4
- * Demonstrates pi.sendUserMessage() for sending user messages from extensions.
5
- * Unlike pi.sendMessage() which sends custom messages, sendUserMessage() sends
6
- * actual user messages that appear in the conversation as if typed by the user.
7
- *
8
- * Usage:
9
- * /ask What is 2+2? - Sends a user message (always triggers a turn)
10
- * /steer Focus on X - Sends while streaming with steer delivery
11
- * /followup And then? - Sends while streaming with followUp delivery
12
- */
13
-
14
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
15
-
16
- export default function (pi: ExtensionAPI) {
17
- // Simple command that sends a user message
18
- pi.registerCommand("ask", {
19
- description: "Send a user message to the agent",
20
- handler: async (args, ctx) => {
21
- if (!args.trim()) {
22
- ctx.ui.notify("Usage: /ask <message>", "warning");
23
- return;
24
- }
25
-
26
- // sendUserMessage always triggers a turn when not streaming
27
- // If streaming, it will throw (no deliverAs specified)
28
- if (!ctx.isIdle()) {
29
- ctx.ui.notify("Agent is busy. Use /steer or /followup instead.", "warning");
30
- return;
31
- }
32
-
33
- pi.sendUserMessage(args);
34
- },
35
- });
36
-
37
- // Command that steers the agent mid-conversation
38
- pi.registerCommand("steer", {
39
- description: "Send a steering message (interrupts current processing)",
40
- handler: async (args, ctx) => {
41
- if (!args.trim()) {
42
- ctx.ui.notify("Usage: /steer <message>", "warning");
43
- return;
44
- }
45
-
46
- if (ctx.isIdle()) {
47
- // Not streaming, just send normally
48
- pi.sendUserMessage(args);
49
- } else {
50
- // Streaming - use steer to interrupt
51
- pi.sendUserMessage(args, { deliverAs: "steer" });
52
- }
53
- },
54
- });
55
-
56
- // Command that queues a follow-up message
57
- pi.registerCommand("followup", {
58
- description: "Queue a follow-up message (waits for current processing)",
59
- handler: async (args, ctx) => {
60
- if (!args.trim()) {
61
- ctx.ui.notify("Usage: /followup <message>", "warning");
62
- return;
63
- }
64
-
65
- if (ctx.isIdle()) {
66
- // Not streaming, just send normally
67
- pi.sendUserMessage(args);
68
- } else {
69
- // Streaming - queue as follow-up
70
- pi.sendUserMessage(args, { deliverAs: "followUp" });
71
- ctx.ui.notify("Follow-up queued", "info");
72
- }
73
- },
74
- });
75
-
76
- // Example with content array (text + images would go here)
77
- pi.registerCommand("askwith", {
78
- description: "Send a user message with structured content",
79
- handler: async (args, ctx) => {
80
- if (!args.trim()) {
81
- ctx.ui.notify("Usage: /askwith <message>", "warning");
82
- return;
83
- }
84
-
85
- if (!ctx.isIdle()) {
86
- ctx.ui.notify("Agent is busy", "warning");
87
- return;
88
- }
89
-
90
- // sendUserMessage accepts string or (TextContent | ImageContent)[]
91
- pi.sendUserMessage([
92
- { type: "text", text: `User request: ${args}` },
93
- { type: "text", text: "Please respond concisely." },
94
- ]);
95
- },
96
- });
97
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Session naming example.
3
- *
4
- * Shows setSessionName/getSessionName to give sessions friendly names
5
- * that appear in the session selector instead of the first message.
6
- *
7
- * Usage: /session-name [name] - set or show session name
8
- */
9
-
10
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
11
-
12
- export default function (pi: ExtensionAPI) {
13
- pi.registerCommand("session-name", {
14
- description: "Set or show session name (usage: /session-name [new name])",
15
- handler: async (args, ctx) => {
16
- const name = args.trim();
17
-
18
- if (name) {
19
- pi.setSessionName(name);
20
- ctx.ui.notify(`Session named: ${name}`, "info");
21
- } else {
22
- const current = pi.getSessionName();
23
- ctx.ui.notify(current ? `Session: ${current}` : "No session name set", "info");
24
- }
25
- },
26
- });
27
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * Shutdown Command Extension
3
- *
4
- * Adds a /quit command that allows extensions to trigger clean shutdown.
5
- * Demonstrates how extensions can use ctx.shutdown() to exit pi cleanly.
6
- */
7
-
8
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
9
- import { Type } from "@sinclair/typebox";
10
-
11
- export default function (pi: ExtensionAPI) {
12
- // Register a /quit command that cleanly exits pi
13
- pi.registerCommand("quit", {
14
- description: "Exit pi cleanly",
15
- handler: async (_args, ctx) => {
16
- ctx.shutdown();
17
- },
18
- });
19
-
20
- // You can also create a tool that shuts down after completing work
21
- pi.registerTool({
22
- name: "finish_and_exit",
23
- label: "Finish and Exit",
24
- description: "Complete a task and exit pi",
25
- parameters: Type.Object({}),
26
- async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
27
- // Do any final work here...
28
- // Request graceful shutdown (deferred until agent is idle)
29
- ctx.shutdown();
30
-
31
- // This return is sent to the LLM before shutdown occurs
32
- return {
33
- content: [{ type: "text", text: "Shutdown requested. Exiting after this response." }],
34
- details: {},
35
- };
36
- },
37
- });
38
-
39
- // You could also create a more complex tool with parameters
40
- pi.registerTool({
41
- name: "deploy_and_exit",
42
- label: "Deploy and Exit",
43
- description: "Deploy the application and exit pi",
44
- parameters: Type.Object({
45
- environment: Type.String({ description: "Target environment (e.g., production, staging)" }),
46
- }),
47
- async execute(_toolCallId, params, _signal, onUpdate, ctx) {
48
- onUpdate?.({ content: [{ type: "text", text: `Deploying to ${params.environment}...` }], details: {} });
49
-
50
- // Example deployment logic
51
- // const result = await pi.exec("npm", ["run", "deploy", params.environment], { signal });
52
-
53
- // On success, request graceful shutdown
54
- onUpdate?.({ content: [{ type: "text", text: "Deployment complete, exiting..." }], details: {} });
55
- ctx.shutdown();
56
-
57
- return {
58
- content: [{ type: "text", text: "Done! Shutdown requested." }],
59
- details: { environment: params.environment },
60
- };
61
- },
62
- });
63
- }