opencroc 1.8.4 → 1.8.5
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.ja.md +383 -386
- package/README.zh-CN.md +383 -414
- package/dist/cli/index.js +24 -8
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/README.zh-CN.md
CHANGED
|
@@ -1,414 +1,383 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="assets/banner.png" alt="OpenCroc 横幅" width="820" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">OpenCroc</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<strong>AI 原生 E2E
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/opencroc"><img src="https://img.shields.io/npm/v/opencroc?color=green" alt="npm version" /></a>
|
|
13
|
-
<a href="https://github.com/opencroc/opencroc/actions/workflows/ci.yml"><img src="https://github.com/opencroc/opencroc/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
14
|
-
<a href="https://github.com/opencroc/opencroc/blob/main/LICENSE"><img src="https://img.shields.io/github/license/opencroc/opencroc" alt="MIT License" /></a>
|
|
15
|
-
<a href="https://opencroc.com"><img src="https://img.shields.io/badge/docs-opencroc.com-blue" alt="Documentation" /></a>
|
|
16
|
-
</p>
|
|
17
|
-
|
|
18
|
-
<p align="center">
|
|
19
|
-
<a href="README.
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## OpenCroc 是什么?
|
|
25
|
-
|
|
26
|
-
OpenCroc 是一个构建在 [Playwright](https://playwright.dev) 之上的
|
|
27
|
-
|
|
28
|
-
当测试失败时,OpenCroc
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| 能力 | 说明 |
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
## 快速开始
|
|
43
|
-
|
|
44
|
-
### 前置要求
|
|
45
|
-
|
|
46
|
-
- Node.js
|
|
47
|
-
- 使用 Express
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
OpenCroc Studio
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
npx opencroc
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
1.
|
|
211
|
-
2.
|
|
212
|
-
3.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
-
|
|
347
|
-
-
|
|
348
|
-
-
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
355
|
-
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
-
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
- `1.1.0`:高级自愈(对话循环、可控修复器、自动修复 PR 生成)
|
|
385
|
-
- `1.2.0`:高级报告系统 + Sprint 0-3 迁移完成
|
|
386
|
-
- `1.3.0`:OpenCroc Studio M1 — Fastify 服务器、知识图谱 API、像素鳄鱼办公室前端
|
|
387
|
-
|
|
388
|
-
### 发布验证
|
|
389
|
-
|
|
390
|
-
```bash
|
|
391
|
-
npm run lint
|
|
392
|
-
npm run typecheck
|
|
393
|
-
npm test
|
|
394
|
-
npm view opencroc version dist-tags --json
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
## 文档
|
|
398
|
-
|
|
399
|
-
访问 **[opencroc.com](https://opencroc.com)** 查看完整文档,或阅读:
|
|
400
|
-
|
|
401
|
-
- [Architecture Guide](docs/architecture.md)
|
|
402
|
-
- [Configuration Reference](docs/configuration.md)
|
|
403
|
-
- [Backend Instrumentation Guide](docs/backend-instrumentation.md)
|
|
404
|
-
- [AI Provider Setup](docs/ai-providers.md)
|
|
405
|
-
- [Self-Healing Guide](docs/self-healing.md)
|
|
406
|
-
- [Troubleshooting](docs/troubleshooting.md)
|
|
407
|
-
|
|
408
|
-
## 贡献
|
|
409
|
-
|
|
410
|
-
欢迎贡献代码与文档。请查看 [CONTRIBUTING.md](CONTRIBUTING.md)。
|
|
411
|
-
|
|
412
|
-
## License
|
|
413
|
-
|
|
414
|
-
[MIT](LICENSE) © 2026 OpenCroc Contributors
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/banner.png" alt="OpenCroc 横幅" width="820" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">OpenCroc</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>AI 原生 E2E 测试框架:读取源码、生成测试,并对失败进行自愈。</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/opencroc"><img src="https://img.shields.io/npm/v/opencroc?color=green" alt="npm version" /></a>
|
|
13
|
+
<a href="https://github.com/opencroc/opencroc/actions/workflows/ci.yml"><img src="https://github.com/opencroc/opencroc/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
14
|
+
<a href="https://github.com/opencroc/opencroc/blob/main/LICENSE"><img src="https://img.shields.io/github/license/opencroc/opencroc" alt="MIT License" /></a>
|
|
15
|
+
<a href="https://opencroc.com"><img src="https://img.shields.io/badge/docs-opencroc.com-blue" alt="Documentation" /></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="README.md">English</a> | <a href="README.zh-CN.md">简体中文</a> | <a href="README.ja.md">日本語</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## OpenCroc 是什么?
|
|
25
|
+
|
|
26
|
+
OpenCroc 是一个构建在 [Playwright](https://playwright.dev) 之上的 AI 原生端到端测试框架。它不要求你手写大量测试脚本,而是直接读取后端源码,理解模型、控制器、DTO 与关系后,自动生成完整的 E2E 测试套件,包括种子数据、请求体、API 调用链和断言。
|
|
27
|
+
|
|
28
|
+
当测试失败时,OpenCroc 不只是输出报错。它会沿着请求链路追踪问题,归因可能的根因,生成修复建议,并在受控流程中重新执行验证。
|
|
29
|
+
|
|
30
|
+
## 核心能力
|
|
31
|
+
|
|
32
|
+
| 能力 | 说明 |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| 源码感知生成 | 解析 Sequelize、TypeORM、Prisma、Drizzle 结构,识别模块、模型、路由与 DTO |
|
|
35
|
+
| AI 配置生成 | 生成请求模板、种子数据计划、参数映射与测试脚手架,并经过校验 |
|
|
36
|
+
| 调用链规划 | 构建依赖 DAG,规划更高覆盖率的 API 执行顺序 |
|
|
37
|
+
| 日志驱动完成判定 | 不只依赖 `networkidle`,还能结合后端执行信号判断是否真正完成 |
|
|
38
|
+
| 失败归因 | 关联前端请求、后端日志与依赖链路,定位问题来源 |
|
|
39
|
+
| 受控自愈 | 支持 backup、patch、dry-run、re-run、verify、rollback 等闭环 |
|
|
40
|
+
| 可视化 Studio | 提供本地 Web UI,用于图谱探索、Agent 状态观察和像素办公室展示 |
|
|
41
|
+
|
|
42
|
+
## 快速开始
|
|
43
|
+
|
|
44
|
+
### 前置要求
|
|
45
|
+
|
|
46
|
+
- Node.js 18 或更高版本
|
|
47
|
+
- 使用 Express 或 NestJS 的后端项目
|
|
48
|
+
- 使用受支持的 ORM 或模式结构
|
|
49
|
+
|
|
50
|
+
### 安装
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install opencroc --save-dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 初始化
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx opencroc init
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
这条命令会:
|
|
63
|
+
|
|
64
|
+
1. 扫描项目结构
|
|
65
|
+
2. 识别框架与 ORM 特征
|
|
66
|
+
3. 创建 `opencroc.config.ts`
|
|
67
|
+
4. 生成起步用的输出结构
|
|
68
|
+
|
|
69
|
+
### 生成测试
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# 为单个模块生成测试
|
|
73
|
+
npx opencroc generate --module=knowledge-base
|
|
74
|
+
|
|
75
|
+
# 为所有检测到的模块生成测试
|
|
76
|
+
npx opencroc generate --all
|
|
77
|
+
|
|
78
|
+
# 仅预览,不落盘
|
|
79
|
+
npx opencroc generate --all --dry-run
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 运行测试
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# 运行全部生成的测试
|
|
86
|
+
npx opencroc test
|
|
87
|
+
|
|
88
|
+
# 运行单个模块
|
|
89
|
+
npx opencroc test --module=knowledge-base
|
|
90
|
+
|
|
91
|
+
# 以 headed 模式运行
|
|
92
|
+
npx opencroc test --headed
|
|
93
|
+
|
|
94
|
+
# 通过 CLI 覆盖生命周期钩子
|
|
95
|
+
npx opencroc test --setup-hook="npm run e2e:setup" --auth-hook="node scripts/auth.js" --teardown-hook="npm run e2e:cleanup"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 校验 AI 配置
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx opencroc validate --all
|
|
102
|
+
npx opencroc compare --baseline=report-a.json --current=report-b.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## OpenCroc Studio
|
|
106
|
+
|
|
107
|
+
OpenCroc Studio 是 OpenCroc 的本地可视化工作台。它把知识图谱视图、像素办公室运营视图和 3D 办公室运行时整合在一个由 CLI 启动的 Web 体验中。
|
|
108
|
+
|
|
109
|
+
### 启动 Studio
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# 启动 Studio 并打开浏览器
|
|
113
|
+
npx opencroc serve
|
|
114
|
+
|
|
115
|
+
# 自定义端口
|
|
116
|
+
npx opencroc serve --port 3000
|
|
117
|
+
|
|
118
|
+
# 禁止自动打开浏览器
|
|
119
|
+
npx opencroc serve --no-open
|
|
120
|
+
|
|
121
|
+
# 绑定公开 host
|
|
122
|
+
npx opencroc serve --host 0.0.0.0 --port 8765
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 当前 Web 架构
|
|
126
|
+
|
|
127
|
+
- Fastify 提供本地 Studio 应用与 API 服务
|
|
128
|
+
- 前端是单入口 Vite SPA
|
|
129
|
+
- 主路由为 `/`、`/studio`、`/pixel`
|
|
130
|
+
- Web 源码位于 `src/web`,按 `app`、`pages`、`features`、`shared`、`styles`、`public` 分层
|
|
131
|
+
- 历史入口如 `/index-studio.html`、`/index-v2-pixel.html` 会被重定向到 SPA 路由
|
|
132
|
+
|
|
133
|
+
### Studio 能力
|
|
134
|
+
|
|
135
|
+
- 模块、API 与关系的知识图谱画布
|
|
136
|
+
- 展示 Agent 活动的像素办公室仪表盘
|
|
137
|
+
- 用于沉浸式监控的 3D 办公室运行时视图
|
|
138
|
+
- 基于 WebSocket 的实时状态更新
|
|
139
|
+
- 支持路由切换的侧边导航
|
|
140
|
+
- REST 接口,例如 `GET /api/project`、`GET /api/agents`、`POST /api/project/refresh`
|
|
141
|
+
|
|
142
|
+
## 完整流水线
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# 执行完整流水线
|
|
146
|
+
npx opencroc run
|
|
147
|
+
|
|
148
|
+
# 对单个模块启用自愈并输出报告
|
|
149
|
+
npx opencroc run --module=users --self-heal --report html,json
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## CI/CD 集成
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npx opencroc ci --platform github
|
|
156
|
+
npx opencroc ci --platform gitlab --self-heal
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Dashboard 与报告
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npx opencroc dashboard
|
|
163
|
+
npx opencroc report --format html,json,markdown
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## 架构
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
+-------------------------------------------------------------------+
|
|
170
|
+
| OpenCroc Studio |
|
|
171
|
+
| Fastify 服务 + 单入口 Vite SPA + WebSocket 更新 |
|
|
172
|
+
| 路由:/, /studio, /pixel |
|
|
173
|
+
+-------------------------------------------------------------------+
|
|
174
|
+
| CLI / Orchestrator |
|
|
175
|
+
+--------------+--------------+---------------+----------------------+
|
|
176
|
+
| 源码解析 | 链路规划 | 测试生成 | 执行 / 观察 |
|
|
177
|
+
+--------------+--------------+---------------+----------------------+
|
|
178
|
+
| 自愈 | 影响分析 | 报告输出 | Dashboard / Studio |
|
|
179
|
+
+--------------+--------------+---------------+----------------------+
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 6 阶段流水线
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
Source Scan -> ER Diagram -> API Analysis -> Chain Planning -> Test Generation -> Failure Analysis
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 工作原理
|
|
189
|
+
|
|
190
|
+
### 1. 源码解析
|
|
191
|
+
|
|
192
|
+
OpenCroc 使用 [ts-morph](https://ts-morph.com) 以及框架感知解析器来分析:
|
|
193
|
+
|
|
194
|
+
- 模型与关系
|
|
195
|
+
- 控制器与路由
|
|
196
|
+
- DTO 字段与校验规则
|
|
197
|
+
- 模块边界与依赖面
|
|
198
|
+
|
|
199
|
+
### 2. AI 配置生成
|
|
200
|
+
|
|
201
|
+
针对每个模块,OpenCroc 可以生成:
|
|
202
|
+
|
|
203
|
+
- 请求体模板
|
|
204
|
+
- 种子数据计划
|
|
205
|
+
- 参数映射
|
|
206
|
+
- ID 别名规则
|
|
207
|
+
|
|
208
|
+
每份配置都要经过以下校验:
|
|
209
|
+
|
|
210
|
+
1. Schema 校验
|
|
211
|
+
2. 语义校验
|
|
212
|
+
3. Dry-run 校验
|
|
213
|
+
|
|
214
|
+
### 3. 日志驱动完成判定
|
|
215
|
+
|
|
216
|
+
OpenCroc 不只依赖浏览器空闲信号,还能结合后端完成信号来判断请求是否真正结束。
|
|
217
|
+
|
|
218
|
+
### 4. 自愈闭环
|
|
219
|
+
|
|
220
|
+
```text
|
|
221
|
+
Test Failure
|
|
222
|
+
-> Attribution
|
|
223
|
+
-> Proposed Fix
|
|
224
|
+
-> Dry-Run Validation
|
|
225
|
+
-> Apply Patch
|
|
226
|
+
-> Re-run
|
|
227
|
+
-> Verify
|
|
228
|
+
-> Rollback if needed
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## 真实项目验证
|
|
232
|
+
|
|
233
|
+
OpenCroc 已在一个生产风格的 RBAC 系统上完成验证,项目包含 100+ Sequelize 模型、数十个控制器以及嵌入式关联定义。
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
$ npx tsx examples/rbac-system/smoke-test.ts
|
|
237
|
+
|
|
238
|
+
Modules : 5
|
|
239
|
+
ER Diagrams : 5
|
|
240
|
+
Chain Plans : 5
|
|
241
|
+
Generated Files: 78
|
|
242
|
+
Duration : 1153ms
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
关键结果:
|
|
246
|
+
|
|
247
|
+
- 从扁平模型布局中提取出 102 张表与 65 条外键关系
|
|
248
|
+
- 无需单独 association 文件即可识别嵌入式关联
|
|
249
|
+
- 在 5 个模块上生成了 78 个测试文件
|
|
250
|
+
- 同时兼容扁平与嵌套目录结构
|
|
251
|
+
|
|
252
|
+
## 配置示例
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { defineConfig } from 'opencroc';
|
|
256
|
+
|
|
257
|
+
export default defineConfig({
|
|
258
|
+
backend: {
|
|
259
|
+
modelsDir: 'src/models',
|
|
260
|
+
controllersDir: 'src/controllers',
|
|
261
|
+
servicesDir: 'src/services',
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
baseUrl: 'http://localhost:3000',
|
|
265
|
+
apiBaseUrl: 'http://localhost:3000/api',
|
|
266
|
+
|
|
267
|
+
ai: {
|
|
268
|
+
provider: 'openai',
|
|
269
|
+
apiKey: process.env.AI_API_KEY,
|
|
270
|
+
model: 'gpt-4o-mini',
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
execution: {
|
|
274
|
+
workers: 4,
|
|
275
|
+
timeout: 30_000,
|
|
276
|
+
retries: 1,
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
logCompletion: {
|
|
280
|
+
enabled: true,
|
|
281
|
+
endpoint: '/internal/test-logs',
|
|
282
|
+
pollIntervalMs: 500,
|
|
283
|
+
timeoutMs: 10_000,
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
selfHealing: {
|
|
287
|
+
enabled: false,
|
|
288
|
+
fixScope: 'config-only',
|
|
289
|
+
maxFixRounds: 3,
|
|
290
|
+
dryRunFirst: true,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 支持的技术栈
|
|
296
|
+
|
|
297
|
+
| 层 | 已支持 | 计划中 |
|
|
298
|
+
| --- | --- | --- |
|
|
299
|
+
| ORM | Sequelize, TypeORM, Prisma, Drizzle | 视需求继续扩展 |
|
|
300
|
+
| Framework | Express | NestJS, Fastify, Koa |
|
|
301
|
+
| Test Runner | Playwright | 更多运行器 |
|
|
302
|
+
| LLM | OpenAI, ZhiPu, Ollama | Anthropic |
|
|
303
|
+
| Database | MySQL, PostgreSQL | SQLite, MongoDB |
|
|
304
|
+
|
|
305
|
+
## 对比
|
|
306
|
+
|
|
307
|
+
| 功能 | OpenCroc | Playwright | Metersphere | auto-playwright |
|
|
308
|
+
| --- | --- | --- | --- | --- |
|
|
309
|
+
| 源码感知生成 | Yes | No | No | No |
|
|
310
|
+
| AI 配置生成与校验 | Yes | No | No | No |
|
|
311
|
+
| 日志驱动完成判定 | Yes | No | No | No |
|
|
312
|
+
| 失败归因 | Yes | No | Partial | No |
|
|
313
|
+
| 自愈与回滚 | Yes | No | No | No |
|
|
314
|
+
| API 依赖 DAG | Yes | No | No | No |
|
|
315
|
+
| 零配置测试生成 | Yes | Limited | Manual | Prompt-driven |
|
|
316
|
+
| 影响分析 | Yes | No | No | No |
|
|
317
|
+
|
|
318
|
+
## 路线图
|
|
319
|
+
|
|
320
|
+
- [x] 6 阶段源码到测试流水线
|
|
321
|
+
- [x] AI 配置生成与校验
|
|
322
|
+
- [x] 受控自愈闭环
|
|
323
|
+
- [x] 日志驱动完成判定
|
|
324
|
+
- [x] 失败归因与影响分析
|
|
325
|
+
- [x] Prisma 与 Drizzle 适配
|
|
326
|
+
- [x] Ollama 本地模型支持
|
|
327
|
+
- [x] CI 集成
|
|
328
|
+
- [x] VS Code 插件脚手架
|
|
329
|
+
- [x] 插件系统
|
|
330
|
+
- [x] HTML、JSON、Markdown 报告
|
|
331
|
+
- [x] 可视化 Studio 仪表盘
|
|
332
|
+
- [x] Runtime 基础设施
|
|
333
|
+
- [x] 全流程编排
|
|
334
|
+
- [x] 高级报告系统
|
|
335
|
+
- [x] OpenCroc Studio 路由化 Web 应用
|
|
336
|
+
|
|
337
|
+
## 版本快照
|
|
338
|
+
|
|
339
|
+
- 本文档对应的产品快照:`1.8.3`
|
|
340
|
+
- Studio 架构快照:Fastify + 单入口 Vite SPA + 路由视图
|
|
341
|
+
- 主 Studio 路由:`/`、`/studio`、`/pixel`
|
|
342
|
+
- 全量质量门禁:41 个测试文件、414 个测试通过
|
|
343
|
+
|
|
344
|
+
### 版本节奏
|
|
345
|
+
|
|
346
|
+
- `0.3.x`:插件系统、CI 模板、报告系统、VS Code 脚手架
|
|
347
|
+
- `0.4.x`:NestJS 控制器解析器
|
|
348
|
+
- `0.5.x`:Drizzle ORM 适配
|
|
349
|
+
- `0.6.x`:可视化 dashboard 与 Windows Vitest 稳定性工作
|
|
350
|
+
- `0.7.x - 0.9.x`:runtime 基础设施、认证、日志驱动检测、规则引擎
|
|
351
|
+
- `1.0.0`:全流程编排管道
|
|
352
|
+
- `1.1.0`:高级自愈
|
|
353
|
+
- `1.2.0`:高级报告与迁移工作
|
|
354
|
+
- `1.3.0`:OpenCroc Studio M1
|
|
355
|
+
- `1.8.3`:Vite SPA 路由化、web 架构整理、发包瘦身
|
|
356
|
+
|
|
357
|
+
### 发布验证
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
npm run lint
|
|
361
|
+
npm run typecheck
|
|
362
|
+
npm test
|
|
363
|
+
npm view opencroc version dist-tags --json
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## 文档
|
|
367
|
+
|
|
368
|
+
访问 **[opencroc.com](https://opencroc.com)** 获取更多文档,也可以查看:
|
|
369
|
+
|
|
370
|
+
- [Architecture Guide](docs/architecture.md)
|
|
371
|
+
- [Configuration Reference](docs/configuration.md)
|
|
372
|
+
- [Backend Instrumentation Guide](docs/backend-instrumentation.md)
|
|
373
|
+
- [AI Provider Setup](docs/ai-providers.md)
|
|
374
|
+
- [Self-Healing Guide](docs/self-healing.md)
|
|
375
|
+
- [Troubleshooting](docs/troubleshooting.md)
|
|
376
|
+
|
|
377
|
+
## 贡献
|
|
378
|
+
|
|
379
|
+
欢迎贡献代码与文档。请查看 [CONTRIBUTING.md](CONTRIBUTING.md)。
|
|
380
|
+
|
|
381
|
+
## 许可证
|
|
382
|
+
|
|
383
|
+
[MIT](LICENSE) Copyright 2026 OpenCroc Contributors
|