@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,335 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Pi Coding Agent Theme",
|
|
4
|
+
"description": "Theme schema for Pi coding agent",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["name", "colors"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "JSON schema reference"
|
|
11
|
+
},
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Theme name"
|
|
15
|
+
},
|
|
16
|
+
"vars": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"description": "Reusable color variables",
|
|
19
|
+
"additionalProperties": {
|
|
20
|
+
"oneOf": [
|
|
21
|
+
{
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "integer",
|
|
27
|
+
"minimum": 0,
|
|
28
|
+
"maximum": 255,
|
|
29
|
+
"description": "256-color palette index (0-255)"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"colors": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "Theme color definitions (all required)",
|
|
37
|
+
"required": [
|
|
38
|
+
"accent",
|
|
39
|
+
"border",
|
|
40
|
+
"borderAccent",
|
|
41
|
+
"borderMuted",
|
|
42
|
+
"success",
|
|
43
|
+
"error",
|
|
44
|
+
"warning",
|
|
45
|
+
"muted",
|
|
46
|
+
"dim",
|
|
47
|
+
"text",
|
|
48
|
+
"thinkingText",
|
|
49
|
+
"selectedBg",
|
|
50
|
+
"userMessageBg",
|
|
51
|
+
"userMessageText",
|
|
52
|
+
"customMessageBg",
|
|
53
|
+
"customMessageText",
|
|
54
|
+
"customMessageLabel",
|
|
55
|
+
"toolPendingBg",
|
|
56
|
+
"toolSuccessBg",
|
|
57
|
+
"toolErrorBg",
|
|
58
|
+
"toolTitle",
|
|
59
|
+
"toolOutput",
|
|
60
|
+
"mdHeading",
|
|
61
|
+
"mdLink",
|
|
62
|
+
"mdLinkUrl",
|
|
63
|
+
"mdCode",
|
|
64
|
+
"mdCodeBlock",
|
|
65
|
+
"mdCodeBlockBorder",
|
|
66
|
+
"mdQuote",
|
|
67
|
+
"mdQuoteBorder",
|
|
68
|
+
"mdHr",
|
|
69
|
+
"mdListBullet",
|
|
70
|
+
"toolDiffAdded",
|
|
71
|
+
"toolDiffRemoved",
|
|
72
|
+
"toolDiffContext",
|
|
73
|
+
"syntaxComment",
|
|
74
|
+
"syntaxKeyword",
|
|
75
|
+
"syntaxFunction",
|
|
76
|
+
"syntaxVariable",
|
|
77
|
+
"syntaxString",
|
|
78
|
+
"syntaxNumber",
|
|
79
|
+
"syntaxType",
|
|
80
|
+
"syntaxOperator",
|
|
81
|
+
"syntaxPunctuation",
|
|
82
|
+
"thinkingOff",
|
|
83
|
+
"thinkingMinimal",
|
|
84
|
+
"thinkingLow",
|
|
85
|
+
"thinkingMedium",
|
|
86
|
+
"thinkingHigh",
|
|
87
|
+
"thinkingXhigh",
|
|
88
|
+
"bashMode"
|
|
89
|
+
],
|
|
90
|
+
"properties": {
|
|
91
|
+
"accent": {
|
|
92
|
+
"$ref": "#/$defs/colorValue",
|
|
93
|
+
"description": "Primary accent color (logo, selected items, cursor)"
|
|
94
|
+
},
|
|
95
|
+
"border": {
|
|
96
|
+
"$ref": "#/$defs/colorValue",
|
|
97
|
+
"description": "Normal borders"
|
|
98
|
+
},
|
|
99
|
+
"borderAccent": {
|
|
100
|
+
"$ref": "#/$defs/colorValue",
|
|
101
|
+
"description": "Highlighted borders"
|
|
102
|
+
},
|
|
103
|
+
"borderMuted": {
|
|
104
|
+
"$ref": "#/$defs/colorValue",
|
|
105
|
+
"description": "Subtle borders"
|
|
106
|
+
},
|
|
107
|
+
"success": {
|
|
108
|
+
"$ref": "#/$defs/colorValue",
|
|
109
|
+
"description": "Success states"
|
|
110
|
+
},
|
|
111
|
+
"error": {
|
|
112
|
+
"$ref": "#/$defs/colorValue",
|
|
113
|
+
"description": "Error states"
|
|
114
|
+
},
|
|
115
|
+
"warning": {
|
|
116
|
+
"$ref": "#/$defs/colorValue",
|
|
117
|
+
"description": "Warning states"
|
|
118
|
+
},
|
|
119
|
+
"muted": {
|
|
120
|
+
"$ref": "#/$defs/colorValue",
|
|
121
|
+
"description": "Secondary/dimmed text"
|
|
122
|
+
},
|
|
123
|
+
"dim": {
|
|
124
|
+
"$ref": "#/$defs/colorValue",
|
|
125
|
+
"description": "Very dimmed text (more subtle than muted)"
|
|
126
|
+
},
|
|
127
|
+
"text": {
|
|
128
|
+
"$ref": "#/$defs/colorValue",
|
|
129
|
+
"description": "Default text color (usually empty string)"
|
|
130
|
+
},
|
|
131
|
+
"thinkingText": {
|
|
132
|
+
"$ref": "#/$defs/colorValue",
|
|
133
|
+
"description": "Thinking block text color"
|
|
134
|
+
},
|
|
135
|
+
"selectedBg": {
|
|
136
|
+
"$ref": "#/$defs/colorValue",
|
|
137
|
+
"description": "Selected item background"
|
|
138
|
+
},
|
|
139
|
+
"userMessageBg": {
|
|
140
|
+
"$ref": "#/$defs/colorValue",
|
|
141
|
+
"description": "User message background"
|
|
142
|
+
},
|
|
143
|
+
"userMessageText": {
|
|
144
|
+
"$ref": "#/$defs/colorValue",
|
|
145
|
+
"description": "User message text color"
|
|
146
|
+
},
|
|
147
|
+
"customMessageBg": {
|
|
148
|
+
"$ref": "#/$defs/colorValue",
|
|
149
|
+
"description": "Custom message background (hook-injected messages)"
|
|
150
|
+
},
|
|
151
|
+
"customMessageText": {
|
|
152
|
+
"$ref": "#/$defs/colorValue",
|
|
153
|
+
"description": "Custom message text color"
|
|
154
|
+
},
|
|
155
|
+
"customMessageLabel": {
|
|
156
|
+
"$ref": "#/$defs/colorValue",
|
|
157
|
+
"description": "Custom message type label color"
|
|
158
|
+
},
|
|
159
|
+
"toolPendingBg": {
|
|
160
|
+
"$ref": "#/$defs/colorValue",
|
|
161
|
+
"description": "Tool execution box (pending state)"
|
|
162
|
+
},
|
|
163
|
+
"toolSuccessBg": {
|
|
164
|
+
"$ref": "#/$defs/colorValue",
|
|
165
|
+
"description": "Tool execution box (success state)"
|
|
166
|
+
},
|
|
167
|
+
"toolErrorBg": {
|
|
168
|
+
"$ref": "#/$defs/colorValue",
|
|
169
|
+
"description": "Tool execution box (error state)"
|
|
170
|
+
},
|
|
171
|
+
"toolTitle": {
|
|
172
|
+
"$ref": "#/$defs/colorValue",
|
|
173
|
+
"description": "Tool execution box title color"
|
|
174
|
+
},
|
|
175
|
+
"toolOutput": {
|
|
176
|
+
"$ref": "#/$defs/colorValue",
|
|
177
|
+
"description": "Tool execution box output text color"
|
|
178
|
+
},
|
|
179
|
+
"mdHeading": {
|
|
180
|
+
"$ref": "#/$defs/colorValue",
|
|
181
|
+
"description": "Markdown heading text"
|
|
182
|
+
},
|
|
183
|
+
"mdLink": {
|
|
184
|
+
"$ref": "#/$defs/colorValue",
|
|
185
|
+
"description": "Markdown link text"
|
|
186
|
+
},
|
|
187
|
+
"mdLinkUrl": {
|
|
188
|
+
"$ref": "#/$defs/colorValue",
|
|
189
|
+
"description": "Markdown link URL"
|
|
190
|
+
},
|
|
191
|
+
"mdCode": {
|
|
192
|
+
"$ref": "#/$defs/colorValue",
|
|
193
|
+
"description": "Markdown inline code"
|
|
194
|
+
},
|
|
195
|
+
"mdCodeBlock": {
|
|
196
|
+
"$ref": "#/$defs/colorValue",
|
|
197
|
+
"description": "Markdown code block content"
|
|
198
|
+
},
|
|
199
|
+
"mdCodeBlockBorder": {
|
|
200
|
+
"$ref": "#/$defs/colorValue",
|
|
201
|
+
"description": "Markdown code block fences"
|
|
202
|
+
},
|
|
203
|
+
"mdQuote": {
|
|
204
|
+
"$ref": "#/$defs/colorValue",
|
|
205
|
+
"description": "Markdown blockquote text"
|
|
206
|
+
},
|
|
207
|
+
"mdQuoteBorder": {
|
|
208
|
+
"$ref": "#/$defs/colorValue",
|
|
209
|
+
"description": "Markdown blockquote border"
|
|
210
|
+
},
|
|
211
|
+
"mdHr": {
|
|
212
|
+
"$ref": "#/$defs/colorValue",
|
|
213
|
+
"description": "Markdown horizontal rule"
|
|
214
|
+
},
|
|
215
|
+
"mdListBullet": {
|
|
216
|
+
"$ref": "#/$defs/colorValue",
|
|
217
|
+
"description": "Markdown list bullets/numbers"
|
|
218
|
+
},
|
|
219
|
+
"toolDiffAdded": {
|
|
220
|
+
"$ref": "#/$defs/colorValue",
|
|
221
|
+
"description": "Added lines in tool diffs"
|
|
222
|
+
},
|
|
223
|
+
"toolDiffRemoved": {
|
|
224
|
+
"$ref": "#/$defs/colorValue",
|
|
225
|
+
"description": "Removed lines in tool diffs"
|
|
226
|
+
},
|
|
227
|
+
"toolDiffContext": {
|
|
228
|
+
"$ref": "#/$defs/colorValue",
|
|
229
|
+
"description": "Context lines in tool diffs"
|
|
230
|
+
},
|
|
231
|
+
"syntaxComment": {
|
|
232
|
+
"$ref": "#/$defs/colorValue",
|
|
233
|
+
"description": "Syntax highlighting: comments"
|
|
234
|
+
},
|
|
235
|
+
"syntaxKeyword": {
|
|
236
|
+
"$ref": "#/$defs/colorValue",
|
|
237
|
+
"description": "Syntax highlighting: keywords"
|
|
238
|
+
},
|
|
239
|
+
"syntaxFunction": {
|
|
240
|
+
"$ref": "#/$defs/colorValue",
|
|
241
|
+
"description": "Syntax highlighting: function names"
|
|
242
|
+
},
|
|
243
|
+
"syntaxVariable": {
|
|
244
|
+
"$ref": "#/$defs/colorValue",
|
|
245
|
+
"description": "Syntax highlighting: variable names"
|
|
246
|
+
},
|
|
247
|
+
"syntaxString": {
|
|
248
|
+
"$ref": "#/$defs/colorValue",
|
|
249
|
+
"description": "Syntax highlighting: string literals"
|
|
250
|
+
},
|
|
251
|
+
"syntaxNumber": {
|
|
252
|
+
"$ref": "#/$defs/colorValue",
|
|
253
|
+
"description": "Syntax highlighting: number literals"
|
|
254
|
+
},
|
|
255
|
+
"syntaxType": {
|
|
256
|
+
"$ref": "#/$defs/colorValue",
|
|
257
|
+
"description": "Syntax highlighting: type names"
|
|
258
|
+
},
|
|
259
|
+
"syntaxOperator": {
|
|
260
|
+
"$ref": "#/$defs/colorValue",
|
|
261
|
+
"description": "Syntax highlighting: operators"
|
|
262
|
+
},
|
|
263
|
+
"syntaxPunctuation": {
|
|
264
|
+
"$ref": "#/$defs/colorValue",
|
|
265
|
+
"description": "Syntax highlighting: punctuation"
|
|
266
|
+
},
|
|
267
|
+
"thinkingOff": {
|
|
268
|
+
"$ref": "#/$defs/colorValue",
|
|
269
|
+
"description": "Thinking level border: off"
|
|
270
|
+
},
|
|
271
|
+
"thinkingMinimal": {
|
|
272
|
+
"$ref": "#/$defs/colorValue",
|
|
273
|
+
"description": "Thinking level border: minimal"
|
|
274
|
+
},
|
|
275
|
+
"thinkingLow": {
|
|
276
|
+
"$ref": "#/$defs/colorValue",
|
|
277
|
+
"description": "Thinking level border: low"
|
|
278
|
+
},
|
|
279
|
+
"thinkingMedium": {
|
|
280
|
+
"$ref": "#/$defs/colorValue",
|
|
281
|
+
"description": "Thinking level border: medium"
|
|
282
|
+
},
|
|
283
|
+
"thinkingHigh": {
|
|
284
|
+
"$ref": "#/$defs/colorValue",
|
|
285
|
+
"description": "Thinking level border: high"
|
|
286
|
+
},
|
|
287
|
+
"thinkingXhigh": {
|
|
288
|
+
"$ref": "#/$defs/colorValue",
|
|
289
|
+
"description": "Thinking level border: xhigh (OpenAI codex-max only)"
|
|
290
|
+
},
|
|
291
|
+
"bashMode": {
|
|
292
|
+
"$ref": "#/$defs/colorValue",
|
|
293
|
+
"description": "Editor border color in bash mode"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"additionalProperties": false
|
|
297
|
+
},
|
|
298
|
+
"export": {
|
|
299
|
+
"type": "object",
|
|
300
|
+
"description": "Optional colors for HTML export (defaults derived from userMessageBg if not specified)",
|
|
301
|
+
"properties": {
|
|
302
|
+
"pageBg": {
|
|
303
|
+
"$ref": "#/$defs/colorValue",
|
|
304
|
+
"description": "Page background color"
|
|
305
|
+
},
|
|
306
|
+
"cardBg": {
|
|
307
|
+
"$ref": "#/$defs/colorValue",
|
|
308
|
+
"description": "Card/container background color"
|
|
309
|
+
},
|
|
310
|
+
"infoBg": {
|
|
311
|
+
"$ref": "#/$defs/colorValue",
|
|
312
|
+
"description": "Info sections background (system prompt, notices)"
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"additionalProperties": false
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
"additionalProperties": false,
|
|
319
|
+
"$defs": {
|
|
320
|
+
"colorValue": {
|
|
321
|
+
"oneOf": [
|
|
322
|
+
{
|
|
323
|
+
"type": "string",
|
|
324
|
+
"description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"type": "integer",
|
|
328
|
+
"minimum": 0,
|
|
329
|
+
"maximum": 255,
|
|
330
|
+
"description": "256-color palette index (0-255)"
|
|
331
|
+
}
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type EditorTheme, type MarkdownTheme, type SelectListTheme, type SettingsListTheme } from "@openadapter/koda-tui";
|
|
2
|
+
import type { SourceInfo } from "../../../core/source-info.ts";
|
|
3
|
+
export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "bashMode";
|
|
4
|
+
export type ThemeBg = "selectedBg" | "userMessageBg" | "customMessageBg" | "toolPendingBg" | "toolSuccessBg" | "toolErrorBg";
|
|
5
|
+
type ColorMode = "truecolor" | "256color";
|
|
6
|
+
export declare class Theme {
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
readonly sourcePath?: string;
|
|
9
|
+
sourceInfo?: SourceInfo;
|
|
10
|
+
private fgColors;
|
|
11
|
+
private bgColors;
|
|
12
|
+
private mode;
|
|
13
|
+
private zenitsuAnsi;
|
|
14
|
+
constructor(fgColors: Record<ThemeColor, string | number>, bgColors: Record<ThemeBg, string | number>, mode: ColorMode, options?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
sourcePath?: string;
|
|
17
|
+
sourceInfo?: SourceInfo;
|
|
18
|
+
});
|
|
19
|
+
private accentAnsi;
|
|
20
|
+
fg(color: ThemeColor, text: string): string;
|
|
21
|
+
bg(color: ThemeBg, text: string): string;
|
|
22
|
+
bold(text: string): string;
|
|
23
|
+
italic(text: string): string;
|
|
24
|
+
underline(text: string): string;
|
|
25
|
+
inverse(text: string): string;
|
|
26
|
+
strikethrough(text: string): string;
|
|
27
|
+
getFgAnsi(color: ThemeColor): string;
|
|
28
|
+
getBgAnsi(color: ThemeBg): string;
|
|
29
|
+
getColorMode(): ColorMode;
|
|
30
|
+
getThinkingBorderColor(level: "off" | "minimal" | "low" | "medium" | "high" | "xhigh"): (str: string) => string;
|
|
31
|
+
getBashModeBorderColor(): (str: string) => string;
|
|
32
|
+
}
|
|
33
|
+
export declare function getAvailableThemes(): string[];
|
|
34
|
+
export interface ThemeInfo {
|
|
35
|
+
name: string;
|
|
36
|
+
path: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare function getAvailableThemesWithPaths(): ThemeInfo[];
|
|
39
|
+
export declare function loadThemeFromPath(themePath: string, mode?: ColorMode): Theme;
|
|
40
|
+
export declare function getThemeByName(name: string): Theme | undefined;
|
|
41
|
+
export type TerminalTheme = "dark" | "light";
|
|
42
|
+
export interface RgbColor {
|
|
43
|
+
r: number;
|
|
44
|
+
g: number;
|
|
45
|
+
b: number;
|
|
46
|
+
}
|
|
47
|
+
export interface TerminalThemeDetection {
|
|
48
|
+
theme: TerminalTheme;
|
|
49
|
+
source: "terminal background" | "COLORFGBG" | "fallback";
|
|
50
|
+
detail: string;
|
|
51
|
+
confidence: "high" | "low";
|
|
52
|
+
}
|
|
53
|
+
export interface TerminalThemeDetectionOptions {
|
|
54
|
+
env?: NodeJS.ProcessEnv;
|
|
55
|
+
}
|
|
56
|
+
export declare function getThemeForRgbColor(rgb: RgbColor): TerminalTheme;
|
|
57
|
+
export declare function parseOsc11BackgroundColor(data: string): RgbColor | undefined;
|
|
58
|
+
export declare function detectTerminalBackground(options?: TerminalThemeDetectionOptions): TerminalThemeDetection;
|
|
59
|
+
export declare function getDefaultTheme(): string;
|
|
60
|
+
export declare const theme: Theme;
|
|
61
|
+
export declare function setRegisteredThemes(themes: Theme[]): void;
|
|
62
|
+
export declare function initTheme(themeName?: string, enableWatcher?: boolean): void;
|
|
63
|
+
export declare function setTheme(name: string, enableWatcher?: boolean): {
|
|
64
|
+
success: boolean;
|
|
65
|
+
error?: string;
|
|
66
|
+
};
|
|
67
|
+
export declare function setThemeInstance(themeInstance: Theme): void;
|
|
68
|
+
export declare function onThemeChange(callback: () => void): void;
|
|
69
|
+
export declare function stopThemeWatcher(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get resolved theme colors as CSS-compatible hex strings.
|
|
72
|
+
* Used by HTML export to generate CSS custom properties.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getResolvedThemeColors(themeName?: string): Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a theme is a "light" theme (for CSS that needs light/dark variants).
|
|
77
|
+
*/
|
|
78
|
+
export declare function isLightTheme(themeName?: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get explicit export colors from theme JSON, if specified.
|
|
81
|
+
* Returns undefined for each color that isn't explicitly set.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getThemeExportColors(themeName?: string): {
|
|
84
|
+
pageBg?: string;
|
|
85
|
+
cardBg?: string;
|
|
86
|
+
infoBg?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Highlight code with syntax coloring based on file extension or language.
|
|
90
|
+
* Returns array of highlighted lines.
|
|
91
|
+
*/
|
|
92
|
+
export declare function highlightCode(code: string, lang?: string): string[];
|
|
93
|
+
/**
|
|
94
|
+
* Get language identifier from file path extension.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getLanguageFromPath(filePath: string): string | undefined;
|
|
97
|
+
export declare function getMarkdownTheme(): MarkdownTheme;
|
|
98
|
+
export declare function getSelectListTheme(): SelectListTheme;
|
|
99
|
+
export declare function getEditorTheme(): EditorTheme;
|
|
100
|
+
export declare function getSettingsListTheme(): SettingsListTheme;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var fe=Object.defineProperty;var r=(e,t)=>fe(e,"name",{value:t,configurable:!0});import*as m from"node:fs";import*as T from"node:path";import{getCapabilities as ue}from"@openadapter/koda-tui";import k from"chalk";import{Type as h}from"typebox";import{Compile as le}from"typebox/compile";import{getCustomThemesDir as M,getThemesDir as U}from"../../../config.js";import{closeWatcher as _,watchWithErrorHandler as he}from"../../../utils/fs-watch.js";import{highlight as q,supportsLanguage as V}from"../../../utils/syntax-highlight.js";const i=h.Union([h.String(),h.Integer({minimum:0,maximum:255})]),de=h.Object({$schema:h.Optional(h.String()),name:h.String(),vars:h.Optional(h.Record(h.String(),i)),colors:h.Object({accent:i,border:i,borderAccent:i,borderMuted:i,success:i,error:i,warning:i,muted:i,dim:i,text:i,thinkingText:i,selectedBg:i,userMessageBg:i,userMessageText:i,customMessageBg:i,customMessageText:i,customMessageLabel:i,toolPendingBg:i,toolSuccessBg:i,toolErrorBg:i,toolTitle:i,toolOutput:i,mdHeading:i,mdLink:i,mdLinkUrl:i,mdCode:i,mdCodeBlock:i,mdCodeBlockBorder:i,mdQuote:i,mdQuoteBorder:i,mdHr:i,mdListBullet:i,toolDiffAdded:i,toolDiffRemoved:i,toolDiffContext:i,syntaxComment:i,syntaxKeyword:i,syntaxFunction:i,syntaxVariable:i,syntaxString:i,syntaxNumber:i,syntaxType:i,syntaxOperator:i,syntaxPunctuation:i,thinkingOff:i,thinkingMinimal:i,thinkingLow:i,thinkingMedium:i,thinkingHigh:i,thinkingXhigh:i,bashMode:i}),export:h.Optional(h.Object({pageBg:h.Optional(i),cardBg:h.Optional(i),infoBg:h.Optional(i)}))}),W=le(de);function S(e){const t=e.replace("#","");if(t.length!==6)throw new Error(`Invalid hex color: ${e}`);const n=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);if(Number.isNaN(n)||Number.isNaN(o)||Number.isNaN(s))throw new Error(`Invalid hex color: ${e}`);return{r:n,g:o,b:s}}r(S,"hexToRgb");const v=[0,95,135,175,215,255],O=Array.from({length:24},(e,t)=>8+t*10);function L(e){let t=1/0,n=0;for(let o=0;o<v.length;o++){const s=Math.abs(e-v[o]);s<t&&(t=s,n=o)}return n}r(L,"findClosestCubeIndex");function ge(e){let t=1/0,n=0;for(let o=0;o<O.length;o++){const s=Math.abs(e-O[o]);s<t&&(t=s,n=o)}return n}r(ge,"findClosestGrayIndex");function J(e,t,n,o,s,c){const a=e-o,u=t-s,l=n-c;return a*a*.299+u*u*.587+l*l*.114}r(J,"colorDistance");function me(e,t,n){const o=L(e),s=L(t),c=L(n),a=v[o],u=v[s],l=v[c],g=16+36*o+6*s+c,p=J(e,t,n,a,u,l),E=Math.round(.299*e+.587*t+.114*n),$=ge(E),y=O[$],se=232+$,ie=J(e,t,n,y,y,y),ce=Math.max(e,t,n),ae=Math.min(e,t,n);return ce-ae<10&&ie<p?se:g}r(me,"rgbTo256");function G(e){const{r:t,g:n,b:o}=S(e);return me(t,n,o)}r(G,"hexTo256");function z(e,t){if(e==="")return"\x1B[39m";if(typeof e=="number")return`\x1B[38;5;${e}m`;if(e.startsWith("#"))if(t==="truecolor"){const{r:n,g:o,b:s}=S(e);return`\x1B[38;2;${n};${o};${s}m`}else return`\x1B[38;5;${G(e)}m`;throw new Error(`Invalid color value: ${e}`)}r(z,"fgAnsi");function pe(e,t){if(e==="")return"\x1B[49m";if(typeof e=="number")return`\x1B[48;5;${e}m`;if(e.startsWith("#"))if(t==="truecolor"){const{r:n,g:o,b:s}=S(e);return`\x1B[48;2;${n};${o};${s}m`}else return`\x1B[48;5;${G(e)}m`;throw new Error(`Invalid color value: ${e}`)}r(pe,"bgAnsi");function P(e,t,n=new Set){if(typeof e=="number"||e===""||e.startsWith("#"))return e;if(n.has(e))throw new Error(`Circular variable reference detected: ${e}`);if(!(e in t))throw new Error(`Variable reference not found: ${e}`);return n.add(e),P(t[e],t,n)}r(P,"resolveVarRefs");function K(e,t={}){const n={};for(const[o,s]of Object.entries(e))n[o]=P(s,t);return n}r(K,"resolveThemeColors");class xe{static{r(this,"Theme")}name;sourcePath;sourceInfo;fgColors;bgColors;mode;zenitsuAnsi;constructor(t,n,o,s={}){this.name=s.name,this.sourcePath=s.sourcePath,this.sourceInfo=s.sourceInfo,this.mode=o,this.fgColors=new Map;for(const[c,a]of Object.entries(t))this.fgColors.set(c,z(a,o));this.bgColors=new Map;for(const[c,a]of Object.entries(n))this.bgColors.set(c,pe(a,o));this.zenitsuAnsi=z("#fbbf24",o)}accentAnsi(t,n){return(t==="accent"||t==="borderAccent")&&process.env.KODA_ZENITSU==="1"?this.zenitsuAnsi:n}fg(t,n){const o=this.fgColors.get(t);if(!o)throw new Error(`Unknown theme color: ${t}`);return`${this.accentAnsi(t,o)}${n}\x1B[39m`}bg(t,n){const o=this.bgColors.get(t);if(!o)throw new Error(`Unknown theme background color: ${t}`);return`${o}${n}\x1B[49m`}bold(t){return k.bold(t)}italic(t){return k.italic(t)}underline(t){return k.underline(t)}inverse(t){return k.inverse(t)}strikethrough(t){return k.strikethrough(t)}getFgAnsi(t){const n=this.fgColors.get(t);if(!n)throw new Error(`Unknown theme color: ${t}`);return this.accentAnsi(t,n)}getBgAnsi(t){const n=this.bgColors.get(t);if(!n)throw new Error(`Unknown theme background color: ${t}`);return n}getColorMode(){return this.mode}getThinkingBorderColor(t){switch(t){case"off":return n=>this.fg("thinkingOff",n);case"minimal":return n=>this.fg("thinkingMinimal",n);case"low":return n=>this.fg("thinkingLow",n);case"medium":return n=>this.fg("thinkingMedium",n);case"high":return n=>this.fg("thinkingHigh",n);case"xhigh":return n=>this.fg("thinkingXhigh",n);default:return n=>this.fg("thinkingOff",n)}}getBashModeBorderColor(){return t=>this.fg("bashMode",t)}}let A;function Q(){if(!A){const e=U(),t=T.join(e,"dark.json"),n=T.join(e,"light.json");A={dark:JSON.parse(m.readFileSync(t,"utf-8")),light:JSON.parse(m.readFileSync(n,"utf-8"))}}return A}r(Q,"getBuiltinThemes");function Ne(){return be().map(({name:e})=>e)}r(Ne,"getAvailableThemes");function be(){const e=U(),t=[],n=new Set,o=r(s=>{n.has(s.name)||(n.add(s.name),t.push(s))},"addTheme");for(const s of Object.keys(Q()))o({name:s,path:T.join(e,`${s}.json`)});for(const s of ye())o(s);for(const[s,c]of B.entries())o({name:s,path:c.sourcePath});return t.sort((s,c)=>s.name.localeCompare(c.name))}r(be,"getAvailableThemesWithPaths");function ye(){const e=M(),t=[];if(!m.existsSync(e))return t;for(const n of m.readdirSync(e)){if(!n.endsWith(".json"))continue;const o=T.join(e,n);try{const s=X(o);s.name&&t.push({name:s.name,path:o})}catch{}}return t}r(ye,"getCustomThemeInfos");function Te(e,t){if(!W.Check(t)){const n=Array.from(W.Errors(t)),o=new Set,s=[];for(const a of n){if(a.keyword==="required"&&a.instancePath==="/colors"){const l=a.params.requiredProperties;for(const g of l??[])o.add(g);continue}const u=a.instancePath||"/";s.push(` - ${u}: ${a.message}`)}let c=`Invalid theme "${e}":
|
|
2
|
+
`;throw o.size>0&&(c+=`
|
|
3
|
+
Missing required color tokens:
|
|
4
|
+
`,c+=Array.from(o).sort().map(a=>` - ${a}`).join(`
|
|
5
|
+
`),c+=`
|
|
6
|
+
|
|
7
|
+
Please add these colors to your theme's "colors" object.`,c+=`
|
|
8
|
+
See the built-in themes (dark.json, light.json) for reference values.`),s.length>0&&(c+=`
|
|
9
|
+
|
|
10
|
+
Other errors:
|
|
11
|
+
${s.join(`
|
|
12
|
+
`)}`),new Error(c)}return t}r(Te,"parseThemeJson");function N(e,t){let n;try{n=JSON.parse(t)}catch(o){throw new Error(`Failed to parse theme ${e}: ${o}`)}return Te(e,n)}r(N,"parseThemeJsonContent");function D(e){const t=Q();if(e in t)return t[e];const n=B.get(e);if(n?.sourcePath){const a=m.readFileSync(n.sourcePath,"utf-8");return N(n.sourcePath,a)}if(n)throw new Error(`Theme "${e}" does not have a source path for export`);const o=M(),s=T.join(o,`${e}.json`);if(!m.existsSync(s))throw new Error(`Theme not found: ${e}`);const c=m.readFileSync(s,"utf-8");return N(e,c)}r(D,"loadThemeJson");function Y(e,t,n){const o=t??(ue().trueColor?"truecolor":"256color"),s=K(e.colors,e.vars),c={},a={},u=new Set(["selectedBg","userMessageBg","customMessageBg","toolPendingBg","toolSuccessBg","toolErrorBg"]);for(const[l,g]of Object.entries(s))u.has(l)?a[l]=g:c[l]=g;return new xe(c,a,o,{name:e.name,sourcePath:n})}r(Y,"createTheme");function X(e,t){const n=m.readFileSync(e,"utf-8"),o=N(e,n);return Y(o,t,e)}r(X,"loadThemeFromPath");function j(e,t){const n=B.get(e);if(n)return n;const o=D(e);return Y(o,t)}r(j,"loadTheme");function De(e){try{return j(e)}catch{return}}r(De,"getThemeByName");function ke(e){const t=e.split(";");for(let n=t.length-1;n>=0;n--){const o=parseInt(t[n].trim(),10);if(Number.isInteger(o)&&o>=0&&o<=255)return o}}r(ke,"getColorFgBgBackgroundIndex");function Z({r:e,g:t,b:n}){const o=r(s=>{const c=s/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4},"toLinear");return .2126*o(e)+.7152*o(t)+.0722*o(n)}r(Z,"getRgbColorLuminance");function Ce(e){return Z(S(H(e)))}r(Ce,"getAnsiColorLuminance");function Fe(e){return Z(e)>=.5?"light":"dark"}r(Fe,"getThemeForRgbColor");function C(e){if(!/^[0-9a-f]+$/i.test(e))return;const t=16**e.length-1;if(!(t<=0))return Math.round(parseInt(e,16)/t*255)}r(C,"parseOscHexChannel");function He(e){const t=e.match(/^\x1b\]11;([^\x07\x1b]*)(?:\x07|\x1b\\)$/i);if(!t)return;const n=t[1].trim();if(n.startsWith("#")){const p=n.slice(1);if(/^[0-9a-f]{6}$/i.test(p))return S(n);if(/^[0-9a-f]{12}$/i.test(p)){const E=C(p.slice(0,4)),$=C(p.slice(4,8)),y=C(p.slice(8,12));return E!==void 0&&$!==void 0&&y!==void 0?{r:E,g:$,b:y}:void 0}return}const o=n.replace(/^rgba?:/i,""),[s,c,a]=o.split("/");if(s===void 0||c===void 0||a===void 0)return;const u=C(s),l=C(c),g=C(a);return u!==void 0&&l!==void 0&&g!==void 0?{r:u,g:l,b:g}:void 0}r(He,"parseOsc11BackgroundColor");function we(e={}){const n=(e.env??process.env).COLORFGBG||"",o=ke(n);return o!==void 0?{theme:Ce(o)>=.5?"light":"dark",source:"COLORFGBG",detail:`background color index ${o}`,confidence:"high"}:{theme:"dark",source:"fallback",detail:"no terminal background hint found",confidence:"low"}}r(we,"detectTerminalBackground");function F(){return we().theme}r(F,"getDefaultTheme");const ee=Symbol.for("@openadapter/koda:theme"),Be=Symbol.for("@mariozechner/pi-coding-agent:theme"),f=new Proxy({},{get(e,t){const n=globalThis[ee];if(!n)throw new Error("Theme not initialized. Call initTheme() first.");return n[t]}});function w(e){globalThis[ee]=e,globalThis[Be]=e}r(w,"setGlobalTheme");let d,I,x,b;const B=new Map;function Re(e){B.clear();for(const t of e)t.name&&B.set(t.name,t)}r(Re,"setRegisteredThemes");function Ue(e,t=!1){const n=e??F();d=n;try{w(j(n)),t&&te()}catch{d="dark",w(j("dark"))}}r(Ue,"initTheme");function _e(e,t=!1){d=e;try{return w(j(e)),t&&te(),b&&b(),{success:!0}}catch(n){return d="dark",w(j("dark")),{success:!1,error:n instanceof Error?n.message:String(n)}}}r(_e,"setTheme");function qe(e){w(e),d="<in-memory>",ne(),b&&b()}r(qe,"setThemeInstance");function Ve(e){b=e}r(Ve,"onThemeChange");function te(){if(ne(),!d||d==="dark"||d==="light")return;const e=M(),t=d,n=`${t}.json`,o=T.join(e,n);if(!m.existsSync(o))return;const s=r(()=>{x&&clearTimeout(x),x=setTimeout(()=>{if(x=void 0,d===t&&m.existsSync(o))try{const c=X(o);B.set(t,c),w(c),b&&b()}catch{}},100)},"scheduleReload");I=he(e,(c,a)=>{if(d===t){if(!a){s();return}a===n&&s()}},()=>{_(I),I=void 0})??void 0}r(te,"startThemeWatcher");function ne(){x&&(clearTimeout(x),x=void 0),_(I),I=void 0}r(ne,"stopThemeWatcher");function H(e){const t=["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"];if(e<16)return t[e];if(e<232){const s=e-16,c=Math.floor(s/36),a=Math.floor(s%36/6),u=s%6,l=r(g=>(g===0?0:55+g*40).toString(16).padStart(2,"0"),"toHex");return`#${l(c)}${l(a)}${l(u)}`}const o=(8+(e-232)*10).toString(16).padStart(2,"0");return`#${o}${o}${o}`}r(H,"ansi256ToHex");function We(e){const t=e??d??F(),n=t==="light",o=D(t),s=K(o.colors,o.vars),c=n?"#000000":"#e5e5e7",a={};for(const[u,l]of Object.entries(s))typeof l=="number"?a[u]=H(l):l===""?a[u]=c:a[u]=l;return a}r(We,"getResolvedThemeColors");function Je(e){return e==="light"}r(Je,"isLightTheme");function Ge(e){const t=e??d??F();try{const n=D(t),o=n.export;if(!o)return{};const s=n.vars??{},c=r(a=>{if(a===void 0)return;const u=P(a,s);if(typeof u=="number")return H(u);if(u!=="")return u},"resolve");return{pageBg:c(o.pageBg),cardBg:c(o.cardBg),infoBg:c(o.infoBg)}}catch{return{}}}r(Ge,"getThemeExportColors");let re,R;function $e(e){return{keyword:r(t=>e.fg("syntaxKeyword",t),"keyword"),built_in:r(t=>e.fg("syntaxType",t),"built_in"),literal:r(t=>e.fg("syntaxNumber",t),"literal"),number:r(t=>e.fg("syntaxNumber",t),"number"),regexp:r(t=>e.fg("syntaxString",t),"regexp"),string:r(t=>e.fg("syntaxString",t),"string"),comment:r(t=>e.fg("syntaxComment",t),"comment"),doctag:r(t=>e.fg("syntaxComment",t),"doctag"),meta:r(t=>e.fg("muted",t),"meta"),function:r(t=>e.fg("syntaxFunction",t),"function"),title:r(t=>e.fg("syntaxFunction",t),"title"),class:r(t=>e.fg("syntaxType",t),"class"),type:r(t=>e.fg("syntaxType",t),"type"),tag:r(t=>e.fg("syntaxPunctuation",t),"tag"),name:r(t=>e.fg("syntaxKeyword",t),"name"),attr:r(t=>e.fg("syntaxVariable",t),"attr"),variable:r(t=>e.fg("syntaxVariable",t),"variable"),params:r(t=>e.fg("syntaxVariable",t),"params"),operator:r(t=>e.fg("syntaxOperator",t),"operator"),punctuation:r(t=>e.fg("syntaxPunctuation",t),"punctuation"),emphasis:r(t=>e.italic(t),"emphasis"),strong:r(t=>e.bold(t),"strong"),link:r(t=>e.underline(t),"link"),addition:r(t=>e.fg("toolDiffAdded",t),"addition"),deletion:r(t=>e.fg("toolDiffRemoved",t),"deletion")}}r($e,"buildCliHighlightTheme");function oe(e){return(re!==e||!R)&&(re=e,R=$e(e)),R}r(oe,"getCliHighlightTheme");function ze(e,t){const n=t&&V(t)?t:void 0;if(!n)return e.split(`
|
|
13
|
+
`).map(s=>f.fg("mdCodeBlock",s));const o={language:n,ignoreIllegals:!0,theme:oe(f)};try{return q(e,o).split(`
|
|
14
|
+
`)}catch{return e.split(`
|
|
15
|
+
`)}}r(ze,"highlightCode");function Ke(e){const t=e.split(".").pop()?.toLowerCase();return t?{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",kt:"kotlin",swift:"swift",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",md:"markdown",markdown:"markdown",dockerfile:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",r:"r",scala:"scala",clj:"clojure",ex:"elixir",exs:"elixir",erl:"erlang",hs:"haskell",ml:"ocaml",vim:"vim",graphql:"graphql",proto:"protobuf",tf:"hcl",hcl:"hcl"}[t]:void 0}r(Ke,"getLanguageFromPath");function Qe(){return{heading:r(e=>f.fg("mdHeading",e),"heading"),link:r(e=>f.fg("mdLink",e),"link"),linkUrl:r(e=>f.fg("mdLinkUrl",e),"linkUrl"),code:r(e=>f.fg("mdCode",e),"code"),codeBlock:r(e=>f.fg("mdCodeBlock",e),"codeBlock"),codeBlockBorder:r(e=>f.fg("mdCodeBlockBorder",e),"codeBlockBorder"),quote:r(e=>f.fg("mdQuote",e),"quote"),quoteBorder:r(e=>f.fg("mdQuoteBorder",e),"quoteBorder"),hr:r(e=>f.fg("mdHr",e),"hr"),listBullet:r(e=>f.fg("mdListBullet",e),"listBullet"),bold:r(e=>f.bold(e),"bold"),italic:r(e=>f.italic(e),"italic"),underline:r(e=>f.underline(e),"underline"),strikethrough:r(e=>k.strikethrough(e),"strikethrough"),highlightCode:r((e,t)=>{const n=t&&V(t)?t:void 0;if(!n)return e.split(`
|
|
16
|
+
`).map(s=>f.fg("mdCodeBlock",s));const o={language:n,ignoreIllegals:!0,theme:oe(f)};try{return q(e,o).split(`
|
|
17
|
+
`)}catch{return e.split(`
|
|
18
|
+
`).map(s=>f.fg("mdCodeBlock",s))}},"highlightCode")}}r(Qe,"getMarkdownTheme");function Se(){return{selectedPrefix:r(e=>f.fg("accent",e),"selectedPrefix"),selectedText:r(e=>f.fg("accent",e),"selectedText"),description:r(e=>f.fg("muted",e),"description"),scrollInfo:r(e=>f.fg("muted",e),"scrollInfo"),noMatch:r(e=>f.fg("muted",e),"noMatch")}}r(Se,"getSelectListTheme");function Ye(){return{borderColor:r(e=>f.fg("accent",e),"borderColor"),selectList:Se()}}r(Ye,"getEditorTheme");function Xe(){return{label:r((e,t)=>t?f.fg("accent",e):e,"label"),value:r((e,t)=>t?f.fg("accent",e):f.fg("muted",e),"value"),description:r(e=>f.fg("dim",e),"description"),cursor:f.fg("accent","\u2192 "),hint:r(e=>f.fg("dim",e),"hint")}}r(Xe,"getSettingsListTheme");export{xe as Theme,we as detectTerminalBackground,Ne as getAvailableThemes,be as getAvailableThemesWithPaths,F as getDefaultTheme,Ye as getEditorTheme,Ke as getLanguageFromPath,Qe as getMarkdownTheme,We as getResolvedThemeColors,Se as getSelectListTheme,Xe as getSettingsListTheme,De as getThemeByName,Ge as getThemeExportColors,Fe as getThemeForRgbColor,ze as highlightCode,Ue as initTheme,Je as isLightTheme,X as loadThemeFromPath,Ve as onThemeChange,He as parseOsc11BackgroundColor,Re as setRegisteredThemes,_e as setTheme,qe as setThemeInstance,ne as stopThemeWatcher,f as theme};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print mode (single-shot): Send prompts, output result, exit.
|
|
3
|
+
*
|
|
4
|
+
* Used for:
|
|
5
|
+
* - `pi -p "prompt"` - text output
|
|
6
|
+
* - `pi --mode json "prompt"` - JSON event stream
|
|
7
|
+
*/
|
|
8
|
+
import type { ImageContent } from "@openadapter/koda-ai";
|
|
9
|
+
import type { AgentSessionRuntime } from "../core/agent-session-runtime.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Options for print mode.
|
|
12
|
+
*/
|
|
13
|
+
export interface PrintModeOptions {
|
|
14
|
+
/** Output mode: "text" for final response only, "json" for all events */
|
|
15
|
+
mode: "text" | "json";
|
|
16
|
+
/** Array of additional prompts to send after initialMessage */
|
|
17
|
+
messages?: string[];
|
|
18
|
+
/** First message to send (may contain @file content) */
|
|
19
|
+
initialMessage?: string;
|
|
20
|
+
/** Images to attach to the initial message */
|
|
21
|
+
initialImages?: ImageContent[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Run in print (single-shot) mode.
|
|
25
|
+
* Sends prompts to the agent and outputs the result.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var h=Object.defineProperty;var n=(r,i)=>h(r,"name",{value:i,configurable:!0});import{flushRawStdout as b,writeRawStdout as l}from"../core/output-guard.js";import{killTrackedDetachedChildren as x}from"../utils/shell.js";async function E(r,i){const{mode:a,messages:S=[],initialMessage:d,initialImages:y}=i;let f=0,t=r.session,c,u=!1;const g=[],p=n(async()=>{u||(u=!0,c?.(),await r.dispose())},"disposeRuntime");n(()=>{const s=["SIGTERM"];process.platform!=="win32"&&s.push("SIGHUP");for(const e of s){const o=n(()=>{x(),p().finally(()=>{process.exit(e==="SIGHUP"?129:143)})},"handler");process.on(e,o),g.push(()=>process.off(e,o))}},"registerSignalHandlers")(),r.setRebindSession(async()=>{await w()});const w=n(async()=>{t=r.session,await t.bindExtensions({mode:a==="json"?"json":"print",commandContextActions:{waitForIdle:n(()=>t.agent.waitForIdle(),"waitForIdle"),newSession:n(async s=>r.newSession(s),"newSession"),fork:n(async(s,e)=>({cancelled:(await r.fork(s,e)).cancelled}),"fork"),navigateTree:n(async(s,e)=>({cancelled:(await t.navigateTree(s,{summarize:e?.summarize,customInstructions:e?.customInstructions,replaceInstructions:e?.replaceInstructions,label:e?.label})).cancelled}),"navigateTree"),switchSession:n(async(s,e)=>r.switchSession(s,e),"switchSession"),reload:n(async()=>{await t.reload()},"reload")},onError:n(s=>{console.error(`Extension error (${s.extensionPath}): ${s.error}`)},"onError")}),c?.(),c=t.subscribe(s=>{a==="json"&&l(`${JSON.stringify(s)}
|
|
2
|
+
`)})},"rebindSession");try{if(a==="json"){const s=t.sessionManager.getHeader();s&&l(`${JSON.stringify(s)}
|
|
3
|
+
`)}await w(),d&&await t.prompt(d,{images:y});for(const s of S)await t.prompt(s);if(a==="text"){const s=t.state,e=s.messages[s.messages.length-1];if(e?.role==="assistant"){const o=e;if(o.stopReason==="error"||o.stopReason==="aborted")console.error(o.errorMessage||`Request ${o.stopReason}`),f=1;else for(const m of o.content)m.type==="text"&&l(`${m.text}
|
|
4
|
+
`)}}return f}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}finally{for(const s of g)s();await p(),await b()}}n(E,"runPrintMode");export{E as runPrintMode};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
/**
|
|
3
|
+
* Serialize a single strict JSONL record.
|
|
4
|
+
*
|
|
5
|
+
* Framing is LF-only. Payload strings may contain other Unicode separators such as
|
|
6
|
+
* U+2028 and U+2029. Clients must split records on `\n` only.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serializeJsonLine(value: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Attach an LF-only JSONL reader to a stream.
|
|
11
|
+
*
|
|
12
|
+
* This intentionally does not use Node readline. Readline splits on additional
|
|
13
|
+
* Unicode separators that are valid inside JSON strings and therefore does not
|
|
14
|
+
* implement strict JSONL framing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var a=Object.defineProperty;var o=(e,i)=>a(e,"name",{value:i,configurable:!0});import{StringDecoder as l}from"node:string_decoder";function p(e){return`${JSON.stringify(e)}
|
|
2
|
+
`}o(p,"serializeJsonLine");function w(e,i){const f=new l("utf8");let n="";const d=o(t=>{i(t.endsWith("\r")?t.slice(0,-1):t)},"emitLine"),c=o(t=>{for(n+=typeof t=="string"?t:f.write(t);;){const r=n.indexOf(`
|
|
3
|
+
`);if(r===-1)return;d(n.slice(0,r)),n=n.slice(r+1)}},"onData"),s=o(()=>{n+=f.end(),n.length>0&&(d(n),n="")},"onEnd");return e.on("data",c),e.on("end",s),()=>{e.off("data",c),e.off("end",s)}}o(w,"attachJsonlLineReader");export{w as attachJsonlLineReader,p as serializeJsonLine};
|