opencroc 0.6.1 → 1.3.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 CHANGED
@@ -1,340 +1,417 @@
1
- <p align="center">
2
- <img src="assets/banner.png" alt="OpenCroc banner" width="820" />
3
- </p>
4
-
5
- <h1 align="center">OpenCroc</h1>
6
-
7
- <p align="center">
8
- <strong>AI-native E2E testing framework that reads your source code, generates tests, and self-heals failures.</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
- ## What is OpenCroc?
25
-
26
- OpenCroc is an **AI-native end-to-end testing framework** built on top of [Playwright](https://playwright.dev). Instead of writing test scripts by hand, OpenCroc **reads your backend source code** (models, controllers, DTOs) and automatically generates complete E2E test suites — including API chains, seed data, request bodies, and assertions.
27
-
28
- When tests fail, OpenCroc doesn't just report errors — it **traces the root cause** through the full request chain, **generates fix patches**, and **re-runs tests to verify the fix** — all autonomously.
29
-
30
- ### Key Capabilities
31
-
32
- | Capability | Description |
33
- |---|---|
34
- | **Source-Aware Test Generation** | Parses Sequelize/TypeORM models, Express/NestJS controllers, and DTO decorators via [ts-morph](https://ts-morph.com) to understand your API surface |
35
- | **AI-Driven Configuration** | LLM generates request body templates, seed data, parameter mappings — validated by 3-layer verification (schema → semantic → dry-run) |
36
- | **Intelligent Chain Planning** | Builds API dependency DAGs, performs topological sorting, and plans test chains with greedy coverage optimization |
37
- | **Log-Driven Completion Detection** | Goes beyond `networkidle` — verifies request completion by matching backend execution logs (`api_exec end`) |
38
- | **Failure Chain Attribution** | Traces failures through the full call chain: network errors → slow APIs → backend logs → root cause |
39
- | **Controlled Self-Healing** | `backup → AI patch → dry-run → apply → re-run → verify → rollback` — with safety gates at every step |
40
- | **Impact Analysis** | BFS traversal of foreign key relations to map blast radius, auto-generates Mermaid diagrams |
41
-
42
- ## Quick Start
43
-
44
- ### Prerequisites
45
-
46
- - Node.js >= 18
47
- - A backend project with Express/NestJS + Sequelize/TypeORM
48
-
49
- ### Installation
50
-
51
- ```bash
52
- npm install opencroc --save-dev
53
- ```
54
-
55
- ### Initialize
56
-
57
- ```bash
58
- npx opencroc init
59
- ```
60
-
61
- This will:
62
- 1. Scan your project structure
63
- 2. Detect your ORM and framework
64
- 3. Create `opencroc.config.ts` with sensible defaults
65
- 4. Generate a sample test suite
66
-
67
- ### Generate Tests
68
-
69
- ```bash
70
- # Generate tests for a single module
71
- npx opencroc generate --module=knowledge-base
72
-
73
- # Generate tests for all detected modules
74
- npx opencroc generate --all
75
-
76
- # Dry-run (preview without writing files)
77
- npx opencroc generate --all --dry-run
78
- ```
79
-
80
- ### Run Tests
81
-
82
- ```bash
83
- # Run all generated tests
84
- npx opencroc test
85
-
86
- # Run specific module
87
- npx opencroc test --module=knowledge-base
88
-
89
- # Run with self-healing enabled
90
- npx opencroc test --self-heal
91
- ```
92
-
93
- ### Validate AI Configs
94
-
95
- ```bash
96
- # Validate generated configurations
97
- npx opencroc validate --all
98
-
99
- # Compare AI-generated vs baseline results
100
- npx opencroc compare --baseline=report-a.json --current=report-b.json
101
- ```
102
-
103
- ## Architecture
104
-
105
- ```
106
- ┌─────────────────────────────────────────────────────────────┐
107
- │ CLI / Orchestrator │
108
- ├──────────┬──────────┬──────────┬──────────┬─────────────────┤
109
- │ Source │ Chain │ Test │ Execution│ Self-Healing │
110
- │ Parser │ Planner │Generator │ Engine │ Engine │
111
- │ │ │ │ │ │
112
- ts-morph │ DAG + │ Template │Playwright│ AI Attribution │
113
- │ Model │ Topo │ + AI │ + Log │ + Controlled │
114
- Controller│ Sort + │ Config │ Driven │ Fix + Verify │
115
- DTO │ Greedy │ Merge │ Assert │ + Rollback │
116
- ├──────────┴──────────┴──────────┴──────────┴─────────────────┤
117
- │ Observation Bus (Network + Backend Logs) │
118
- ├──────────────────────────────────────────────────────────────┤
119
- │ Report Engine (HTML / JSON / Markdown) │
120
- └──────────────────────────────────────────────────────────────┘
121
- ```
122
-
123
- ### 6-Stage Pipeline
124
-
125
- ```
126
- Source Scan ER Diagram API Analysis Chain Planning Test Generation Failure Analysis
127
- │ │ │ │ │ │
128
- ts-morph Mermaid Dependency Topological Playwright + Root Cause +
129
- parsing erDiagram DAG builder + greedy AI body/seed Impact map
130
- ```
131
-
132
- ## How It Works
133
-
134
- ### 1. Source Parsing
135
-
136
- OpenCroc uses [ts-morph](https://ts-morph.com) to statically analyze your backend:
137
-
138
- - **Models**: Extracts table names, column types, indexes, and foreign keys from Sequelize `Model.init()` / TypeORM `@Entity()`
139
- - **Controllers**: Extracts routes, HTTP methods, path parameters from Express `router.get/post/put/delete`
140
- - **DTOs**: Extracts validation rules from `@IsString()`, `@IsNumber()`, `@IsOptional()` decorators
141
-
142
- ### 2. AI Configuration Generation
143
-
144
- For each module, OpenCroc calls an LLM (OpenAI / ZhiPu / any OpenAI-compatible API) to generate:
145
-
146
- - **Request body templates** — field-accurate POST/PUT payloads
147
- - **Seed data** `beforeAll` setup steps with correct API sequences
148
- - **Parameter mappings** path parameter aliases (`/:id` → `categoryId`)
149
- - **ID aliases** — preventing ID conflicts across multi-resource chains
150
-
151
- Each config is validated through **3 layers**:
152
- 1. **Schema validation** — JSON structure completeness
153
- 2. **Semantic validation** — field values match source code metadata
154
- 3. **Dry-run validation** — TypeScript compilation check
155
-
156
- Failed configs are **automatically fixed** (up to 3 rounds) before being written.
157
-
158
- ### 3. Log-Driven Completion
159
-
160
- Instead of relying on fragile `networkidle` signals:
161
-
162
- ```
163
- Frontend Request → Backend api_exec start log → Backend processing → api_exec end log
164
-
165
- OpenCroc polls end logs to confirm completion
166
- ```
167
-
168
- This catches cases where the frontend appears idle but the backend is still processing.
169
-
170
- ### 4. Self-Healing Loop
171
-
172
- ```
173
- Test Failure
174
- AI Attribution (LLM + heuristic fallback)
175
- Generate Fix Patch
176
- Dry-Run Validation
177
- → Apply Patch (with backup)
178
- Re-run Failed Tests
179
- → Verify Fix
180
- Commit or Rollback
181
- ```
182
-
183
- ## Real-World Validation
184
-
185
- OpenCroc has been validated against a **production-scale RBAC system** (multi-tenant enterprise permission management) with 100+ Sequelize models, 75+ Express controllers, and embedded associations:
186
-
187
- ```
188
- $ npx tsx examples/rbac-system/smoke-test.ts
189
-
190
- Modules : 5 (default, aigc, data-platform, integration, workflow)
191
- ER Diagrams : 5
192
- [default] 102 tables, 65 relations
193
- [aigc] 6 tables, 0 relations
194
- [data-platform] 4 tables, 0 relations
195
- [integration] 14 tables, 0 relations
196
- [workflow] 2 tables, 0 relations
197
- Chain Plans : 5
198
- [aigc] 78 chains, 150 steps
199
- Generated Files: 78
200
- Duration : 1153ms
201
- ```
202
-
203
- Key findings:
204
- - **102 tables** and **65 foreign key relations** correctly extracted from flat model layout
205
- - **Embedded associations** (`.belongsTo()` / `.hasMany()` inside model files) detected without dedicated association files
206
- - **78 test files** generated across 5 modules in just over 1 second
207
- - Handles both flat (`models/*.ts`) and nested (`models/module/*.ts`) directory structures
208
-
209
- ## Configuration
210
-
211
- ```typescript
212
- // opencroc.config.ts
213
- import { defineConfig } from 'opencroc';
214
-
215
- export default defineConfig({
216
- // Backend source paths
217
- backend: {
218
- modelsDir: 'src/models',
219
- controllersDir: 'src/controllers',
220
- servicesDir: 'src/services',
221
- },
222
-
223
- // Target application
224
- baseUrl: 'http://localhost:3000',
225
- apiBaseUrl: 'http://localhost:3000/api',
226
-
227
- // AI configuration
228
- ai: {
229
- provider: 'openai', // 'openai' | 'zhipu' | 'custom'
230
- apiKey: process.env.AI_API_KEY,
231
- model: 'gpt-4o-mini',
232
- },
233
-
234
- // Test execution
235
- execution: {
236
- workers: 4,
237
- timeout: 30_000,
238
- retries: 1,
239
- },
240
-
241
- // Log-driven completion (requires backend instrumentation)
242
- logCompletion: {
243
- enabled: true,
244
- endpoint: '/internal/test-logs',
245
- pollIntervalMs: 500,
246
- timeoutMs: 10_000,
247
- },
248
-
249
- // Self-healing
250
- selfHealing: {
251
- enabled: false,
252
- fixScope: 'config-only', // 'config-only' | 'config-and-source'
253
- maxFixRounds: 3,
254
- dryRunFirst: true,
255
- },
256
- });
257
- ```
258
-
259
- ## Supported Tech Stacks
260
-
261
- | Layer | Supported | Planned |
262
- |---|---|---|
263
- | **ORM** | Sequelize, TypeORM, Prisma, Drizzle | — |
264
- | **Framework** | Express | NestJS, Fastify, Koa |
265
- | **Test Runner** | Playwright | |
266
- | **LLM** | OpenAI, ZhiPu (GLM), Ollama (local) | Anthropic |
267
- | **Database** | MySQL, PostgreSQL | SQLite, MongoDB |
268
-
269
- ## Comparison
270
-
271
- | Feature | OpenCroc | Playwright | Metersphere | auto-playwright |
272
- |---|---|---|---|---|
273
- | Source-aware generation | ✅ | ❌ | ❌ | ❌ |
274
- | AI config generation + validation | ✅ | ❌ | ❌ | ❌ |
275
- | Log-driven completion | ✅ | ❌ | ❌ | ❌ |
276
- | Failure chain attribution | ✅ | ❌ | Partial | ❌ |
277
- | Self-healing with rollback | ✅ | ❌ | ❌ | ❌ |
278
- | API dependency DAG | ✅ | ❌ | ❌ | ❌ |
279
- | Zero-config test generation | ✅ | Codegen only | Manual | NL→action |
280
- | Impact blast radius analysis | ✅ | ❌ | ❌ | ❌ |
281
-
282
- ## Roadmap
283
-
284
- - [x] 6-stage source-to-test pipeline
285
- - [x] AI configuration generation with 3-layer validation
286
- - [x] Controlled self-healing loop
287
- - [x] Log-driven completion detection
288
- - [x] Failure chain attribution + impact analysis
289
- - [x] TypeORM / Prisma adapter
290
- - [x] Ollama local LLM support
291
- - [x] Real-world validation (102 tables, 65 relations, 78 generated tests)
292
- - [x] GitHub Actions / GitLab CI integration
293
- - [x] VS Code extension scaffold
294
- - [x] Plugin system
295
- - [x] HTML / JSON / Markdown report generation
296
- - [x] NestJS controller parser
297
- - [x] Visual dashboard (opencroc.com)
298
- - [x] Drizzle ORM adapter
299
-
300
- ## Release Snapshot
301
-
302
- - Current stable release: `0.6.1`
303
- - npm dist-tag `latest`: `0.6.1`
304
- - Roadmap status: fully completed
305
- - Full-suite quality gate: 23 test files / 184 tests passing on Windows with stable Vitest config
306
-
307
- ### Version Rhythm
308
-
309
- - `0.3.x`: plugin system, CI templates, reporters, VS Code scaffold, CI hardening
310
- - `0.4.x`: NestJS controller parser
311
- - `0.5.x`: Drizzle ORM adapter
312
- - `0.6.x`: visual dashboard + Windows Vitest stability hardening
313
-
314
- ### Release Verification
315
-
316
- ```bash
317
- npm run lint
318
- npm run typecheck
319
- npm test
320
- npm view opencroc version dist-tags --json
321
- ```
322
-
323
- ## Documentation
324
-
325
- Visit **[opencroc.com](https://opencroc.com)** for full documentation, or browse:
326
-
327
- - [Architecture Guide](docs/architecture.md)
328
- - [Configuration Reference](docs/configuration.md)
329
- - [Backend Instrumentation Guide](docs/backend-instrumentation.md)
330
- - [AI Provider Setup](docs/ai-providers.md)
331
- - [Self-Healing Guide](docs/self-healing.md)
332
- - [Troubleshooting](docs/troubleshooting.md)
333
-
334
- ## Contributing
335
-
336
- We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
337
-
338
- ## License
339
-
340
- [MIT](LICENSE) © 2026 OpenCroc Contributors
1
+ <p align="center">
2
+ <img src="assets/banner.png" alt="OpenCroc banner" width="820" />
3
+ </p>
4
+
5
+ <h1 align="center">OpenCroc</h1>
6
+
7
+ <p align="center">
8
+ <strong>AI-native E2E testing framework that reads your source code, generates tests, and self-heals failures.</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
+ ## What is OpenCroc?
25
+
26
+ OpenCroc is an **AI-native end-to-end testing framework** built on top of [Playwright](https://playwright.dev). Instead of writing test scripts by hand, OpenCroc **reads your backend source code** (models, controllers, DTOs) and automatically generates complete E2E test suites — including API chains, seed data, request bodies, and assertions.
27
+
28
+ When tests fail, OpenCroc doesn't just report errors — it **traces the root cause** through the full request chain, **generates fix patches**, and **re-runs tests to verify the fix** — all autonomously.
29
+
30
+ ### Key Capabilities
31
+
32
+ | Capability | Description |
33
+ |---|---|
34
+ | **Source-Aware Test Generation** | Parses Sequelize/TypeORM models, Express/NestJS controllers, and DTO decorators via [ts-morph](https://ts-morph.com) to understand your API surface |
35
+ | **AI-Driven Configuration** | LLM generates request body templates, seed data, parameter mappings — validated by 3-layer verification (schema → semantic → dry-run) |
36
+ | **Intelligent Chain Planning** | Builds API dependency DAGs, performs topological sorting, and plans test chains with greedy coverage optimization |
37
+ | **Log-Driven Completion Detection** | Goes beyond `networkidle` — verifies request completion by matching backend execution logs (`api_exec end`) |
38
+ | **Failure Chain Attribution** | Traces failures through the full call chain: network errors → slow APIs → backend logs → root cause |
39
+ | **Controlled Self-Healing** | `backup → AI patch → dry-run → apply → re-run → verify → rollback` — with safety gates at every step |
40
+ | **Impact Analysis** | BFS traversal of foreign key relations to map blast radius, auto-generates Mermaid diagrams |
41
+
42
+ ## Quick Start
43
+
44
+ ### Prerequisites
45
+
46
+ - Node.js >= 18
47
+ - A backend project with Express/NestJS + Sequelize/TypeORM
48
+
49
+ ### Installation
50
+
51
+ ```bash
52
+ npm install opencroc --save-dev
53
+ ```
54
+
55
+ ### Initialize
56
+
57
+ ```bash
58
+ npx opencroc init
59
+ ```
60
+
61
+ This will:
62
+ 1. Scan your project structure
63
+ 2. Detect your ORM and framework
64
+ 3. Create `opencroc.config.ts` with sensible defaults
65
+ 4. Generate a sample test suite
66
+
67
+ ### Generate Tests
68
+
69
+ ```bash
70
+ # Generate tests for a single module
71
+ npx opencroc generate --module=knowledge-base
72
+
73
+ # Generate tests for all detected modules
74
+ npx opencroc generate --all
75
+
76
+ # Dry-run (preview without writing files)
77
+ npx opencroc generate --all --dry-run
78
+ ```
79
+
80
+ ### Run Tests
81
+
82
+ ```bash
83
+ # Run all generated tests
84
+ npx opencroc test
85
+
86
+ # Run specific module
87
+ npx opencroc test --module=knowledge-base
88
+
89
+ # Run in headed browser mode
90
+ npx opencroc test --headed
91
+
92
+ # Override lifecycle hooks from CLI
93
+ npx opencroc test --setup-hook="npm run e2e:setup" --auth-hook="node scripts/auth.js" --teardown-hook="npm run e2e:cleanup"
94
+ ```
95
+
96
+ ### Validate AI Configs
97
+
98
+ ```bash
99
+ # Validate generated configurations
100
+ npx opencroc validate --all
101
+
102
+ # Compare AI-generated vs baseline results
103
+ npx opencroc compare --baseline=report-a.json --current=report-b.json
104
+ ```
105
+
106
+ ### Launch OpenCroc Studio
107
+
108
+ OpenCroc Studio is a **pixel-art croc office** with a real-time **knowledge graph** UI. It runs as a local web server and visualizes your project structure, agent status, and test results.
109
+
110
+ ```bash
111
+ # Start Studio (opens browser at http://localhost:8765)
112
+ npx opencroc serve
113
+
114
+ # Custom port
115
+ npx opencroc serve --port 3000
116
+
117
+ # Don't auto-open browser
118
+ npx opencroc serve --no-open
119
+
120
+ # Specify host (e.g. for remote access)
121
+ npx opencroc serve --host 0.0.0.0 --port 8765
122
+ ```
123
+
124
+ Studio features:
125
+ - **Knowledge Graph Canvas** — interactive graph of your project's models, controllers, and API relations (drag, zoom, hover)
126
+ - **Pixel Croc Office** 6 AI agents (Parser 🐊, Analyzer 🐊, Tester 🐊, Healer 🐊, Planner 🐊, Reporter 🐊) with live status animations
127
+ - **Real-time WebSocket** — agent status and graph changes push to the browser instantly
128
+ - **Module Sidebar** — browse discovered modules and agent states at a glance
129
+ - **REST API** — `GET /api/project` (graph data), `GET /api/agents` (agent states), `POST /api/project/refresh` (re-scan)
130
+
131
+ ### Full Pipeline (One Command)
132
+
133
+ ```bash
134
+ # Run everything: generate → execute → analyze → heal → report
135
+ npx opencroc run
136
+
137
+ # With options
138
+ npx opencroc run --module=users --self-heal --report html,json
139
+ ```
140
+
141
+ ### CI/CD Integration
142
+
143
+ ```bash
144
+ # Generate GitHub Actions workflow
145
+ npx opencroc ci --platform github
146
+
147
+ # Generate GitLab CI pipeline
148
+ npx opencroc ci --platform gitlab --self-heal
149
+ ```
150
+
151
+ ### Dashboard & Reports
152
+
153
+ ```bash
154
+ # Generate visual dashboard
155
+ npx opencroc dashboard
156
+
157
+ # Generate reports in multiple formats
158
+ npx opencroc report --format html,json,markdown
159
+ ```
160
+
161
+ ## Architecture
162
+
163
+ ```
164
+ ┌─────────────────────────────────────────────────────────────┐
165
+ OpenCroc Studio (localhost:8765) │
166
+ │ Pixel Croc Office + Knowledge Graph + WebSocket │
167
+ ├─────────────────────────────────────────────────────────────┤
168
+ │ CLI / Orchestrator │
169
+ ├──────────┬──────────┬──────────┬──────────┬─────────────────┤
170
+ │ Source │ Chain │ Test │ Execution│ Self-Healing
171
+ │ Parser │ Planner │Generator │ Engine │ Engine │
172
+ │ │ │ │ │ │
173
+ ts-morph │ DAG + │ Template │Playwright│ AI Attribution │
174
+ Model │ Topo │ + AI + Log │ + Controlled │
175
+ Controller│ Sort + │ Config │ Driven │ Fix + Verify │
176
+ DTO │ Greedy │ Merge │ Assert │ + Rollback │
177
+ ├──────────┴──────────┴──────────┴──────────┴─────────────────┤
178
+ │ Observation Bus (Network + Backend Logs) │
179
+ ├──────────────────────────────────────────────────────────────┤
180
+ │ Report Engine (HTML / JSON / Markdown) │
181
+ └──────────────────────────────────────────────────────────────┘
182
+ ```
183
+
184
+ ### 6-Stage Pipeline
185
+
186
+ ```
187
+ Source Scan → ER Diagram → API Analysis → Chain Planning → Test Generation → Failure Analysis
188
+ │ │ │ │ │ │
189
+ ts-morph Mermaid Dependency Topological Playwright + Root Cause +
190
+ parsing erDiagram DAG builder + greedy AI body/seed Impact map
191
+ ```
192
+
193
+ ## How It Works
194
+
195
+ ### 1. Source Parsing
196
+
197
+ OpenCroc uses [ts-morph](https://ts-morph.com) to statically analyze your backend:
198
+
199
+ - **Models**: Extracts table names, column types, indexes, and foreign keys from Sequelize `Model.init()` / TypeORM `@Entity()`
200
+ - **Controllers**: Extracts routes, HTTP methods, path parameters from Express `router.get/post/put/delete`
201
+ - **DTOs**: Extracts validation rules from `@IsString()`, `@IsNumber()`, `@IsOptional()` decorators
202
+
203
+ ### 2. AI Configuration Generation
204
+
205
+ For each module, OpenCroc calls an LLM (OpenAI / ZhiPu / any OpenAI-compatible API) to generate:
206
+
207
+ - **Request body templates** field-accurate POST/PUT payloads
208
+ - **Seed data** — `beforeAll` setup steps with correct API sequences
209
+ - **Parameter mappings** — path parameter aliases (`/:id` → `categoryId`)
210
+ - **ID aliases** — preventing ID conflicts across multi-resource chains
211
+
212
+ Each config is validated through **3 layers**:
213
+ 1. **Schema validation** JSON structure completeness
214
+ 2. **Semantic validation** — field values match source code metadata
215
+ 3. **Dry-run validation** — TypeScript compilation check
216
+
217
+ Failed configs are **automatically fixed** (up to 3 rounds) before being written.
218
+
219
+ ### 3. Log-Driven Completion
220
+
221
+ Instead of relying on fragile `networkidle` signals:
222
+
223
+ ```
224
+ Frontend Request → Backend api_exec start log → Backend processing → api_exec end log
225
+
226
+ OpenCroc polls end logs to confirm completion
227
+ ```
228
+
229
+ This catches cases where the frontend appears idle but the backend is still processing.
230
+
231
+ ### 4. Self-Healing Loop
232
+
233
+ ```
234
+ Test Failure
235
+ AI Attribution (LLM + heuristic fallback)
236
+ Generate Fix Patch
237
+ Dry-Run Validation
238
+ Apply Patch (with backup)
239
+ → Re-run Failed Tests
240
+ → Verify Fix
241
+ Commit or Rollback
242
+ ```
243
+
244
+ ## Real-World Validation
245
+
246
+ OpenCroc has been validated against a **production-scale RBAC system** (multi-tenant enterprise permission management) with 100+ Sequelize models, 75+ Express controllers, and embedded associations:
247
+
248
+ ```
249
+ $ npx tsx examples/rbac-system/smoke-test.ts
250
+
251
+ Modules : 5 (default, aigc, data-platform, integration, workflow)
252
+ ER Diagrams : 5
253
+ [default] 102 tables, 65 relations
254
+ [aigc] 6 tables, 0 relations
255
+ [data-platform] 4 tables, 0 relations
256
+ [integration] 14 tables, 0 relations
257
+ [workflow] 2 tables, 0 relations
258
+ Chain Plans : 5
259
+ [aigc] 78 chains, 150 steps
260
+ Generated Files: 78
261
+ Duration : 1153ms
262
+ ```
263
+
264
+ Key findings:
265
+ - **102 tables** and **65 foreign key relations** correctly extracted from flat model layout
266
+ - **Embedded associations** (`.belongsTo()` / `.hasMany()` inside model files) detected without dedicated association files
267
+ - **78 test files** generated across 5 modules in just over 1 second
268
+ - Handles both flat (`models/*.ts`) and nested (`models/module/*.ts`) directory structures
269
+
270
+ ## Configuration
271
+
272
+ ```typescript
273
+ // opencroc.config.ts
274
+ import { defineConfig } from 'opencroc';
275
+
276
+ export default defineConfig({
277
+ // Backend source paths
278
+ backend: {
279
+ modelsDir: 'src/models',
280
+ controllersDir: 'src/controllers',
281
+ servicesDir: 'src/services',
282
+ },
283
+
284
+ // Target application
285
+ baseUrl: 'http://localhost:3000',
286
+ apiBaseUrl: 'http://localhost:3000/api',
287
+
288
+ // AI configuration
289
+ ai: {
290
+ provider: 'openai', // 'openai' | 'zhipu' | 'custom'
291
+ apiKey: process.env.AI_API_KEY,
292
+ model: 'gpt-4o-mini',
293
+ },
294
+
295
+ // Test execution
296
+ execution: {
297
+ workers: 4,
298
+ timeout: 30_000,
299
+ retries: 1,
300
+ },
301
+
302
+ // Log-driven completion (requires backend instrumentation)
303
+ logCompletion: {
304
+ enabled: true,
305
+ endpoint: '/internal/test-logs',
306
+ pollIntervalMs: 500,
307
+ timeoutMs: 10_000,
308
+ },
309
+
310
+ // Self-healing
311
+ selfHealing: {
312
+ enabled: false,
313
+ fixScope: 'config-only', // 'config-only' | 'config-and-source'
314
+ maxFixRounds: 3,
315
+ dryRunFirst: true,
316
+ },
317
+ });
318
+ ```
319
+
320
+ ## Supported Tech Stacks
321
+
322
+ | Layer | Supported | Planned |
323
+ |---|---|---|
324
+ | **ORM** | Sequelize, TypeORM, Prisma, Drizzle | — |
325
+ | **Framework** | Express | NestJS, Fastify, Koa |
326
+ | **Test Runner** | Playwright | — |
327
+ | **LLM** | OpenAI, ZhiPu (GLM), Ollama (local) | Anthropic |
328
+ | **Database** | MySQL, PostgreSQL | SQLite, MongoDB |
329
+
330
+ ## Comparison
331
+
332
+ | Feature | OpenCroc | Playwright | Metersphere | auto-playwright |
333
+ |---|---|---|---|---|
334
+ | Source-aware generation | ✅ | ❌ | ❌ | ❌ |
335
+ | AI config generation + validation | ✅ | ❌ | ❌ | ❌ |
336
+ | Log-driven completion | | ❌ | ❌ | ❌ |
337
+ | Failure chain attribution | ✅ | ❌ | Partial | ❌ |
338
+ | Self-healing with rollback | ✅ | ❌ | ❌ | ❌ |
339
+ | API dependency DAG | ✅ | ❌ | ❌ | ❌ |
340
+ | Zero-config test generation | ✅ | Codegen only | Manual | NL→action |
341
+ | Impact blast radius analysis | ✅ | ❌ | ❌ | ❌ |
342
+
343
+ ## Roadmap
344
+
345
+ - [x] 6-stage source-to-test pipeline
346
+ - [x] AI configuration generation with 3-layer validation
347
+ - [x] Controlled self-healing loop
348
+ - [x] Log-driven completion detection
349
+ - [x] Failure chain attribution + impact analysis
350
+ - [x] TypeORM / Prisma adapter
351
+ - [x] Ollama local LLM support
352
+ - [x] Real-world validation (102 tables, 65 relations, 78 generated tests)
353
+ - [x] GitHub Actions / GitLab CI integration
354
+ - [x] VS Code extension scaffold
355
+ - [x] Plugin system
356
+ - [x] HTML / JSON / Markdown report generation
357
+ - [x] NestJS controller parser
358
+ - [x] Visual dashboard (opencroc.com)
359
+ - [x] Drizzle ORM adapter
360
+ - [x] AI Config Suggester + Enhanced DTO-aware Suggester
361
+ - [x] Auto-Fixer (4 strategies: interface-path, DTO field, seed dependency, param mapping)
362
+ - [x] 3-layer config validation (schema → semantic → dry-run)
363
+ - [x] DTO Parser (ts-morph interface + express-validator extraction)
364
+ - [x] Baseline Comparator (Playwright report diff + regression detection)
365
+ - [x] Module config preset loader
366
+ - [x] LLM-enhanced chain planner
367
+ - [x] Runtime infrastructure (Playwright config, auth setup, teardown, network monitor)
368
+ - [x] Full orchestration pipeline
369
+ - [x] Advanced reporters (checklist, workorder, token tracking)
370
+ - [x] OpenCroc Studio — pixel croc office + knowledge graph UI (`opencroc serve`)
371
+
372
+ ## Release Snapshot
373
+
374
+ - Current stable release: `1.3.0`
375
+ - npm dist-tag `latest`: `1.3.0`
376
+ - Roadmap status: M1 Studio delivered
377
+ - Full-suite quality gate: 34 test files / 373 tests passing on Node.js 20.x & 22.x
378
+
379
+ ### Version Rhythm
380
+
381
+ - `0.3.x`: plugin system, CI templates, reporters, VS Code scaffold, CI hardening
382
+ - `0.4.x`: NestJS controller parser
383
+ - `0.5.x`: Drizzle ORM adapter
384
+ - `0.6.x`: visual dashboard + Windows Vitest stability hardening
385
+ - `0.7.x – 0.9.x`: runtime infrastructure (Playwright generators, auth, log-driven detection, rules engine)
386
+ - `1.0.0`: full orchestration pipeline
387
+ - `1.1.0`: advanced self-healing (dialog loop, controlled fixer, auto-fix PR generation)
388
+ - `1.2.0`: advanced reporters (checklist, workorder, token tracking) + Sprint 0-3 migration complete
389
+ - `1.3.0`: OpenCroc Studio M1 — Fastify server, knowledge graph API, pixel croc office frontend
390
+
391
+ ### Release Verification
392
+
393
+ ```bash
394
+ npm run lint
395
+ npm run typecheck
396
+ npm test
397
+ npm view opencroc version dist-tags --json
398
+ ```
399
+
400
+ ## Documentation
401
+
402
+ Visit **[opencroc.com](https://opencroc.com)** for full documentation, or browse:
403
+
404
+ - [Architecture Guide](docs/architecture.md)
405
+ - [Configuration Reference](docs/configuration.md)
406
+ - [Backend Instrumentation Guide](docs/backend-instrumentation.md)
407
+ - [AI Provider Setup](docs/ai-providers.md)
408
+ - [Self-Healing Guide](docs/self-healing.md)
409
+ - [Troubleshooting](docs/troubleshooting.md)
410
+
411
+ ## Contributing
412
+
413
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
414
+
415
+ ## License
416
+
417
+ [MIT](LICENSE) © 2026 OpenCroc Contributors