@lenylvt/pi-coding-agent 0.64.0
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 +3331 -0
- package/README.md +48 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +5 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/cli/args.d.ts +49 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +292 -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 +83 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.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 +35 -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 +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +69 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +178 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +622 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2688 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +132 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +422 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +46 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +113 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +88 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +243 -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 +613 -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 +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -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 +75 -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 +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +224 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1001 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1690 -0
- package/dist/core/export-html/tool-renderer.d.ts +38 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +95 -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 +12 -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 +436 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +148 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +700 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1085 -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 +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +44 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +252 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +275 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +241 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +132 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +565 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +110 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +464 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +59 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +172 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1801 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +51 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +249 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +23 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +126 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +185 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +698 -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 +233 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/self-update.d.ts +3 -0
- package/dist/core/self-update.d.ts.map +1 -0
- package/dist/core/self-update.js +46 -0
- package/dist/core/self-update.js.map +1 -0
- package/dist/core/session-manager.d.ts +329 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1097 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +237 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +708 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +409 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +22 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +116 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +8 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +31 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +73 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +342 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +85 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +337 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +53 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +196 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +37 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +46 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +258 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +56 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +293 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +115 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +86 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +46 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +172 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +46 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +225 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +21 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +49 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +32 -0
- package/dist/core/tools/tool-definition-wrapper.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 +35 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +216 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/version-check.d.ts +2 -0
- package/dist/core/version-check.d.ts.map +1 -0
- package/dist/core/version-check.js +73 -0
- package/dist/core/version-check.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 +811 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +32 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +258 -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 +18 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +107 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +175 -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/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 +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +111 -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 +198 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +32 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +8 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +22 -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 +275 -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 +848 -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 +301 -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 +39 -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 +50 -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 +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +58 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +274 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +87 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1051 -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 +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +28 -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 +311 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3798 -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 +81 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +975 -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 +107 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.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 +401 -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 +522 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +408 -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/child-process.d.ts +11 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +78 -0
- package/dist/utils/child-process.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 +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +8 -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 +78 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.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 +39 -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 +137 -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 +252 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +394 -0
- package/docs/custom-provider.md +327 -0
- package/docs/extensions.md +2229 -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 +82 -0
- package/docs/keybindings.md +173 -0
- package/docs/models.md +197 -0
- package/docs/packages.md +218 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +98 -0
- package/docs/release.md +40 -0
- package/docs/rpc.md +1377 -0
- package/docs/sdk.md +971 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +149 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +232 -0
- package/docs/terminal-setup.md +106 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tree.md +228 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +204 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +127 -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.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/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/dynamic-tools.ts +74 -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 +153 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/hidden-thinking-label.ts +57 -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 +1348 -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 +166 -0
- package/examples/extensions/preset.ts +397 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +14 -0
- package/examples/extensions/qna.ts +122 -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 +321 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +986 -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 +206 -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 +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +32 -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 +52 -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 +48 -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 +81 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +95 -0
- package/src/bun/cli.ts +5 -0
- package/src/cli/args.ts +309 -0
- package/src/cli/config-selector.ts +52 -0
- package/src/cli/file-processor.ts +100 -0
- package/src/cli/initial-message.ts +43 -0
- package/src/cli/list-models.ts +104 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli.ts +16 -0
- package/src/config.ts +214 -0
- package/src/core/agent-session.ts +3279 -0
- package/src/core/auth-storage.ts +488 -0
- package/src/core/bash-executor.ts +158 -0
- package/src/core/compaction/branch-summarization.ts +355 -0
- package/src/core/compaction/compaction.ts +823 -0
- package/src/core/compaction/index.ts +7 -0
- package/src/core/compaction/utils.ts +170 -0
- package/src/core/defaults.ts +3 -0
- package/src/core/diagnostics.ts +15 -0
- package/src/core/event-bus.ts +33 -0
- package/src/core/exec.ts +107 -0
- package/src/core/export-html/ansi-to-html.ts +258 -0
- package/src/core/export-html/index.ts +314 -0
- package/src/core/export-html/template.css +1001 -0
- package/src/core/export-html/template.html +55 -0
- package/src/core/export-html/template.js +1690 -0
- package/src/core/export-html/tool-renderer.ts +156 -0
- package/src/core/export-html/vendor/highlight.min.js +1213 -0
- package/src/core/export-html/vendor/marked.min.js +6 -0
- package/src/core/extensions/index.ts +168 -0
- package/src/core/extensions/loader.ts +557 -0
- package/src/core/extensions/runner.ts +915 -0
- package/src/core/extensions/types.ts +1461 -0
- package/src/core/extensions/wrapper.ts +27 -0
- package/src/core/footer-data-provider.ts +273 -0
- package/src/core/index.ts +61 -0
- package/src/core/keybindings.ts +302 -0
- package/src/core/messages.ts +195 -0
- package/src/core/model-registry.ts +766 -0
- package/src/core/model-resolver.ts +606 -0
- package/src/core/output-guard.ts +74 -0
- package/src/core/package-manager.ts +2222 -0
- package/src/core/prompt-templates.ts +294 -0
- package/src/core/resolve-config-value.ts +142 -0
- package/src/core/resource-loader.ts +886 -0
- package/src/core/sdk.ts +360 -0
- package/src/core/self-update.ts +57 -0
- package/src/core/session-manager.ts +1410 -0
- package/src/core/settings-manager.ts +973 -0
- package/src/core/skills.ts +508 -0
- package/src/core/slash-commands.ts +37 -0
- package/src/core/source-info.ts +40 -0
- package/src/core/system-prompt.ts +168 -0
- package/src/core/timings.ts +31 -0
- package/src/core/tools/bash.ts +431 -0
- package/src/core/tools/edit-diff.ts +445 -0
- package/src/core/tools/edit.ts +307 -0
- package/src/core/tools/file-mutation-queue.ts +39 -0
- package/src/core/tools/find.ts +314 -0
- package/src/core/tools/grep.ts +375 -0
- package/src/core/tools/index.ts +193 -0
- package/src/core/tools/ls.ts +233 -0
- package/src/core/tools/path-utils.ts +94 -0
- package/src/core/tools/read.ts +269 -0
- package/src/core/tools/render-utils.ts +64 -0
- package/src/core/tools/tool-definition-wrapper.ts +43 -0
- package/src/core/tools/truncate.ts +265 -0
- package/src/core/tools/write.ts +285 -0
- package/src/core/version-check.ts +85 -0
- package/src/index.ts +348 -0
- package/src/main.ts +958 -0
- package/src/migrations.ts +290 -0
- package/src/modes/index.ts +9 -0
- package/src/modes/interactive/components/armin.ts +382 -0
- package/src/modes/interactive/components/assistant-message.ts +130 -0
- package/src/modes/interactive/components/bash-execution.ts +218 -0
- package/src/modes/interactive/components/bordered-loader.ts +66 -0
- package/src/modes/interactive/components/branch-summary-message.ts +58 -0
- package/src/modes/interactive/components/compaction-summary-message.ts +59 -0
- package/src/modes/interactive/components/config-selector.ts +592 -0
- package/src/modes/interactive/components/countdown-timer.ts +38 -0
- package/src/modes/interactive/components/custom-editor.ts +80 -0
- package/src/modes/interactive/components/custom-message.ts +99 -0
- package/src/modes/interactive/components/diff.ts +147 -0
- package/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/src/modes/interactive/components/extension-editor.ts +147 -0
- package/src/modes/interactive/components/extension-input.ts +87 -0
- package/src/modes/interactive/components/extension-selector.ts +107 -0
- package/src/modes/interactive/components/footer.ts +216 -0
- package/src/modes/interactive/components/index.ts +31 -0
- package/src/modes/interactive/components/keybinding-hints.ts +24 -0
- package/src/modes/interactive/components/login-dialog.ts +178 -0
- package/src/modes/interactive/components/model-selector.ts +328 -0
- package/src/modes/interactive/components/oauth-selector.ts +121 -0
- package/src/modes/interactive/components/scoped-models-selector.ts +346 -0
- package/src/modes/interactive/components/session-selector-search.ts +194 -0
- package/src/modes/interactive/components/session-selector.ts +1010 -0
- package/src/modes/interactive/components/settings-selector.ts +432 -0
- package/src/modes/interactive/components/show-images-selector.ts +50 -0
- package/src/modes/interactive/components/skill-invocation-message.ts +55 -0
- package/src/modes/interactive/components/theme-selector.ts +67 -0
- package/src/modes/interactive/components/thinking-selector.ts +74 -0
- package/src/modes/interactive/components/tool-execution.ts +328 -0
- package/src/modes/interactive/components/tree-selector.ts +1197 -0
- package/src/modes/interactive/components/user-message-selector.ts +143 -0
- package/src/modes/interactive/components/user-message.ts +33 -0
- package/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/src/modes/interactive/interactive-mode.ts +4501 -0
- package/src/modes/interactive/theme/dark.json +85 -0
- package/src/modes/interactive/theme/light.json +84 -0
- package/src/modes/interactive/theme/theme-schema.json +335 -0
- package/src/modes/interactive/theme/theme.ts +1137 -0
- package/src/modes/print-mode.ts +131 -0
- package/src/modes/rpc/jsonl.ts +58 -0
- package/src/modes/rpc/rpc-client.ts +505 -0
- package/src/modes/rpc/rpc-mode.ts +654 -0
- package/src/modes/rpc/rpc-types.ts +262 -0
- package/src/utils/changelog.ts +99 -0
- package/src/utils/child-process.ts +86 -0
- package/src/utils/clipboard-image.ts +300 -0
- package/src/utils/clipboard-native.ts +22 -0
- package/src/utils/clipboard.ts +81 -0
- package/src/utils/exif-orientation.ts +183 -0
- package/src/utils/frontmatter.ts +39 -0
- package/src/utils/git.ts +192 -0
- package/src/utils/image-convert.ts +41 -0
- package/src/utils/image-resize.ts +176 -0
- package/src/utils/mime.ts +30 -0
- package/src/utils/photon.ts +139 -0
- package/src/utils/shell.ts +202 -0
- package/src/utils/sleep.ts +18 -0
- package/src/utils/tools-manager.ts +287 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-time migrations that run on startup.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
7
|
+
import { dirname, join } from "path";
|
|
8
|
+
import { CONFIG_DIR_NAME, getAgentDir, getBinDir, getChangelogPath, getDocsPath } from "./config.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Migrate legacy oauth.json and settings.json apiKeys to auth.json.
|
|
12
|
+
*
|
|
13
|
+
* @returns Array of provider names that were migrated
|
|
14
|
+
*/
|
|
15
|
+
export function migrateAuthToAuthJson(): string[] {
|
|
16
|
+
const agentDir = getAgentDir();
|
|
17
|
+
const authPath = join(agentDir, "auth.json");
|
|
18
|
+
const oauthPath = join(agentDir, "oauth.json");
|
|
19
|
+
const settingsPath = join(agentDir, "settings.json");
|
|
20
|
+
|
|
21
|
+
// Skip if auth.json already exists
|
|
22
|
+
if (existsSync(authPath)) return [];
|
|
23
|
+
|
|
24
|
+
const migrated: Record<string, unknown> = {};
|
|
25
|
+
const providers: string[] = [];
|
|
26
|
+
|
|
27
|
+
// Migrate oauth.json
|
|
28
|
+
if (existsSync(oauthPath)) {
|
|
29
|
+
try {
|
|
30
|
+
const oauth = JSON.parse(readFileSync(oauthPath, "utf-8"));
|
|
31
|
+
for (const [provider, cred] of Object.entries(oauth)) {
|
|
32
|
+
migrated[provider] = { type: "oauth", ...(cred as object) };
|
|
33
|
+
providers.push(provider);
|
|
34
|
+
}
|
|
35
|
+
renameSync(oauthPath, `${oauthPath}.migrated`);
|
|
36
|
+
} catch {
|
|
37
|
+
// Skip on error
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Migrate settings.json apiKeys
|
|
42
|
+
if (existsSync(settingsPath)) {
|
|
43
|
+
try {
|
|
44
|
+
const content = readFileSync(settingsPath, "utf-8");
|
|
45
|
+
const settings = JSON.parse(content);
|
|
46
|
+
if (settings.apiKeys && typeof settings.apiKeys === "object") {
|
|
47
|
+
for (const [provider, key] of Object.entries(settings.apiKeys)) {
|
|
48
|
+
if (!migrated[provider] && typeof key === "string") {
|
|
49
|
+
migrated[provider] = { type: "api_key", key };
|
|
50
|
+
providers.push(provider);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
delete settings.apiKeys;
|
|
54
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
// Skip on error
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (Object.keys(migrated).length > 0) {
|
|
62
|
+
mkdirSync(dirname(authPath), { recursive: true });
|
|
63
|
+
writeFileSync(authPath, JSON.stringify(migrated, null, 2), { mode: 0o600 });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return providers;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Migrate sessions from ~/.pi/agent/*.jsonl to proper session directories.
|
|
71
|
+
*
|
|
72
|
+
* Bug in v0.30.0: Sessions were saved to ~/.pi/agent/ instead of
|
|
73
|
+
* ~/.pi/agent/sessions/<encoded-cwd>/. This migration moves them
|
|
74
|
+
* to the correct location based on the cwd in their session header.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
export function migrateSessionsFromAgentRoot(): void {
|
|
78
|
+
const agentDir = getAgentDir();
|
|
79
|
+
|
|
80
|
+
// Find all .jsonl files directly in agentDir (not in subdirectories)
|
|
81
|
+
let files: string[];
|
|
82
|
+
try {
|
|
83
|
+
files = readdirSync(agentDir)
|
|
84
|
+
.filter((f) => f.endsWith(".jsonl"))
|
|
85
|
+
.map((f) => join(agentDir, f));
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (files.length === 0) return;
|
|
91
|
+
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
try {
|
|
94
|
+
// Read first line to get session header
|
|
95
|
+
const content = readFileSync(file, "utf8");
|
|
96
|
+
const firstLine = content.split("\n")[0];
|
|
97
|
+
if (!firstLine?.trim()) continue;
|
|
98
|
+
|
|
99
|
+
const header = JSON.parse(firstLine);
|
|
100
|
+
if (header.type !== "session" || !header.cwd) continue;
|
|
101
|
+
|
|
102
|
+
const cwd: string = header.cwd;
|
|
103
|
+
|
|
104
|
+
// Compute the correct session directory (same encoding as session-manager.ts)
|
|
105
|
+
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
106
|
+
const correctDir = join(agentDir, "sessions", safePath);
|
|
107
|
+
|
|
108
|
+
// Create directory if needed
|
|
109
|
+
if (!existsSync(correctDir)) {
|
|
110
|
+
mkdirSync(correctDir, { recursive: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Move the file
|
|
114
|
+
const fileName = file.split("/").pop() || file.split("\\").pop();
|
|
115
|
+
const newPath = join(correctDir, fileName!);
|
|
116
|
+
|
|
117
|
+
if (existsSync(newPath)) continue; // Skip if target exists
|
|
118
|
+
|
|
119
|
+
renameSync(file, newPath);
|
|
120
|
+
} catch {
|
|
121
|
+
// Skip files that can't be migrated
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Migrate commands/ to prompts/ if needed.
|
|
128
|
+
* Works for both regular directories and symlinks.
|
|
129
|
+
*/
|
|
130
|
+
function migrateCommandsToPrompts(baseDir: string, label: string): boolean {
|
|
131
|
+
const commandsDir = join(baseDir, "commands");
|
|
132
|
+
const promptsDir = join(baseDir, "prompts");
|
|
133
|
+
|
|
134
|
+
if (existsSync(commandsDir) && !existsSync(promptsDir)) {
|
|
135
|
+
try {
|
|
136
|
+
renameSync(commandsDir, promptsDir);
|
|
137
|
+
console.log(chalk.green(`Migrated ${label} commands/ → prompts/`));
|
|
138
|
+
return true;
|
|
139
|
+
} catch (err) {
|
|
140
|
+
console.log(
|
|
141
|
+
chalk.yellow(
|
|
142
|
+
`Warning: Could not migrate ${label} commands/ to prompts/: ${err instanceof Error ? err.message : err}`,
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Move fd/rg binaries from tools/ to bin/ if they exist.
|
|
152
|
+
*/
|
|
153
|
+
function migrateToolsToBin(): void {
|
|
154
|
+
const agentDir = getAgentDir();
|
|
155
|
+
const toolsDir = join(agentDir, "tools");
|
|
156
|
+
const binDir = getBinDir();
|
|
157
|
+
|
|
158
|
+
if (!existsSync(toolsDir)) return;
|
|
159
|
+
|
|
160
|
+
const binaries = ["fd", "rg", "fd.exe", "rg.exe"];
|
|
161
|
+
let movedAny = false;
|
|
162
|
+
|
|
163
|
+
for (const bin of binaries) {
|
|
164
|
+
const oldPath = join(toolsDir, bin);
|
|
165
|
+
const newPath = join(binDir, bin);
|
|
166
|
+
|
|
167
|
+
if (existsSync(oldPath)) {
|
|
168
|
+
if (!existsSync(binDir)) {
|
|
169
|
+
mkdirSync(binDir, { recursive: true });
|
|
170
|
+
}
|
|
171
|
+
if (!existsSync(newPath)) {
|
|
172
|
+
try {
|
|
173
|
+
renameSync(oldPath, newPath);
|
|
174
|
+
movedAny = true;
|
|
175
|
+
} catch {
|
|
176
|
+
// Ignore errors
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
// Target exists, just delete the old one
|
|
180
|
+
try {
|
|
181
|
+
rmSync?.(oldPath, { force: true });
|
|
182
|
+
} catch {
|
|
183
|
+
// Ignore
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (movedAny) {
|
|
190
|
+
console.log(chalk.green(`Migrated managed binaries tools/ → bin/`));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Check for deprecated hooks/ and tools/ directories.
|
|
196
|
+
* Note: tools/ may contain fd/rg binaries extracted by pi, so only warn if it has other files.
|
|
197
|
+
*/
|
|
198
|
+
function checkDeprecatedExtensionDirs(baseDir: string, label: string): string[] {
|
|
199
|
+
const hooksDir = join(baseDir, "hooks");
|
|
200
|
+
const toolsDir = join(baseDir, "tools");
|
|
201
|
+
const warnings: string[] = [];
|
|
202
|
+
|
|
203
|
+
if (existsSync(hooksDir)) {
|
|
204
|
+
warnings.push(`${label} hooks/ directory found. Hooks have been renamed to extensions.`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (existsSync(toolsDir)) {
|
|
208
|
+
// Check if tools/ contains anything other than fd/rg (which are auto-extracted binaries)
|
|
209
|
+
try {
|
|
210
|
+
const entries = readdirSync(toolsDir);
|
|
211
|
+
const customTools = entries.filter((e) => {
|
|
212
|
+
const lower = e.toLowerCase();
|
|
213
|
+
return (
|
|
214
|
+
lower !== "fd" && lower !== "rg" && lower !== "fd.exe" && lower !== "rg.exe" && !e.startsWith(".") // Ignore .DS_Store and other hidden files
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
if (customTools.length > 0) {
|
|
218
|
+
warnings.push(
|
|
219
|
+
`${label} tools/ directory contains custom tools. Custom tools have been merged into extensions.`,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
} catch {
|
|
223
|
+
// Ignore read errors
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return warnings;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Run extension system migrations (commands→prompts) and collect warnings about deprecated directories.
|
|
232
|
+
*/
|
|
233
|
+
function migrateExtensionSystem(cwd: string): string[] {
|
|
234
|
+
const agentDir = getAgentDir();
|
|
235
|
+
const projectDir = join(cwd, CONFIG_DIR_NAME);
|
|
236
|
+
|
|
237
|
+
// Migrate commands/ to prompts/
|
|
238
|
+
migrateCommandsToPrompts(agentDir, "Global");
|
|
239
|
+
migrateCommandsToPrompts(projectDir, "Project");
|
|
240
|
+
|
|
241
|
+
// Check for deprecated directories
|
|
242
|
+
const warnings = [
|
|
243
|
+
...checkDeprecatedExtensionDirs(agentDir, "Global"),
|
|
244
|
+
...checkDeprecatedExtensionDirs(projectDir, "Project"),
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
return warnings;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Print deprecation warnings and wait for keypress.
|
|
252
|
+
*/
|
|
253
|
+
export async function showDeprecationWarnings(warnings: string[]): Promise<void> {
|
|
254
|
+
if (warnings.length === 0) return;
|
|
255
|
+
|
|
256
|
+
for (const warning of warnings) {
|
|
257
|
+
console.log(chalk.yellow(`Warning: ${warning}`));
|
|
258
|
+
}
|
|
259
|
+
console.log(chalk.yellow(`\nMove your extensions to the extensions/ directory.`));
|
|
260
|
+
console.log(chalk.yellow(`Migration guide: ${getChangelogPath()}`));
|
|
261
|
+
console.log(chalk.yellow(`Documentation: ${join(getDocsPath(), "extensions.md")}`));
|
|
262
|
+
console.log(chalk.dim(`\nPress any key to continue...`));
|
|
263
|
+
|
|
264
|
+
await new Promise<void>((resolve) => {
|
|
265
|
+
process.stdin.setRawMode?.(true);
|
|
266
|
+
process.stdin.resume();
|
|
267
|
+
process.stdin.once("data", () => {
|
|
268
|
+
process.stdin.setRawMode?.(false);
|
|
269
|
+
process.stdin.pause();
|
|
270
|
+
resolve();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
console.log();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Run all migrations. Called once on startup.
|
|
278
|
+
*
|
|
279
|
+
* @returns Object with migration results and deprecation warnings
|
|
280
|
+
*/
|
|
281
|
+
export function runMigrations(cwd: string = process.cwd()): {
|
|
282
|
+
migratedAuthProviders: string[];
|
|
283
|
+
deprecationWarnings: string[];
|
|
284
|
+
} {
|
|
285
|
+
const migratedAuthProviders = migrateAuthToAuthJson();
|
|
286
|
+
migrateSessionsFromAgentRoot();
|
|
287
|
+
migrateToolsToBin();
|
|
288
|
+
const deprecationWarnings = migrateExtensionSystem(cwd);
|
|
289
|
+
return { migratedAuthProviders, deprecationWarnings };
|
|
290
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run modes for the coding agent.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { InteractiveMode, type InteractiveModeOptions } from "./interactive/interactive-mode.js";
|
|
6
|
+
export { type PrintModeOptions, runPrintMode } from "./print-mode.js";
|
|
7
|
+
export { type ModelInfo, RpcClient, type RpcClientOptions, type RpcEventListener } from "./rpc/rpc-client.js";
|
|
8
|
+
export { runRpcMode } from "./rpc/rpc-mode.js";
|
|
9
|
+
export type { RpcCommand, RpcResponse, RpcSessionState } from "./rpc/rpc-types.js";
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Armin says hi! A fun easter egg with animated XBM art.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Component, TUI } from "@lenylvt/pi-tui";
|
|
6
|
+
import { theme } from "../theme/theme.js";
|
|
7
|
+
|
|
8
|
+
// XBM image: 31x36 pixels, LSB first, 1=background, 0=foreground
|
|
9
|
+
const WIDTH = 31;
|
|
10
|
+
const HEIGHT = 36;
|
|
11
|
+
const BITS = [
|
|
12
|
+
0xff, 0xff, 0xff, 0x7f, 0xff, 0xf0, 0xff, 0x7f, 0xff, 0xed, 0xff, 0x7f, 0xff, 0xdb, 0xff, 0x7f, 0xff, 0xb7, 0xff,
|
|
13
|
+
0x7f, 0xff, 0x77, 0xfe, 0x7f, 0x3f, 0xf8, 0xfe, 0x7f, 0xdf, 0xff, 0xfe, 0x7f, 0xdf, 0x3f, 0xfc, 0x7f, 0x9f, 0xc3,
|
|
14
|
+
0xfb, 0x7f, 0x6f, 0xfc, 0xf4, 0x7f, 0xf7, 0x0f, 0xf7, 0x7f, 0xf7, 0xff, 0xf7, 0x7f, 0xf7, 0xff, 0xe3, 0x7f, 0xf7,
|
|
15
|
+
0x07, 0xe8, 0x7f, 0xef, 0xf8, 0x67, 0x70, 0x0f, 0xff, 0xbb, 0x6f, 0xf1, 0x00, 0xd0, 0x5b, 0xfd, 0x3f, 0xec, 0x53,
|
|
16
|
+
0xc1, 0xff, 0xef, 0x57, 0x9f, 0xfd, 0xee, 0x5f, 0x9f, 0xfc, 0xae, 0x5f, 0x1f, 0x78, 0xac, 0x5f, 0x3f, 0x00, 0x50,
|
|
17
|
+
0x6c, 0x7f, 0x00, 0xdc, 0x77, 0xff, 0xc0, 0x3f, 0x78, 0xff, 0x01, 0xf8, 0x7f, 0xff, 0x03, 0x9c, 0x78, 0xff, 0x07,
|
|
18
|
+
0x8c, 0x7c, 0xff, 0x0f, 0xce, 0x78, 0xff, 0xff, 0xcf, 0x7f, 0xff, 0xff, 0xcf, 0x78, 0xff, 0xff, 0xdf, 0x78, 0xff,
|
|
19
|
+
0xff, 0xdf, 0x7d, 0xff, 0xff, 0x3f, 0x7e, 0xff, 0xff, 0xff, 0x7f,
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const BYTES_PER_ROW = Math.ceil(WIDTH / 8);
|
|
23
|
+
const DISPLAY_HEIGHT = Math.ceil(HEIGHT / 2); // Half-block rendering
|
|
24
|
+
|
|
25
|
+
type Effect = "typewriter" | "scanline" | "rain" | "fade" | "crt" | "glitch" | "dissolve";
|
|
26
|
+
|
|
27
|
+
const EFFECTS: Effect[] = ["typewriter", "scanline", "rain", "fade", "crt", "glitch", "dissolve"];
|
|
28
|
+
|
|
29
|
+
// Get pixel at (x, y): true = foreground, false = background
|
|
30
|
+
function getPixel(x: number, y: number): boolean {
|
|
31
|
+
if (y >= HEIGHT) return false;
|
|
32
|
+
const byteIndex = y * BYTES_PER_ROW + Math.floor(x / 8);
|
|
33
|
+
const bitIndex = x % 8;
|
|
34
|
+
return ((BITS[byteIndex] >> bitIndex) & 1) === 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Get the character for a cell (2 vertical pixels packed)
|
|
38
|
+
function getChar(x: number, row: number): string {
|
|
39
|
+
const upper = getPixel(x, row * 2);
|
|
40
|
+
const lower = getPixel(x, row * 2 + 1);
|
|
41
|
+
if (upper && lower) return "█";
|
|
42
|
+
if (upper) return "▀";
|
|
43
|
+
if (lower) return "▄";
|
|
44
|
+
return " ";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Build the final image grid
|
|
48
|
+
function buildFinalGrid(): string[][] {
|
|
49
|
+
const grid: string[][] = [];
|
|
50
|
+
for (let row = 0; row < DISPLAY_HEIGHT; row++) {
|
|
51
|
+
const line: string[] = [];
|
|
52
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
53
|
+
line.push(getChar(x, row));
|
|
54
|
+
}
|
|
55
|
+
grid.push(line);
|
|
56
|
+
}
|
|
57
|
+
return grid;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class ArminComponent implements Component {
|
|
61
|
+
private ui: TUI;
|
|
62
|
+
private interval: ReturnType<typeof setInterval> | null = null;
|
|
63
|
+
private effect: Effect;
|
|
64
|
+
private finalGrid: string[][];
|
|
65
|
+
private currentGrid: string[][];
|
|
66
|
+
private effectState: Record<string, unknown> = {};
|
|
67
|
+
private cachedLines: string[] = [];
|
|
68
|
+
private cachedWidth = 0;
|
|
69
|
+
private gridVersion = 0;
|
|
70
|
+
private cachedVersion = -1;
|
|
71
|
+
|
|
72
|
+
constructor(ui: TUI) {
|
|
73
|
+
this.ui = ui;
|
|
74
|
+
this.effect = EFFECTS[Math.floor(Math.random() * EFFECTS.length)];
|
|
75
|
+
this.finalGrid = buildFinalGrid();
|
|
76
|
+
this.currentGrid = this.createEmptyGrid();
|
|
77
|
+
|
|
78
|
+
this.initEffect();
|
|
79
|
+
this.startAnimation();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
invalidate(): void {
|
|
83
|
+
this.cachedWidth = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render(width: number): string[] {
|
|
87
|
+
if (width === this.cachedWidth && this.cachedVersion === this.gridVersion) {
|
|
88
|
+
return this.cachedLines;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const padding = 1;
|
|
92
|
+
const availableWidth = width - padding;
|
|
93
|
+
|
|
94
|
+
this.cachedLines = this.currentGrid.map((row) => {
|
|
95
|
+
// Clip row to available width before applying color
|
|
96
|
+
const clipped = row.slice(0, availableWidth).join("");
|
|
97
|
+
const padRight = Math.max(0, width - padding - clipped.length);
|
|
98
|
+
return ` ${theme.fg("accent", clipped)}${" ".repeat(padRight)}`;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Add "ARMIN SAYS HI" at the end
|
|
102
|
+
const message = "ARMIN SAYS HI";
|
|
103
|
+
const msgPadRight = Math.max(0, width - padding - message.length);
|
|
104
|
+
this.cachedLines.push(` ${theme.fg("accent", message)}${" ".repeat(msgPadRight)}`);
|
|
105
|
+
|
|
106
|
+
this.cachedWidth = width;
|
|
107
|
+
this.cachedVersion = this.gridVersion;
|
|
108
|
+
|
|
109
|
+
return this.cachedLines;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private createEmptyGrid(): string[][] {
|
|
113
|
+
return Array.from({ length: DISPLAY_HEIGHT }, () => Array(WIDTH).fill(" "));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private initEffect(): void {
|
|
117
|
+
switch (this.effect) {
|
|
118
|
+
case "typewriter":
|
|
119
|
+
this.effectState = { pos: 0 };
|
|
120
|
+
break;
|
|
121
|
+
case "scanline":
|
|
122
|
+
this.effectState = { row: 0 };
|
|
123
|
+
break;
|
|
124
|
+
case "rain":
|
|
125
|
+
// Track falling position for each column
|
|
126
|
+
this.effectState = {
|
|
127
|
+
drops: Array.from({ length: WIDTH }, () => ({
|
|
128
|
+
y: -Math.floor(Math.random() * DISPLAY_HEIGHT * 2),
|
|
129
|
+
settled: 0,
|
|
130
|
+
})),
|
|
131
|
+
};
|
|
132
|
+
break;
|
|
133
|
+
case "fade": {
|
|
134
|
+
// Shuffle all pixel positions
|
|
135
|
+
const positions: [number, number][] = [];
|
|
136
|
+
for (let row = 0; row < DISPLAY_HEIGHT; row++) {
|
|
137
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
138
|
+
positions.push([row, x]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Fisher-Yates shuffle
|
|
142
|
+
for (let i = positions.length - 1; i > 0; i--) {
|
|
143
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
144
|
+
[positions[i], positions[j]] = [positions[j], positions[i]];
|
|
145
|
+
}
|
|
146
|
+
this.effectState = { positions, idx: 0 };
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "crt":
|
|
150
|
+
this.effectState = { expansion: 0 };
|
|
151
|
+
break;
|
|
152
|
+
case "glitch":
|
|
153
|
+
this.effectState = { phase: 0, glitchFrames: 8 };
|
|
154
|
+
break;
|
|
155
|
+
case "dissolve": {
|
|
156
|
+
// Start with random noise
|
|
157
|
+
this.currentGrid = Array.from({ length: DISPLAY_HEIGHT }, () =>
|
|
158
|
+
Array.from({ length: WIDTH }, () => {
|
|
159
|
+
const chars = [" ", "░", "▒", "▓", "█", "▀", "▄"];
|
|
160
|
+
return chars[Math.floor(Math.random() * chars.length)];
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
// Shuffle positions for gradual resolve
|
|
164
|
+
const dissolvePositions: [number, number][] = [];
|
|
165
|
+
for (let row = 0; row < DISPLAY_HEIGHT; row++) {
|
|
166
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
167
|
+
dissolvePositions.push([row, x]);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (let i = dissolvePositions.length - 1; i > 0; i--) {
|
|
171
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
172
|
+
[dissolvePositions[i], dissolvePositions[j]] = [dissolvePositions[j], dissolvePositions[i]];
|
|
173
|
+
}
|
|
174
|
+
this.effectState = { positions: dissolvePositions, idx: 0 };
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private startAnimation(): void {
|
|
181
|
+
const fps = this.effect === "glitch" ? 60 : 30;
|
|
182
|
+
this.interval = setInterval(() => {
|
|
183
|
+
const done = this.tickEffect();
|
|
184
|
+
this.updateDisplay();
|
|
185
|
+
this.ui.requestRender();
|
|
186
|
+
if (done) {
|
|
187
|
+
this.stopAnimation();
|
|
188
|
+
}
|
|
189
|
+
}, 1000 / fps);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private stopAnimation(): void {
|
|
193
|
+
if (this.interval) {
|
|
194
|
+
clearInterval(this.interval);
|
|
195
|
+
this.interval = null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private tickEffect(): boolean {
|
|
200
|
+
switch (this.effect) {
|
|
201
|
+
case "typewriter":
|
|
202
|
+
return this.tickTypewriter();
|
|
203
|
+
case "scanline":
|
|
204
|
+
return this.tickScanline();
|
|
205
|
+
case "rain":
|
|
206
|
+
return this.tickRain();
|
|
207
|
+
case "fade":
|
|
208
|
+
return this.tickFade();
|
|
209
|
+
case "crt":
|
|
210
|
+
return this.tickCrt();
|
|
211
|
+
case "glitch":
|
|
212
|
+
return this.tickGlitch();
|
|
213
|
+
case "dissolve":
|
|
214
|
+
return this.tickDissolve();
|
|
215
|
+
default:
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private tickTypewriter(): boolean {
|
|
221
|
+
const state = this.effectState as { pos: number };
|
|
222
|
+
const pixelsPerFrame = 3;
|
|
223
|
+
|
|
224
|
+
for (let i = 0; i < pixelsPerFrame; i++) {
|
|
225
|
+
const row = Math.floor(state.pos / WIDTH);
|
|
226
|
+
const x = state.pos % WIDTH;
|
|
227
|
+
if (row >= DISPLAY_HEIGHT) return true;
|
|
228
|
+
this.currentGrid[row][x] = this.finalGrid[row][x];
|
|
229
|
+
state.pos++;
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private tickScanline(): boolean {
|
|
235
|
+
const state = this.effectState as { row: number };
|
|
236
|
+
if (state.row >= DISPLAY_HEIGHT) return true;
|
|
237
|
+
|
|
238
|
+
// Copy row
|
|
239
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
240
|
+
this.currentGrid[state.row][x] = this.finalGrid[state.row][x];
|
|
241
|
+
}
|
|
242
|
+
state.row++;
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private tickRain(): boolean {
|
|
247
|
+
const state = this.effectState as {
|
|
248
|
+
drops: { y: number; settled: number }[];
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
let allSettled = true;
|
|
252
|
+
this.currentGrid = this.createEmptyGrid();
|
|
253
|
+
|
|
254
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
255
|
+
const drop = state.drops[x];
|
|
256
|
+
|
|
257
|
+
// Draw settled pixels
|
|
258
|
+
for (let row = DISPLAY_HEIGHT - 1; row >= DISPLAY_HEIGHT - drop.settled; row--) {
|
|
259
|
+
if (row >= 0) {
|
|
260
|
+
this.currentGrid[row][x] = this.finalGrid[row][x];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Check if this column is done
|
|
265
|
+
if (drop.settled >= DISPLAY_HEIGHT) continue;
|
|
266
|
+
|
|
267
|
+
allSettled = false;
|
|
268
|
+
|
|
269
|
+
// Find the target row for this column (lowest non-space pixel)
|
|
270
|
+
let targetRow = -1;
|
|
271
|
+
for (let row = DISPLAY_HEIGHT - 1 - drop.settled; row >= 0; row--) {
|
|
272
|
+
if (this.finalGrid[row][x] !== " ") {
|
|
273
|
+
targetRow = row;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Move drop down
|
|
279
|
+
drop.y++;
|
|
280
|
+
|
|
281
|
+
// Draw falling drop
|
|
282
|
+
if (drop.y >= 0 && drop.y < DISPLAY_HEIGHT) {
|
|
283
|
+
if (targetRow >= 0 && drop.y >= targetRow) {
|
|
284
|
+
// Settle
|
|
285
|
+
drop.settled = DISPLAY_HEIGHT - targetRow;
|
|
286
|
+
drop.y = -Math.floor(Math.random() * 5) - 1;
|
|
287
|
+
} else {
|
|
288
|
+
// Still falling
|
|
289
|
+
this.currentGrid[drop.y][x] = "▓";
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return allSettled;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private tickFade(): boolean {
|
|
298
|
+
const state = this.effectState as { positions: [number, number][]; idx: number };
|
|
299
|
+
const pixelsPerFrame = 15;
|
|
300
|
+
|
|
301
|
+
for (let i = 0; i < pixelsPerFrame; i++) {
|
|
302
|
+
if (state.idx >= state.positions.length) return true;
|
|
303
|
+
const [row, x] = state.positions[state.idx];
|
|
304
|
+
this.currentGrid[row][x] = this.finalGrid[row][x];
|
|
305
|
+
state.idx++;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private tickCrt(): boolean {
|
|
311
|
+
const state = this.effectState as { expansion: number };
|
|
312
|
+
const midRow = Math.floor(DISPLAY_HEIGHT / 2);
|
|
313
|
+
|
|
314
|
+
this.currentGrid = this.createEmptyGrid();
|
|
315
|
+
|
|
316
|
+
// Draw from middle expanding outward
|
|
317
|
+
const top = midRow - state.expansion;
|
|
318
|
+
const bottom = midRow + state.expansion;
|
|
319
|
+
|
|
320
|
+
for (let row = Math.max(0, top); row <= Math.min(DISPLAY_HEIGHT - 1, bottom); row++) {
|
|
321
|
+
for (let x = 0; x < WIDTH; x++) {
|
|
322
|
+
this.currentGrid[row][x] = this.finalGrid[row][x];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
state.expansion++;
|
|
327
|
+
return state.expansion > DISPLAY_HEIGHT;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private tickGlitch(): boolean {
|
|
331
|
+
const state = this.effectState as { phase: number; glitchFrames: number };
|
|
332
|
+
|
|
333
|
+
if (state.phase < state.glitchFrames) {
|
|
334
|
+
// Glitch phase: show corrupted version
|
|
335
|
+
this.currentGrid = this.finalGrid.map((row) => {
|
|
336
|
+
const offset = Math.floor(Math.random() * 7) - 3;
|
|
337
|
+
const glitchRow = [...row];
|
|
338
|
+
|
|
339
|
+
// Random horizontal offset
|
|
340
|
+
if (Math.random() < 0.3) {
|
|
341
|
+
const shifted = glitchRow.slice(offset).concat(glitchRow.slice(0, offset));
|
|
342
|
+
return shifted.slice(0, WIDTH);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Random vertical swap
|
|
346
|
+
if (Math.random() < 0.2) {
|
|
347
|
+
const swapRow = Math.floor(Math.random() * DISPLAY_HEIGHT);
|
|
348
|
+
return [...this.finalGrid[swapRow]];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return glitchRow;
|
|
352
|
+
});
|
|
353
|
+
state.phase++;
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Final frame: show clean image
|
|
358
|
+
this.currentGrid = this.finalGrid.map((row) => [...row]);
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private tickDissolve(): boolean {
|
|
363
|
+
const state = this.effectState as { positions: [number, number][]; idx: number };
|
|
364
|
+
const pixelsPerFrame = 20;
|
|
365
|
+
|
|
366
|
+
for (let i = 0; i < pixelsPerFrame; i++) {
|
|
367
|
+
if (state.idx >= state.positions.length) return true;
|
|
368
|
+
const [row, x] = state.positions[state.idx];
|
|
369
|
+
this.currentGrid[row][x] = this.finalGrid[row][x];
|
|
370
|
+
state.idx++;
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private updateDisplay(): void {
|
|
376
|
+
this.gridVersion++;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
dispose(): void {
|
|
380
|
+
this.stopAnimation();
|
|
381
|
+
}
|
|
382
|
+
}
|