dgxay-code-cli 0.0.0-stage → 1.1.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/LICENSE +674 -0
- package/README-zh.md +242 -0
- package/README.md +223 -2
- package/bin/dgxay.js +42 -0
- package/package.json +47 -4
- package/src/cli/ansi.js +539 -0
- package/src/cli/approval.js +186 -0
- package/src/cli/args.js +162 -0
- package/src/cli/command-table.js +52 -0
- package/src/cli/editor.js +828 -0
- package/src/cli/i18n.js +276 -0
- package/src/cli/index.js +228 -0
- package/src/cli/print.js +148 -0
- package/src/cli/render.js +395 -0
- package/src/cli/repl-state.js +85 -0
- package/src/cli/repl.js +1231 -0
- package/src/cli/slash.js +75 -0
- package/src/cli/ui.js +52 -0
- package/src/commands/_shared.js +20 -0
- package/src/commands/chat.js +212 -0
- package/src/commands/config.js +363 -0
- package/src/commands/context.js +43 -0
- package/src/commands/doctor.js +192 -0
- package/src/commands/export.js +102 -0
- package/src/commands/mcp.js +257 -0
- package/src/commands/model.js +223 -0
- package/src/commands/oauth.js +246 -0
- package/src/commands/permission.js +108 -0
- package/src/commands/provider.js +332 -0
- package/src/commands/run.js +172 -0
- package/src/commands/skill.js +94 -0
- package/src/commands/workspace.js +100 -0
- package/src/core/agent.js +420 -0
- package/src/core/llm.js +709 -0
- package/src/core/mcp.js +271 -0
- package/src/core/oauth.js +737 -0
- package/src/core/prompt.js +269 -0
- package/src/core/sessions.js +208 -0
- package/src/core/tools.js +391 -0
- package/src/services/config.js +182 -0
- package/src/services/input.js +91 -0
- package/src/services/session-bus.js +104 -0
- package/src/services/settings.js +340 -0
- package/src/services/skills.js +125 -0
- package/src/services/terminal.js +124 -0
- package/src/services/version.js +25 -0
package/README-zh.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# DgxayCode CLI
|
|
2
|
+
|
|
3
|
+
DgxayCode 的命令行版本:一个支持多协议、四档权限、自动审查、技能与 MCP 的 AI 编码助手。
|
|
4
|
+
|
|
5
|
+
桌面版(Electron)的全部能力都搬到了终端里,只去掉了界面:
|
|
6
|
+
|
|
7
|
+
- **三种接口协议**:OpenAI ChatCompletions、Anthropic Messages、OpenAI Responses,可自由切换供应商与模型
|
|
8
|
+
- **工作模式**:读写文件、执行命令、访问网络,先读后写、完成前不停止
|
|
9
|
+
- **四档权限**:无权限 / 普通权限 / 自动审查 / 完全权限,在进程内强制执行
|
|
10
|
+
- **自动审查**:由审查模型判断每次操作,可疑操作转交你确认
|
|
11
|
+
- **会话**:历史持久化、恢复、列表、重命名、删除、导出(最多保留 200 段)
|
|
12
|
+
- **上下文压缩**:`/compress` 用摘要替换历史
|
|
13
|
+
- **技能**:扫描 `~/.dcb/skills`,按会话启用
|
|
14
|
+
- **MCP**:配置、启停、日志
|
|
15
|
+
- **OAuth**:OpenAI / Anthropic / xAI / Google 账户连接(PKCE + 系统浏览器)
|
|
16
|
+
- **自检**:`dgxay doctor` 检查环境与模型连通性
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
需要 **Node.js 18 或更高版本**。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g dgxay-code-cli
|
|
24
|
+
dgxay
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
也可以不安装直接用:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx dgxay-code-cli --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
从源码安装:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/dgxay/DgxayCode.git
|
|
37
|
+
cd DgxayCode-cli
|
|
38
|
+
npm link # 或 npm install -g .
|
|
39
|
+
dgxay --version
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 快速开始
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 1. 首次配置:选择协议、填写 Base URL / API Key / 模型
|
|
46
|
+
dgxay config init
|
|
47
|
+
|
|
48
|
+
# 2. 自检
|
|
49
|
+
dgxay doctor
|
|
50
|
+
|
|
51
|
+
# 3. 进入交互模式
|
|
52
|
+
dgxay
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
一条命令直接提问:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dgxay "把这个目录里的 JSON 合并成一个数组"
|
|
59
|
+
|
|
60
|
+
# 指定工作空间、工作模式、自动审查
|
|
61
|
+
dgxay run -p "给所有 Python 文件补上类型注解" -C ./project -m work --permission auto
|
|
62
|
+
|
|
63
|
+
# 结构化输出,方便接管道
|
|
64
|
+
dgxay run -p "总结这个仓库的架构" -o json | jq -r .text
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 交互模式
|
|
68
|
+
|
|
69
|
+
进入 `dgxay` 后,界面由三部分组成:
|
|
70
|
+
|
|
71
|
+
- **输入框**:一个带边框的方框,宽度随终端自适应,长文本自动折行
|
|
72
|
+
- **命令菜单**:输入 `/` 时在输入框上方/下方弹出,可上下选择
|
|
73
|
+
- **思考区**:模型思考时实时显示计时与思考内容
|
|
74
|
+
|
|
75
|
+
| 输入 | 作用 |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| 直接输入文字 | 发送给模型 |
|
|
78
|
+
| `/` | 弹出命令菜单 |
|
|
79
|
+
| `↑` / `↓` | 菜单打开时选择命令;菜单关闭时 `↑` 回填上一条提问 |
|
|
80
|
+
| `Tab` | 补全当前选中的命令 |
|
|
81
|
+
| `Enter` | 菜单打开时执行选中命令;否则发送消息 |
|
|
82
|
+
| `Esc` | 关闭菜单 |
|
|
83
|
+
| `!命令` | 执行终端命令,输出进入对话上下文,例如 `!git status` |
|
|
84
|
+
| 行尾 `\` | 续行,输入多行消息 |
|
|
85
|
+
| `Ctrl+C` | 生成中中断;空闲时退出;输入框有内容时清空 |
|
|
86
|
+
| `Ctrl+D` | 退出 |
|
|
87
|
+
|
|
88
|
+
### 语言
|
|
89
|
+
|
|
90
|
+
界面默认英文。想切回中文:`DGXAY_LANG=zh dgxay`。
|
|
91
|
+
AI 的回复语言跟随你的提问语言。
|
|
92
|
+
|
|
93
|
+
### 思考过程
|
|
94
|
+
|
|
95
|
+
模型返回思考内容时,终端会实时显示:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
⠿ Thinking 2.4s 当前正在考虑的部分…
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
思考结束后折叠为一行摘要,并把完整思考内容以灰色缩进段落列出:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
⌁ Thought for 12.8s · 1450 chars
|
|
105
|
+
│ 先看一下目录结构……
|
|
106
|
+
│ 然后读入口文件……
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
想只看摘要不显示详细内容:`DGXAY_SHOW_REASONING=0`。
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### 斜杠命令
|
|
113
|
+
|
|
114
|
+
| 命令 | 说明 |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `/help` | 查看全部命令 |
|
|
117
|
+
| `/new` `/list` `/resume <序号>` `/delete <序号>` `/rename <标题>` | 会话管理 |
|
|
118
|
+
| `/compress`(`/压缩`) | 压缩上下文,有损且不可撤销 |
|
|
119
|
+
| `/skill [名称]`(`/技能`) | 列出 / 启用技能 |
|
|
120
|
+
| `/model` `/provider` | 查看或切换模型 / 供应商 |
|
|
121
|
+
| `/mode [chat\|work]` | 切换模式 |
|
|
122
|
+
| `/permission [档位]` | 切换权限 |
|
|
123
|
+
| `/cd <目录>` `/ls` `/pwd` | 工作空间 |
|
|
124
|
+
| `/term <命令>` | 执行终端命令 |
|
|
125
|
+
| `/context` | 上下文用量 |
|
|
126
|
+
| `/mcp [子命令]` | MCP 管理 |
|
|
127
|
+
| `/clear` `/exit` | 清屏 / 退出 |
|
|
128
|
+
|
|
129
|
+
## 子命令
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
dgxay 进入交互模式
|
|
133
|
+
dgxay "问题" 单次执行后退出
|
|
134
|
+
dgxay run 单次执行(-p / -C / -m / --permission / -o json)
|
|
135
|
+
dgxay chat 会话:list / show / resume / rm / rename / clear
|
|
136
|
+
dgxay config init / show / get / set / path / reset
|
|
137
|
+
dgxay provider list / add / edit / rm / use / mv / review
|
|
138
|
+
dgxay model list / use / add / rm / fetch
|
|
139
|
+
dgxay oauth list / connect / disconnect / client
|
|
140
|
+
dgxay mcp list / add / start / stop / logs / rm / env
|
|
141
|
+
dgxay skill list / show / path
|
|
142
|
+
dgxay workspace set / list / clear
|
|
143
|
+
dgxay permission list / set
|
|
144
|
+
dgxay context 查看上下文估算
|
|
145
|
+
dgxay export 导出会话(Markdown / JSON)
|
|
146
|
+
dgxay doctor 自检
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
任何子命令都可以加 `--help` 查看详细用法。
|
|
150
|
+
|
|
151
|
+
## 权限
|
|
152
|
+
|
|
153
|
+
| 档位 | 能力 | 授权 |
|
|
154
|
+
| --- | --- | --- |
|
|
155
|
+
| `none` 无权限 | 只能以只读方式访问工作空间内的文件 | 无 |
|
|
156
|
+
| `normal` 普通权限 | 全部能力 | **每次**操作都要你确认 |
|
|
157
|
+
| `auto` 自动审查 | 全部能力 | 先由审查模型判断,可疑才询问 |
|
|
158
|
+
| `full` 完全权限 | 全部能力 | 不审查、不询问 |
|
|
159
|
+
|
|
160
|
+
- 权限在工具执行层强制校验,改前端(这里是交互层)绕不过去。
|
|
161
|
+
- 自动审查需要给供应商配置审查模型:`dgxay provider review <供应商> --model <模型ID>`;没配置时 `auto` 不可用,会自动回落到 `normal`。
|
|
162
|
+
- 非交互环境(管道输入)遇到需要确认的操作一律拒绝;确实要放行时加 `--yes`。
|
|
163
|
+
- 删除是**永久删除**,不进回收站;批量修改前请先提交 Git。
|
|
164
|
+
|
|
165
|
+
## 数据与配置
|
|
166
|
+
|
|
167
|
+
数据目录:`~/.dcb`(Windows 为 `%USERPROFILE%\.dcb`),与桌面版共用同一份配置与对话。
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
~/.dcb/
|
|
171
|
+
├── config.json # 供应商、模型、审查模型、模式、权限
|
|
172
|
+
├── chats.json # 对话历史(最多 200 段)
|
|
173
|
+
├── oauth.json # OAuth 客户端与账户令牌(0600)
|
|
174
|
+
├── mcp.json # MCP server 配置
|
|
175
|
+
└── skills/ # 技能(SKILL.md 或 name.md)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- API Key 在 `config.json` 中**是明文**;不要把该目录发到公开仓库。
|
|
179
|
+
- 用 `DGXAY_HOME=/tmp/test dgxay` 可以隔离数据目录(桌面版的 `DCB_HOME` 同样兼容)。
|
|
180
|
+
- 如果本机从桌面版迁移,OAuth 令牌由 Electron `safeStorage` 加密,CLI 无法解密,需要重新执行 `dgxay oauth connect <平台>`。
|
|
181
|
+
|
|
182
|
+
## 环境变量
|
|
183
|
+
|
|
184
|
+
| 变量 | 作用 |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| `DGXAY_HOME` | 覆盖数据目录 |
|
|
187
|
+
| `DGXAY_API_KEY` | `config init` 时用作 API Key |
|
|
188
|
+
| `DGXAY_TOKEN_KEY` | 给 OAuth 令牌加解密口令(不设置则按明文 base64 保存) |
|
|
189
|
+
| `DGXAY_LANG=zh` | 界面切成中文(默认英文) |
|
|
190
|
+
| `DGXAY_SHOW_REASONING=0` | 只显示思考摘要,不列出思考内容 |
|
|
191
|
+
| `DGXAY_REASONING_LINES=6` | 思考内容最多显示几行 |
|
|
192
|
+
| `DGXAY_NO_CURSOR_UP=1` | 强制降级为单行输入框 |
|
|
193
|
+
| `DGXAY_ASCII=1` | 强制用 ASCII 框线(+ - |) |
|
|
194
|
+
| `DGXAY_COLOR=always\|never` | 强制开关颜色 |
|
|
195
|
+
| `NO_COLOR` | 关闭颜色 |
|
|
196
|
+
| `DGXAY_DEBUG=1` | 输出调试信息与堆栈 |
|
|
197
|
+
| `DGXAY_OAUTH_NO_BROWSER=1` | 授权时不自动打开浏览器(只打印链接) |
|
|
198
|
+
|
|
199
|
+
## 终端兼容性
|
|
200
|
+
|
|
201
|
+
启动时会探测终端能力,分两种模式:
|
|
202
|
+
|
|
203
|
+
**支持光标上移(Windows Terminal、VSCode、iTerm、大多数 Linux 终端)**
|
|
204
|
+
输入框是真正的方框,命令菜单可以原地刷新、上下选择不残留。
|
|
205
|
+
|
|
206
|
+
**不支持光标上移(老式 conhost)**
|
|
207
|
+
自动降级为单行 `❯` 提示,只做行内刷新,不会出现无法擦除的叠加错位。
|
|
208
|
+
|
|
209
|
+
流式正文始终只使用 `\r` 回行首 + 空格擦尾,不依赖光标上移;生成过程中只在最后一行刷新预览,
|
|
210
|
+
结束时一次性按 Markdown 完整排版。所以正文每段只会出现一次。
|
|
211
|
+
|
|
212
|
+
想强制降级:`DGXAY_NO_CURSOR_UP=1`;想强制 ASCII 框线:`DGXAY_ASCII=1`。
|
|
213
|
+
|
|
214
|
+
## 与桌面版的差异
|
|
215
|
+
|
|
216
|
+
- 没有窗口、没有快捷键,全部操作用命令或斜杠命令完成。
|
|
217
|
+
- 上下文圆环换成输入框上方的状态行和 `/context`。
|
|
218
|
+
- OAuth 令牌不再使用系统钥匙串加密;可用 `DGXAY_TOKEN_KEY` 开启加密。
|
|
219
|
+
- 补上了桌面版没有的能力:`dgxay run` 单次执行、`export` 导出、`doctor` 自检。
|
|
220
|
+
|
|
221
|
+
## 已知限制
|
|
222
|
+
|
|
223
|
+
- 每次请求只发送最近 **24 条**消息,更早的内容会被丢弃;长对话请先 `/compress` 或另起会话。
|
|
224
|
+
- `/compress` 有损且不可撤销。
|
|
225
|
+
- MCP 目前只管理进程,**尚未把 MCP 工具暴露给模型**(与桌面版一致)。
|
|
226
|
+
- 终端命令没有 PTY,不支持 `vim` / `top` / `ssh` 等交互式命令。
|
|
227
|
+
- 自动审查是 LLM,可能判断错误,不能代替人工审查。
|
|
228
|
+
- 上下文用量是字符启发式估算,实际 token 以模型返回的 `usage` 为准。
|
|
229
|
+
|
|
230
|
+
## 开发
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm test # 运行全部测试(内置 mock 服务,不消耗真实额度)
|
|
234
|
+
npm run pack:check # 检查 npm 发布内容
|
|
235
|
+
node bin/dgxay.js --help
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
测试覆盖:三种协议的流式与工具调用、权限矩阵(含拒绝路径)、会话持久化与压缩、SSE 分块解析、Markdown 渲染、参数解析。
|
|
239
|
+
|
|
240
|
+
## 许可证
|
|
241
|
+
|
|
242
|
+
GNU General Public License v3.0,见 [LICENSE](./LICENSE)。
|
package/README.md
CHANGED
|
@@ -1,3 +1,224 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DgxayCode CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The command-line edition of DgxayCode: a multi-protocol AI coding agent with four permission levels, model-based safety review, skills and MCP support.
|
|
4
|
+
|
|
5
|
+
Everything the desktop (Electron) app can do is available here — only the UI is gone:
|
|
6
|
+
|
|
7
|
+
- **Three protocols** — OpenAI ChatCompletions, Anthropic Messages and OpenAI Responses; switch providers and models freely.
|
|
8
|
+
- **Work mode** — read/write files, run commands, fetch URLs; works through a task to completion instead of stopping at a plan.
|
|
9
|
+
- **Four permission levels** — none / normal / auto-review / full, enforced inside the tool layer.
|
|
10
|
+
- **Auto review** — a reviewer model judges each operation; suspicious ones are handed back to you.
|
|
11
|
+
- **Sessions** — persisted history, resume, list, rename, delete, export (200 sessions max).
|
|
12
|
+
- **Context compression** — `/compress` replaces history with a summary.
|
|
13
|
+
- **Skills** — scanned from `~/.dcb/skills`, enabled per conversation.
|
|
14
|
+
- **MCP** — configure, start, stop, inspect logs.
|
|
15
|
+
- **OAuth** — connect OpenAI / Anthropic / xAI / Google accounts (PKCE, system browser).
|
|
16
|
+
- **Self-check** — `dgxay doctor` verifies environment and model connectivity.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
Requires **Node.js 18+**.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g dgxay-code-cli
|
|
24
|
+
dgxay
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or run without installing:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx dgxay-code-cli --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
From source:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/dgxay/DgxayCode.git
|
|
37
|
+
cd DgxayCode-cli
|
|
38
|
+
npm link # or: npm install -g .
|
|
39
|
+
dgxay --version
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 1. First-time setup: protocol, Base URL, API key, model
|
|
46
|
+
dgxay config init
|
|
47
|
+
|
|
48
|
+
# 2. Self-check
|
|
49
|
+
dgxay doctor
|
|
50
|
+
|
|
51
|
+
# 3. Interactive mode
|
|
52
|
+
dgxay
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Ask once and exit:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dgxay "merge every JSON file in this folder into one array"
|
|
59
|
+
|
|
60
|
+
# work mode with auto review
|
|
61
|
+
dgxay run -p "add type hints to all Python files" -C ./project -m work --permission auto
|
|
62
|
+
|
|
63
|
+
# structured output
|
|
64
|
+
dgxay run -p "summarize this repo's architecture" -o json | jq -r .text
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Interactive mode
|
|
68
|
+
|
|
69
|
+
The interface has three parts:
|
|
70
|
+
|
|
71
|
+
- **Input box** — a bordered box that adapts to the terminal width and wraps long input
|
|
72
|
+
- **Command menu** — appears when you type `/`, navigable with the arrow keys
|
|
73
|
+
- **Thinking area** — shows a live timer and the model's reasoning while it works
|
|
74
|
+
|
|
75
|
+
| Input | Action |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| text | Send to the model |
|
|
78
|
+
| `/` | Open the command menu |
|
|
79
|
+
| `↑` / `↓` | Menu open: move the selection. Menu closed: `↑` recalls your previous prompt |
|
|
80
|
+
| `Tab` | Complete the selected command |
|
|
81
|
+
| `Enter` | Menu open: run the selected command. Otherwise: send the message |
|
|
82
|
+
| `Esc` | Close the menu |
|
|
83
|
+
| `!command` | Run a shell command; output joins the context, e.g. `!git status` |
|
|
84
|
+
| trailing `\` | Continue on the next line |
|
|
85
|
+
| `Ctrl+C` | Abort while generating; clear the input when non-empty; exit when idle |
|
|
86
|
+
| `Ctrl+D` | Exit |
|
|
87
|
+
|
|
88
|
+
### Language
|
|
89
|
+
|
|
90
|
+
The interface is English by default. Switch to Chinese with `DGXAY_LANG=zh dgxay`.
|
|
91
|
+
The AI replies in the language you write in.
|
|
92
|
+
|
|
93
|
+
### Thinking
|
|
94
|
+
|
|
95
|
+
While the model reasons, the terminal shows a live timer:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
⠿ Thinking 2.4s latest reasoning fragment…
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
When it finishes, that folds into a one-line summary followed by the full reasoning in grey:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
⌁ Thought for 12.8s · 1450 chars
|
|
105
|
+
│ First I'll look at the directory layout…
|
|
106
|
+
│ Then read the entry file…
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Set `DGXAY_SHOW_REASONING=0` to keep only the summary.
|
|
110
|
+
|
|
111
|
+
### Slash commands
|
|
112
|
+
|
|
113
|
+
`/help` `/new` `/list` `/resume` `/delete` `/rename` `/compress` `/skill` `/model` `/provider` `/mode` `/permission` `/cd` `/ls` `/pwd` `/term` `/context` `/mcp` `/clear` `/exit`
|
|
114
|
+
|
|
115
|
+
## Subcommands
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
dgxay interactive mode
|
|
119
|
+
dgxay "question" one-shot ask
|
|
120
|
+
dgxay run one-shot ask (-p / -C / -m / --permission / -o json)
|
|
121
|
+
dgxay chat list / show / resume / rm / rename / clear
|
|
122
|
+
dgxay config init / show / get / set / path / reset
|
|
123
|
+
dgxay provider list / add / edit / rm / use / mv / review
|
|
124
|
+
dgxay model list / use / add / rm / fetch
|
|
125
|
+
dgxay oauth list / connect / disconnect / client
|
|
126
|
+
dgxay mcp list / add / start / stop / logs / rm / env
|
|
127
|
+
dgxay skill list / show / path
|
|
128
|
+
dgxay workspace set / list / clear
|
|
129
|
+
dgxay permission list / set
|
|
130
|
+
dgxay context context usage estimate
|
|
131
|
+
dgxay export export a session (Markdown / JSON)
|
|
132
|
+
dgxay doctor self-check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Every subcommand supports `--help`.
|
|
136
|
+
|
|
137
|
+
## Permissions
|
|
138
|
+
|
|
139
|
+
| Level | Capabilities | Approval |
|
|
140
|
+
| --- | --- | --- |
|
|
141
|
+
| `none` | read-only inside the workspace | none |
|
|
142
|
+
| `normal` | everything | **every** operation needs your confirmation |
|
|
143
|
+
| `auto` | everything | reviewer model decides; suspicious operations ask you |
|
|
144
|
+
| `full` | everything | no review, no prompts |
|
|
145
|
+
|
|
146
|
+
- Enforced in the tool layer — the UI (here, the REPL) cannot bypass it.
|
|
147
|
+
- Auto review requires a review model: `dgxay provider review <provider> --model <modelId>`; without it `auto` is unavailable and falls back to `normal`.
|
|
148
|
+
- In non-interactive pipelines, approval-requiring operations are denied unless you pass `--yes`.
|
|
149
|
+
- Deletions are **permanent** (no trash). Commit to Git before bulk edits.
|
|
150
|
+
|
|
151
|
+
## Data
|
|
152
|
+
|
|
153
|
+
`~/.dcb` (Windows: `%USERPROFILE%\.dcb`), shared with the desktop app:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
~/.dcb/
|
|
157
|
+
├── config.json # providers, models, review models, mode, permission
|
|
158
|
+
├── chats.json # conversation history (200 sessions max)
|
|
159
|
+
├── oauth.json # OAuth client + tokens (0600)
|
|
160
|
+
├── mcp.json # MCP servers
|
|
161
|
+
└── skills/ # SKILL.md or name.md
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
API keys are stored **in plain text** in `config.json`. Use `DGXAY_HOME=/tmp/test dgxay` to isolate a data directory (desktop's `DCB_HOME` also works). OAuth tokens written by the desktop app are encrypted with Electron `safeStorage` and cannot be read by the CLI — reconnect with `dgxay oauth connect <platform>`.
|
|
165
|
+
|
|
166
|
+
## Environment variables
|
|
167
|
+
|
|
168
|
+
| Variable | Purpose |
|
|
169
|
+
| --- | --- |
|
|
170
|
+
| `DGXAY_HOME` | Override the data directory |
|
|
171
|
+
| `DGXAY_API_KEY` | API key used by `config init` |
|
|
172
|
+
| `DGXAY_TOKEN_KEY` | Passphrase that encrypts OAuth tokens (plain base64 otherwise) |
|
|
173
|
+
| `DGXAY_LANG=zh` | Use the Chinese interface (English by default) |
|
|
174
|
+
| `DGXAY_SHOW_REASONING=0` | Show only the thinking summary, not the reasoning text |
|
|
175
|
+
| `DGXAY_REASONING_LINES=6` | How many reasoning lines to display |
|
|
176
|
+
| `DGXAY_NO_CURSOR_UP=1` | Force the single-line fallback input |
|
|
177
|
+
| `DGXAY_ASCII=1` | Force ASCII box drawing characters |
|
|
178
|
+
| `DGXAY_COLOR=always\|never` | Force colours on/off |
|
|
179
|
+
| `NO_COLOR` | Disable colours |
|
|
180
|
+
| `DGXAY_DEBUG=1` | Debug output and stack traces |
|
|
181
|
+
| `DGXAY_OAUTH_NO_BROWSER=1` | Don't open a browser during OAuth; print the URL only |
|
|
182
|
+
|
|
183
|
+
## Terminal compatibility
|
|
184
|
+
|
|
185
|
+
The terminal is probed at startup and the UI adapts:
|
|
186
|
+
|
|
187
|
+
**Cursor-up supported** (Windows Terminal, VSCode, iTerm, most Linux terminals)
|
|
188
|
+
The input is a real box and the command menu refreshes in place without leftovers.
|
|
189
|
+
|
|
190
|
+
**Cursor-up unsupported** (legacy conhost)
|
|
191
|
+
Falls back to a single-line `❯` prompt with in-place redraw, so nothing can stack up.
|
|
192
|
+
|
|
193
|
+
Streaming text always uses only `\r` and space padding; while generating, just the last line is refreshed, and
|
|
194
|
+
the whole reply is laid out once as Markdown at the end. Every paragraph appears exactly once.
|
|
195
|
+
|
|
196
|
+
Force the fallback with `DGXAY_NO_CURSOR_UP=1`, or ASCII borders with `DGXAY_ASCII=1`.
|
|
197
|
+
|
|
198
|
+
## Differences from the desktop app
|
|
199
|
+
|
|
200
|
+
- No window and no global shortcuts — everything is a subcommand or slash command.
|
|
201
|
+
- The context ring becomes a status line plus `/context`.
|
|
202
|
+
- OAuth tokens no longer use the OS keychain; set `DGXAY_TOKEN_KEY` to encrypt them.
|
|
203
|
+
- New in the CLI: `dgxay run`, `export`, `doctor`.
|
|
204
|
+
|
|
205
|
+
## Known limitations
|
|
206
|
+
|
|
207
|
+
- Only the most recent **24** messages are sent per request; compress or start a new session for long conversations.
|
|
208
|
+
- `/compress` is lossy and cannot be undone.
|
|
209
|
+
- MCP is process management only — MCP tools are **not** exposed to the model yet (same as desktop).
|
|
210
|
+
- Shell commands have no PTY: no `vim`, `top` or `ssh`.
|
|
211
|
+
- Auto review is an LLM and can be wrong; it is not a sandbox.
|
|
212
|
+
- Context usage is a character-based estimate; rely on the model's `usage` for real tokens.
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npm test # full suite against a built-in mock server (no real API usage)
|
|
218
|
+
npm run pack:check # inspect the npm tarball
|
|
219
|
+
node bin/dgxay.js --help
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
GNU General Public License v3.0 — see [LICENSE](./LICENSE). 中文说明见 [README-zh.md](./README-zh.md).
|
package/bin/dgxay.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DgxayCode CLI 可执行入口。
|
|
6
|
+
*
|
|
7
|
+
* 全局安装后直接运行 `dgxay` 即可:
|
|
8
|
+
* npm install -g dgxay-code-cli
|
|
9
|
+
* dgxay
|
|
10
|
+
*
|
|
11
|
+
* 这里只做三件事:检查 Node 版本、屏蔽不兼容的交互环境、把控制权交给 src/cli/index.js。
|
|
12
|
+
* 真正的参数解析与业务逻辑都在 cli 层,保证入口文件足够小、在任何平台都能被 npm 正常解析。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const MIN_MAJOR = 18;
|
|
16
|
+
|
|
17
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
18
|
+
if (!Number.isFinite(major) || major < MIN_MAJOR) {
|
|
19
|
+
process.stderr.write(
|
|
20
|
+
`DgxayCode CLI 需要 Node.js ${MIN_MAJOR} 或更高版本,当前为 ${process.versions.node}。\n` +
|
|
21
|
+
'请升级 Node.js 后重试:https://nodejs.org/\n'
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function run() {
|
|
27
|
+
require('../src/cli/index.js')
|
|
28
|
+
.main(process.argv.slice(2))
|
|
29
|
+
.then((code) => {
|
|
30
|
+
if (typeof code === 'number' && code !== 0) process.exitCode = code;
|
|
31
|
+
})
|
|
32
|
+
.catch((error) => {
|
|
33
|
+
const message = error && error.message ? error.message : String(error);
|
|
34
|
+
process.stderr.write(`\n发生未处理的错误:${message}\n`);
|
|
35
|
+
if (process.env.DGXAY_DEBUG === '1' && error && error.stack) {
|
|
36
|
+
process.stderr.write(`${error.stack}\n`);
|
|
37
|
+
}
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dgxay-code-cli",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"productName": "DgxayCode CLI",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"description": "DgxayCode 命令行版:多协议 AI 编码助手,支持工作空间、四档权限、自动审查、技能与 MCP。",
|
|
6
|
+
"author": "Dgxay",
|
|
7
|
+
"license": "GPL-3.0-only",
|
|
8
|
+
"bin": {
|
|
9
|
+
"dgxay": "bin/dgxay.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "src/cli/index.js",
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/**/*",
|
|
18
|
+
"src/**/*",
|
|
19
|
+
"README.md",
|
|
20
|
+
"README-zh.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cli",
|
|
25
|
+
"ai",
|
|
26
|
+
"agent",
|
|
27
|
+
"coding-assistant",
|
|
28
|
+
"ai-coding",
|
|
29
|
+
"openai",
|
|
30
|
+
"anthropic",
|
|
31
|
+
"deepseek",
|
|
32
|
+
"llm",
|
|
33
|
+
"mcp",
|
|
34
|
+
"terminal"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"start": "node bin/dgxay.js",
|
|
38
|
+
"test": "node test/run.js",
|
|
39
|
+
"pack:check": "npm pack --dry-run"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/dgxay/DgxayCode",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/dgxay/DgxayCode.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/dgxay/DgxayCode/issues"
|
|
48
|
+
}
|
|
49
|
+
}
|