deepccc 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +277 -200
- package/dist/cli.js +48 -5
- package/dist/file-tools.d.ts +6 -1
- package/dist/file-tools.js +82 -7
- package/dist/index.d.ts +12 -0
- package/dist/index.js +18 -9
- package/dist/permissions.d.ts +42 -0
- package/dist/permissions.js +170 -0
- package/dist/privacy.d.ts +21 -0
- package/dist/privacy.js +124 -0
- package/package.json +61 -61
package/README.md
CHANGED
|
@@ -1,200 +1,277 @@
|
|
|
1
|
-
# deepccc
|
|
2
|
-
|
|
3
|
-
`deepccc` 是一个轻量级本地编程 Agent,针对 DeepSeek 使用体验做了优化,同时支持其他 OpenAI-compatible 模型接口。
|
|
4
|
-
|
|
5
|
-
它提供交互式命令行、JSONL 流式输出、本地文件工具、命令执行、项目提示词自动注入和持久化上下文。
|
|
6
|
-
|
|
7
|
-
## 当前状态
|
|
8
|
-
|
|
9
|
-
代码已经开源在 GitHub:
|
|
10
|
-
|
|
11
|
-
https://github.com/wzj998/deepccc-agent
|
|
12
|
-
|
|
13
|
-
npm 包名规划为 `deepccc`。如果 npm 包已经发布,可以直接全局安装:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install -g deepccc
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
如果还没有发布,可以从源码运行:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
git clone https://github.com/wzj998/deepccc-agent.git
|
|
23
|
-
cd deepccc-agent
|
|
24
|
-
npm install
|
|
25
|
-
npm run build
|
|
26
|
-
node bin/deepccc.mjs --help
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
运行要求:
|
|
30
|
-
|
|
31
|
-
- Node.js >= 20
|
|
32
|
-
- DeepSeek 或其他 OpenAI-compatible 模型服务的 API Key
|
|
33
|
-
|
|
34
|
-
## 配置
|
|
35
|
-
|
|
36
|
-
最快的方式是使用环境变量:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
export DEEPCCC_API_KEY="sk-..."
|
|
40
|
-
export DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
|
|
41
|
-
export DEEPCCC_MODEL="deepseek-v4-pro"
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Windows PowerShell:
|
|
45
|
-
|
|
46
|
-
```powershell
|
|
47
|
-
$env:DEEPCCC_API_KEY="sk-..."
|
|
48
|
-
$env:DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
|
|
49
|
-
$env:DEEPCCC_MODEL="deepseek-v4-pro"
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
也兼容这些 DeepSeek 别名:
|
|
53
|
-
|
|
54
|
-
- `DEEPSEEK_API_KEY`
|
|
55
|
-
- `DEEPSEEK_BASE_URL`
|
|
56
|
-
- `DEEPSEEK_MODEL`
|
|
57
|
-
- `DEEPSEEK_EFFORT`
|
|
58
|
-
|
|
59
|
-
也可以创建 `~/.deepccc/config.json`:
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"apiKey": "sk-...",
|
|
64
|
-
"baseURL": "https://api.deepseek.com/v1",
|
|
65
|
-
"model": "deepseek-v4-pro",
|
|
66
|
-
"effort": "",
|
|
67
|
-
"rawStreamLogs": {
|
|
68
|
-
"enabled": false,
|
|
69
|
-
"maxBytesPerTurn": 1048576,
|
|
70
|
-
"retentionDays": 7,
|
|
71
|
-
"keepCompleted": false
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
deepccc
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
1
|
+
# deepccc
|
|
2
|
+
|
|
3
|
+
`deepccc` 是一个轻量级本地编程 Agent,针对 DeepSeek 使用体验做了优化,同时支持其他 OpenAI-compatible 模型接口。
|
|
4
|
+
|
|
5
|
+
它提供交互式命令行、JSONL 流式输出、本地文件工具、命令执行、项目提示词自动注入和持久化上下文。
|
|
6
|
+
|
|
7
|
+
## 当前状态
|
|
8
|
+
|
|
9
|
+
代码已经开源在 GitHub:
|
|
10
|
+
|
|
11
|
+
https://github.com/wzj998/deepccc-agent
|
|
12
|
+
|
|
13
|
+
npm 包名规划为 `deepccc`。如果 npm 包已经发布,可以直接全局安装:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g deepccc
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
如果还没有发布,可以从源码运行:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/wzj998/deepccc-agent.git
|
|
23
|
+
cd deepccc-agent
|
|
24
|
+
npm install
|
|
25
|
+
npm run build
|
|
26
|
+
node bin/deepccc.mjs --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
运行要求:
|
|
30
|
+
|
|
31
|
+
- Node.js >= 20
|
|
32
|
+
- DeepSeek 或其他 OpenAI-compatible 模型服务的 API Key
|
|
33
|
+
|
|
34
|
+
## 配置
|
|
35
|
+
|
|
36
|
+
最快的方式是使用环境变量:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
export DEEPCCC_API_KEY="sk-..."
|
|
40
|
+
export DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
|
|
41
|
+
export DEEPCCC_MODEL="deepseek-v4-pro"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Windows PowerShell:
|
|
45
|
+
|
|
46
|
+
```powershell
|
|
47
|
+
$env:DEEPCCC_API_KEY="sk-..."
|
|
48
|
+
$env:DEEPCCC_BASE_URL="https://api.deepseek.com/v1"
|
|
49
|
+
$env:DEEPCCC_MODEL="deepseek-v4-pro"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
也兼容这些 DeepSeek 别名:
|
|
53
|
+
|
|
54
|
+
- `DEEPSEEK_API_KEY`
|
|
55
|
+
- `DEEPSEEK_BASE_URL`
|
|
56
|
+
- `DEEPSEEK_MODEL`
|
|
57
|
+
- `DEEPSEEK_EFFORT`
|
|
58
|
+
|
|
59
|
+
也可以创建 `~/.deepccc/config.json`:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"apiKey": "sk-...",
|
|
64
|
+
"baseURL": "https://api.deepseek.com/v1",
|
|
65
|
+
"model": "deepseek-v4-pro",
|
|
66
|
+
"effort": "",
|
|
67
|
+
"rawStreamLogs": {
|
|
68
|
+
"enabled": false,
|
|
69
|
+
"maxBytesPerTurn": 1048576,
|
|
70
|
+
"retentionDays": 7,
|
|
71
|
+
"keepCompleted": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 隐私替换
|
|
77
|
+
|
|
78
|
+
`deepccc` 支持在展示层(终端输出 / JSONL 流式输出)把敏感信息替换为掩码值,防止用户名、路径等隐私内容出现在终端或管道输出里。创建 `~/.deepccc/privacy.json` 即可启用:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"enabled": true,
|
|
83
|
+
"rules": {
|
|
84
|
+
"weizhangjian": "wzj"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- `rules` 的键按字面量替换(`split`/`join`,非正则),可配置多条规则;不配置 `enabled`/`rules` 字段时,扁平写法 `{ "weizhangjian": "wzj" }` 也兼容(等效 `enabled: true`)。
|
|
90
|
+
- 替换作用于模型回复文本、工具调用参数与结果、错误消息中的字符串字段;持久化上下文仍保存原文,替换仅影响展示层。
|
|
91
|
+
- 文件变更后自动热加载,无需重启进程。
|
|
92
|
+
|
|
93
|
+
## 命令行交互
|
|
94
|
+
|
|
95
|
+
在当前目录启动一个交互式 Agent:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
deepccc
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
指定其他模型或 OpenAI-compatible 接口:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
deepccc --base-url https://api.openai.com/v1 --api-key "$OPENAI_API_KEY" --model gpt-4.1
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
指定工作目录:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
deepccc --cwd /path/to/project
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
恢复当前工作目录最近一次会话:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
deepccc --resume
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
设置工具调用步数上限:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
deepccc --max-steps 20
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
默认情况下,`deepccc` 不设置固定步数上限,会让模型自然完成工具循环。
|
|
126
|
+
|
|
127
|
+
设置推理强度(reasoning effort):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
deepccc --effort high
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
可选值:`none` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`(留空则不传 `reasoning_effort` 请求字段)。
|
|
134
|
+
|
|
135
|
+
## 权限机制
|
|
136
|
+
|
|
137
|
+
`deepccc` 内置轻量权限机制,对标主流 agent 的审批体验:**只拦截有副作用的操作**(`run_command` 与文件写操作),只读工具(`read_file` / `list_dir` / `search_code`)永不拦截,常规文件编辑默认放行不打断工作流。
|
|
138
|
+
|
|
139
|
+
默认模式(`ask`)下,只有**命中内置危险命令库**的高危命令才会询问,例如:
|
|
140
|
+
|
|
141
|
+
- `rm -rf` / `rm -fr` / `del /s` / `rmdir /s` 等强制删除
|
|
142
|
+
- `git push --force` / `git reset --hard` / `git clean -f` 等破坏性 git 操作
|
|
143
|
+
- `format` / `diskpart` / `mkfs` / `dd of=设备` 等磁盘操作
|
|
144
|
+
- `shutdown` / `reboot` 等系统操作
|
|
145
|
+
- `drop table` / `truncate table` 等数据库操作
|
|
146
|
+
- `npm publish` / `npm uninstall -g` / `pip uninstall` 等发布与全局卸载
|
|
147
|
+
|
|
148
|
+
交互模式下,高危命令会暂停并询问:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
⚠️ 高危操作需要确认
|
|
152
|
+
运行命令: rm -rf node_modules
|
|
153
|
+
允许一次(y) / 永远允许(a) / 拒绝(n) / 本会话允许所有(g) >
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- `y` — 允许本次
|
|
157
|
+
- `a` — 永远允许,写入 `~/.deepccc/allow.json`
|
|
158
|
+
- `n` — 拒绝本次
|
|
159
|
+
- `g` — 本会话内全部放行(不落盘)
|
|
160
|
+
|
|
161
|
+
### 规则文件 `~/.deepccc/allow.json`
|
|
162
|
+
|
|
163
|
+
规则格式为 `"<工具>:<模式>"`(`*` 为通配符,`*:` 匹配所有工具),支持相对/绝对路径:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"allow": [
|
|
168
|
+
"run_command:git status*",
|
|
169
|
+
"run_command:git push --force origin release*"
|
|
170
|
+
],
|
|
171
|
+
"deny": [
|
|
172
|
+
"edit_file:node_modules/**",
|
|
173
|
+
"run_command:npm publish*"
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`deny` 命中永远拒绝,`allow` 命中永远放行(可覆盖高危判定)。文件变更后自动热加载,无需重启。
|
|
179
|
+
|
|
180
|
+
### 非交互模式与 bypass
|
|
181
|
+
|
|
182
|
+
`--stream-json` 或程序化调用(无终端可交互)时,高危命令**安全默认拒绝**。需要全自动场景可显式传入:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
deepccc --dangerously-bypass-permissions
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
该参数与 `ChatSession` 的 `permissionMode: "bypass"` 等价,也是 chatccc 集成 deepccc 时使用的模式(对齐 chatccc 调用 Claude Code / Codex 的 bypass 方式)。
|
|
189
|
+
|
|
190
|
+
## 终端过程区块
|
|
191
|
+
|
|
192
|
+
交互模式下,每轮回复渲染为固定"过程区块":状态行(生成中/完成/已停止/异常结束)+ 折叠工具行 + 原地更新正文,不滚屏刷 JSON。生成中有心跳点号动画;完成/停止/异常后区块定型留在屏幕上。
|
|
193
|
+
|
|
194
|
+
如果终端渲染出现异常,可以强制回退为纯文本流式输出:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
deepccc --plain
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## JSONL 流式输出
|
|
201
|
+
|
|
202
|
+
JSONL 模式适合脚本、服务端集成或其他上层系统调用:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
deepccc --stream-json --prompt "检查这个仓库并总结测试命令"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
也可以从 stdin 传入提示词:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
echo "运行测试并解释失败原因" | deepccc --stream-json
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
输出是逐行 JSON:
|
|
215
|
+
|
|
216
|
+
```jsonl
|
|
217
|
+
{"type":"start","session_id":"session-...","mode":"new","cwd":"/repo","model":"deepseek-v4-pro"}
|
|
218
|
+
{"type":"text_delta","text":"...","accumulated":"..."}
|
|
219
|
+
{"type":"tool_call","id":"call_...","name":"read_file","input":{"path":"package.json"}}
|
|
220
|
+
{"type":"tool_result","tool_call_id":"call_...","name":"read_file","content":{},"is_error":false}
|
|
221
|
+
{"type":"done","text":"..."}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 在 ChatCCC 中使用
|
|
225
|
+
|
|
226
|
+
**ChatCCC 已内置 deepccc**:ChatCCC 的 "CCC Agent" 工具直接内嵌 deepccc 的代码(`src/builtin/`),以 `permissionMode: "bypass"` 全自动运行,无需单独安装或配置本仓库。
|
|
227
|
+
|
|
228
|
+
ChatCCC 是一个把 Claude Code / Codex / Cursor / CCC Agent 聚合到飞书/企微等 IM 消息通道的本地机器人框架,提供会话管理、过程卡片、用量统计与隐私替换等能力。
|
|
229
|
+
|
|
230
|
+
- 公有仓库:https://github.com/wzj998/ChatCCC
|
|
231
|
+
- npm 包:`chatccc`(`npm install -g chatccc`)
|
|
232
|
+
|
|
233
|
+
在 ChatCCC 会话里可以使用隐藏指令创建 `deepccc` Agent 会话:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
/new ccc
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
这种方式适合已经在 ChatCCC 里协作的场景:ChatCCC 负责会话入口和消息通道,`deepccc` 负责本地编程 Agent 能力,包括读取项目提示词、运行命令、编辑文件和输出流式结果。
|
|
240
|
+
|
|
241
|
+
如果希望让 ChatCCC 使用本仓库(deepccc-agent)最新的独立版本能力,也可以把 `src/builtin/` 与本仓库 `src/` 同步后构建。
|
|
242
|
+
|
|
243
|
+
## 项目提示词自动注入
|
|
244
|
+
|
|
245
|
+
会话启动时,`deepccc` 会从当前工作目录读取这些文件,如果存在就注入为项目级提示词:
|
|
246
|
+
|
|
247
|
+
- `AGENTS.md`
|
|
248
|
+
- `AGENTS.local.md`
|
|
249
|
+
- `CLAUDE.md`
|
|
250
|
+
- `CLAUDE.local.md`
|
|
251
|
+
|
|
252
|
+
这些内容会放在固定系统提示词之后,作为项目指导使用。
|
|
253
|
+
|
|
254
|
+
## Codex-style Skills 支持
|
|
255
|
+
|
|
256
|
+
`deepccc` 会扫描以下目录,把本机的 Codex 目录式 skill(`<name>/SKILL.md`,含 `name` + `description` frontmatter)索引注入系统提示词;模型在任务匹配时先用 `read_file` 读取 `SKILL.md` 全文再执行:
|
|
257
|
+
|
|
258
|
+
- `~/.codex/skills`
|
|
259
|
+
- `~/.agents/skills`
|
|
260
|
+
- `<cwd>/.codex/skills`(项目级,优先级最高)
|
|
261
|
+
|
|
262
|
+
## 内置工具
|
|
263
|
+
|
|
264
|
+
`deepccc` 可以让模型调用这些本地工具:
|
|
265
|
+
|
|
266
|
+
- 按行读取文件
|
|
267
|
+
- 列目录
|
|
268
|
+
- 用 ripgrep 搜索代码
|
|
269
|
+
- 编辑、创建、删除、移动文件
|
|
270
|
+
- 应用 unified diff patch
|
|
271
|
+
- 运行非交互式 shell 命令,并返回 stdout、stderr、exitCode 和超时状态
|
|
272
|
+
|
|
273
|
+
命令返回非零退出码时不会直接被当成工具异常;模型可以读取结构化结果,继续判断下一步。
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
Apache-2.0
|
package/dist/cli.js
CHANGED
|
@@ -87,6 +87,10 @@ function parseArgs(argv = process.argv.slice(2)) {
|
|
|
87
87
|
else if (arg === "--plain") {
|
|
88
88
|
plain = true;
|
|
89
89
|
}
|
|
90
|
+
else if (arg === "--dangerously-bypass-permissions") {
|
|
91
|
+
// 仅保留一个 bypass 入口(对齐 chatccc 调 claude/codex 的 bypass 模式)
|
|
92
|
+
options.permissionMode = "bypass";
|
|
93
|
+
}
|
|
90
94
|
else if (arg === "--help" || arg === "-h") {
|
|
91
95
|
help = true;
|
|
92
96
|
}
|
|
@@ -118,8 +122,16 @@ function printHelp(appConfig) {
|
|
|
118
122
|
" --stream-json One-shot mode: write JSONL events to stdout",
|
|
119
123
|
" --prompt <text> Prompt text for --stream-json",
|
|
120
124
|
" --plain Force plain streaming output (no progress block renderer)",
|
|
125
|
+
" --dangerously-bypass-permissions Skip all permission prompts (aligns with chatccc's bypass mode)",
|
|
121
126
|
" --help, -h Show help",
|
|
122
127
|
"",
|
|
128
|
+
"Permissions:",
|
|
129
|
+
" Default mode asks before high-risk commands (rm -rf, git push --force, ...).",
|
|
130
|
+
" Answer y = allow once, a = allow always (saved to ~/.deepccc/allow.json),",
|
|
131
|
+
" n = deny, g = allow all for this session. Read-only tools and normal file",
|
|
132
|
+
" edits never prompt. In non-interactive mode (--stream-json) high-risk",
|
|
133
|
+
" commands are denied unless --dangerously-bypass-permissions is passed.",
|
|
134
|
+
"",
|
|
123
135
|
"Default config source:",
|
|
124
136
|
" ~/.deepccc/config.json, DEEPCCC_* environment variables, or DEEPSEEK_* aliases",
|
|
125
137
|
"",
|
|
@@ -338,6 +350,37 @@ async function runRepl(args) {
|
|
|
338
350
|
if (process.stdout.isTTY === true && !args.plain) {
|
|
339
351
|
muteConsoleLogToFile(setupFileLogging(defaultLogDir(), "index").logPath);
|
|
340
352
|
}
|
|
353
|
+
const rl = readline.createInterface({
|
|
354
|
+
input: process.stdin,
|
|
355
|
+
output: process.stdout,
|
|
356
|
+
prompt: `${C.green}>${C.reset} `,
|
|
357
|
+
});
|
|
358
|
+
// 权限交互:暂停过程区块渲染(恢复光标)→ readline 提问 → 恢复渲染。
|
|
359
|
+
// activeRenderer/activeView 由每轮 line 处理器维护,resolver 只在工具
|
|
360
|
+
// 执行期间被调用,此时当前轮的区块正处于运行中。
|
|
361
|
+
let activeRenderer = null;
|
|
362
|
+
let activeView = null;
|
|
363
|
+
const permissionResolver = async (request) => {
|
|
364
|
+
const renderer = activeRenderer;
|
|
365
|
+
const view = activeView;
|
|
366
|
+
if (renderer)
|
|
367
|
+
renderer.dispose();
|
|
368
|
+
process.stdout.write(`\n${C.yellow}⚠️ 高危操作需要确认${C.reset}\n`);
|
|
369
|
+
process.stdout.write(`${C.dim}${request.detail}${C.reset}\n`);
|
|
370
|
+
const answer = await new Promise((resolve) => {
|
|
371
|
+
rl.question(`${C.green}允许一次(y) / 永远允许(a) / 拒绝(n) / 本会话允许所有(g) >${C.reset} `, resolve);
|
|
372
|
+
});
|
|
373
|
+
if (renderer && view)
|
|
374
|
+
renderer.begin(view);
|
|
375
|
+
const v = answer.trim().toLowerCase();
|
|
376
|
+
if (v === "y")
|
|
377
|
+
return "allow";
|
|
378
|
+
if (v === "a")
|
|
379
|
+
return "allow-always";
|
|
380
|
+
if (v === "g")
|
|
381
|
+
return "allow-session";
|
|
382
|
+
return "deny";
|
|
383
|
+
};
|
|
341
384
|
let session;
|
|
342
385
|
try {
|
|
343
386
|
session = new ChatSession(args.config, {
|
|
@@ -345,17 +388,13 @@ async function runRepl(args) {
|
|
|
345
388
|
cwd,
|
|
346
389
|
persist: true,
|
|
347
390
|
sessionId: resolvedSession.sessionId,
|
|
391
|
+
permissionResolver,
|
|
348
392
|
});
|
|
349
393
|
}
|
|
350
394
|
catch (err) {
|
|
351
395
|
console.error(`${C.yellow}${err.message}${C.reset}`);
|
|
352
396
|
process.exit(1);
|
|
353
397
|
}
|
|
354
|
-
const rl = readline.createInterface({
|
|
355
|
-
input: process.stdin,
|
|
356
|
-
output: process.stdout,
|
|
357
|
-
prompt: `${C.green}>${C.reset} `,
|
|
358
|
-
});
|
|
359
398
|
let currentAbort = null;
|
|
360
399
|
const ctrlCState = createCtrlCState();
|
|
361
400
|
rl.prompt();
|
|
@@ -391,6 +430,8 @@ async function runRepl(args) {
|
|
|
391
430
|
let view = null;
|
|
392
431
|
if (renderer) {
|
|
393
432
|
view = progressView({ headerTitle: "生成中..." });
|
|
433
|
+
activeRenderer = renderer;
|
|
434
|
+
activeView = view;
|
|
394
435
|
// 先回行首换行再 begin:让过程区块从输入行下方开始,避免首帧 \r\x1b[2K
|
|
395
436
|
// 清掉用户刚输入的问题行(历史文本不被刷掉)。\r\n 兼容 readline
|
|
396
437
|
// 行提交后光标仍停在输入行行尾的情况。
|
|
@@ -446,6 +487,8 @@ async function runRepl(args) {
|
|
|
446
487
|
console.error(`\n${C.yellow}[error] ${err.message}${C.reset}`);
|
|
447
488
|
}
|
|
448
489
|
finally {
|
|
490
|
+
activeRenderer = null;
|
|
491
|
+
activeView = null;
|
|
449
492
|
if (renderer && view && !rendererEnded) {
|
|
450
493
|
// 定型终态区块(完成/已停止/异常结束)留在屏幕上,恢复光标
|
|
451
494
|
renderer.end(view);
|
package/dist/file-tools.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ToolSet } from "ai";
|
|
2
|
+
import { type PermissionGate } from "./permissions.js";
|
|
2
3
|
export interface ReadFileInput {
|
|
3
4
|
path: string;
|
|
4
5
|
startLine?: number;
|
|
@@ -140,4 +141,8 @@ export declare function createFileForTool(cwd: string, input: CreateFileInput):
|
|
|
140
141
|
export declare function deleteFileForTool(cwd: string, input: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
141
142
|
export declare function moveFileForTool(cwd: string, input: MoveFileInput): Promise<MoveFileOutput>;
|
|
142
143
|
export declare function applyPatchForTool(cwd: string, input: ApplyPatchInput): Promise<ApplyPatchOutput>;
|
|
143
|
-
export
|
|
144
|
+
export interface BuiltinFileToolsOptions {
|
|
145
|
+
/** 权限门控:副作用工具(run_command/文件写操作)执行前会先经过 gate.check */
|
|
146
|
+
permissionGate?: PermissionGate;
|
|
147
|
+
}
|
|
148
|
+
export declare function createBuiltinFileTools(cwd: string, options?: BuiltinFileToolsOptions): ToolSet;
|