@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,162 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
import { clipboard } from "./clipboard-native.js";
|
|
3
|
+
import { loadPhoton } from "./photon.js";
|
|
4
|
+
const SUPPORTED_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif"];
|
|
5
|
+
const DEFAULT_LIST_TIMEOUT_MS = 1000;
|
|
6
|
+
const DEFAULT_READ_TIMEOUT_MS = 3000;
|
|
7
|
+
const DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
8
|
+
export function isWaylandSession(env = process.env) {
|
|
9
|
+
return Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === "wayland";
|
|
10
|
+
}
|
|
11
|
+
function baseMimeType(mimeType) {
|
|
12
|
+
return mimeType.split(";")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
export function extensionForImageMimeType(mimeType) {
|
|
15
|
+
switch (baseMimeType(mimeType)) {
|
|
16
|
+
case "image/png":
|
|
17
|
+
return "png";
|
|
18
|
+
case "image/jpeg":
|
|
19
|
+
return "jpg";
|
|
20
|
+
case "image/webp":
|
|
21
|
+
return "webp";
|
|
22
|
+
case "image/gif":
|
|
23
|
+
return "gif";
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function selectPreferredImageMimeType(mimeTypes) {
|
|
29
|
+
const normalized = mimeTypes
|
|
30
|
+
.map((t) => t.trim())
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.map((t) => ({ raw: t, base: baseMimeType(t) }));
|
|
33
|
+
for (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {
|
|
34
|
+
const match = normalized.find((t) => t.base === preferred);
|
|
35
|
+
if (match) {
|
|
36
|
+
return match.raw;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const anyImage = normalized.find((t) => t.base.startsWith("image/"));
|
|
40
|
+
return anyImage?.raw ?? null;
|
|
41
|
+
}
|
|
42
|
+
function isSupportedImageMimeType(mimeType) {
|
|
43
|
+
const base = baseMimeType(mimeType);
|
|
44
|
+
return SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Convert unsupported image formats to PNG using Photon.
|
|
48
|
+
* Returns null if conversion is unavailable or fails.
|
|
49
|
+
*/
|
|
50
|
+
async function convertToPng(bytes) {
|
|
51
|
+
const photon = await loadPhoton();
|
|
52
|
+
if (!photon) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const image = photon.PhotonImage.new_from_byteslice(bytes);
|
|
57
|
+
try {
|
|
58
|
+
return image.get_bytes();
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
image.free();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function runCommand(command, args, options) {
|
|
69
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;
|
|
70
|
+
const maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;
|
|
71
|
+
const result = spawnSync(command, args, {
|
|
72
|
+
timeout: timeoutMs,
|
|
73
|
+
maxBuffer: maxBufferBytes,
|
|
74
|
+
});
|
|
75
|
+
if (result.error) {
|
|
76
|
+
return { ok: false, stdout: Buffer.alloc(0) };
|
|
77
|
+
}
|
|
78
|
+
if (result.status !== 0) {
|
|
79
|
+
return { ok: false, stdout: Buffer.alloc(0) };
|
|
80
|
+
}
|
|
81
|
+
const stdout = Buffer.isBuffer(result.stdout)
|
|
82
|
+
? result.stdout
|
|
83
|
+
: Buffer.from(result.stdout ?? "", typeof result.stdout === "string" ? "utf-8" : undefined);
|
|
84
|
+
return { ok: true, stdout };
|
|
85
|
+
}
|
|
86
|
+
function readClipboardImageViaWlPaste() {
|
|
87
|
+
const list = runCommand("wl-paste", ["--list-types"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });
|
|
88
|
+
if (!list.ok) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const types = list.stdout
|
|
92
|
+
.toString("utf-8")
|
|
93
|
+
.split(/\r?\n/)
|
|
94
|
+
.map((t) => t.trim())
|
|
95
|
+
.filter(Boolean);
|
|
96
|
+
const selectedType = selectPreferredImageMimeType(types);
|
|
97
|
+
if (!selectedType) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const data = runCommand("wl-paste", ["--type", selectedType, "--no-newline"]);
|
|
101
|
+
if (!data.ok || data.stdout.length === 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return { bytes: data.stdout, mimeType: baseMimeType(selectedType) };
|
|
105
|
+
}
|
|
106
|
+
function readClipboardImageViaXclip() {
|
|
107
|
+
const targets = runCommand("xclip", ["-selection", "clipboard", "-t", "TARGETS", "-o"], {
|
|
108
|
+
timeoutMs: DEFAULT_LIST_TIMEOUT_MS,
|
|
109
|
+
});
|
|
110
|
+
let candidateTypes = [];
|
|
111
|
+
if (targets.ok) {
|
|
112
|
+
candidateTypes = targets.stdout
|
|
113
|
+
.toString("utf-8")
|
|
114
|
+
.split(/\r?\n/)
|
|
115
|
+
.map((t) => t.trim())
|
|
116
|
+
.filter(Boolean);
|
|
117
|
+
}
|
|
118
|
+
const preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;
|
|
119
|
+
const tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];
|
|
120
|
+
for (const mimeType of tryTypes) {
|
|
121
|
+
const data = runCommand("xclip", ["-selection", "clipboard", "-t", mimeType, "-o"]);
|
|
122
|
+
if (data.ok && data.stdout.length > 0) {
|
|
123
|
+
return { bytes: data.stdout, mimeType: baseMimeType(mimeType) };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
export async function readClipboardImage(options) {
|
|
129
|
+
const env = options?.env ?? process.env;
|
|
130
|
+
const platform = options?.platform ?? process.platform;
|
|
131
|
+
if (env.TERMUX_VERSION) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
let image = null;
|
|
135
|
+
if (platform === "linux" && isWaylandSession(env)) {
|
|
136
|
+
image = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (!clipboard || !clipboard.hasImage()) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const imageData = await clipboard.getImageBinary();
|
|
143
|
+
if (!imageData || imageData.length === 0) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);
|
|
147
|
+
image = { bytes, mimeType: "image/png" };
|
|
148
|
+
}
|
|
149
|
+
if (!image) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
// Convert unsupported formats (e.g., BMP from WSLg) to PNG
|
|
153
|
+
if (!isSupportedImageMimeType(image.mimeType)) {
|
|
154
|
+
const pngBytes = await convertToPng(image.bytes);
|
|
155
|
+
if (!pngBytes) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
return { bytes: pngBytes, mimeType: "image/png" };
|
|
159
|
+
}
|
|
160
|
+
return image;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=clipboard-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard-image.js","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,0BAA0B,GAAG,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C,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,KAAK,GAAG,SAAS,YAAY,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvF,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import { spawnSync } from \"child_process\";\r\n\r\nimport { clipboard } from \"./clipboard-native.js\";\r\nimport { loadPhoton } from \"./photon.js\";\r\n\r\nexport type ClipboardImage = {\r\n\tbytes: Uint8Array;\r\n\tmimeType: string;\r\n};\r\n\r\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\r\n\r\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\r\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\r\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\r\n\r\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\r\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\r\n}\r\n\r\nfunction baseMimeType(mimeType: string): string {\r\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\r\n}\r\n\r\nexport function extensionForImageMimeType(mimeType: string): string | null {\r\n\tswitch (baseMimeType(mimeType)) {\r\n\t\tcase \"image/png\":\r\n\t\t\treturn \"png\";\r\n\t\tcase \"image/jpeg\":\r\n\t\t\treturn \"jpg\";\r\n\t\tcase \"image/webp\":\r\n\t\t\treturn \"webp\";\r\n\t\tcase \"image/gif\":\r\n\t\t\treturn \"gif\";\r\n\t\tdefault:\r\n\t\t\treturn null;\r\n\t}\r\n}\r\n\r\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\r\n\tconst normalized = mimeTypes\r\n\t\t.map((t) => t.trim())\r\n\t\t.filter(Boolean)\r\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\r\n\r\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\r\n\t\tconst match = normalized.find((t) => t.base === preferred);\r\n\t\tif (match) {\r\n\t\t\treturn match.raw;\r\n\t\t}\r\n\t}\r\n\r\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\r\n\treturn anyImage?.raw ?? null;\r\n}\r\n\r\nfunction isSupportedImageMimeType(mimeType: string): boolean {\r\n\tconst base = baseMimeType(mimeType);\r\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\r\n}\r\n\r\n/**\r\n * Convert unsupported image formats to PNG using Photon.\r\n * Returns null if conversion is unavailable or fails.\r\n */\r\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\r\n\tconst photon = await loadPhoton();\r\n\tif (!photon) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\ttry {\r\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\r\n\t\ttry {\r\n\t\t\treturn image.get_bytes();\r\n\t\t} finally {\r\n\t\t\timage.free();\r\n\t\t}\r\n\t} catch {\r\n\t\treturn null;\r\n\t}\r\n}\r\n\r\nfunction runCommand(\r\n\tcommand: string,\r\n\targs: string[],\r\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number },\r\n): { stdout: Buffer; ok: boolean } {\r\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\r\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\r\n\r\n\tconst result = spawnSync(command, args, {\r\n\t\ttimeout: timeoutMs,\r\n\t\tmaxBuffer: maxBufferBytes,\r\n\t});\r\n\r\n\tif (result.error) {\r\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\r\n\t}\r\n\r\n\tif (result.status !== 0) {\r\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\r\n\t}\r\n\r\n\tconst stdout = Buffer.isBuffer(result.stdout)\r\n\t\t? result.stdout\r\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\r\n\r\n\treturn { ok: true, stdout };\r\n}\r\n\r\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\r\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\r\n\tif (!list.ok) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst types = list.stdout\r\n\t\t.toString(\"utf-8\")\r\n\t\t.split(/\\r?\\n/)\r\n\t\t.map((t) => t.trim())\r\n\t\t.filter(Boolean);\r\n\r\n\tconst selectedType = selectPreferredImageMimeType(types);\r\n\tif (!selectedType) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\r\n\tif (!data.ok || data.stdout.length === 0) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\r\n}\r\n\r\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\r\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\r\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\r\n\t});\r\n\r\n\tlet candidateTypes: string[] = [];\r\n\tif (targets.ok) {\r\n\t\tcandidateTypes = targets.stdout\r\n\t\t\t.toString(\"utf-8\")\r\n\t\t\t.split(/\\r?\\n/)\r\n\t\t\t.map((t) => t.trim())\r\n\t\t\t.filter(Boolean);\r\n\t}\r\n\r\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\r\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\r\n\r\n\tfor (const mimeType of tryTypes) {\r\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\r\n\t\tif (data.ok && data.stdout.length > 0) {\r\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\r\n\t\t}\r\n\t}\r\n\r\n\treturn null;\r\n}\r\n\r\nexport async function readClipboardImage(options?: {\r\n\tenv?: NodeJS.ProcessEnv;\r\n\tplatform?: NodeJS.Platform;\r\n}): Promise<ClipboardImage | null> {\r\n\tconst env = options?.env ?? process.env;\r\n\tconst platform = options?.platform ?? process.platform;\r\n\r\n\tif (env.TERMUX_VERSION) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tlet image: ClipboardImage | null = null;\r\n\r\n\tif (platform === \"linux\" && isWaylandSession(env)) {\r\n\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\r\n\t} else {\r\n\t\tif (!clipboard || !clipboard.hasImage()) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tconst imageData = await clipboard.getImageBinary();\r\n\t\tif (!imageData || imageData.length === 0) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\r\n\t\timage = { bytes, mimeType: \"image/png\" };\r\n\t}\r\n\r\n\tif (!image) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\r\n\tif (!isSupportedImageMimeType(image.mimeType)) {\r\n\t\tconst pngBytes = await convertToPng(image.bytes);\r\n\t\tif (!pngBytes) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\r\n\t}\r\n\r\n\treturn image;\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard-native.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard-native.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAGF,QAAA,IAAI,SAAS,EAAE,eAAe,GAAG,IAAW,CAAC;AAY7C,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createRequire } from \"module\";\r\n\r\nexport type ClipboardModule = {\r\n\thasImage: () => boolean;\r\n\tgetImageBinary: () => Promise<Array<number>>;\r\n};\r\n\r\nconst require = createRequire(import.meta.url);\r\nlet clipboard: ClipboardModule | null = null;\r\n\r\nconst hasDisplay = process.platform !== \"linux\" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);\r\n\r\nif (!process.env.TERMUX_VERSION && hasDisplay) {\r\n\ttry {\r\n\t\tclipboard = require(\"@mariozechner/clipboard\") as ClipboardModule;\r\n\t} catch {\r\n\t\tclipboard = null;\r\n\t}\r\n}\r\n\r\nexport { clipboard };\r\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
let clipboard = null;
|
|
4
|
+
const hasDisplay = process.platform !== "linux" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);
|
|
5
|
+
if (!process.env.TERMUX_VERSION && hasDisplay) {
|
|
6
|
+
try {
|
|
7
|
+
clipboard = require("@mariozechner/clipboard");
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
clipboard = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { clipboard };
|
|
14
|
+
//# sourceMappingURL=clipboard-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard-native.js","sourceRoot":"","sources":["../../src/utils/clipboard-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAOvC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,IAAI,SAAS,GAA2B,IAAI,CAAC;AAE7C,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAE/G,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,UAAU,EAAE,CAAC;IAC/C,IAAI,CAAC;QACJ,SAAS,GAAG,OAAO,CAAC,yBAAyB,CAAoB,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACR,SAAS,GAAG,IAAI,CAAC;IAClB,CAAC;AACF,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createRequire } from \"module\";\r\n\r\nexport type ClipboardModule = {\r\n\thasImage: () => boolean;\r\n\tgetImageBinary: () => Promise<Array<number>>;\r\n};\r\n\r\nconst require = createRequire(import.meta.url);\r\nlet clipboard: ClipboardModule | null = null;\r\n\r\nconst hasDisplay = process.platform !== \"linux\" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);\r\n\r\nif (!process.env.TERMUX_VERSION && hasDisplay) {\r\n\ttry {\r\n\t\tclipboard = require(\"@mariozechner/clipboard\") as ClipboardModule;\r\n\t} catch {\r\n\t\tclipboard = null;\r\n\t}\r\n}\r\n\r\nexport { clipboard };\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAyDlD","sourcesContent":["import { execSync, spawn } from \"child_process\";\r\nimport { platform } from \"os\";\r\nimport { isWaylandSession } from \"./clipboard-image.js\";\r\n\r\nexport function copyToClipboard(text: string): void {\r\n\t// Always emit OSC 52 - works over SSH/mosh, harmless locally\r\n\tconst encoded = Buffer.from(text).toString(\"base64\");\r\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\r\n\r\n\t// Also try native tools (best effort for local sessions)\r\n\tconst p = platform();\r\n\tconst options = { input: text, timeout: 5000 };\r\n\r\n\ttry {\r\n\t\tif (p === \"darwin\") {\r\n\t\t\texecSync(\"pbcopy\", options);\r\n\t\t} else if (p === \"win32\") {\r\n\t\t\texecSync(\"clip\", options);\r\n\t\t} else {\r\n\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\r\n\t\t\tif (process.env.TERMUX_VERSION) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t} catch {\r\n\t\t\t\t\t// Fall back to Wayland or X11 tools.\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst isWayland = isWaylandSession();\r\n\t\t\tif (isWayland) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\r\n\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\r\n\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\r\n\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\r\n\t\t\t\t\tproc.stdin.on(\"error\", () => {\r\n\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\r\n\t\t\t\t\t});\r\n\t\t\t\t\tproc.stdin.write(text);\r\n\t\t\t\t\tproc.stdin.end();\r\n\t\t\t\t\tproc.unref();\r\n\t\t\t\t} catch {\r\n\t\t\t\t\t// Fall back to xclip/xsel (works on XWayland)\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\texecSync(\"xclip -selection clipboard\", options);\r\n\t\t\t\t\t} catch {\r\n\t\t\t\t\t\texecSync(\"xsel --clipboard --input\", options);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\ttry {\r\n\t\t\t\t\texecSync(\"xclip -selection clipboard\", options);\r\n\t\t\t\t} catch {\r\n\t\t\t\t\texecSync(\"xsel --clipboard --input\", options);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} catch {\r\n\t\t// Ignore - OSC 52 already emitted as fallback\r\n\t}\r\n}\r\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { execSync, spawn } from "child_process";
|
|
2
|
+
import { platform } from "os";
|
|
3
|
+
import { isWaylandSession } from "./clipboard-image.js";
|
|
4
|
+
export function copyToClipboard(text) {
|
|
5
|
+
// Always emit OSC 52 - works over SSH/mosh, harmless locally
|
|
6
|
+
const encoded = Buffer.from(text).toString("base64");
|
|
7
|
+
process.stdout.write(`\x1b]52;c;${encoded}\x07`);
|
|
8
|
+
// Also try native tools (best effort for local sessions)
|
|
9
|
+
const p = platform();
|
|
10
|
+
const options = { input: text, timeout: 5000 };
|
|
11
|
+
try {
|
|
12
|
+
if (p === "darwin") {
|
|
13
|
+
execSync("pbcopy", options);
|
|
14
|
+
}
|
|
15
|
+
else if (p === "win32") {
|
|
16
|
+
execSync("clip", options);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// Linux. Try Termux, Wayland, or X11 clipboard tools.
|
|
20
|
+
if (process.env.TERMUX_VERSION) {
|
|
21
|
+
try {
|
|
22
|
+
execSync("termux-clipboard-set", options);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Fall back to Wayland or X11 tools.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const isWayland = isWaylandSession();
|
|
30
|
+
if (isWayland) {
|
|
31
|
+
try {
|
|
32
|
+
// Verify wl-copy exists (spawn errors are async and won't be caught)
|
|
33
|
+
execSync("which wl-copy", { stdio: "ignore" });
|
|
34
|
+
// wl-copy with execSync hangs due to fork behavior; use spawn instead
|
|
35
|
+
const proc = spawn("wl-copy", [], { stdio: ["pipe", "ignore", "ignore"] });
|
|
36
|
+
proc.stdin.on("error", () => {
|
|
37
|
+
// Ignore EPIPE errors if wl-copy exits early
|
|
38
|
+
});
|
|
39
|
+
proc.stdin.write(text);
|
|
40
|
+
proc.stdin.end();
|
|
41
|
+
proc.unref();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Fall back to xclip/xsel (works on XWayland)
|
|
45
|
+
try {
|
|
46
|
+
execSync("xclip -selection clipboard", options);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
execSync("xsel --clipboard --input", options);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
try {
|
|
55
|
+
execSync("xclip -selection clipboard", options);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
execSync("xsel --clipboard --input", options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Ignore - OSC 52 already emitted as fallback
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=clipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.js","sourceRoot":"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/C,sEAAsE;oBACtE,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;oBAC3E,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;wBAC5B,6CAA6C;oBADhB,CAE7B,CAAC,CAAC;oBACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACvB,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;oBACjB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACd,CAAC;gBAAC,MAAM,CAAC;oBACR,8CAA8C;oBAC9C,IAAI,CAAC;wBACJ,QAAQ,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;oBACjD,CAAC;oBAAC,MAAM,CAAC;wBACR,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;oBAC/C,CAAC;gBACF,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC;oBACJ,QAAQ,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;gBACjD,CAAC;gBAAC,MAAM,CAAC;oBACR,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;gBAC/C,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,8CAA8C;IAC/C,CAAC;AAAA,CACD","sourcesContent":["import { execSync, spawn } from \"child_process\";\r\nimport { platform } from \"os\";\r\nimport { isWaylandSession } from \"./clipboard-image.js\";\r\n\r\nexport function copyToClipboard(text: string): void {\r\n\t// Always emit OSC 52 - works over SSH/mosh, harmless locally\r\n\tconst encoded = Buffer.from(text).toString(\"base64\");\r\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\r\n\r\n\t// Also try native tools (best effort for local sessions)\r\n\tconst p = platform();\r\n\tconst options = { input: text, timeout: 5000 };\r\n\r\n\ttry {\r\n\t\tif (p === \"darwin\") {\r\n\t\t\texecSync(\"pbcopy\", options);\r\n\t\t} else if (p === \"win32\") {\r\n\t\t\texecSync(\"clip\", options);\r\n\t\t} else {\r\n\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\r\n\t\t\tif (process.env.TERMUX_VERSION) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t} catch {\r\n\t\t\t\t\t// Fall back to Wayland or X11 tools.\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst isWayland = isWaylandSession();\r\n\t\t\tif (isWayland) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\r\n\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\r\n\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\r\n\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\r\n\t\t\t\t\tproc.stdin.on(\"error\", () => {\r\n\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\r\n\t\t\t\t\t});\r\n\t\t\t\t\tproc.stdin.write(text);\r\n\t\t\t\t\tproc.stdin.end();\r\n\t\t\t\t\tproc.unref();\r\n\t\t\t\t} catch {\r\n\t\t\t\t\t// Fall back to xclip/xsel (works on XWayland)\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\texecSync(\"xclip -selection clipboard\", options);\r\n\t\t\t\t\t} catch {\r\n\t\t\t\t\t\texecSync(\"xsel --clipboard --input\", options);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\ttry {\r\n\t\t\t\t\texecSync(\"xclip -selection clipboard\", options);\r\n\t\t\t\t} catch {\r\n\t\t\t\t\texecSync(\"xsel --clipboard --input\", options);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} catch {\r\n\t\t// Ignore - OSC 52 already emitted as fallback\r\n\t}\r\n}\r\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ParsedFrontmatter<T extends Record<string, unknown>> = {
|
|
2
|
+
frontmatter: T;
|
|
3
|
+
body: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const parseFrontmatter: <T extends Record<string, unknown> = Record<string, unknown>>(content: string) => ParsedFrontmatter<T>;
|
|
6
|
+
export declare const stripFrontmatter: (content: string) => string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/utils/frontmatter.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3D,WAAW,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAsBF,eAAO,MAAM,gBAAgB,GAAI,CAAC,oGASjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6BAA8D,CAAC","sourcesContent":["import { parse } from \"yaml\";\r\n\r\ntype ParsedFrontmatter<T extends Record<string, unknown>> = {\r\n\tfrontmatter: T;\r\n\tbody: string;\r\n};\r\n\r\nconst normalizeNewlines = (value: string): string => value.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\r\n\r\nconst extractFrontmatter = (content: string): { yamlString: string | null; body: string } => {\r\n\tconst normalized = normalizeNewlines(content);\r\n\r\n\tif (!normalized.startsWith(\"---\")) {\r\n\t\treturn { yamlString: null, body: normalized };\r\n\t}\r\n\r\n\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\r\n\tif (endIndex === -1) {\r\n\t\treturn { yamlString: null, body: normalized };\r\n\t}\r\n\r\n\treturn {\r\n\t\tyamlString: normalized.slice(4, endIndex),\r\n\t\tbody: normalized.slice(endIndex + 4).trim(),\r\n\t};\r\n};\r\n\r\nexport const parseFrontmatter = <T extends Record<string, unknown> = Record<string, unknown>>(\r\n\tcontent: string,\r\n): ParsedFrontmatter<T> => {\r\n\tconst { yamlString, body } = extractFrontmatter(content);\r\n\tif (!yamlString) {\r\n\t\treturn { frontmatter: {} as T, body };\r\n\t}\r\n\tconst parsed = parse(yamlString);\r\n\treturn { frontmatter: (parsed ?? {}) as T, body };\r\n};\r\n\r\nexport const stripFrontmatter = (content: string): string => parseFrontmatter(content).body;\r\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { parse } from "yaml";
|
|
2
|
+
const normalizeNewlines = (value) => value.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
3
|
+
const extractFrontmatter = (content) => {
|
|
4
|
+
const normalized = normalizeNewlines(content);
|
|
5
|
+
if (!normalized.startsWith("---")) {
|
|
6
|
+
return { yamlString: null, body: normalized };
|
|
7
|
+
}
|
|
8
|
+
const endIndex = normalized.indexOf("\n---", 3);
|
|
9
|
+
if (endIndex === -1) {
|
|
10
|
+
return { yamlString: null, body: normalized };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
yamlString: normalized.slice(4, endIndex),
|
|
14
|
+
body: normalized.slice(endIndex + 4).trim(),
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const parseFrontmatter = (content) => {
|
|
18
|
+
const { yamlString, body } = extractFrontmatter(content);
|
|
19
|
+
if (!yamlString) {
|
|
20
|
+
return { frontmatter: {}, body };
|
|
21
|
+
}
|
|
22
|
+
const parsed = parse(yamlString);
|
|
23
|
+
return { frontmatter: (parsed ?? {}), body };
|
|
24
|
+
};
|
|
25
|
+
export const stripFrontmatter = (content) => parseFrontmatter(content).body;
|
|
26
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot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IACjC,OAAO,EAAE,WAAW,EAAE,CAAC,MAAM,IAAI,EAAE,CAAM,EAAE,IAAI,EAAE,CAAC;AAAA,CAClD,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC","sourcesContent":["import { parse } from \"yaml\";\r\n\r\ntype ParsedFrontmatter<T extends Record<string, unknown>> = {\r\n\tfrontmatter: T;\r\n\tbody: string;\r\n};\r\n\r\nconst normalizeNewlines = (value: string): string => value.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\r\n\r\nconst extractFrontmatter = (content: string): { yamlString: string | null; body: string } => {\r\n\tconst normalized = normalizeNewlines(content);\r\n\r\n\tif (!normalized.startsWith(\"---\")) {\r\n\t\treturn { yamlString: null, body: normalized };\r\n\t}\r\n\r\n\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\r\n\tif (endIndex === -1) {\r\n\t\treturn { yamlString: null, body: normalized };\r\n\t}\r\n\r\n\treturn {\r\n\t\tyamlString: normalized.slice(4, endIndex),\r\n\t\tbody: normalized.slice(endIndex + 4).trim(),\r\n\t};\r\n};\r\n\r\nexport const parseFrontmatter = <T extends Record<string, unknown> = Record<string, unknown>>(\r\n\tcontent: string,\r\n): ParsedFrontmatter<T> => {\r\n\tconst { yamlString, body } = extractFrontmatter(content);\r\n\tif (!yamlString) {\r\n\t\treturn { frontmatter: {} as T, body };\r\n\t}\r\n\tconst parsed = parse(yamlString);\r\n\treturn { frontmatter: (parsed ?? {}) as T, body };\r\n};\r\n\r\nexport const stripFrontmatter = (content: string): string => parseFrontmatter(content).body;\r\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed git URL information.
|
|
3
|
+
*/
|
|
4
|
+
export type GitSource = {
|
|
5
|
+
/** Always "git" for git sources */
|
|
6
|
+
type: "git";
|
|
7
|
+
/** Clone URL (always valid for git clone, without ref suffix) */
|
|
8
|
+
repo: string;
|
|
9
|
+
/** Git host domain (e.g., "github.com") */
|
|
10
|
+
host: string;
|
|
11
|
+
/** Repository path (e.g., "user/repo") */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Git ref (branch, tag, commit) if specified */
|
|
14
|
+
ref?: string;
|
|
15
|
+
/** True if ref was specified (package won't be auto-updated) */
|
|
16
|
+
pinned: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Parse git source into a GitSource.
|
|
20
|
+
*
|
|
21
|
+
* Rules:
|
|
22
|
+
* - With git: prefix, accept all historical shorthand forms.
|
|
23
|
+
* - Without git: prefix, only accept explicit protocol URLs.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseGitUrl(source: string): GitSource | null;
|
|
26
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC;AA4GF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA0D5D","sourcesContent":["import hostedGitInfo from \"hosted-git-info\";\r\n\r\n/**\r\n * Parsed git URL information.\r\n */\r\nexport type GitSource = {\r\n\t/** Always \"git\" for git sources */\r\n\ttype: \"git\";\r\n\t/** Clone URL (always valid for git clone, without ref suffix) */\r\n\trepo: string;\r\n\t/** Git host domain (e.g., \"github.com\") */\r\n\thost: string;\r\n\t/** Repository path (e.g., \"user/repo\") */\r\n\tpath: string;\r\n\t/** Git ref (branch, tag, commit) if specified */\r\n\tref?: string;\r\n\t/** True if ref was specified (package won't be auto-updated) */\r\n\tpinned: boolean;\r\n};\r\n\r\nfunction splitRef(url: string): { repo: string; ref?: string } {\r\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\r\n\tif (scpLikeMatch) {\r\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\r\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\t\tif (refSeparator < 0) return { repo: url };\r\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\t\tif (!repoPath || !ref) return { repo: url };\r\n\t\treturn {\r\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\r\n\t\t\tref,\r\n\t\t};\r\n\t}\r\n\r\n\tif (url.includes(\"://\")) {\r\n\t\ttry {\r\n\t\t\tconst parsed = new URL(url);\r\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\r\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\t\t\tif (refSeparator < 0) return { repo: url };\r\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\t\t\tif (!repoPath || !ref) return { repo: url };\r\n\t\t\tparsed.pathname = `/${repoPath}`;\r\n\t\t\treturn {\r\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\r\n\t\t\t\tref,\r\n\t\t\t};\r\n\t\t} catch {\r\n\t\t\treturn { repo: url };\r\n\t\t}\r\n\t}\r\n\r\n\tconst slashIndex = url.indexOf(\"/\");\r\n\tif (slashIndex < 0) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\tconst host = url.slice(0, slashIndex);\r\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\r\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\tif (refSeparator < 0) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\tif (!repoPath || !ref) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\treturn {\r\n\t\trepo: `${host}/${repoPath}`,\r\n\t\tref,\r\n\t};\r\n}\r\n\r\nfunction parseGenericGitUrl(url: string): GitSource | null {\r\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\r\n\tlet repo = repoWithoutRef;\r\n\tlet host = \"\";\r\n\tlet path = \"\";\r\n\r\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\r\n\tif (scpLikeMatch) {\r\n\t\thost = scpLikeMatch[1] ?? \"\";\r\n\t\tpath = scpLikeMatch[2] ?? \"\";\r\n\t} else if (\r\n\t\trepoWithoutRef.startsWith(\"https://\") ||\r\n\t\trepoWithoutRef.startsWith(\"http://\") ||\r\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\r\n\t\trepoWithoutRef.startsWith(\"git://\")\r\n\t) {\r\n\t\ttry {\r\n\t\t\tconst parsed = new URL(repoWithoutRef);\r\n\t\t\thost = parsed.hostname;\r\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\r\n\t\t} catch {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t} else {\r\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\r\n\t\tif (slashIndex < 0) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\thost = repoWithoutRef.slice(0, slashIndex);\r\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\r\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\trepo = `https://${repoWithoutRef}`;\r\n\t}\r\n\r\n\tconst normalizedPath = path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\r\n\tif (!host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn {\r\n\t\ttype: \"git\",\r\n\t\trepo,\r\n\t\thost,\r\n\t\tpath: normalizedPath,\r\n\t\tref,\r\n\t\tpinned: Boolean(ref),\r\n\t};\r\n}\r\n\r\n/**\r\n * Parse git source into a GitSource.\r\n *\r\n * Rules:\r\n * - With git: prefix, accept all historical shorthand forms.\r\n * - Without git: prefix, only accept explicit protocol URLs.\r\n */\r\nexport function parseGitUrl(source: string): GitSource | null {\r\n\tconst trimmed = source.trim();\r\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\r\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\r\n\r\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst split = splitRef(url);\r\n\r\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\r\n\t\t(value): value is string => Boolean(value),\r\n\t);\r\n\tfor (const candidate of hostedCandidates) {\r\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\r\n\t\tif (info) {\r\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst useHttpsPrefix =\r\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"git@\");\r\n\t\t\treturn {\r\n\t\t\t\ttype: \"git\",\r\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\r\n\t\t\t\thost: info.domain || \"\",\r\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\r\n\t\t\t\tref: info.committish || split.ref || undefined,\r\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\r\n\t\t(value): value is string => Boolean(value),\r\n\t);\r\n\tfor (const candidate of httpsCandidates) {\r\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\r\n\t\tif (info) {\r\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\treturn {\r\n\t\t\t\ttype: \"git\",\r\n\t\t\t\trepo: `https://${split.repo}`,\r\n\t\t\t\thost: info.domain || \"\",\r\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\r\n\t\t\t\tref: info.committish || split.ref || undefined,\r\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\treturn parseGenericGitUrl(url);\r\n}\r\n"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import hostedGitInfo from "hosted-git-info";
|
|
2
|
+
function splitRef(url) {
|
|
3
|
+
const scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);
|
|
4
|
+
if (scpLikeMatch) {
|
|
5
|
+
const pathWithMaybeRef = scpLikeMatch[2] ?? "";
|
|
6
|
+
const refSeparator = pathWithMaybeRef.indexOf("@");
|
|
7
|
+
if (refSeparator < 0)
|
|
8
|
+
return { repo: url };
|
|
9
|
+
const repoPath = pathWithMaybeRef.slice(0, refSeparator);
|
|
10
|
+
const ref = pathWithMaybeRef.slice(refSeparator + 1);
|
|
11
|
+
if (!repoPath || !ref)
|
|
12
|
+
return { repo: url };
|
|
13
|
+
return {
|
|
14
|
+
repo: `git@${scpLikeMatch[1] ?? ""}:${repoPath}`,
|
|
15
|
+
ref,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (url.includes("://")) {
|
|
19
|
+
try {
|
|
20
|
+
const parsed = new URL(url);
|
|
21
|
+
const pathWithMaybeRef = parsed.pathname.replace(/^\/+/, "");
|
|
22
|
+
const refSeparator = pathWithMaybeRef.indexOf("@");
|
|
23
|
+
if (refSeparator < 0)
|
|
24
|
+
return { repo: url };
|
|
25
|
+
const repoPath = pathWithMaybeRef.slice(0, refSeparator);
|
|
26
|
+
const ref = pathWithMaybeRef.slice(refSeparator + 1);
|
|
27
|
+
if (!repoPath || !ref)
|
|
28
|
+
return { repo: url };
|
|
29
|
+
parsed.pathname = `/${repoPath}`;
|
|
30
|
+
return {
|
|
31
|
+
repo: parsed.toString().replace(/\/$/, ""),
|
|
32
|
+
ref,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { repo: url };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const slashIndex = url.indexOf("/");
|
|
40
|
+
if (slashIndex < 0) {
|
|
41
|
+
return { repo: url };
|
|
42
|
+
}
|
|
43
|
+
const host = url.slice(0, slashIndex);
|
|
44
|
+
const pathWithMaybeRef = url.slice(slashIndex + 1);
|
|
45
|
+
const refSeparator = pathWithMaybeRef.indexOf("@");
|
|
46
|
+
if (refSeparator < 0) {
|
|
47
|
+
return { repo: url };
|
|
48
|
+
}
|
|
49
|
+
const repoPath = pathWithMaybeRef.slice(0, refSeparator);
|
|
50
|
+
const ref = pathWithMaybeRef.slice(refSeparator + 1);
|
|
51
|
+
if (!repoPath || !ref) {
|
|
52
|
+
return { repo: url };
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
repo: `${host}/${repoPath}`,
|
|
56
|
+
ref,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function parseGenericGitUrl(url) {
|
|
60
|
+
const { repo: repoWithoutRef, ref } = splitRef(url);
|
|
61
|
+
let repo = repoWithoutRef;
|
|
62
|
+
let host = "";
|
|
63
|
+
let path = "";
|
|
64
|
+
const scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);
|
|
65
|
+
if (scpLikeMatch) {
|
|
66
|
+
host = scpLikeMatch[1] ?? "";
|
|
67
|
+
path = scpLikeMatch[2] ?? "";
|
|
68
|
+
}
|
|
69
|
+
else if (repoWithoutRef.startsWith("https://") ||
|
|
70
|
+
repoWithoutRef.startsWith("http://") ||
|
|
71
|
+
repoWithoutRef.startsWith("ssh://") ||
|
|
72
|
+
repoWithoutRef.startsWith("git://")) {
|
|
73
|
+
try {
|
|
74
|
+
const parsed = new URL(repoWithoutRef);
|
|
75
|
+
host = parsed.hostname;
|
|
76
|
+
path = parsed.pathname.replace(/^\/+/, "");
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const slashIndex = repoWithoutRef.indexOf("/");
|
|
84
|
+
if (slashIndex < 0) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
host = repoWithoutRef.slice(0, slashIndex);
|
|
88
|
+
path = repoWithoutRef.slice(slashIndex + 1);
|
|
89
|
+
if (!host.includes(".") && host !== "localhost") {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
repo = `https://${repoWithoutRef}`;
|
|
93
|
+
}
|
|
94
|
+
const normalizedPath = path.replace(/\.git$/, "").replace(/^\/+/, "");
|
|
95
|
+
if (!host || !normalizedPath || normalizedPath.split("/").length < 2) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
type: "git",
|
|
100
|
+
repo,
|
|
101
|
+
host,
|
|
102
|
+
path: normalizedPath,
|
|
103
|
+
ref,
|
|
104
|
+
pinned: Boolean(ref),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parse git source into a GitSource.
|
|
109
|
+
*
|
|
110
|
+
* Rules:
|
|
111
|
+
* - With git: prefix, accept all historical shorthand forms.
|
|
112
|
+
* - Without git: prefix, only accept explicit protocol URLs.
|
|
113
|
+
*/
|
|
114
|
+
export function parseGitUrl(source) {
|
|
115
|
+
const trimmed = source.trim();
|
|
116
|
+
const hasGitPrefix = trimmed.startsWith("git:");
|
|
117
|
+
const url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;
|
|
118
|
+
if (!hasGitPrefix && !/^(https?|ssh|git):\/\//i.test(url)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const split = splitRef(url);
|
|
122
|
+
const hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter((value) => Boolean(value));
|
|
123
|
+
for (const candidate of hostedCandidates) {
|
|
124
|
+
const info = hostedGitInfo.fromUrl(candidate);
|
|
125
|
+
if (info) {
|
|
126
|
+
if (split.ref && info.project?.includes("@")) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const useHttpsPrefix = !split.repo.startsWith("http://") &&
|
|
130
|
+
!split.repo.startsWith("https://") &&
|
|
131
|
+
!split.repo.startsWith("ssh://") &&
|
|
132
|
+
!split.repo.startsWith("git://") &&
|
|
133
|
+
!split.repo.startsWith("git@");
|
|
134
|
+
return {
|
|
135
|
+
type: "git",
|
|
136
|
+
repo: useHttpsPrefix ? `https://${split.repo}` : split.repo,
|
|
137
|
+
host: info.domain || "",
|
|
138
|
+
path: `${info.user}/${info.project}`.replace(/\.git$/, ""),
|
|
139
|
+
ref: info.committish || split.ref || undefined,
|
|
140
|
+
pinned: Boolean(info.committish || split.ref),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter((value) => Boolean(value));
|
|
145
|
+
for (const candidate of httpsCandidates) {
|
|
146
|
+
const info = hostedGitInfo.fromUrl(candidate);
|
|
147
|
+
if (info) {
|
|
148
|
+
if (split.ref && info.project?.includes("@")) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
type: "git",
|
|
153
|
+
repo: `https://${split.repo}`,
|
|
154
|
+
host: info.domain || "",
|
|
155
|
+
path: `${info.user}/${info.project}`.replace(/\.git$/, ""),
|
|
156
|
+
ref: info.committish || split.ref || undefined,
|
|
157
|
+
pinned: Boolean(info.committish || split.ref),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return parseGenericGitUrl(url);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAoB5C,SAAS,QAAQ,CAAC,GAAW,EAAkC;IAC9D,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,YAAY,EAAE,CAAC;QAClB,MAAM,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,YAAY,GAAG,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAC5C,OAAO;YACN,IAAI,EAAE,OAAO,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,QAAQ,EAAE;YAChD,G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,IAAI,EAAE;gBACvB,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC1D,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,IAAI,SAAS;gBAC9C,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC;aAC7C,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAAA,CAC/B","sourcesContent":["import hostedGitInfo from \"hosted-git-info\";\r\n\r\n/**\r\n * Parsed git URL information.\r\n */\r\nexport type GitSource = {\r\n\t/** Always \"git\" for git sources */\r\n\ttype: \"git\";\r\n\t/** Clone URL (always valid for git clone, without ref suffix) */\r\n\trepo: string;\r\n\t/** Git host domain (e.g., \"github.com\") */\r\n\thost: string;\r\n\t/** Repository path (e.g., \"user/repo\") */\r\n\tpath: string;\r\n\t/** Git ref (branch, tag, commit) if specified */\r\n\tref?: string;\r\n\t/** True if ref was specified (package won't be auto-updated) */\r\n\tpinned: boolean;\r\n};\r\n\r\nfunction splitRef(url: string): { repo: string; ref?: string } {\r\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\r\n\tif (scpLikeMatch) {\r\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\r\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\t\tif (refSeparator < 0) return { repo: url };\r\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\t\tif (!repoPath || !ref) return { repo: url };\r\n\t\treturn {\r\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\r\n\t\t\tref,\r\n\t\t};\r\n\t}\r\n\r\n\tif (url.includes(\"://\")) {\r\n\t\ttry {\r\n\t\t\tconst parsed = new URL(url);\r\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\r\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\t\t\tif (refSeparator < 0) return { repo: url };\r\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\t\t\tif (!repoPath || !ref) return { repo: url };\r\n\t\t\tparsed.pathname = `/${repoPath}`;\r\n\t\t\treturn {\r\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\r\n\t\t\t\tref,\r\n\t\t\t};\r\n\t\t} catch {\r\n\t\t\treturn { repo: url };\r\n\t\t}\r\n\t}\r\n\r\n\tconst slashIndex = url.indexOf(\"/\");\r\n\tif (slashIndex < 0) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\tconst host = url.slice(0, slashIndex);\r\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\r\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\r\n\tif (refSeparator < 0) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\r\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\r\n\tif (!repoPath || !ref) {\r\n\t\treturn { repo: url };\r\n\t}\r\n\treturn {\r\n\t\trepo: `${host}/${repoPath}`,\r\n\t\tref,\r\n\t};\r\n}\r\n\r\nfunction parseGenericGitUrl(url: string): GitSource | null {\r\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\r\n\tlet repo = repoWithoutRef;\r\n\tlet host = \"\";\r\n\tlet path = \"\";\r\n\r\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\r\n\tif (scpLikeMatch) {\r\n\t\thost = scpLikeMatch[1] ?? \"\";\r\n\t\tpath = scpLikeMatch[2] ?? \"\";\r\n\t} else if (\r\n\t\trepoWithoutRef.startsWith(\"https://\") ||\r\n\t\trepoWithoutRef.startsWith(\"http://\") ||\r\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\r\n\t\trepoWithoutRef.startsWith(\"git://\")\r\n\t) {\r\n\t\ttry {\r\n\t\t\tconst parsed = new URL(repoWithoutRef);\r\n\t\t\thost = parsed.hostname;\r\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\r\n\t\t} catch {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t} else {\r\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\r\n\t\tif (slashIndex < 0) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\thost = repoWithoutRef.slice(0, slashIndex);\r\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\r\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\trepo = `https://${repoWithoutRef}`;\r\n\t}\r\n\r\n\tconst normalizedPath = path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\r\n\tif (!host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn {\r\n\t\ttype: \"git\",\r\n\t\trepo,\r\n\t\thost,\r\n\t\tpath: normalizedPath,\r\n\t\tref,\r\n\t\tpinned: Boolean(ref),\r\n\t};\r\n}\r\n\r\n/**\r\n * Parse git source into a GitSource.\r\n *\r\n * Rules:\r\n * - With git: prefix, accept all historical shorthand forms.\r\n * - Without git: prefix, only accept explicit protocol URLs.\r\n */\r\nexport function parseGitUrl(source: string): GitSource | null {\r\n\tconst trimmed = source.trim();\r\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\r\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\r\n\r\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst split = splitRef(url);\r\n\r\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\r\n\t\t(value): value is string => Boolean(value),\r\n\t);\r\n\tfor (const candidate of hostedCandidates) {\r\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\r\n\t\tif (info) {\r\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst useHttpsPrefix =\r\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\r\n\t\t\t\t!split.repo.startsWith(\"git@\");\r\n\t\t\treturn {\r\n\t\t\t\ttype: \"git\",\r\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\r\n\t\t\t\thost: info.domain || \"\",\r\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\r\n\t\t\t\tref: info.committish || split.ref || undefined,\r\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\r\n\t\t(value): value is string => Boolean(value),\r\n\t);\r\n\tfor (const candidate of httpsCandidates) {\r\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\r\n\t\tif (info) {\r\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\treturn {\r\n\t\t\t\ttype: \"git\",\r\n\t\t\t\trepo: `https://${split.repo}`,\r\n\t\t\t\thost: info.domain || \"\",\r\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\r\n\t\t\t\tref: info.committish || split.ref || undefined,\r\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\treturn parseGenericGitUrl(url);\r\n}\r\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert image to PNG format for terminal display.
|
|
3
|
+
* Kitty graphics protocol requires PNG format (f=100).
|
|
4
|
+
*/
|
|
5
|
+
export declare function convertToPng(base64Data: string, mimeType: string): Promise<{
|
|
6
|
+
data: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
} | null>;
|
|
9
|
+
//# sourceMappingURL=image-convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-convert.d.ts","sourceRoot":"","sources":["../../src/utils/image-convert.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,YAAY,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA4BpD","sourcesContent":["import { loadPhoton } from \"./photon.js\";\r\n\r\n/**\r\n * Convert image to PNG format for terminal display.\r\n * Kitty graphics protocol requires PNG format (f=100).\r\n */\r\nexport async function convertToPng(\r\n\tbase64Data: string,\r\n\tmimeType: string,\r\n): Promise<{ data: string; mimeType: string } | null> {\r\n\t// Already PNG, no conversion needed\r\n\tif (mimeType === \"image/png\") {\r\n\t\treturn { data: base64Data, mimeType };\r\n\t}\r\n\r\n\tconst photon = await loadPhoton();\r\n\tif (!photon) {\r\n\t\t// Photon not available, can't convert\r\n\t\treturn null;\r\n\t}\r\n\r\n\ttry {\r\n\t\tconst bytes = new Uint8Array(Buffer.from(base64Data, \"base64\"));\r\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\r\n\t\ttry {\r\n\t\t\tconst pngBuffer = image.get_bytes();\r\n\t\t\treturn {\r\n\t\t\t\tdata: Buffer.from(pngBuffer).toString(\"base64\"),\r\n\t\t\t\tmimeType: \"image/png\",\r\n\t\t\t};\r\n\t\t} finally {\r\n\t\t\timage.free();\r\n\t\t}\r\n\t} catch {\r\n\t\t// Conversion failed\r\n\t\treturn null;\r\n\t}\r\n}\r\n"]}
|