@openadapter/koda 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4448 -0
- package/README.md +665 -0
- package/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +2 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +12 -0
- package/dist/bun/restore-sandbox-env.js +1 -0
- package/dist/cli/args.d.ts +55 -0
- package/dist/cli/args.js +167 -0
- package/dist/cli/config-selector.d.ts +13 -0
- package/dist/cli/config-selector.js +1 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +7 -0
- package/dist/cli/import-sessions.d.ts +34 -0
- package/dist/cli/import-sessions.js +6 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +1 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +2 -0
- package/dist/cli/openadapter-setup.d.ts +29 -0
- package/dist/cli/openadapter-setup.js +3 -0
- package/dist/cli/session-picker.d.ts +8 -0
- package/dist/cli/session-picker.js +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +2 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.js +1 -0
- package/dist/core/agent-session-runtime.d.ts +116 -0
- package/dist/core/agent-session-runtime.js +1 -0
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session.d.ts +747 -0
- package/dist/core/agent-session.js +32 -0
- package/dist/core/auth-guidance.d.ts +4 -0
- package/dist/core/auth-guidance.js +8 -0
- package/dist/core/auth-storage.d.ts +140 -0
- package/dist/core/auth-storage.js +1 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +89 -0
- package/dist/core/compaction/branch-summarization.js +38 -0
- package/dist/core/compaction/compaction.d.ts +120 -0
- package/dist/core/compaction/compaction.js +104 -0
- package/dist/core/compaction/index.d.ts +6 -0
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +19 -0
- package/dist/core/defaults.d.ts +2 -0
- package/dist/core/defaults.js +1 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/diagnostics.js +0 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +1 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +1 -0
- package/dist/core/export-html/index.d.ts +36 -0
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +72 -0
- package/dist/core/export-html/tool-renderer.d.ts +33 -0
- package/dist/core/export-html/tool-renderer.js +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +8 -0
- package/dist/core/export-html/vendor/marked.min.js +56 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/loader.d.ts +23 -0
- package/dist/core/extensions/loader.js +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/types.d.ts +1180 -0
- package/dist/core/extensions/types.js +1 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +1 -0
- package/dist/core/footer-data-provider.d.ts +53 -0
- package/dist/core/footer-data-provider.js +1 -0
- package/dist/core/http-dispatcher.d.ts +20 -0
- package/dist/core/http-dispatcher.js +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.js +1 -0
- package/dist/core/keybindings.d.ts +352 -0
- package/dist/core/keybindings.js +1 -0
- package/dist/core/messages.d.ts +76 -0
- package/dist/core/messages.js +17 -0
- package/dist/core/model-registry.d.ts +149 -0
- package/dist/core/model-registry.js +9 -0
- package/dist/core/model-resolver.d.ts +109 -0
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.js +1 -0
- package/dist/core/package-manager.d.ts +203 -0
- package/dist/core/package-manager.js +3 -0
- package/dist/core/prompt-templates.d.ts +51 -0
- package/dist/core/prompt-templates.js +2 -0
- package/dist/core/provider-attribution.d.ts +3 -0
- package/dist/core/provider-attribution.js +1 -0
- package/dist/core/provider-display-names.d.ts +1 -0
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/core/resolve-config-value.js +1 -0
- package/dist/core/resource-loader.d.ts +193 -0
- package/dist/core/resource-loader.js +1 -0
- package/dist/core/sdk.d.ts +108 -0
- package/dist/core/sdk.js +1 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +7 -0
- package/dist/core/session-manager.d.ts +331 -0
- package/dist/core/session-manager.js +11 -0
- package/dist/core/settings-manager.d.ts +265 -0
- package/dist/core/settings-manager.js +1 -0
- package/dist/core/skills.d.ts +59 -0
- package/dist/core/skills.js +4 -0
- package/dist/core/slash-commands.d.ts +13 -0
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +1 -0
- package/dist/core/system-prompt.d.ts +27 -0
- package/dist/core/system-prompt.js +52 -0
- package/dist/core/telemetry.d.ts +2 -0
- package/dist/core/telemetry.js +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.js +3 -0
- package/dist/core/tools/bash.d.ts +67 -0
- package/dist/core/tools/bash.js +18 -0
- package/dist/core/tools/edit-diff.d.ts +86 -0
- package/dist/core/tools/edit-diff.js +16 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +1 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +13 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +13 -0
- package/dist/core/tools/index.d.ts +39 -0
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +9 -0
- package/dist/core/tools/output-accumulator.d.ts +51 -0
- package/dist/core/tools/output-accumulator.js +4 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.js +1 -0
- package/dist/core/tools/read.d.ts +34 -0
- package/dist/core/tools/read.js +22 -0
- package/dist/core/tools/render-utils.d.ts +23 -0
- package/dist/core/tools/render-utils.js +4 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +1 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +5 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +1 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +1 -0
- package/dist/migrations.d.ts +32 -0
- package/dist/migrations.js +8 -0
- package/dist/modes/index.d.ts +8 -0
- package/dist/modes/index.js +1 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
- package/dist/modes/interactive/components/assistant-message.js +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +13 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +3 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +3 -0
- package/dist/modes/interactive/components/config-selector.d.ts +70 -0
- package/dist/modes/interactive/components/config-selector.js +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +20 -0
- package/dist/modes/interactive/components/custom-editor.js +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +19 -0
- package/dist/modes/interactive/components/custom-message.js +2 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +1 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +3 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-editor.js +3 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +25 -0
- package/dist/modes/interactive/components/extension-selector.js +2 -0
- package/dist/modes/interactive/components/footer.d.ts +27 -0
- package/dist/modes/interactive/components/footer.js +1 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +46 -0
- package/dist/modes/interactive/components/model-selector.js +2 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +30 -0
- package/dist/modes/interactive/components/oauth-selector.js +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +41 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.js +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.js +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +68 -0
- package/dist/modes/interactive/components/settings-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +62 -0
- package/dist/modes/interactive/components/tool-execution.js +4 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +88 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.js +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +417 -0
- package/dist/modes/interactive/interactive-mode.js +116 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +101 -0
- package/dist/modes/interactive/theme/theme.js +18 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +4 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +3 -0
- package/dist/modes/rpc/rpc-client.d.ts +226 -0
- package/dist/modes/rpc/rpc-client.js +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +419 -0
- package/dist/modes/rpc/rpc-types.js +0 -0
- package/dist/package-manager-cli.d.ts +3 -0
- package/dist/package-manager-cli.js +49 -0
- package/dist/utils/ansi.d.ts +1 -0
- package/dist/utils/ansi.js +1 -0
- package/dist/utils/auto-update.d.ts +13 -0
- package/dist/utils/auto-update.js +1 -0
- package/dist/utils/changelog.d.ts +20 -0
- package/dist/utils/changelog.js +4 -0
- package/dist/utils/child-process.d.ts +14 -0
- package/dist/utils/child-process.js +1 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +1 -0
- package/dist/utils/clipboard-native.d.ts +9 -0
- package/dist/utils/clipboard-native.js +1 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +1 -0
- package/dist/utils/deprecation.d.ts +3 -0
- package/dist/utils/deprecation.js +1 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +1 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +4 -0
- package/dist/utils/fs-watch.d.ts +4 -0
- package/dist/utils/fs-watch.js +1 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +1 -0
- package/dist/utils/html.d.ts +6 -0
- package/dist/utils/html.js +1 -0
- package/dist/utils/image-convert.d.ts +8 -0
- package/dist/utils/image-convert.js +1 -0
- package/dist/utils/image-resize-core.d.ts +29 -0
- package/dist/utils/image-resize-core.js +1 -0
- package/dist/utils/image-resize-worker.d.ts +1 -0
- package/dist/utils/image-resize-worker.js +1 -0
- package/dist/utils/image-resize.d.ts +15 -0
- package/dist/utils/image-resize.js +1 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +1 -0
- package/dist/utils/koda-user-agent.d.ts +1 -0
- package/dist/utils/koda-user-agent.js +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.js +1 -0
- package/dist/utils/paths.d.ts +30 -0
- package/dist/utils/paths.js +1 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +1 -0
- package/dist/utils/shell.d.ts +29 -0
- package/dist/utils/shell.js +8 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +1 -0
- package/dist/utils/syntax-highlight.d.ts +11 -0
- package/dist/utils/syntax-highlight.js +2 -0
- package/dist/utils/tools-manager.d.ts +2 -0
- package/dist/utils/tools-manager.js +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.js +1 -0
- package/dist/utils/windows-self-update.d.ts +2 -0
- package/dist/utils/windows-self-update.js +1 -0
- package/docs/compaction.md +394 -0
- package/docs/custom-provider.md +736 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +148 -0
- package/docs/extensions.md +2626 -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/index.md +80 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +493 -0
- package/docs/packages.md +226 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +253 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1408 -0
- package/docs/sdk.md +1137 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +281 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +114 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +927 -0
- package/docs/usage.md +288 -0
- package/docs/windows.md +17 -0
- package/npm-shrinkwrap.json +1792 -0
- package/openadapter/extensions/koda-ask.js +12 -0
- package/openadapter/extensions/koda-bg.js +14 -0
- package/openadapter/extensions/koda-commands.mjs +15 -0
- package/openadapter/extensions/koda-help.js +8 -0
- package/openadapter/extensions/koda-memory.js +16 -0
- package/openadapter/extensions/koda-status.js +1 -0
- package/openadapter/extensions/koda-todo.js +4 -0
- package/openadapter/extensions/koda-vision.js +4 -0
- package/openadapter/extensions/koda-web.js +7 -0
- package/openadapter/setup.mjs +173 -0
- package/openadapter/skills/code-review/SKILL.md +22 -0
- package/openadapter/skills/debugging/SKILL.md +28 -0
- package/openadapter/skills/frontend/SKILL.md +38 -0
- package/package.json +108 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var S=Object.defineProperty;var n=(e,o)=>S(e,"name",{value:o,configurable:!0});import{Markdown as M}from"@openadapter/koda-tui";import t from"chalk";import{selectConfig as O}from"./cli/config-selector.js";import{APP_NAME as a,detectInstallMethod as A,getAgentDir as P,getPackageDir as R,getSelfUpdateCommand as I,getSelfUpdateUnavailableInstruction as D,PACKAGE_NAME as y,VERSION as v}from"./config.js";import{DefaultPackageManager as C}from"./core/package-manager.js";import{SettingsManager as E}from"./core/settings-manager.js";import{spawnProcess as W}from"./utils/child-process.js";import{getLatestPiRelease as j,isNewerPackageVersion as T}from"./utils/version-check.js";import{cleanupWindowsSelfUpdateQuarantine as _,quarantineWindowsNativeDependencies as B}from"./utils/windows-self-update.js";const F={heading:n(e=>t.bold(t.yellow(e)),"heading"),link:n(e=>t.cyan(e),"link"),linkUrl:n(e=>t.dim(e),"linkUrl"),code:n(e=>t.yellow(e),"code"),codeBlock:n(e=>t.dim(e),"codeBlock"),codeBlockBorder:n(e=>t.dim(e),"codeBlockBorder"),quote:n(e=>t.dim(e),"quote"),quoteBorder:n(e=>t.dim(e),"quoteBorder"),hr:n(e=>t.dim(e),"hr"),listBullet:n(e=>t.yellow(e),"listBullet"),bold:n(e=>t.bold(e),"bold"),italic:n(e=>t.italic(e),"italic"),strikethrough:n(e=>t.strikethrough(e),"strikethrough"),underline:n(e=>t.underline(e),"underline")};function N(e,o){const s=e.drainErrors();for(const{scope:r,error:m}of s)console.error(t.yellow(`Warning (${o}, ${r} settings): ${m.message}`)),m.stack&&console.error(t.dim(m.stack))}n(N,"reportSettingsErrors");function h(e){switch(e){case"install":return`${a} install <source> [-l]`;case"remove":return`${a} remove <source> [-l]`;case"update":return`${a} update [source|self|koda] [--self] [--extensions] [--extension <source>] [--force]`;case"list":return`${a} list`}}n(h,"getPackageCommandUsage");function L(e){switch(e){case"install":console.log(`${t.bold("Usage:")}
|
|
2
|
+
${h("install")}
|
|
3
|
+
|
|
4
|
+
Install a package and add it to settings.
|
|
5
|
+
|
|
6
|
+
Options:
|
|
7
|
+
-l, --local Install project-locally (.pi/settings.json)
|
|
8
|
+
|
|
9
|
+
Examples:
|
|
10
|
+
${a} install npm:@foo/bar
|
|
11
|
+
${a} install git:github.com/user/repo
|
|
12
|
+
${a} install git:git@github.com:user/repo
|
|
13
|
+
${a} install https://github.com/user/repo
|
|
14
|
+
${a} install ssh://git@github.com/user/repo
|
|
15
|
+
${a} install ./local/path
|
|
16
|
+
`);return;case"remove":console.log(`${t.bold("Usage:")}
|
|
17
|
+
${h("remove")}
|
|
18
|
+
|
|
19
|
+
Remove a package and its source from settings.
|
|
20
|
+
Alias: ${a} uninstall <source> [-l]
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
-l, --local Remove from project settings (.pi/settings.json)
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
${a} remove npm:@foo/bar
|
|
27
|
+
${a} uninstall npm:@foo/bar
|
|
28
|
+
`);return;case"update":console.log(`${t.bold("Usage:")}
|
|
29
|
+
${h("update")}
|
|
30
|
+
|
|
31
|
+
Update koda and installed packages.
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--self Update pi only
|
|
35
|
+
--extensions Update installed packages only
|
|
36
|
+
--extension <source> Update one package only
|
|
37
|
+
--force Reinstall pi even if the current version is latest
|
|
38
|
+
|
|
39
|
+
Short forms:
|
|
40
|
+
${a} update Update koda and all extensions
|
|
41
|
+
${a} update <source> Update one package
|
|
42
|
+
${a} update pi Update pi only (self works as alias to pi)
|
|
43
|
+
`);return;case"list":console.log(`${t.bold("Usage:")}
|
|
44
|
+
${h("list")}
|
|
45
|
+
|
|
46
|
+
List installed packages from user and project settings.
|
|
47
|
+
`);return}}n(L,"printPackageCommandHelp");function V(e){const[o,...s]=e;let r;if(o==="uninstall"?r="remove":(o==="install"||o==="remove"||o==="update"||o==="list")&&(r=o),!r)return;let m=!1,g=!1,k=!1,i,c,d,u,f,l=!1,$=!1,x;for(let U=0;U<s.length;U++){const p=s[U];if(p==="-h"||p==="--help"){k=!0;continue}if(p==="-l"||p==="--local"){r==="install"||r==="remove"?m=!0:i=i??p;continue}if(p==="--self"){r==="update"?l=!0:i=i??p;continue}if(p==="--extensions"){r==="update"?$=!0:i=i??p;continue}if(p==="--force"){r==="update"?g=!0:i=i??p;continue}if(p==="--extension"){if(r!=="update"){i=i??p;continue}const b=s[U+1];!b||b.startsWith("-")?d=d??p:x?(u=u??"--extension can only be provided once",U++):(x=b,U++);continue}if(p.startsWith("-")){i=i??p;continue}f?c=c??p:f=p}let w;return r==="update"&&(x?((l||$)&&(u=u??"--extension cannot be combined with --self or --extensions"),f&&(u=u??"--extension cannot be combined with a positional source"),w={type:"extensions",source:x}):f?f==="self"||f==="koda"||f==="pi"?w=$?{type:"all"}:{type:"self"}:(($||l)&&(u=u??"positional update targets cannot be combined with --self or --extensions"),w={type:"extensions",source:f}):l&&$?w={type:"all"}:l?w={type:"self"}:$?w={type:"extensions"}:w={type:"all"}),{command:r,source:f,updateTarget:w,local:m,force:g,help:k,invalidOption:i,invalidArgument:c,missingOptionValue:d,conflictingOptions:u}}n(V,"parsePackageCommand");function q(e){return e.type==="all"||e.type==="self"}n(q,"updateTargetIncludesSelf");function G(e){return e.type==="all"||e.type==="extensions"}n(G,"updateTargetIncludesExtensions");function H(e,o=y){console.error(`error: ${a} cannot self-update this installation.`),console.error(D(y,e,o));const s=process.argv[1];s&&(console.error(""),console.error(`Location of koda executable: ${s}`))}n(H,"printSelfUpdateUnavailable");function K(e){console.error(t.dim(`If this keeps failing, run this command yourself: ${e.display}`))}n(K,"printSelfUpdateFallback");function Q(e){const o=e.trim();if(o){console.log(),console.log(t.bold(t.yellow("Update note")));try{const s=Math.max(20,process.stdout.columns??80),r=new M(o,0,0,F).render(s).map(m=>m.trimEnd());console.log(r.join(`
|
|
48
|
+
`))}catch{console.log(o)}console.log()}}n(Q,"printSelfUpdateNote");async function z(e){const o=v.includes("-")?"@beta":"";if(e)return{packageName:y+o,shouldRun:!0};try{const s=await j(v),r=s?.packageName??y;if(!s||r!==y||T(s.version,v))return{packageName:r+o,shouldRun:!0,...s?.note?{note:s.note}:{}}}catch{return{packageName:y+o,shouldRun:!0}}return console.log(t.green(`${a} is already up to date (v${v})`)),{packageName:y,shouldRun:!1}}n(z,"getSelfUpdatePlan");async function J(e){console.log(t.dim(`Updating ${a} with ${e.display}...`));for(const o of e.steps??[e])await new Promise((s,r)=>{const m=W(o.command,o.args,{stdio:"inherit"});m.on("error",g=>{r(g)}),m.on("close",(g,k)=>{g===0?s():r(k?new Error(`${o.display} terminated by signal ${k}`):new Error(`${o.display} exited with code ${g??"unknown"}`))})})}n(J,"runSelfUpdate");function X(){if(process.platform!=="win32")return;const e=R();_(e),B(e)}n(X,"prepareWindowsNpmSelfUpdate");async function ie(e){if(e[0]!=="config")return!1;const o=process.cwd(),s=P(),r=E.create(o,s);N(r,"config command");const g=await new C({cwd:o,agentDir:s,settingsManager:r}).resolve();await O({resolvedPaths:g,settingsManager:r,cwd:o,agentDir:s}),process.exit(0)}n(ie,"handleConfigCommand");async function ce(e){const o=V(e);if(!o)return!1;if(o.help)return L(o.command),!0;if(o.invalidOption)return console.error(t.red(`Unknown option ${o.invalidOption} for "${o.command}".`)),console.error(t.dim(`Use "${a} --help" or "${h(o.command)}".`)),process.exitCode=1,!0;if(o.missingOptionValue)return console.error(t.red(`Missing value for ${o.missingOptionValue}.`)),console.error(t.dim(`Usage: ${h(o.command)}`)),process.exitCode=1,!0;if(o.invalidArgument)return console.error(t.red(`Unexpected argument ${o.invalidArgument}.`)),console.error(t.dim(`Usage: ${h(o.command)}`)),process.exitCode=1,!0;if(o.conflictingOptions)return console.error(t.red(o.conflictingOptions)),console.error(t.dim(`Usage: ${h(o.command)}`)),process.exitCode=1,!0;const s=o.source;if((o.command==="install"||o.command==="remove")&&!s)return console.error(t.red(`Missing ${o.command} source.`)),console.error(t.dim(`Usage: ${h(o.command)}`)),process.exitCode=1,!0;const r=process.cwd(),m=P(),g=E.create(r,m);N(g,"package command");const k=g.getGlobalSettings().npmCommand,i=new C({cwd:r,agentDir:m,settingsManager:g});i.setProgressCallback(c=>{c.type==="start"&&process.stdout.write(t.dim(`${c.message}
|
|
49
|
+
`))});try{switch(o.command){case"install":return await i.installAndPersist(s,{local:o.local}),console.log(t.green(`Installed ${s}`)),!0;case"remove":return await i.removeAndPersist(s,{local:o.local})?(console.log(t.green(`Removed ${s}`)),!0):(console.error(t.red(`No matching package found for ${s}`)),process.exitCode=1,!0);case"list":{const c=i.listConfiguredPackages(),d=c.filter(l=>l.scope==="user"),u=c.filter(l=>l.scope==="project");if(c.length===0)return console.log(t.dim("No packages installed.")),!0;const f=n(l=>{const $=l.filtered?`${l.source} (filtered)`:l.source;console.log(` ${$}`),l.installedPath&&console.log(t.dim(` ${l.installedPath}`))},"formatPackage");if(d.length>0){console.log(t.bold("User packages:"));for(const l of d)f(l)}if(u.length>0){d.length>0&&console.log(),console.log(t.bold("Project packages:"));for(const l of u)f(l)}return!0}case"update":{const c=o.updateTarget??{type:"all"};if(G(c)){const d=c.type==="extensions"?c.source:void 0;await i.update(d),console.log(d?t.green(`Updated ${d}`):t.green("Updated packages"))}if(q(c)){const d=await z(o.force);if(!d.shouldRun)return!0;const u=A();if(process.platform==="win32"&&u!=="npm"&&u!=="pnpm")return console.error(t.red(`${a} self-update on Windows is only supported for npm and pnpm installs.`)),console.error(t.dim(`Detected install method: ${u}. Update ${a} manually.`)),process.exitCode=1,!0;const f=I(y,k,d.packageName);if(!f)return H(k,d.packageName),process.exitCode=1,!0;d.note&&Q(d.note);try{u==="npm"&&X(),await J(f)}catch(l){const $=l instanceof Error?l.message:"Unknown package command error";return console.error(t.red(`Error: ${$}`)),K(f),process.exitCode=1,!0}console.log(t.green(`Updated ${a}`))}return!0}}}catch(c){const d=c instanceof Error?c.message:"Unknown package command error";return console.error(t.red(`Error: ${d}`)),process.exitCode=1,!0}}n(ce,"handlePackageCommand");export{ie as handleConfigCommand,ce as handlePackageCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripAnsi(value: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var t=(n,e)=>r(n,"name",{value:e,configurable:!0});function c({onlyFirst:n=!1}={}){const s="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(s,n?void 0:"g")}t(c,"ansiRegex");const o=c();function p(n){if(typeof n!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof n}\``);return!n.includes("\x1B")&&!n.includes("\x9B")?n:n.replace(o,"")}t(p,"stripAnsi");export{p as stripAnsi};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background self-update. When a newer version is published, Koda updates itself
|
|
3
|
+
* in the background (best-effort) so the next launch is current — like Claude Code.
|
|
4
|
+
*
|
|
5
|
+
* - Only runs for managed, writable global installs (npm/pnpm/yarn/bun) — for any
|
|
6
|
+
* other install getSelfUpdateCommand() returns undefined and we skip silently.
|
|
7
|
+
* - Prerelease users track the `beta` channel.
|
|
8
|
+
* - Disable with KODA_NO_AUTO_UPDATE=1 (or KODA_OFFLINE).
|
|
9
|
+
*/
|
|
10
|
+
/** The install spec to update to, honoring the prerelease (beta) channel. */
|
|
11
|
+
export declare function selfUpdateInstallSpec(): string;
|
|
12
|
+
/** Run the self-update command(s) in the background. Resolves true on success. */
|
|
13
|
+
export declare function runBackgroundSelfUpdate(): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var t=(e,o)=>u(e,"name",{value:o,configurable:!0});import{spawn as m}from"node:child_process";import{getSelfUpdateCommand as p,PACKAGE_NAME as a,VERSION as d}from"../config.js";function A(){return d.includes("-")?`${a}@beta`:a}t(A,"selfUpdateInstallSpec");async function U(){if(process.env.KODA_NO_AUTO_UPDATE==="1"||process.env.KODA_OFFLINE)return!1;const e=p(a,void 0,A());if(!e)return!1;const o=e.steps??[e];for(const c of o)if(!await new Promise(l=>{let i=!1;const n=t(r=>{i||(i=!0,l(r))},"finish"),s=m(c.command,c.args,{stdio:"ignore"}),f=setTimeout(()=>{try{s.kill()}catch{}n(!1)},18e4);s.on("close",r=>{clearTimeout(f),n(r===0)}),s.on("error",()=>{clearTimeout(f),n(!1)})}))return!1;return!0}t(U,"runBackgroundSelfUpdate");export{U as runBackgroundSelfUpdate,A as selfUpdateInstallSpec};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ChangelogEntry {
|
|
2
|
+
major: number;
|
|
3
|
+
minor: number;
|
|
4
|
+
patch: number;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parse changelog entries from CHANGELOG.md
|
|
9
|
+
* Scans for ## lines and collects content until next ## or EOF
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseChangelog(changelogPath: string): ChangelogEntry[];
|
|
12
|
+
/**
|
|
13
|
+
* Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2
|
|
14
|
+
*/
|
|
15
|
+
export declare function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get entries newer than lastVersion
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[];
|
|
20
|
+
export { getChangelogPath } from "../config.ts";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var m=Object.defineProperty;var a=(r,n)=>m(r,"name",{value:n,configurable:!0});import{existsSync as u,readFileSync as p}from"fs";function g(r){if(!u(r))return[];try{const o=p(r,"utf-8").split(`
|
|
2
|
+
`),i=[];let t=[],e=null;for(const s of o)if(s.startsWith("## ")){e&&t.length>0&&i.push({...e,content:t.join(`
|
|
3
|
+
`).trim()});const c=s.match(/##\s+\[?(\d+)\.(\d+)\.(\d+)\]?/);c?(e={major:Number.parseInt(c[1],10),minor:Number.parseInt(c[2],10),patch:Number.parseInt(c[3],10)},t=[s]):(e=null,t=[])}else e&&t.push(s);return e&&t.length>0&&i.push({...e,content:t.join(`
|
|
4
|
+
`).trim()}),i}catch(n){return console.error(`Warning: Could not parse changelog: ${n}`),[]}}a(g,"parseChangelog");function l(r,n){return r.major!==n.major?r.major-n.major:r.minor!==n.minor?r.minor-n.minor:r.patch-n.patch}a(l,"compareVersions");function j(r,n){const o=n.split(".").map(Number),i={major:o[0]||0,minor:o[1]||0,patch:o[2]||0,content:""};return r.filter(t=>l(t,i)>0)}a(j,"getNewEntries");import{getChangelogPath as N}from"../config.js";export{l as compareVersions,N as getChangelogPath,j as getNewEntries,g as parseChangelog};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ChildProcess, type ChildProcessByStdio, type SpawnOptions, type SpawnOptionsWithStdioTuple, type SpawnSyncOptionsWithStringEncoding, type SpawnSyncReturns, type StdioNull, type StdioPipe } from "node:child_process";
|
|
2
|
+
import type { Readable } from "node:stream";
|
|
3
|
+
export declare function spawnProcess(command: string, args: string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
|
|
4
|
+
export declare function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;
|
|
5
|
+
export declare function spawnProcessSync(command: string, args: string[], options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Wait for a child process to terminate without hanging on inherited stdio handles.
|
|
8
|
+
*
|
|
9
|
+
* On Windows, daemonized descendants can inherit the child's stdout/stderr pipe
|
|
10
|
+
* handles. In that case the child emits `exit`, but `close` can hang forever even
|
|
11
|
+
* though the original process is already gone. We wait briefly for stdio to end,
|
|
12
|
+
* then forcibly stop tracking the inherited handles.
|
|
13
|
+
*/
|
|
14
|
+
export declare function waitForChildProcess(child: ChildProcess): Promise<number | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=Object.defineProperty;var t=(e,r)=>v(e,"name",{value:r,configurable:!0});import{spawn as L,spawnSync as T}from"node:child_process";import y from"cross-spawn";const C=100;function A(e,r,o){return process.platform==="win32"?y(e,r,o):L(e,r,o)}t(A,"spawnProcess");function F(e,r,o){return process.platform==="win32"?y.sync(e,r,o):T(e,r,o)}t(F,"spawnProcessSync");function I(e){return new Promise((r,o)=>{let s=!1,d=!1,p=null,u,a=e.stdout===null,c=e.stderr===null;const l=t(()=>{u&&(clearTimeout(u),u=void 0),e.removeListener("error",x),e.removeListener("exit",E),e.removeListener("close",S),e.stdout?.removeListener("end",m),e.stderr?.removeListener("end",w)},"cleanup"),i=t(n=>{s||(s=!0,l(),e.stdout?.destroy(),e.stderr?.destroy(),r(n))},"finalize"),f=t(()=>{!d||s||a&&c&&i(p)},"maybeFinalizeAfterExit"),m=t(()=>{a=!0,f()},"onStdoutEnd"),w=t(()=>{c=!0,f()},"onStderrEnd"),x=t(n=>{s||(s=!0,l(),o(n))},"onError"),E=t(n=>{d=!0,p=n,f(),s||(u=setTimeout(()=>i(n),C))},"onExit"),S=t(n=>{i(n)},"onClose");e.stdout?.once("end",m),e.stderr?.once("end",w),e.once("error",x),e.once("exit",E),e.once("close",S)})}t(I,"waitForChildProcess");export{A as spawnProcess,F as spawnProcessSync,I as waitForChildProcess};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ClipboardImage = {
|
|
2
|
+
bytes: Uint8Array;
|
|
3
|
+
mimeType: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function isWaylandSession(env?: NodeJS.ProcessEnv): boolean;
|
|
6
|
+
export declare function extensionForImageMimeType(mimeType: string): string | null;
|
|
7
|
+
export declare function readClipboardImage(options?: {
|
|
8
|
+
env?: NodeJS.ProcessEnv;
|
|
9
|
+
platform?: NodeJS.Platform;
|
|
10
|
+
}): Promise<ClipboardImage | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=Object.defineProperty;var s=(t,n)=>w(t,"name",{value:n,configurable:!0});import{spawnSync as T}from"child_process";import{randomUUID as S}from"crypto";import{readFileSync as p,unlinkSync as b}from"fs";import{tmpdir as I}from"os";import{join as h}from"path";import{clipboard as m}from"./clipboard-native.js";import{loadPhoton as _}from"./photon.js";const l=["image/png","image/jpeg","image/webp","image/gif"],f=1e3,E=3e3,M=5e3,A=50*1024*1024;function B(t=process.env){return!!t.WAYLAND_DISPLAY||t.XDG_SESSION_TYPE==="wayland"}s(B,"isWaylandSession");function u(t){return t.split(";")[0]?.trim().toLowerCase()??t.toLowerCase()}s(u,"baseMimeType");function V(t){switch(u(t)){case"image/png":return"png";case"image/jpeg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";default:return null}}s(V,"extensionForImageMimeType");function g(t){const n=t.map(e=>e.trim()).filter(Boolean).map(e=>({raw:e,base:u(e)}));for(const e of l){const o=n.find(i=>i.base===e);if(o)return o.raw}return n.find(e=>e.base.startsWith("image/"))?.raw??null}s(g,"selectPreferredImageMimeType");function P(t){const n=u(t);return l.some(r=>r===n)}s(P,"isSupportedImageMimeType");async function U(t){const n=await _();if(!n)return null;try{const r=n.PhotonImage.new_from_byteslice(t);try{return r.get_bytes()}finally{r.free()}}catch{return null}}s(U,"convertToPng");function a(t,n,r){const e=r?.timeoutMs??E,o=r?.maxBufferBytes??A,i=T(t,n,{timeout:e,maxBuffer:o,env:r?.env});return i.error?{ok:!1,stdout:Buffer.alloc(0)}:i.status!==0?{ok:!1,stdout:Buffer.alloc(0)}:{ok:!0,stdout:Buffer.isBuffer(i.stdout)?i.stdout:Buffer.from(i.stdout??"",typeof i.stdout=="string"?"utf-8":void 0)}}s(a,"runCommand");function D(){const t=a("wl-paste",["--list-types"],{timeoutMs:f});if(!t.ok)return null;const n=t.stdout.toString("utf-8").split(/\r?\n/).map(o=>o.trim()).filter(Boolean),r=g(n);if(!r)return null;const e=a("wl-paste",["--type",r,"--no-newline"]);return!e.ok||e.stdout.length===0?null:{bytes:e.stdout,mimeType:u(r)}}s(D,"readClipboardImageViaWlPaste");function L(t=process.env){if(t.WSL_DISTRO_NAME||t.WSLENV)return!0;try{const n=p("/proc/version","utf-8");return/microsoft|wsl/i.test(n)}catch{return!1}}s(L,"isWSL");function W(){const t=h(I(),`pi-wsl-clip-${S()}.png`);try{const n=a("wslpath",["-w",t],{timeoutMs:f});if(!n.ok)return null;const r=n.stdout.toString("utf-8").trim();if(!r)return null;const o=["Add-Type -AssemblyName System.Windows.Forms","Add-Type -AssemblyName System.Drawing",`$path = '${r.replaceAll("'","''")}'`,"$img = [System.Windows.Forms.Clipboard]::GetImage()","if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }"].join("; "),i=a("powershell.exe",["-NoProfile","-Command",o],{timeoutMs:M});if(!i.ok||i.stdout.toString("utf-8").trim()!=="ok")return null;const c=p(t);return c.length===0?null:{bytes:new Uint8Array(c),mimeType:"image/png"}}catch{return null}finally{try{b(t)}catch{}}}s(W,"readClipboardImageViaPowerShell");function k(){const t=a("xclip",["-selection","clipboard","-t","TARGETS","-o"],{timeoutMs:f});let n=[];t.ok&&(n=t.stdout.toString("utf-8").split(/\r?\n/).map(o=>o.trim()).filter(Boolean));const r=n.length>0?g(n):null,e=r?[r,...l]:[...l];for(const o of e){const i=a("xclip",["-selection","clipboard","-t",o,"-o"]);if(i.ok&&i.stdout.length>0)return{bytes:i.stdout,mimeType:u(o)}}return null}s(k,"readClipboardImageViaXclip");async function d(){if(!m||!m.hasImage())return null;const t=await m.getImageBinary();return!t||t.length===0?null:{bytes:t instanceof Uint8Array?t:Uint8Array.from(t),mimeType:"image/png"}}s(d,"readClipboardImageViaNativeClipboard");async function j(t){const n=t?.env??process.env,r=t?.platform??process.platform;if(n.TERMUX_VERSION)return null;let e=null;if(r==="linux"){const o=L(n),i=B(n);(i||o)&&(e=D()??k()),!e&&o&&(e=W()),!e&&!i&&(e=await d())}else e=await d();if(!e)return null;if(!P(e.mimeType)){const o=await U(e.bytes);return o?{bytes:o,mimeType:"image/png"}:null}return e}s(j,"readClipboardImage");export{V as extensionForImageMimeType,B as isWaylandSession,j as readClipboardImage};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ClipboardModule = {
|
|
2
|
+
setText: (text: string) => Promise<void>;
|
|
3
|
+
hasImage: () => boolean;
|
|
4
|
+
getImageBinary: () => Promise<Array<number>>;
|
|
5
|
+
};
|
|
6
|
+
type ClipboardRequire = (id: string) => unknown;
|
|
7
|
+
export declare function loadClipboardNative(requires?: readonly ClipboardRequire[]): ClipboardModule | null;
|
|
8
|
+
declare const clipboard: ClipboardModule | null;
|
|
9
|
+
export { clipboard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var o=(e,r)=>i(e,"name",{value:r,configurable:!0});import{createRequire as t}from"module";import{dirname as a,join as c}from"path";import{pathToFileURL as n}from"url";const p=t(import.meta.url),s=t(n(c(a(process.execPath),"package.json")).href),l=process.platform!=="linux"||!!(process.env.DISPLAY||process.env.WAYLAND_DISPLAY);function u(e=[p,s]){for(const r of e)try{return r("@mariozechner/clipboard")}catch{}return null}o(u,"loadClipboardNative");const m=!process.env.TERMUX_VERSION&&l?u():null;export{m as clipboard,u as loadClipboardNative};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyToClipboard(text: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var r=(e,o)=>d(e,"name",{value:o,configurable:!0});import{execSync as i,spawn as u}from"child_process";import{platform as y}from"os";import{isWaylandSession as m}from"./clipboard-image.js";import{clipboard as l}from"./clipboard-native.js";function f(e){try{i("xclip -selection clipboard",e)}catch{i("xsel --clipboard --input",e)}}r(f,"copyToX11Clipboard");const S=1e5;function h(e=process.env){return!!(e.SSH_CONNECTION||e.SSH_CLIENT||e.MOSH_CONNECTION)}r(h,"isRemoteSession");function w(e){const o=Buffer.from(e).toString("base64");return o.length>S?!1:(process.stdout.write(`\x1B]52;c;${o}\x07`),!0)}r(w,"emitOsc52");async function T(e){let o=!1;const c=y();try{l&&c!=="linux"&&(await l.setText(e),o=!0)}catch{}const p=h();if(o&&!p)return;const t={input:e,timeout:5e3,stdio:["pipe","ignore","ignore"]};if(!o)try{if(c==="darwin")i("pbcopy",t),o=!0;else if(c==="win32")i("clip",t),o=!0;else{if(process.env.TERMUX_VERSION)try{i("termux-clipboard-set",t),o=!0}catch{}if(!o){const s=!!process.env.WAYLAND_DISPLAY,a=!!process.env.DISPLAY;if(m()&&s)try{i("which wl-copy",{stdio:"ignore"});const n=u("wl-copy",[],{stdio:["pipe","ignore","ignore"]});n.stdin.on("error",()=>{}),n.stdin.write(e),n.stdin.end(),n.unref(),o=!0}catch{a&&(f(t),o=!0)}else a&&(f(t),o=!0)}}}catch{}if(p||!o){const s=w(e);o=o||s}if(!o)throw new Error("Failed to copy to clipboard")}r(T,"copyToClipboard");export{T as copyToClipboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var r=(n,o)=>t(n,"name",{value:o,configurable:!0});import a from"chalk";const e=new Set;function p(n){e.has(n)||(e.add(n),console.warn(a.yellow(`Deprecation warning: ${n}`)))}r(p,"warnDeprecation");function l(){e.clear()}r(l,"clearDeprecationWarningsForTests");export{l as clearDeprecationWarningsForTests,p as warnDeprecation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var O=Object.defineProperty;var x=(n,r)=>O(n,"name",{value:r,configurable:!0});function g(n,r){if(r+8>n.length)return 1;const i=(n[r]<<8|n[r+1])===18761,t=x(f=>i?n[f]|n[f+1]<<8:n[f]<<8|n[f+1],"read16"),e=x(f=>i?n[f]|n[f+1]<<8|n[f+2]<<16|n[f+3]<<24:(n[f]<<24|n[f+1]<<16|n[f+2]<<8|n[f+3])>>>0,"read32")(r+4),c=r+e;if(c+2>n.length)return 1;const l=t(c);for(let f=0;f<l;f++){const o=c+2+f*12;if(o+12>n.length)return 1;if(t(o)===274){const a=t(o+8);return a>=1&&a<=8?a:1}}return 1}x(g,"readOrientationFromTiff");function _(n){let r=2;for(;r<n.length-1;){if(n[r]!==255)return-1;const d=n[r+1];if(d===255){r++;continue}if(d===225){if(r+4>=n.length)return-1;const t=r+4;return t+6>n.length||!w(n,t)?-1:t+6}if(r+4>n.length)return-1;const i=n[r+2]<<8|n[r+3];r+=2+i}return-1}x(_,"findJpegTiffOffset");function I(n){let r=12;for(;r+8<=n.length;){const d=String.fromCharCode(n[r],n[r+1],n[r+2],n[r+3]),i=n[r+4]|n[r+5]<<8|n[r+6]<<16|n[r+7]<<24,t=r+8;if(d==="EXIF")return t+i>n.length?-1:i>=6&&w(n,t)?t+6:t;r=t+i+i%2}return-1}x(I,"findWebpTiffOffset");function w(n,r){return n[r]===69&&n[r+1]===120&&n[r+2]===105&&n[r+3]===102&&n[r+4]===0&&n[r+5]===0}x(w,"hasExifHeader");function E(n){let r=-1;return n.length>=2&&n[0]===255&&n[1]===216?r=_(n):n.length>=12&&n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80&&(r=I(n)),r===-1?1:g(n,r)}x(E,"getExifOrientation");function h(n,r,d){const i=r.get_width(),t=r.get_height(),u=r.get_raw_pixels(),e=new Uint8Array(u.length);for(let c=0;c<t;c++)for(let l=0;l<i;l++){const f=(c*i+l)*4,o=d(l,c,i,t)*4;e[o]=u[f],e[o+1]=u[f+1],e[o+2]=u[f+2],e[o+3]=u[f+3]}return new n.PhotonImage(e,t,i)}x(h,"rotate90");function v(n,r,d){const i=E(d);if(i===1)return r;switch(i){case 2:return n.fliph(r),r;case 3:return n.fliph(r),n.flipv(r),r;case 4:return n.flipv(r),r;case 5:{const t=h(n,r,(u,e,c,l)=>u*l+(l-1-e));return n.fliph(t),t}case 6:return h(n,r,(t,u,e,c)=>t*c+(c-1-u));case 7:{const t=h(n,r,(u,e,c,l)=>(c-1-u)*l+e);return n.fliph(t),t}case 8:return h(n,r,(t,u,e,c)=>(e-1-t)*c+u);default:return r}}x(v,"applyExifOrientation");export{v as applyExifOrientation};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var o=Object.defineProperty;var e=(t,r)=>o(t,"name",{value:r,configurable:!0});import{parse as a}from"yaml";const s=e(t=>t.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`),"normalizeNewlines"),i=e(t=>{const r=s(t);if(!r.startsWith("---"))return{yamlString:null,body:r};const n=r.indexOf(`
|
|
4
|
+
---`,3);return n===-1?{yamlString:null,body:r}:{yamlString:r.slice(4,n),body:r.slice(n+4).trim()}},"extractFrontmatter"),l=e(t=>{const{yamlString:r,body:n}=i(t);return r?{frontmatter:a(r)??{},body:n}:{frontmatter:{},body:n}},"parseFrontmatter"),p=e(t=>l(t).body,"stripFrontmatter");export{l as parseFrontmatter,p as stripFrontmatter};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type FSWatcher, type WatchListener } from "node:fs";
|
|
2
|
+
export declare const FS_WATCH_RETRY_DELAY_MS = 5000;
|
|
3
|
+
export declare function closeWatcher(watcher: FSWatcher | null | undefined): void;
|
|
4
|
+
export declare function watchWithErrorHandler(path: string, listener: WatchListener<string>, onError: () => void): FSWatcher | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var c=(t,r)=>n(t,"name",{value:r,configurable:!0});import{watch as a}from"node:fs";const i=5e3;function l(t){if(t)try{t.close()}catch{}}c(l,"closeWatcher");function f(t,r,o){try{const e=a(t,r);return e.on("error",o),e}catch{return o(),null}}c(f,"watchWithErrorHandler");export{i as FS_WATCH_RETRY_DELAY_MS,l as closeWatcher,f as watchWithErrorHandler};
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var $=Object.defineProperty;var l=(s,r)=>$(s,"name",{value:r,configurable:!0});import u from"hosted-git-info";function m(s){const r=s.match(/^git@([^:]+):(.+)$/);if(r){const e=r[2]??"",a=e.indexOf("@");if(a<0)return{repo:s};const f=e.slice(0,a),h=e.slice(a+1);return!f||!h?{repo:s}:{repo:`git@${r[1]??""}:${f}`,ref:h}}if(s.includes("://"))try{const e=new URL(s),a=e.pathname.replace(/^\/+/,""),f=a.indexOf("@");if(f<0)return{repo:s};const h=a.slice(0,f),d=a.slice(f+1);return!h||!d?{repo:s}:(e.pathname=`/${h}`,{repo:e.toString().replace(/\/$/,""),ref:d})}catch{return{repo:s}}const p=s.indexOf("/");if(p<0)return{repo:s};const n=s.slice(0,p),t=s.slice(p+1),o=t.indexOf("@");if(o<0)return{repo:s};const c=t.slice(0,o),i=t.slice(o+1);return!c||!i?{repo:s}:{repo:`${n}/${c}`,ref:i}}l(m,"splitRef");function g(s){const{repo:r,ref:p}=m(s);let n=r,t="",o="";const c=r.match(/^git@([^:]+):(.+)$/);if(c)t=c[1]??"",o=c[2]??"";else if(r.startsWith("https://")||r.startsWith("http://")||r.startsWith("ssh://")||r.startsWith("git://"))try{const e=new URL(r);t=e.hostname,o=e.pathname.replace(/^\/+/,"")}catch{return null}else{const e=r.indexOf("/");if(e<0||(t=r.slice(0,e),o=r.slice(e+1),!t.includes(".")&&t!=="localhost"))return null;n=`https://${r}`}const i=o.replace(/\.git$/,"").replace(/^\/+/,"");return!t||!i||i.split("/").length<2?null:{type:"git",repo:n,host:t,path:i,ref:p,pinned:!!p}}l(g,"parseGenericGitUrl");function y(s){const r=s.trim(),p=r.startsWith("git:"),n=p?r.slice(4).trim():r;if(!p&&!/^(https?|ssh|git):\/\//i.test(n))return null;const t=m(n),o=[t.ref?`${t.repo}#${t.ref}`:void 0,n].filter(i=>!!i);for(const i of o){const e=u.fromUrl(i);if(e){if(t.ref&&e.project?.includes("@"))continue;return{type:"git",repo:!t.repo.startsWith("http://")&&!t.repo.startsWith("https://")&&!t.repo.startsWith("ssh://")&&!t.repo.startsWith("git://")&&!t.repo.startsWith("git@")?`https://${t.repo}`:t.repo,host:e.domain||"",path:`${e.user}/${e.project}`.replace(/\.git$/,""),ref:e.committish||t.ref||void 0,pinned:!!(e.committish||t.ref)}}}const c=[t.ref?`https://${t.repo}#${t.ref}`:void 0,`https://${n}`].filter(i=>!!i);for(const i of c){const e=u.fromUrl(i);if(e){if(t.ref&&e.project?.includes("@"))continue;return{type:"git",repo:`https://${t.repo}`,host:e.domain||"",path:`${e.user}/${e.project}`.replace(/\.git$/,""),ref:e.committish||t.ref||void 0,pinned:!!(e.committish||t.ref)}}}return g(n)}l(y,"parseGitUrl");export{y as parseGitUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var n=(e,r)=>i(e,"name",{value:r,configurable:!0});function s(e){if(!(!Number.isInteger(e)||e<0||e>1114111))return String.fromCodePoint(e)}n(s,"decodeCodePoint");function c(e){switch(e){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'"}if(e.startsWith("#x")||e.startsWith("#X"))return s(Number.parseInt(e.slice(2),16));if(e.startsWith("#"))return s(Number.parseInt(e.slice(1),10))}n(c,"decodeHtmlEntity");function o(e,r){const t=e.indexOf(";",r+1);if(t===-1||t-r>16)return;const f=e.slice(r+1,t),u=c(f);if(u!==void 0)return{text:u,length:t-r+1}}n(o,"decodeHtmlEntityAt");export{c as decodeHtmlEntity,o as decodeHtmlEntityAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var a=(t,n)=>m(t,"name",{value:n,configurable:!0});import{applyExifOrientation as c}from"./exif-orientation.js";import{loadPhoton as g}from"./photon.js";async function p(t,n){if(n==="image/png")return{data:t,mimeType:n};const r=await g();if(!r)return null;try{const f=new Uint8Array(Buffer.from(t,"base64")),e=r.PhotonImage.new_from_byteslice(f),o=c(r,e,f);o!==e&&e.free();try{const i=o.get_bytes();return{data:Buffer.from(i).toString("base64"),mimeType:"image/png"}}finally{o.free()}}catch{return null}}a(p,"convertToPng");export{p as convertToPng};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ImageResizeOptions {
|
|
2
|
+
maxWidth?: number;
|
|
3
|
+
maxHeight?: number;
|
|
4
|
+
maxBytes?: number;
|
|
5
|
+
jpegQuality?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ResizedImage {
|
|
8
|
+
data: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
originalWidth: number;
|
|
11
|
+
originalHeight: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
wasResized: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resize an image to fit within the specified max dimensions and encoded file size.
|
|
18
|
+
* Returns null if the image cannot be resized below maxBytes.
|
|
19
|
+
*
|
|
20
|
+
* Uses Photon (Rust/WASM) for image processing. If Photon is not available,
|
|
21
|
+
* returns null.
|
|
22
|
+
*
|
|
23
|
+
* Strategy for staying under maxBytes:
|
|
24
|
+
* 1. First resize to maxWidth/maxHeight
|
|
25
|
+
* 2. Try both PNG and JPEG formats, pick the smaller one
|
|
26
|
+
* 3. If still too large, try JPEG with decreasing quality
|
|
27
|
+
* 4. If still too large, progressively reduce dimensions until 1x1
|
|
28
|
+
*/
|
|
29
|
+
export declare function resizeImageInProcess(inputBytes: Uint8Array, mimeType: string, options?: ImageResizeOptions): Promise<ResizedImage | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var W=Object.defineProperty;var u=(e,o)=>W(e,"name",{value:o,configurable:!0});import{applyExifOrientation as M}from"./exif-orientation.js";import{loadPhoton as T}from"./photon.js";const B=4.5*1024*1024,E={maxWidth:2e3,maxHeight:2e3,maxBytes:B,jpegQuality:80};function w(e,o){const d=Buffer.from(e).toString("base64");return{data:d,encodedSize:Buffer.byteLength(d,"utf-8"),mimeType:o}}u(w,"encodeCandidate");async function A(e,o,d){const t={...E,...d},S=Math.ceil(e.byteLength/3)*4,f=await T();if(!f)return null;let i;try{let b=function(y,m,l){const r=f.resize(i,y,m,f.SamplingFilter.Lanczos3);try{const p=[w(r.get_bytes(),"image/png")];for(const H of l)p.push(w(r.get_bytes_jpeg(H),"image/jpeg"));return p}finally{r.free()}};u(b,"tryEncodings");const x=f.PhotonImage.new_from_byteslice(e);i=M(f,x,e),i!==x&&x.free();const g=i.get_width(),c=i.get_height(),_=o.split("/")[1]??"png";if(g<=t.maxWidth&&c<=t.maxHeight&&S<t.maxBytes)return{data:Buffer.from(e).toString("base64"),mimeType:o||`image/${_}`,originalWidth:g,originalHeight:c,width:g,height:c,wasResized:!1};let s=g,h=c;s>t.maxWidth&&(h=Math.round(h*t.maxWidth/s),s=t.maxWidth),h>t.maxHeight&&(s=Math.round(s*t.maxHeight/h),h=t.maxHeight);const z=Array.from(new Set([t.jpegQuality,85,70,55,40]));let a=s,n=h;for(;;){const y=b(a,n,z);for(const r of y)if(r.encodedSize<t.maxBytes)return{data:r.data,mimeType:r.mimeType,originalWidth:g,originalHeight:c,width:a,height:n,wasResized:!0};if(a===1&&n===1)break;const m=a===1?1:Math.max(1,Math.floor(a*.75)),l=n===1?1:Math.max(1,Math.floor(n*.75));if(m===a&&l===n)break;a=m,n=l}return null}catch{return null}finally{i&&i.free()}}u(A,"resizeImageInProcess");export{A as resizeImageInProcess};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var s=(r,e)=>n(r,"name",{value:e,configurable:!0});import{parentPort as i}from"node:worker_threads";import{resizeImageInProcess as p}from"./image-resize-core.js";function c(r){if(!r||typeof r!="object")return!1;const e=r;return e.inputBytes instanceof Uint8Array&&typeof e.mimeType=="string"}s(c,"isResizeImageWorkerRequest");const t=i;if(!t)throw new Error("image resize worker requires parentPort");t.once("message",r=>{(async()=>{try{if(!c(r))throw new Error("Invalid image resize worker request");const o={result:await p(r.inputBytes,r.mimeType,r.options)};t.postMessage(o)}catch(e){const o={error:e instanceof Error?e.message:String(e)};t.postMessage(o)}})()});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ImageResizeOptions, type ResizedImage } from "./image-resize-core.ts";
|
|
2
|
+
export type { ImageResizeOptions, ResizedImage } from "./image-resize-core.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Resize an image to fit within the specified max dimensions and encoded file size.
|
|
5
|
+
* Runs Photon in a worker thread so WASM decoding, resizing, and encoding do not
|
|
6
|
+
* block the TUI event loop. If the worker cannot be loaded (for example in some
|
|
7
|
+
* Bun compiled executable layouts), fall back to in-process resizing so image
|
|
8
|
+
* reads still work.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resizeImage(inputBytes: Uint8Array, mimeType: string, options?: ImageResizeOptions): Promise<ResizedImage | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Format a dimension note for resized images.
|
|
13
|
+
* This helps the model understand the coordinate mapping.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatDimensionNote(result: ResizedImage): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var i=(r,t)=>m(r,"name",{value:t,configurable:!0});import{Worker as g}from"node:worker_threads";import{resizeImageInProcess as p}from"./image-resize-core.js";function h(r){return new Uint8Array(r)}i(h,"toTransferableBytes");function k(r){return r!==null&&typeof r=="object"}i(k,"isResizeImageWorkerResponse");function y(r){return new g(r)}i(y,"createResizeWorker");async function u(r,t,o,c){const n=y(r);try{const f=h(t);return await new Promise((w,l)=>{let a=!1;const d=i(e=>{a||(a=!0,w(e))},"settle"),s=i(e=>{a||(a=!0,l(e))},"fail");n.once("message",e=>{if(!k(e)){s(new Error("Invalid image resize worker response"));return}if(e.error){s(new Error(e.error));return}d(e.result??null)}),n.once("error",s),n.once("exit",e=>{a||s(new Error(`Image resize worker exited with code ${e}`))}),n.postMessage({inputBytes:f,mimeType:o,options:c},[f.buffer])})}finally{n.terminate().catch(()=>{})}}i(u,"resizeImageInWorker");async function x(r,t,o){const c=import.meta.url.endsWith(".ts"),n=new URL(c?"./image-resize-worker.ts":"./image-resize-worker.js",import.meta.url);if(typeof process.versions.bun=="string")try{return await u("./src/utils/image-resize-worker.ts",r,t,o)}catch{}try{return await u(n,r,t,o)}catch{return p(r,t,o)}}i(x,"resizeImage");function R(r){if(!r.wasResized)return;const t=r.originalWidth/r.width;return`[Image: original ${r.originalWidth}x${r.originalHeight}, displayed at ${r.width}x${r.height}. Multiply coordinates by ${t.toFixed(2)} to map to original image.]`}i(R,"formatDimensionNote");export{R as formatDimensionNote,x as resizeImage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var r=(n,e)=>o(n,"name",{value:e,configurable:!0});function s(n){return n.replace(/"(?:\\.|[^"\\])*"|\/\/[^\n]*/g,e=>e[0]==='"'?e:"").replace(/"(?:\\.|[^"\\])*"|,(\s*[}\]])/g,(e,t)=>t??(e[0]==='"'?e:""))}r(s,"stripJsonComments");export{s as stripJsonComments};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getKodaUserAgent(version: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var o=(s,e)=>r(s,"name",{value:e,configurable:!0});function c(s){const e=process.versions.bun?`bun/${process.versions.bun}`:`node/${process.version}`;return`koda/${s} (${process.platform}; ${e}; ${process.arch})`}o(c,"getKodaUserAgent");export{c as getKodaUserAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var r=(n,t)=>u(n,"name",{value:t,configurable:!0});import{open as h}from"node:fs/promises";const o=4100,c=[137,80,78,71,13,10,26,10];function x(n){return g(n,[255,216,255])?n[3]===247?null:"image/jpeg":g(n,c)?p(n)&&!d(n)?"image/png":null:a(n,0,"GIF")?"image/gif":a(n,0,"RIFF")&&a(n,8,"WEBP")?"image/webp":null}r(x,"detectSupportedImageMimeType");async function y(n){const t=await h(n,"r");try{const i=Buffer.alloc(o),{bytesRead:e}=await t.read(i,0,o,0);return x(i.subarray(0,e))}finally{await t.close()}}r(y,"detectSupportedImageMimeTypeFromFile");function p(n){return n.length>=16&&s(n,c.length)===13&&a(n,12,"IHDR")}r(p,"isPng");function d(n){let t=c.length;for(;t+8<=n.length;){const i=s(n,t),e=t+4;if(a(n,e,"acTL"))return!0;if(a(n,e,"IDAT"))return!1;const l=t+8+i+4;if(l<=t||l>n.length)return!1;t=l}return!1}r(d,"isAnimatedPng");function s(n,t){return(n[t]??0)*16777216+((n[t+1]??0)<<16)+((n[t+2]??0)<<8)+(n[t+3]??0)}r(s,"readUint32BE");function g(n,t){return n.length<t.length?!1:t.every((i,e)=>n[e]===i)}r(g,"startsWith");function a(n,t,i){if(n.length<t+i.length)return!1;for(let e=0;e<i.length;e++)if(n[t+e]!==i.charCodeAt(e))return!1;return!0}r(a,"startsWithAscii");export{x as detectSupportedImageMimeType,y as detectSupportedImageMimeTypeFromFile};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface PathInputOptions {
|
|
2
|
+
/** Trim leading/trailing whitespace before normalization. */
|
|
3
|
+
trim?: boolean;
|
|
4
|
+
/** Expand leading `~` to a home directory. Defaults to true. */
|
|
5
|
+
expandTilde?: boolean;
|
|
6
|
+
/** Home directory used for `~` expansion. Defaults to `os.homedir()`. */
|
|
7
|
+
homeDir?: string;
|
|
8
|
+
/** Strip a leading `@`, used for CLI @file paths. */
|
|
9
|
+
stripAtPrefix?: boolean;
|
|
10
|
+
/** Normalize unicode space variants to regular spaces. */
|
|
11
|
+
normalizeUnicodeSpaces?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a path to its canonical (real) form, following symlinks.
|
|
15
|
+
* Falls back to the raw path if resolution fails (e.g. the target does
|
|
16
|
+
* not exist yet), so that callers never crash on missing filesystem
|
|
17
|
+
* entries.
|
|
18
|
+
*/
|
|
19
|
+
export declare function canonicalizePath(path: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if the value is NOT a package source (npm:, git:, etc.)
|
|
22
|
+
* or a remote URL protocol. Bare names, relative paths, and file: URLs
|
|
23
|
+
* are considered local.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isLocalPath(value: string): boolean;
|
|
26
|
+
export declare function normalizePath(input: string, options?: PathInputOptions): string;
|
|
27
|
+
export declare function resolvePath(input: string, baseDir?: string, options?: PathInputOptions): string;
|
|
28
|
+
export declare function getCwdRelativePath(filePath: string, cwd: string): string | undefined;
|
|
29
|
+
export declare function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string;
|
|
30
|
+
export declare function markPathIgnoredByCloudSync(path: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var i=(e,t)=>d(e,"name",{value:t,configurable:!0});import{realpathSync as m}from"node:fs";import{homedir as p}from"node:os";import{isAbsolute as a,join as h,resolve as c,relative as P,sep as l}from"node:path";import{fileURLToPath as x}from"node:url";import{spawnProcessSync as f}from"./child-process.js";const g=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;function y(e){try{return m(e)}catch{return e}}i(y,"canonicalizePath");function I(e){const t=e.trim();return!(t.startsWith("npm:")||t.startsWith("git:")||t.startsWith("github:")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("ssh:"))}i(I,"isLocalPath");function u(e,t={}){let r=t.trim?e.trim():e;if(t.normalizeUnicodeSpaces&&(r=r.replace(g," ")),t.stripAtPrefix&&r.startsWith("@")&&(r=r.slice(1)),t.expandTilde??!0){const o=t.homeDir??p();if(r==="~")return o;if(r.startsWith("~/")||process.platform==="win32"&&r.startsWith("~\\"))return h(o,r.slice(2))}return/^file:\/\//.test(r)?x(r):r}i(u,"normalizePath");function n(e,t=process.cwd(),r={}){const o=u(e,r),s=u(t);return a(o)?c(o):c(s,o)}i(n,"resolvePath");function v(e,t){const r=n(t),o=n(e,r),s=P(r,o);return s===""||s!==".."&&!s.startsWith(`..${l}`)&&!a(s)?s||".":void 0}i(v,"getCwdRelativePath");function R(e,t){const r=n(e,t);return(v(r,t)??r).split(l).join("/")}i(R,"formatPathRelativeToCwdOrAbsolute");function D(e){const t=process.platform==="darwin"?["com.dropbox.ignored","com.apple.fileprovider.ignore#P"]:process.platform==="linux"?["user.com.dropbox.ignored"]:[];for(const r of t)process.platform==="darwin"?f("xattr",["-w",r,"1",e],{encoding:"utf-8",stdio:"ignore"}):f("setfattr",["-n",r,"-v","1",e],{encoding:"utf-8",stdio:"ignore"})}i(D,"markPathIgnoredByCloudSync");export{y as canonicalizePath,R as formatPathRelativeToCwdOrAbsolute,v as getCwdRelativePath,I as isLocalPath,D as markPathIgnoredByCloudSync,u as normalizePath,n as resolvePath};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Photon image processing wrapper.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a unified interface to @silvia-odwyer/photon-node that works in:
|
|
5
|
+
* 1. Node.js (development, npm run build)
|
|
6
|
+
* 2. Bun compiled binaries (standalone distribution)
|
|
7
|
+
*
|
|
8
|
+
* The challenge: photon-node's CJS entry uses fs.readFileSync(__dirname + '/photon_rs_bg.wasm')
|
|
9
|
+
* which bakes the build machine's absolute path into Bun compiled binaries.
|
|
10
|
+
*
|
|
11
|
+
* Solution:
|
|
12
|
+
* 1. Patch fs.readFileSync to redirect missing photon_rs_bg.wasm reads
|
|
13
|
+
* 2. Copy photon_rs_bg.wasm next to the executable in build:binary
|
|
14
|
+
*/
|
|
15
|
+
export type { PhotonImage as PhotonImageType } from "@silvia-odwyer/photon-node";
|
|
16
|
+
/**
|
|
17
|
+
* Load the photon module asynchronously.
|
|
18
|
+
* Returns cached module on subsequent calls.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadPhoton(): Promise<typeof import("@silvia-odwyer/photon-node") | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var e=(t,i)=>m(t,"name",{value:i,configurable:!0});import{createRequire as b}from"module";import*as o from"path";import{fileURLToPath as P}from"url";const F=b(import.meta.url),r=F("fs"),c="photon_rs_bg.wasm";let n=null,a=null;function S(t){return typeof t=="string"?t:t instanceof URL?P(t):null}e(S,"pathOrNull");function w(){const t=o.dirname(process.execPath);return[o.join(t,c),o.join(t,"photon",c),o.join(process.cwd(),c)]}e(w,"getFallbackWasmPaths");function R(){const t=r.readFileSync.bind(r),i=w(),f=r,d=e(((...l)=>{const[y,h]=l;if(S(y)?.endsWith(c))try{return t(...l)}catch(u){const p=u;if(p?.code&&p.code!=="ENOENT")throw u;for(const s of i)if(r.existsSync(s))return h===void 0?t(s):t(s,h);throw u}return t(...l)}),"patchedReadFileSync");try{f.readFileSync=d}catch{Object.defineProperty(r,"readFileSync",{value:d,writable:!0,configurable:!0})}return()=>{try{f.readFileSync=t}catch{Object.defineProperty(r,"readFileSync",{value:t,writable:!0,configurable:!0})}}}e(R,"patchPhotonWasmRead");async function E(){return n||a||(a=(async()=>{const t=R();try{return n=await import("@silvia-odwyer/photon-node"),n}catch{return n=null,n}finally{t()}})(),a)}e(E,"loadPhoton");export{E as loadPhoton};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ShellConfig {
|
|
2
|
+
shell: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Resolve shell configuration based on platform and an optional explicit shell path.
|
|
7
|
+
* Resolution order:
|
|
8
|
+
* 1. User-specified shellPath
|
|
9
|
+
* 2. On Windows: Git Bash in known locations, then bash on PATH
|
|
10
|
+
* 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh
|
|
11
|
+
*/
|
|
12
|
+
export declare function getShellConfig(customShellPath?: string): ShellConfig;
|
|
13
|
+
export declare function getShellEnv(): NodeJS.ProcessEnv;
|
|
14
|
+
/**
|
|
15
|
+
* Sanitize binary output for display/storage.
|
|
16
|
+
* Removes characters that crash string-width or cause display issues:
|
|
17
|
+
* - Control characters (except tab, newline, carriage return)
|
|
18
|
+
* - Lone surrogates
|
|
19
|
+
* - Unicode Format characters (crash string-width due to a bug)
|
|
20
|
+
* - Characters with undefined code points
|
|
21
|
+
*/
|
|
22
|
+
export declare function sanitizeBinaryOutput(str: string): string;
|
|
23
|
+
export declare function trackDetachedChildPid(pid: number): void;
|
|
24
|
+
export declare function untrackDetachedChildPid(pid: number): void;
|
|
25
|
+
export declare function killTrackedDetachedChildren(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Kill a process and all its children (cross-platform)
|
|
28
|
+
*/
|
|
29
|
+
export declare function killProcessTree(pid: number): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var d=Object.defineProperty;var n=(t,r)=>d(t,"name",{value:r,configurable:!0});import{existsSync as o}from"node:fs";import{delimiter as l}from"node:path";import{spawn as p,spawnSync as h}from"child_process";import{getBinDir as m}from"../config.js";function u(){if(process.platform==="win32"){try{const t=h("where",["bash.exe"],{encoding:"utf-8",timeout:5e3,windowsHide:!0});if(t.status===0&&t.stdout){const r=t.stdout.trim().split(/\r?\n/)[0];if(r&&o(r))return r}}catch{}return null}try{const t=h("which",["bash"],{encoding:"utf-8",timeout:5e3});if(t.status===0&&t.stdout){const r=t.stdout.trim().split(/\r?\n/)[0];if(r)return r}}catch{}return null}n(u,"findBashOnPath");function k(t){if(t){if(o(t))return{shell:t,args:["-c"]};throw new Error(`Custom shell path not found: ${t}`)}if(process.platform==="win32"){const e=[],a=process.env.ProgramFiles;a&&e.push(`${a}\\Git\\bin\\bash.exe`);const f=process.env["ProgramFiles(x86)"];f&&e.push(`${f}\\Git\\bin\\bash.exe`);for(const s of e)if(o(s))return{shell:s,args:["-c"]};const i=u();if(i)return{shell:i,args:["-c"]};throw new Error(`No bash shell found. Options:
|
|
2
|
+
1. Install Git for Windows: https://git-scm.com/download/win
|
|
3
|
+
2. Add your bash to PATH (Cygwin, MSYS2, etc.)
|
|
4
|
+
3. Set shellPath in settings.json
|
|
5
|
+
|
|
6
|
+
Searched Git Bash in:
|
|
7
|
+
${e.map(s=>` ${s}`).join(`
|
|
8
|
+
`)}`)}if(o("/bin/bash"))return{shell:"/bin/bash",args:["-c"]};const r=u();return r?{shell:r,args:["-c"]}:{shell:"sh",args:["-c"]}}n(k,"getShellConfig");function D(){const t=m(),r=Object.keys(process.env).find(s=>s.toLowerCase()==="path")??"PATH",e=process.env[r]??"",i=e.split(l).filter(Boolean).includes(t)?e:[t,e].filter(Boolean).join(l);return{...process.env,[r]:i}}n(D,"getShellEnv");function S(t){return Array.from(t).filter(r=>{const e=r.codePointAt(0);return e===void 0?!1:e===9||e===10||e===13?!0:!(e<=31||e>=65529&&e<=65531)}).join("")}n(S,"sanitizeBinaryOutput");const c=new Set;function B(t){c.add(t)}n(B,"trackDetachedChildPid");function C(t){c.delete(t)}n(C,"untrackDetachedChildPid");function v(){for(const t of c)g(t);c.clear()}n(v,"killTrackedDetachedChildren");function g(t){if(process.platform==="win32")try{p("taskkill",["/F","/T","/PID",String(t)],{stdio:"ignore",detached:!0,windowsHide:!0})}catch{}else try{process.kill(-t,"SIGKILL")}catch{try{process.kill(t,"SIGKILL")}catch{}}}n(g,"killProcessTree");export{k as getShellConfig,D as getShellEnv,g as killProcessTree,v as killTrackedDetachedChildren,S as sanitizeBinaryOutput,B as trackDetachedChildPid,C as untrackDetachedChildPid};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var o=(r,e)=>u(r,"name",{value:e,configurable:!0});function b(r,e){return new Promise((n,t)=>{if(e?.aborted){t(new Error("Aborted"));return}const i=setTimeout(n,r);e?.addEventListener("abort",()=>{clearTimeout(i),t(new Error("Aborted"))})})}o(b,"sleep");export{b as sleep};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type HighlightFormatter = (text: string) => string;
|
|
2
|
+
export type HighlightTheme = Partial<Record<string, HighlightFormatter>>;
|
|
3
|
+
export interface HighlightOptions {
|
|
4
|
+
language?: string;
|
|
5
|
+
ignoreIllegals?: boolean;
|
|
6
|
+
languageSubset?: string[];
|
|
7
|
+
theme?: HighlightTheme;
|
|
8
|
+
}
|
|
9
|
+
export declare function renderHighlightedHtml(html: string, theme?: HighlightTheme): string;
|
|
10
|
+
export declare function highlight(code: string, options?: HighlightOptions): string;
|
|
11
|
+
export declare function supportsLanguage(name: string): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h=Object.defineProperty;var a=(t,n)=>h(t,"name",{value:n,configurable:!0});import f from"highlight.js/lib/index.js";import{decodeHtmlEntityAt as x}from"./html.js";const c="</span>",g="hljs-";function p(t){const n=/\sclass\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(t),e=n?.[1]??n?.[2];if(e){for(const r of e.split(/\s+/))if(r.startsWith(g))return r.slice(g.length)}}a(p,"getScopeFromSpanTag");function S(t,n){const e=n[t];if(e)return e;const r=t.indexOf(".");if(r!==-1){const u=n[t.slice(0,r)];if(u)return u}const s=t.indexOf("-");if(s!==-1){const u=n[t.slice(0,s)];if(u)return u}}a(S,"getScopeFormatter");function I(t,n){for(let e=t.length-1;e>=0;e--){const r=t[e];if(!r)continue;const s=S(r,n);if(s)return s}return n.default}a(I,"getActiveFormatter");function m(t,n){if(!t.startsWith("<span",n))return!1;const e=t[n+5];return e===">"||e===" "||e===" "||e===`
|
|
2
|
+
`||e==="\r"}a(m,"isSpanOpenTagStart");function F(t,n={}){let e="",r="";const s=[],u=a(()=>{if(!r)return;const o=I(s,n);e+=o?o(r):r,r=""},"flushText");let i=0;for(;i<t.length;){if(m(t,i)){const o=t.indexOf(">",i+5);if(o!==-1){u();const l=t.slice(i,o+1),d=p(l);s.push(d),i=o+1;continue}}if(t.startsWith(c,i)){u(),s.length>0&&s.pop(),i+=c.length;continue}if(t[i]==="&"){const o=x(t,i);if(o){r+=o.text,i+=o.length;continue}}r+=t[i],i++}return u(),e}a(F,"renderHighlightedHtml");function O(t,n={}){const e=n.language?f.highlight(t,{language:n.language,ignoreIllegals:n.ignoreIllegals}).value:f.highlightAuto(t,n.languageSubset).value;return F(e,n.theme)}a(O,"highlight");function E(t){return f.getLanguage(t)!==void 0}a(E,"supportsLanguage");export{O as highlight,F as renderHighlightedHtml,E as supportsLanguage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=Object.defineProperty;var a=(e,r)=>v(e,"name",{value:r,configurable:!0});import u from"chalk";import{spawnSync as S}from"child_process";import{chmodSync as A,createWriteStream as F,existsSync as y,mkdirSync as N,readdirSync as z,renameSync as P,rmSync as E}from"fs";import{arch as T,platform as h}from"os";import{join as s}from"path";import{Readable as k}from"stream";import{pipeline as O}from"stream/promises";import{APP_NAME as B,getBinDir as C}from"../config.js";const d=C(),D=1e4,I=12e4;function L(){const e=process.env.KODA_OFFLINE;return e?e==="1"||e.toLowerCase()==="true"||e.toLowerCase()==="yes":!1}a(L,"isOfflineModeEnabled");const $={fd:{name:"fd",repo:"sharkdp/fd",binaryName:"fd",systemBinaryNames:["fd","fdfind"],tagPrefix:"v",getAssetName:a((e,r,n)=>r==="darwin"?`fd-v${e}-${n==="arm64"?"aarch64":"x86_64"}-apple-darwin.tar.gz`:r==="linux"?`fd-v${e}-${n==="arm64"?"aarch64":"x86_64"}-unknown-linux-gnu.tar.gz`:r==="win32"?`fd-v${e}-${n==="arm64"?"aarch64":"x86_64"}-pc-windows-msvc.zip`:null,"getAssetName")},rg:{name:"ripgrep",repo:"BurntSushi/ripgrep",binaryName:"rg",tagPrefix:"",getAssetName:a((e,r,n)=>r==="darwin"?`ripgrep-${e}-${n==="arm64"?"aarch64":"x86_64"}-apple-darwin.tar.gz`:r==="linux"?n==="arm64"?`ripgrep-${e}-aarch64-unknown-linux-gnu.tar.gz`:`ripgrep-${e}-x86_64-unknown-linux-musl.tar.gz`:r==="win32"?`ripgrep-${e}-${n==="arm64"?"aarch64":"x86_64"}-pc-windows-msvc.zip`:null,"getAssetName")}};function M(e){try{const r=S(e,["--version"],{stdio:"pipe"});return r.error===void 0||r.error===null}catch{return!1}}a(M,"commandExists");function R(e){const r=$[e];if(!r)return null;const n=s(d,r.binaryName+(h()==="win32"?".exe":""));if(y(n))return n;const t=r.systemBinaryNames??[r.binaryName];for(const o of t)if(M(o))return o;return null}a(R,"getToolPath");async function U(e){const r=await fetch(`https://api.github.com/repos/${e}/releases/latest`,{headers:{"User-Agent":`${B}-coding-agent`},signal:AbortSignal.timeout(D)});if(!r.ok)throw new Error(`GitHub API error: ${r.status}`);return(await r.json()).tag_name.replace(/^v/,"")}a(U,"getLatestVersion");async function W(e,r){const n=await fetch(e,{signal:AbortSignal.timeout(I)});if(!n.ok)throw new Error(`Failed to download: ${n.status}`);if(!n.body)throw new Error("No response body");const t=F(r);await O(k.fromWeb(n.body),t)}a(W,"downloadFile");function j(e,r){const n=[e];for(;n.length>0;){const t=n.pop();if(!t)continue;const o=z(t,{withFileTypes:!0});for(const i of o){const f=s(t,i.name);if(i.isFile()&&i.name===r)return f;i.isDirectory()&&n.push(f)}}return null}a(j,"findBinaryRecursively");function G(e){if(e.error?.message)return e.error.message;const r=e.stderr?.toString().trim();if(r)return r;const n=e.stdout?.toString().trim();return n||`exit status ${e.status??"unknown"}`}a(G,"formatSpawnFailure");function l(e,r){const n=S(e,r,{stdio:"pipe"});return!n.error&&n.status===0?null:`${e}: ${G(n)}`}a(l,"runExtractionCommand");function K(e,r,n){const t=l("tar",["xzf",e,"-C",r]);if(t)throw new Error(`Failed to extract ${n}: ${t}`)}a(K,"extractTarGzArchive");function q(){const e=process.env.SystemRoot??process.env.WINDIR;if(e){const r=s(e,"System32","tar.exe");if(y(r))return r}return"tar.exe"}a(q,"getWindowsTarCommand");function H(e,r,n){const t=[];if(h()==="win32"){const o=l(q(),["xf",e,"-C",r]);if(!o)return;t.push(o);const f=l("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command","& { param($archive, $destination) $ErrorActionPreference = 'Stop'; Expand-Archive -LiteralPath $archive -DestinationPath $destination -Force }",e,r]);if(!f)return;t.push(f)}else{const o=l("unzip",["-q",e,"-d",r]);if(!o)return;t.push(o);const i=l("tar",["xf",e,"-C",r]);if(!i)return;t.push(i)}throw new Error(`Failed to extract ${n}: ${t.join("; ")}`)}a(H,"extractZipArchive");async function V(e){const r=$[e];if(!r)throw new Error(`Unknown tool: ${e}`);const n=h(),t=T();let o=await U(r.repo);e==="fd"&&n==="darwin"&&t==="x64"&&(o="10.3.0");const i=r.getAssetName(o,n,t);if(!i)throw new Error(`Unsupported platform: ${n}/${t}`);N(d,{recursive:!0});const f=`https://github.com/${r.repo}/releases/download/${r.tagPrefix}${o}/${i}`,m=s(d,i),x=n==="win32"?".exe":"",g=s(d,r.binaryName+x);await W(f,m);const c=s(d,`extract_tmp_${r.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`);N(c,{recursive:!0});try{if(i.endsWith(".tar.gz"))K(m,c,i);else if(i.endsWith(".zip"))H(m,c,i);else throw new Error(`Unsupported archive format: ${i}`);const p=r.binaryName+x,b=s(c,i.replace(/\.(tar\.gz|zip)$/,""));let w=[s(b,p),s(c,p)].find(_=>y(_));if(w||(w=j(c,p)??void 0),w)P(w,g);else throw new Error(`Binary not found in archive: expected ${p} under ${c}`);n!=="win32"&&A(g,493)}finally{E(m,{force:!0}),E(c,{recursive:!0,force:!0})}return g}a(V,"downloadTool");const X={fd:"fd",rg:"ripgrep"};async function ar(e,r=!1){const n=R(e);if(n)return n;const t=$[e];if(t){if(L()){r||console.log(u.yellow(`${t.name} not found. Offline mode enabled, skipping download.`));return}if(h()==="android"){const o=X[e]??e;r||console.log(u.yellow(`${t.name} not found. Install with: pkg install ${o}`));return}r||console.log(u.dim(`${t.name} not found. Downloading...`));try{const o=await V(e);return r||console.log(u.dim(`${t.name} installed to ${o}`)),o}catch(o){r||console.log(u.yellow(`Failed to download ${t.name}: ${o instanceof Error?o.message:o}`));return}}}a(ar,"ensureTool");export{ar as ensureTool,R as getToolPath};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface LatestPiRelease {
|
|
2
|
+
version: string;
|
|
3
|
+
packageName?: string;
|
|
4
|
+
note?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function comparePackageVersions(leftVersion: string, rightVersion: string): number | undefined;
|
|
7
|
+
export declare function isNewerPackageVersion(candidateVersion: string, currentVersion: string): boolean;
|
|
8
|
+
export declare function getLatestPiRelease(currentVersion: string, options?: {
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
}): Promise<LatestPiRelease | undefined>;
|
|
11
|
+
export declare function getLatestPiVersion(currentVersion: string, options?: {
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
}): Promise<string | undefined>;
|
|
14
|
+
export declare function checkForNewPiVersion(currentVersion: string): Promise<LatestPiRelease | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var a=(r,e)=>u(r,"name",{value:e,configurable:!0});import{PACKAGE_NAME as o}from"../config.js";import{getKodaUserAgent as f}from"./koda-user-agent.js";const m=`https://registry.npmjs.org/${o.replace("/","%2f")}`,d=1e4;function c(r){const e=r.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/);if(e)return{major:Number.parseInt(e[1],10),minor:Number.parseInt(e[2],10),patch:Number.parseInt(e[3],10),prerelease:e[4]}}a(c,"parsePackageVersion");function l(r,e){const t=c(r),n=c(e);if(!(!t||!n))return t.major!==n.major?t.major-n.major:t.minor!==n.minor?t.minor-n.minor:t.patch!==n.patch?t.patch-n.patch:t.prerelease===n.prerelease?0:t.prerelease?n.prerelease?t.prerelease.localeCompare(n.prerelease):-1:1}a(l,"comparePackageVersions");function g(r,e){const t=l(r,e);return t!==void 0?t>0:r.trim()!==e.trim()}a(g,"isNewerPackageVersion");async function p(r,e={}){if(process.env.KODA_SKIP_VERSION_CHECK||process.env.KODA_OFFLINE)return;const t=await fetch(m,{headers:{"User-Agent":f(r),accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(e.timeoutMs??d)});if(!t.ok)return;const s=(await t.json())["dist-tags"]??{},i=r.includes("-")?s.beta||s.latest:s.latest||s.beta;if(!(typeof i!="string"||!i.trim()))return{version:i.trim(),packageName:o}}a(p,"getLatestPiRelease");async function _(r,e={}){return(await p(r,e))?.version}a(_,"getLatestPiVersion");async function v(r){try{const e=await p(r);return e&&g(e.version,r)?e:void 0}catch{return}}a(v,"checkForNewPiVersion");export{v as checkForNewPiVersion,l as comparePackageVersions,p as getLatestPiRelease,_ as getLatestPiVersion,g as isNewerPackageVersion};
|