dimcode 0.0.65 → 0.0.66-beta.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.
Files changed (42) hide show
  1. package/bin/dim.mjs +180 -0
  2. package/dist/ink.mjs +1340 -0
  3. package/package.json +12 -69
  4. package/README.md +0 -451
  5. package/cli.mjs +0 -99
  6. package/dist/aihubmix.json +0 -1
  7. package/dist/anthropic.json +0 -1
  8. package/dist/ark-code.json +0 -1
  9. package/dist/bailian-coding-plan.json +0 -1
  10. package/dist/cli.mjs +0 -1250
  11. package/dist/custom-provider.json +0 -1
  12. package/dist/deepseek.json +0 -1
  13. package/dist/google.json +0 -1
  14. package/dist/kimi-for-coding.json +0 -1
  15. package/dist/lm-studio.json +0 -1
  16. package/dist/minimax-cn-coding-plan.json +0 -1
  17. package/dist/minimax-cn.json +0 -1
  18. package/dist/minimax-coding-plan.json +0 -1
  19. package/dist/minimax.json +0 -1
  20. package/dist/models/aihubmix.json +0 -1
  21. package/dist/models/custom-provider.json +0 -1
  22. package/dist/models/openrouter.json +0 -1
  23. package/dist/models/siliconflow-com.json +0 -1
  24. package/dist/models/siliconflow.json +0 -1
  25. package/dist/models/zenmux.json +0 -1
  26. package/dist/moonshot-ai.json +0 -1
  27. package/dist/moonshot.json +0 -1
  28. package/dist/next-api-oauth.json +0 -1
  29. package/dist/ollama.json +0 -1
  30. package/dist/openai.json +0 -1
  31. package/dist/openrouter.json +0 -1
  32. package/dist/ppinfra.json +0 -1
  33. package/dist/siliconflow-com.json +0 -1
  34. package/dist/siliconflow.json +0 -1
  35. package/dist/xai.json +0 -1
  36. package/dist/xiaomi-token-plan-cn.json +0 -1
  37. package/dist/zai-coding-plan.json +0 -1
  38. package/dist/zai.json +0 -1
  39. package/dist/zenmux.json +0 -1
  40. package/dist/zhipuai-coding-plan.json +0 -1
  41. package/dist/zhipuai.json +0 -1
  42. package/icon.png +0 -0
package/package.json CHANGED
@@ -1,78 +1,21 @@
1
1
  {
2
2
  "name": "dimcode",
3
+ "version": "0.0.66-beta.0",
4
+ "description": "AI coding agent CLI and terminal coding assistant with an interactive TUI (beta channel)",
3
5
  "type": "module",
4
- "version": "0.0.65",
5
- "description": "AI coding agent CLI and terminal coding assistant with an interactive TUI",
6
- "exports": {
7
- ".": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.js"
10
- },
11
- "./cli": {
12
- "types": "./dist/cli.d.ts",
13
- "import": "./dist/cli.js"
14
- }
15
- },
16
- "imports": {
17
- "#cli/*": "./src/*"
18
- },
19
- "main": "./dist/index.js",
20
- "types": "./dist/index.d.ts",
21
6
  "bin": {
22
- "dim": "./cli.mjs",
23
- "dimcode": "./cli.mjs"
7
+ "dim": "./bin/dim.mjs",
8
+ "dimcode": "./bin/dim.mjs"
24
9
  },
25
10
  "files": [
26
- "assets",
27
- "cli.mjs",
28
- "dist",
29
- "icon.png"
11
+ "bin",
12
+ "dist"
30
13
  ],
