@hongmaple0820/scale-engine 0.10.0 → 0.11.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 (40) hide show
  1. package/README.en.md +127 -196
  2. package/README.md +168 -1114
  3. package/dist/api/cli.js +2 -2
  4. package/dist/api/cli.js.map +1 -1
  5. package/dist/artifact/types.d.ts +1 -1
  6. package/dist/artifact/types.js.map +1 -1
  7. package/dist/capabilities/BrowserQACapability.d.ts +151 -0
  8. package/dist/capabilities/BrowserQACapability.js +344 -0
  9. package/dist/capabilities/BrowserQACapability.js.map +1 -0
  10. package/dist/cli/evolutionCommands.d.ts +112 -0
  11. package/dist/cli/evolutionCommands.js +246 -0
  12. package/dist/cli/evolutionCommands.js.map +1 -0
  13. package/dist/cli/phaseCommands.d.ts +9 -0
  14. package/dist/cli/phaseCommands.js +169 -48
  15. package/dist/cli/phaseCommands.js.map +1 -1
  16. package/dist/guardrails/OWASPDetector.d.ts +58 -0
  17. package/dist/guardrails/OWASPDetector.js +508 -0
  18. package/dist/guardrails/OWASPDetector.js.map +1 -0
  19. package/dist/workflow/ReviewAnalyzer.d.ts +5 -0
  20. package/dist/workflow/ReviewAnalyzer.js +194 -10
  21. package/dist/workflow/ReviewAnalyzer.js.map +1 -1
  22. package/dist/workflow/VerificationCommands.d.ts +4 -0
  23. package/dist/workflow/VerificationCommands.js +2 -0
  24. package/dist/workflow/VerificationCommands.js.map +1 -1
  25. package/dist/workflow/WorkflowEngine.js +1 -1
  26. package/dist/workflow/WorkflowEngine.js.map +1 -1
  27. package/dist/workflow/evolution/LessonExtractor.d.ts +90 -0
  28. package/dist/workflow/evolution/LessonExtractor.js +317 -0
  29. package/dist/workflow/evolution/LessonExtractor.js.map +1 -0
  30. package/dist/workflow/evolution/SelfImproveEngine.d.ts +156 -0
  31. package/dist/workflow/evolution/SelfImproveEngine.js +361 -0
  32. package/dist/workflow/evolution/SelfImproveEngine.js.map +1 -0
  33. package/dist/workflow/gates/GateSystem.d.ts +28 -2
  34. package/dist/workflow/gates/GateSystem.js +291 -82
  35. package/dist/workflow/gates/GateSystem.js.map +1 -1
  36. package/dist/workflow/qa/E2ETestRunner.d.ts +102 -0
  37. package/dist/workflow/qa/E2ETestRunner.js +227 -0
  38. package/dist/workflow/qa/E2ETestRunner.js.map +1 -0
  39. package/dist/workflow/types.d.ts +7 -0
  40. package/package.json +3 -3
