@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.en.md CHANGED
@@ -1,237 +1,168 @@
1
1
  <p align="center">
2
- <img src="https://img.shields.io/badge/version-0.8.0-orange?style=flat-square" alt="version" />
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" />
3
4
  <img src="https://img.shields.io/badge/agents-12-blue?style=flat-square" alt="agents" />
4
5
  <img src="https://img.shields.io/badge/workflows-10-green?style=flat-square" alt="workflows" />
5
6
  <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" />
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" />
8
9
  </p>
9
10
 
10
- # SCALE Engine v0.8.0
11
+ # SCALE Engine v0.10.1
11
12
 
12
- > **S**caffold · **C**ontrol · **A**rtifact · **L**earn · **E**volve
13
- >
14
- > AI Engineering Scaffold Engine — Enforce engineering constraints physically, not via prompt "self-discipline"
13
+ SCALE Engine is an AI engineering workflow runtime for agentic coding tools. It turns prompt-level engineering rules into stateful workflow gates, persisted evidence, review records, and release checks.
15
14
 
16
- ---
15
+ Repository: https://github.com/hongmaple0820/scale-engine
16
+ Mirror: https://gitee.com/hongmaple/scale-engine
17
+ npm: https://www.npmjs.com/package/@hongmaple0820/scale-engine
18
+ Language: [English](README.en.md) | [Chinese](README.md)
17
19
 
18
- ## 📦 Repository
20
+ ## Why It Exists
19
21
 
20
- | Platform | URL |
21
- |----------|-----|
22
- | **GitHub** | https://github.com/hongmaple0820/scale-engine |
23
- | **Gitee (Mirror)** | https://gitee.com/hongmaple/scale-engine |
24
- | **npm** | https://www.npmjs.com/package/@hongmaple0820/scale-engine |
22
+ Prompt instructions are advisory. Production engineering needs mechanisms:
25
23
 
26
- **Language:** [English](README.en.md) | [中文文档](README.md)
24
+ - A model can claim tests passed; SCALE stores verification evidence.
25
+ - A model can skip review; SCALE blocks `ship` without persisted review records.
26
+ - A model can stage unrelated files; SCALE now stages only reviewed files.
27
+ - A model can lose workflow state; SCALE stores artifacts and FSM transitions under `.scale`.
27
28
 
28
- ---
29
+ ## Current Release
29
30
 
30
- ## 📖 Table of Contents
31
+ v0.10.1 hardens the phase-aligned delivery workflow:
31
32
 
