@vandeepunk/pi-coding-agent 0.0.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 +2564 -0
- package/README.md +555 -0
- package/dist/cli/args.d.ts +47 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +286 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +203 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +574 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2260 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +102 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +282 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +47 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +212 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +607 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +909 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1549 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +57 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +400 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +129 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +576 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +928 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +153 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +100 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +419 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +76 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +313 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +131 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1290 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +184 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +673 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +90 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +234 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1091 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +187 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +552 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +310 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +21 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/system-prompt.d.ts +24 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +137 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +25 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +55 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +242 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +146 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +206 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +239 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +73 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +61 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +40 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +118 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +29 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +78 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +623 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +91 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +162 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +479 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +17 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +102 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +26 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +220 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +145 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +266 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +97 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +270 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +851 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +53 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +277 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +46 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +70 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +621 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +68 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +934 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +113 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +8 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +16 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +313 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3664 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +98 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +500 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +6 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +201 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +539 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1827 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +174 -0
- package/docs/models.md +254 -0
- package/docs/packages.md +191 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +168 -0
- package/docs/rpc.md +1311 -0
- package/docs/sdk.md +957 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +221 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +227 -0
- package/docs/terminal-setup.md +70 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tree.md +219 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +202 -0
- package/examples/extensions/antigravity-image-gen.ts +413 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +127 -0
- package/examples/extensions/subagent/index.ts +963 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +97 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Override Example - Demonstrates overriding built-in tools
|
|
3
|
+
*
|
|
4
|
+
* Extensions can register tools with the same name as built-in tools to replace them.
|
|
5
|
+
* This is useful for:
|
|
6
|
+
* - Adding logging or auditing to tool calls
|
|
7
|
+
* - Implementing access control or sandboxing
|
|
8
|
+
* - Routing tool calls to remote systems (e.g., pi-ssh-remote)
|
|
9
|
+
* - Modifying tool behavior for specific workflows
|
|
10
|
+
*
|
|
11
|
+
* This example overrides the `read` tool to:
|
|
12
|
+
* 1. Log all file access to a log file
|
|
13
|
+
* 2. Block access to sensitive paths (e.g., .env files)
|
|
14
|
+
* 3. Delegate to the original read implementation for allowed files
|
|
15
|
+
*
|
|
16
|
+
* Since no custom renderCall/renderResult are provided, the built-in renderer
|
|
17
|
+
* is used automatically (syntax highlighting, line numbers, truncation warnings).
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* pi -e ./tool-override.ts
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { TextContent } from "@mariozechner/pi-ai";
|
|
24
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
25
|
+
import { Type } from "@sinclair/typebox";
|
|
26
|
+
import { appendFileSync, constants, readFileSync } from "fs";
|
|
27
|
+
import { access, readFile } from "fs/promises";
|
|
28
|
+
import { homedir } from "os";
|
|
29
|
+
import { join, resolve } from "path";
|
|
30
|
+
|
|
31
|
+
const LOG_FILE = join(homedir(), ".pi", "agent", "read-access.log");
|
|
32
|
+
|
|
33
|
+
// Paths that are blocked from reading
|
|
34
|
+
const BLOCKED_PATTERNS = [
|
|
35
|
+
/\.env$/,
|
|
36
|
+
/\.env\..+$/,
|
|
37
|
+
/secrets?\.(json|yaml|yml|toml)$/i,
|
|
38
|
+
/credentials?\.(json|yaml|yml|toml)$/i,
|
|
39
|
+
/\/\.ssh\//,
|
|
40
|
+
/\/\.aws\//,
|
|
41
|
+
/\/\.gnupg\//,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function isBlockedPath(path: string): boolean {
|
|
45
|
+
return BLOCKED_PATTERNS.some((pattern) => pattern.test(path));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function logAccess(path: string, allowed: boolean, reason?: string) {
|
|
49
|
+
const timestamp = new Date().toISOString();
|
|
50
|
+
const status = allowed ? "ALLOWED" : "BLOCKED";
|
|
51
|
+
const msg = reason ? ` (${reason})` : "";
|
|
52
|
+
const line = `[${timestamp}] ${status}: ${path}${msg}\n`;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
appendFileSync(LOG_FILE, line);
|
|
56
|
+
} catch {
|
|
57
|
+
// Ignore logging errors
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const readSchema = Type.Object({
|
|
62
|
+
path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
|
|
63
|
+
offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
|
|
64
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export default function (pi: ExtensionAPI) {
|
|
68
|
+
pi.registerTool({
|
|
69
|
+
name: "read", // Same name as built-in - this will override it
|
|
70
|
+
label: "read (audited)",
|
|
71
|
+
description:
|
|
72
|
+
"Read the contents of a file with access logging. Some sensitive paths (.env, secrets, credentials) are blocked.",
|
|
73
|
+
parameters: readSchema,
|
|
74
|
+
|
|
75
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
76
|
+
const { path, offset, limit } = params;
|
|
77
|
+
const absolutePath = resolve(ctx.cwd, path);
|
|
78
|
+
|
|
79
|
+
// Check if path is blocked
|
|
80
|
+
if (isBlockedPath(absolutePath)) {
|
|
81
|
+
logAccess(absolutePath, false, "matches blocked pattern");
|
|
82
|
+
return {
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: `Access denied: "${path}" matches a blocked pattern (sensitive file). This tool blocks access to .env files, secrets, credentials, and SSH/AWS/GPG directories.`,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
details: { blocked: true },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Log allowed access
|
|
94
|
+
logAccess(absolutePath, true);
|
|
95
|
+
|
|
96
|
+
// Perform the actual read (simplified implementation)
|
|
97
|
+
try {
|
|
98
|
+
await access(absolutePath, constants.R_OK);
|
|
99
|
+
const content = await readFile(absolutePath, "utf-8");
|
|
100
|
+
const lines = content.split("\n");
|
|
101
|
+
|
|
102
|
+
// Apply offset and limit
|
|
103
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
104
|
+
const endLine = limit ? startLine + limit : lines.length;
|
|
105
|
+
const selectedLines = lines.slice(startLine, endLine);
|
|
106
|
+
|
|
107
|
+
// Basic truncation (50KB limit)
|
|
108
|
+
let text = selectedLines.join("\n");
|
|
109
|
+
const maxBytes = 50 * 1024;
|
|
110
|
+
if (Buffer.byteLength(text, "utf-8") > maxBytes) {
|
|
111
|
+
text = `${text.slice(0, maxBytes)}\n\n[Output truncated at 50KB]`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text", text }] as TextContent[],
|
|
116
|
+
details: { lines: lines.length },
|
|
117
|
+
};
|
|
118
|
+
} catch (error: any) {
|
|
119
|
+
return {
|
|
120
|
+
content: [{ type: "text", text: `Error reading file: ${error.message}` }] as TextContent[],
|
|
121
|
+
details: { error: true },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
// No renderCall/renderResult - uses built-in renderer automatically
|
|
127
|
+
// (syntax highlighting, line numbers, truncation warnings, etc.)
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Also register a command to view the access log
|
|
131
|
+
pi.registerCommand("read-log", {
|
|
132
|
+
description: "View the file access log",
|
|
133
|
+
handler: async (_args, ctx) => {
|
|
134
|
+
try {
|
|
135
|
+
const log = readFileSync(LOG_FILE, "utf-8");
|
|
136
|
+
const lines = log.trim().split("\n").slice(-20); // Last 20 entries
|
|
137
|
+
ctx.ui.notify(`Recent file access:\n${lines.join("\n")}`, "info");
|
|
138
|
+
} catch {
|
|
139
|
+
ctx.ui.notify("No access log found", "info");
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools Extension
|
|
3
|
+
*
|
|
4
|
+
* Provides a /tools command to enable/disable tools interactively.
|
|
5
|
+
* Tool selection persists across session reloads and respects branch navigation.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
9
|
+
* 2. Use /tools to open the tool selector
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ExtensionAPI, ExtensionContext, ToolInfo } from "@mariozechner/pi-coding-agent";
|
|
13
|
+
import { getSettingsListTheme } from "@mariozechner/pi-coding-agent";
|
|
14
|
+
import { Container, type SettingItem, SettingsList } from "@mariozechner/pi-tui";
|
|
15
|
+
|
|
16
|
+
// State persisted to session
|
|
17
|
+
interface ToolsState {
|
|
18
|
+
enabledTools: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function toolsExtension(pi: ExtensionAPI) {
|
|
22
|
+
// Track enabled tools
|
|
23
|
+
let enabledTools: Set<string> = new Set();
|
|
24
|
+
let allTools: ToolInfo[] = [];
|
|
25
|
+
|
|
26
|
+
// Persist current state
|
|
27
|
+
function persistState() {
|
|
28
|
+
pi.appendEntry<ToolsState>("tools-config", {
|
|
29
|
+
enabledTools: Array.from(enabledTools),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Apply current tool selection
|
|
34
|
+
function applyTools() {
|
|
35
|
+
pi.setActiveTools(Array.from(enabledTools));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Find the last tools-config entry in the current branch
|
|
39
|
+
function restoreFromBranch(ctx: ExtensionContext) {
|
|
40
|
+
allTools = pi.getAllTools();
|
|
41
|
+
|
|
42
|
+
// Get entries in current branch only
|
|
43
|
+
const branchEntries = ctx.sessionManager.getBranch();
|
|
44
|
+
let savedTools: string[] | undefined;
|
|
45
|
+
|
|
46
|
+
for (const entry of branchEntries) {
|
|
47
|
+
if (entry.type === "custom" && entry.customType === "tools-config") {
|
|
48
|
+
const data = entry.data as ToolsState | undefined;
|
|
49
|
+
if (data?.enabledTools) {
|
|
50
|
+
savedTools = data.enabledTools;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (savedTools) {
|
|
56
|
+
// Restore saved tool selection (filter to only tools that still exist)
|
|
57
|
+
const allToolNames = allTools.map((t) => t.name);
|
|
58
|
+
enabledTools = new Set(savedTools.filter((t: string) => allToolNames.includes(t)));
|
|
59
|
+
applyTools();
|
|
60
|
+
} else {
|
|
61
|
+
// No saved state - sync with currently active tools
|
|
62
|
+
enabledTools = new Set(pi.getActiveTools());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Register /tools command
|
|
67
|
+
pi.registerCommand("tools", {
|
|
68
|
+
description: "Enable/disable tools",
|
|
69
|
+
handler: async (_args, ctx) => {
|
|
70
|
+
// Refresh tool list
|
|
71
|
+
allTools = pi.getAllTools();
|
|
72
|
+
|
|
73
|
+
await ctx.ui.custom((tui, theme, _kb, done) => {
|
|
74
|
+
// Build settings items for each tool
|
|
75
|
+
const items: SettingItem[] = allTools.map((tool) => ({
|
|
76
|
+
id: tool.name,
|
|
77
|
+
label: tool.name,
|
|
78
|
+
currentValue: enabledTools.has(tool.name) ? "enabled" : "disabled",
|
|
79
|
+
values: ["enabled", "disabled"],
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
const container = new Container();
|
|
83
|
+
container.addChild(
|
|
84
|
+
new (class {
|
|
85
|
+
render(_width: number) {
|
|
86
|
+
return [theme.fg("accent", theme.bold("Tool Configuration")), ""];
|
|
87
|
+
}
|
|
88
|
+
invalidate() {}
|
|
89
|
+
})(),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const settingsList = new SettingsList(
|
|
93
|
+
items,
|
|
94
|
+
Math.min(items.length + 2, 15),
|
|
95
|
+
getSettingsListTheme(),
|
|
96
|
+
(id, newValue) => {
|
|
97
|
+
// Update enabled state and apply immediately
|
|
98
|
+
if (newValue === "enabled") {
|
|
99
|
+
enabledTools.add(id);
|
|
100
|
+
} else {
|
|
101
|
+
enabledTools.delete(id);
|
|
102
|
+
}
|
|
103
|
+
applyTools();
|
|
104
|
+
persistState();
|
|
105
|
+
},
|
|
106
|
+
() => {
|
|
107
|
+
// Close dialog
|
|
108
|
+
done(undefined);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
container.addChild(settingsList);
|
|
113
|
+
|
|
114
|
+
const component = {
|
|
115
|
+
render(width: number) {
|
|
116
|
+
return container.render(width);
|
|
117
|
+
},
|
|
118
|
+
invalidate() {
|
|
119
|
+
container.invalidate();
|
|
120
|
+
},
|
|
121
|
+
handleInput(data: string) {
|
|
122
|
+
settingsList.handleInput?.(data);
|
|
123
|
+
tui.requestRender();
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return component;
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Restore state on session start
|
|
133
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
134
|
+
restoreFromBranch(ctx);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Restore state when navigating the session tree
|
|
138
|
+
pi.on("session_tree", async (_event, ctx) => {
|
|
139
|
+
restoreFromBranch(ctx);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Restore state after forking
|
|
143
|
+
pi.on("session_fork", async (_event, ctx) => {
|
|
144
|
+
restoreFromBranch(ctx);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
const COMPACT_THRESHOLD_TOKENS = 100_000;
|
|
4
|
+
|
|
5
|
+
export default function (pi: ExtensionAPI) {
|
|
6
|
+
const triggerCompaction = (ctx: ExtensionContext, customInstructions?: string) => {
|
|
7
|
+
if (ctx.hasUI) {
|
|
8
|
+
ctx.ui.notify("Compaction started", "info");
|
|
9
|
+
}
|
|
10
|
+
ctx.compact({
|
|
11
|
+
customInstructions,
|
|
12
|
+
onComplete: () => {
|
|
13
|
+
if (ctx.hasUI) {
|
|
14
|
+
ctx.ui.notify("Compaction completed", "info");
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
onError: (error) => {
|
|
18
|
+
if (ctx.hasUI) {
|
|
19
|
+
ctx.ui.notify(`Compaction failed: ${error.message}`, "error");
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
pi.on("turn_end", (_event, ctx) => {
|
|
26
|
+
const usage = ctx.getContextUsage();
|
|
27
|
+
if (!usage || usage.tokens <= COMPACT_THRESHOLD_TOKENS) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
triggerCompaction(ctx);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
pi.registerCommand("trigger-compact", {
|
|
34
|
+
description: "Trigger compaction immediately",
|
|
35
|
+
handler: async (args, ctx) => {
|
|
36
|
+
const instructions = args.trim() || undefined;
|
|
37
|
+
triggerCompaction(ctx, instructions);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncated Tool Example - Demonstrates proper output truncation for custom tools
|
|
3
|
+
*
|
|
4
|
+
* Custom tools MUST truncate their output to avoid overwhelming the LLM context.
|
|
5
|
+
* The built-in limit is 50KB (~10k tokens) and 2000 lines, whichever is hit first.
|
|
6
|
+
*
|
|
7
|
+
* This example shows how to:
|
|
8
|
+
* 1. Use the built-in truncation utilities
|
|
9
|
+
* 2. Write full output to a temp file when truncated
|
|
10
|
+
* 3. Inform the LLM where to find the complete output
|
|
11
|
+
* 4. Custom rendering of tool calls and results
|
|
12
|
+
*
|
|
13
|
+
* The `rg` tool here wraps ripgrep with proper truncation. Compare this to the
|
|
14
|
+
* built-in `grep` tool in src/core/tools/grep.ts for a more complete implementation.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
18
|
+
import {
|
|
19
|
+
DEFAULT_MAX_BYTES,
|
|
20
|
+
DEFAULT_MAX_LINES,
|
|
21
|
+
formatSize,
|
|
22
|
+
type TruncationResult,
|
|
23
|
+
truncateHead,
|
|
24
|
+
} from "@mariozechner/pi-coding-agent";
|
|
25
|
+
import { Text } from "@mariozechner/pi-tui";
|
|
26
|
+
import { Type } from "@sinclair/typebox";
|
|
27
|
+
import { execSync } from "child_process";
|
|
28
|
+
import { mkdtempSync, writeFileSync } from "fs";
|
|
29
|
+
import { tmpdir } from "os";
|
|
30
|
+
import { join } from "path";
|
|
31
|
+
|
|
32
|
+
const RgParams = Type.Object({
|
|
33
|
+
pattern: Type.String({ description: "Search pattern (regex)" }),
|
|
34
|
+
path: Type.Optional(Type.String({ description: "Directory to search (default: current directory)" })),
|
|
35
|
+
glob: Type.Optional(Type.String({ description: "File glob pattern, e.g. '*.ts'" })),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
interface RgDetails {
|
|
39
|
+
pattern: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
glob?: string;
|
|
42
|
+
matchCount: number;
|
|
43
|
+
truncation?: TruncationResult;
|
|
44
|
+
fullOutputPath?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default function (pi: ExtensionAPI) {
|
|
48
|
+
pi.registerTool({
|
|
49
|
+
name: "rg",
|
|
50
|
+
label: "ripgrep",
|
|
51
|
+
// Document the truncation limits in the tool description so the LLM knows
|
|
52
|
+
description: `Search file contents using ripgrep. Output is truncated to ${DEFAULT_MAX_LINES} lines or ${formatSize(DEFAULT_MAX_BYTES)} (whichever is hit first). If truncated, full output is saved to a temp file.`,
|
|
53
|
+
parameters: RgParams,
|
|
54
|
+
|
|
55
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
56
|
+
const { pattern, path: searchPath, glob } = params;
|
|
57
|
+
|
|
58
|
+
// Build the ripgrep command
|
|
59
|
+
const args = ["rg", "--line-number", "--color=never"];
|
|
60
|
+
if (glob) args.push("--glob", glob);
|
|
61
|
+
args.push(pattern);
|
|
62
|
+
args.push(searchPath || ".");
|
|
63
|
+
|
|
64
|
+
let output: string;
|
|
65
|
+
try {
|
|
66
|
+
output = execSync(args.join(" "), {
|
|
67
|
+
cwd: ctx.cwd,
|
|
68
|
+
encoding: "utf-8",
|
|
69
|
+
maxBuffer: 100 * 1024 * 1024, // 100MB buffer to capture full output
|
|
70
|
+
});
|
|
71
|
+
} catch (err: any) {
|
|
72
|
+
// ripgrep exits with 1 when no matches found
|
|
73
|
+
if (err.status === 1) {
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: "No matches found" }],
|
|
76
|
+
details: { pattern, path: searchPath, glob, matchCount: 0 } as RgDetails,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`ripgrep failed: ${err.message}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!output.trim()) {
|
|
83
|
+
return {
|
|
84
|
+
content: [{ type: "text", text: "No matches found" }],
|
|
85
|
+
details: { pattern, path: searchPath, glob, matchCount: 0 } as RgDetails,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Apply truncation using built-in utilities
|
|
90
|
+
// truncateHead keeps the first N lines/bytes (good for search results)
|
|
91
|
+
// truncateTail keeps the last N lines/bytes (good for logs/command output)
|
|
92
|
+
const truncation = truncateHead(output, {
|
|
93
|
+
maxLines: DEFAULT_MAX_LINES,
|
|
94
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Count matches (each non-empty line with a match)
|
|
98
|
+
const matchCount = output.split("\n").filter((line) => line.trim()).length;
|
|
99
|
+
|
|
100
|
+
const details: RgDetails = {
|
|
101
|
+
pattern,
|
|
102
|
+
path: searchPath,
|
|
103
|
+
glob,
|
|
104
|
+
matchCount,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
let resultText = truncation.content;
|
|
108
|
+
|
|
109
|
+
if (truncation.truncated) {
|
|
110
|
+
// Save full output to a temp file so LLM can access it if needed
|
|
111
|
+
const tempDir = mkdtempSync(join(tmpdir(), "pi-rg-"));
|
|
112
|
+
const tempFile = join(tempDir, "output.txt");
|
|
113
|
+
writeFileSync(tempFile, output);
|
|
114
|
+
|
|
115
|
+
details.truncation = truncation;
|
|
116
|
+
details.fullOutputPath = tempFile;
|
|
117
|
+
|
|
118
|
+
// Add truncation notice - this helps the LLM understand the output is incomplete
|
|
119
|
+
const truncatedLines = truncation.totalLines - truncation.outputLines;
|
|
120
|
+
const truncatedBytes = truncation.totalBytes - truncation.outputBytes;
|
|
121
|
+
|
|
122
|
+
resultText += `\n\n[Output truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`;
|
|
123
|
+
resultText += ` (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}).`;
|
|
124
|
+
resultText += ` ${truncatedLines} lines (${formatSize(truncatedBytes)}) omitted.`;
|
|
125
|
+
resultText += ` Full output saved to: ${tempFile}]`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
content: [{ type: "text", text: resultText }],
|
|
130
|
+
details,
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// Custom rendering of the tool call (shown before/during execution)
|
|
135
|
+
renderCall(args, theme) {
|
|
136
|
+
let text = theme.fg("toolTitle", theme.bold("rg "));
|
|
137
|
+
text += theme.fg("accent", `"${args.pattern}"`);
|
|
138
|
+
if (args.path) {
|
|
139
|
+
text += theme.fg("muted", ` in ${args.path}`);
|
|
140
|
+
}
|
|
141
|
+
if (args.glob) {
|
|
142
|
+
text += theme.fg("dim", ` --glob ${args.glob}`);
|
|
143
|
+
}
|
|
144
|
+
return new Text(text, 0, 0);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
// Custom rendering of the tool result
|
|
148
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
149
|
+
const details = result.details as RgDetails | undefined;
|
|
150
|
+
|
|
151
|
+
// Handle streaming/partial results
|
|
152
|
+
if (isPartial) {
|
|
153
|
+
return new Text(theme.fg("warning", "Searching..."), 0, 0);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// No matches
|
|
157
|
+
if (!details || details.matchCount === 0) {
|
|
158
|
+
return new Text(theme.fg("dim", "No matches found"), 0, 0);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Build result display
|
|
162
|
+
let text = theme.fg("success", `${details.matchCount} matches`);
|
|
163
|
+
|
|
164
|
+
// Show truncation warning if applicable
|
|
165
|
+
if (details.truncation?.truncated) {
|
|
166
|
+
text += theme.fg("warning", " (truncated)");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// In expanded view, show the actual matches
|
|
170
|
+
if (expanded) {
|
|
171
|
+
const content = result.content[0];
|
|
172
|
+
if (content?.type === "text") {
|
|
173
|
+
// Show first 20 lines in expanded view, or all if fewer
|
|
174
|
+
const lines = content.text.split("\n").slice(0, 20);
|
|
175
|
+
for (const line of lines) {
|
|
176
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
177
|
+
}
|
|
178
|
+
if (content.text.split("\n").length > 20) {
|
|
179
|
+
text += `\n${theme.fg("muted", "... (use read tool to see full output)")}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Show temp file path if truncated
|
|
184
|
+
if (details.fullOutputPath) {
|
|
185
|
+
text += `\n${theme.fg("dim", `Full output: ${details.fullOutputPath}`)}`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return new Text(text, 0, 0);
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
const applyWidgets = (ctx: ExtensionContext) => {
|
|
4
|
+
if (!ctx.hasUI) return;
|
|
5
|
+
ctx.ui.setWidget("widget-above", ["Above editor widget"]);
|
|
6
|
+
ctx.ui.setWidget("widget-below", ["Below editor widget"], { placement: "belowEditor" });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function widgetPlacementExtension(pi: ExtensionAPI) {
|
|
10
|
+
pi.on("session_start", (_event, ctx) => {
|
|
11
|
+
applyWidgets(ctx);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
pi.on("session_switch", (_event, ctx) => {
|
|
15
|
+
applyWidgets(ctx);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example extension with its own npm dependencies.
|
|
3
|
+
* Tests that jiti resolves modules from the extension's own node_modules.
|
|
4
|
+
*
|
|
5
|
+
* Requires: npm install in this directory
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
import { Type } from "@sinclair/typebox";
|
|
10
|
+
import ms from "ms";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI) {
|
|
13
|
+
// Register a tool that uses ms
|
|
14
|
+
pi.registerTool({
|
|
15
|
+
name: "parse_duration",
|
|
16
|
+
label: "Parse Duration",
|
|
17
|
+
description: "Parse a human-readable duration string (e.g., '2 days', '1h', '5m') to milliseconds",
|
|
18
|
+
parameters: Type.Object({
|
|
19
|
+
duration: Type.String({ description: "Duration string like '2 days', '1h', '5m'" }),
|
|
20
|
+
}),
|
|
21
|
+
execute: async (_toolCallId, params) => {
|
|
22
|
+
const result = ms(params.duration as ms.StringValue);
|
|
23
|
+
if (result === undefined) {
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: "text", text: `Invalid duration: "${params.duration}"` }],
|
|
26
|
+
isError: true,
|
|
27
|
+
details: {},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: `${params.duration} = ${result} milliseconds` }],
|
|
32
|
+
details: {},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-extension-with-deps",
|
|
3
|
+
"version": "1.15.6",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "pi-extension-with-deps",
|
|
9
|
+
"version": "1.15.6",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"ms": "^2.1.3"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/ms": "^2.1.0"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"node_modules/@types/ms": {
|
|
18
|
+
"version": "2.1.0",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
|
|
20
|
+
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
|
|
21
|
+
"dev": true,
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
},
|
|
24
|
+
"node_modules/ms": {
|
|
25
|
+
"version": "2.1.3",
|
|
26
|
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
|
27
|
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
|
28
|
+
"license": "MIT"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-extension-with-deps",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.15.6",
|
|
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
|
+
"ms": "^2.1.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/ms": "^2.1.0"
|
|
21
|
+
}
|
|
22
|
+
}
|