pi-namespace-patch 0.85.1 → 0.86.1-namespace.1
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/CHANGELOG.md +110 -0
- package/README.md +26 -705
- package/dist/bundle/chunks/anthropic-messages-MYU5ZMRF.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-HUSQ3GP2.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +47 -38
- package/dist/bundle/chunks/chunk-4YJERF5N.js +2 -0
- package/dist/bundle/chunks/chunk-A3JYRWB6.js +2 -0
- package/dist/bundle/chunks/chunk-CVPNLAPW.js +1562 -0
- package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +42 -0
- package/dist/bundle/chunks/chunk-FUXEF6JQ.js +44 -0
- package/dist/bundle/chunks/{chunk-IDDQWTHI.js → chunk-RCZIEVGO.js} +10 -1
- package/dist/bundle/chunks/chunk-S7SZN6Z3.js +2 -0
- package/dist/bundle/chunks/chunk-WIUZI2CJ.js +11 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-IMS5EK2Y.js +2 -0
- package/dist/bundle/chunks/google-vertex-O4YJEQUW.js +2 -0
- package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-NOSQHBEY.js +5 -0
- package/dist/bundle/chunks/{node-KG362ECQ.js → node-O3RIBJRH.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-QDSOTBBO.js +10 -0
- package/dist/bundle/chunks/openai-completions-CYGM3XXP.js +7 -0
- package/dist/bundle/chunks/openai-responses-HWEUZ6WZ.js +2 -0
- package/dist/bundle/chunks/{pi-messages-PML4SPVJ.js → pi-messages-GFKBWJHZ.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-R7YYFUSE.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +4 -2
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +56 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +294 -157
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +12 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +22 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +102 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +342 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -12
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/crash-log.d.ts +22 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +71 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/experimental.d.ts +0 -4
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +0 -4
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +4 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +4 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +38 -51
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +10 -7
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +85 -67
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +60 -50
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +38 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +101 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +25 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +6 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +60 -38
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts +29 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +159 -96
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +43 -7
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +121 -92
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +9 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -9
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -2
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +16 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +206 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -1
- package/dist/modes/interactive/chat-viewport.js +1 -1
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +7 -2
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +74 -48
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +11 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +7 -7
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +18 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +15 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +227 -84
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +2 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +8 -4
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/tui-renderer.js +2 -2
- package/dist/modes/interactive/tui-renderer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +53 -81
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +111 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +11 -4
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/compaction.md +39 -13
- package/docs/custom-provider.md +22 -13
- package/docs/development.md +4 -4
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +57 -43
- package/docs/json.md +4 -4
- package/docs/models.md +33 -2
- package/docs/providers.md +10 -2
- package/docs/sdk.md +4 -2
- package/docs/security.md +1 -1
- package/docs/session-format.md +82 -40
- package/docs/sessions.md +27 -0
- package/docs/settings.md +60 -1
- package/docs/termux.md +0 -1
- package/docs/tui.md +2 -2
- package/docs/usage.md +1 -0
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +435 -762
- package/package.json +17 -23
- package/dist/bundle/chunks/anthropic-messages-VWZZOSJQ.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-BJLAM6CD.js +0 -2
- package/dist/bundle/chunks/chunk-AXIIZGTV.js +0 -2
- package/dist/bundle/chunks/chunk-CLNPYIDP.js +0 -42
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +0 -2
- package/dist/bundle/chunks/chunk-JJ2YFCJF.js +0 -1547
- package/dist/bundle/chunks/chunk-OUXLLA64.js +0 -11
- package/dist/bundle/chunks/chunk-U6ZMQKGD.js +0 -50
- package/dist/bundle/chunks/chunk-UAQELI3K.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-Q2K7FBDI.js +0 -2
- package/dist/bundle/chunks/google-vertex-7UJBF4S7.js +0 -2
- package/dist/bundle/chunks/mistral-conversations-4M6BZBX6.js +0 -5
- package/dist/bundle/chunks/openai-codex-responses-R6VYZTVY.js +0 -10
- package/dist/bundle/chunks/openai-completions-EKZT2IH2.js +0 -7
- package/dist/bundle/chunks/openai-responses-TFDINO6W.js +0 -2
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
package/docs/tui.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Extensions and custom tools can render custom TUI components for interactive user interfaces. This page covers the component system and available building blocks.
|
|
6
6
|
|
|
7
|
-
**Source:** [`@earendil-works/pi-tui`](https://github.com/earendil-works/pi
|
|
7
|
+
**Source:** [`@earendil-works/pi-tui`](https://github.com/earendil-works/pi/tree/main/packages/tui)
|
|
8
8
|
|
|
9
9
|
## Component Interface
|
|
10
10
|
|
|
@@ -930,7 +930,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
930
930
|
|
|
931
931
|
- **Extend `CustomEditor`** (not base `Editor`) to get app keybindings (escape to abort, ctrl+d to exit, model switching, etc.)
|
|
932
932
|
- **Call `super.handleInput(data)`** for keys you don't handle
|
|
933
|
-
- **
|
|
933
|
+
- **Status spinners**: custom editors keep standalone status rows by default. Pass `{ embedWorkingStatus: true }` as the fourth `CustomEditor` constructor argument to embed working, compaction, branch summarization, and retry spinners in the editor border instead.
|
|
934
934
|
- **Factory pattern**: `setEditorComponent` receives a factory function that gets `tui`, `theme`, and `keybindings`
|
|
935
935
|
- **Pass `undefined`** to restore the default editor: `ctx.ui.setEditorComponent(undefined)`
|
|
936
936
|
|
package/docs/usage.md
CHANGED
|
@@ -55,6 +55,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
55
55
|
| `/export [file]` | Export session to HTML or JSONL |
|
|
56
56
|
| `/import <file>` | Import and resume a session from a JSONL file |
|
|
57
57
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
58
|
+
| `/bug [description]` | Report a bug to the Pi developers; see [Sessions](sessions.md#reporting-bugs) |
|
|
58
59
|
| `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
|
|
59
60
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
60
61
|
| `/changelog` | Display version history |
|
|
@@ -36,7 +36,6 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|
|
36
36
|
| `questionnaire.ts` | Multi-question input with tab bar navigation between questions |
|
|
37
37
|
| `tool-override.ts` | Override built-in tools (e.g., add logging/access control to `read`) |
|
|
38
38
|
| `dynamic-tools.ts` | Register tools after startup (`session_start`) and at runtime via command, with prompt snippets and tool-specific prompt guidelines |
|
|
39
|
-
| `kimi-deferred-tools.ts` | Search for and progressively activate tools for Kimi's deferred-tool loading protocol |
|
|
40
39
|
| `structured-output.ts` | Final structured-output tool that returns `terminate: true` so the agent can end on the tool call |
|
|
41
40
|
| `built-in-tool-renderer.ts` | Custom compact rendering for built-in tools (read, bash, edit, write) while keeping original behavior |
|
|
42
41
|
| `minimal-mode.ts` | Override built-in tool rendering for minimal display (only tool calls, no output in collapsed mode) |
|
|
@@ -27,9 +27,11 @@ import {
|
|
|
27
27
|
type Api,
|
|
28
28
|
type AssistantMessage,
|
|
29
29
|
type AssistantMessageEventStream,
|
|
30
|
-
type Context,
|
|
31
30
|
calculateCost,
|
|
31
|
+
collapseSystemMessages,
|
|
32
32
|
createAssistantMessageEventStream,
|
|
33
|
+
getCurrentSystemPrompt,
|
|
34
|
+
getCurrentTools,
|
|
33
35
|
type ImageContent,
|
|
34
36
|
type Message,
|
|
35
37
|
type Model,
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
type Tool,
|
|
43
45
|
type ToolCall,
|
|
44
46
|
type ToolResultMessage,
|
|
47
|
+
type TranscriptContext,
|
|
45
48
|
} from "@earendil-works/pi-ai";
|
|
46
49
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
47
50
|
|
|
@@ -334,10 +337,15 @@ function mapStopReason(reason: string): StopReason {
|
|
|
334
337
|
|
|
335
338
|
function streamCustomAnthropic(
|
|
336
339
|
model: Model<Api>,
|
|
337
|
-
context:
|
|
340
|
+
context: TranscriptContext,
|
|
338
341
|
options?: SimpleStreamOptions,
|
|
339
342
|
): AssistantMessageEventStream {
|
|
340
343
|
const stream = createAssistantMessageEventStream();
|
|
344
|
+
// The transcript carries the prompt and tools in its system messages. This provider sends
|
|
345
|
+
// one top-level system prompt, so fold later system messages into the leading one first.
|
|
346
|
+
const transcript = collapseSystemMessages(context);
|
|
347
|
+
const systemPrompt = getCurrentSystemPrompt(transcript.messages);
|
|
348
|
+
const tools = getCurrentTools(transcript.messages);
|
|
341
349
|
|
|
342
350
|
(async () => {
|
|
343
351
|
const output: AssistantMessage = {
|
|
@@ -393,7 +401,7 @@ function streamCustomAnthropic(
|
|
|
393
401
|
// Build request params
|
|
394
402
|
const params: MessageCreateParamsStreaming = {
|
|
395
403
|
model: model.id,
|
|
396
|
-
messages: convertMessages(
|
|
404
|
+
messages: convertMessages(transcript.messages, isOAuth, tools),
|
|
397
405
|
max_tokens: options?.maxTokens || Math.floor(model.maxTokens / 3),
|
|
398
406
|
stream: true,
|
|
399
407
|
};
|
|
@@ -407,25 +415,25 @@ function streamCustomAnthropic(
|
|
|
407
415
|
cache_control: { type: "ephemeral" },
|
|
408
416
|
},
|
|
409
417
|
];
|
|
410
|
-
if (
|
|
418
|
+
if (systemPrompt) {
|
|
411
419
|
params.system.push({
|
|
412
420
|
type: "text",
|
|
413
|
-
text: sanitizeSurrogates(
|
|
421
|
+
text: sanitizeSurrogates(systemPrompt),
|
|
414
422
|
cache_control: { type: "ephemeral" },
|
|
415
423
|
});
|
|
416
424
|
}
|
|
417
|
-
} else if (
|
|
425
|
+
} else if (systemPrompt) {
|
|
418
426
|
params.system = [
|
|
419
427
|
{
|
|
420
428
|
type: "text",
|
|
421
|
-
text: sanitizeSurrogates(
|
|
429
|
+
text: sanitizeSurrogates(systemPrompt),
|
|
422
430
|
cache_control: { type: "ephemeral" },
|
|
423
431
|
},
|
|
424
432
|
];
|
|
425
433
|
}
|
|
426
434
|
|
|
427
|
-
if (
|
|
428
|
-
params.tools = convertTools(
|
|
435
|
+
if (tools.length > 0) {
|
|
436
|
+
params.tools = convertTools(tools, isOAuth);
|
|
429
437
|
}
|
|
430
438
|
|
|
431
439
|
// Handle thinking/reasoning
|
|
@@ -474,9 +482,7 @@ function streamCustomAnthropic(
|
|
|
474
482
|
output.content.push({
|
|
475
483
|
type: "toolCall",
|
|
476
484
|
id: event.content_block.id,
|
|
477
|
-
name: isOAuth
|
|
478
|
-
? fromClaudeCodeName(event.content_block.name, context.tools)
|
|
479
|
-
: event.content_block.name,
|
|
485
|
+
name: isOAuth ? fromClaudeCodeName(event.content_block.name, tools) : event.content_block.name,
|
|
480
486
|
arguments: {},
|
|
481
487
|
partialJson: "",
|
|
482
488
|
index: event.index,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.86.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type Api,
|
|
14
14
|
type AssistantMessageEventStream,
|
|
15
15
|
anthropicMessagesApi,
|
|
16
|
-
type Context,
|
|
17
16
|
createAssistantMessageEventStream,
|
|
18
17
|
type Model,
|
|
19
18
|
type OAuthCredentials,
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
openAIResponsesApi,
|
|
22
21
|
type SimpleStreamOptions,
|
|
23
22
|
type ThinkingLevelMap,
|
|
23
|
+
type TranscriptContext,
|
|
24
24
|
} from "@earendil-works/pi-ai/compat";
|
|
25
25
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
26
26
|
|
|
@@ -306,7 +306,7 @@ async function refreshGitLabToken(credentials: OAuthCredentials, signal: AbortSi
|
|
|
306
306
|
|
|
307
307
|
export function streamGitLabDuo(
|
|
308
308
|
model: Model<Api>,
|
|
309
|
-
context:
|
|
309
|
+
context: TranscriptContext,
|
|
310
310
|
options?: SimpleStreamOptions,
|
|
311
311
|
): AssistantMessageEventStream {
|
|
312
312
|
const stream = createAssistantMessageEventStream();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.86.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Prompt Customizer Extension
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates using systemPromptOptions to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* This extension adds tool-specific guidance based on what tools and skills
|
|
8
|
-
* are currently active, respecting whatever the user has configured.
|
|
4
|
+
* Demonstrates using systemPromptOptions to add context-aware prompt sections
|
|
5
|
+
* without replacing or reparsing the complete rendered prompt.
|
|
9
6
|
*
|
|
10
7
|
* Usage:
|
|
11
8
|
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
@@ -14,84 +11,39 @@
|
|
|
14
11
|
|
|
15
12
|
import type { BuildSystemPromptOptions, ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
* Adds tool-specific guidance that adapts to the active tool set.
|
|
19
|
-
* Instead of appending one-size-fits-all instructions, this reads what's
|
|
20
|
-
* actually loaded and tailors the guidance accordingly.
|
|
21
|
-
*/
|
|
22
|
-
function addToolGuidance(options: BuildSystemPromptOptions, basePrompt: string): string {
|
|
14
|
+
function buildToolGuidance(options: BuildSystemPromptOptions): string {
|
|
23
15
|
const hasTool = (name: string) => options.selectedTools?.includes(name) ?? false;
|
|
24
|
-
|
|
25
|
-
const parts: string[] = [];
|
|
16
|
+
const rules: string[] = [];
|
|
26
17
|
|
|
27
18
|
if (hasTool("read")) {
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
19
|
+
rules.push(
|
|
20
|
+
"- Use `read` for file contents; it supports text and images.",
|
|
21
|
+
"- For large files, use `offset` and `limit` to read in chunks.",
|
|
31
22
|
);
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
if (hasTool("bash")) {
|
|
35
|
-
|
|
25
|
+
rules.push("- Use `bash` for file operations such as `ls`, `find`, and `grep`.");
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
if (hasTool("edit")) {
|
|
39
|
-
|
|
40
|
-
"• Use the `edit` tool for precise text replacements in files. Match exact content including whitespace.",
|
|
41
|
-
);
|
|
28
|
+
rules.push("- Use `edit` for precise text replacements that match existing content exactly.");
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
if (hasTool("write")) {
|
|
45
|
-
|
|
31
|
+
rules.push("- Use `write` to create new files or replace existing files completely.");
|
|
46
32
|
}
|
|
47
|
-
|
|
48
33
|
if (options.skills && options.skills.length > 0) {
|
|
49
|
-
|
|
50
|
-
parts.push(`\nAvailable skills: ${skillNames}`, "Use skill documentation for best practices on specific tools.");
|
|
34
|
+
rules.push(`- Available skills: ${options.skills.map((skill) => skill.name).join(", ")}.`);
|
|
51
35
|
}
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
return basePrompt;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return `${basePrompt}
|
|
58
|
-
|
|
59
|
-
## Tool Guidance
|
|
60
|
-
|
|
61
|
-
${parts.join("\n")}
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Merges extension instructions with user-provided append prompts.
|
|
67
|
-
* This respects whatever the user configured via --append-system-prompt
|
|
68
|
-
* flags or files, rather than duplicating that work.
|
|
69
|
-
*/
|
|
70
|
-
function mergeWithUserAppend(options: BuildSystemPromptOptions): string {
|
|
71
|
-
const userAppend = options.appendSystemPrompt;
|
|
72
|
-
const extensionSpecific = `
|
|
73
|
-
## Extension-Added Context
|
|
74
|
-
|
|
75
|
-
This prompt includes tool guidance and skill information loaded dynamically.
|
|
76
|
-
If you have additional requirements, configure them via --append-system-prompt or project context files.
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
if (userAppend) {
|
|
80
|
-
return `${userAppend}\n\n${extensionSpecific}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return extensionSpecific;
|
|
37
|
+
return rules.join("\n");
|
|
84
38
|
}
|
|
85
39
|
|
|
86
40
|
export default function promptCustomizer(pi: ExtensionAPI) {
|
|
87
|
-
pi.on("before_agent_start",
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
systemPrompt: `${customPrompt}${appendSection}`,
|
|
95
|
-
};
|
|
41
|
+
pi.on("before_agent_start", (event) => {
|
|
42
|
+
const guidance = buildToolGuidance(event.systemPromptOptions);
|
|
43
|
+
if (guidance) {
|
|
44
|
+
event.systemPromptOptions.sections.tool_guidance = guidance;
|
|
45
|
+
} else {
|
|
46
|
+
delete event.systemPromptOptions.sections.tool_guidance;
|
|
47
|
+
}
|
|
96
48
|
});
|
|
97
49
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.16.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.86.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|