package/README.md CHANGED
@@ -1,1114 +1,168 @@
1
- <p align="center">
2
- <img src="https://img.shields.io/badge/version-0.8.0-orange?style=flat-square" alt="version" />
3
- <img src="https://img.shields.io/badge/agents-12-blue?style=flat-square" alt="agents" />
4
- <img src="https://img.shields.io/badge/workflows-10-green?style=flat-square" alt="workflows" />
5
- <img src="https://img.shields.io/badge/detectors-9-red?style=flat-square" alt="detectors" />
6
- <img src="https://img.shields.io/badge/tests-410-passing-brightgreen?style=flat-square" alt="tests" />
7
- <img src="https://img.shields.io/badge/npm-0.8.0-cb3837?style=flat-square&logo=npm" alt="npm" />
8
- </p>
9
-
10
- # SCALE Engine v0.8.0
11
-
12
- > **S**caffold · **C**ontrol · **A**rtifact · **L**earn · **E**volve
13
- >
14
- > AI 工程化脚手架引擎 — 让 AI Agent 在物理约束下工作,而不是靠提示词自律
15
-
16
- ---
17
-
18
- ## 📦 仓库地址
19
-
20
- | 平台 | 地址 |
21
- |------|------|
22
- | **GitHub** | https://github.com/hongmaple0820/scale-engine |
23
- | **Gitee (镜像)** | https://gitee.com/hongmaple/scale-engine |
24
- | **npm** | https://www.npmjs.com/package/@hongmaple0820/scale-engine |
25
-
26
- **语言版本:** [中文文档](README.md) | [English Documentation](README.en.md)
27
-
28
- ---
29
-
30
- ## 📖 目录
31
-
32
- - [项目介绍](#-项目介绍)
33
- - [技术架构](#-技术架构)
34
- - [功能特性](#-功能特性)
35
- - [快速开始](#-快速开始)
36
- - [完整 API 参考](#-完整-api-参考)
37
- - [社区与推广](#-社区与推广)
38
- - [CHANGELOG](#-changelog)
39
- - [贡献指南](#-贡献指南)
40
-
41
- ---
42
-
43
- ## 🎯 项目介绍
44
-
45
- ### 什么是 SCALE Engine?
46
-
47
- SCALE Engine 是一个 **AI 工程化脚手架引擎**,为 AI Agent(Claude Code、Codex CLI、OpenCode、Cursor、Gemini CLI 等)提供物理约束层,确保 AI 在编码过程中遵循工程规范,而不是依赖提示词的"自律"。
48
-
49
- ### 为什么需要它?
50
-
51
- 当前 AI 编码的核心矛盾:
52
-
53
- ```
54
- ❌ 提示词说 "你应该跑测试" → AI 可以假装跑了
55
- 提示词说 "不要硬编码密钥" → AI 可以忽视规则
56
- ❌ 提示词说 "别暴力重试" → AI 可以反复重试
57
- ❌ 提示词说 "先规划再写代码" → AI 可以跳过规划直接写
58
- ```
59
-
60
- **根本问题**:提示词是"建议",AI 可以选择性遵守。这就是为什么你经常看到:
61
-
62
- - AI 声称"已完成"但没跑测试
63
- - AI 反复用同一策略重试失败
64
- - AI 甩锅给"环境问题"但没验证
65
- - AI 在同一个文件来回修改
66
- - AI 硬编码密钥到代码中
67
-
68
- SCALE Engine 的解决方案:**物理约束**。
69
-
70
- ```
71
- ✅ Stop Hook 检查 "未跑测试" → AI 物理无法跳过
72
- PreTool Hook 拦截危险命令 → AI 物理无法执行
73
- ✅ FSM 状态机控制工作流 → AI 物理无法跳步
74
- ✅ Role 网关限制工具权限 → AI 物理无法越权
75
- 检测器发现异常行为 → AI 物理无法隐藏
76
- ```
77
-
78
- ### 它是如何工作的?
79
-
80
- SCALE Engine 通过 **六层架构** 实现 AI 工程化:
81
-
82
- | 层级 | 职责 | 核心机制 |
83
- |------|------|---------|
84
- | **L1 Context** | 上下文构建 | Token 预算 + 哲学注入 + 场景感知 |
85
- | **L2 Guardrails** | 安全护栏 | 9 检测器 + Role 网关 + 级联升级 |
86
- | **L3 Observability** | 可观测性 | EventBus + BehaviorTracker + 模式检测 |
87
- | **L4 Orchestration** | 任务编排 | TaskEngine + Effects + 10 工作流 |
88
- | **L5 Memory** | 知识记忆 | KnowledgeBase + 衰减算法 + 技能发现 |
89
- | **L6 Evolution** | 自进化 | Defect→Lesson→Rule→Hook 闭环 |
90
-
91
- ### 核心哲学
92
-
93
- ```
94
- 提示词自律 ❌ 物理约束 ✅
95
- ─────────────────────────────────────────────────────
96
- "你应该跑测试" → Stop Hook 物理拦截未验证的完成
97
- "不要硬编码密钥" → PreTool Hook 物理阻止密钥写入
98
- "别暴力重试" → BruteRetry 检测器 3次强制换策略
99
- "先规划再编码" → FSM 状态机 Plan APPROVED 才能实现
100
- "声称完成要验证" → PrematureDone 检测器物理阻止
101
- ```
102
-
103
- ---
104
-
105
- ## 🏗️ 技术架构
106
-
107
- ### 六层架构图
108
-
109
- ```
110
- ┌─────────────────────────────────────────────────────────────────┐
111
- │ SCALE Engine v0.6.0 │
112
- │ │
113
- │ ┌───────────────────────────────────────────────────────────┐ │
114
- │ │ L6 Evolution — 自进化层 │ │
115
- │ │ Defect → Lesson → Rule → Hook │ │
116
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
117
- │ │ │Lesson │→│Rule │→│Hook │→│Auto- │ │ │
118
- │ │ │Extractor │ │Proposer │ │Generator │ │Enforce │ │ │
119
- │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
120
- │ └───────────────────────────────────────────────────────────┘ │
121
- │ ┌───────────────────────────────────────────────────────────┐ │
122
- │ │ L5 Memory — 知识记忆层 │ │
123
- │ │ KnowledgeBase + 衰减算法 + 技能发现 │ │
124
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
125
- │ │ │Knowledge │ │Decay │ │Skill │ │ │
126
- │ │Base │ │Algorithm │ │Discovery │ │ │
127
- │ │ └──────────┘ └──────────┘ └──────────┘ │ │
128
- │ └───────────────────────────────────────────────────────────┘ │
129
- │ ┌───────────────────────────────────────────────────────────┐ │
130
- │ │ L4 Orchestration — 任务编排层 │ │
131
- │ │ TaskEngine + Effects + ModelRouter + 10 工作流预设 │ │
132
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
133
- │ │ │Task │ │Effects │ │Model │ │Workflow │ │ │
134
- │ │ │Engine │ │Wiring │ │Router │ │Presets │ │ │
135
- │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
136
- │ └───────────────────────────────────────────────────────────┘ │
137
- │ ┌───────────────────────────────────────────────────────────┐ │
138
- │ │ L3 Observability — 可观测性层 │ │
139
- │ │ EventBus + BehaviorTracker + 6 种行为模式检测 │ │
140
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
141
- │ │ │Event │ │Behavior │ │Session │ │ │
142
- │ │ │Bus │ │Tracker │ │Metrics │ │ │
143
- │ │ └──────────┘ └──────────┘ └──────────┘ │ │
144
- │ └───────────────────────────────────────────────────────────┘ │
145
- │ ┌───────────────────────────────────────────────────────────┐ │
146
- │ │ L2 Guardrails 安全护栏层 │ │
147
- │ │ 9 检测器 + Role 网关 + 级联升级 L0→L3 + 场景模式敏感度 │ │
148
- │ │ ┌─────────────────────────────────────────────────┐ │ │
149
- │ │ │ Gateway │ │ │
150
- │ │ │ ┌─────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌───────┐ │ │ │
151
- │ │ │ │Brute│ │Idle │ │Busy │ │Premat│ │Blame │ │ │ │
152
- │ │ │ │Retry│ │Tool │ │Loop │ │Done │ │Shift │ │ │ │
153
- │ │ │ └─────┘ └──────┘ └──────┘ └──────┘ └───────┘ │ │ │
154
- │ │ │ ┌─────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ │
155
- │ │ │ │Dang │Secret│ │Role │ │Scope │ │ │ │
156
- │ │ │ │Cmd │ │Leak │ │Gate │ │Creep │ │ │ │
157
- │ │ │ └─────┘ └──────┘ └──────┘ └──────┘ │ │ │
158
- │ │ └─────────────────────────────────────────────────┘ │ │
159
- │ └───────────────────────────────────────────────────────────┘ │
160
- │ ┌───────────────────────────────────────────────────────────┐ │
161
- │ │ L1 Context — 上下文构建层 │ │
162
- │ │ Token 预算 + SCALE v10.0 哲学 + 场景模式感知 │ │
163
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
164
- │ │ │Context │ │SCALE v10 │ │Scenario │ │ │
165
- │ │ │Builder │ │Philosophy│ │Mode │ │ │
166
- │ │ └──────────┘ └──────────┘ └──────────┘ │ │
167
- │ └───────────────────────────────────────────────────────────┘ │
168
- │ │
169
- │ ┌───────────────────────────────────────────────────────────┐ │
170
- │ │ 11 Agent 平台适配器 │ │
171
- │ │ Claude Code │ Codex CLI │ OpenCode │ Cursor │ Gemini │ │ │
172
- │ │ OpenClaw │ Hermes │ Trae │ WorkBuddy │ VSC │ QCoder │ │
173
- │ └───────────────────────────────────────────────────────────┘ │
174
- │ │
175
- │ ┌───────────────────────────────────────────────────────────┐ │
176
- │ │ 12 专业 Agent Profiles │ │
177
- │ │ frontend │ backend │ test │ ui-design │ ops │ product │ │
178
- │ │ code-review │ security │ database │ perf │ docs │ arch │ │
179
- │ └───────────────────────────────────────────────────────────┘ │
180
- │ │
181
- │ ┌──────────────────────┐ ┌──────────────────────────────────┐│
182
- │ │ MCP Server │ │ CLI (命令) ││
183
- │ │ Model Context Proto │ │ scale init/doctor/agent/team... ││
184
- │ └──────────────────────┘ └──────────────────────────────────┘│
185
- └─────────────────────────────────────────────────────────────────┘
186
- ```
187
-
188
- ### L1 Context — 上下文构建层
189
-
190
- ContextBuilder 负责组装 AI 可见的上下文,采用 **分层优先级 + Token 预算** 策略:
191
-
192
- ```
193
- 优先级 层级 内容 预估 Token
194
- ───────────────────────────────────────────────────────────────
195
- P1 system_rules SCALE v10.0 哲学 ~3,500
196
- P1.5 scenario_mode 场景模式感知 ~800
197
- P2 role_prompt 当前角色提示词 ~1,500
198
- P3 current_artifact 当前 Artifact 上下文 ~5,000
199
- P5 recalled_lessons 召回的历史经验 ~1,500
200
- ───────────────────────────────────────────────────────────────
201
- 总计 总预算: 200K, 保留: 30K ~12,300
202
- ```
203
-
204
- **SCALE v10.0 核心哲学(P1 层,不可绕过)**:
205
-
206
- - 🧠 **认知诚实**:不确定→`[UNCERTAIN]`,严禁幻觉式合规
207
- - 🔍 **显性推理**:`<think reasoning="effort">` before action
208
- - 👑 **Owner 意识**:做 Owner 不做执行者
209
- - 🔥 **反惰性**:暴力重试→换策略 | 甩锅→先验证 | 工具闲置→穷尽工具 | 忙碌假象→换思路
210
- - 📐 **1% 规则**:有 1% 可能→必须调用技能
211
- - ✅ **验证门控**:✅ 只来自工具,不来自脑补
212
-
213
- ### L2 Guardrails — 安全护栏层
214
-
215
- **9 个检测器**,覆盖 3 个 Hook 阶段:
216
-
217
- | # | 检测器 | Hook 阶段 | 严重度 | 说明 |
218
- |---|--------|----------|--------|------|
219
- | 1 | `DangerousCommand` | PreTool | deny | 拦截 `rm -rf`、`DROP TABLE`、`curl|bash`、`chmod 777` 等危险命令 |
220
- | 2 | `SecretLeak` | PreTool | block | 拦截硬编码 AWS Key、OpenAI Key、GitHub PAT、密码、私钥 |
221
- | 3 | `RoleGate` | PreTool | deny | 角色权限控制(Explorer/Planner/Implementer/Reviewer) |
222
- | 4 | `BruteRetry` | PreTool | block | 3 分钟内相同工具+参数 ≥3 次 → 强制换策略 |
223
- | 5 | `IdleTool` | PreTool | warn | 工具失败后未调查(Read/Grep)就改代码 |
224
- | 6 | `BusyLoop` | PreTool | block | 同一文件来回反复修改(检测 old↔new 循环) |
225
- | 7 | `PrematureDone` | BeforeStop | block | 修改了代码但未运行 test/lint/build |
226
- | 8 | `BlameShift` | PostTool | warn | 甩锅给环境但未做足够验证 |
227
- | 9 | `ScopeCreep` | PreTool | warn | 检测任务范围蔓延,偏离原始 Spec |
228
-
229
- **Role 网关**:4 种内置角色,物理限制工具权限
230
-
231
- | 角色 | 允许的工具 | 禁止的工具 |
232
- |------|-----------|-----------|
233
- | 🔍 Explorer | Read, Grep, Glob, WebSearch, Bash | Edit, Write, MultiEdit |
234
- | 📋 Planner | Read, Grep, Glob, Write | Bash |
235
- | 🔨 Implementer | Read, Grep, Glob, Edit, Write, MultiEdit, Bash | — |
236
- | 👁️ Reviewer | Read, Grep, Glob, Bash | Edit, Write, MultiEdit |
237
-
238
- **级联升级 L0→L3**:
239
-
240
- ```
241
- L0 允许 (allow) → 无异常,正常放行
242
- L1 警告 (warn) → 放行但注入上下文提醒
243
- L2 阻断 (block) → 拦截操作,必须修正后重试
244
- L3 拒绝 (deny) → 绝对拦截,不可绕过(危险命令/密钥泄露/越权)
245
- ```
246
-
247
- **场景模式敏感度**:
248
-
249
- | 模式 | 检测器敏感度 | 验证要求 | 人工确认 | 最大重试 |
250
- |------|------------|---------|---------|---------|
251
- | 🏖️ Sandbox | 低 | 不要求 | 不要求 | 10 |
252
- | ⚙️ Standard | 中 | 要求 | 不要求 | 5 |
253
- | 🔒 Critical | 高 | 要求 | 要求 | 3 |
254
-
255
- ### L3 Observability — 可观测性层
256
-
257
- **EventBus**:全链路事件总线,支持发布/订阅 + 历史查询
258
-
259
- ```
260
- 事件类型覆盖:
261
- ├── Artifact 生命周期: created → updated → transitioned → gate_checked → deleted
262
- ├── 工具调用: called → completed / failed → blocked
263
- ├── 护栏: checked → passed / failed
264
- ├── 行为模式: brute_retry / idle_tool / busy_loop / premature_done / blame_shift / scope_creep
265
- ├── Role: activated / denied
266
- ├── Session: started → ended → compacted / cleared
267
- ├── Knowledge: proposed → approved / rejected → recalled → helpful / useless
268
- ├── Task: scheduled → started → checkpointed → paused → resumed → completed / failed
269
- ├── Evolution: rule.proposed → rule.enforced → hook.generated → evolution.cycle_completed
270
- └── Context: built
271
- ```
272
-
273
- **BehaviorTracker**:6 种行为模式检测 + 会话级指标统计
274
-
275
- | 指标 | 说明 |
276
- |------|------|
277
- | `toolCalls` | 工具调用总数 |
278
- | `toolFailures` | 工具失败总数 |
279
- | `bruteRetryCount` | 暴力重试次数 |
280
- | `blameShiftCount` | 甩锅次数 |
281
- | `prematureDoneCount` | 声称完成但未验证次数 |
282
- | `artifactsCreated` | 创建的 Artifact 数 |
283
- | `rolesUsed` | 使用的角色列表 |
284
- | `modelsUsed` | 使用的模型统计 |
285
-
286
- ### L4 Orchestration — 任务编排层
287
-
288
- **TaskEngine**:步骤执行 + Checkpoint + 失败恢复
289
-
290
- **Effects 系统**:FSM 迁移时自动触发副作用(如 Plan APPROVED → 自动失效下游)
291
-
292
- **ModelRouter**:多模型路由策略
293
-
294
- ```typescript
295
- DEFAULT_MODELS = {
296
- fast: 'claude-3-5-haiku', // 探索/规划
297
- standard: 'claude-3-5-sonnet', // 日常实现
298
- premium: 'claude-3-opus', // 复杂推理/审查
299
- }
300
- ```
301
-
302
- **10 种工作流预设**:见 [功能特性](#-10-种工作流预设)
303
-
304
- ### L5 Memory — 知识记忆层
305
-
306
- **KnowledgeBase**(双引擎):
307
-
308
- - **InMemory** — 内存版,适合开发/测试
309
- - **SQLiteKnowledgeBase** — 持久化版,基于 better-sqlite3 + drizzle-orm,WAL 模式
310
- - 支持按标签、类型、相关性召回
311
- - 向量相似度检索(预留 embedding 接口)
312
- - 衰减算法:知识条目随时间衰减 `relevance`,被访问后提升
313
- - 知识类型:`lesson` | `pattern` | `best_practice` | `anti_pattern` | `decision` | `troubleshooting` | `workflow` | `reference`
314
-
315
- **SkillDiscovery**:自动检测 Agent 平台 → 扫描技能目录 → 生成 `skills.md`
316
-
317
- ### L6 Evolution — 自进化层
318
-
319
- **4 级自进化闭环**:
320
-
321
- ```
322
- Defect (closed) → Lesson (extracted) → Rule (proposed) → Hook (generated)
323
- 3 Gates: 2 Gates: 2 Gates: 1 Gate:
324
- 状态+根因+去重 verified+active relevance≥0.6 approved
325
- accessCount≥3 accessCount≥3 enforcement=hook
326
- ```
327
-
328
- | 级别 | 输入 → 输出 | 门控条件 |
329
- |------|------------|---------|
330
- | **1. Lesson 提取** | Defect → Lesson | 状态 ≥ DIAGNOSED + rootCause ≠ unknown + 标题去重 |
331
- | **2. Rule 提议** | Lesson → Rule | verified=true + relevance≥0.6 + accessCount≥3 |
332
- | **3. Hook 生成** | Rule → Hook | approved=true + enforcement=hook |
333
- | **4. 自动执行** | Hook → 物理约束 | 脚本部署到 hooks 目录,Agent 启动时自动加载 |
334
-
335
- ---
336
-
337
- ## ✨ 功能特性
338
-
339
- ### 11 种 Agent 适配器
340
-
341
- | Agent | 配置文件 | 知识文档 | 技能目录 | 特色能力 |
342
- |-------|---------|---------|---------|---------|
343
- | 🟠 **Claude Code** | `.claude/settings.json` | `CLAUDE.md` | `.claude/commands/` | OMC + 多模型 + Hooks + Autopilot |
344
- | 🔵 **Codex CLI** | `.codex/hooks.json` + `config.toml` | `AGENTS.md` | `.codex/commands/` | OMX + $Commands + tmux + 多模型 |
345
- | 🟢 **OpenCode** | `~/.config/opencode/hooks.json` | `AGENTS.md` | `~/.config/opencode/skills/` | OmO + 多模型 + AST-Grep + 开放 |
346
- | 🟣 **Cursor** | `.cursor/settings.json` | `.cursorrules` | `.cursor/skills/` | IDE 集成 + gstack + 设计优先 |
347
- | 🔴 **Gemini** | `.gemini/settings.json` | `GEMINI.md` | — | Google 生态 + gstack + 免费额度 |
348
- | 🟡 **OpenClaw** | `.openclaw/settings.json` | `AGENTS.md` | — | 开源 Agent 框架 |
349
- | 🟤 **Hermes** | `.hermes/settings.json` | `.hermes.md` | — | 轻量级 Agent |
350
- | 🟦 **Trae** | `.trae/settings.json` | `TRAE.md` | — | 字节跳动 AI 编程助手 |
351
- | 🟪 **WorkBuddy** | `.workbuddy/settings.json` | `WORKBUDDY.md` | — | 腾讯 CodeBuddy 团队协作 |
352
- | 🟦 **VSC** | `.vscode/scale.json` | `VSC.md` | — | VS Code Copilot CLI |
353
- | 🟧 **QCoder** | `.qwen/settings.json` | `QWEN.md` | — | 阿里通义千问 Code CLI |
354
-
355
- **统一工厂函数**:
356
-
357
- ```typescript
358
- import { createAdapter, SUPPORTED_AGENTS } from '@hongmaple0820/scale-engine'
359
-
360
- const adapter = createAdapter('claude-code', { scenarioMode: 'critical' })
361
- const result = await adapter.init() // 生成配置文件 + hooks + 知识文档
362
- ```
363
-
364
- ### 3 种场景模式
365
-
366
- | 模式 | Emoji | 适用场景 | 检测器敏感度 | 验证要求 | 人工确认 | 最大重试 |
367
- |------|-------|---------|------------|---------|---------|---------|
368
- | **Sandbox** | 🏖️ | 探索/原型/学习 | 低 | 不要求 | 不要求 | 10 |
369
- | **Standard** | ⚙️ | 日常开发/Bug修复 | 中 | 要求 | 不要求 | 5 |
370
- | **Critical** | 🔒 | 安全审计/生产部署 | 高 | 要求 | 要求 | 3 |
371
-
372
- ### 10 种工作流预设
373
-
374
- | # | 工作流 | 场景 | 步骤数 | 核心流程 |
375
- |---|--------|------|--------|---------|
376
- | 1 | 🚀 基础开发流 | Standard | 8 | Explore→Spec→Plan→Implement→Verify |
377
- | 2 | 🧪 TDD 功能开发 | Standard | 7 | RED→GREEN→REFACTOR(测试先行) |
378
- | 3 | 🐛 Bug 修复 | Standard | 7 | 复现→诊断→修复→验证→沉淀 |
379
- | 4 | 📜 SDD | Critical | 11 | 严格契约驱动,ambiguity ≤ 0.1 |
380
- | 5 | 👁️ 代码审查 | Standard | 7 | 风格→逻辑→安全→性能 |
381
- | 6 | 🔐 安全审计 | Critical | 8 | 密钥→注入→认证→数据→依赖 |
382
- | 7 | 🤖 Ralph 自主循环 | Sandbox | 7 | 全自动 AI 循环 |
383
- | 8 | ⚡ 快速原型 | Sandbox | 4 | 最小仪式,快速验证 |
384
- | 9 | 🏗️ 大规模重构 | Critical | 8 | 增量重构 + 测试护城河 |
385
- | 10 | ⚡ 并行执行 | Standard | 7 | 依赖分析 + 并行任务执行 |
386
-
387
- ### 9 个检测器
388
-
389
- | # | 检测器 | Hook 阶段 | 严重度 | 说明 |
390
- |---|--------|----------|--------|------|
391
- | 1 | 🛑 `DangerousCommand` | PreTool | deny | 拦截 `rm -rf`、`DROP TABLE`、`curl|bash`、`chmod 777`、fork bomb 等 12 种危险模式 |
392
- | 2 | 🔑 `SecretLeak` | PreTool | block | 拦截 AWS Key、OpenAI Key、GitHub PAT、私钥、硬编码密码等 6 种密钥模式 |
393
- | 3 | ⛔ `RoleGate` | PreTool | deny | 4 种内置角色(Explorer/Planner/Implementer/Reviewer)物理限制工具权限 |
394
- | 4 | 🔄 `BruteRetry` | PreTool | block | 3 分钟内相同工具+参数 ≥3 次 → 强制换策略 |
395
- | 5 | 🔧 `IdleTool` | PreTool | warn | 工具失败后未调查(Read/Grep/Bash)就改代码 |
396
- | 6 | 🔁 `BusyLoop` | PreTool | block | 同一文件来回反复修改(MD5 哈希检测循环) |
397
- | 7 | ✋ `PrematureDone` | BeforeStop | block | 修改了代码但未运行 test/lint/build,或验证早于最后修改 |
398
- | 8 | 🤷 `BlameShift` | PostTool | warn | 检测"可能是环境问题"等 5 种甩锅模式 |
399
- | 9 | 📏 `ScopeCreep` | PreTool | warn | 检测任务范围蔓延,偏离原始 Spec 定义 |
400
-
401
- ### 级联升级 L0→L3
402
-
403
- ```
404
- ┌──────────────────────────────────────┐
405
- │ Gateway 级联升级决策 │
406
- └──────────────────────────────────────┘
407
-
408
- ┌────────────┼────────────┐
409
- ▼ ▼ ▼
410
- ┌─────────┐ ┌─────────┐ ┌─────────┐
411
- │ L0 │ │ L1 │ │ L2/L3 │
412
- │ 允许 │ │ 警告 │ │ 阻断 │
413
- │ allow │ │ warn │ │ block/ │
414
- │ │ │ │ │ deny │
415
- └─────────┘ └─────────┘ └─────────┘
416
- │ │ │
417
- ▼ ▼ ▼
418
- 正常放行 注入上下文 拦截操作
419
- emit event 提醒AI 必须修正
420
- ```
421
-
422
- ### 6 种行为模式检测
423
-
424
- | 行为模式 | 事件名 | 检测逻辑 |
425
- |---------|--------|---------|
426
- | 🔄 暴力重试 | `behavior.brute_retry` | 3 分钟内相同工具+参数 ≥3 次 |
427
- | 🔧 工具闲置 | `behavior.idle_tool` | 失败后未 Read/Grep 就改代码 |
428
- | 🔁 忙碌假象 | `behavior.busy_loop` | 同一文件 old↔new 循环修改 |
429
- | ✋ 声称完成 | `behavior.premature_done` | 修改代码但未运行验证 |
430
- | 🤷 甩锅推诿 | `behavior.blame_shift` | 甩锅环境但无验证证据 |
431
- | 📏 范围蔓延 | `behavior.scope_creep` | 实现超出 Spec 定义的范围 |
432
-
433
- ### 11 种 Artifact FSM
434
-
435
- ```
436
- Need ──refine──→ Insight ──verify──→ Spec ──approve──→ Plan ──approve──→ TestPlan
437
- │ │
438
- ↓ ↓
439
- Task ←──schedule── Ready
440
-
441
- implement
442
-
443
-
444
- Change ──commit──→ Evidence ──pass──→ Release
445
-
446
-
447
- Defect ──diagnose──→ Lesson ──evolve──→ Rule → Hook
448
- ```
449
-
450
- | Artifact | 初始状态 | 终态 | 关键 Guard |
451
- |----------|---------|------|-----------|
452
- | Need | DRAFT | FULFILLED, ABANDONED | — |
453
- | Insight | DRAFT | INVALIDATED | — |
454
- | Spec | DRAFT | OBSOLETED | ambiguity ≤ 0.2, has successCriteria |
455
- | Plan | DRAFT | SUPERSEDED | has rollbackStrategy |
456
- | TestPlan | DRAFT | PASSED, FAILED | — |
457
- | Task | PENDING | COMPLETED, FAILED, CANCELLED | build+lint+test 全通过 |
458
- | Change | DRAFT | REVERTED | — |
459
- | Evidence | COLLECTED | PASS, FAIL | — |
460
- | Defect | OPEN | CLOSED, DUPLICATE | has rootCauseCategory ≠ unknown |
461
- | Lesson | PROPOSED | REJECTED, SUPERSEDED | verified → active → evolve |
462
- | Release | PLANNED | DEPLOYED, ROLLED_BACK | — |
463
-
464
- ### 4 级自进化
465
-
466
- | 级别 | 转化 | 门控 | 产出 |
467
- |------|------|------|------|
468
- | 1️⃣ Lesson 提取 | Defect → Lesson | 状态 ≥ DIAGNOSED + rootCause ≠ unknown + 去重 | 知识条目入库 |
469
- | 2️⃣ Rule 提议 | Lesson → Rule | verified + relevance≥0.6 + accessCount≥3 | 规则提议(prompt/hook) |
470
- | 3️⃣ Hook 生成 | Rule → Hook | approved + enforcement=hook | 自动生成 Hook 脚本 |
471
- | 4️⃣ 自动执行 | Hook → 物理约束 | 部署到 `.scale/hooks/` | AI 物理无法绕过 |
472
-
473
- ### 15 个 CLI 命令
474
-
475
- | 命令 | 说明 | 示例 |
476
- |------|------|------|
477
- | `scale init` | 初始化项目 | `scale init --agent claude-code --scenario critical` |
478
- | `scale doctor` | 环境诊断 + 健康检查 | `scale doctor` |
479
- | `scale create` | 创建 Artifact(11 种) | `scale create Spec "用户导出功能"` |
480
- | `scale list` | 列表查询 | `scale list --type Task --status RUNNING` |
481
- | `scale show` | 详情 | `scale show SPEC-20260421-0007` |
482
- | `scale suggest` | 可用操作建议 | `scale suggest SPEC-20260421-0007` |
483
- | `scale transition` | 状态迁移(含 guard) | `scale transition SPEC-xxx approve` |
484
- | `scale verify-task` | 代码质量验证 | `scale verify-task TASK-xxx` |
485
- | `scale create-prd` | 自动创建 Spec→Plan→Tasks | `scale create-prd "支付功能"` |
486
- | `scale role` | 角色切换 | `scale role activate implementer` |
487
- | `scale context` | 上下文组装 | `scale context status --session-id xxx` |
488
- | `scale context inject` | SessionStart FSM 注入 | `scale context inject --session-id xxx` |
489
- | `scale evolve` | 进化周期 | `scale evolve` |
490
- | `scale stats` | 统计 | `scale stats` |
491
- | `scale workflow` | 工作流预设管理 | `scale workflow list --scenario critical` |
492
- | `scale skill` | 技能发现 | `scale skill scan` |
493
-
494
- ### MCP Server 集成
495
-
496
- SCALE Engine 内置 MCP Server,可被任何支持 Model Context Protocol 的 Agent 直接调用:
497
-
498
- ```bash
499
- # 启动 MCP Server
500
- scale mcp
501
-
502
- # 在 Claude Code 中配置
503
- claude mcp add scale-engine -- node dist/api/mcp.js
504
- ```
505
-
506
- ---
507
-
508
- ## 🚀 快速开始
509
-
510
- ### 安装
511
-
512
- ```bash
513
- npm install -g @hongmaple0820/scale-engine
514
- ```
515
-
516
- ### 初始化项目
517
-
518
- ```bash
519
- cd your-project
520
-
521
- # 基础初始化
522
- scale init --agent claude-code
523
-
524
- # 指定场景模式
525
- scale init --agent claude-code --scenario sandbox # 🏖️ 探索/原型
526
- scale init --agent claude-code --scenario standard # ⚙️ 日常开发(默认)
527
- scale init --agent claude-code --scenario critical # 🔒 生产/安全
528
-
529
- # 支持 11 种 Agent
530
- scale init --agent codex # Codex CLI
531
- scale init --agent opencode # OpenCode
532
- scale init --agent cursor # Cursor
533
- scale init --agent gemini # Gemini
534
- scale init --agent openclaw # OpenClaw
535
- scale init --agent hermes # Hermes
536
- scale init --agent trae # 字节 Trae
537
- scale init --agent workbuddy # 腾讯 WorkBuddy
538
- scale init --agent vsc # VS Code Copilot CLI
539
- scale init --agent qcoder # 阿里 Qwen Code
540
- ```
541
-
542
- ### 环境诊断
543
-
544
- ```bash
545
- scale doctor
546
- ```
547
-
548
- ### 工作流管理
549
-
550
- ```bash
551
- # 查看所有 10 种工作流
552
- scale workflow list
553
-
554
- # 按场景筛选
555
- scale workflow list --scenario critical
556
- ```
557
-
558
- ### 技能发现
559
-
560
- ```bash
561
- # 自动检测 Agent 平台,扫描技能目录,生成 skills.md
562
- scale skill scan
563
- ```
564
-
565
- ### 日常使用示例
566
-
567
- ```bash
568
- # 📜 创建需求
569
- scale create Spec "用户导出 Excel 功能"
570
-
571
- # 🔄 迭代优化
572
- scale transition SPEC-xxx refine
573
-
574
- # ✅ 审批(ambiguity > 0.2 会被物理拦截)
575
- scale transition SPEC-xxx approve
576
-
577
- # 📋 创建计划
578
- scale create Plan
579
-
580
- # ✅ 审批计划
581
- scale transition PLAN-xxx approve
582
-
583
- # 🔨 创建任务
584
- scale create Task "实现 Excel 导出接口"
585
-
586
- # ✅ 验证任务(build + lint + test)
587
- scale verify-task TASK-xxx
588
-
589
- # ✋ 完成任务
590
- scale transition TASK-xxx complete
591
-
592
- # 🧬 触发自进化
593
- scale evolve
594
- ```
595
-
596
- ### 编程式使用
597
-
598
- ```typescript
599
- import {
600
- EventBus, Container, logger,
601
- FSM, InMemoryArtifactStore,
602
- registerAllFSMs, INITIAL_STATES,
603
- Gateway, BruteRetryDetector, PrematureDoneDetector,
604
- ContextBuilder, KnowledgeBase, EvolutionEngine,
605
- createAdapter, SUPPORTED_AGENTS,
606
- SkillDiscovery,
607
- listWorkflowPresets, getPresetsByScenario,
608
- } from '@hongmaple0820/scale-engine'
609
-
610
- // 1. 初始化核心基础设施
611
- const eventBus = new EventBus()
612
- const store = new InMemoryArtifactStore()
613
- const fsm = new FSM(store, eventBus)
614
- registerAllFSMs(fsm)
615
-
616
- // 2. 初始化护栏
617
- const gateway = new Gateway(eventBus)
618
- gateway.registerDetector(new BruteRetryDetector(), 'preTool')
619
- gateway.registerDetector(new PrematureDoneDetector(), 'beforeStop')
620
-
621
- // 3. 初始化上下文构建器
622
- const kb = new KnowledgeBase(eventBus)
623
- const contextBuilder = new ContextBuilder(store, kb, eventBus)
624
-
625
- // 4. 构建 Agent 适配器
626
- const adapter = createAdapter('claude-code', { scenarioMode: 'standard' })
627
- const initResult = await adapter.init()
628
- console.log('生成的配置文件:', initResult.files)
629
- ```
630
-
631
- ---
632
-
633
- ## 📚 完整 API 参考
634
-
635
- ### 核心基础设施
636
-
637
- | 导出 | 类型 | 说明 |
638
- |------|------|------|
639
- | `EventBus` | Class | 全链路事件总线,支持 on/emit/query |
640
- | `IEventBus` | Interface | EventBus 接口定义 |
641
- | `Container` | Class | 依赖注入容器 |
642
- | `container` | Instance | 全局默认容器实例 |
643
- | `createToken` | Function | 创建 DI Token |
644
- | `logger` | Instance | Pino 日志实例 |
645
-
646
- ### Artifact + FSM
647
-
648
- | 导出 | 类型 | 说明 |
649
- |------|------|------|
650
- | `FSM` | Class | 通用有限状态机引擎 |
651
- | `SpecFSM` | Constant | Spec 类型 FSM 定义 |
652
- | `InMemoryArtifactStore` | Class | 内存 Artifact 存储 |
653
- | `IArtifactStore` | Interface | Artifact 存储接口 |
654
- | `registerAllFSMs` | Function | 注册全部 11 种 FSM |
655
- | `INITIAL_STATES` | Constant | 各 Artifact 初始状态映射表 |
656
-
657
- ### 类型系统(从 `./artifact/types.js` 导出)
658
-
659
- | 导出 | 类型 | 说明 |
660
- |------|------|------|
661
- | `Artifact<T>` | Interface | 通用 Artifact 结构 |
662
- | `ArtifactType` | Type | 11 种 Artifact 类型联合 |
663
- | `ArtifactId` | Type | `SPEC-20260421-0007` 格式 ID |
664
- | `NeedPayload` | Interface | Need 载荷 |
665
- | `InsightPayload` | Interface | Insight 载荷 |
666
- | `SpecPayload` | Interface | Spec 载荷 |
667
- | `PlanPayload` | Interface | Plan 载荷 |
668
- | `TestPlanPayload` | Interface | TestPlan 载荷 |
669
- | `TaskPayload` | Interface | Task 载荷(含 buildStatus/lintStatus/testPassed) |
670
- | `ChangePayload` | Interface | Change 载荷 |
671
- | `EvidencePayload` | Interface | Evidence 载荷 |
672
- | `DefectPayload` | Interface | Defect 载荷(含 rootCauseCategory) |
673
- | `LessonPayload` | Interface | Lesson 载荷(8 种类型) |
674
- | `ReleasePayload` | Interface | Release 载荷 |
675
- | `PayloadOf<T>` | Type | 根据 ArtifactType 推断 Payload 类型 |
676
- | `Event<T>` | Interface | 事件结构 |
677
- | `EventType` | Type | 50+ 种事件类型联合 |
678
- | `FSMDefinition` | Interface | FSM 定义结构 |
679
- | `TransitionDef` | Interface | 状态迁移定义 |
680
- | `Guard` | Interface | 门控条件 |
681
- | `Effect` | Interface | 迁移副作用 |
682
- | `ScenarioMode` | Type | `'sandbox' \| 'standard' \| 'critical'` |
683
- | `ScenarioModeConfig` | Interface | 场景模式配置 |
684
- | `SCENARIO_MODE_CONFIGS` | Constant | 3 种场景模式预设 |
685
- | `AgentPlatform` | Type | 11 种 Agent 平台联合类型 |
686
- | `SkillRef` | Interface | 技能引用 |
687
- | `SkillScanResult` | Interface | 技能扫描结果 |
688
- | `WorkflowPreset` | Interface | 工作流预设 |
689
- | `WorkflowStep` | Interface | 工作流步骤 |
690
- | `ScaleError` | Class | 基础错误类 |
691
- | `InvalidTransitionError` | Class | 无效迁移错误 |
692
- | `GuardFailedError` | Class | Guard 失败错误 |
693
- | `RoleDeniedError` | Class | Role 拒绝错误 |
694
- | `ArtifactNotFoundError` | Class | Artifact 未找到错误 |
695
-
696
- ### 护栏 (Guardrails)
697
-
698
- | 导出 | 类型 | 说明 |
699
- |------|------|------|
700
- | `Gateway` | Class | Hook 网关,3 阶段检测(preTool/postTool/beforeStop) |
701
- | `IDetector` | Interface | 检测器接口 |
702
- | `DetectorContext` | Interface | 检测器上下文 |
703
- | `BruteRetryDetector` | Class | 暴力重试检测器 |
704
- | `IdleToolDetector` | Class | 工具闲置检测器 |
705
- | `BusyLoopDetector` | Class | 忙碌假象检测器 |
706
- | `PrematureDoneDetector` | Class | 声称完成但未验证检测器 |
707
- | `BlameShiftDetector` | Class | 甩锅检测器 |
708
- | `DangerousCommandDetector` | Class | 危险命令拦截器(rm -rf / DROP TABLE 等) |
709
- | `SecretLeakDetector` | Class | 密钥泄露拦截器(AWS Key / GitHub PAT 等) |
710
- | `RoleGateDetector` | Class | 角色权限拦截器(4 种内置角色) |
711
- | `ScopeCreepDetector` | Class | 范围蔓延检测器(第 9 个) |
712
- | `BUILT_IN_ROLES` | Constant | 内置角色定义(含工具权限矩阵) |
713
- | `ROLES` | Constant | 角色常量 |
714
- | `getRole` | Function | 获取角色 |
715
- | `listRoles` | Function | 列出所有角色 |
716
-
717
- ### 上下文 (Context)
718
-
719
- | 导出 | 类型 | 说明 |
720
- |------|------|------|
721
- | `ContextBuilder` | Class | 分层上下文构建器(P1-P5 + Token 预算) |
722
- | `IContextBuilder` | Interface | ContextBuilder 接口 |
723
- | `ContextLayer` | Interface | 上下文层结构 |
724
- | `BuiltContext` | Interface | 构建结果 |
725
- | `ContextStatus` | Interface | 上下文状态(含 constraints) |
726
-
727
- ### 编排 (Orchestration)
728
-
729
- | 导出 | 类型 | 说明 |
730
- |------|------|------|
731
- | `TaskEngine` | Class | 任务引擎(步骤执行 + Checkpoint + 恢复) |
732
- | `wireEffects` | Function | Effects 接线(FSM 迁移副作用) |
733
-
734
- ### 路由 (Routing)
735
-
736
- | 导出 | 类型 | 说明 |
737
- |------|------|------|
738
- | `ModelRouter` | Class | 多模型路由策略 |
739
- | `DEFAULT_MODELS` | Constant | 默认模型配置(Haiku/Sonnet/Opus) |
740
-
741
- ### 知识 (Knowledge)
742
-
743
- | 导出 | 类型 | 说明 |
744
- |------|------|------|
745
- | `KnowledgeBase` | Class | 内存知识库(标签/向量召回 + 衰减算法) |
746
- | `SQLiteKnowledgeBase` | Class | SQLite 持久化知识库(WAL 模式 + 并发安全) |
747
- | `IKnowledgeBase` | Interface | 知识库统一接口 |
748
-
749
- ### 进化 (Evolution)
750
-
751
- | 导出 | 类型 | 说明 |
752
- |------|------|------|
753
- | `BehaviorTracker` | Class | 行为追踪器(6 种模式 + 会话指标 + 自动触发进化) |
754
- | `IBehaviorTracker` | Interface | 行为追踪接口 |
755
- | `SessionMetrics` | Interface | 会话指标结构 |
756
- | `AutoEvolveConfig` | Interface | 自动进化配置 |
757
- | `AutoDefectCreator` | Class | 自动 Defect 创建器(从行为事件自动创建 Defect) |
758
- | `IAutoDefectCreator` | Interface | AutoDefectCreator 接口 |
759
- | `DefectPayload` | Interface | Defect 载荷(含 rootCauseCategory/severity) |
760
- | `LessonExtractor` | Class | Lesson 提取器(Defect → Lesson) |
761
- | `RuleProposer` | Class | Rule 提议器(Lesson → Rule) |
762
- | `HookGenerator` | Class | Hook 生成器(Rule → Hook) |
763
- | `EvolutionEngine` | Class | 进化引擎(编排 4 级闭环) |
764
- | `ProposedRule` | Interface | 提议的规则结构 |
765
- | `GeneratedHook` | Interface | 生成的 Hook 结构 |
766
- | `EvolutionStats` | Interface | 进化统计 |
767
-
768
- ### FSM Agent Bridge
769
-
770
- | 导出 | 类型 | 说明 |
771
- |------|------|------|
772
- | `FSMAgentBridge` | Class | FSM Agent 上下文桥接(SessionStart FSM 注入) |
773
- | `IFSMAgentBridge` | Interface | FSMAgentBridge 接口 |
774
- | `FSMContextSnapshot` | Interface | FSM 状态快照 |
775
- | `SessionFSMContext` | Interface | Session FSM 上下文 |
776
-
777
- ### Agent 适配器
778
-
779
- | 导出 | 类型 | 说明 |
780
- |------|------|------|
781
- | `ClaudeCodeAdapter` | Class | Claude Code 适配器 |
782
- | `CodexAdapter` | Class | Codex CLI 适配器 |
783
- | `OpenCodeAdapter` | Class | OpenCode 适配器 |
784
- | `CursorAdapter` | Class | Cursor 适配器 |
785
- | `GeminiAdapter` | Class | Gemini CLI 适配器 |
786
- | `OpenClawAdapter` | Class | OpenClaw 适配器 |
787
- | `HermesAdapter` | Class | Hermes 适配器 |
788
- | `createAdapter` | Function | 统一适配器工厂函数 |
789
- | `SUPPORTED_AGENTS` | Constant | 支持的 Agent 列表 |
790
- | `IAgentAdapter` | Interface | Agent 适配器接口 |
791
- | `AdapterConfig` | Interface | 适配器配置 |
792
- | `InitResult` | Interface | 初始化结果 |
793
- | `SettingsJson` | Interface | settings.json 结构 |
794
- | `HookEntry` | Interface | Hook 配置条目 |
795
-
796
- ### 技能发现
797
-
798
- | 导出 | 类型 | 说明 |
799
- |------|------|------|
800
- | `SkillDiscovery` | Class | 技能发现引擎 |
801
-
802
- ### 工作流预设
803
-
804
- | 导出 | 类型 | 说明 |
805
- |------|------|------|
806
- | `WORKFLOW_PRESETS` | Constant | 全部 10 种工作流映射表 |
807
- | `getWorkflowPreset` | Function | 按 ID 获取工作流 |
808
- | `listWorkflowPresets` | Function | 列出所有工作流 |
809
- | `getPresetsByScenario` | Function | 按场景模式筛选 |
810
- | `BASIC_DEV` | Constant | 基础开发流 |
811
- | `TDD_DEV` | Constant | TDD 功能开发 |
812
- | `BUG_FIX` | Constant | Bug 修复 |
813
- | `SDD` | Constant | 规约驱动开发 |
814
- | `CODE_REVIEW` | Constant | 代码审查 |
815
- | `SECURITY_AUDIT` | Constant | 安全审计 |
816
- | `RALPH_LOOP` | Constant | Ralph 自主循环 |
817
- | `RAPID_PROTO` | Constant | 快速原型 |
818
- | `MASSIVE_REFACTOR` | Constant | 大规模重构 |
819
- | `PARALLEL_EXEC` | Constant | 并行执行 |
820
-
821
- ### API
822
-
823
- | 导出 | 类型 | 说明 |
824
- |------|------|------|
825
- | `Doctor` | Class | 环境诊断工具 |
826
- | `ScaleMCPServer` | Class | MCP Server 实现 |
827
-
828
- ---
829
-
830
- ## 🌐 社区与推广
831
-
832
- ### 链接
833
-
834
- | 平台 | 链接 | 说明 |
835
- |------|------|------|
836
- | 📦 **GitHub** | [https://github.com/hongmaple0820/scale-engine](https://github.com/hongmaple0820/scale-engine) | 源码 + Issues + PR |
837
- | 🔧 **Gitee** | [https://gitee.com/hongmaple/scale-engine](https://gitee.com/hongmaple/scale-engine) | 国内镜像 |
838
- | 📦 **npm** | [https://www.npmjs.com/package/@hongmaple0820/scale-engine](https://www.npmjs.com/package/@hongmaple0820/scale-engine) | 包下载 |
839
-
840
- ### 社区交流群
841
-
842
- <p align="center">
843
- <a href="https://qm.qq.com/q/RuCfOyaOUm">
844
- <img src="https://img.shields.io/badge/QQ群-628043364-blue.svg?style=for-the-badge" alt="加入QQ群" />
845
- </a>
846
- </p>
847
-
848
- <p align="center">
849
- <strong>飞书群</strong><br/>
850
- <img src="https://cdn.nlark.com/yuque/0/2026/jpeg/1698739/1778311890484-5f96693f-745c-4ed5-950a-c3143de40811.jpeg" alt="飞书群二维码" width="300" />
851
- </p>
852
-
853
- ### 微信公众号
854
-
855
- <p align="center">
856
- <strong>鸿枫技术栈</strong><br/>
857
- <img src="https://cdn.nlark.com/yuque/0/2026/png/1698739/1778312235122-cfa7ad6c-7420-40dd-9741-2254f6fef5b0.png" alt="微信公众号" width="300" />
858
- </p>
859
-
860
- 关注「**鸿枫技术栈**」公众号,获取最新动态和工程化实践文章。
861
-
862
- ### 微信交流群
863
-
864
- 添加微信 **mapleCx330** 加入交流群,或通过邮箱 **2496155694@qq.com** 联系。
865
-
866
- ### 知识星球(¥99/年)
867
-
868
- 加入知识星球,获取:
869
- - 专属技能包和配置模板
870
- - 深度实战案例拆解
871
- - 社区专家 1v1 答疑
872
- - 新功能优先体验权
873
-
874
- > 📌 加入知识星球,和认真的 AI 编码开发者一起成长:[https://t.zsxq.com/6T5Eq](https://t.zsxq.com/6T5Eq)
875
-
876
- ### 🌟 Star History
877
-
878
- 如果 SCALE Engine 对你有帮助,请给个 ⭐ Star!
879
-
880
- <a href="https://www.star-history.com/?type=date&repos=hongmaple0820%2Fscale-engine">
881
- <picture>
882
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=hongmaple0820/scale-engine&type=date&theme=dark&legend=top-left" />
883
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=hongmaple0820/scale-engine&type=date&legend=top-left" />
884
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=hongmaple0820/scale-engine&type=date&legend=top-left" />
885
- </picture>
886
- </a>
887
-
888
- ---
889
-
890
- ### ❤️ 开源不易,谢谢打赏
891
-
892
- <p align="center">
893
- <img src="/image/wxPay.jpg" alt="微信支付" width="150" />
894
- <img src="/image/zfb.jpg" alt="支付宝" width="150" />
895
- </p>
896
-
897
- ---
898
-
899
- ## 📋 CHANGELOG
900
-
901
- ### v0.8.0 (2026-05-08)
902
-
903
- **多 Agent 协作系统 + mattpoclock/skills 风格集成 + TF-IDF 记忆召回:**
904
-
905
- **Phase 1-3: 工作流增强**
906
- - ✨ **SessionStart Hook** — `scale context inject` 自动注入 FSM 状态和相关 lessons
907
- - ✨ **AutoDefectCreator** — 自动从检测器事件创建 Defect(hallucination/brute_retry/blame_shift)
908
- - ✨ **BehaviorTracker.autoEvolve** — bruteRetry 达阈值(默认3次)自动触发进化周期
909
- - ✨ **KnowledgeBase TF-IDF** — recallByVector 使用 TF-IDF 算法计算文本相似度
910
-
911
- **Phase 4-9: 多 Agent 协作系统**
912
- - ✨ **12 专业 Agent Profiles** — frontend/backend/test/ui-design/ops/product/code-review/security/database/performance/docs/architect
913
- - ✨ **AgentPool** — Agent 实例池管理(spawn/assign/complete/recycle)
914
- - ✨ **AgentDispatcher** — 任务自动分发到合适 Agent Profile
915
- - ✨ **AgentChannel** — Agent 间消息传递和广播机制
916
- - ✨ **AgentCoordinator** — 团队任务协调器(Task Lead 角色)
917
- - ✨ **CLI 命令** — `scale agent spawn/assign/status` + `scale team create/execute/status`
918
-
919
- **mattpoclock/skills 风格集成(设计完成)**
920
- - 📋 **UbiquitousLanguageManager** — CONTEXT.md + ADR 实时更新机制设计
921
- - 📋 **GrillingSessionSkill** — 递归决策树探索需求精炼
922
- - 📋 **IssueTriageFSM** — Issue 状态机(needs-triage → ready-for-agent → completed)
923
- - 📋 **CavemanCompressor** — 超压缩通信模式(约 75% token 减少)
924
-
925
- **Karpathy 反惰性原则**
926
- - 📋 **暴力重试反制** — 每次必须换策略,连续 2 次同策略触发级联
927
- - 📋 **甩锅反制** — 甩锅前必须验证,未验证的归因 = 甩锅
928
- - 📋 **工具闲置反制** — 有工具/技能不用而直接放弃 = 触发级联
929
- - 📋 **忙碌假象反制** — 反复微调同一行无新信息产生 = 触发级联
930
- - 📋 **被动等待反制** — 修完表面问题就停不泛化检查 = 触发级联
931
-
932
- **测试与发布**
933
- - ✅ 测试:410 passed (32 test files)
934
- - ✅ npm 发布:@hongmaple0820/scale-engine@0.8.0
935
- - ✅ GitHub 推送:master + tag v0.8.0
936
-
937
- ### v0.7.1 (2026-05-06)
938
-
939
- **SessionStart Hook 增强 + 自进化闭环自动化 + 记忆利用率提升:**
940
- - ✨ **SessionStart hook 增强** — `scale context inject` 命令注入 FSM 状态
941
- - ✨ **AutoDefectCreator** — 自动从检测器事件创建 Defect(5 种事件类型)
942
- - ✨ **BehaviorTracker.setAutoEvolve** — bruteRetry 达阈值触发进化周期
943
- - ✨ **ContextBuilder.recallRelevantLessons** — 基于 tags 自动召回 lessons
944
- - ✨ **FSMAgentBridge.getSessionContext** — 获取 session FSM 上下文
945
- - 🔧 新增事件类型 `defect.auto_created`
946
- - 🔧 ClaudeCodeAdapter SessionStart hook 改为调用 context inject
947
- - ✅ 测试:323 passed (21 test files)
948
-
949
- ### v0.6.1 (Unreleased)
950
-
951
- **新增 4 种 Agent 适配器(共 11 种):**
952
- - ✨ **TraeAdapter** — 字节跳动 Trae AI 编程助手(`.trae/settings.json` + `TRAE.md`)
953
- - ✨ **WorkBuddyAdapter** — 腾讯 CodeBuddy 团队协作(`.workbuddy/settings.json` + `WORKBUDDY.md`)
954
- - ✨ **VSCAdapter** — VS Code Copilot CLI(`.vscode/scale.json` + `VSC.md`)
955
- - ✨ **QCoderAdapter** — 阿里通义千问 Code CLI(`.qwen/settings.json` + `QWEN.md`)
956
-
957
- **集成完整性:**
958
- - `AgentPlatform` 联合类型扩展至 11 种
959
- - `Doctor.checkSettingsJson` / `checkKnowledgeDoc` 支持新增 4 种平台检测
960
- - `SkillDiscovery.detectPlatform` 支持识别 4 种新平台
961
- - `createAdapter` / `SUPPORTED_AGENTS` 注册新适配器
962
- - 4 个测试套件 × 共 ~50 个新测试用例
963
-
964
- ### v0.6.0 (2026-04-29)
965
-
966
- **新增功能:**
967
- - ✨ **SQLiteKnowledgeBase** — 基于 better-sqlite3 的持久化知识库,WAL 模式,并发安全
968
- - ✨ **FSM 并发锁** — per-artifact Promise 链式锁,防止竞态条件
969
- - ✨ **ScopeCreepDetector** — 第 9 个检测器,检测任务范围蔓延(15 文件 / 10 分钟窗口)
970
-
971
- **改进:**
972
- - CLI 默认使用 SQLiteKnowledgeBase(替代内存版)
973
- - CLI 注册 ScopeCreepDetector 为 preTool 检测器
974
- - 公共 API 新增导出:`SQLiteKnowledgeBase`, `IKnowledgeBase`, `DangerousCommandDetector`, `SecretLeakDetector`, `RoleGateDetector`, `ScopeCreepDetector`, `BUILT_IN_ROLES`
975
- - package.json 添加 `exports` 字段,支持现代 Node.js 模块解析
976
-
977
- **测试:**
978
- - 新增 28 个测试(SQLite KB 19 + FSM 并发锁 4 + ScopeCreep 5)
979
- - 修复 9 个预存测试失败(import 路径、断言值、FSM guard payload、Gateway warn 语义)
980
- - 测试套件:197/197 全部通过
981
-
982
- ### v0.5.1 (2026-04-22)
983
-
984
- **P0 Bug 修复:**
985
- - 🐛 修复 ContextBuilder 导入 `ScenarioModeConfig` 类型无效引用
986
- - 🐛 修复 Task FSM `complete` Guard 在 `buildStatus` 未设置时误判逻辑
987
- - 🐛 修复 BlameShiftDetector 正则匹配大小写不一致
988
-
989
- **P1 新功能:**
990
- - ✨ 新增 `ScopeCreepDetector` — 第 9 个检测器,检测任务范围蔓延
991
- - ✨ 新增 6 种行为模式检测(brute_retry / idle_tool / busy_loop / premature_done / blame_shift / scope_creep)
992
- - ✨ 新增级联升级机制 L0→L3(allow / warn / block / deny)
993
- - ✨ 新增场景模式敏感度自动调节
994
- - ✨ 新增 MCP Server 集成 (`ScaleMCPServer`)
995
-
996
- **P2 清理:**
997
- - 🧹 统一适配器导出入口 (`adapters/index.ts`)
998
- - 🧹 完善公共 API 导出
999
- - 🧹 更新 README 文档
1000
-
1001
- ### v0.5.0 (2026-04-22)
1002
-
1003
- **重大更新:7 Agent 适配器 + 场景模式 + 工作流预设 + 技能生态**
1004
-
1005
- - 🆕 **7 种 Agent 适配器**:Claude Code, Codex, OpenCode, Cursor, Gemini, OpenClaw, Hermes
1006
- - 统一 `createAdapter()` 工厂函数
1007
- - `SUPPORTED_AGENTS` 常量导出
1008
- - 🆕 **3 种场景模式**:Sandbox / Standard / Critical
1009
- - 不同检测器敏感度 (low/medium/high)
1010
- - 不同验证要求、人工确认要求、最大重试次数
1011
- - 🆕 **10 种工作流预设**:基础开发、TDD、Bug修复、SDD、代码审查、安全审计、Ralph自主循环、快速原型、大规模重构、并行执行
1012
- - 🆕 **技能生态系统**:自动检测 Agent 平台 → 扫描技能目录 → 生成 `skills.md`
1013
- - 🆕 **SCALE v10.0 哲学**:ContextBuilder P1 系统规则层(物理约束 + 场景模式感知)
1014
- - 🆕 **CLI 增强**:`scale init --scenario`, `scale workflow list`, `scale skill scan`
1015
-
1016
- ### v0.4.0 (2026-04-22)
1017
-
1018
- - 新增 `scale context status --session-id` 命令
1019
- - 新增 `scale create-prd` 自动创建 Spec→Plan→Tasks 层级
1020
- - 配置 hooks 集成(SessionStart/PreToolUse/PostToolUse/Stop)
1021
-
1022
- ### v0.3.0 (2026-04-21)
1023
-
1024
- - 新增 `scale suggest` 命令,显示 Artifact 可执行操作列表
1025
- - 支持 `--json` 输出用于脚本集成
1026
-
1027
- ### v0.2.0 (2026-04-21)
1028
-
1029
- - 新增 `scale suggest <id>` 命令
1030
- - 支持 Guard 条件和拦截原因显示
1031
-
1032
- ### v0.1.0 (2026-04-21)
1033
-
1034
- **初始发布 — 六层架构完整实现:**
1035
-
1036
- - L1 Context — Token 预算 + 上下文组装策略
1037
- - L2 Guardrails — 8 检测器 + Role 网关 + 模糊度阈值拦截
1038
- - L3 Observability — EventBus + BehaviorTracker 全链路追踪
1039
- - L4 Orchestration — TaskEngine + Effects 系统 + ModelRouter
1040
- - L5 Memory — KnowledgeBase + 衰减算法 + SQLite 持久化
1041
- - L6 Evolution — Defect→Lesson→Rule→Hook 四级自进化闭环
1042
- - 148+ 单元测试通过
1043
-
1044
- ---
1045
-
1046
- ## 🤝 贡献指南
1047
-
1048
- 我们欢迎所有形式的贡献!无论是 Bug 报告、功能建议、文档改进还是代码贡献。
1049
-
1050
- ### 贡献流程
1051
-
1052
- 1. **Fork** 仓库到你的 GitHub 账号
1053
- 2. 创建 **dev 分支**:`git checkout -b feat/your-feature`
1054
- 3. **开发 & 测试**:确保 `pnpm test` 和 `pnpm lint` 通过
1055
- 4. **提交**:使用规范的 Commit Message
1056
- 5. **推送 & PR**:推送到你的 Fork,然后创建 Pull Request
1057
-
1058
- ### Commit Message 格式
1059
-
1060
- | 类型 | 说明 | 示例 |
1061
- |------|------|------|
1062
- | `feat` | 新功能 | `feat: add ScopeCreepDetector` |
1063
- | `fix` | Bug 修复 | `fix: correct Task FSM guard logic` |
1064
- | `chore` | 构建/工具 | `chore: update dependencies` |
1065
- | `docs` | 文档 | `docs: update API reference` |
1066
- | `refactor` | 重构 | `refactor: extract common detector logic` |
1067
- | `test` | 测试 | `test: add gateway integration tests` |
1068
- | `perf` | 性能 | `perf: optimize event bus query` |
1069
-
1070
- ### 开发环境
1071
-
1072
- ```bash
1073
- # 克隆仓库
1074
- git clone https://github.com/hongmaple0820/scale-os.git
1075
- cd scale-engine
1076
-
1077
- # 安装依赖
1078
- npm install
1079
-
1080
- # 运行测试
1081
- npm test
1082
-
1083
- # 类型检查
1084
- npm run typecheck
1085
-
1086
- # Lint
1087
- npm run lint
1088
-
1089
- # 构建
1090
- npm run build
1091
-
1092
- # 启动 MCP Server
1093
- npm run mcp
1094
- ```
1095
-
1096
- ### 技术栈
1097
-
1098
- | 技术 | 版本 | 用途 |
1099
- |------|------|------|
1100
- | **TypeScript** | 5.5+ | 主语言,ESM 模式 |
1101
- | **better-sqlite3** | 11.x | SQLite WAL 模式持久化 |
1102
- | **Zod** | 3.x | 运行时类型校验 |
1103
- | **Pino** | 9.x | 结构化日志 |
1104
- | **Citty** | 0.1.x | CLI 框架 |
1105
- | **Hono** | 4.x | HTTP API |
1106
- | **MCP SDK** | 1.x | Model Context Protocol |
1107
- | **Vitest** | 2.x | 单元测试 |
1108
-
1109
- ---
1110
-
1111
- <p align="center">
1112
- <strong>SCALE Engine</strong> — 让 AI 在物理约束下工作,而不是靠提示词自律<br/>
1113
- <sub>Built with ❤️ by the SCALE OS Team</sub>
1114
- </p>
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/version-0.10.1-orange?style=flat-square" alt="version" />
3
+ <img src="https://img.shields.io/badge/platforms-11-blue?style=flat-square" alt="platforms" />
4
+ <img src="https://img.shields.io/badge/agents-12-blue?style=flat-square" alt="agents" />
5
+ <img src="https://img.shields.io/badge/workflows-10-green?style=flat-square" alt="workflows" />
6
+ <img src="https://img.shields.io/badge/detectors-9-red?style=flat-square" alt="detectors" />
7
+ <img src="https://img.shields.io/badge/tests-461-passing-brightgreen?style=flat-square" alt="tests" />
8
+ <img src="https://img.shields.io/badge/npm-0.10.1-cb3837?style=flat-square&logo=npm" alt="npm" />
9
+ </p>
10
+
11
+ # SCALE Engine v0.10.1
12
+
13
+ SCALE Engine 是一个面向 AI 编码 Agent 的工程化工作流运行时。它把提示词里的工程纪律,下沉为状态机、质量门禁、持久化证据、确定性 review 记录和发布检查。
14
+
15
+ 源码仓库:https://github.com/hongmaple0820/scale-engine
16
+ 国内镜像:https://gitee.com/hongmaple/scale-engine
17
+ npm:https://www.npmjs.com/package/@hongmaple0820/scale-engine
18
+ 语言:[中文](README.md) | [English](README.en.md)
19
+
20
+ ## 为什么需要它
21
+
22
+ 提示词是建议,工程交付需要机制:
23
+
24
+ - Agent 可以声称测试通过,SCALE 会保存真实验证证据。
25
+ - Agent 可以跳过 review,SCALE 会在缺少 review 记录时阻断 `ship`。
26
+ - Agent 可以误提交无关文件,SCALE 只暂存已通过 review 覆盖的文件。
27
+ - Agent 可以丢失阶段状态,SCALE 会把 artifact 和 FSM 状态保存在 `.scale`。
28
+
29
+ ## 当前版本
30
+
31
+ v0.10.1 聚焦阶段化交付链路加固:
32
+
33
+ - `define -> plan -> build -> verify -> review -> ship`
34
+ - Spec、Plan、Task artifact 接入 FSM
35
+ - 验证门禁证据持久化
36
+ - 代码 review 记录持久化
37
+ - 确定性 review scanner 会阻断空 `catch`、`@ts-ignore`、focused test、危险 shell/git 命令和缺 G7 证据的安全敏感变更
38
+ - G7 内置安全扫描会记录可解释的文件/行号证据,默认阻断 CRITICAL,严格模式可阻断 HIGH
39
+ - 可选严格 TDD evidence 门禁:`--tdd-evidence` 和 `--tdd-strict`
40
+ - `ship --no-commit` 交付报告
41
+ - `ship` 发布前强制验证 review evidence
42
+ - 11 个平台适配器,12 个专业 Agent Profile
43
+ - Exa/search capability 集成
44
+ - 本轮 scoped ship、TDD evidence、review scanner 与 G7 security scan 加固后,461 个 Vitest 测试通过
45
+
46
+ ## 安装
47
+
48
+ ```bash
49
+ npm install -g @hongmaple0820/scale-engine
50
+ scale --version
51
+ ```
52
+
53
+ 需要 Node.js 20 或更高版本。
54
+
55
+ ## 阶段工作流
56
+
57
+ ```bash
58
+ scale define "Scoped release workflow" \
59
+ --description "Implement a TypeScript CLI workflow with verification evidence, review records, rollback constraints, and release safety checks." \
60
+ --success-criteria "verify evidence is persisted,review evidence is persisted,ship blocks unreviewed files"
61
+
62
+ scale plan <spec-id> --rollback "Revert the release commit and remove generated artifacts"
63
+ scale build <plan-id> --description "Implement scoped release workflow"
64
+ scale verify <task-id>
65
+ scale review <task-id>
66
+ scale ship <task-id> --message "feat(workflow): add scoped release workflow"
67
+ ```
68
+
69
+ 如果只需要生成交付报告,不创建 Git commit:
70
+
71
+ ```bash
72
+ scale ship <task-id> --no-commit
73
+ ```
74
+
75
+ 需要严格校验 TDD 证据时:
76
+
77
+ ```bash
78
+ scale verify <task-id> --tdd-strict --tdd-evidence .scale/tdd/<task-id>.json
79
+ ```
80
+
81
+ TDD evidence JSON 需要包含 `red`、`green`、`refactor`、`testFirst` 且值都为 `true`。
82
+
83
+ ## 安全模型
84
+
85
+ | 层级 | 作用 |
86
+ | --- | --- |
87
+ | FSM | 阻止非法 artifact 状态流转 |
88
+ | GateSystem | 执行 build、lint、test、coverage、security 门禁 |
89
+ | EvidenceStore | 持久化验证证据,用于审计和发布门禁 |
90
+ | ReviewStore | 持久化确定性 review 记录 |
91
+ | ReviewAnalyzer | 扫描 diff 中的高风险代码、流程债和缺失安全证据 |
92
+ | Detectors | 检测暴力重试、过早完成、甩锅、忙碌假象等失败模式 |
93
+ | Ship gate | 发布前必须验证通过,并且 review evidence 必须存在且通过 |
94
+
95
+ `ship` 不再执行 `git add .`。它只会暂存已通过 review 记录覆盖的文件;如果 review 后出现新的可 review 变更,`ship` 会阻断并要求重新 review。
96
+
97
+ G7 `SecurityGate` 内置轻量安全扫描,覆盖硬编码密钥、私钥、TLS 校验关闭、`eval`/`Function`、原始 HTML 注入、危险 shell 命令、shell 执行和空 `catch` 等模式。兼容模式只阻断 CRITICAL;严格模式会同时阻断 HIGH。
98
+
99
+ ## 支持的平台与角色
100
+
101
+ SCALE Engine 内置 11 个平台适配器,包括 Claude Code、Codex CLI、OpenCode、Cursor、Gemini CLI、OpenClaw、Hermes、Trae、WorkBuddy、VS Code Copilot CLI、QCoder。
102
+
103
+ 内置 12 个专业 Agent Profile:
104
+
105
+ - frontend
106
+ - backend
107
+ - testing
108
+ - UI design
109
+ - operations
110
+ - product
111
+ - code review
112
+ - security
113
+ - database
114
+ - performance
115
+ - documentation
116
+ - architecture
117
+
118
+ ## 项目结构
119
+
120
+ ```text
121
+ src/api/cli.ts CLI 入口
122
+ src/cli/phaseCommands.ts DEFINE/PLAN/BUILD/VERIFY/REVIEW/SHIP
123
+ src/workflow/gates/ 质量门禁与验证证据
124
+ src/workflow/ReviewAnalyzer.ts 确定性 review 分析
125
+ src/workflow/ReviewStore.ts review 记录持久化
126
+ src/workflow/EvidenceStore.ts gate evidence 持久化
127
+ src/artifact/ artifact 存储与 FSM 定义
128
+ src/guardrails/ detector 与 gateway
129
+ src/evolution/ Defect/Lesson/Rule/Hook 自进化层
130
+ tests/ Vitest 测试
131
+ ```
132
+
133
+ ## 开发与验证
134
+
135
+ ```bash
136
+ npm install
137
+ npm run build
138
+ npx vitest run
139
+ npm pack --dry-run
140
+ ```
141
+
142
+ 工作流相关定向测试:
143
+
144
+ ```bash
145
+ npx vitest run tests/workflow/phaseCli.test.ts
146
+ npx vitest run tests/workflow/reviewAnalyzer.test.ts tests/workflow/reviewStore.test.ts tests/workflow/gateSystem.test.ts
147
+ ```
148
+
149
+ ## v0.10.1 更新
150
+
151
+ - 新增 `ship --no-commit`。
152
+ - 强化 `ship`:发布提交只暂存已 review 文件。
153
+ - 新增可选严格 TDD evidence 校验。
154
+ - 增强命令证据元数据:工作目录、时间戳、stdout/stderr 尾部和输出 hash。
155
+ - 强化 deterministic review scanner:阻断空 `catch`、`@ts-ignore`、focused test、危险 shell/git 命令与缺 G7 证据的安全敏感变更。
156
+ - 强化 G7 内置安全扫描:输出文件/行号证据,默认阻断 CRITICAL,严格模式阻断 HIGH。
157
+ - 新增 `review -> ship`、未 review 文件阻断和安全扫描误报边界的 CLI/单元回归测试。
158
+ - 发版前已验证 `npm run build`、完整 Vitest 测试和 `npm pack --dry-run`。
159
+
160
+ ## v0.10.0 更新
161
+
162
+ - 新增阶段化 CLI 工作流,并接入 FSM。
163
+ - 新增验证证据和 review 记录持久化。
164
+ - 发布 `@hongmaple0820/scale-engine@0.10.0`。
165
+
166
+ ## License
167
+
168
+ MIT