@synth-coder/pi-coding-agent 0.55.3
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 +2866 -0
- package/README.md +574 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +298 -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 +571 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2343 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +129 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +394 -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 +971 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1586 -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 +412 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +146 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +645 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1011 -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 +112 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +534 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +433 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +151 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1447 -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 +670 -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 +235 -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 +1098 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +225 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +653 -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 +364 -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 +22 -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 +661 -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 +96 -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 +213 -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 +271 -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 +275 -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 +56 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +287 -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 +75 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +752 -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 +315 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3719 -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 +101 -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 +511 -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 +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -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 +251 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +580 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1952 -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 +293 -0
- package/docs/packages.md +209 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +186 -0
- package/docs/rpc.md +1317 -0
- package/docs/sdk.md +968 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +223 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -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 +204 -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/built-in-tool-renderer.ts +246 -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/reload-runtime.ts +37 -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 +126 -0
- package/examples/extensions/subagent/index.ts +964 -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 +51 -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,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Commit on Exit Extension
|
|
3
|
+
*
|
|
4
|
+
* Automatically commits changes when the agent exits.
|
|
5
|
+
* Uses the last assistant message to generate a commit message.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
export default function (pi: ExtensionAPI) {
|
|
11
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
12
|
+
// Check for uncommitted changes
|
|
13
|
+
const { stdout: status, code } = await pi.exec("git", ["status", "--porcelain"]);
|
|
14
|
+
|
|
15
|
+
if (code !== 0 || status.trim().length === 0) {
|
|
16
|
+
// Not a git repo or no changes
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Find the last assistant message for commit context
|
|
21
|
+
const entries = ctx.sessionManager.getEntries();
|
|
22
|
+
let lastAssistantText = "";
|
|
23
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
24
|
+
const entry = entries[i];
|
|
25
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
26
|
+
const content = entry.message.content;
|
|
27
|
+
if (Array.isArray(content)) {
|
|
28
|
+
lastAssistantText = content
|
|
29
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
30
|
+
.map((c) => c.text)
|
|
31
|
+
.join("\n");
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Generate a simple commit message
|
|
38
|
+
const firstLine = lastAssistantText.split("\n")[0] || "Work in progress";
|
|
39
|
+
const commitMessage = `[pi] ${firstLine.slice(0, 50)}${firstLine.length > 50 ? "..." : ""}`;
|
|
40
|
+
|
|
41
|
+
// Stage and commit
|
|
42
|
+
await pi.exec("git", ["add", "-A"]);
|
|
43
|
+
const { code: commitCode } = await pi.exec("git", ["commit", "-m", commitMessage]);
|
|
44
|
+
|
|
45
|
+
if (commitCode === 0 && ctx.hasUI) {
|
|
46
|
+
ctx.ui.notify(`Auto-committed: ${commitMessage}`, "info");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bash Spawn Hook Example
|
|
3
|
+
*
|
|
4
|
+
* Adjusts command, cwd, and env before execution.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* pi -e ./bash-spawn-hook.ts
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
|
+
import { createBashTool } from "@mariozechner/pi-coding-agent";
|
|
12
|
+
|
|
13
|
+
export default function (pi: ExtensionAPI) {
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
|
|
16
|
+
const bashTool = createBashTool(cwd, {
|
|
17
|
+
spawnHook: ({ command, cwd, env }) => ({
|
|
18
|
+
command: `source ~/.profile\n${command}`,
|
|
19
|
+
cwd,
|
|
20
|
+
env: { ...env, PI_SPAWN_HOOK: "1" },
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
pi.registerTool({
|
|
25
|
+
...bashTool,
|
|
26
|
+
execute: async (id, params, signal, onUpdate, _ctx) => {
|
|
27
|
+
return bashTool.execute(id, params, signal, onUpdate);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry bookmarking example.
|
|
3
|
+
*
|
|
4
|
+
* Shows setLabel to mark entries with labels for easy navigation in /tree.
|
|
5
|
+
* Labels appear in the tree view and help you find important points.
|
|
6
|
+
*
|
|
7
|
+
* Usage: /bookmark [label] - bookmark the last assistant message
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI) {
|
|
13
|
+
pi.registerCommand("bookmark", {
|
|
14
|
+
description: "Bookmark last message (usage: /bookmark [label])",
|
|
15
|
+
handler: async (args, ctx) => {
|
|
16
|
+
const label = args.trim() || `bookmark-${Date.now()}`;
|
|
17
|
+
|
|
18
|
+
// Find the last assistant message entry
|
|
19
|
+
const entries = ctx.sessionManager.getEntries();
|
|
20
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
21
|
+
const entry = entries[i];
|
|
22
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
23
|
+
pi.setLabel(entry.id, label);
|
|
24
|
+
ctx.ui.notify(`Bookmarked as: ${label}`, "info");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ctx.ui.notify("No assistant message to bookmark", "warning");
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Remove bookmark
|
|
34
|
+
pi.registerCommand("unbookmark", {
|
|
35
|
+
description: "Remove bookmark from last labeled entry",
|
|
36
|
+
handler: async (_args, ctx) => {
|
|
37
|
+
const entries = ctx.sessionManager.getEntries();
|
|
38
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
39
|
+
const entry = entries[i];
|
|
40
|
+
const label = ctx.sessionManager.getLabel(entry.id);
|
|
41
|
+
if (label) {
|
|
42
|
+
pi.setLabel(entry.id, undefined);
|
|
43
|
+
ctx.ui.notify(`Removed bookmark: ${label}`, "info");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ctx.ui.notify("No bookmarked entry found", "warning");
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Tool Renderer Example - Custom rendering for built-in tools
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates how to override the rendering of built-in tools (read, bash,
|
|
5
|
+
* edit, write) without changing their behavior. Each tool is re-registered
|
|
6
|
+
* with the same name, delegating execution to the original implementation
|
|
7
|
+
* while providing compact custom renderCall/renderResult functions.
|
|
8
|
+
*
|
|
9
|
+
* This is useful for users who prefer more concise tool output, or who want
|
|
10
|
+
* to highlight specific information (e.g., showing only the diff stats for
|
|
11
|
+
* edit, or just the exit code for bash).
|
|
12
|
+
*
|
|
13
|
+
* How it works:
|
|
14
|
+
* - registerTool() with the same name as a built-in replaces it entirely
|
|
15
|
+
* - We create instances of the original tools via createReadTool(), etc.
|
|
16
|
+
* and delegate execute() to them
|
|
17
|
+
* - renderCall() controls what's shown when the tool is invoked
|
|
18
|
+
* - renderResult() controls what's shown after execution completes
|
|
19
|
+
* - The `expanded` flag in renderResult indicates whether the user has
|
|
20
|
+
* toggled the tool output open (via ctrl+e or clicking)
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* pi -e ./built-in-tool-renderer.ts
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { BashToolDetails, EditToolDetails, ExtensionAPI, ReadToolDetails } from "@mariozechner/pi-coding-agent";
|
|
27
|
+
import { createBashTool, createEditTool, createReadTool, createWriteTool } from "@mariozechner/pi-coding-agent";
|
|
28
|
+
import { Text } from "@mariozechner/pi-tui";
|
|
29
|
+
|
|
30
|
+
export default function (pi: ExtensionAPI) {
|
|
31
|
+
const cwd = process.cwd();
|
|
32
|
+
|
|
33
|
+
// --- Read tool: show path and line count ---
|
|
34
|
+
const originalRead = createReadTool(cwd);
|
|
35
|
+
pi.registerTool({
|
|
36
|
+
name: "read",
|
|
37
|
+
label: "read",
|
|
38
|
+
description: originalRead.description,
|
|
39
|
+
parameters: originalRead.parameters,
|
|
40
|
+
|
|
41
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
42
|
+
return originalRead.execute(toolCallId, params, signal, onUpdate);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
renderCall(args, theme) {
|
|
46
|
+
let text = theme.fg("toolTitle", theme.bold("read "));
|
|
47
|
+
text += theme.fg("accent", args.path);
|
|
48
|
+
if (args.offset || args.limit) {
|
|
49
|
+
const parts: string[] = [];
|
|
50
|
+
if (args.offset) parts.push(`offset=${args.offset}`);
|
|
51
|
+
if (args.limit) parts.push(`limit=${args.limit}`);
|
|
52
|
+
text += theme.fg("dim", ` (${parts.join(", ")})`);
|
|
53
|
+
}
|
|
54
|
+
return new Text(text, 0, 0);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
58
|
+
if (isPartial) return new Text(theme.fg("warning", "Reading..."), 0, 0);
|
|
59
|
+
|
|
60
|
+
const details = result.details as ReadToolDetails | undefined;
|
|
61
|
+
const content = result.content[0];
|
|
62
|
+
|
|
63
|
+
if (content?.type === "image") {
|
|
64
|
+
return new Text(theme.fg("success", "Image loaded"), 0, 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (content?.type !== "text") {
|
|
68
|
+
return new Text(theme.fg("error", "No content"), 0, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const lineCount = content.text.split("\n").length;
|
|
72
|
+
let text = theme.fg("success", `${lineCount} lines`);
|
|
73
|
+
|
|
74
|
+
if (details?.truncation?.truncated) {
|
|
75
|
+
text += theme.fg("warning", ` (truncated from ${details.truncation.totalLines})`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (expanded) {
|
|
79
|
+
const lines = content.text.split("\n").slice(0, 15);
|
|
80
|
+
for (const line of lines) {
|
|
81
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
82
|
+
}
|
|
83
|
+
if (lineCount > 15) {
|
|
84
|
+
text += `\n${theme.fg("muted", `... ${lineCount - 15} more lines`)}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return new Text(text, 0, 0);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// --- Bash tool: show command and exit code ---
|
|
93
|
+
const originalBash = createBashTool(cwd);
|
|
94
|
+
pi.registerTool({
|
|
95
|
+
name: "bash",
|
|
96
|
+
label: "bash",
|
|
97
|
+
description: originalBash.description,
|
|
98
|
+
parameters: originalBash.parameters,
|
|
99
|
+
|
|
100
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
101
|
+
return originalBash.execute(toolCallId, params, signal, onUpdate);
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
renderCall(args, theme) {
|
|
105
|
+
let text = theme.fg("toolTitle", theme.bold("$ "));
|
|
106
|
+
const cmd = args.command.length > 80 ? `${args.command.slice(0, 77)}...` : args.command;
|
|
107
|
+
text += theme.fg("accent", cmd);
|
|
108
|
+
if (args.timeout) {
|
|
109
|
+
text += theme.fg("dim", ` (timeout: ${args.timeout}s)`);
|
|
110
|
+
}
|
|
111
|
+
return new Text(text, 0, 0);
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
115
|
+
if (isPartial) return new Text(theme.fg("warning", "Running..."), 0, 0);
|
|
116
|
+
|
|
117
|
+
const details = result.details as BashToolDetails | undefined;
|
|
118
|
+
const content = result.content[0];
|
|
119
|
+
const output = content?.type === "text" ? content.text : "";
|
|
120
|
+
|
|
121
|
+
const exitMatch = output.match(/exit code: (\d+)/);
|
|
122
|
+
const exitCode = exitMatch ? parseInt(exitMatch[1], 10) : null;
|
|
123
|
+
const lineCount = output.split("\n").filter((l) => l.trim()).length;
|
|
124
|
+
|
|
125
|
+
let text = "";
|
|
126
|
+
if (exitCode === 0 || exitCode === null) {
|
|
127
|
+
text += theme.fg("success", "done");
|
|
128
|
+
} else {
|
|
129
|
+
text += theme.fg("error", `exit ${exitCode}`);
|
|
130
|
+
}
|
|
131
|
+
text += theme.fg("dim", ` (${lineCount} lines)`);
|
|
132
|
+
|
|
133
|
+
if (details?.truncation?.truncated) {
|
|
134
|
+
text += theme.fg("warning", " [truncated]");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (expanded) {
|
|
138
|
+
const lines = output.split("\n").slice(0, 20);
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
141
|
+
}
|
|
142
|
+
if (output.split("\n").length > 20) {
|
|
143
|
+
text += `\n${theme.fg("muted", "... more output")}`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return new Text(text, 0, 0);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// --- Edit tool: show path and diff stats ---
|
|
152
|
+
const originalEdit = createEditTool(cwd);
|
|
153
|
+
pi.registerTool({
|
|
154
|
+
name: "edit",
|
|
155
|
+
label: "edit",
|
|
156
|
+
description: originalEdit.description,
|
|
157
|
+
parameters: originalEdit.parameters,
|
|
158
|
+
|
|
159
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
160
|
+
return originalEdit.execute(toolCallId, params, signal, onUpdate);
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
renderCall(args, theme) {
|
|
164
|
+
let text = theme.fg("toolTitle", theme.bold("edit "));
|
|
165
|
+
text += theme.fg("accent", args.path);
|
|
166
|
+
return new Text(text, 0, 0);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
170
|
+
if (isPartial) return new Text(theme.fg("warning", "Editing..."), 0, 0);
|
|
171
|
+
|
|
172
|
+
const details = result.details as EditToolDetails | undefined;
|
|
173
|
+
const content = result.content[0];
|
|
174
|
+
|
|
175
|
+
if (content?.type === "text" && content.text.startsWith("Error")) {
|
|
176
|
+
return new Text(theme.fg("error", content.text.split("\n")[0]), 0, 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!details?.diff) {
|
|
180
|
+
return new Text(theme.fg("success", "Applied"), 0, 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Count additions and removals from the diff
|
|
184
|
+
const diffLines = details.diff.split("\n");
|
|
185
|
+
let additions = 0;
|
|
186
|
+
let removals = 0;
|
|
187
|
+
for (const line of diffLines) {
|
|
188
|
+
if (line.startsWith("+") && !line.startsWith("+++")) additions++;
|
|
189
|
+
if (line.startsWith("-") && !line.startsWith("---")) removals++;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let text = theme.fg("success", `+${additions}`);
|
|
193
|
+
text += theme.fg("dim", " / ");
|
|
194
|
+
text += theme.fg("error", `-${removals}`);
|
|
195
|
+
|
|
196
|
+
if (expanded) {
|
|
197
|
+
for (const line of diffLines.slice(0, 30)) {
|
|
198
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
199
|
+
text += `\n${theme.fg("success", line)}`;
|
|
200
|
+
} else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
201
|
+
text += `\n${theme.fg("error", line)}`;
|
|
202
|
+
} else {
|
|
203
|
+
text += `\n${theme.fg("dim", line)}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (diffLines.length > 30) {
|
|
207
|
+
text += `\n${theme.fg("muted", `... ${diffLines.length - 30} more diff lines`)}`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return new Text(text, 0, 0);
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// --- Write tool: show path and size ---
|
|
216
|
+
const originalWrite = createWriteTool(cwd);
|
|
217
|
+
pi.registerTool({
|
|
218
|
+
name: "write",
|
|
219
|
+
label: "write",
|
|
220
|
+
description: originalWrite.description,
|
|
221
|
+
parameters: originalWrite.parameters,
|
|
222
|
+
|
|
223
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
224
|
+
return originalWrite.execute(toolCallId, params, signal, onUpdate);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
renderCall(args, theme) {
|
|
228
|
+
let text = theme.fg("toolTitle", theme.bold("write "));
|
|
229
|
+
text += theme.fg("accent", args.path);
|
|
230
|
+
const lineCount = args.content.split("\n").length;
|
|
231
|
+
text += theme.fg("dim", ` (${lineCount} lines)`);
|
|
232
|
+
return new Text(text, 0, 0);
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
renderResult(result, { isPartial }, theme) {
|
|
236
|
+
if (isPartial) return new Text(theme.fg("warning", "Writing..."), 0, 0);
|
|
237
|
+
|
|
238
|
+
const content = result.content[0];
|
|
239
|
+
if (content?.type === "text" && content.text.startsWith("Error")) {
|
|
240
|
+
return new Text(theme.fg("error", content.text.split("\n")[0]), 0, 0);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return new Text(theme.fg("success", "Written"), 0, 0);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Rules Extension
|
|
3
|
+
*
|
|
4
|
+
* Scans the project's .claude/rules/ folder for rule files and lists them
|
|
5
|
+
* in the system prompt. The agent can then use the read tool to load
|
|
6
|
+
* specific rules when needed.
|
|
7
|
+
*
|
|
8
|
+
* Best practices for .claude/rules/:
|
|
9
|
+
* - Keep rules focused: Each file should cover one topic (e.g., testing.md, api-design.md)
|
|
10
|
+
* - Use descriptive filenames: The filename should indicate what the rules cover
|
|
11
|
+
* - Use conditional rules sparingly: Only add paths frontmatter when rules truly apply to specific file types
|
|
12
|
+
* - Organize with subdirectories: Group related rules (e.g., frontend/, backend/)
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
16
|
+
* 2. Create .claude/rules/ folder in your project root
|
|
17
|
+
* 3. Add .md files with your rules
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import * as fs from "node:fs";
|
|
21
|
+
import * as path from "node:path";
|
|
22
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Recursively find all .md files in a directory
|
|
26
|
+
*/
|
|
27
|
+
function findMarkdownFiles(dir: string, basePath: string = ""): string[] {
|
|
28
|
+
const results: string[] = [];
|
|
29
|
+
|
|
30
|
+
if (!fs.existsSync(dir)) {
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
35
|
+
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
38
|
+
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
results.push(...findMarkdownFiles(path.join(dir, entry.name), relativePath));
|
|
41
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
42
|
+
results.push(relativePath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function claudeRulesExtension(pi: ExtensionAPI) {
|
|
50
|
+
let ruleFiles: string[] = [];
|
|
51
|
+
let rulesDir: string = "";
|
|
52
|
+
|
|
53
|
+
// Scan for rules on session start
|
|
54
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
55
|
+
rulesDir = path.join(ctx.cwd, ".claude", "rules");
|
|
56
|
+
ruleFiles = findMarkdownFiles(rulesDir);
|
|
57
|
+
|
|
58
|
+
if (ruleFiles.length > 0) {
|
|
59
|
+
ctx.ui.notify(`Found ${ruleFiles.length} rule(s) in .claude/rules/`, "info");
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Append available rules to system prompt
|
|
64
|
+
pi.on("before_agent_start", async (event) => {
|
|
65
|
+
if (ruleFiles.length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const rulesList = ruleFiles.map((f) => `- .claude/rules/${f}`).join("\n");
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
systemPrompt:
|
|
73
|
+
event.systemPrompt +
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
## Project Rules
|
|
77
|
+
|
|
78
|
+
The following project rules are available in .claude/rules/:
|
|
79
|
+
|
|
80
|
+
${rulesList}
|
|
81
|
+
|
|
82
|
+
When working on tasks related to these rules, use the read tool to load the relevant rule files for guidance.
|
|
83
|
+
`,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the pi.getCommands() API by providing a /commands command
|
|
5
|
+
* that lists all available slash commands in the current session.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
9
|
+
* 2. Use /commands to see available commands
|
|
10
|
+
* 3. Use /commands extensions to filter by source
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ExtensionAPI, SlashCommandInfo } from "@mariozechner/pi-coding-agent";
|
|
14
|
+
|
|
15
|
+
export default function commandsExtension(pi: ExtensionAPI) {
|
|
16
|
+
pi.registerCommand("commands", {
|
|
17
|
+
description: "List available slash commands",
|
|
18
|
+
getArgumentCompletions: (prefix) => {
|
|
19
|
+
const sources = ["extension", "prompt", "skill"];
|
|
20
|
+
const filtered = sources.filter((s) => s.startsWith(prefix));
|
|
21
|
+
return filtered.length > 0 ? filtered.map((s) => ({ value: s, label: s })) : null;
|
|
22
|
+
},
|
|
23
|
+
handler: async (args, ctx) => {
|
|
24
|
+
const commands = pi.getCommands();
|
|
25
|
+
const sourceFilter = args.trim() as "extension" | "prompt" | "skill" | "";
|
|
26
|
+
|
|
27
|
+
// Filter by source if specified
|
|
28
|
+
const filtered = sourceFilter ? commands.filter((c) => c.source === sourceFilter) : commands;
|
|
29
|
+
|
|
30
|
+
if (filtered.length === 0) {
|
|
31
|
+
ctx.ui.notify(sourceFilter ? `No ${sourceFilter} commands found` : "No commands found", "info");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Build selection items grouped by source
|
|
36
|
+
const formatCommand = (cmd: SlashCommandInfo): string => {
|
|
37
|
+
const desc = cmd.description ? ` - ${cmd.description}` : "";
|
|
38
|
+
return `/${cmd.name}${desc}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const items: string[] = [];
|
|
42
|
+
const sources: Array<{ key: "extension" | "prompt" | "skill"; label: string }> = [
|
|
43
|
+
{ key: "extension", label: "Extensions" },
|
|
44
|
+
{ key: "prompt", label: "Prompts" },
|
|
45
|
+
{ key: "skill", label: "Skills" },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
for (const { key, label } of sources) {
|
|
49
|
+
const cmds = filtered.filter((c) => c.source === key);
|
|
50
|
+
if (cmds.length > 0) {
|
|
51
|
+
items.push(`--- ${label} ---`);
|
|
52
|
+
items.push(...cmds.map(formatCommand));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Show in a selector (user can scroll and see all commands)
|
|
57
|
+
const selected = await ctx.ui.select("Available Commands", items);
|
|
58
|
+
|
|
59
|
+
// If user selected a command (not a header), offer to show its path
|
|
60
|
+
if (selected && !selected.startsWith("---")) {
|
|
61
|
+
const cmdName = selected.split(" - ")[0].slice(1); // Remove leading /
|
|
62
|
+
const cmd = commands.find((c) => c.name === cmdName);
|
|
63
|
+
if (cmd?.path) {
|
|
64
|
+
const showPath = await ctx.ui.confirm(cmd.name, `View source path?\n${cmd.path}`);
|
|
65
|
+
if (showPath) {
|
|
66
|
+
ctx.ui.notify(cmd.path, "info");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm Destructive Actions Extension
|
|
3
|
+
*
|
|
4
|
+
* Prompts for confirmation before destructive session actions (clear, switch, branch).
|
|
5
|
+
* Demonstrates how to cancel session events using the before_* events.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI, SessionBeforeSwitchEvent, SessionMessageEntry } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
export default function (pi: ExtensionAPI) {
|
|
11
|
+
pi.on("session_before_switch", async (event: SessionBeforeSwitchEvent, ctx) => {
|
|
12
|
+
if (!ctx.hasUI) return;
|
|
13
|
+
|
|
14
|
+
if (event.reason === "new") {
|
|
15
|
+
const confirmed = await ctx.ui.confirm(
|
|
16
|
+
"Clear session?",
|
|
17
|
+
"This will delete all messages in the current session.",
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (!confirmed) {
|
|
21
|
+
ctx.ui.notify("Clear cancelled", "info");
|
|
22
|
+
return { cancel: true };
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// reason === "resume" - check if there are unsaved changes (messages since last assistant response)
|
|
28
|
+
const entries = ctx.sessionManager.getEntries();
|
|
29
|
+
const hasUnsavedWork = entries.some(
|
|
30
|
+
(e): e is SessionMessageEntry => e.type === "message" && e.message.role === "user",
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (hasUnsavedWork) {
|
|
34
|
+
const confirmed = await ctx.ui.confirm(
|
|
35
|
+
"Switch session?",
|
|
36
|
+
"You have messages in the current session. Switch anyway?",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!confirmed) {
|
|
40
|
+
ctx.ui.notify("Switch cancelled", "info");
|
|
41
|
+
return { cancel: true };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
pi.on("session_before_fork", async (event, ctx) => {
|
|
47
|
+
if (!ctx.hasUI) return;
|
|
48
|
+
|
|
49
|
+
const choice = await ctx.ui.select(`Fork from entry ${event.entryId.slice(0, 8)}?`, [
|
|
50
|
+
"Yes, create fork",
|
|
51
|
+
"No, stay in current session",
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
if (choice !== "Yes, create fork") {
|
|
55
|
+
ctx.ui.notify("Fork cancelled", "info");
|
|
56
|
+
return { cancel: true };
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|