31
- "scripts": {
32
- "build": "bun run build.mjs",
33
- "build:npm": "bun run build-npm.mjs",
34
- "build:binary": "bun run build.mjs --binary",
35
- "build:binary:macos": "bun run build.mjs --binary --target=bun-darwin-arm64",
36
- "build:binary:macos-x64": "bun run build.mjs --binary --target=bun-darwin-x64",
37
- "build:binary:linux": "bun run build.mjs --binary --target=bun-linux-x64",
38
- "build:binary:linux-arm64": "bun run build.mjs --binary --target=bun-linux-arm64",
39
- "build:binary:windows": "bun run build.mjs --binary --target=bun-windows-x64",
40
- "typecheck": "node ../../scripts/check-public-agent-imports.mjs ./src && tsc --noEmit",
41
- "cli": "bun scripts/cli-watch.mjs",
42
- "cli:run": "esno src/cli.ts",
43
- "cli:run:node": "node --enable-source-maps --import tsx src/cli.ts",
44
- "bench:scroll": "bun scripts/scroll-benchmark.ts",
45
- "bench:layout": "bun scripts/layout-benchmark.ts",
46
- "bench:stdout": "bun scripts/stdout-benchmark.ts",
47
- "test": "bun test --preload ./test/setup.ts",
48
- "smoke": "bun run build && bun dist/cli.mjs --help",
49
- "lint": "eslint src/**/*.ts",
50
- "lint:fix": "eslint src/**/*.ts --fix",
51
- "prepack": "bun run build",
52
- "fix-package": "bun run fix-package.mjs",
53
- "restore-package": "bun run restore-package.mjs",
54
- "release": "bumpp --commit --no-verify --no-tag --no-push && bun run build && bun publish",
55
- "release:npm": "bumpp --commit --no-verify --no-tag --no-push && bun run build:npm && npm publish"
56
- },
57
- "dependencies": {
58
- "cross-spawn": "^7.0.6",
59
- "nanoid": "^5.1.7",
60
- "node-notifier": "^10.0.1",
61
- "semver": "^7.7.4",
62
- "shiki": "^3.23.0",
63
- "undici": "^6.21.0",
64
- "vue": "^3.5.30"
65
- },
66
- "devDependencies": {
67
- "@simon_he/vue-tui": "0.0.7",
68
- "@types/node": "^18.19.130",
69
- "@types/node-notifier": "^8.0.5",
70
- "@types/semver": "^7.7.1",
71
- "chokidar": "^4.0.3",
72
- "happy-dom": "^17.6.3",
73
- "bun-types": "latest",
74
- "tsdown": "^0.20.3",
75
- "typescript": "^5.9.3",
76
- "vitest": "^4.1.0"
14
+ "optionalDependencies": {
15
+ "dimcode-darwin-arm64": "0.0.66-beta.0",
16
+ "dimcode-darwin-x64": "0.0.66-beta.0",
17
+ "dimcode-linux-arm64": "0.0.66-beta.0",
18
+ "dimcode-linux-x64": "0.0.66-beta.0",
19
+ "dimcode-windows-x64": "0.0.66-beta.0"
77
20
  }
78
21
  }
