@imdigitalashish/zpi 0.1.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 +2801 -0
- package/README.md +95 -0
- package/dist/cli/args.d.ts +47 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +293 -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 +2353 -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 +402 -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 +626 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +984 -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/memory.d.ts +64 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +247 -0
- package/dist/core/memory.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 +149 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +102 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +515 -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 +403 -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 +1426 -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 +238 -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 +230 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +656 -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 +23 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/system-prompt.d.ts +26 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +150 -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 +102 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +71 -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/memory.d.ts +45 -0
- package/dist/core/tools/memory.d.ts.map +1 -0
- package/dist/core/tools/memory.js +346 -0
- package/dist/core/tools/memory.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 +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -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 +651 -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 +58 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +299 -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 +636 -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 +316 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3848 -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 +207 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +548 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1935 -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 +203 -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/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 +127 -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 +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceR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AC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YAClE,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,MAAM,GAAG,iBAAiB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;gBACvD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;oBAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;gBACxE,CAAC;qBAAM,CAAC;oBACP,cAAc,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;gBAC5C,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,mCAAmC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;YAC5G,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC;YACrF,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QACvE,CAAC;IACF,CAAC;IAED,OAAO;QACN,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrC,WAAW,EAAE,CAAC,GAAG,cAAc,EAAE,GAAG,oBAAoB,CAAC;KACzD,CAAC;AAAA,CACF","sourcesContent":["import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from \"fs\";\r\nimport ignore from \"ignore\";\r\nimport { homedir } from \"os\";\r\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"path\";\r\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.js\";\r\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\r\nimport type { ResourceDiagnostic } from \"./diagnostics.js\";\r\n\r\n/** Max name length per spec */\r\nconst MAX_NAME_LENGTH = 64;\r\n\r\n/** Max description length per spec */\r\nconst MAX_DESCRIPTION_LENGTH = 1024;\r\n\r\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\r\n\r\ntype IgnoreMatcher = ReturnType<typeof ignore>;\r\n\r\nfunction toPosixPath(p: string): string {\r\n\treturn p.split(sep).join(\"/\");\r\n}\r\n\r\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\r\n\tconst trimmed = line.trim();\r\n\tif (!trimmed) return null;\r\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\r\n\r\n\tlet pattern = line;\r\n\tlet negated = false;\r\n\r\n\tif (pattern.startsWith(\"!\")) {\r\n\t\tnegated = true;\r\n\t\tpattern = pattern.slice(1);\r\n\t} else if (pattern.startsWith(\"\\\\!\")) {\r\n\t\tpattern = pattern.slice(1);\r\n\t}\r\n\r\n\tif (pattern.startsWith(\"/\")) {\r\n\t\tpattern = pattern.slice(1);\r\n\t}\r\n\r\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\r\n\treturn negated ? `!${prefixed}` : prefixed;\r\n}\r\n\r\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\r\n\tconst relativeDir = relative(rootDir, dir);\r\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\r\n\r\n\tfor (const filename of IGNORE_FILE_NAMES) {\r\n\t\tconst ignorePath = join(dir, filename);\r\n\t\tif (!existsSync(ignorePath)) continue;\r\n\t\ttry {\r\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\r\n\t\t\tconst patterns = content\r\n\t\t\t\t.split(/\\r?\\n/)\r\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\r\n\t\t\t\t.filter((line): line is string => Boolean(line));\r\n\t\t\tif (patterns.length > 0) {\r\n\t\t\t\tig.add(patterns);\r\n\t\t\t}\r\n\t\t} catch {}\r\n\t}\r\n}\r\n\r\nexport interface SkillFrontmatter {\r\n\tname?: string;\r\n\tdescription?: string;\r\n\t\"disable-model-invocation\"?: boolean;\r\n\t[key: string]: unknown;\r\n}\r\n\r\nexport interface Skill {\r\n\tname: string;\r\n\tdescription: string;\r\n\tfilePath: string;\r\n\tbaseDir: string;\r\n\tsource: string;\r\n\tdisableModelInvocation: boolean;\r\n}\r\n\r\nexport interface LoadSkillsResult {\r\n\tskills: Skill[];\r\n\tdiagnostics: ResourceDiagnostic[];\r\n}\r\n\r\n/**\r\n * Validate skill name per Agent Skills spec.\r\n * Returns array of validation error messages (empty if valid).\r\n */\r\nfunction validateName(name: string, parentDirName: string): string[] {\r\n\tconst errors: string[] = [];\r\n\r\n\tif (name !== parentDirName) {\r\n\t\terrors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\r\n\t}\r\n\r\n\tif (name.length > MAX_NAME_LENGTH) {\r\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\r\n\t}\r\n\r\n\tif (!/^[a-z0-9-]+$/.test(name)) {\r\n\t\terrors.push(`name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)`);\r\n\t}\r\n\r\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\r\n\t\terrors.push(`name must not start or end with a hyphen`);\r\n\t}\r\n\r\n\tif (name.includes(\"--\")) {\r\n\t\terrors.push(`name must not contain consecutive hyphens`);\r\n\t}\r\n\r\n\treturn errors;\r\n}\r\n\r\n/**\r\n * Validate description per Agent Skills spec.\r\n */\r\nfunction validateDescription(description: string | undefined): string[] {\r\n\tconst errors: string[] = [];\r\n\r\n\tif (!description || description.trim() === \"\") {\r\n\t\terrors.push(\"description is required\");\r\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\r\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\r\n\t}\r\n\r\n\treturn errors;\r\n}\r\n\r\nexport interface LoadSkillsFromDirOptions {\r\n\t/** Directory to scan for skills */\r\n\tdir: string;\r\n\t/** Source identifier for these skills */\r\n\tsource: string;\r\n}\r\n\r\n/**\r\n * Load skills from a directory.\r\n *\r\n * Discovery rules:\r\n * - direct .md children in the root\r\n * - recursive SKILL.md under subdirectories\r\n */\r\nexport function loadSkillsFromDir(options: LoadSkillsFromDirOptions): LoadSkillsResult {\r\n\tconst { dir, source } = options;\r\n\treturn loadSkillsFromDirInternal(dir, source, true);\r\n}\r\n\r\nfunction loadSkillsFromDirInternal(\r\n\tdir: string,\r\n\tsource: string,\r\n\tincludeRootFiles: boolean,\r\n\tignoreMatcher?: IgnoreMatcher,\r\n\trootDir?: string,\r\n): LoadSkillsResult {\r\n\tconst skills: Skill[] = [];\r\n\tconst diagnostics: ResourceDiagnostic[] = [];\r\n\r\n\tif (!existsSync(dir)) {\r\n\t\treturn { skills, diagnostics };\r\n\t}\r\n\r\n\tconst root = rootDir ?? dir;\r\n\tconst ig = ignoreMatcher ?? ignore();\r\n\taddIgnoreRules(ig, dir, root);\r\n\r\n\ttry {\r\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\r\n\r\n\t\tfor (const entry of entries) {\r\n\t\t\tif (entry.name.startsWith(\".\")) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// Skip node_modules to avoid scanning dependencies\r\n\t\t\tif (entry.name === \"node_modules\") {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tconst fullPath = join(dir, entry.name);\r\n\r\n\t\t\t// For symlinks, check if they point to a directory and follow them\r\n\t\t\tlet isDirectory = entry.isDirectory();\r\n\t\t\tlet isFile = entry.isFile();\r\n\t\t\tif (entry.isSymbolicLink()) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tconst stats = statSync(fullPath);\r\n\t\t\t\t\tisDirectory = stats.isDirectory();\r\n\t\t\t\t\tisFile = stats.isFile();\r\n\t\t\t\t} catch {\r\n\t\t\t\t\t// Broken symlink, skip it\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\r\n\t\t\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\r\n\t\t\tif (ig.ignores(ignorePath)) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (isDirectory) {\r\n\t\t\t\tconst subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);\r\n\t\t\t\tskills.push(...subResult.skills);\r\n\t\t\t\tdiagnostics.push(...subResult.diagnostics);\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (!isFile) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tconst isRootMd = includeRootFiles && entry.name.endsWith(\".md\");\r\n\t\t\tconst isSkillMd = !includeRootFiles && entry.name === \"SKILL.md\";\r\n\t\t\tif (!isRootMd && !isSkillMd) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\r\n\t\t\tif (result.skill) {\r\n\t\t\t\tskills.push(result.skill);\r\n\t\t\t}\r\n\t\t\tdiagnostics.push(...result.diagnostics);\r\n\t\t}\r\n\t} catch {}\r\n\r\n\treturn { skills, diagnostics };\r\n}\r\n\r\nfunction loadSkillFromFile(\r\n\tfilePath: string,\r\n\tsource: string,\r\n): { skill: Skill | null; diagnostics: ResourceDiagnostic[] } {\r\n\tconst diagnostics: ResourceDiagnostic[] = [];\r\n\r\n\ttry {\r\n\t\tconst rawContent = readFileSync(filePath, \"utf-8\");\r\n\t\tconst { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);\r\n\t\tconst skillDir = dirname(filePath);\r\n\t\tconst parentDirName = basename(skillDir);\r\n\r\n\t\t// Validate description\r\n\t\tconst descErrors = validateDescription(frontmatter.description);\r\n\t\tfor (const error of descErrors) {\r\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\r\n\t\t}\r\n\r\n\t\t// Use name from frontmatter, or fall back to parent directory name\r\n\t\tconst name = frontmatter.name || parentDirName;\r\n\r\n\t\t// Validate name\r\n\t\tconst nameErrors = validateName(name, parentDirName);\r\n\t\tfor (const error of nameErrors) {\r\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\r\n\t\t}\r\n\r\n\t\t// Still load the skill even with warnings (unless description is completely missing)\r\n\t\tif (!frontmatter.description || frontmatter.description.trim() === \"\") {\r\n\t\t\treturn { skill: null, diagnostics };\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tskill: {\r\n\t\t\t\tname,\r\n\t\t\t\tdescription: frontmatter.description,\r\n\t\t\t\tfilePath,\r\n\t\t\t\tbaseDir: skillDir,\r\n\t\t\t\tsource,\r\n\t\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\r\n\t\t\t},\r\n\t\t\tdiagnostics,\r\n\t\t};\r\n\t} catch (error) {\r\n\t\tconst message = error instanceof Error ? error.message : \"failed to parse skill file\";\r\n\t\tdiagnostics.push({ type: \"warning\", message, path: filePath });\r\n\t\treturn { skill: null, diagnostics };\r\n\t}\r\n}\r\n\r\n/**\r\n * Format skills for inclusion in a system prompt.\r\n * Uses XML format per Agent Skills standard.\r\n * See: https://agentskills.io/integrate-skills\r\n *\r\n * Skills with disableModelInvocation=true are excluded from the prompt\r\n * (they can only be invoked explicitly via /skill:name commands).\r\n */\r\nexport function formatSkillsForPrompt(skills: Skill[]): string {\r\n\tconst visibleSkills = skills.filter((s) => !s.disableModelInvocation);\r\n\r\n\tif (visibleSkills.length === 0) {\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tconst lines = [\r\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\r\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\r\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\r\n\t\t\"\",\r\n\t\t\"<available_skills>\",\r\n\t];\r\n\r\n\tfor (const skill of visibleSkills) {\r\n\t\tlines.push(\" <skill>\");\r\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\r\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\r\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\r\n\t\tlines.push(\" </skill>\");\r\n\t}\r\n\r\n\tlines.push(\"</available_skills>\");\r\n\r\n\treturn lines.join(\"\\n\");\r\n}\r\n\r\nfunction escapeXml(str: string): string {\r\n\treturn str\r\n\t\t.replace(/&/g, \"&\")\r\n\t\t.replace(/</g, \"<\")\r\n\t\t.replace(/>/g, \">\")\r\n\t\t.replace(/\"/g, \""\")\r\n\t\t.replace(/'/g, \"'\");\r\n}\r\n\r\nexport interface LoadSkillsOptions {\r\n\t/** Working directory for project-local skills. Default: process.cwd() */\r\n\tcwd?: string;\r\n\t/** Agent config directory for global skills. Default: ~/.pi/agent */\r\n\tagentDir?: string;\r\n\t/** Explicit skill paths (files or directories) */\r\n\tskillPaths?: string[];\r\n\t/** Include default skills directories. Default: true */\r\n\tincludeDefaults?: boolean;\r\n}\r\n\r\nfunction normalizePath(input: string): string {\r\n\tconst trimmed = input.trim();\r\n\tif (trimmed === \"~\") return homedir();\r\n\tif (trimmed.startsWith(\"~/\")) return join(homedir(), trimmed.slice(2));\r\n\tif (trimmed.startsWith(\"~\")) return join(homedir(), trimmed.slice(1));\r\n\treturn trimmed;\r\n}\r\n\r\nfunction resolveSkillPath(p: string, cwd: string): string {\r\n\tconst normalized = normalizePath(p);\r\n\treturn isAbsolute(normalized) ? normalized : resolve(cwd, normalized);\r\n}\r\n\r\n/**\r\n * Load skills from all configured locations.\r\n * Returns skills and any validation diagnostics.\r\n */\r\nexport function loadSkills(options: LoadSkillsOptions = {}): LoadSkillsResult {\r\n\tconst { cwd = process.cwd(), agentDir, skillPaths = [], includeDefaults = true } = options;\r\n\r\n\t// Resolve agentDir - if not provided, use default from config\r\n\tconst resolvedAgentDir = agentDir ?? getAgentDir();\r\n\r\n\tconst skillMap = new Map<string, Skill>();\r\n\tconst realPathSet = new Set<string>();\r\n\tconst allDiagnostics: ResourceDiagnostic[] = [];\r\n\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\r\n\r\n\tfunction addSkills(result: LoadSkillsResult) {\r\n\t\tallDiagnostics.push(...result.diagnostics);\r\n\t\tfor (const skill of result.skills) {\r\n\t\t\t// Resolve symlinks to detect duplicate files\r\n\t\t\tlet realPath: string;\r\n\t\t\ttry {\r\n\t\t\t\trealPath = realpathSync(skill.filePath);\r\n\t\t\t} catch {\r\n\t\t\t\trealPath = skill.filePath;\r\n\t\t\t}\r\n\r\n\t\t\t// Skip silently if we've already loaded this exact file (via symlink)\r\n\t\t\tif (realPathSet.has(realPath)) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tconst existing = skillMap.get(skill.name);\r\n\t\t\tif (existing) {\r\n\t\t\t\tcollisionDiagnostics.push({\r\n\t\t\t\t\ttype: \"collision\",\r\n\t\t\t\t\tmessage: `name \"${skill.name}\" collision`,\r\n\t\t\t\t\tpath: skill.filePath,\r\n\t\t\t\t\tcollision: {\r\n\t\t\t\t\t\tresourceType: \"skill\",\r\n\t\t\t\t\t\tname: skill.name,\r\n\t\t\t\t\t\twinnerPath: existing.filePath,\r\n\t\t\t\t\t\tloserPath: skill.filePath,\r\n\t\t\t\t\t},\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tskillMap.set(skill.name, skill);\r\n\t\t\t\trealPathSet.add(realPath);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (includeDefaults) {\r\n\t\taddSkills(loadSkillsFromDirInternal(join(resolvedAgentDir, \"skills\"), \"user\", true));\r\n\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, CONFIG_DIR_NAME, \"skills\"), \"project\", true));\r\n\t}\r\n\r\n\tconst userSkillsDir = join(resolvedAgentDir, \"skills\");\r\n\tconst projectSkillsDir = resolve(cwd, CONFIG_DIR_NAME, \"skills\");\r\n\r\n\tconst isUnderPath = (target: string, root: string): boolean => {\r\n\t\tconst normalizedRoot = resolve(root);\r\n\t\tif (target === normalizedRoot) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\r\n\t\treturn target.startsWith(prefix);\r\n\t};\r\n\r\n\tconst getSource = (resolvedPath: string): \"user\" | \"project\" | \"path\" => {\r\n\t\tif (!includeDefaults) {\r\n\t\t\tif (isUnderPath(resolvedPath, userSkillsDir)) return \"user\";\r\n\t\t\tif (isUnderPath(resolvedPath, projectSkillsDir)) return \"project\";\r\n\t\t}\r\n\t\treturn \"path\";\r\n\t};\r\n\r\n\tfor (const rawPath of skillPaths) {\r\n\t\tconst resolvedPath = resolveSkillPath(rawPath, cwd);\r\n\t\tif (!existsSync(resolvedPath)) {\r\n\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path does not exist\", path: resolvedPath });\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst stats = statSync(resolvedPath);\r\n\t\t\tconst source = getSource(resolvedPath);\r\n\t\t\tif (stats.isDirectory()) {\r\n\t\t\t\taddSkills(loadSkillsFromDirInternal(resolvedPath, source, true));\r\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\r\n\t\t\t\tconst result = loadSkillFromFile(resolvedPath, source);\r\n\t\t\t\tif (result.skill) {\r\n\t\t\t\t\taddSkills({ skills: [result.skill], diagnostics: result.diagnostics });\r\n\t\t\t\t} else {\r\n\t\t\t\t\tallDiagnostics.push(...result.diagnostics);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path is not a markdown file\", path: resolvedPath });\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconst message = error instanceof Error ? error.message : \"failed to read skill path\";\r\n\t\t\tallDiagnostics.push({ type: \"warning\", message, path: resolvedPath });\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tskills: Array.from(skillMap.values()),\r\n\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\r\n\t};\r\n}\r\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SlashCommandSource = "extension" | "prompt" | "skill";
|
|
2
|
+
export type SlashCommandLocation = "user" | "project" | "path";
|
|
3
|
+
export interface SlashCommandInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
source: SlashCommandSource;
|
|
7
|
+
location?: SlashCommandLocation;
|
|
8
|
+
path?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BuiltinSlashCommand {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand>;
|
|
15
|
+
//# sourceMappingURL=slash-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,mBAAmB,CAqBrE,CAAC","sourcesContent":["export type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\r\n\r\nexport type SlashCommandLocation = \"user\" | \"project\" | \"path\";\r\n\r\nexport interface SlashCommandInfo {\r\n\tname: string;\r\n\tdescription?: string;\r\n\tsource: SlashCommandSource;\r\n\tlocation?: SlashCommandLocation;\r\n\tpath?: string;\r\n}\r\n\r\nexport interface BuiltinSlashCommand {\r\n\tname: string;\r\n\tdescription: string;\r\n}\r\n\r\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\r\n\t{ name: \"settings\", description: \"Open settings menu\" },\r\n\t{ name: \"model\", description: \"Select model (opens selector UI)\" },\r\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\r\n\t{ name: \"export\", description: \"Export session to HTML file\" },\r\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\r\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\r\n\t{ name: \"name\", description: \"Set session display name\" },\r\n\t{ name: \"session\", description: \"Show session info and stats\" },\r\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\r\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\r\n\t{ name: \"fork\", description: \"Create a new fork from a previous message\" },\r\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\r\n\t{ name: \"login\", description: \"Login with OAuth provider\" },\r\n\t{ name: \"logout\", description: \"Logout from OAuth provider\" },\r\n\t{ name: \"new\", description: \"Start a new session\" },\r\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\r\n\t{ name: \"resume\", description: \"Resume a different session\" },\r\n\t{ name: \"reload\", description: \"Reload extensions, skills, prompts, and themes\" },\r\n\t{ name: \"memory\", description: \"View, search, delete, or compact project memories\" },\r\n\t{ name: \"quit\", description: \"Quit pi\" },\r\n];\r\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const BUILTIN_SLASH_COMMANDS = [
|
|
2
|
+
{ name: "settings", description: "Open settings menu" },
|
|
3
|
+
{ name: "model", description: "Select model (opens selector UI)" },
|
|
4
|
+
{ name: "scoped-models", description: "Enable/disable models for Ctrl+P cycling" },
|
|
5
|
+
{ name: "export", description: "Export session to HTML file" },
|
|
6
|
+
{ name: "share", description: "Share session as a secret GitHub gist" },
|
|
7
|
+
{ name: "copy", description: "Copy last agent message to clipboard" },
|
|
8
|
+
{ name: "name", description: "Set session display name" },
|
|
9
|
+
{ name: "session", description: "Show session info and stats" },
|
|
10
|
+
{ name: "changelog", description: "Show changelog entries" },
|
|
11
|
+
{ name: "hotkeys", description: "Show all keyboard shortcuts" },
|
|
12
|
+
{ name: "fork", description: "Create a new fork from a previous message" },
|
|
13
|
+
{ name: "tree", description: "Navigate session tree (switch branches)" },
|
|
14
|
+
{ name: "login", description: "Login with OAuth provider" },
|
|
15
|
+
{ name: "logout", description: "Logout from OAuth provider" },
|
|
16
|
+
{ name: "new", description: "Start a new session" },
|
|
17
|
+
{ name: "compact", description: "Manually compact the session context" },
|
|
18
|
+
{ name: "resume", description: "Resume a different session" },
|
|
19
|
+
{ name: "reload", description: "Reload extensions, skills, prompts, and themes" },
|
|
20
|
+
{ name: "memory", description: "View, search, delete, or compact project memories" },
|
|
21
|
+
{ name: "quit", description: "Quit pi" },
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=slash-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,sBAAsB,GAAuC;IACzE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,oBAA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["export type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\r\n\r\nexport type SlashCommandLocation = \"user\" | \"project\" | \"path\";\r\n\r\nexport interface SlashCommandInfo {\r\n\tname: string;\r\n\tdescription?: string;\r\n\tsource: SlashCommandSource;\r\n\tlocation?: SlashCommandLocation;\r\n\tpath?: string;\r\n}\r\n\r\nexport interface BuiltinSlashCommand {\r\n\tname: string;\r\n\tdescription: string;\r\n}\r\n\r\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\r\n\t{ name: \"settings\", description: \"Open settings menu\" },\r\n\t{ name: \"model\", description: \"Select model (opens selector UI)\" },\r\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\r\n\t{ name: \"export\", description: \"Export session to HTML file\" },\r\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\r\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\r\n\t{ name: \"name\", description: \"Set session display name\" },\r\n\t{ name: \"session\", description: \"Show session info and stats\" },\r\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\r\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\r\n\t{ name: \"fork\", description: \"Create a new fork from a previous message\" },\r\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\r\n\t{ name: \"login\", description: \"Login with OAuth provider\" },\r\n\t{ name: \"logout\", description: \"Logout from OAuth provider\" },\r\n\t{ name: \"new\", description: \"Start a new session\" },\r\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\r\n\t{ name: \"resume\", description: \"Resume a different session\" },\r\n\t{ name: \"reload\", description: \"Reload extensions, skills, prompts, and themes\" },\r\n\t{ name: \"memory\", description: \"View, search, delete, or compact project memories\" },\r\n\t{ name: \"quit\", description: \"Quit pi\" },\r\n];\r\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System prompt construction and project context loading
|
|
3
|
+
*/
|
|
4
|
+
import { type Skill } from "./skills.js";
|
|
5
|
+
export interface BuildSystemPromptOptions {
|
|
6
|
+
/** Custom system prompt (replaces default). */
|
|
7
|
+
customPrompt?: string;
|
|
8
|
+
/** Tools to include in prompt. Default: [read, bash, edit, write] */
|
|
9
|
+
selectedTools?: string[];
|
|
10
|
+
/** Text to append to system prompt. */
|
|
11
|
+
appendSystemPrompt?: string;
|
|
12
|
+
/** Working directory. Default: process.cwd() */
|
|
13
|
+
cwd?: string;
|
|
14
|
+
/** Pre-loaded context files. */
|
|
15
|
+
contextFiles?: Array<{
|
|
16
|
+
path: string;
|
|
17
|
+
content: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Pre-loaded skills. */
|
|
20
|
+
skills?: Skill[];
|
|
21
|
+
/** Whether the memory system is enabled. Default: true */
|
|
22
|
+
memoryEnabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Build the system prompt with tools, guidelines, and context */
|
|
25
|
+
export declare function buildSystemPrompt(options?: BuildSystemPromptOptions): string;
|
|
26
|
+
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAiBhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,MAAM,CAoKhF","sourcesContent":["/**\r\n * System prompt construction and project context loading\r\n */\r\n\r\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\r\nimport { buildMemoryPromptSection } from \"./memory.js\";\r\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\r\n\r\n/** Tool descriptions for system prompt */\r\nconst toolDescriptions: Record<string, string> = {\r\n\tread: \"Read file contents\",\r\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\r\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\r\n\twrite: \"Create or overwrite files\",\r\n\tgrep: \"Search file contents for patterns (respects .gitignore)\",\r\n\tfind: \"Find files by glob pattern (respects .gitignore)\",\r\n\tls: \"List directory contents\",\r\n\tmemory_write: \"Save a memory (procedural workflow, preference, or session summary)\",\r\n\tmemory_read: \"Read stored memories by type, ID, or search query\",\r\n\tmemory_update: \"Update an existing memory\",\r\n\tmemory_delete: \"Delete a memory by ID\",\r\n};\r\n\r\nexport interface BuildSystemPromptOptions {\r\n\t/** Custom system prompt (replaces default). */\r\n\tcustomPrompt?: string;\r\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\r\n\tselectedTools?: string[];\r\n\t/** Text to append to system prompt. */\r\n\tappendSystemPrompt?: string;\r\n\t/** Working directory. Default: process.cwd() */\r\n\tcwd?: string;\r\n\t/** Pre-loaded context files. */\r\n\tcontextFiles?: Array<{ path: string; content: string }>;\r\n\t/** Pre-loaded skills. */\r\n\tskills?: Skill[];\r\n\t/** Whether the memory system is enabled. Default: true */\r\n\tmemoryEnabled?: boolean;\r\n}\r\n\r\n/** Build the system prompt with tools, guidelines, and context */\r\nexport function buildSystemPrompt(options: BuildSystemPromptOptions = {}): string {\r\n\tconst {\r\n\t\tcustomPrompt,\r\n\t\tselectedTools,\r\n\t\tappendSystemPrompt,\r\n\t\tcwd,\r\n\t\tcontextFiles: providedContextFiles,\r\n\t\tskills: providedSkills,\r\n\t\tmemoryEnabled = true,\r\n\t} = options;\r\n\tconst resolvedCwd = cwd ?? process.cwd();\r\n\r\n\tconst now = new Date();\r\n\tconst dateTime = now.toLocaleString(\"en-US\", {\r\n\t\tweekday: \"long\",\r\n\t\tyear: \"numeric\",\r\n\t\tmonth: \"long\",\r\n\t\tday: \"numeric\",\r\n\t\thour: \"2-digit\",\r\n\t\tminute: \"2-digit\",\r\n\t\tsecond: \"2-digit\",\r\n\t\ttimeZoneName: \"short\",\r\n\t});\r\n\r\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\r\n\r\n\tconst contextFiles = providedContextFiles ?? [];\r\n\tconst skills = providedSkills ?? [];\r\n\r\n\tif (customPrompt) {\r\n\t\tlet prompt = customPrompt;\r\n\r\n\t\tif (appendSection) {\r\n\t\t\tprompt += appendSection;\r\n\t\t}\r\n\r\n\t\t// Append project context files\r\n\t\tif (contextFiles.length > 0) {\r\n\t\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\r\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\r\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\r\n\t\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Append skills section (only if read tool is available)\r\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\r\n\t\tif (customPromptHasRead && skills.length > 0) {\r\n\t\t\tprompt += formatSkillsForPrompt(skills);\r\n\t\t}\r\n\r\n\t\t// Append memory system context\r\n\t\tif (memoryEnabled) {\r\n\t\t\tprompt += buildMemoryPromptSection(resolvedCwd);\r\n\t\t}\r\n\r\n\t\t// Add date/time and working directory last\r\n\t\tprompt += `\\nCurrent date and time: ${dateTime}`;\r\n\t\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\r\n\r\n\t\treturn prompt;\r\n\t}\r\n\r\n\t// Get absolute paths to documentation and examples\r\n\tconst readmePath = getReadmePath();\r\n\tconst docsPath = getDocsPath();\r\n\tconst examplesPath = getExamplesPath();\r\n\r\n\t// Build tools list based on selected tools (only built-in tools with known descriptions)\r\n\tconst tools = (selectedTools || [\"read\", \"bash\", \"edit\", \"write\"]).filter((t) => t in toolDescriptions);\r\n\tconst toolsList = tools.length > 0 ? tools.map((t) => `- ${t}: ${toolDescriptions[t]}`).join(\"\\n\") : \"(none)\";\r\n\r\n\t// Build guidelines based on which tools are actually available\r\n\tconst guidelinesList: string[] = [];\r\n\r\n\tconst hasBash = tools.includes(\"bash\");\r\n\tconst hasEdit = tools.includes(\"edit\");\r\n\tconst hasWrite = tools.includes(\"write\");\r\n\tconst hasGrep = tools.includes(\"grep\");\r\n\tconst hasFind = tools.includes(\"find\");\r\n\tconst hasLs = tools.includes(\"ls\");\r\n\tconst hasRead = tools.includes(\"read\");\r\n\r\n\t// File exploration guidelines\r\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\r\n\t\tguidelinesList.push(\"Use bash for file operations like ls, rg, find\");\r\n\t} else if (hasBash && (hasGrep || hasFind || hasLs)) {\r\n\t\tguidelinesList.push(\"Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)\");\r\n\t}\r\n\r\n\t// Read before edit guideline\r\n\tif (hasRead && hasEdit) {\r\n\t\tguidelinesList.push(\"Use read to examine files before editing. You must use this tool instead of cat or sed.\");\r\n\t}\r\n\r\n\t// Edit guideline\r\n\tif (hasEdit) {\r\n\t\tguidelinesList.push(\"Use edit for precise changes (old text must match exactly)\");\r\n\t}\r\n\r\n\t// Write guideline\r\n\tif (hasWrite) {\r\n\t\tguidelinesList.push(\"Use write only for new files or complete rewrites\");\r\n\t}\r\n\r\n\t// Output guideline (only when actually writing or executing)\r\n\tif (hasEdit || hasWrite) {\r\n\t\tguidelinesList.push(\r\n\t\t\t\"When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did\",\r\n\t\t);\r\n\t}\r\n\r\n\t// Always include these\r\n\tguidelinesList.push(\"Be concise in your responses\");\r\n\tguidelinesList.push(\"Show file paths clearly when working with files\");\r\n\r\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\r\n\r\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\r\n\r\nAvailable tools:\r\n${toolsList}\r\n\r\nIn addition to the tools above, you may have access to other custom tools depending on the project.\r\n\r\nGuidelines:\r\n${guidelines}\r\n\r\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\r\n- Main documentation: ${readmePath}\r\n- Additional docs: ${docsPath}\r\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\r\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\r\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\r\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\r\n\r\n\tif (appendSection) {\r\n\t\tprompt += appendSection;\r\n\t}\r\n\r\n\t// Append project context files\r\n\tif (contextFiles.length > 0) {\r\n\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\r\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\r\n\t\tfor (const { path: filePath, content } of contextFiles) {\r\n\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\r\n\t\t}\r\n\t}\r\n\r\n\t// Append skills section (only if read tool is available)\r\n\tif (hasRead && skills.length > 0) {\r\n\t\tprompt += formatSkillsForPrompt(skills);\r\n\t}\r\n\r\n\t// Append memory system context\r\n\tif (memoryEnabled) {\r\n\t\tprompt += buildMemoryPromptSection(resolvedCwd);\r\n\t}\r\n\r\n\t// Add date/time and working directory last\r\n\tprompt += `\\nCurrent date and time: ${dateTime}`;\r\n\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\r\n\r\n\treturn prompt;\r\n}\r\n"]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System prompt construction and project context loading
|
|
3
|
+
*/
|
|
4
|
+
import { getDocsPath, getExamplesPath, getReadmePath } from "../config.js";
|
|
5
|
+
import { buildMemoryPromptSection } from "./memory.js";
|
|
6
|
+
import { formatSkillsForPrompt } from "./skills.js";
|
|
7
|
+
/** Tool descriptions for system prompt */
|
|
8
|
+
const toolDescriptions = {
|
|
9
|
+
read: "Read file contents",
|
|
10
|
+
bash: "Execute bash commands (ls, grep, find, etc.)",
|
|
11
|
+
edit: "Make surgical edits to files (find exact text and replace)",
|
|
12
|
+
write: "Create or overwrite files",
|
|
13
|
+
grep: "Search file contents for patterns (respects .gitignore)",
|
|
14
|
+
find: "Find files by glob pattern (respects .gitignore)",
|
|
15
|
+
ls: "List directory contents",
|
|
16
|
+
memory_write: "Save a memory (procedural workflow, preference, or session summary)",
|
|
17
|
+
memory_read: "Read stored memories by type, ID, or search query",
|
|
18
|
+
memory_update: "Update an existing memory",
|
|
19
|
+
memory_delete: "Delete a memory by ID",
|
|
20
|
+
};
|
|
21
|
+
/** Build the system prompt with tools, guidelines, and context */
|
|
22
|
+
export function buildSystemPrompt(options = {}) {
|
|
23
|
+
const { customPrompt, selectedTools, appendSystemPrompt, cwd, contextFiles: providedContextFiles, skills: providedSkills, memoryEnabled = true, } = options;
|
|
24
|
+
const resolvedCwd = cwd ?? process.cwd();
|
|
25
|
+
const now = new Date();
|
|
26
|
+
const dateTime = now.toLocaleString("en-US", {
|
|
27
|
+
weekday: "long",
|
|
28
|
+
year: "numeric",
|
|
29
|
+
month: "long",
|
|
30
|
+
day: "numeric",
|
|
31
|
+
hour: "2-digit",
|
|
32
|
+
minute: "2-digit",
|
|
33
|
+
second: "2-digit",
|
|
34
|
+
timeZoneName: "short",
|
|
35
|
+
});
|
|
36
|
+
const appendSection = appendSystemPrompt ? `\n\n${appendSystemPrompt}` : "";
|
|
37
|
+
const contextFiles = providedContextFiles ?? [];
|
|
38
|
+
const skills = providedSkills ?? [];
|
|
39
|
+
if (customPrompt) {
|
|
40
|
+
let prompt = customPrompt;
|
|
41
|
+
if (appendSection) {
|
|
42
|
+
prompt += appendSection;
|
|
43
|
+
}
|
|
44
|
+
// Append project context files
|
|
45
|
+
if (contextFiles.length > 0) {
|
|
46
|
+
prompt += "\n\n# Project Context\n\n";
|
|
47
|
+
prompt += "Project-specific instructions and guidelines:\n\n";
|
|
48
|
+
for (const { path: filePath, content } of contextFiles) {
|
|
49
|
+
prompt += `## ${filePath}\n\n${content}\n\n`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Append skills section (only if read tool is available)
|
|
53
|
+
const customPromptHasRead = !selectedTools || selectedTools.includes("read");
|
|
54
|
+
if (customPromptHasRead && skills.length > 0) {
|
|
55
|
+
prompt += formatSkillsForPrompt(skills);
|
|
56
|
+
}
|
|
57
|
+
// Append memory system context
|
|
58
|
+
if (memoryEnabled) {
|
|
59
|
+
prompt += buildMemoryPromptSection(resolvedCwd);
|
|
60
|
+
}
|
|
61
|
+
// Add date/time and working directory last
|
|
62
|
+
prompt += `\nCurrent date and time: ${dateTime}`;
|
|
63
|
+
prompt += `\nCurrent working directory: ${resolvedCwd}`;
|
|
64
|
+
return prompt;
|
|
65
|
+
}
|
|
66
|
+
// Get absolute paths to documentation and examples
|
|
67
|
+
const readmePath = getReadmePath();
|
|
68
|
+
const docsPath = getDocsPath();
|
|
69
|
+
const examplesPath = getExamplesPath();
|
|
70
|
+
// Build tools list based on selected tools (only built-in tools with known descriptions)
|
|
71
|
+
const tools = (selectedTools || ["read", "bash", "edit", "write"]).filter((t) => t in toolDescriptions);
|
|
72
|
+
const toolsList = tools.length > 0 ? tools.map((t) => `- ${t}: ${toolDescriptions[t]}`).join("\n") : "(none)";
|
|
73
|
+
// Build guidelines based on which tools are actually available
|
|
74
|
+
const guidelinesList = [];
|
|
75
|
+
const hasBash = tools.includes("bash");
|
|
76
|
+
const hasEdit = tools.includes("edit");
|
|
77
|
+
const hasWrite = tools.includes("write");
|
|
78
|
+
const hasGrep = tools.includes("grep");
|
|
79
|
+
const hasFind = tools.includes("find");
|
|
80
|
+
const hasLs = tools.includes("ls");
|
|
81
|
+
const hasRead = tools.includes("read");
|
|
82
|
+
// File exploration guidelines
|
|
83
|
+
if (hasBash && !hasGrep && !hasFind && !hasLs) {
|
|
84
|
+
guidelinesList.push("Use bash for file operations like ls, rg, find");
|
|
85
|
+
}
|
|
86
|
+
else if (hasBash && (hasGrep || hasFind || hasLs)) {
|
|
87
|
+
guidelinesList.push("Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)");
|
|
88
|
+
}
|
|
89
|
+
// Read before edit guideline
|
|
90
|
+
if (hasRead && hasEdit) {
|
|
91
|
+
guidelinesList.push("Use read to examine files before editing. You must use this tool instead of cat or sed.");
|
|
92
|
+
}
|
|
93
|
+
// Edit guideline
|
|
94
|
+
if (hasEdit) {
|
|
95
|
+
guidelinesList.push("Use edit for precise changes (old text must match exactly)");
|
|
96
|
+
}
|
|
97
|
+
// Write guideline
|
|
98
|
+
if (hasWrite) {
|
|
99
|
+
guidelinesList.push("Use write only for new files or complete rewrites");
|
|
100
|
+
}
|
|
101
|
+
// Output guideline (only when actually writing or executing)
|
|
102
|
+
if (hasEdit || hasWrite) {
|
|
103
|
+
guidelinesList.push("When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did");
|
|
104
|
+
}
|
|
105
|
+
// Always include these
|
|
106
|
+
guidelinesList.push("Be concise in your responses");
|
|
107
|
+
guidelinesList.push("Show file paths clearly when working with files");
|
|
108
|
+
const guidelines = guidelinesList.map((g) => `- ${g}`).join("\n");
|
|
109
|
+
let prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.
|
|
110
|
+
|
|
111
|
+
Available tools:
|
|
112
|
+
${toolsList}
|
|
113
|
+
|
|
114
|
+
In addition to the tools above, you may have access to other custom tools depending on the project.
|
|
115
|
+
|
|
116
|
+
Guidelines:
|
|
117
|
+
${guidelines}
|
|
118
|
+
|
|
119
|
+
Pi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):
|
|
120
|
+
- Main documentation: ${readmePath}
|
|
121
|
+
- Additional docs: ${docsPath}
|
|
122
|
+
- Examples: ${examplesPath} (extensions, custom tools, SDK)
|
|
123
|
+
- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)
|
|
124
|
+
- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing
|
|
125
|
+
- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;
|
|
126
|
+
if (appendSection) {
|
|
127
|
+
prompt += appendSection;
|
|
128
|
+
}
|
|
129
|
+
// Append project context files
|
|
130
|
+
if (contextFiles.length > 0) {
|
|
131
|
+
prompt += "\n\n# Project Context\n\n";
|
|
132
|
+
prompt += "Project-specific instructions and guidelines:\n\n";
|
|
133
|
+
for (const { path: filePath, content } of contextFiles) {
|
|
134
|
+
prompt += `## ${filePath}\n\n${content}\n\n`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Append skills section (only if read tool is available)
|
|
138
|
+
if (hasRead && skills.length > 0) {
|
|
139
|
+
prompt += formatSkillsForPrompt(skills);
|
|
140
|
+
}
|
|
141
|
+
// Append memory system context
|
|
142
|
+
if (memoryEnabled) {
|
|
143
|
+
prompt += buildMemoryPromptSection(resolvedCwd);
|
|
144
|
+
}
|
|
145
|
+
// Add date/time and working directory last
|
|
146
|
+
prompt += `\nCurrent date and time: ${dateTime}`;
|
|
147
|
+
prompt += `\nCurrent working directory: ${resolvedCwd}`;
|
|
148
|
+
return prompt;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,gBAAgB,GAA2B;IAChD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,8CAA8C;IACpD,IAAI,EAAE,4DAA4D;IAClE,KAAK,EAAE,2BAA2B;IAClC,IAAI,EAAE,yDAAyD;IAC/D,IAAI,EAAE,kDAAkD;IACxD,EAAE,EAAE,yBAAyB;IAC7B,YAAY,EAAE,qEAAqE;IACnF,WAAW,EAAE,mDAAmD;IAChE,aAAa,EAAE,2BAA2B;IAC1C,aAAa,EAAE,uBAAuB;CACtC,CAAC;AAmBF,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,OAAO,GAA6B,EAAE,EAAU;IACjF,MAAM,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,cAAc,EACtB,aAAa,GAAG,IAAI,GACpB,GAAG,OAAO,CAAC;IACZ,MAAM,WAAW,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEzC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAA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AC,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,+BAA+B;IAC/B,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,2CAA2C;IAC3C,MAAM,IAAI,4BAA4B,QAAQ,EAAE,CAAC;IACjD,MAAM,IAAI,gCAAgC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\r\n * System prompt construction and project context loading\r\n */\r\n\r\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\r\nimport { buildMemoryPromptSection } from \"./memory.js\";\r\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\r\n\r\n/** Tool descriptions for system prompt */\r\nconst toolDescriptions: Record<string, string> = {\r\n\tread: \"Read file contents\",\r\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\r\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\r\n\twrite: \"Create or overwrite files\",\r\n\tgrep: \"Search file contents for patterns (respects .gitignore)\",\r\n\tfind: \"Find files by glob pattern (respects .gitignore)\",\r\n\tls: \"List directory contents\",\r\n\tmemory_write: \"Save a memory (procedural workflow, preference, or session summary)\",\r\n\tmemory_read: \"Read stored memories by type, ID, or search query\",\r\n\tmemory_update: \"Update an existing memory\",\r\n\tmemory_delete: \"Delete a memory by ID\",\r\n};\r\n\r\nexport interface BuildSystemPromptOptions {\r\n\t/** Custom system prompt (replaces default). */\r\n\tcustomPrompt?: string;\r\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\r\n\tselectedTools?: string[];\r\n\t/** Text to append to system prompt. */\r\n\tappendSystemPrompt?: string;\r\n\t/** Working directory. Default: process.cwd() */\r\n\tcwd?: string;\r\n\t/** Pre-loaded context files. */\r\n\tcontextFiles?: Array<{ path: string; content: string }>;\r\n\t/** Pre-loaded skills. */\r\n\tskills?: Skill[];\r\n\t/** Whether the memory system is enabled. Default: true */\r\n\tmemoryEnabled?: boolean;\r\n}\r\n\r\n/** Build the system prompt with tools, guidelines, and context */\r\nexport function buildSystemPrompt(options: BuildSystemPromptOptions = {}): string {\r\n\tconst {\r\n\t\tcustomPrompt,\r\n\t\tselectedTools,\r\n\t\tappendSystemPrompt,\r\n\t\tcwd,\r\n\t\tcontextFiles: providedContextFiles,\r\n\t\tskills: providedSkills,\r\n\t\tmemoryEnabled = true,\r\n\t} = options;\r\n\tconst resolvedCwd = cwd ?? process.cwd();\r\n\r\n\tconst now = new Date();\r\n\tconst dateTime = now.toLocaleString(\"en-US\", {\r\n\t\tweekday: \"long\",\r\n\t\tyear: \"numeric\",\r\n\t\tmonth: \"long\",\r\n\t\tday: \"numeric\",\r\n\t\thour: \"2-digit\",\r\n\t\tminute: \"2-digit\",\r\n\t\tsecond: \"2-digit\",\r\n\t\ttimeZoneName: \"short\",\r\n\t});\r\n\r\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\r\n\r\n\tconst contextFiles = providedContextFiles ?? [];\r\n\tconst skills = providedSkills ?? [];\r\n\r\n\tif (customPrompt) {\r\n\t\tlet prompt = customPrompt;\r\n\r\n\t\tif (appendSection) {\r\n\t\t\tprompt += appendSection;\r\n\t\t}\r\n\r\n\t\t// Append project context files\r\n\t\tif (contextFiles.length > 0) {\r\n\t\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\r\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\r\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\r\n\t\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Append skills section (only if read tool is available)\r\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\r\n\t\tif (customPromptHasRead && skills.length > 0) {\r\n\t\t\tprompt += formatSkillsForPrompt(skills);\r\n\t\t}\r\n\r\n\t\t// Append memory system context\r\n\t\tif (memoryEnabled) {\r\n\t\t\tprompt += buildMemoryPromptSection(resolvedCwd);\r\n\t\t}\r\n\r\n\t\t// Add date/time and working directory last\r\n\t\tprompt += `\\nCurrent date and time: ${dateTime}`;\r\n\t\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\r\n\r\n\t\treturn prompt;\r\n\t}\r\n\r\n\t// Get absolute paths to documentation and examples\r\n\tconst readmePath = getReadmePath();\r\n\tconst docsPath = getDocsPath();\r\n\tconst examplesPath = getExamplesPath();\r\n\r\n\t// Build tools list based on selected tools (only built-in tools with known descriptions)\r\n\tconst tools = (selectedTools || [\"read\", \"bash\", \"edit\", \"write\"]).filter((t) => t in toolDescriptions);\r\n\tconst toolsList = tools.length > 0 ? tools.map((t) => `- ${t}: ${toolDescriptions[t]}`).join(\"\\n\") : \"(none)\";\r\n\r\n\t// Build guidelines based on which tools are actually available\r\n\tconst guidelinesList: string[] = [];\r\n\r\n\tconst hasBash = tools.includes(\"bash\");\r\n\tconst hasEdit = tools.includes(\"edit\");\r\n\tconst hasWrite = tools.includes(\"write\");\r\n\tconst hasGrep = tools.includes(\"grep\");\r\n\tconst hasFind = tools.includes(\"find\");\r\n\tconst hasLs = tools.includes(\"ls\");\r\n\tconst hasRead = tools.includes(\"read\");\r\n\r\n\t// File exploration guidelines\r\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\r\n\t\tguidelinesList.push(\"Use bash for file operations like ls, rg, find\");\r\n\t} else if (hasBash && (hasGrep || hasFind || hasLs)) {\r\n\t\tguidelinesList.push(\"Prefer grep/find/ls tools over bash for file exploration (faster, respects .gitignore)\");\r\n\t}\r\n\r\n\t// Read before edit guideline\r\n\tif (hasRead && hasEdit) {\r\n\t\tguidelinesList.push(\"Use read to examine files before editing. You must use this tool instead of cat or sed.\");\r\n\t}\r\n\r\n\t// Edit guideline\r\n\tif (hasEdit) {\r\n\t\tguidelinesList.push(\"Use edit for precise changes (old text must match exactly)\");\r\n\t}\r\n\r\n\t// Write guideline\r\n\tif (hasWrite) {\r\n\t\tguidelinesList.push(\"Use write only for new files or complete rewrites\");\r\n\t}\r\n\r\n\t// Output guideline (only when actually writing or executing)\r\n\tif (hasEdit || hasWrite) {\r\n\t\tguidelinesList.push(\r\n\t\t\t\"When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did\",\r\n\t\t);\r\n\t}\r\n\r\n\t// Always include these\r\n\tguidelinesList.push(\"Be concise in your responses\");\r\n\tguidelinesList.push(\"Show file paths clearly when working with files\");\r\n\r\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\r\n\r\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\r\n\r\nAvailable tools:\r\n${toolsList}\r\n\r\nIn addition to the tools above, you may have access to other custom tools depending on the project.\r\n\r\nGuidelines:\r\n${guidelines}\r\n\r\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\r\n- Main documentation: ${readmePath}\r\n- Additional docs: ${docsPath}\r\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\r\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\r\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\r\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\r\n\r\n\tif (appendSection) {\r\n\t\tprompt += appendSection;\r\n\t}\r\n\r\n\t// Append project context files\r\n\tif (contextFiles.length > 0) {\r\n\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\r\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\r\n\t\tfor (const { path: filePath, content } of contextFiles) {\r\n\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\r\n\t\t}\r\n\t}\r\n\r\n\t// Append skills section (only if read tool is available)\r\n\tif (hasRead && skills.length > 0) {\r\n\t\tprompt += formatSkillsForPrompt(skills);\r\n\t}\r\n\r\n\t// Append memory system context\r\n\tif (memoryEnabled) {\r\n\t\tprompt += buildMemoryPromptSection(resolvedCwd);\r\n\t}\r\n\r\n\t// Add date/time and working directory last\r\n\tprompt += `\\nCurrent date and time: ${dateTime}`;\r\n\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\r\n\r\n\treturn prompt;\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timings.d.ts","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAQnC","sourcesContent":["/**\r\n * Central timing instrumentation for startup profiling.\r\n * Enable with PI_TIMING=1 environment variable.\r\n */\r\n\r\nconst ENABLED = process.env.PI_TIMING === \"1\";\r\nconst timings: Array<{ label: string; ms: number }> = [];\r\nlet lastTime = Date.now();\r\n\r\nexport function time(label: string): void {\r\n\tif (!ENABLED) return;\r\n\tconst now = Date.now();\r\n\ttimings.push({ label, ms: now - lastTime });\r\n\tlastTime = now;\r\n}\r\n\r\nexport function printTimings(): void {\r\n\tif (!ENABLED || timings.length === 0) return;\r\n\tconsole.error(\"\\n--- Startup Timings ---\");\r\n\tfor (const t of timings) {\r\n\t\tconsole.error(` ${t.label}: ${t.ms}ms`);\r\n\t}\r\n\tconsole.error(` TOTAL: ${timings.reduce((a, b) => a + b.ms, 0)}ms`);\r\n\tconsole.error(\"------------------------\\n\");\r\n}\r\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central timing instrumentation for startup profiling.
|
|
3
|
+
* Enable with PI_TIMING=1 environment variable.
|
|
4
|
+
*/
|
|
5
|
+
const ENABLED = process.env.PI_TIMING === "1";
|
|
6
|
+
const timings = [];
|
|
7
|
+
let lastTime = Date.now();
|
|
8
|
+
export function time(label) {
|
|
9
|
+
if (!ENABLED)
|
|
10
|
+
return;
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
timings.push({ label, ms: now - lastTime });
|
|
13
|
+
lastTime = now;
|
|
14
|
+
}
|
|
15
|
+
export function printTimings() {
|
|
16
|
+
if (!ENABLED || timings.length === 0)
|
|
17
|
+
return;
|
|
18
|
+
console.error("\n--- Startup Timings ---");
|
|
19
|
+
for (const t of timings) {
|
|
20
|
+
console.error(` ${t.label}: ${t.ms}ms`);
|
|
21
|
+
}
|
|
22
|
+
console.error(` TOTAL: ${timings.reduce((a, b) => a + b.ms, 0)}ms`);
|
|
23
|
+
console.error("------------------------\n");
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=timings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timings.js","sourceRoot":"","sources":["../../src/core/timings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC;AAC9C,MAAM,OAAO,GAAyC,EAAE,CAAC;AACzD,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE1B,MAAM,UAAU,IAAI,CAAC,KAAa,EAAQ;IACzC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,GAAG,QAAQ,EAAE,CAAC,CAAC;IAC5C,QAAQ,GAAG,GAAG,CAAC;AAAA,CACf;AAED,MAAM,UAAU,YAAY,GAAS;IACpC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC7C,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,YAAY,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACrE,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAAA,CAC5C","sourcesContent":["/**\r\n * Central timing instrumentation for startup profiling.\r\n * Enable with PI_TIMING=1 environment variable.\r\n */\r\n\r\nconst ENABLED = process.env.PI_TIMING === \"1\";\r\nconst timings: Array<{ label: string; ms: number }> = [];\r\nlet lastTime = Date.now();\r\n\r\nexport function time(label: string): void {\r\n\tif (!ENABLED) return;\r\n\tconst now = Date.now();\r\n\ttimings.push({ label, ms: now - lastTime });\r\n\tlastTime = now;\r\n}\r\n\r\nexport function printTimings(): void {\r\n\tif (!ENABLED || timings.length === 0) return;\r\n\tconsole.error(\"\\n--- Startup Timings ---\");\r\n\tfor (const t of timings) {\r\n\t\tconsole.error(` ${t.label}: ${t.ms}ms`);\r\n\t}\r\n\tconsole.error(` TOTAL: ${timings.reduce((a, b) => a + b.ms, 0)}ms`);\r\n\tconsole.error(\"------------------------\\n\");\r\n}\r\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
import { type TruncationResult } from "./truncate.js";
|
|
4
|
+
declare const bashSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
command: import("@sinclair/typebox").TString;
|
|
6
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
7
|
+
}>;
|
|
8
|
+
export type BashToolInput = Static<typeof bashSchema>;
|
|
9
|
+
export interface BashToolDetails {
|
|
10
|
+
truncation?: TruncationResult;
|
|
11
|
+
fullOutputPath?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Pluggable operations for the bash tool.
|
|
15
|
+
* Override these to delegate command execution to remote systems (e.g., SSH).
|
|
16
|
+
*/
|
|
17
|
+
export interface BashOperations {
|
|
18
|
+
/**
|
|
19
|
+
* Execute a command and stream output.
|
|
20
|
+
* @param command - The command to execute
|
|
21
|
+
* @param cwd - Working directory
|
|
22
|
+
* @param options - Execution options
|
|
23
|
+
* @returns Promise resolving to exit code (null if killed)
|
|
24
|
+
*/
|
|
25
|
+
exec: (command: string, cwd: string, options: {
|
|
26
|
+
onData: (data: Buffer) => void;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
env?: NodeJS.ProcessEnv;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
exitCode: number | null;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export interface BashSpawnContext {
|
|
35
|
+
command: string;
|
|
36
|
+
cwd: string;
|
|
37
|
+
env: NodeJS.ProcessEnv;
|
|
38
|
+
}
|
|
39
|
+
export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;
|
|
40
|
+
export interface BashToolOptions {
|
|
41
|
+
/** Custom operations for command execution. Default: local shell */
|
|
42
|
+
operations?: BashOperations;
|
|
43
|
+
/** Command prefix prepended to every command (e.g., "shopt -s expand_aliases" for alias support) */
|
|
44
|
+
commandPrefix?: string;
|
|
45
|
+
/** Hook to adjust command, cwd, or env before execution */
|
|
46
|
+
spawnHook?: BashSpawnHook;
|
|
47
|
+
}
|
|
48
|
+
export declare function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema>;
|
|
49
|
+
/** Default bash tool using process.cwd() - for backwards compatibility */
|
|
50
|
+
export declare const bashTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
51
|
+
command: import("@sinclair/typebox").TString;
|
|
52
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
53
|
+
}>, any>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAUtH,QAAA,MAAM,UAAU;;;EAGd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;OAMG;IACH,IAAI,EAAE,CACL,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QACR,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;KACxB,KACG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CAC1C;AAsFD,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,gBAAgB,CAAC;AAY5E,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,oGAAoG;IACpG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAwJnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;QAAgC,CAAC","sourcesContent":["import { randomBytes } from \"node:crypto\";\r\nimport { createWriteStream, existsSync } from \"node:fs\";\r\nimport { tmpdir } from \"node:os\";\r\nimport { join } from \"node:path\";\r\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\r\nimport { type Static, Type } from \"@sinclair/typebox\";\r\nimport { spawn } from \"child_process\";\r\nimport { getShellConfig, getShellEnv, killProcessTree } from \"../../utils/shell.js\";\r\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateTail } from \"./truncate.js\";\r\n\r\n/**\r\n * Generate a unique temp file path for bash output\r\n */\r\nfunction getTempFilePath(): string {\r\n\tconst id = randomBytes(8).toString(\"hex\");\r\n\treturn join(tmpdir(), `pi-bash-${id}.log`);\r\n}\r\n\r\nconst bashSchema = Type.Object({\r\n\tcommand: Type.String({ description: \"Bash command to execute\" }),\r\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\r\n});\r\n\r\nexport type BashToolInput = Static<typeof bashSchema>;\r\n\r\nexport interface BashToolDetails {\r\n\ttruncation?: TruncationResult;\r\n\tfullOutputPath?: string;\r\n}\r\n\r\n/**\r\n * Pluggable operations for the bash tool.\r\n * Override these to delegate command execution to remote systems (e.g., SSH).\r\n */\r\nexport interface BashOperations {\r\n\t/**\r\n\t * Execute a command and stream output.\r\n\t * @param command - The command to execute\r\n\t * @param cwd - Working directory\r\n\t * @param options - Execution options\r\n\t * @returns Promise resolving to exit code (null if killed)\r\n\t */\r\n\texec: (\r\n\t\tcommand: string,\r\n\t\tcwd: string,\r\n\t\toptions: {\r\n\t\t\tonData: (data: Buffer) => void;\r\n\t\t\tsignal?: AbortSignal;\r\n\t\t\ttimeout?: number;\r\n\t\t\tenv?: NodeJS.ProcessEnv;\r\n\t\t},\r\n\t) => Promise<{ exitCode: number | null }>;\r\n}\r\n\r\n/**\r\n * Default bash operations using local shell\r\n */\r\nconst defaultBashOperations: BashOperations = {\r\n\texec: (command, cwd, { onData, signal, timeout, env }) => {\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tconst { shell, args } = getShellConfig();\r\n\r\n\t\t\tif (!existsSync(cwd)) {\r\n\t\t\t\treject(new Error(`Working directory does not exist: ${cwd}\\nCannot execute bash commands.`));\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst child = spawn(shell, [...args, command], {\r\n\t\t\t\tcwd,\r\n\t\t\t\tdetached: true,\r\n\t\t\t\tenv: env ?? getShellEnv(),\r\n\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\r\n\t\t\t});\r\n\r\n\t\t\tlet timedOut = false;\r\n\r\n\t\t\t// Set timeout if provided\r\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\r\n\t\t\tif (timeout !== undefined && timeout > 0) {\r\n\t\t\t\ttimeoutHandle = setTimeout(() => {\r\n\t\t\t\t\ttimedOut = true;\r\n\t\t\t\t\tif (child.pid) {\r\n\t\t\t\t\t\tkillProcessTree(child.pid);\r\n\t\t\t\t\t}\r\n\t\t\t\t}, timeout * 1000);\r\n\t\t\t}\r\n\r\n\t\t\t// Stream stdout and stderr\r\n\t\t\tif (child.stdout) {\r\n\t\t\t\tchild.stdout.on(\"data\", onData);\r\n\t\t\t}\r\n\t\t\tif (child.stderr) {\r\n\t\t\t\tchild.stderr.on(\"data\", onData);\r\n\t\t\t}\r\n\r\n\t\t\t// Handle shell spawn errors\r\n\t\t\tchild.on(\"error\", (err) => {\r\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\r\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\r\n\t\t\t\treject(err);\r\n\t\t\t});\r\n\r\n\t\t\t// Handle abort signal - kill entire process tree\r\n\t\t\tconst onAbort = () => {\r\n\t\t\t\tif (child.pid) {\r\n\t\t\t\t\tkillProcessTree(child.pid);\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tif (signal) {\r\n\t\t\t\tif (signal.aborted) {\r\n\t\t\t\t\tonAbort();\r\n\t\t\t\t} else {\r\n\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Handle process exit\r\n\t\t\tchild.on(\"close\", (code) => {\r\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\r\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\r\n\r\n\t\t\t\tif (signal?.aborted) {\r\n\t\t\t\t\treject(new Error(\"aborted\"));\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (timedOut) {\r\n\t\t\t\t\treject(new Error(`timeout:${timeout}`));\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tresolve({ exitCode: code });\r\n\t\t\t});\r\n\t\t});\r\n\t},\r\n};\r\n\r\nexport interface BashSpawnContext {\r\n\tcommand: string;\r\n\tcwd: string;\r\n\tenv: NodeJS.ProcessEnv;\r\n}\r\n\r\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\r\n\r\nfunction resolveSpawnContext(command: string, cwd: string, spawnHook?: BashSpawnHook): BashSpawnContext {\r\n\tconst baseContext: BashSpawnContext = {\r\n\t\tcommand,\r\n\t\tcwd,\r\n\t\tenv: { ...getShellEnv() },\r\n\t};\r\n\r\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\r\n}\r\n\r\nexport interface BashToolOptions {\r\n\t/** Custom operations for command execution. Default: local shell */\r\n\toperations?: BashOperations;\r\n\t/** Command prefix prepended to every command (e.g., \"shopt -s expand_aliases\" for alias support) */\r\n\tcommandPrefix?: string;\r\n\t/** Hook to adjust command, cwd, or env before execution */\r\n\tspawnHook?: BashSpawnHook;\r\n}\r\n\r\nexport function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema> {\r\n\tconst ops = options?.operations ?? defaultBashOperations;\r\n\tconst commandPrefix = options?.commandPrefix;\r\n\tconst spawnHook = options?.spawnHook;\r\n\r\n\treturn {\r\n\t\tname: \"bash\",\r\n\t\tlabel: \"bash\",\r\n\t\tdescription: `Execute a bash command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,\r\n\t\tparameters: bashSchema,\r\n\t\texecute: async (\r\n\t\t\t_toolCallId: string,\r\n\t\t\t{ command, timeout }: { command: string; timeout?: number },\r\n\t\t\tsignal?: AbortSignal,\r\n\t\t\tonUpdate?,\r\n\t\t) => {\r\n\t\t\t// Apply command prefix if configured (e.g., \"shopt -s expand_aliases\" for alias support)\r\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\r\n\t\t\tconst spawnContext = resolveSpawnContext(resolvedCommand, cwd, spawnHook);\r\n\r\n\t\t\treturn new Promise((resolve, reject) => {\r\n\t\t\t\t// We'll stream to a temp file if output gets large\r\n\t\t\t\tlet tempFilePath: string | undefined;\r\n\t\t\t\tlet tempFileStream: ReturnType<typeof createWriteStream> | undefined;\r\n\t\t\t\tlet totalBytes = 0;\r\n\r\n\t\t\t\t// Keep a rolling buffer of the last chunk for tail truncation\r\n\t\t\t\tconst chunks: Buffer[] = [];\r\n\t\t\t\tlet chunksBytes = 0;\r\n\t\t\t\t// Keep more than we need so we have enough for truncation\r\n\t\t\t\tconst maxChunksBytes = DEFAULT_MAX_BYTES * 2;\r\n\r\n\t\t\t\tconst handleData = (data: Buffer) => {\r\n\t\t\t\t\ttotalBytes += data.length;\r\n\r\n\t\t\t\t\t// Start writing to temp file once we exceed the threshold\r\n\t\t\t\t\tif (totalBytes > DEFAULT_MAX_BYTES && !tempFilePath) {\r\n\t\t\t\t\t\ttempFilePath = getTempFilePath();\r\n\t\t\t\t\t\ttempFileStream = createWriteStream(tempFilePath);\r\n\t\t\t\t\t\t// Write all buffered chunks to the file\r\n\t\t\t\t\t\tfor (const chunk of chunks) {\r\n\t\t\t\t\t\t\ttempFileStream.write(chunk);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Write to temp file if we have one\r\n\t\t\t\t\tif (tempFileStream) {\r\n\t\t\t\t\t\ttempFileStream.write(data);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Keep rolling buffer of recent data\r\n\t\t\t\t\tchunks.push(data);\r\n\t\t\t\t\tchunksBytes += data.length;\r\n\r\n\t\t\t\t\t// Trim old chunks if buffer is too large\r\n\t\t\t\t\twhile (chunksBytes > maxChunksBytes && chunks.length > 1) {\r\n\t\t\t\t\t\tconst removed = chunks.shift()!;\r\n\t\t\t\t\t\tchunksBytes -= removed.length;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Stream partial output to callback (truncated rolling buffer)\r\n\t\t\t\t\tif (onUpdate) {\r\n\t\t\t\t\t\tconst fullBuffer = Buffer.concat(chunks);\r\n\t\t\t\t\t\tconst fullText = fullBuffer.toString(\"utf-8\");\r\n\t\t\t\t\t\tconst truncation = truncateTail(fullText);\r\n\t\t\t\t\t\tonUpdate({\r\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: truncation.content || \"\" }],\r\n\t\t\t\t\t\t\tdetails: {\r\n\t\t\t\t\t\t\t\ttruncation: truncation.truncated ? truncation : undefined,\r\n\t\t\t\t\t\t\t\tfullOutputPath: tempFilePath,\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tops.exec(spawnContext.command, spawnContext.cwd, {\r\n\t\t\t\t\tonData: handleData,\r\n\t\t\t\t\tsignal,\r\n\t\t\t\t\ttimeout,\r\n\t\t\t\t\tenv: spawnContext.env,\r\n\t\t\t\t})\r\n\t\t\t\t\t.then(({ exitCode }) => {\r\n\t\t\t\t\t\t// Close temp file stream\r\n\t\t\t\t\t\tif (tempFileStream) {\r\n\t\t\t\t\t\t\ttempFileStream.end();\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// Combine all buffered chunks\r\n\t\t\t\t\t\tconst fullBuffer = Buffer.concat(chunks);\r\n\t\t\t\t\t\tconst fullOutput = fullBuffer.toString(\"utf-8\");\r\n\r\n\t\t\t\t\t\t// Apply tail truncation\r\n\t\t\t\t\t\tconst truncation = truncateTail(fullOutput);\r\n\t\t\t\t\t\tlet outputText = truncation.content || \"(no output)\";\r\n\r\n\t\t\t\t\t\t// Build details with truncation info\r\n\t\t\t\t\t\tlet details: BashToolDetails | undefined;\r\n\r\n\t\t\t\t\t\tif (truncation.truncated) {\r\n\t\t\t\t\t\t\tdetails = {\r\n\t\t\t\t\t\t\t\ttruncation,\r\n\t\t\t\t\t\t\t\tfullOutputPath: tempFilePath,\r\n\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t\t// Build actionable notice\r\n\t\t\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\r\n\t\t\t\t\t\t\tconst endLine = truncation.totalLines;\r\n\r\n\t\t\t\t\t\t\tif (truncation.lastLinePartial) {\r\n\t\t\t\t\t\t\t\t// Edge case: last line alone > 30KB\r\n\t\t\t\t\t\t\t\tconst lastLineSize = formatSize(Buffer.byteLength(fullOutput.split(\"\\n\").pop() || \"\", \"utf-8\"));\r\n\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}). Full output: ${tempFilePath}]`;\r\n\t\t\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\r\n\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}. Full output: ${tempFilePath}]`;\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Full output: ${tempFilePath}]`;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (exitCode !== 0 && exitCode !== null) {\r\n\t\t\t\t\t\t\toutputText += `\\n\\nCommand exited with code ${exitCode}`;\r\n\t\t\t\t\t\t\treject(new Error(outputText));\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: outputText }], details });\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t})\r\n\t\t\t\t\t.catch((err: Error) => {\r\n\t\t\t\t\t\t// Close temp file stream\r\n\t\t\t\t\t\tif (tempFileStream) {\r\n\t\t\t\t\t\t\ttempFileStream.end();\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// Combine all buffered chunks for error output\r\n\t\t\t\t\t\tconst fullBuffer = Buffer.concat(chunks);\r\n\t\t\t\t\t\tlet output = fullBuffer.toString(\"utf-8\");\r\n\r\n\t\t\t\t\t\tif (err.message === \"aborted\") {\r\n\t\t\t\t\t\t\tif (output) output += \"\\n\\n\";\r\n\t\t\t\t\t\t\toutput += \"Command aborted\";\r\n\t\t\t\t\t\t\treject(new Error(output));\r\n\t\t\t\t\t\t} else if (err.message.startsWith(\"timeout:\")) {\r\n\t\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\r\n\t\t\t\t\t\t\tif (output) output += \"\\n\\n\";\r\n\t\t\t\t\t\t\toutput += `Command timed out after ${timeoutSecs} seconds`;\r\n\t\t\t\t\t\t\treject(new Error(output));\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t});\r\n\t\t},\r\n\t};\r\n}\r\n\r\n/** Default bash tool using process.cwd() - for backwards compatibility */\r\nexport const bashTool = createBashTool(process.cwd());\r\n"]}
|