32
- - [Introduction](#-introduction)
33
- - [Architecture](#-architecture)
34
- - [Features](#-features)
35
- - [Quick Start](#-quick-start)
36
- - [API Reference](#-api-reference)
37
- - [CHANGELOG](#-changelog)
38
- - [License](#-license)
33
+ - `define -> plan -> build -> verify -> review -> ship`
34
+ - FSM-backed artifacts for specs, plans, and tasks
35
+ - persisted gate evidence and review records
36
+ - deterministic review scanner blocks empty `catch`, `@ts-ignore`, focused tests, dangerous shell/Git commands, and security-sensitive changes without G7 evidence
37
+ - built-in G7 security scanning records explainable file/line evidence, blocks CRITICAL by default, and can block HIGH findings in strict mode
38
+ - optional strict TDD evidence gate with `--tdd-evidence` and `--tdd-strict`
39
+ - `ship --no-commit` delivery reports
40
+ - review-gated release commits
41
+ - 11 platform adapters and 12 professional agent profiles
42
+ - Exa/search capability integration
43
+ - 461 Vitest tests passing after scoped ship, TDD evidence, review scanner, and G7 security scan hardening
39
44
 
40
- ---
45
+ ## Installation
41
46
 
42
- ## 🎯 Introduction
43
-
44
- ### What is SCALE Engine?
45
-
46
- SCALE Engine is an **AI Engineering Scaffold** that provides physical constraint layers for AI Agents (Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, etc.), ensuring engineering standards are enforced through mechanisms, not prompt instructions.
47
-
48
- ### Why Do You Need It?
49
-
50
- The core contradiction of AI coding:
51
-
52
- ```
53
- ❌ Prompt says "run tests" → AI can fake it
54
- ❌ Prompt says "don't hardcode keys" → AI can ignore rules
55
- ❌ Prompt says "don't brute retry" → AI can retry indefinitely
56
- ❌ Prompt says "plan before code" → AI can skip planning
47
+ ```bash
48
+ npm install -g @hongmaple0820/scale-engine
49
+ scale --version
57
50
  ```
58
51
 
59
- **Root Problem**: Prompts are "suggestions" that AI can choose to ignore.
52
+ Node.js 20 or newer is required.
60
53
 
61
- SCALE Engine's solution: **Physical Constraints**.
54
+ ## Phase Workflow
62
55
 
56
+ ```bash
57
+ scale define "Scoped release workflow" \
58
+ --description "Implement a TypeScript CLI workflow with verification evidence, review records, rollback constraints, and release safety checks." \
59
+ --success-criteria "verify evidence is persisted,review evidence is persisted,ship blocks unreviewed files"
60
+
61
+ scale plan <spec-id> --rollback "Revert the release commit and remove generated artifacts"
62
+ scale build <plan-id> --description "Implement scoped release workflow"
63
+ scale verify <task-id>
64
+ scale review <task-id>
65
+ scale ship <task-id> --message "feat(workflow): add scoped release workflow"
63
66
  ```
64
- ✅ Stop Hook checks "no tests run" → AI physically cannot skip
65
- ✅ PreTool Hook blocks dangerous commands → AI physically cannot execute
66
- ✅ FSM controls workflow states → AI physically cannot skip steps
67
- ✅ Role Gate limits tool permissions → AI physically cannot overstep
68
- ✅ Detectors catch abnormal behaviors → AI physically cannot hide
69
- ```
70
-
71
- ### How Does It Work?
72
-
73
- SCALE Engine implements AI engineering through **Six Layers**:
74
67
 
75
- | Layer | Responsibility | Core Mechanism |
76
- |-------|----------------|----------------|
77
- | **L1 Context** | Context Building | Token budget + Philosophy injection + Scenario awareness |
78
- | **L2 Guardrails** | Safety Guardrails | 9 Detectors + Role Gate + Cascade escalation |
79
- | **L3 Observability** | Observability | EventBus + BehaviorTracker + Pattern detection |
80
- | **L4 Orchestration** | Task Orchestration | TaskEngine + Effects + 10 Workflows |
81
- | **L5 Memory** | Knowledge Memory | KnowledgeBase + Decay algorithm + Skill discovery |
82
- | **L6 Evolution** | Self-Evolution | Defect→Lesson→Rule→Hook closed loop |
68
+ Use `scale ship <task-id> --no-commit` to generate the delivery report without creating a Git commit.
83
69
 
84
- ---
70
+ Strict TDD evidence can be enforced when needed:
85
71
 
86
- ## 🏗️ Architecture
87
-
88
- ```
89
- ┌─────────────────────────────────────────────────────────────────┐
90
- │ L6 Evolution │
91
- │ Defect → Lesson → Rule → Hook (Self-improvement closed loop) │
92
- ├─────────────────────────────────────────────────────────────────┤
93
- │ L5 Memory │
94
- │ KnowledgeBase + Decay + TF-IDF Recall + Skill Discovery │
95
- ├─────────────────────────────────────────────────────────────────┤
96
- │ L4 Orchestration │
97
- │ TaskEngine + FSM + 10 Workflows + Multi-Agent Collaboration │
98
- ├─────────────────────────────────────────────────────────────────┤
99
- │ L3 Observability │
100
- │ EventBus + BehaviorTracker + 9 Detectors + Pattern Detection │
101
- ├─────────────────────────────────────────────────────────────────┤
102
- │ L2 Guardrails │
103
- │ Role Gate + PreTool/PostTool Hooks + Cascade Escalation │
104
- ├─────────────────────────────────────────────────────────────────┤
105
- │ L1 Context │
106
- │ Token Budget + Philosophy Injection + Scenario Awareness │
107
- └─────────────────────────────────────────────────────────────────┘
72
+ ```bash
73
+ scale verify <task-id> --tdd-strict --tdd-evidence .scale/tdd/<task-id>.json
108
74
  ```
109
75
 
110
- ---
111
-
112
- ## Features
113
-
114
- ### v0.8.0 Highlights
115
-
116
- **Multi-Agent Collaboration System (Phase 4-9)**
117
- - 12 Professional Agent Profiles: frontend, backend, test, ui-design, ops, product, code-review, security, database, performance, docs, architect
118
- - AgentPool: Instance lifecycle management
119
- - AgentDispatcher: Automatic task distribution
120
- - AgentChannel: Inter-agent messaging
121
- - AgentCoordinator: Team task orchestration
122
-
123
- **Workflow Enhancements (Phase 1-3)**
124
- - SessionStart Hook: Automatic FSM state injection
125
- - AutoDefectCreator: Automatic defect creation from detector events
126
- - TF-IDF Memory Recall: Text similarity-based knowledge retrieval
127
-
128
- **Karpathy Anti-Patterns**
129
- - Brute Retry, Blame Shift, Tool Idle, Busy Illusion, Passive Wait countermeasures
130
-
131
- ---
132
-
133
- ## 🚀 Quick Start
134
-
135
- ### Installation
136
-
137
- ```bash
138
- npm install @hongmaple0820/scale-engine
76
+ The TDD evidence JSON must include `red`, `green`, `refactor`, and `testFirst` set to `true`.
77
+
78
+ ## Safety Model
79
+
80
+ SCALE Engine uses multiple enforcement layers:
81
+
82
+ | Layer | Purpose |
83
+ | --- | --- |
84
+ | FSM | Prevents invalid artifact lifecycle transitions |
85
+ | GateSystem | Runs build, lint, test, coverage, and security gates |
86
+ | EvidenceStore | Persists verification evidence for audit and release gating |
87
+ | ReviewStore | Persists deterministic review records |
88
+ | ReviewAnalyzer | Scans diffs for high-risk code, process debt, and missing security evidence |
89
+ | Detectors | Detects brute retry, premature completion, blame shifting, busy loops, and related failure modes |
90
+ | Ship gate | Requires passing verification and review evidence before release |
91
+
92
+ The `ship` command no longer stages the whole workspace. It stages only files covered by passing review records and blocks if new reviewable files appear after review.
93
+
94
+ G7 `SecurityGate` includes a lightweight built-in scan for hardcoded secrets, private keys, disabled TLS verification, `eval`/`Function`, raw HTML injection, dangerous shell commands, shell execution, and empty `catch` blocks. Compatibility mode blocks CRITICAL findings; strict mode also blocks HIGH findings.
95
+
96
+ ## Supported Platforms
97
+
98
+ SCALE Engine includes adapters for 11 agent platforms, including Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, OpenClaw, Hermes, Trae, WorkBuddy, VS Code Copilot CLI, and QCoder.
99
+
100
+ It also includes 12 professional agent profiles:
101
+
102
+ - frontend
103
+ - backend
104
+ - testing
105
+ - UI design
106
+ - operations
107
+ - product
108
+ - code review
109
+ - security
110
+ - database
111
+ - performance
112
+ - documentation
113
+ - architecture
114
+
115
+ ## Project Layout
116
+
117
+ ```text
118
+ src/api/cli.ts CLI entrypoint
119
+ src/cli/phaseCommands.ts DEFINE/PLAN/BUILD/VERIFY/REVIEW/SHIP
120
+ src/workflow/gates/ Quality gates and persisted evidence
121
+ src/workflow/ReviewAnalyzer.ts Deterministic review analysis
122
+ src/workflow/ReviewStore.ts Review record persistence
123
+ src/workflow/EvidenceStore.ts Gate evidence persistence
124
+ src/artifact/ Artifact store and FSM definitions
125
+ src/guardrails/ Detector and gateway logic
126
+ src/evolution/ Defect/Lesson/Rule/Hook evolution layer
127
+ tests/ Vitest test suites
139
128
  ```
140
129
 
141
- ### CLI Usage
130
+ ## Development
142
131
 
143
132
  ```bash
144
- scale init --scenario standard
145
- scale doctor
146
- scale agent spawn --profile frontend
147
- scale team create --profiles frontend,backend,test --task "Implement auth"
148
- scale workflow list
133
+ npm install
134
+ npm run build
135
+ npx vitest run
136
+ npm pack --dry-run
149
137
  ```
150
138
 
151
- ### Programmatic Usage
139
+ Targeted workflow tests:
152
140
 
153
- ```typescript
154
- import { AgentPool, AgentDispatcher, KnowledgeBase } from '@hongmaple0820/scale-engine'
155
-
156
- const pool = new AgentPool(eventBus, modelRouter)
157
- const agent = pool.spawn('frontend-agent')
158
- await dispatcher.dispatch(taskId, ['frontend-agent', 'backend-agent'])
141
+ ```bash
142
+ npx vitest run tests/workflow/phaseCli.test.ts
143
+ npx vitest run tests/workflow/reviewAnalyzer.test.ts tests/workflow/reviewStore.test.ts tests/workflow/gateSystem.test.ts
159
144
  ```
160
145
 
161
- ---
162
-
163
- ## 📋 CHANGELOG
146
+ ## Release Notes
164
147
 
165
- ### v0.8.0 (2026-05-08)
148
+ ### v0.10.1
166
149
 
167
- - Multi-Agent Collaboration System (12 profiles, AgentPool, Dispatcher, Channel, Coordinator)
168
- - TF-IDF Memory Recall
169
- - SessionStart Hook, AutoDefectCreator, BehaviorTracker.autoEvolve
170
- - Karpathy Anti-Patterns
171
- - Tests: 410 passed (32 files)
150
+ - Hardened `ship` so release commits stage only files covered by passing review records.
151
+ - Added `ship --no-commit` delivery reports for reviewable output without creating a Git commit.
152
+ - Added optional strict TDD evidence verification with `--tdd-evidence` and `--tdd-strict`.
153
+ - Added richer command evidence metadata: working directory, timestamps, stdout/stderr tails, and output hashes.
154
+ - Hardened deterministic review scanning for empty `catch`, `@ts-ignore`, focused tests, dangerous shell/Git commands, and security-sensitive changes without G7 evidence.
155
+ - Hardened built-in G7 security scanning with explainable file/line evidence and compatibility vs strict blocking modes.
156
+ - Added CLI/unit regression tests for `review -> ship`, unreviewed-file blocking, and security-scanner false-positive boundaries.
157
+ - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
172
158
 
173
- ### v0.7.1 (2026-05-06)
159
+ ### v0.10.0
174
160
 
175
- - SessionStart hook, AutoDefectCreator, ContextBuilder enhancements
176
- - Tests: 323 passed
161
+ - Added phase-aligned workflow commands with FSM integration.
162
+ - Added persisted verification evidence and review records.
163
+ - Published `@hongmaple0820/scale-engine@0.10.0`.
164
+ - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
177
165
 
178
- ### v0.6.0 (2026-04-29)
166
+ ## License
179
167
 
180
- - SQLiteKnowledgeBase, FSM concurrency locks, ScopeCreepDetector
181
-
182
- ### v0.5.0 (2026-04-22)
183
-
184
- - 7 Agent adapters, 3 Scenario modes, 10 Workflows, Skill ecosystem
185
-
186
- ---
187
-
188
- ## 🌐 Community
189
-
190
- ### Links
191
-
192
- | Platform | URL |
193
- |----------|-----|
194
- | **GitHub** | https://github.com/hongmaple0820/scale-engine |
195
- | **Gitee (Mirror)** | https://gitee.com/hongmaple/scale-engine |
196
- | **npm** | https://www.npmjs.com/package/@hongmaple0820/scale-engine |
197
-
198
- ### Community Groups
199
-
200
- <p align="center">
201
- <a href="https://qm.qq.com/q/RuCfOyaOUm">
202
- <img src="https://img.shields.io/badge/QQ-628043364-blue.svg?style=for-the-badge" alt="Join QQ Group" />
203
- </a>
204
- </p>
205
-
206
- <p align="center">
207
- <strong>Feishu Group</strong><br/>
208
- <img src="https://cdn.nlark.com/yuque/0/2026/jpeg/1698739/1778311890484-5f96693f-745c-4ed5-950a-c3143de40811.jpeg" alt="Feishu QR" width="300" />
209
- </p>
210
-
211
- ### WeChat
212
-
213
- <p align="center">
214
- <strong>Public Account: 鸿枫技术栈</strong><br/>
215
- <img src="https://cdn.nlark.com/yuque/0/2026/png/1698739/1778312235122-cfa7ad6c-7420-40dd-9741-2254f6fef5b0.png" alt="WeChat QR" width="300" />
216
- </p>
217
-
218
- - **Group Chat**: Add **mapleCx330** to join discussion group
219
- - **Email**: 2496155694@qq.com
220
-
221
- ### Knowledge Planet (¥99/year)
222
-
223
- - Exclusive skill packs and configuration templates
224
- - Deep case study breakdowns
225
- - 1v1 Q&A with community experts
226
- - Early access to new features
227
-
228
- > Join: https://t.zsxq.com/6T5Eq
229
-
230
- ---
231
-
232
- ### ❤️ Support Open Source
233
-
234
- <p align="center">
235
- <img src="/image/wxPay.jpg" alt="WeChat Pay" width="150" />
236
- <img src="/image/zfb.jpg" alt="Alipay" width="150" />
237
- </p>
168
+ MIT