package/README.md DELETED
@@ -1,451 +0,0 @@
1
- # Dimcode
2
-
3
- AI coding agent CLI with an interactive terminal UI, one-shot execution, session history, MCP connectors, plugins, skills, and built-in model provider management.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g dimcode
9
- ```
10
-
11
- After installation, run the CLI with either binary:
12
-
13
- ```bash
14
- dim
15
- dimcode
16
- ```
17
-
18
- ## Quick Start
19
-
20
- Start the interactive TUI:
21
-
22
- ```bash
23
- dim
24
- ```
25
-
26
- Inside the TUI:
27
-
28
- ```text
29
- /connect connect a model provider
30
- /models select the active model
31
- hello start chatting
32
- ```
33
-
34
- ## One-shot Execution
35
-
36
- Run a prompt and exit:
37
-
38
- ```bash
39
- dim "Run the tests and fix any failures"
40
- ```
41
-
42
- Run from a specific project directory:
43
-
44
- ```bash
45
- dim --cwd ./my-project --no-interaction "Refactor the auth middleware"
46
- ```
47
-
48
- Read the prompt from stdin:
49
-
50
- ```bash
51
- printf "Summarize this repository" | dim --no-interaction
52
- ```
53
-
54
- Reuse a known session id:
55
-
56
- ```bash
57
- dim --session my-session "Continue the previous task"
58
- ```
59
-
60
- One-shot mode auto-approves tools and prints the final answer to stdout. `--no-interaction` disables follow-up questions and runs in agent mode.
61
-
62
- ## Interactive Commands
63
-
64
- Type `/` in the TUI to open command suggestions. Press `Ctrl+P` for the command palette and `F1` for help.
65
-
66
- | Command | Action |
67
- | -------------------- | ------------------------------------------------ |
68
- | `/sessions` | List, switch, or delete saved sessions |
69
- | `/new` | Start a new session |
70
- | `/timeline` or `/tl` | Jump to a user message in the current session |
71
- | `/resume` | Resume a paused queue |
72
- | `/compact` | Compact the current session context |
73
- | `/redo` | Redo after reverting messages |
74
- | `/rename <title>` | Rename the current session |
75
- | `/connect` | Connect or switch model providers |
76
- | `/models` | Select the active model |
77
- | `/settings` | Edit custom provider settings |
78
- | `/approvals` | Configure tool approval mode |
79
- | `/mcp` | Manage MCP connectors |
80
- | `/plugins` | Manage plugins |
81
- | `/debug` | Configure SDK observability JSONL logs |
82
- | `/language` | Switch UI language |
83
- | `/theme` | Switch the UI theme |
84
- | `/skills` | View and activate loaded skills |
85
- | `/review` | Ask Dimcode to review current code changes |
86
- | `/init` | Ask Dimcode to initialize or improve `AGENTS.md` |
87
- | `/exit` | Exit the application |
88
-
89
- ## CLI Commands
90
-
91
- ```bash
92
- dim version # Print version info
93
- dim upgrade [version] # Upgrade the CLI
94
- dim acp # Start the ACP server for editor integrations
95
- ```
96
-
97
- Auto-update checks run by default. Set `DIMCODE_DISABLE_AUTOUPDATE=1` to disable them.
98
-
99
- `dim upgrade` tracks the current release channel. Pass an explicit npm version to switch channels:
100
-
101
- ```bash
102
- npm install -g dimcode@1.2.0-beta.3
103
- ```
104
-
105
- ## Options
106
-
107
- ```text
108
- Usage:
109
- dim Interactive TUI
110
- dim [--cwd dir] [--session id] [--debug dir] [--no-interaction] "prompt"
111
- One-shot execution
112
- dim version
113
- dim upgrade [version]
114
- dim acp
115
-
116
- Options:
117
- --approvals auto|normal|strict Tool approval mode for the TUI
118
- --auto-approve, --yes, -y Shorthand for --approvals auto
119
- --cwd, -c, -cwd, --chdir <dir> Working directory for one-shot execution
120
- --session, -s <id> Session id for one-shot execution
121
- --no-interaction One-shot mode with follow-up questions disabled
122
- --debug <dir> Write SDK observability logs for this run
123
- -h, --help Show CLI help
124
- ```
125
-
126
- The interactive TUI starts with `normal` approvals. One-shot execution sets tool approvals to `auto`.
127
-
128
- ## Configuration
129
-
130
- Dimcode stores user data under `~/.dimcode` by default:
131
-
132
- | Path | Purpose |
133
- | ------------------------------- | --------------------------------------------- |
134
- | `~/.dimcode/config.json` | Provider, model, and custom provider settings |
135
- | `~/.dimcode/tools.json` | Tool-specific settings such as WebSearch |
136
- | `~/.dimcode/mcp.json` | MCP server settings |
137
- | `~/.dimcode/dimcode/cache.json` | UI cache and recent settings |
138
- | `~/.dimcode/state/` | Session state, uploads, and runtime artifacts |
139
-
140
- Move the whole config home with:
141
-
142
- ```bash
143
- export DIMCODE_HOME=/path/to/dimcode-home
144
- ```
145
-
146
- Move runtime state only with:
147
-
148
- ```bash
149
- export DIMCODE_STATE_DIR=/path/to/state
150
- ```
151
-
152
- Daily configuration is available in the TUI:
153
-
154
- | Entry | Purpose |
155
- | ------------ | ------------------------------------------------------- |
156
- | `/connect` | Configure provider API keys and editable base URLs |
157
- | `/models` | Select the model for the active provider |
158
- | `/settings` | Manage custom providers and advanced model parameters |
159
- | `/mcp` | Edit and load MCP connectors |
160
- | `/approvals` | Choose `auto`, `normal`, or `strict` tool approvals |
161
- | `/debug` | Choose `Off`, `On`, or `Auto` SDK observability logging |
162
-
163
- Debug logs are written as JSONL files at `<debug-dir>/<session-id>.jsonl`.
164
-
165
- ## Model Providers
166
-
167
- Built-in providers include OpenAI, DimCode OAuth, OpenRouter, Aihubmix, Model Studio Coding Plan, ZhipuAI, Z.AI, DeepSeek, ZenMux, Moonshot, Kimi For Coding, Google, Anthropic, SiliconFlow, PPInfra, Ark Code, Ollama, LM Studio, xAI, Xiaomi Token Plan, and MiniMax variants.
168
-
169
- Custom providers support OpenAI-compatible, OpenAI Responses, Gemini, and Anthropic adapters. Built-in base URLs are editable for OpenAI, Anthropic, Google, Ollama, and LM Studio.
170
-
171
- ## MCP, Plugins, and Skills
172
-
173
- `/mcp` manages stdio, HTTP, and SSE MCP servers from `~/.dimcode/mcp.json`.
174
-
175
- `/plugins` manages installed plugins.
176
-
177
- The command palette also includes Tool Settings for the WebSearch API key.
178
-
179
- `/skills` lists loaded skills. Mention a skill with `$skill-name` in the prompt to force it for that turn.
180
-
181
- ## Keyboard Shortcuts
182
-
183
- | Shortcut | Action |
184
- | ------------------------ | ------------------------------------- |
185
- | `F1` | Open help |
186
- | `Ctrl+P` | Open command palette |
187
- | `Ctrl+K` | Open settings |
188
- | `Ctrl+O` | Expand or collapse tools and thinking |
189
- | `Tab` | Switch mode or focus |
190
- | `Shift+Enter` / `Ctrl+J` | Insert a newline |
191
- | `Cmd+Delete` / `Ctrl+W` | Clear input |
192
- | `Ctrl+Click` | Open files or links |
193
- | `Esc` | Cancel the current dialog or action |
194
-
195
- The command palette, timeline, and new session shortcuts can be customized in settings.
196
-
197
- ## Editor Integration
198
-
199
- Start the ACP server:
200
-
201
- ```bash
202
- dim acp
203
- ```
204
-
205
- Example Zed settings:
206
-
207
- ```json
208
- {
209
- "agent_servers": {
210
- "dimcode": {
211
- "command": "dim",
212
- "args": ["acp"]
213
- }
214
- }
215
- }
216
- ```
217
-
218
- ## Help
219
-
220
- ```bash
221
- dim --help
222
- ```
223
-
224
- Inside the TUI, press `F1`.
225
-
226
- ---
227
-
228
- # Dimcode 中文版
229
-
230
- Dimcode 是一个 AI 编程助手 CLI,提供交互式终端 UI、单次执行、会话历史、MCP 连接器、插件、Skills,以及内置模型提供方管理。
231
-
232
- ## 安装
233
-
234
- ```bash
235
- npm install -g dimcode
236
- ```
237
-
238
- 安装后可使用任一命令运行:
239
-
240
- ```bash
241
- dim
242
- dimcode
243
- ```
244
-
245
- ## 快速开始
246
-
247
- 启动交互式 TUI:
248
-
249
- ```bash
250
- dim
251
- ```
252
-
253
- 进入 TUI 后:
254
-
255
- ```text
256
- /connect 连接模型提供方
257
- /models 选择当前模型
258
- hello 开始对话
259
- ```
260
-
261
- ## 单次执行
262
-
263
- 执行提示词并退出:
264
-
265
- ```bash
266
- dim "Run the tests and fix any failures"
267
- ```
268
-
269
- 在指定项目目录运行:
270
-
271
- ```bash
272
- dim --cwd ./my-project --no-interaction "Refactor the auth middleware"
273
- ```
274
-
275
- 从 stdin 读取提示词:
276
-
277
- ```bash
278
- printf "Summarize this repository" | dim --no-interaction
279
- ```
280
-
281
- 复用指定会话 id:
282
-
283
- ```bash
284
- dim --session my-session "Continue the previous task"
285
- ```
286
-
287
- 单次执行模式会自动批准工具调用,并将最终回答输出到 stdout。`--no-interaction` 会关闭追问并使用 agent 模式。
288
-
289
- ## 交互命令
290
-
291
- 在 TUI 中输入 `/` 可打开命令建议。按 `Ctrl+P` 打开命令面板,按 `F1` 打开帮助。
292
-
293
- | 命令 | 功能 |
294
- | -------------------- | ----------------------------------- |
295
- | `/sessions` | 列出、切换或删除已保存会话 |
296
- | `/new` | 开始新会话 |
297
- | `/timeline` 或 `/tl` | 跳转到当前会话中的用户消息 |
298
- | `/resume` | 恢复已暂停队列 |
299
- | `/compact` | 压缩当前会话上下文 |
300
- | `/redo` | 在消息回退后重做 |
301
- | `/rename <title>` | 重命名当前会话 |
302
- | `/connect` | 连接或切换模型提供方 |
303
- | `/models` | 选择当前模型 |
304
- | `/settings` | 编辑自定义提供方设置 |
305
- | `/approvals` | 配置工具审批模式 |
306
- | `/mcp` | 管理 MCP 连接器 |
307
- | `/plugins` | 管理插件 |
308
- | `/debug` | 配置 SDK observability JSONL 日志 |
309
- | `/language` | 切换界面语言 |
310
- | `/theme` | 切换界面主题 |
311
- | `/skills` | 查看并启用已加载 Skills |
312
- | `/review` | 让 Dimcode 审查当前代码变更 |
313
- | `/init` | 让 Dimcode 初始化或改进 `AGENTS.md` |
314
- | `/exit` | 退出应用 |
315
-
316
- ## CLI 命令
317
-
318
- ```bash
319
- dim version # Print version info
320
- dim upgrade [version] # Upgrade the CLI
321
- dim acp # Start the ACP server for editor integrations
322
- ```
323
-
324
- 自动更新检查默认开启。设置 `DIMCODE_DISABLE_AUTOUPDATE=1` 可关闭。
325
-
326
- `dim upgrade` 会跟随当前发布通道。传入明确 npm 版本可切换通道:
327
-
328
- ```bash
329
- npm install -g dimcode@1.2.0-beta.3
330
- ```
331
-
332
- ## 选项
333
-
334
- ```text
335
- Usage:
336
- dim Interactive TUI
337
- dim [--cwd dir] [--session id] [--debug dir] [--no-interaction] "prompt"
338
- One-shot execution
339
- dim version
340
- dim upgrade [version]
341
- dim acp
342
-
343
- Options:
344
- --approvals auto|normal|strict Tool approval mode for the TUI
345
- --auto-approve, --yes, -y Shorthand for --approvals auto
346
- --cwd, -c, -cwd, --chdir <dir> Working directory for one-shot execution
347
- --session, -s <id> Session id for one-shot execution
348
- --no-interaction One-shot mode with follow-up questions disabled
349
- --debug <dir> Write SDK observability logs for this run
350
- -h, --help Show CLI help
351
- ```
352
-
353
- 交互式 TUI 默认使用 `normal` 审批模式。单次执行会将工具审批设为 `auto`。
354
-
355
- ## 配置
356
-
357
- Dimcode 默认将用户数据保存到 `~/.dimcode`:
358
-
359
- | 路径 | 用途 |
360
- | ------------------------------- | ------------------------------ |
361
- | `~/.dimcode/config.json` | 提供方、模型、自定义提供方设置 |
362
- | `~/.dimcode/tools.json` | WebSearch 等工具级设置 |
363
- | `~/.dimcode/mcp.json` | MCP server 设置 |
364
- | `~/.dimcode/dimcode/cache.json` | UI 缓存和最近设置 |
365
- | `~/.dimcode/state/` | 会话状态、上传文件、运行时产物 |
366
-
367
- 移动完整配置目录:
368
-
369
- ```bash
370
- export DIMCODE_HOME=/path/to/dimcode-home
371
- ```
372
-
373
- 单独移动运行时状态目录:
374
-
375
- ```bash
376
- export DIMCODE_STATE_DIR=/path/to/state
377
- ```
378
-
379
- 日常配置可在 TUI 中完成:
380
-
381
- | 入口 | 用途 |
382
- | ------------ | ------------------------------------------------- |
383
- | `/connect` | 配置提供方 API key 和可编辑 base URL |
384
- | `/models` | 为当前提供方选择模型 |
385
- | `/settings` | 管理自定义提供方和高级模型参数 |
386
- | `/mcp` | 编辑并加载 MCP 连接器 |
387
- | `/approvals` | 选择 `auto`、`normal` 或 `strict` 工具审批 |
388
- | `/debug` | 选择 `Off`、`On` 或 `Auto` SDK observability 日志 |
389
-
390
- Debug 日志会以 JSONL 写入 `<debug-dir>/<session-id>.jsonl`。
391
-
392
- ## 模型提供方
393
-
394
- 内置提供方包括 OpenAI、DimCode OAuth、OpenRouter、Aihubmix、Model Studio Coding Plan、ZhipuAI、Z.AI、DeepSeek、ZenMux、Moonshot、Kimi For Coding、Google、Anthropic、SiliconFlow、PPInfra、Ark Code、Ollama、LM Studio、xAI、Xiaomi Token Plan、MiniMax 等变体。
395
-
396
- 自定义提供方支持 OpenAI-compatible、OpenAI Responses、Gemini、Anthropic adapters。OpenAI、Anthropic、Google、Ollama、LM Studio 的内置 base URL 可编辑。
397
-
398
- ## MCP、插件与 Skills
399
-
400
- `/mcp` 会从 `~/.dimcode/mcp.json` 管理 stdio、HTTP、SSE MCP servers。
401
-
402
- `/plugins` 用于管理已安装插件。
403
-
404
- 命令面板中的 Tool Settings 可配置 WebSearch API key。
405
-
406
- `/skills` 用于查看已加载 Skills。在提示词中使用 `$skill-name` 可为当前轮次指定 Skill。
407
-
408
- ## 快捷键
409
-
410
- | 快捷键 | 功能 |
411
- | ------------------------ | ------------------------- |
412
- | `F1` | 打开帮助 |
413
- | `Ctrl+P` | 打开命令面板 |
414
- | `Ctrl+K` | 打开设置 |
415
- | `Ctrl+O` | 展开或收起工具与 thinking |
416
- | `Tab` | 切换模式或焦点 |
417
- | `Shift+Enter` / `Ctrl+J` | 输入换行 |
418
- | `Cmd+Delete` / `Ctrl+W` | 清空输入 |
419
- | `Ctrl+Click` | 打开文件或链接 |
420
- | `Esc` | 取消当前对话框或操作 |
421
-
422
- 命令面板、时间线、新会话快捷键可在设置中自定义。
423
-
424
- ## 编辑器集成
425
-
426
- 启动 ACP server:
427
-
428
- ```bash
429
- dim acp
430
- ```
431
-
432
- Zed 配置示例:
433
-
434
- ```json
435
- {
436
- "agent_servers": {
437
- "dimcode": {
438
- "command": "dim",
439
- "args": ["acp"]
440
- }
441
- }
442
- }
443
- ```
444
-
445
- ## 获取帮助
446
-
447
- ```bash
448
- dim --help
449
- ```
450
-
451
- 在 TUI 内按 `F1`。
package/cli.mjs DELETED
@@ -1,99 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn, spawnSync } from 'node:child_process'
4
- import { existsSync } from 'node:fs'
5
- import path from 'node:path'
6
- import process from 'node:process'
7
- import { fileURLToPath } from 'node:url'
8
-
9
- const cliPath = fileURLToPath(import.meta.url)
10
- const cliDir = path.dirname(cliPath)
11
- const sourceEntry = path.join(cliDir, 'src', 'cli.ts')
12
- const bundledEntry = path.join(cliDir, 'dist', 'cli.mjs')
13
- const sourceEntryUrl = new URL('./src/cli.ts', import.meta.url).href
14
- const bundledEntryUrl = new URL('./dist/cli.mjs', import.meta.url).href
15
-
16
- function resolveBunCommand() {
17
- return process.env.BUN_BIN?.trim() || 'bun'
18
- }
19
-
20
- function canRelayToBunSource() {
21
- if (typeof globalThis.Bun !== 'undefined')
22
- return false
23
- if (!existsSync(sourceEntry))
24
- return false
25
-
26
- const probe = spawnSync(resolveBunCommand(), ['--version'], { stdio: 'ignore' })
27
- return probe.status === 0
28
- }
29
-
30
- async function installEnvProxyDispatcher() {
31
- // Node's native fetch (undici) ignores HTTP_PROXY/HTTPS_PROXY env vars unless
32
- // a proxy-aware dispatcher is installed. Bun's fetch honors them natively, so
33
- // this is only needed on the Node-bundled path. Skip silently if no proxy env
34
- // is set, or if undici is unavailable.
35
- const env = process.env
36
- const hasProxyEnv = Boolean(
37
- env.HTTP_PROXY || env.http_proxy
38
- || env.HTTPS_PROXY || env.https_proxy
39
- || env.NO_PROXY || env.no_proxy,
40
- )
41
- if (!hasProxyEnv)
42
- return
43
- try {
44
- const { setGlobalDispatcher, EnvHttpProxyAgent } = await import('undici')
45
- setGlobalDispatcher(new EnvHttpProxyAgent())
46
- }
47
- catch (err) {
48
- if (env.DIMCODE_DEBUG === '1' || env.DIMCODE_DEBUG === 'true') {
49
- console.error(
50
- '[dimcode] failed to install EnvHttpProxyAgent:',
51
- err instanceof Error ? err.message : String(err),
52
- )
53
- }
54
- }
55
- }
56
-
57
- async function relayToBunSource() {
58
- const child = spawn(resolveBunCommand(), [cliPath, ...process.argv.slice(2)], {
59
- stdio: 'inherit',
60
- env: process.env,
61
- })
62
-
63
- const forwardSignal = (signal) => {
64
- if (!child.killed)
65
- child.kill(signal)
66
- }
67
-
68
- for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'])
69
- process.on(signal, () => forwardSignal(signal))
70
-
71
- child.on('error', (error) => {
72
- console.error(error)
73
- process.exit(1)
74
- })
75
-
76
- await new Promise((resolve) => {
77
- child.on('exit', (code) => {
78
- process.exit(code ?? 1)
79
- })
80
- child.on('close', () => resolve())
81
- })
82
- }
83
-
84
- if (typeof globalThis.Bun !== 'undefined') {
85
- if (existsSync(bundledEntry))
86
- await import(bundledEntryUrl)
87
- else {
88
- const { main } = await import(sourceEntryUrl)
89
- await main()
90
- }
91
- }
92
- else if (canRelayToBunSource()) {
93
- // In source checkouts, prefer Bun so `node .../cli.mjs` uses the current TS sources.
94
- await relayToBunSource()
95
- }
96
- else {
97
- await installEnvProxyDispatcher()
98
- await import(bundledEntryUrl)
99
- }
@@ -1 +0,0 @@
1
- {"id":"aihubmix","name":"Aihubmix","api":"https://aihubmix.com/v1","adapter":"openai","modelsFile":"models/aihubmix.json","defaultModelId":"gpt-5.5"}