yuangs 2.29.0 → 2.31.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/README.md +284 -337
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +2 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llmAdapter.js +1 -1
- package/dist/agent/llmAdapter.js.map +1 -1
- package/dist/agent/policy/engine.d.ts +14 -0
- package/dist/agent/policy/engine.js +76 -0
- package/dist/agent/policy/engine.js.map +1 -0
- package/dist/agent/policy/index.d.ts +3 -0
- package/dist/agent/policy/index.js +20 -0
- package/dist/agent/policy/index.js.map +1 -0
- package/dist/agent/policy/policies/noDangerousShell.d.ts +7 -0
- package/dist/agent/policy/policies/noDangerousShell.js +45 -0
- package/dist/agent/policy/policies/noDangerousShell.js.map +1 -0
- package/dist/agent/policy/types.d.ts +23 -0
- package/dist/agent/policy/types.js +3 -0
- package/dist/agent/policy/types.js.map +1 -0
- package/dist/agent/replay/events.d.ts +21 -0
- package/dist/agent/replay/events.js +3 -0
- package/dist/agent/replay/events.js.map +1 -0
- package/dist/agent/replay/index.d.ts +3 -0
- package/dist/agent/replay/index.js +20 -0
- package/dist/agent/replay/index.js.map +1 -0
- package/dist/agent/replay/recorder.d.ts +11 -0
- package/dist/agent/replay/recorder.js +51 -0
- package/dist/agent/replay/recorder.js.map +1 -0
- package/dist/agent/replay/replayer.d.ts +21 -0
- package/dist/agent/replay/replayer.js +65 -0
- package/dist/agent/replay/replayer.js.map +1 -0
- package/dist/agent/selectModel.js +1 -1
- package/dist/agent/selectModel.js.map +1 -1
- package/dist/agent/skills.d.ts +5 -0
- package/dist/agent/skills.js +7 -3
- package/dist/agent/skills.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +18 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/registryAPI.d.ts +22 -0
- package/dist/api/registryAPI.js +66 -0
- package/dist/api/registryAPI.js.map +1 -0
- package/dist/audit/index.d.ts +1 -0
- package/dist/audit/index.js +18 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/timeline.d.ts +75 -0
- package/dist/audit/timeline.js +254 -0
- package/dist/audit/timeline.js.map +1 -0
- package/dist/cli.js +19 -10
- package/dist/cli.js.map +1 -1
- package/dist/commands/explainCommands.d.ts +2 -0
- package/dist/commands/explainCommands.js +36 -0
- package/dist/commands/explainCommands.js.map +1 -0
- package/dist/commands/handleAICommand.js +1 -1
- package/dist/commands/handleAICommand.js.map +1 -1
- package/dist/commands/registryCommands.d.ts +2 -0
- package/dist/commands/registryCommands.js +243 -0
- package/dist/commands/registryCommands.js.map +1 -0
- package/dist/commands/replayCommands.d.ts +2 -0
- package/dist/commands/replayCommands.js +75 -0
- package/dist/commands/replayCommands.js.map +1 -0
- package/dist/commands/skillsCommands.d.ts +2 -0
- package/dist/commands/skillsCommands.js +114 -0
- package/dist/commands/skillsCommands.js.map +1 -0
- package/dist/core/capabilitySystem.js +2 -2
- package/dist/core/capabilitySystem.js.map +1 -1
- package/dist/core/executionRecord.d.ts +8 -0
- package/dist/core/executionRecord.js +2 -0
- package/dist/core/executionRecord.js.map +1 -1
- package/dist/core/explain.d.ts +8 -0
- package/dist/core/explain.js +84 -0
- package/dist/core/explain.js.map +1 -0
- package/dist/core/replayDiff.d.ts +55 -0
- package/dist/core/replayDiff.js +205 -0
- package/dist/core/replayDiff.js.map +1 -0
- package/dist/core/replayEngine.d.ts +3 -0
- package/dist/core/replayEngine.js +23 -1
- package/dist/core/replayEngine.js.map +1 -1
- package/dist/registry/errors.d.ts +21 -0
- package/dist/registry/errors.js +35 -0
- package/dist/registry/errors.js.map +1 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +20 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/manifest.d.ts +43 -0
- package/dist/registry/manifest.js +32 -0
- package/dist/registry/manifest.js.map +1 -0
- package/dist/registry/registry.d.ts +20 -0
- package/dist/registry/registry.js +201 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/risk/explainer.d.ts +39 -0
- package/dist/risk/explainer.js +214 -0
- package/dist/risk/explainer.js.map +1 -0
- package/dist/risk/index.d.ts +1 -0
- package/dist/risk/index.js +18 -0
- package/dist/risk/index.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# 🚀 yuangs CLI - An AI‑Augmented Shell
|
|
3
2
|
|
|
4
3
|
**以人类意图为中心的 AI‑Augmented Shell**
|
|
@@ -14,7 +13,6 @@
|
|
|
14
13
|
|
|
15
14
|
---
|
|
16
15
|
|
|
17
|
-
|
|
18
16
|
# yuangs
|
|
19
17
|
|
|
20
18
|
> **为终端而生的 AI 治理运行时**
|
|
@@ -24,7 +22,7 @@
|
|
|
24
22
|
|
|
25
23
|
它不是浏览器插件。
|
|
26
24
|
不是 GUI 助手。
|
|
27
|
-
|
|
25
|
+
也不是"披着 CLI 外衣的聊天机器人"。
|
|
28
26
|
|
|
29
27
|
它解决的是一个更难的问题:
|
|
30
28
|
|
|
@@ -36,7 +34,7 @@
|
|
|
36
34
|
|
|
37
35
|
### 🧩 做好一件事(Do one thing and do it well)
|
|
38
36
|
|
|
39
|
-
`yuangs`
|
|
37
|
+
`yuangs` 的定位不是"全能助手",而是一个**上下文治理器(Context Governor)**。
|
|
40
38
|
|
|
41
39
|
你始终清楚、并且显式地决定:
|
|
42
40
|
- 哪些文件进入 AI 上下文
|
|
@@ -55,22 +53,20 @@ ai "@src/**/*.ts #docs"
|
|
|
55
53
|
|
|
56
54
|
---
|
|
57
55
|
|
|
58
|
-
### 🛡️
|
|
59
|
-
|
|
60
|
-
很多终端 AI 工具追求“省事”,代价却是**不透明**:
|
|
56
|
+
### 🛡️ 开发者主权,而不是"方便至上"
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
58
|
+
很多终端 AI 工具追求"省事",代价却是**不透明**:
|
|
59
|
+
- 数据悄悄上传
|
|
60
|
+
- 上下文被隐式截断
|
|
61
|
+
- 执行逻辑不可审计
|
|
65
62
|
|
|
66
63
|
`yuangs` 选择了另一条路:
|
|
67
|
-
|
|
68
|
-
- ✅ **Swiss‑Cheese 采样预览**:发送前看到“每一块奶酪”
|
|
64
|
+
- ✅ **Swiss‑Cheese 采样预览**:发送前看到"每一块奶酪"
|
|
69
65
|
- ✅ **TokenPolicy**:先估算、再确认
|
|
70
66
|
- ✅ **Human‑in‑the‑loop**:切模型、发请求、跑执行,永远需要你点头
|
|
71
67
|
|
|
72
|
-
你的终端,
|
|
73
|
-
你的数据,
|
|
68
|
+
你的终端,
|
|
69
|
+
你的数据,
|
|
74
70
|
你的决定。
|
|
75
71
|
|
|
76
72
|
这才是极客眼中的**真自由**。
|
|
@@ -79,7 +75,7 @@ ai "@src/**/*.ts #docs"
|
|
|
79
75
|
|
|
80
76
|
### 🧠 可编程的 Agent 基础设施,而不是 Prompt Wrapper
|
|
81
77
|
|
|
82
|
-
`yuangs` 发布到 npm
|
|
78
|
+
`yuangs` 发布到 npm 的不是一个"命令",
|
|
83
79
|
而是一套**可组合的 Agent 运行时**。
|
|
84
80
|
|
|
85
81
|
核心抽象包括:
|
|
@@ -88,14 +84,14 @@ ai "@src/**/*.ts #docs"
|
|
|
88
84
|
- 能力感知的执行策略
|
|
89
85
|
- 可回放、可审计的执行记录
|
|
90
86
|
|
|
91
|
-
你拿到的不是黑盒,
|
|
87
|
+
你拿到的不是黑盒,
|
|
92
88
|
而是一盒**带说明书的乐高**。
|
|
93
89
|
|
|
94
90
|
你可以用它构建:
|
|
95
|
-
- 仓库结构分析器
|
|
96
|
-
- 日志 → AI 的自动采集管道
|
|
97
|
-
- 可控的重构 Agent
|
|
98
|
-
- 可审计的自动化流程
|
|
91
|
+
- 仓库结构分析器
|
|
92
|
+
- 日志 → AI 的自动采集管道
|
|
93
|
+
- 可控的重构 Agent
|
|
94
|
+
- 可审计的自动化流程
|
|
99
95
|
|
|
100
96
|
---
|
|
101
97
|
|
|
@@ -113,26 +109,29 @@ ai "@src/**/*.ts #docs"
|
|
|
113
109
|
✅ **可回放、可审计**
|
|
114
110
|
每一次 AI 行为都能复盘、复现、调试。
|
|
115
111
|
|
|
112
|
+
✅ **可解释、可治理**
|
|
113
|
+
通过 `explain` 和 `replay` 命令,理解系统决策过程。
|
|
114
|
+
|
|
116
115
|
---
|
|
117
116
|
|
|
118
117
|
## 适合谁?
|
|
119
118
|
|
|
120
|
-
- 终端原教旨主义者
|
|
121
|
-
- Linux / Unix 哲学信徒
|
|
122
|
-
- 被不透明 AI 工具伤过的工程师
|
|
123
|
-
- 追求**确定性高于便利性**的人
|
|
119
|
+
- 终端原教旨主义者
|
|
120
|
+
- Linux / Unix 哲学信徒
|
|
121
|
+
- 被不透明 AI 工具伤过的工程师
|
|
122
|
+
- 追求**确定性高于便利性**的人
|
|
124
123
|
|
|
125
124
|
如果你认同这句话:
|
|
126
125
|
|
|
127
|
-
>
|
|
126
|
+
> **"AI 很强大,所以它必须被治理。"**
|
|
128
127
|
|
|
129
128
|
那 `yuangs` 就是为你写的。
|
|
130
129
|
|
|
131
130
|
---
|
|
132
131
|
|
|
132
|
+
## 📜 语法说明
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
yuangs 通过一套**显式的符号语法**,清晰界定“副作用”的来源,
|
|
134
|
+
yuangs 通过一套**显式的符号语法**,清晰界定"副作用"的来源,
|
|
136
135
|
确保每一条命令 **可理解、可确认、可审计**。
|
|
137
136
|
|
|
138
137
|
| 语法 | 行为逻辑 | 决策来源 | 适用场景 |
|
|
@@ -158,18 +157,18 @@ yuangs ai
|
|
|
158
157
|
|
|
159
158
|
特性包括:
|
|
160
159
|
|
|
161
|
-
- **模式自动路由**
|
|
160
|
+
- **模式自动路由**
|
|
162
161
|
无需切换模式:
|
|
163
|
-
- 输入 `git status` → 直接执行
|
|
162
|
+
- 输入 `git status` → 直接执行
|
|
164
163
|
- 输入「解释这段代码」→ 进入对话
|
|
165
164
|
|
|
166
|
-
- **👻 Ghost Text(幽灵建议)**
|
|
167
|
-
根据历史记录与插件预测输入
|
|
165
|
+
- **👻 Ghost Text(幽灵建议)**
|
|
166
|
+
根据历史记录与插件预测输入
|
|
168
167
|
例如输入 `npm r`,灰色显示 `un dev`,按 `Tab` 采纳
|
|
169
168
|
|
|
170
169
|
- **⚡ 补全增强**
|
|
171
|
-
- **PATH 扫描**:自动补全 40+ 常用系统命令
|
|
172
|
-
- **精准行号**:支持 `@src/index.ts:10-50`
|
|
170
|
+
- **PATH 扫描**:自动补全 40+ 常用系统命令
|
|
171
|
+
- **精准行号**:支持 `@src/index.ts:10-50`
|
|
173
172
|
- **项目感知**:提升 `src/`、`packages/` 等目录权重
|
|
174
173
|
|
|
175
174
|
---
|
|
@@ -184,7 +183,6 @@ git diff | yuangs -w "Review 变更逻辑"
|
|
|
184
183
|
```
|
|
185
184
|
|
|
186
185
|
#### `-w` 智能读取
|
|
187
|
-
|
|
188
186
|
- 自动解析管道中的文件路径
|
|
189
187
|
- 只读取**被显式引用**的文件内容
|
|
190
188
|
- 不进行隐式文件系统扫描
|
|
@@ -193,7 +191,7 @@ git diff | yuangs -w "Review 变更逻辑"
|
|
|
193
191
|
|
|
194
192
|
### 3. 插件系统(Plugins)
|
|
195
193
|
|
|
196
|
-
在 `.shell/plugins/` 下放置自定义脚本,
|
|
194
|
+
在 `.shell/plugins/` 下放置自定义脚本,
|
|
197
195
|
扩展特定工具的补全与推理能力(如 `docker`、`kubectl`)。
|
|
198
196
|
|
|
199
197
|
示例:
|
|
@@ -210,437 +208,386 @@ module.exports = {
|
|
|
210
208
|
|
|
211
209
|
---
|
|
212
210
|
|
|
213
|
-
##
|
|
214
|
-
|
|
215
|
-
### 工程理性 vs. AI 狂热
|
|
216
|
-
|
|
217
|
-
yuangs 并不是一个试图“替你完成任务”的工具。
|
|
218
|
-
它诞生于一个更克制的问题:
|
|
219
|
-
|
|
220
|
-
> **在 AI 能力爆炸的时代,命令行该如何进化,而不背叛工程理性?**
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
### 为什么 yuangs 不是 Autonomous Agent?
|
|
225
|
-
|
|
226
|
-
Autonomous Agent 承诺:
|
|
227
|
-
给 AI 一个目标,让它自行规划、执行、修正。
|
|
211
|
+
## 🔒 Phase 2: Explainability & Governance (v1)
|
|
228
212
|
|
|
229
|
-
|
|
213
|
+
### 🎯 概述
|
|
230
214
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
- 自动执行系统命令的权力
|
|
236
|
-
- 隐式修改文件或运行环境的权力
|
|
237
|
-
- 在未确认的情况下产生任何副作用的权力
|
|
215
|
+
Phase 2 引入了**系统可观测性和控制能力**,但不改变核心行为:
|
|
216
|
+
- ✅ **Explainability**:人类可读的执行解释
|
|
217
|
+
- ✅ **Replay++**:Dry-run、explain 和 diff 能力
|
|
218
|
+
- ✅ **Skill Control**:启用/禁用技能以实现细粒度控制
|
|
238
219
|
|
|
239
220
|
---
|
|
240
221
|
|
|
241
|
-
##
|
|
242
|
-
|
|
243
|
-
yuangs 严格遵循以下边界,以确保长期工程可靠性:
|
|
222
|
+
## 📦 新命令
|
|
244
223
|
|
|
245
|
-
|
|
246
|
-
AI 负责推理与建议,人类始终是最终决策者与执行者。
|
|
224
|
+
### `yuangs explain [id | last]`
|
|
247
225
|
|
|
248
|
-
|
|
249
|
-
AI 不具备系统写权限。
|
|
250
|
-
所有建议必须转化为**用户可见的 Action**并经确认后执行。
|
|
251
|
-
|
|
252
|
-
- **显式上下文(Explicit Context)**
|
|
253
|
-
除显式输入外,yuangs 不会在后台扫描文件系统。
|
|
254
|
-
|
|
255
|
-
- **可回溯性(Auditable Records)**
|
|
256
|
-
所有 AI 建议、命令生成与执行结果均被记录,
|
|
257
|
-
确保完整决策链条可追溯、可审计。
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## 💡 使用场景示例
|
|
262
|
-
|
|
263
|
-
### 场景 A:智能调试
|
|
226
|
+
**目的**:解释系统为什么做出某个决策
|
|
264
227
|
|
|
228
|
+
**用法**:
|
|
265
229
|
```bash
|
|
266
|
-
|
|
267
|
-
|
|
230
|
+
# 解释最近一次执行
|
|
231
|
+
yuangs explain last
|
|
268
232
|
|
|
269
|
-
|
|
233
|
+
# 解释指定 ID 的执行
|
|
234
|
+
yuangs explain exec_1768820380225_rgts34981
|
|
270
235
|
```
|
|
271
236
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
### 场景 B:命令生成
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
ai -e "查找当前目录下大于 100M 的文件"
|
|
237
|
+
**输出格式(v1)**:
|
|
280
238
|
```
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
239
|
+
=== Execution Explanation ===
|
|
240
|
+
[1] Command
|
|
241
|
+
- Name: ai-command
|
|
242
|
+
- Args: echo "hello"
|
|
243
|
+
|
|
244
|
+
[2] Decision
|
|
245
|
+
- Strategy: capability-match
|
|
246
|
+
- Selected Model: gemini-2.5-flash-lite
|
|
247
|
+
- Reason: Capability-based selection with fallback support
|
|
248
|
+
|
|
249
|
+
[3] Model
|
|
250
|
+
- Name: gemini-2.5-flash-lite
|
|
251
|
+
- Provider: aiproxy
|
|
252
|
+
- Context Window: 8000
|
|
253
|
+
- Cost Profile: low
|
|
254
|
+
|
|
255
|
+
[4] Skills
|
|
256
|
+
- (none)
|
|
257
|
+
|
|
258
|
+
[5] Meta
|
|
259
|
+
- Execution ID: exec_1768820380225_rgts34981
|
|
260
|
+
- Timestamp: 2026-01-19T10:59:40.225Z
|
|
261
|
+
- Replayable: true
|
|
262
|
+
- Version: unknown
|
|
263
|
+
=============================
|
|
292
264
|
```
|
|
293
265
|
|
|
294
|
-
|
|
266
|
+
**关键特性**:
|
|
267
|
+
- ✅ 纯只读操作(无副作用)
|
|
268
|
+
- ✅ 稳定、可 snapshot 的输出
|
|
269
|
+
- ✅ 为未来的 diff/audit 工作流做好的准备
|
|
295
270
|
|
|
296
271
|
---
|
|
297
272
|
|
|
298
|
-
|
|
273
|
+
### `yuangs replay <id> [options]`
|
|
299
274
|
|
|
300
|
-
|
|
301
|
-
npm install -g yuangs
|
|
302
|
-
```
|
|
275
|
+
**目的**:使用控制标志重放执行
|
|
303
276
|
|
|
304
|
-
|
|
277
|
+
**选项**:
|
|
278
|
+
| 选项 | 描述 |
|
|
279
|
+
|--------|-------------|
|
|
280
|
+
| `-s, --strict` | 严格重放(使用精确模型) |
|
|
281
|
+
| `-c, --compatible` | 兼容重放(允许 fallback) |
|
|
282
|
+
| `-r, --re-evaluate` | 使用当前配置重新评估 |
|
|
283
|
+
| `-v, --verbose` | 详细输出 |
|
|
284
|
+
| `--dry` | Dry run - 显示将要发生的内容但不执行 |
|
|
285
|
+
| `--explain` | 在重放前显示解释 |
|
|
286
|
+
| `--diff` | 显示原始配置与当前配置的差异 |
|
|
305
287
|
|
|
288
|
+
**用法示例**:
|
|
306
289
|
```bash
|
|
307
|
-
|
|
308
|
-
yuangs
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
---
|
|
312
|
-
|
|
313
|
-
## 🗓️ 近期更新(Changelog)
|
|
314
|
-
|
|
315
|
-
- **v2.11.0** (2026‑01‑18)
|
|
316
|
-
新增 40+ Shell 内置命令支持(cd, pwd, ls, git 等)
|
|
290
|
+
# 使用解释进行 dry run
|
|
291
|
+
yuangs replay exec_1768820380225_rgts34981 --dry --explain
|
|
317
292
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
- **v1.3.67** (2026‑01‑17)
|
|
322
|
-
新增 `@` 文件选择与 `#` 目录读取功能
|
|
323
|
-
|
|
324
|
-
---
|
|
325
|
-
|
|
326
|
-
## ⚖️ 维护者
|
|
293
|
+
# 仅显示 diff(不执行)
|
|
294
|
+
yuangs replay exec_1768820380225_rgts34981 --diff --dry
|
|
327
295
|
|
|
328
|
-
|
|
296
|
+
# 带差异的完整重放
|
|
297
|
+
yuangs replay exec_1768820380225_rgts34981 --diff
|
|
298
|
+
```
|
|
329
299
|
|
|
330
|
-
|
|
331
|
-
|
|
300
|
+
**重放行为矩阵**:
|
|
301
|
+
| explain | dry | strict | 行为 |
|
|
302
|
+
|--------|-----|--------|----------|
|
|
303
|
+
| ✅ | ✅ | any | 仅解释,不执行 |
|
|
304
|
+
| ✅ | ❌ | ✅ | 解释 → 重放 |
|
|
305
|
+
| ❌ | ✅ | ✅ | 打印严格信息 → 退出 |
|
|
306
|
+
| ❌ | ❌ | ✅ | 正常重放 |
|
|
332
307
|
|
|
333
|
-
|
|
308
|
+
**差异输出**:
|
|
309
|
+
```
|
|
310
|
+
=== Replay Diff ===
|
|
311
|
+
[Decision]
|
|
312
|
+
- no change
|
|
334
313
|
|
|
335
|
-
|
|
314
|
+
[Model]
|
|
315
|
+
- no change
|
|
336
316
|
|
|
337
|
-
|
|
338
|
-
-
|
|
339
|
-
|
|
340
|
-
- **非目标**: [docs/non-goals.md](docs/non-goals.md)
|
|
341
|
-
- **威胁模型**: [docs/threat_model.md](docs/threat_model.md)
|
|
342
|
-
- **实现差距分析**: [docs/implementation_gap.md](docs/implementation_gap.md)
|
|
343
|
-
- **变更日志**: [docs/CHANGELOG.md](docs/CHANGELOG.md)
|
|
344
|
-
- **Shell 补全**: [docs/tab_completion_guide.md](docs/tab_completion_guide.md)
|
|
345
|
-
- **上下文优化**: [docs/context_optimization_analysis.md](docs/context_optimization_analysis.md)
|
|
346
|
-
- **代理管道**: [docs/AGENT_PIPELINE.md](docs/AGENT_PIPELINE.md)
|
|
347
|
-
- **上下文管理**: [docs/context_management.md](docs/context_management.md)
|
|
317
|
+
[Skills]
|
|
318
|
+
- no change
|
|
319
|
+
===================
|
|
348
320
|
```
|
|
349
321
|
|
|
350
322
|
---
|
|
351
323
|
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
# 一、先明确:**这种“感觉”到底是什么?**
|
|
356
|
-
|
|
357
|
-
如果抽象到一句话,它不是“AI 很聪明”,而是:
|
|
358
|
-
|
|
359
|
-
> **AI 在该收手的时候会收手,在该判断的时候才判断。**
|
|
324
|
+
### `yuangs skills <subcommand>`
|
|
360
325
|
|
|
361
|
-
|
|
326
|
+
**目的**:管理技能库
|
|
362
327
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
这三条一旦被破坏,`yuangs` 就会变成另一个“吵闹的 Copilot”。
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
# 二、把感觉固化 = 把“边界”写死
|
|
328
|
+
**子命令**:
|
|
329
|
+
```bash
|
|
330
|
+
# 列出所有技能及其分数
|
|
331
|
+
yuangs skills list
|
|
372
332
|
|
|
373
|
-
|
|
333
|
+
# 解释特定技能
|
|
334
|
+
yuangs skills explain <skill-name>
|
|
374
335
|
|
|
375
|
-
|
|
336
|
+
# 禁用技能
|
|
337
|
+
yuangs skills disable <skill-name>
|
|
376
338
|
|
|
377
|
-
|
|
339
|
+
# 启用技能
|
|
340
|
+
yuangs skills enable <skill-name>
|
|
341
|
+
```
|
|
378
342
|
|
|
379
|
-
|
|
380
|
-
|
|
343
|
+
**输出示例**(`skills list`):
|
|
344
|
+
```
|
|
345
|
+
📦 Skills (3)
|
|
346
|
+
|
|
347
|
+
✔ deploy-production
|
|
348
|
+
Confidence: 72%
|
|
349
|
+
Success: 8 / Failure: 1
|
|
350
|
+
Last used: 2 days ago
|
|
351
|
+
|
|
352
|
+
✔ cleanup-logs
|
|
353
|
+
Confidence: 41%
|
|
354
|
+
Success: 5 / Failure: 7
|
|
355
|
+
Last used: 1 day ago
|
|
356
|
+
|
|
357
|
+
⊘ legacy-search (disabled)
|
|
358
|
+
Confidence: 23%
|
|
359
|
+
Success: 2 / Failure: 6
|
|
360
|
+
Last used: 7 days ago
|
|
381
361
|
```
|
|
382
362
|
|
|
383
|
-
|
|
363
|
+
**关键特性**:
|
|
364
|
+
- ✅ 技能可以被禁用而不删除
|
|
365
|
+
- ✅ 技能按相关性评分和排序
|
|
366
|
+
- ✅ 禁用的技能不影响新决策
|
|
367
|
+
- ✅ 所有技能在 `explain` 输出中仍然可见
|
|
384
368
|
|
|
385
|
-
|
|
369
|
+
---
|
|
386
370
|
|
|
387
|
-
|
|
388
|
-
❌ “也许之前存在 XXX 架构问题”
|
|
371
|
+
## 🧭 Explain 输出规范 v1
|
|
389
372
|
|
|
390
|
-
|
|
373
|
+
explain 输出遵循严格格式,设计用于:
|
|
374
|
+
- ✅ 人类可读性
|
|
375
|
+
- ✅ 稳定性和 snapshot 兼容性
|
|
376
|
+
- ✅ 未来的 diff/audit 工作流
|
|
377
|
+
- ✅ 无实现耦合
|
|
391
378
|
|
|
392
|
-
|
|
379
|
+
**结构**(5 个部分,不可变顺序):
|
|
380
|
+
1. `[1] Command` - 用户输入层
|
|
381
|
+
2. `[2] Decision` - 决策核心
|
|
382
|
+
3. `[3] Model` - 执行环境
|
|
383
|
+
4. `[4] Skills` - 影响决策的技能
|
|
384
|
+
5. `[5] Meta` - 审计/重放元数据
|
|
393
385
|
|
|
394
|
-
|
|
386
|
+
**重要提示**:
|
|
387
|
+
- ⚠️ 不要在升级规范版本时更改格式
|
|
388
|
+
- ✅ 输出是纯文本(snapshot 无颜色)
|
|
389
|
+
- ✅ 相同执行记录 = 100% 可重现输出
|
|
395
390
|
|
|
396
391
|
---
|
|
397
392
|
|
|
398
|
-
##
|
|
399
|
-
|
|
400
|
-
这是你这个例子里最“高级”的地方。
|
|
401
|
-
|
|
402
|
-
- 输入:只有一条注释
|
|
403
|
-
- 输出:朴素、干净、甚至有点“空”
|
|
393
|
+
## 🔒 技能与启用状态
|
|
404
394
|
|
|
405
|
-
|
|
395
|
+
技能现在有一个 `enabled` 字段,控制它们在新决策中的参与:
|
|
406
396
|
|
|
407
|
-
|
|
397
|
+
**默认行为**:
|
|
398
|
+
- ✅ 新技能:`enabled: true`
|
|
399
|
+
- ✅ 旧技能:`enabled: true`(如果字段缺失)
|
|
400
|
+
- ❌ 禁用的技能:不包含在 `getRelevantSkills()` 中
|
|
408
401
|
|
|
409
|
-
|
|
402
|
+
**使用场景**:
|
|
403
|
+
1. **治理**:临时禁用有风险的技能
|
|
404
|
+
2. **A/B 测试**:比较不同的技能配置
|
|
405
|
+
3. **回滚**:禁用新添加的技能而不删除
|
|
406
|
+
4. **审计**:在 explain 输出中查看禁用的技能
|
|
410
407
|
|
|
411
|
-
|
|
408
|
+
**CLI 命令**:
|
|
409
|
+
```bash
|
|
410
|
+
# 禁用技能
|
|
411
|
+
yuangs skills disable risky-operation
|
|
412
412
|
|
|
413
|
-
|
|
413
|
+
# 列出以验证
|
|
414
|
+
yuangs skills list
|
|
414
415
|
|
|
415
|
-
|
|
416
|
+
# 如果需要,重新启用
|
|
417
|
+
yuangs skills enable risky-operation
|
|
418
|
+
```
|
|
416
419
|
|
|
417
420
|
---
|
|
418
421
|
|
|
419
|
-
##
|
|
420
|
-
|
|
421
|
-
这条极其重要。
|
|
422
|
+
## 🧪 测试与 Snapshots
|
|
422
423
|
|
|
423
|
-
|
|
424
|
+
### 创建 Explain Snapshots
|
|
424
425
|
|
|
425
|
-
❌ 自动:
|
|
426
|
-
> “这个改动不太好,建议重构”
|
|
427
|
-
|
|
428
|
-
✅ 触发式:
|
|
429
426
|
```bash
|
|
430
|
-
|
|
431
|
-
|
|
427
|
+
# 创建最近一次执行的 snapshot
|
|
428
|
+
yuangs replay exec_1768820380225_rgts34981 --explain --dry > snapshot.txt
|
|
432
429
|
```
|
|
433
430
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
> **没有 judgement prompt,AI 只做 description。**
|
|
431
|
+
Snapshots 可用于:
|
|
432
|
+
- ✅ 回归测试
|
|
433
|
+
- ✅ 输出格式验证
|
|
434
|
+
- ✅ 文档示例
|
|
435
|
+
- ✅ 审计线索
|
|
440
436
|
|
|
441
437
|
---
|
|
442
438
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
你现在其实已经有了三个**隐式模式**,只是还没被“命名”。
|
|
446
|
-
|
|
447
|
-
我帮你命名,它们一旦被命名,就能长期稳定存在。
|
|
448
|
-
|
|
449
|
-
---
|
|
439
|
+
## 💡 使用场景示例
|
|
450
440
|
|
|
451
|
-
|
|
441
|
+
### 场景 A:智能调试
|
|
452
442
|
|
|
453
443
|
```bash
|
|
454
|
-
|
|
455
|
-
|
|
444
|
+
@!build.sh
|
|
445
|
+
# 系统返回报错…
|
|
456
446
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
- 不推断
|
|
460
|
-
- 不给建议
|
|
461
|
-
- 只还原信息
|
|
447
|
+
上面的错误是什么意思?
|
|
448
|
+
```
|
|
462
449
|
|
|
463
|
-
|
|
450
|
+
AI 将结合 **build.sh 内容 + 实际输出** 进行分析。
|
|
464
451
|
|
|
465
452
|
---
|
|
466
453
|
|
|
467
|
-
|
|
454
|
+
### 场景 B:命令生成
|
|
468
455
|
|
|
469
456
|
```bash
|
|
470
|
-
|
|
457
|
+
ai -e "查找当前目录下大于 100M 的文件"
|
|
471
458
|
```
|
|
472
459
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
- 可以提出风险
|
|
476
|
-
- 可以提建议
|
|
477
|
-
- 仍然基于 diff
|
|
478
|
-
|
|
479
|
-
👉 **这是工程协作态。**
|
|
460
|
+
AI 生成建议命令(如 `find . -type f -size +100M`),
|
|
461
|
+
**存入剪贴板,等待你确认执行。**
|
|
480
462
|
|
|
481
463
|
---
|
|
482
464
|
|
|
483
|
-
|
|
465
|
+
### 场景 C:项目审计
|
|
484
466
|
|
|
485
467
|
```bash
|
|
486
|
-
|
|
468
|
+
#src/
|
|
469
|
+
分析这些模块的功能
|
|
487
470
|
```
|
|
488
471
|
|
|
489
|
-
|
|
490
|
-
- 允许假设
|
|
491
|
-
- 允许不确定性
|
|
492
|
-
- 必须显式标注「推测」
|
|
493
|
-
|
|
494
|
-
👉 **这是思考扩展态,不是事实陈述。**
|
|
472
|
+
AI 在**显式授权**下读取目录内容并生成结构分析。
|
|
495
473
|
|
|
496
474
|
---
|
|
497
475
|
|
|
498
|
-
|
|
476
|
+
## 📝 实现说明
|
|
499
477
|
|
|
500
|
-
|
|
478
|
+
### Explain Output v1
|
|
501
479
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
# 四、一个非常重要但容易被忽略的点
|
|
480
|
+
**文件**:`src/core/explain.ts`
|
|
505
481
|
|
|
506
|
-
|
|
482
|
+
**关键设计**:
|
|
483
|
+
- 纯函数(无副作用)
|
|
484
|
+
- 无全局状态的外部依赖
|
|
485
|
+
- 使用现有的 `ExecutionRecord` 结构
|
|
486
|
+
- 稳定格式(版本化)
|
|
507
487
|
|
|
508
|
-
|
|
488
|
+
---
|
|
509
489
|
|
|
510
|
-
|
|
511
|
-
- 不强行帮忙
|
|
512
|
-
- 不输出废话
|
|
490
|
+
### Replay Diff
|
|
513
491
|
|
|
514
|
-
|
|
515
|
-
但在 **3 个月 / 6 个月 / 1 年** 后:
|
|
492
|
+
**文件**:`src/core/replayDiff.ts`
|
|
516
493
|
|
|
517
|
-
|
|
518
|
-
|
|
494
|
+
**关键设计**:
|
|
495
|
+
- 比较 Decision、Model 和 Skills 层
|
|
496
|
+
- 显示 added/removed/changed 技能
|
|
497
|
+
- 语义 diff(非 token 级别)
|
|
498
|
+
- 与 Explain v1 格式兼容
|
|
519
499
|
|
|
520
500
|
---
|
|
521
501
|
|
|
522
|
-
###
|
|
523
|
-
|
|
524
|
-
> **A governed AI runtime for the terminal.**
|
|
525
|
-
> *No OOM. No surprises. Human in the loop — always.*
|
|
526
|
-
|
|
527
|
-
`yuangs` is a Unix‑style AI tool for developers who live in the terminal and **refuse black boxes**.
|
|
502
|
+
### Skills Control
|
|
528
503
|
|
|
529
|
-
|
|
530
|
-
It does **not** hide decisions behind magic prompts.
|
|
531
|
-
Instead, it answers a harder question:
|
|
504
|
+
**文件**:`src/agent/skills.ts`
|
|
532
505
|
|
|
533
|
-
|
|
506
|
+
**关键变更**:
|
|
507
|
+
- 向 `Skill` 接口添加 `enabled: boolean` 字段
|
|
508
|
+
- 导出 `computeSkillScore()` 供 CLI 使用
|
|
509
|
+
- `getRelevantSkills()` 过滤禁用的技能
|
|
534
510
|
|
|
535
511
|
---
|
|
536
512
|
|
|
537
|
-
##
|
|
538
|
-
|
|
539
|
-
### 🧩 Do one thing, and do it well
|
|
540
|
-
|
|
541
|
-
`yuangs` is not a browser plugin, not a GUI assistant, and not a “chatbot in disguise”.
|
|
542
|
-
|
|
543
|
-
It is a **context governor**.
|
|
513
|
+
## 📦 安装与配置
|
|
544
514
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
- when sampling happens
|
|
549
|
-
- when execution is permitted
|
|
515
|
+
```bash
|
|
516
|
+
npm install -g yuangs
|
|
517
|
+
```
|
|
550
518
|
|
|
551
|
-
|
|
519
|
+
常用配置:
|
|
552
520
|
|
|
553
521
|
```bash
|
|
554
|
-
|
|
522
|
+
yuangs config defaultModel Assistant
|
|
523
|
+
yuangs config accountType pro
|
|
555
524
|
```
|
|
556
525
|
|
|
557
|
-
This is Unix philosophy applied to AI:
|
|
558
|
-
**syntax is power**.
|
|
559
|
-
|
|
560
526
|
---
|
|
561
527
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
Most AI CLI tools optimize for convenience — at the cost of trust.
|
|
565
|
-
|
|
566
|
-
They:
|
|
567
|
-
- upload silently
|
|
568
|
-
- truncate context implicitly
|
|
569
|
-
- execute plans opaquely
|
|
570
|
-
|
|
571
|
-
`yuangs` does the opposite.
|
|
572
|
-
|
|
573
|
-
- **Swiss‑cheese sampling preview** — see *exactly* what will be sent
|
|
574
|
-
- **TokenPolicy** — estimate before resolve, always
|
|
575
|
-
- **Human‑in‑the‑loop decisions** — model switches, sampling, execution
|
|
528
|
+
## 🗓️ 近期更新(Changelog)
|
|
576
529
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
530
|
+
- **v2.29.0** (2026‑01‑20)
|
|
531
|
+
- 新增 Explainability 功能(`explain` 命令)
|
|
532
|
+
- 新增 Replay++ 支持(`--dry`, `--explain`, `--diff`)
|
|
533
|
+
- 新增 Skills 管理命令(`skills list/explain/disable/enable`)
|
|
534
|
+
- 引入 Explain Output Spec v1 规范
|
|
535
|
+
- 实现 Replay Diff 功能
|
|
536
|
+
- **v2.11.0** (2026‑01‑18)
|
|
537
|
+
- 新增 40+ Shell 内置命令支持(cd, pwd, ls, git 等)
|
|
538
|
+
- **v2.10.0** (2026‑01‑18)
|
|
539
|
+
- 引入 Shell 交互内核、Ghost Text 与插件系统
|
|
540
|
+
- **v1.3.67** (2026‑01‑17)
|
|
541
|
+
- 新增 `@` 文件选择与 `#` 目录读取功能
|
|
580
542
|
|
|
581
543
|
---
|
|
582
544
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
Publishing `yuangs` to npm doesn’t give you just a command.
|
|
586
|
-
It gives you **an agent runtime you can compose**.
|
|
545
|
+
## ✅ Phase 2 完成清单
|
|
587
546
|
|
|
588
|
-
|
|
589
|
-
- `PendingContextItem`
|
|
590
|
-
- token estimation vs resolution
|
|
591
|
-
- capability‑aware execution
|
|
592
|
-
- replayable execution records
|
|
547
|
+
所有 Phase 2 目标已完成:
|
|
593
548
|
|
|
594
|
-
|
|
595
|
-
|
|
549
|
+
- [x] Explainability(ExecutionRecord 级别)
|
|
550
|
+
- [x] Replay dry / explain / strict
|
|
551
|
+
- [x] Skill scoring & enable 标志
|
|
552
|
+
- [x] 所有三个功能的 CLI 集成
|
|
553
|
+
- [x] Replay diff 实现
|
|
554
|
+
- [x] Skills enabled 过滤
|
|
555
|
+
- [x] Explain v1 规范
|
|
556
|
+
- [x] Snapshot 测试能力
|
|
596
557
|
|
|
597
|
-
|
|
598
|
-
- repo analyzers
|
|
599
|
-
- log‑to‑AI pipelines
|
|
600
|
-
- controlled refactoring agents
|
|
601
|
-
- auditable automation
|
|
558
|
+
**下一阶段**:Phase 3 - 高级治理与项目级智能
|
|
602
559
|
|
|
603
560
|
---
|
|
604
561
|
|
|
605
|
-
##
|
|
606
|
-
|
|
607
|
-
✅ **No OOM, no surprise**
|
|
608
|
-
Large repos, massive logs — nothing is fully loaded or sent without confirmation.
|
|
609
|
-
|
|
610
|
-
✅ **Human in the loop, always**
|
|
611
|
-
AI never escalates privileges or cost silently.
|
|
612
|
-
|
|
613
|
-
✅ **Power of syntax**
|
|
614
|
-
`@file`, `#dir`, intent‑driven commands — faster than any drag‑and‑drop UI.
|
|
562
|
+
## 📚 更多信息
|
|
615
563
|
|
|
616
|
-
|
|
617
|
-
|
|
564
|
+
- **设计原理**: [docs/implementation_principles.md](docs/implementation_principles.md)
|
|
565
|
+
- **场景示例**: [docs/scenarios.md](docs/scenarios.md)
|
|
566
|
+
- **执行语义**: [docs/semantics.md](docs/semantics.md)
|
|
567
|
+
- **非目标**: [docs/non-goals.md](docs/non-goals.md)
|
|
568
|
+
- **威胁模型**: [docs/threat_model.md](docs/threat_model.md)
|
|
569
|
+
- **变更日志**: [docs/CHANGELOG.md](docs/CHANGELOG.md)
|
|
570
|
+
- **Shell 补全**: [docs/tab_completion_guide.md](docs/tab_completion_guide.md)
|
|
571
|
+
- **上下文优化**: [docs/context_optimization_analysis.md](docs/context_optimization_analysis.md)
|
|
572
|
+
- **代理管道**: [docs/AGENT_PIPELINE.md](docs/AGENT_PIPELINE.md)
|
|
573
|
+
- **上下文管理**: [docs/context_management.md](docs/context_management.md)
|
|
618
574
|
|
|
619
575
|
---
|
|
620
576
|
|
|
621
|
-
##
|
|
622
|
-
|
|
623
|
-
- Terminal‑first developers
|
|
624
|
-
- Linux / Unix philosophy believers
|
|
625
|
-
- Engineers burned by opaque AI tools
|
|
626
|
-
- Anyone who wants **control before convenience**
|
|
577
|
+
## ⚖️ 维护者
|
|
627
578
|
|
|
628
|
-
|
|
629
|
-
> *“AI is powerful — and that’s exactly why it must be governed.”*
|
|
579
|
+
**@yuanguangshan**
|
|
630
580
|
|
|
631
|
-
|
|
581
|
+
> **AI 提供思路,人类掌控执行。**
|
|
582
|
+
> 这不是妥协,而是对工程理性的尊重。
|
|
632
583
|
|
|
633
584
|
---
|
|
634
585
|
|
|
635
|
-
##
|
|
636
|
-
|
|
637
|
-
`yuangs` is actively evolving.
|
|
638
|
-
The core governance model is stable; interfaces are still sharpening.
|
|
639
|
-
|
|
640
|
-
Contributions, ideas, and principled criticism are welcome.
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
> **“AI should never appear smarter than the input unless explicitly asked.”**
|
|
586
|
+
## 状态
|
|
644
587
|
|
|
588
|
+
`yuangs` 正在积极演进中。
|
|
589
|
+
核心治理模型已稳定;接口仍在优化中。
|
|
645
590
|
|
|
591
|
+
欢迎贡献、想法和有原则的批评。
|
|
646
592
|
|
|
593
|
+
> **"AI 除非被明确要求,否则不应该比输入看起来更聪明。"**
|