orient-cli 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/orient/orient-extension.js +69 -2
- package/dist/orient/orient-extension.js.map +1 -1
- package/dist/orient/phase-context.d.ts +17 -0
- package/dist/orient/phase-context.js +88 -0
- package/dist/orient/phase-context.js.map +1 -0
- package/docs/configuration.md +24 -9
- package/package.json +1 -1
- package/vendor/@orient-cli/agent-core/README.md +456 -0
- package/vendor/@orient-cli/agent-core/dist/agent-loop.d.ts.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/agent-loop.js.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/agent.d.ts +7 -0
- package/vendor/@orient-cli/agent-core/dist/agent.d.ts.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/agent.js +2 -24
- package/vendor/@orient-cli/agent-core/dist/agent.js.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/index.d.ts.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/proxy.d.ts.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/proxy.js.map +1 -1
- package/vendor/@orient-cli/agent-core/dist/types.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/README.md +1315 -0
- package/vendor/@orient-cli/ai/dist/api-registry.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/api-registry.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/bedrock-provider.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/cli.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/cli.js +0 -0
- package/vendor/@orient-cli/ai/dist/cli.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/env-api-keys.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/env-api-keys.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/index.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/models.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/models.generated.d.ts +488 -488
- package/vendor/@orient-cli/ai/dist/models.generated.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/models.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/oauth.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/amazon-bedrock.js +1 -1
- package/vendor/@orient-cli/ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/anthropic.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/anthropic.js +1 -1
- package/vendor/@orient-cli/ai/dist/providers/anthropic.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/faux.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/faux.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/github-copilot-headers.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-shared.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-shared.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-vertex.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google-vertex.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/google.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/mistral.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/mistral.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-codex-responses.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-completions.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-responses-shared.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-responses-shared.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-responses.js +1 -1
- package/vendor/@orient-cli/ai/dist/providers/openai-responses.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/register-builtins.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/simple-options.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/simple-options.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/transform-messages.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/providers/transform-messages.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/stream.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/stream.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/types.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/event-stream.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/event-stream.js +3 -7
- package/vendor/@orient-cli/ai/dist/utils/event-stream.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/hash.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/hash.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/json-parse.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/json-parse.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/anthropic.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/anthropic.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/google-antigravity.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/index.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/index.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/oauth-page.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/oauth-page.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/openai-codex.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/openai-codex.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/pkce.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/pkce.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/oauth/types.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/overflow.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/overflow.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/sanitize-unicode.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/sanitize-unicode.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/typebox-helpers.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/typebox-helpers.js.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/validation.d.ts.map +1 -1
- package/vendor/@orient-cli/ai/dist/utils/validation.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/README.md +618 -0
- package/vendor/@orient-cli/coding-agent/dist/bun/cli.js +1 -1
- package/vendor/@orient-cli/coding-agent/dist/bun/cli.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/cli.js +2 -1
- package/vendor/@orient-cli/coding-agent/dist/cli.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/config.d.ts.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/config.js +4 -2
- package/vendor/@orient-cli/coding-agent/dist/config.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/core/export-html/template.css +1001 -0
- package/vendor/@orient-cli/coding-agent/dist/core/export-html/template.html +55 -0
- package/vendor/@orient-cli/coding-agent/dist/core/package-manager.js +1 -1
- package/vendor/@orient-cli/coding-agent/dist/core/package-manager.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/core/settings-manager.js +2 -2
- package/vendor/@orient-cli/coding-agent/dist/core/settings-manager.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/core/timings.d.ts +1 -1
- package/vendor/@orient-cli/coding-agent/dist/core/timings.js +2 -2
- package/vendor/@orient-cli/coding-agent/dist/core/timings.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/main.d.ts.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/main.js +4 -2
- package/vendor/@orient-cli/coding-agent/dist/main.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/modes/interactive/interactive-mode.js +2 -2
- package/vendor/@orient-cli/coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/dist/modes/interactive/theme/dark.json +85 -0
- package/vendor/@orient-cli/coding-agent/dist/modes/interactive/theme/light.json +84 -0
- package/vendor/@orient-cli/coding-agent/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/vendor/@orient-cli/coding-agent/dist/utils/tools-manager.js +1 -1
- package/vendor/@orient-cli/coding-agent/dist/utils/tools-manager.js.map +1 -1
- package/vendor/@orient-cli/coding-agent/docs/compaction.md +394 -0
- package/vendor/@orient-cli/coding-agent/docs/custom-provider.md +596 -0
- package/vendor/@orient-cli/coding-agent/docs/development.md +71 -0
- package/vendor/@orient-cli/coding-agent/docs/extensions.md +2262 -0
- package/vendor/@orient-cli/coding-agent/docs/images/doom-extension.png +0 -0
- package/vendor/@orient-cli/coding-agent/docs/images/exy.png +0 -0
- package/vendor/@orient-cli/coding-agent/docs/images/interactive-mode.png +0 -0
- package/vendor/@orient-cli/coding-agent/docs/images/tree-view.png +0 -0
- package/vendor/@orient-cli/coding-agent/docs/json.md +82 -0
- package/vendor/@orient-cli/coding-agent/docs/keybindings.md +175 -0
- package/vendor/@orient-cli/coding-agent/docs/models.md +392 -0
- package/vendor/@orient-cli/coding-agent/docs/packages.md +218 -0
- package/vendor/@orient-cli/coding-agent/docs/prompt-templates.md +67 -0
- package/vendor/@orient-cli/coding-agent/docs/providers.md +195 -0
- package/vendor/@orient-cli/coding-agent/docs/rpc.md +1377 -0
- package/vendor/@orient-cli/coding-agent/docs/sdk.md +1124 -0
- package/vendor/@orient-cli/coding-agent/docs/session.md +412 -0
- package/vendor/@orient-cli/coding-agent/docs/settings.md +246 -0
- package/vendor/@orient-cli/coding-agent/docs/shell-aliases.md +13 -0
- package/vendor/@orient-cli/coding-agent/docs/skills.md +232 -0
- package/vendor/@orient-cli/coding-agent/docs/terminal-setup.md +106 -0
- package/vendor/@orient-cli/coding-agent/docs/termux.md +127 -0
- package/vendor/@orient-cli/coding-agent/docs/themes.md +295 -0
- package/vendor/@orient-cli/coding-agent/docs/tmux.md +61 -0
- package/vendor/@orient-cli/coding-agent/docs/tree.md +231 -0
- package/vendor/@orient-cli/coding-agent/docs/tui.md +887 -0
- package/vendor/@orient-cli/coding-agent/docs/windows.md +17 -0
- package/vendor/@orient-cli/tui/README.md +767 -0
- package/vendor/@orient-cli/tui/dist/autocomplete.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/autocomplete.js +0 -3
- package/vendor/@orient-cli/tui/dist/autocomplete.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/box.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/box.js +1 -6
- package/vendor/@orient-cli/tui/dist/components/box.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/cancellable-loader.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/cancellable-loader.js +4 -3
- package/vendor/@orient-cli/tui/dist/components/cancellable-loader.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/editor.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/editor.js +37 -48
- package/vendor/@orient-cli/tui/dist/components/editor.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/image.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/image.js +0 -8
- package/vendor/@orient-cli/tui/dist/components/image.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/input.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/input.js +14 -14
- package/vendor/@orient-cli/tui/dist/components/input.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/loader.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/loader.js +4 -7
- package/vendor/@orient-cli/tui/dist/components/loader.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/markdown.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/markdown.js +0 -10
- package/vendor/@orient-cli/tui/dist/components/markdown.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/select-list.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/select-list.js +4 -9
- package/vendor/@orient-cli/tui/dist/components/select-list.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/settings-list.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/settings-list.js +4 -12
- package/vendor/@orient-cli/tui/dist/components/settings-list.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/spacer.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/spacer.js +0 -1
- package/vendor/@orient-cli/tui/dist/components/spacer.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/text.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/text.js +0 -8
- package/vendor/@orient-cli/tui/dist/components/text.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/truncated-text.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/components/truncated-text.js +0 -3
- package/vendor/@orient-cli/tui/dist/components/truncated-text.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/editor-component.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/fuzzy.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/fuzzy.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/index.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/keybindings.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/keybindings.js +2 -4
- package/vendor/@orient-cli/tui/dist/keybindings.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/keys.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/keys.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/kill-ring.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/kill-ring.js +3 -1
- package/vendor/@orient-cli/tui/dist/kill-ring.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/stdin-buffer.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/stdin-buffer.js +4 -5
- package/vendor/@orient-cli/tui/dist/stdin-buffer.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/terminal-image.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/terminal-image.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/terminal.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/terminal.js +20 -22
- package/vendor/@orient-cli/tui/dist/terminal.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/tui.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/tui.js +25 -27
- package/vendor/@orient-cli/tui/dist/tui.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/undo-stack.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/undo-stack.js +3 -1
- package/vendor/@orient-cli/tui/dist/undo-stack.js.map +1 -1
- package/vendor/@orient-cli/tui/dist/utils.d.ts.map +1 -1
- package/vendor/@orient-cli/tui/dist/utils.js +13 -11
- package/vendor/@orient-cli/tui/dist/utils.js.map +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/badlogic/pi-mono/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
|
3
|
+
"name": "dark",
|
|
4
|
+
"vars": {
|
|
5
|
+
"cyan": "#00d7ff",
|
|
6
|
+
"blue": "#5f87ff",
|
|
7
|
+
"green": "#b5bd68",
|
|
8
|
+
"red": "#cc6666",
|
|
9
|
+
"yellow": "#ffff00",
|
|
10
|
+
"gray": "#808080",
|
|
11
|
+
"dimGray": "#666666",
|
|
12
|
+
"darkGray": "#505050",
|
|
13
|
+
"accent": "#8abeb7",
|
|
14
|
+
"selectedBg": "#3a3a4a",
|
|
15
|
+
"userMsgBg": "#343541",
|
|
16
|
+
"toolPendingBg": "#282832",
|
|
17
|
+
"toolSuccessBg": "#283228",
|
|
18
|
+
"toolErrorBg": "#3c2828",
|
|
19
|
+
"customMsgBg": "#2d2838"
|
|
20
|
+
},
|
|
21
|
+
"colors": {
|
|
22
|
+
"accent": "accent",
|
|
23
|
+
"border": "blue",
|
|
24
|
+
"borderAccent": "cyan",
|
|
25
|
+
"borderMuted": "darkGray",
|
|
26
|
+
"success": "green",
|
|
27
|
+
"error": "red",
|
|
28
|
+
"warning": "yellow",
|
|
29
|
+
"muted": "gray",
|
|
30
|
+
"dim": "dimGray",
|
|
31
|
+
"text": "",
|
|
32
|
+
"thinkingText": "gray",
|
|
33
|
+
|
|
34
|
+
"selectedBg": "selectedBg",
|
|
35
|
+
"userMessageBg": "userMsgBg",
|
|
36
|
+
"userMessageText": "",
|
|
37
|
+
"customMessageBg": "customMsgBg",
|
|
38
|
+
"customMessageText": "",
|
|
39
|
+
"customMessageLabel": "#9575cd",
|
|
40
|
+
"toolPendingBg": "toolPendingBg",
|
|
41
|
+
"toolSuccessBg": "toolSuccessBg",
|
|
42
|
+
"toolErrorBg": "toolErrorBg",
|
|
43
|
+
"toolTitle": "",
|
|
44
|
+
"toolOutput": "gray",
|
|
45
|
+
|
|
46
|
+
"mdHeading": "#f0c674",
|
|
47
|
+
"mdLink": "#81a2be",
|
|
48
|
+
"mdLinkUrl": "dimGray",
|
|
49
|
+
"mdCode": "accent",
|
|
50
|
+
"mdCodeBlock": "green",
|
|
51
|
+
"mdCodeBlockBorder": "gray",
|
|
52
|
+
"mdQuote": "gray",
|
|
53
|
+
"mdQuoteBorder": "gray",
|
|
54
|
+
"mdHr": "gray",
|
|
55
|
+
"mdListBullet": "accent",
|
|
56
|
+
|
|
57
|
+
"toolDiffAdded": "green",
|
|
58
|
+
"toolDiffRemoved": "red",
|
|
59
|
+
"toolDiffContext": "gray",
|
|
60
|
+
|
|
61
|
+
"syntaxComment": "#6A9955",
|
|
62
|
+
"syntaxKeyword": "#569CD6",
|
|
63
|
+
"syntaxFunction": "#DCDCAA",
|
|
64
|
+
"syntaxVariable": "#9CDCFE",
|
|
65
|
+
"syntaxString": "#CE9178",
|
|
66
|
+
"syntaxNumber": "#B5CEA8",
|
|
67
|
+
"syntaxType": "#4EC9B0",
|
|
68
|
+
"syntaxOperator": "#D4D4D4",
|
|
69
|
+
"syntaxPunctuation": "#D4D4D4",
|
|
70
|
+
|
|
71
|
+
"thinkingOff": "darkGray",
|
|
72
|
+
"thinkingMinimal": "#6e6e6e",
|
|
73
|
+
"thinkingLow": "#5f87af",
|
|
74
|
+
"thinkingMedium": "#81a2be",
|
|
75
|
+
"thinkingHigh": "#b294bb",
|
|
76
|
+
"thinkingXhigh": "#d183e8",
|
|
77
|
+
|
|
78
|
+
"bashMode": "green"
|
|
79
|
+
},
|
|
80
|
+
"export": {
|
|
81
|
+
"pageBg": "#18181e",
|
|
82
|
+
"cardBg": "#1e1e24",
|
|
83
|
+
"infoBg": "#3c3728"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/badlogic/pi-mono/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
|
3
|
+
"name": "light",
|
|
4
|
+
"vars": {
|
|
5
|
+
"teal": "#5a8080",
|
|
6
|
+
"blue": "#547da7",
|
|
7
|
+
"green": "#588458",
|
|
8
|
+
"red": "#aa5555",
|
|
9
|
+
"yellow": "#9a7326",
|
|
10
|
+
"mediumGray": "#6c6c6c",
|
|
11
|
+
"dimGray": "#767676",
|
|
12
|
+
"lightGray": "#b0b0b0",
|
|
13
|
+
"selectedBg": "#d0d0e0",
|
|
14
|
+
"userMsgBg": "#e8e8e8",
|
|
15
|
+
"toolPendingBg": "#e8e8f0",
|
|
16
|
+
"toolSuccessBg": "#e8f0e8",
|
|
17
|
+
"toolErrorBg": "#f0e8e8",
|
|
18
|
+
"customMsgBg": "#ede7f6"
|
|
19
|
+
},
|
|
20
|
+
"colors": {
|
|
21
|
+
"accent": "teal",
|
|
22
|
+
"border": "blue",
|
|
23
|
+
"borderAccent": "teal",
|
|
24
|
+
"borderMuted": "lightGray",
|
|
25
|
+
"success": "green",
|
|
26
|
+
"error": "red",
|
|
27
|
+
"warning": "yellow",
|
|
28
|
+
"muted": "mediumGray",
|
|
29
|
+
"dim": "dimGray",
|
|
30
|
+
"text": "",
|
|
31
|
+
"thinkingText": "mediumGray",
|
|
32
|
+
|
|
33
|
+
"selectedBg": "selectedBg",
|
|
34
|
+
"userMessageBg": "userMsgBg",
|
|
35
|
+
"userMessageText": "",
|
|
36
|
+
"customMessageBg": "customMsgBg",
|
|
37
|
+
"customMessageText": "",
|
|
38
|
+
"customMessageLabel": "#7e57c2",
|
|
39
|
+
"toolPendingBg": "toolPendingBg",
|
|
40
|
+
"toolSuccessBg": "toolSuccessBg",
|
|
41
|
+
"toolErrorBg": "toolErrorBg",
|
|
42
|
+
"toolTitle": "",
|
|
43
|
+
"toolOutput": "mediumGray",
|
|
44
|
+
|
|
45
|
+
"mdHeading": "yellow",
|
|
46
|
+
"mdLink": "blue",
|
|
47
|
+
"mdLinkUrl": "dimGray",
|
|
48
|
+
"mdCode": "teal",
|
|
49
|
+
"mdCodeBlock": "green",
|
|
50
|
+
"mdCodeBlockBorder": "mediumGray",
|
|
51
|
+
"mdQuote": "mediumGray",
|
|
52
|
+
"mdQuoteBorder": "mediumGray",
|
|
53
|
+
"mdHr": "mediumGray",
|
|
54
|
+
"mdListBullet": "green",
|
|
55
|
+
|
|
56
|
+
"toolDiffAdded": "green",
|
|
57
|
+
"toolDiffRemoved": "red",
|
|
58
|
+
"toolDiffContext": "mediumGray",
|
|
59
|
+
|
|
60
|
+
"syntaxComment": "#008000",
|
|
61
|
+
"syntaxKeyword": "#0000FF",
|
|
62
|
+
"syntaxFunction": "#795E26",
|
|
63
|
+
"syntaxVariable": "#001080",
|
|
64
|
+
"syntaxString": "#A31515",
|
|
65
|
+
"syntaxNumber": "#098658",
|
|
66
|
+
"syntaxType": "#267F99",
|
|
67
|
+
"syntaxOperator": "#000000",
|
|
68
|
+
"syntaxPunctuation": "#000000",
|
|
69
|
+
|
|
70
|
+
"thinkingOff": "lightGray",
|
|
71
|
+
"thinkingMinimal": "#767676",
|
|
72
|
+
"thinkingLow": "blue",
|
|
73
|
+
"thinkingMedium": "teal",
|
|
74
|
+
"thinkingHigh": "#875f87",
|
|
75
|
+
"thinkingXhigh": "#8b008b",
|
|
76
|
+
|
|
77
|
+
"bashMode": "green"
|
|
78
|
+
},
|
|
79
|
+
"export": {
|
|
80
|
+
"pageBg": "#f8f8f8",
|
|
81
|
+
"cardBg": "#ffffff",
|
|
82
|
+
"infoBg": "#fffae6"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "ORIENT Coding Agent Theme",
|
|
4
|
+
"description": "Theme schema for ORIENT 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
|
+
}
|
|
@@ -11,7 +11,7 @@ const TOOLS_DIR = getBinDir();
|
|
|
11
11
|
const NETWORK_TIMEOUT_MS = 10_000;
|
|
12
12
|
const DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
13
13
|
function isOfflineModeEnabled() {
|
|
14
|
-
const value = process.env.PI_OFFLINE;
|
|
14
|
+
const value = process.env.ORIENT_OFFLINE || process.env.PI_OFFLINE;
|
|
15
15
|
if (!value)
|
|
16
16
|
return false;
|
|
17
17
|
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA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AM,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import chalk from \"chalk\";\nimport { spawnSync } from \"child_process\";\nimport extractZip from \"extract-zip\";\nimport { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from \"fs\";\nimport { arch, platform } from \"os\";\nimport { join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { APP_NAME, getBinDir } from \"../config.js\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, plat: string, architecture: string) => string | null;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-unknown-linux-gnu.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tif (architecture === \"arm64\") {\n\t\t\t\t\treturn `ripgrep-${version}-aarch64-unknown-linux-gnu.tar.gz`;\n\t\t\t\t}\n\t\t\t\treturn `ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tif (commandExists(config.binaryName)) {\n\t\treturn config.binaryName;\n\t}\n\n\treturn null;\n}\n\n// Fetch latest release version from GitHub\nasync function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {\n\t\theaders: { \"User-Agent\": `${APP_NAME}-coding-agent` },\n\t\tsignal: AbortSignal.timeout(NETWORK_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub API error: ${response.status}`);\n\t}\n\n\tconst data = (await response.json()) as { tag_name: string };\n\treturn data.tag_name.replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Failed to download: ${response.status}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\n// Download and install a tool\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\n\t// Get latest version\n\tconst version = await getLatestVersion(config.repo);\n\n\t// Get asset name for this platform\n\tconst assetName = config.getAssetName(version, plat, architecture);\n\tif (!assetName) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\tconst extractResult = spawnSync(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir], { stdio: \"pipe\" });\n\t\t\tif (extractResult.error || extractResult.status !== 0) {\n\t\t\t\tconst errMsg = extractResult.error?.message ?? extractResult.stderr?.toString().trim() ?? \"unknown error\";\n\t\t\t\tthrow new Error(`Failed to extract ${assetName}: ${errMsg}`);\n\t\t\t}\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\tawait extractZip(archivePath, { dir: extractDir });\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\n// Ensure a tool is available, downloading if necessary\n// Returns the path to the tool, or null if unavailable\nexport async function ensureTool(tool: \"fd\" | \"rg\", silent: boolean = false): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tif (!silent) {\n\t\tconsole.log(chalk.dim(`${config.name} not found. Downloading...`));\n\t}\n\n\ttry {\n\t\tconst path = await downloadTool(tool);\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(`${config.name} installed to ${path}`));\n\t\t}\n\t\treturn path;\n\t} catch (e) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,E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I,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import chalk from \"chalk\";\nimport { spawnSync } from \"child_process\";\nimport extractZip from \"extract-zip\";\nimport { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from \"fs\";\nimport { arch, platform } from \"os\";\nimport { join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { APP_NAME, getBinDir } from \"../config.js\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.ORIENT_OFFLINE || process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, plat: string, architecture: string) => string | null;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-unknown-linux-gnu.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tif (architecture === \"arm64\") {\n\t\t\t\t\treturn `ripgrep-${version}-aarch64-unknown-linux-gnu.tar.gz`;\n\t\t\t\t}\n\t\t\t\treturn `ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tif (commandExists(config.binaryName)) {\n\t\treturn config.binaryName;\n\t}\n\n\treturn null;\n}\n\n// Fetch latest release version from GitHub\nasync function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {\n\t\theaders: { \"User-Agent\": `${APP_NAME}-coding-agent` },\n\t\tsignal: AbortSignal.timeout(NETWORK_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub API error: ${response.status}`);\n\t}\n\n\tconst data = (await response.json()) as { tag_name: string };\n\treturn data.tag_name.replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Failed to download: ${response.status}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\n// Download and install a tool\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\n\t// Get latest version\n\tconst version = await getLatestVersion(config.repo);\n\n\t// Get asset name for this platform\n\tconst assetName = config.getAssetName(version, plat, architecture);\n\tif (!assetName) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\tconst extractResult = spawnSync(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir], { stdio: \"pipe\" });\n\t\t\tif (extractResult.error || extractResult.status !== 0) {\n\t\t\t\tconst errMsg = extractResult.error?.message ?? extractResult.stderr?.toString().trim() ?? \"unknown error\";\n\t\t\t\tthrow new Error(`Failed to extract ${assetName}: ${errMsg}`);\n\t\t\t}\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\tawait extractZip(archivePath, { dir: extractDir });\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\n// Ensure a tool is available, downloading if necessary\n// Returns the path to the tool, or null if unavailable\nexport async function ensureTool(tool: \"fd\" | \"rg\", silent: boolean = false): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tif (!silent) {\n\t\tconsole.log(chalk.dim(`${config.name} not found. Downloading...`));\n\t}\n\n\ttry {\n\t\tconst path = await downloadTool(tool);\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(`${config.name} installed to ${path}`));\n\t\t}\n\t\treturn path;\n\t} catch (e) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|