@hongmaple0820/scale-engine 0.24.0 → 0.26.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 (155) hide show
  1. package/LICENSE +15 -15
  2. package/README.en.md +336 -304
  3. package/README.md +500 -475
  4. package/dist/adapters/AiderAdapter.js +52 -52
  5. package/dist/adapters/AntigravityAdapter.d.ts +4 -0
  6. package/dist/adapters/AntigravityAdapter.js +21 -0
  7. package/dist/adapters/AntigravityAdapter.js.map +1 -0
  8. package/dist/adapters/ClaudeCodeAdapter.d.ts +4 -1
  9. package/dist/adapters/ClaudeCodeAdapter.js +34 -34
  10. package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
  11. package/dist/adapters/ClineAdapter.d.ts +4 -0
  12. package/dist/adapters/ClineAdapter.js +20 -0
  13. package/dist/adapters/ClineAdapter.js.map +1 -0
  14. package/dist/adapters/CodexAdapter.js +28 -28
  15. package/dist/adapters/CursorAdapter.js +26 -26
  16. package/dist/adapters/DeepSeekTuiAdapter.js +97 -97
  17. package/dist/adapters/DoubaoAdapter.js +33 -33
  18. package/dist/adapters/GeminiAdapter.js +26 -26
  19. package/dist/adapters/GenericProjectAgentAdapter.d.ts +29 -0
  20. package/dist/adapters/GenericProjectAgentAdapter.js +204 -0
  21. package/dist/adapters/GenericProjectAgentAdapter.js.map +1 -0
  22. package/dist/adapters/HermesAdapter.js +26 -26
  23. package/dist/adapters/JCodeAdapter.d.ts +4 -0
  24. package/dist/adapters/JCodeAdapter.js +19 -0
  25. package/dist/adapters/JCodeAdapter.js.map +1 -0
  26. package/dist/adapters/KiloCodeAdapter.d.ts +4 -0
  27. package/dist/adapters/KiloCodeAdapter.js +20 -0
  28. package/dist/adapters/KiloCodeAdapter.js.map +1 -0
  29. package/dist/adapters/KimiAdapter.js +32 -32
  30. package/dist/adapters/KiroAdapter.js +26 -26
  31. package/dist/adapters/OpenClawAdapter.js +26 -26
  32. package/dist/adapters/OpenCodeAdapter.js +26 -26
  33. package/dist/adapters/QCoderAdapter.js +26 -26
  34. package/dist/adapters/QoderAdapter.d.ts +4 -0
  35. package/dist/adapters/QoderAdapter.js +21 -0
  36. package/dist/adapters/QoderAdapter.js.map +1 -0
  37. package/dist/adapters/TraeAdapter.js +26 -26
  38. package/dist/adapters/VSCAdapter.js +26 -26
  39. package/dist/adapters/WindsurfAdapter.js +32 -32
  40. package/dist/adapters/WorkBuddyAdapter.js +26 -26
  41. package/dist/adapters/index.d.ts +5 -0
  42. package/dist/adapters/index.js +15 -0
  43. package/dist/adapters/index.js.map +1 -1
  44. package/dist/api/cli.js +226 -48
  45. package/dist/api/cli.js.map +1 -1
  46. package/dist/api/doctor.js +10 -3
  47. package/dist/api/doctor.js.map +1 -1
  48. package/dist/api/quickstart.js +7 -1
  49. package/dist/api/quickstart.js.map +1 -1
  50. package/dist/artifact/sqliteStore.js +89 -89
  51. package/dist/artifact/types.d.ts +1 -1
  52. package/dist/cli/phaseCommands.js +45 -45
  53. package/dist/context/AntiPatternRegistry.js +20 -20
  54. package/dist/context/ContextBuilder.js +155 -155
  55. package/dist/evolution/EvolutionEngine.js +31 -31
  56. package/dist/evolution/EvolutionEvaluator.d.ts +2 -0
  57. package/dist/evolution/EvolutionEvaluator.js +7 -1
  58. package/dist/evolution/EvolutionEvaluator.js.map +1 -1
  59. package/dist/fsm/FSMAgentBridge.js +11 -11
  60. package/dist/hooks/HookGeneratorEnhanced.js +218 -218
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +2 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/knowledge/SQLiteKnowledgeBase.js +28 -28
  65. package/dist/memory/MemoryBrain.d.ts +1 -0
  66. package/dist/memory/MemoryBrain.js +55 -52
  67. package/dist/memory/MemoryBrain.js.map +1 -1
  68. package/dist/memory/MemoryFabric.d.ts +13 -1
  69. package/dist/memory/MemoryFabric.js +35 -0
  70. package/dist/memory/MemoryFabric.js.map +1 -1
  71. package/dist/memory/MemoryProviders.d.ts +111 -0
  72. package/dist/memory/MemoryProviders.js +385 -0
  73. package/dist/memory/MemoryProviders.js.map +1 -0
  74. package/dist/memory/index.d.ts +1 -0
  75. package/dist/memory/index.js +1 -0
  76. package/dist/memory/index.js.map +1 -1
  77. package/dist/output/GovernanceDashboard.js +44 -44
  78. package/dist/output/HTMLArtifactLayer.js +31 -31
  79. package/dist/prompts/VibeTemplateGallery.js +121 -121
  80. package/dist/skills/SkillDiscovery.js +12 -1
  81. package/dist/skills/SkillDiscovery.js.map +1 -1
  82. package/dist/skills/SkillRadar.js +20 -0
  83. package/dist/skills/SkillRadar.js.map +1 -1
  84. package/dist/skills/SkillRepository.d.ts +9 -1
  85. package/dist/skills/SkillRepository.js +70 -0
  86. package/dist/skills/SkillRepository.js.map +1 -1
  87. package/dist/skills/routing/SkillPlanner.js +40 -40
  88. package/dist/workflow/EngineeringStandards.js +62 -62
  89. package/dist/workflow/GovernanceTemplatePacks.d.ts +1 -1
  90. package/dist/workflow/GovernanceTemplatePacks.js +1990 -162
  91. package/dist/workflow/GovernanceTemplatePacks.js.map +1 -1
  92. package/dist/workflow/GovernanceTemplates.d.ts +2 -0
  93. package/dist/workflow/GovernanceTemplates.js +1012 -1001
  94. package/dist/workflow/GovernanceTemplates.js.map +1 -1
  95. package/dist/workflow/ResourceGovernance.js +16 -16
  96. package/dist/workflow/TaskArtifactScaffolder.js +10 -10
  97. package/dist/workflow/UpgradeManager.d.ts +3 -2
  98. package/dist/workflow/UpgradeManager.js +134 -49
  99. package/dist/workflow/UpgradeManager.js.map +1 -1
  100. package/dist/workflow/WorkspaceTopology.js +18 -15
  101. package/dist/workflow/WorkspaceTopology.js.map +1 -1
  102. package/docs/CODE_INTELLIGENCE.md +138 -138
  103. package/docs/CONTEXT_BUDGET.md +81 -81
  104. package/docs/EXTERNAL_REFERENCES.md +63 -0
  105. package/docs/GITLAB_FLOW.md +125 -125
  106. package/docs/GOVERNANCE_DASHBOARD.md +64 -64
  107. package/docs/MEMORY_BRAIN.md +104 -104
  108. package/docs/MEMORY_FABRIC.md +134 -107
  109. package/docs/README.md +79 -68
  110. package/docs/RUNTIME_EVIDENCE.md +101 -101
  111. package/docs/SKILL-REPOSITORY.md +57 -0
  112. package/docs/SKILL_RADAR.md +122 -115
  113. package/docs/THIRD_PARTY_SKILLS.md +57 -0
  114. package/docs/WORKFLOW_EVAL.md +151 -151
  115. package/docs/guides/DEVELOPMENT_WORKFLOW.md +80 -0
  116. package/docs/guides/GETTING_STARTED.md +50 -0
  117. package/docs/start/README.md +78 -72
  118. package/docs/start/agent-governance-demo.md +107 -107
  119. package/docs/start/quickstart.md +137 -127
  120. package/docs/start/workflow-upgrade.md +32 -8
  121. package/docs/workflow/README.md +67 -0
  122. package/docs/workflow/node-library.md +52 -0
  123. package/docs/workflow/templates/api-contract.md +29 -0
  124. package/docs/workflow/templates/architecture-review.md +23 -0
  125. package/docs/workflow/templates/db-change-plan.md +20 -0
  126. package/docs/workflow/templates/docs-impact.md +17 -0
  127. package/docs/workflow/templates/e2e-plan.md +20 -0
  128. package/docs/workflow/templates/explore.md +16 -0
  129. package/docs/workflow/templates/github-actions-scale-preflight.yml +32 -0
  130. package/docs/workflow/templates/mini-prd.md +16 -0
  131. package/docs/workflow/templates/plan.md +37 -0
  132. package/docs/workflow/templates/pre-push-scale-preflight.sh +8 -0
  133. package/docs/workflow/templates/product-smoke.md +61 -0
  134. package/docs/workflow/templates/reality-check.md +28 -0
  135. package/docs/workflow/templates/resource-cleanup.md +17 -0
  136. package/docs/workflow/templates/resource-impact.md +25 -0
  137. package/docs/workflow/templates/review.md +12 -0
  138. package/docs/workflow/templates/runtime.md +23 -0
  139. package/docs/workflow/templates/security-review.md +26 -0
  140. package/docs/workflow/templates/skill-evidence.md +33 -0
  141. package/docs/workflow/templates/skill-plan.md +39 -0
  142. package/docs/workflow/templates/spec.md +17 -0
  143. package/docs/workflow/templates/standards-impact.md +28 -0
  144. package/docs/workflow/templates/summary.md +16 -0
  145. package/docs/workflow/templates/tasks.md +8 -0
  146. package/docs/workflow/templates/ui-spec.md +29 -0
  147. package/docs/workflow/templates/verification.md +20 -0
  148. package/docs/workflow/templates/visual-review.md +20 -0
  149. package/examples/demo-projects/agent-governance-demo/CONTEXT.md +14 -14
  150. package/examples/demo-projects/agent-governance-demo/README.md +48 -48
  151. package/examples/demo-projects/agent-governance-demo/docs/CONTEXT-MAP.md +14 -14
  152. package/examples/demo-projects/agent-governance-demo/package.json +22 -21
  153. package/examples/demo-projects/agent-governance-demo/src/oauth-state.ts +39 -39
  154. package/examples/demo-projects/agent-governance-demo/tests/oauth-state.test.ts +52 -52
  155. package/package.json +88 -75
package/README.en.md CHANGED
@@ -1,17 +1,17 @@
1
- <p align="center">
2
- <img src="https://img.shields.io/badge/version-0.23.0-orange?style=flat-square" alt="version" />
3
- <img src="https://img.shields.io/badge/platforms-16-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-19-red?style=flat-square" alt="detectors" />
7
- <img src="https://img.shields.io/badge/tests-verified-brightgreen?style=flat-square" alt="tests" />
8
- <img src="https://img.shields.io/badge/npm-0.23.0-cb3837?style=flat-square&logo=npm" alt="npm" />
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/version-0.26.0-orange?style=flat-square" alt="version" />
3
+ <img src="https://img.shields.io/badge/platforms-22-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-19-red?style=flat-square" alt="detectors" />
7
+ <img src="https://img.shields.io/badge/tests-verified-brightgreen?style=flat-square" alt="tests" />
8
+ <img src="https://img.shields.io/badge/npm-0.26.0-cb3837?style=flat-square&logo=npm" alt="npm" />
9
9
  </p>
10
10
 
11
- # SCALE Engine v0.23.0
12
-
13
- SCALE Engine makes AI coding agents follow engineering rules through executable workflow gates, evidence files, and review constraints instead of relying on prompt discipline alone. It helps humans see what the agent explored, planned, verified, skipped, and why a task is or is not ready to ship.
14
-
11
+ # SCALE Engine v0.26.0
12
+
13
+ SCALE Engine makes AI coding agents follow engineering rules through executable workflow gates, evidence files, and review constraints instead of relying on prompt discipline alone. It helps humans see what the agent explored, planned, verified, skipped, and why a task is or is not ready to ship.
14
+
15
15
  Repository: https://github.com/hongmaple0820/scale-engine
16
16
  Mirror: https://gitee.com/hongmaple/scale-engine
17
17
  npm: https://www.npmjs.com/package/@hongmaple0820/scale-engine
@@ -42,295 +42,327 @@ If SCALE Engine saves engineering governance time for your team, or helps move A
42
42
  </p>
43
43
 
44
44
  ## What It Solves
45
-
46
- AI coding becomes hard when agents must behave consistently across real teams and real repositories:
47
-
48
- | Failure mode | SCALE mechanism |
49
- | --- | --- |
50
- | Agent says tests passed without running them | Verification profiles and evidence stores record actual commands and results |
51
- | Agent skips discovery, design, TDD, or review | `scale context`, `scale diagnose`, `scale tdd`, and `scale status` produce required next actions |
52
- | Agent stages unrelated files or edits the wrong repository | Review-gated shipping, MOE workspace rules, and child repository blockers control boundaries |
53
- | Docs, screenshots, reports, scripts, and temporary files become unmaintainable | Resource governance classifies maintained assets, task evidence, temporary outputs, and forbidden commits |
54
- | Noisy logs, secrets, ORM misuse, framework violations, or security risks slip through | Engineering standards and OWASP scans produce traceable findings |
55
- | Long Markdown reports are not read | `scale artifact` renders traceable HTML reports from maintained Markdown sources |
56
-
57
- ## See It In 3 Minutes
58
-
59
- ```bash
60
- npm install -g @hongmaple0820/scale-engine
61
- mkdir scale-demo && cd scale-demo
62
- scale init --governance-pack standard
63
- scale preflight --preflight-profile quick
64
- scale status
65
- ```
66
-
67
- This generates governance files you can commit to a project:
68
-
69
- - `.scale/verification.json`: service matrix and verification profiles
70
- - `.scale/skills.json`: skill routing and evidence requirements
71
- - `.scale/tools.json`: CLI/MCP/browser/desktop orchestration policy
72
- - `docs/workflow/templates/`: Mini-PRD, plan, verification, review, and summary templates
73
- - `docs/standards/`: engineering, Git collaboration, and resource governance rules
74
-
75
- Continue with a full workflow loop:
76
-
77
- ```bash
78
- scale context init --name "Scale Demo"
79
- scale context grill --task-id 2026-05-18-oauth-hardening --task "Harden OAuth callback"
80
- scale diagnose plan --task-id 2026-05-18-oauth-hardening --symptom "callback returns 500 when state expires"
81
- scale tdd slice --task-id 2026-05-18-oauth-hardening --behavior "reject expired OAuth state" --public-interface "GET /oauth/callback" --failing-test "expired state returns 401" --test-file tests/oauth.test.ts --impl-files src/oauth.ts
82
- scale artifact render --task-id 2026-05-18-oauth-hardening --artifact-dir .planning/tasks/2026-05-18-oauth-hardening
83
- scale artifact doctor --artifact-dir .planning/tasks/2026-05-18-oauth-hardening
84
- ```
85
-
86
- Read [Quickstart](docs/start/quickstart.md) and [Agent Governance Demo](docs/start/agent-governance-demo.md) for the complete walkthrough.
87
-
88
- ## Who It Is For
89
-
90
- - Teams using Codex, Claude Code, Cursor, Gemini CLI, OpenCode, Aider, or similar agents on real projects.
91
- - Teams with multi-service, multi-repository, MOE workspace, frontend/backend, or scaffold governance needs.
92
- - Teams that want agents to actively use skills, MCPs, CLIs, browser automation, E2E checks, and HTML reports with safety boundaries.
93
- - Project owners who feel AI code is fast but hard to review, verify, and maintain.
94
-
95
- It is not optimized for toy projects that only want one minimal prompt file and do not need gates, collaboration rules, or long-term maintainability.
96
-
97
- ## Core Capabilities
98
-
99
- - Workflow Engine: `define -> plan -> build -> verify -> review -> ship` with persisted state.
100
- - GateSystem: build, lint, test, coverage, security, TDD, review, and tool evidence gates.
101
- - Governance Packs: `standard`, `project-scaffold`, `moe-workspace`, `resource-governance`, `go-service-matrix`, `node-library`, and `frontend-app`.
102
- - Resource Governance: docs, media, reports, test scripts, temporary scripts, HTML artifacts, and local config lifecycle rules.
103
- - Skill and Tool Orchestration: UI/UX, web research, browser E2E, Chrome DevTools MCP, desktop automation, and external agent CLIs.
104
- - Engineering Standards: noisy logs, sensitive data, injection risks, ORM/database usage, framework boundaries, test rigor, and deployment risk.
105
- - HTML Artifacts: Markdown remains the maintained source; HTML becomes the review, comparison, status, and release handoff layer.
106
-
107
- ## Installation
108
-
109
- ```bash
110
- npm install -g @hongmaple0820/scale-engine
111
- scale --version
112
- ```
113
-
114
- Node.js 20 or newer is required.
115
-
116
- ## Governance Packs
117
-
118
- Use `scale init` to install a governed workflow into an existing project:
119
-
120
- ```bash
121
- scale init --governance-pack standard
122
- scale init --governance-pack project-scaffold
123
- scale init --governance-pack moe-workspace
124
- scale init --governance-pack resource-governance
125
- scale init --governance-pack go-service-matrix
126
- scale init --governance-pack node-library
127
- scale init --governance-pack frontend-app
128
- ```
129
-
130
- Supported packs:
131
-
132
- | Pack | Best fit |
133
- | --- | --- |
134
- | `standard` | General project governance with task artifacts, verification, metrics, resources, standards, and skills policy |
135
- | `project-scaffold` | Reproducible engineering workflow scaffold and demo governance project |
136
- | `moe-workspace` | Parent workspace with independent child repositories or MOE-style multi-repo development |
137
- | `resource-governance` | Asset/document lifecycle policy for docs, reports, screenshots, scripts, media, and generated outputs |
138
- | `go-service-matrix` | Go backend services with service-aware build/lint/test/security verification |
139
- | `node-library` | Node/TypeScript package workflow, release, and verification governance |
140
- | `frontend-app` | UI/UX, browser evidence, responsive checks, E2E, and visual review governance |
141
-
142
- If you are unsure, start with `standard`. Use a specialized pack when the project shape is clear:
143
-
144
- See [Getting Started](docs/start/README.md) for runnable tutorials and demo paths.
145
-
146
- ## Phase Workflow
147
-
148
- ```bash
149
- scale define "Scoped release workflow" \
150
- --description "Implement a TypeScript CLI workflow with verification evidence, review records, rollback constraints, and release safety checks." \
151
- --success-criteria "verify evidence is persisted,review evidence is persisted,ship blocks unreviewed files"
152
-
153
- scale plan <spec-id> --rollback "Revert the release commit and remove generated artifacts"
154
- scale build <plan-id> --description "Implement scoped release workflow"
155
- scale verify <task-id>
156
- scale review <task-id>
157
- scale ship <task-id> --message "feat(workflow): add scoped release workflow"
158
- ```
159
-
160
- Use `scale ship <task-id> --no-commit` to generate the delivery report without creating a Git commit.
161
-
162
- Strict TDD evidence can be enforced when needed:
163
-
164
- ```bash
165
- scale verify <task-id> --tdd-strict --tdd-evidence .scale/tdd/<task-id>.json
166
- ```
167
-
168
- The TDD evidence JSON must include `red`, `green`, `refactor`, and `testFirst` set to `true`.
169
-
170
- ## Evolution Self-Improve Loop
171
-
172
- Extract lessons from session defects and promote to rules and hooks:
173
-
174
- ```bash
175
- # Extract Lessons from session
176
- scale evolution extract <session-id>
177
-
178
- # Run self-improve loop: Defect → Lesson → Rule → Hook
179
- scale evolution improve <session-id>
180
-
181
- # Show self-improve report
182
- scale evolution report <session-id>
183
-
184
- # View generated Hooks config
185
- scale evolution hooks <session-id> --json
186
- ```
187
-
188
- Thresholds:
189
- - Lesson → Rule: requires 3 verifications
190
- - Rule Active: requires 10 hits
191
- - Rule → Hook: requires 20 hits
192
-
193
- ## Safety Model
194
-
195
- SCALE Engine uses multiple enforcement layers:
196
-
197
- | Layer | Purpose |
198
- | --- | --- |
199
- | FSM | Prevents invalid artifact lifecycle transitions |
200
- | GateSystem | Runs build, lint, test, coverage, and security gates |
201
- | EvidenceStore | Persists verification evidence for audit and release gating |
202
- | ReviewStore | Persists deterministic review records |
203
- | ReviewAnalyzer | Scans diffs for high-risk code, process debt, and missing security evidence |
204
- | Detectors | Detects brute retry, premature completion, blame shifting, busy loops, and related failure modes |
205
- | Ship gate | Requires passing verification and review evidence before release |
206
-
207
- 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.
208
-
209
- Git branch governance follows a GitLab Flow variant: short branches merge into `dev`, verified releases land on `master`, and production publishing is triggered by user-created `vX.Y.Z` tags on `master`. `scale ship` blocks direct governed commits on `dev`, `master`, `main`, or detached HEAD, and temporary worktree cleanup is blocked when the branch still has unpushed or unmerged commits. See [docs/GITLAB_FLOW.md](docs/GITLAB_FLOW.md).
210
-
211
- 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.
212
-
213
- ## Supported Platforms
214
-
215
- SCALE Engine includes adapters for 16 agent platforms, including Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, OpenClaw, Hermes, Trae, WorkBuddy, VS Code Copilot CLI, QCoder, DeepSeek-TUI, Aider, Windsurf, Kimi, and Doubao.
216
-
217
- It also includes 12 professional agent profiles:
218
-
219
- - frontend
220
- - backend
221
- - testing
222
- - UI design
223
- - operations
224
- - product
225
- - code review
226
- - security
227
- - database
228
- - performance
229
- - documentation
230
- - architecture
231
-
232
- ## Project Layout
233
-
234
- ```text
235
- src/api/cli.ts CLI entrypoint
236
- src/cli/phaseCommands.ts DEFINE/PLAN/BUILD/VERIFY/REVIEW/SHIP
237
- src/cli/evolutionCommands.ts L6 Evolution CLI commands
238
- src/workflow/gates/ Quality gates and persisted evidence
239
- src/workflow/ReviewAnalyzer.ts Deterministic review analysis
240
- src/workflow/ReviewStore.ts Review record persistence
241
- src/workflow/EvidenceStore.ts Gate evidence persistence
242
- src/workflow/evolution/ LessonExtractor + SelfImproveEngine
243
- src/workflow/qa/ BrowserQA + E2ETestRunner
244
- src/artifact/ Artifact store and FSM definitions
245
- src/guardrails/ Detector and gateway logic
246
- src/guardrails/OWASPDetector.ts OWASP Top 10 security detection
247
- src/capabilities/BrowserQACapability.ts Playwright MCP wrapper
248
- src/evolution/ Defect/Lesson/Rule/Hook evolution layer
249
- tests/ Vitest test suites
250
- ```
251
-
252
- ## Development
253
-
254
- ```bash
255
- npm install
256
- npm run build
257
- npx vitest run
258
- npm pack --dry-run
259
- ```
260
-
261
- Targeted workflow tests:
262
-
263
- ```bash
264
- npx vitest run tests/workflow/phaseCli.test.ts
265
- npx vitest run tests/workflow/reviewAnalyzer.test.ts tests/workflow/reviewStore.test.ts tests/workflow/gateSystem.test.ts
266
- ```
267
-
268
- ## Release Notes
269
-
270
- ### v0.20.0
271
-
272
- - Added Context Budget and Progressive Governance so low-risk S tasks stay lightweight while auth, data, security, deployment, and cross-module changes escalate automatically.
273
- - Added Code Intelligence with adapter-first CodeGraph / Graphify support, explicit fallback, impact analysis, context recommendations, and exploration ROI.
274
- - Added Workflow Eval, Failure Replay, and improvement candidates with pass@k, fix iterations, tool-call counts, token estimates, and human-correction metrics.
275
- - Added Skill Radar for intent-based skills, MCP, browser, desktop automation, and external CLI recommendations with confidence, safety level, and evidence requirements.
276
- - Added Memory Brain for evidence-backed long-term memory candidates, contradiction detection, dream maintenance, explicit promotion, and failure replay ingestion.
277
- - Added Governance Dashboard to summarize runtime, eval, memory, resource, and HTML artifact evidence in a local HTML review surface.
278
- - Fixed new `--dir` aware commands so relative `.scale` state resolves inside the target project instead of the caller workspace.
279
-
280
- ### v0.19.0
281
-
282
- - Added product smoke gates, runtime evidence learning settlement, memory context packs, workspace conflict blockers, and release-readiness demo coverage.
283
-
284
- ### v0.18.0
285
-
286
- - Governed HTML artifacts: `scale artifact render/doctor/settle/open`.
287
- - Markdown remains the editable source of truth; generated HTML is traceable task evidence.
288
- - Governance packs now include output policy and HTML artifact resource classification.
289
- - Added tests for HTML artifact rendering, safety checks, settlement evidence, and generated template output.
290
-
291
- ### v0.17.0
292
-
293
- - Added active workflow command gates: `scale context`, `scale diagnose`, `scale tdd`, and `scale status`.
294
- - Added required next-action queues so agents cannot silently skip context, debugging, TDD, or verification work.
295
-
296
- ### v0.16.0
297
-
298
- - Added governed skill repository, skill recommendation, install-safety checks, visual Vibe templates, and leadership presets.
299
- - Strengthened tool orchestration and resource/engineering standards governance.
300
-
301
- ### v0.15.1
302
-
303
- - Added UI/UX, web research, browser automation, desktop automation, and external Agent CLI routing contracts.
304
- - Added resource governance and engineering standards governance for generated project packs.
305
-
306
- ### v0.11.1
307
-
308
- - Phase Commands FSM blocking: `canTransition` + `process.exit(1)` for guard failures
309
- - OWASP Top 10 Detector: 19 security detection patterns
310
- - Browser QA Capability: Playwright MCP wrapper for E2E testing
311
- - L6 Evolution: `Defect → Lesson → Rule → Hook` self-improve loop
312
- - Evolution CLI: `scale evolution extract/improve/report/hooks`
313
- - ReviewAnalyzer regex fix: avoid false positives on pattern definitions
314
- - Vitest suite covered in release verification
315
-
316
- ### v0.10.1
317
-
318
- - Hardened `ship` so release commits stage only files covered by passing review records.
319
- - Added `ship --no-commit` delivery reports for reviewable output without creating a Git commit.
320
- - Added optional strict TDD evidence verification with `--tdd-evidence` and `--tdd-strict`.
321
- - Added richer command evidence metadata: working directory, timestamps, stdout/stderr tails, and output hashes.
322
- - Hardened deterministic review scanning for empty `catch`, `@ts-ignore`, focused tests, dangerous shell/Git commands, and security-sensitive changes without G7 evidence.
323
- - Hardened built-in G7 security scanning with explainable file/line evidence and compatibility vs strict blocking modes.
324
- - Added CLI/unit regression tests for `review -> ship`, unreviewed-file blocking, and security-scanner false-positive boundaries.
325
- - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
326
-
327
- ### v0.10.0
328
-
329
- - Added phase-aligned workflow commands with FSM integration.
330
- - Added persisted verification evidence and review records.
331
- - Published `@hongmaple0820/scale-engine@0.10.0`.
332
- - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
333
-
334
- ## License
335
-
336
- MIT
45
+
46
+ AI coding becomes hard when agents must behave consistently across real teams and real repositories:
47
+
48
+ | Failure mode | SCALE mechanism |
49
+ | --- | --- |
50
+ | Agent says tests passed without running them | Verification profiles and evidence stores record actual commands and results |
51
+ | Agent skips discovery, design, TDD, or review | `scale context`, `scale diagnose`, `scale tdd`, and `scale status` produce required next actions |
52
+ | Agent stages unrelated files or edits the wrong repository | Review-gated shipping, MOE workspace rules, and child repository blockers control boundaries |
53
+ | Docs, screenshots, reports, scripts, and temporary files become unmaintainable | Resource governance classifies maintained assets, task evidence, temporary outputs, and forbidden commits |
54
+ | Noisy logs, secrets, ORM misuse, framework violations, or security risks slip through | Engineering standards and OWASP scans produce traceable findings |
55
+ | Long Markdown reports are not read | `scale artifact` renders traceable HTML reports from maintained Markdown sources |
56
+
57
+ ## See It In 3 Minutes
58
+
59
+ ```bash
60
+ npm install -g @hongmaple0820/scale-engine
61
+ mkdir scale-demo && cd scale-demo
62
+ scale init --governance-pack standard
63
+ scale preflight --preflight-profile quick
64
+ scale status
65
+ ```
66
+
67
+ This generates governance files you can commit to a project:
68
+
69
+ - `.scale/verification.json`: service matrix and verification profiles
70
+ - `.scale/skills.json`: skill routing and evidence requirements
71
+ - `.scale/tools.json`: CLI/MCP/browser/desktop orchestration policy
72
+ - `docs/workflow/templates/`: Mini-PRD, plan, verification, review, and summary templates
73
+ - `docs/standards/`: engineering, Git collaboration, and resource governance rules
74
+
75
+ Continue with a full workflow loop:
76
+
77
+ ```bash
78
+ scale context init --name "Scale Demo"
79
+ scale context grill --task-id 2026-05-18-oauth-hardening --task "Harden OAuth callback"
80
+ scale diagnose plan --task-id 2026-05-18-oauth-hardening --symptom "callback returns 500 when state expires"
81
+ scale tdd slice --task-id 2026-05-18-oauth-hardening --behavior "reject expired OAuth state" --public-interface "GET /oauth/callback" --failing-test "expired state returns 401" --test-file tests/oauth.test.ts --impl-files src/oauth.ts
82
+ scale artifact render --task-id 2026-05-18-oauth-hardening --artifact-dir .planning/tasks/2026-05-18-oauth-hardening
83
+ scale artifact doctor --artifact-dir .planning/tasks/2026-05-18-oauth-hardening
84
+ ```
85
+
86
+ Read [Quickstart](docs/start/quickstart.md) and [Agent Governance Demo](docs/start/agent-governance-demo.md) for the complete walkthrough.
87
+
88
+ ## Who It Is For
89
+
90
+ - Teams using Codex, Claude Code, Cursor, Gemini CLI, OpenCode, Aider, or similar agents on real projects.
91
+ - Teams with multi-service, multi-repository, MOE workspace, frontend/backend, or scaffold governance needs.
92
+ - Teams that want agents to actively use skills, MCPs, CLIs, browser automation, E2E checks, and HTML reports with safety boundaries.
93
+ - Project owners who feel AI code is fast but hard to review, verify, and maintain.
94
+
95
+ It is not optimized for toy projects that only want one minimal prompt file and do not need gates, collaboration rules, or long-term maintainability.
96
+
97
+ ## Core Capabilities
98
+
99
+ - Workflow Engine: `define -> plan -> build -> verify -> review -> ship` with persisted state.
100
+ - GateSystem: build, lint, test, coverage, security, TDD, review, and tool evidence gates.
101
+ - Governance Packs: `standard`, `project-scaffold`, `moe-workspace`, `resource-governance`, `go-service-matrix`, `node-library`, and `frontend-app`.
102
+ - Resource Governance: docs, media, reports, test scripts, temporary scripts, HTML artifacts, and local config lifecycle rules.
103
+ - Skill and Tool Orchestration: UI/UX, web research, browser E2E, Chrome DevTools MCP, desktop automation, and external agent CLIs.
104
+ - Engineering Standards: noisy logs, sensitive data, injection risks, ORM/database usage, framework boundaries, test rigor, and deployment risk.
105
+ - HTML Artifacts: Markdown remains the maintained source; HTML becomes the review, comparison, status, and release handoff layer.
106
+
107
+ ## Installation
108
+
109
+ ```bash
110
+ npm install -g @hongmaple0820/scale-engine
111
+ scale --version
112
+ ```
113
+
114
+ Node.js 20 or newer is required.
115
+
116
+ ## Governance Packs
117
+
118
+ Use `scale init` to install a governed workflow into an existing project:
119
+
120
+ ```bash
121
+ scale init --governance-pack standard
122
+ scale init --governance-pack project-scaffold
123
+ scale init --governance-pack moe-workspace
124
+ scale init --governance-pack resource-governance
125
+ scale init --governance-pack go-service-matrix
126
+ scale init --governance-pack node-library
127
+ scale init --governance-pack frontend-app
128
+ ```
129
+
130
+ Supported packs:
131
+
132
+ | Pack | Best fit |
133
+ | --- | --- |
134
+ | `standard` | General project governance with task artifacts, verification, metrics, resources, standards, and skills policy |
135
+ | `project-scaffold` | Reproducible engineering workflow scaffold and demo governance project |
136
+ | `moe-workspace` | Parent workspace with independent child repositories or MOE-style multi-repo development |
137
+ | `resource-governance` | Asset/document lifecycle policy for docs, reports, screenshots, scripts, media, and generated outputs |
138
+ | `go-service-matrix` | Go backend services with service-aware build/lint/test/security verification |
139
+ | `node-library` | Node/TypeScript package workflow, release, and verification governance |
140
+ | `frontend-app` | UI/UX, browser evidence, responsive checks, E2E, and visual review governance |
141
+
142
+ If you are unsure, start with `standard`. Use a specialized pack when the project shape is clear:
143
+
144
+ See [Getting Started](docs/start/README.md) for runnable tutorials and demo paths.
145
+
146
+ ## Workflow Upgrade
147
+
148
+ Do not rerun `scale init` as a blind upgrade command in existing projects. Use the guarded upgrade flow:
149
+
150
+ ```bash
151
+ scale upgrade check --dir . --lang en
152
+ scale upgrade plan --dir . --html --lang en
153
+ scale upgrade apply --dir . --confirm --lang en
154
+ scale upgrade rollback --dir . --lang en
155
+ ```
156
+
157
+ Chinese output is the default. Add `--lang en` for English prompts and English HTML plans.
158
+
159
+ Upgrade rules:
160
+
161
+ - Missing managed files can be restored automatically after plan review.
162
+ - Clean managed files whose content still matches `.scale/governance.lock.json` can be refreshed when a governance pack version changes.
163
+ - Locally edited managed files are marked `manual-review` and are not overwritten automatically.
164
+ - Third-party skills, MCP servers, desktop automation, browser tools, and external CLIs are check-only; SCALE reports source and trust policy but does not auto-install them.
165
+
166
+ See [Workflow Upgrade Guide](docs/start/workflow-upgrade.md) for the runnable path.
167
+
168
+ ## Phase Workflow
169
+
170
+ ```bash
171
+ scale define "Scoped release workflow" \
172
+ --description "Implement a TypeScript CLI workflow with verification evidence, review records, rollback constraints, and release safety checks." \
173
+ --success-criteria "verify evidence is persisted,review evidence is persisted,ship blocks unreviewed files"
174
+
175
+ scale plan <spec-id> --rollback "Revert the release commit and remove generated artifacts"
176
+ scale build <plan-id> --description "Implement scoped release workflow"
177
+ scale verify <task-id>
178
+ scale review <task-id>
179
+ scale ship <task-id> --message "feat(workflow): add scoped release workflow"
180
+ ```
181
+
182
+ Use `scale ship <task-id> --no-commit` to generate the delivery report without creating a Git commit.
183
+
184
+ Strict TDD evidence can be enforced when needed:
185
+
186
+ ```bash
187
+ scale verify <task-id> --tdd-strict --tdd-evidence .scale/tdd/<task-id>.json
188
+ ```
189
+
190
+ The TDD evidence JSON must include `red`, `green`, `refactor`, and `testFirst` set to `true`.
191
+
192
+ ## Evolution Self-Improve Loop
193
+
194
+ Extract lessons from session defects and promote to rules and hooks:
195
+
196
+ ```bash
197
+ # Extract Lessons from session
198
+ scale evolution extract <session-id>
199
+
200
+ # Run self-improve loop: Defect Lesson Rule Hook
201
+ scale evolution improve <session-id>
202
+
203
+ # Show self-improve report
204
+ scale evolution report <session-id>
205
+
206
+ # View generated Hooks config
207
+ scale evolution hooks <session-id> --json
208
+ ```
209
+
210
+ Thresholds:
211
+ - Lesson Rule: requires 3 verifications
212
+ - Rule → Active: requires 10 hits
213
+ - Rule → Hook: requires 20 hits
214
+
215
+ ## Safety Model
216
+
217
+ SCALE Engine uses multiple enforcement layers:
218
+
219
+ | Layer | Purpose |
220
+ | --- | --- |
221
+ | FSM | Prevents invalid artifact lifecycle transitions |
222
+ | GateSystem | Runs build, lint, test, coverage, and security gates |
223
+ | EvidenceStore | Persists verification evidence for audit and release gating |
224
+ | ReviewStore | Persists deterministic review records |
225
+ | ReviewAnalyzer | Scans diffs for high-risk code, process debt, and missing security evidence |
226
+ | Detectors | Detects brute retry, premature completion, blame shifting, busy loops, and related failure modes |
227
+ | Ship gate | Requires passing verification and review evidence before release |
228
+
229
+ 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.
230
+
231
+ Git branch governance follows a GitLab Flow variant: short branches merge into `dev`, verified releases land on `master`, and production publishing is triggered by user-created `vX.Y.Z` tags on `master`. `scale ship` blocks direct governed commits on `dev`, `master`, `main`, or detached HEAD, and temporary worktree cleanup is blocked when the branch still has unpushed or unmerged commits. See [docs/GITLAB_FLOW.md](docs/GITLAB_FLOW.md).
232
+
233
+ 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.
234
+
235
+ ## Skill and Tool Governance
236
+
237
+ Skill Radar recommends skills, MCP servers, browser automation, desktop automation, planning workflows, memory providers, and external CLIs by task intent. It returns confidence, safety level, evidence requirements, attribution metadata, and fallback behavior.
238
+
239
+ Third-party skills stay review-required until source, scripts, license, attribution, and pinned revision are checked. `OthmanAdi/planning-with-files` (MIT), `rohitg00/agentmemory` (Apache-2.0), and `garrytan/gbrain` (MIT) have explicit attribution records; other external skills, MCP servers, CLIs, adapters, and discovery candidates are tracked in the [External Reference Inventory](docs/EXTERNAL_REFERENCES.md) with unknown licenses kept `review-required`. SCALE records them as governed references, optional integrations, or adapted concepts; it does not vendor upstream source code.
240
+
241
+ Memory is provider-routed rather than expanded as a built-in Memory OS. Agents can use `scale memory provider status` and `scale memory provider recall` to select `agentmemory`, `gbrain`, or `scale-local` under policy; external providers are read-only by default and fall back to local evidence-backed memory.
242
+
243
+ See [Skill Radar](docs/SKILL_RADAR.md), [Third-Party Skills](docs/THIRD_PARTY_SKILLS.md), and [External Reference Inventory](docs/EXTERNAL_REFERENCES.md).
244
+
245
+ ## Supported Platforms
246
+
247
+ SCALE Engine includes adapters for 22 agent platforms, including Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, OpenClaw, Hermes, Trae, WorkBuddy, VS Code Copilot CLI, QCoder, Qoder, JCode, DeepSeek-TUI, Aider, Windsurf, Kiro, Cline, Kilo Code, Antigravity, Kimi, and Doubao.
248
+
249
+ It also includes 12 professional agent profiles:
250
+
251
+ - frontend
252
+ - backend
253
+ - testing
254
+ - UI design
255
+ - operations
256
+ - product
257
+ - code review
258
+ - security
259
+ - database
260
+ - performance
261
+ - documentation
262
+ - architecture
263
+
264
+ ## Project Layout
265
+
266
+ ```text
267
+ src/api/cli.ts CLI entrypoint
268
+ src/cli/phaseCommands.ts DEFINE/PLAN/BUILD/VERIFY/REVIEW/SHIP
269
+ src/cli/evolutionCommands.ts L6 Evolution CLI commands
270
+ src/workflow/gates/ Quality gates and persisted evidence
271
+ src/workflow/ReviewAnalyzer.ts Deterministic review analysis
272
+ src/workflow/ReviewStore.ts Review record persistence
273
+ src/workflow/EvidenceStore.ts Gate evidence persistence
274
+ src/workflow/evolution/ LessonExtractor + SelfImproveEngine
275
+ src/workflow/qa/ BrowserQA + E2ETestRunner
276
+ src/artifact/ Artifact store and FSM definitions
277
+ src/guardrails/ Detector and gateway logic
278
+ src/guardrails/OWASPDetector.ts OWASP Top 10 security detection
279
+ src/capabilities/BrowserQACapability.ts Playwright MCP wrapper
280
+ src/evolution/ Defect/Lesson/Rule/Hook evolution layer
281
+ tests/ Vitest test suites
282
+ ```
283
+
284
+ ## Development
285
+
286
+ ```bash
287
+ npm install
288
+ npm run build
289
+ npx vitest run
290
+ npm pack --dry-run
291
+ ```
292
+
293
+ Targeted workflow tests:
294
+
295
+ ```bash
296
+ npx vitest run tests/workflow/phaseCli.test.ts
297
+ npx vitest run tests/workflow/reviewAnalyzer.test.ts tests/workflow/reviewStore.test.ts tests/workflow/gateSystem.test.ts
298
+ ```
299
+
300
+ ## Release Notes
301
+
302
+ ### v0.20.0
303
+
304
+ - Added Context Budget and Progressive Governance so low-risk S tasks stay lightweight while auth, data, security, deployment, and cross-module changes escalate automatically.
305
+ - Added Code Intelligence with adapter-first CodeGraph / Graphify support, explicit fallback, impact analysis, context recommendations, and exploration ROI.
306
+ - Added Workflow Eval, Failure Replay, and improvement candidates with pass@k, fix iterations, tool-call counts, token estimates, and human-correction metrics.
307
+ - Added Skill Radar for intent-based skills, MCP, browser, desktop automation, and external CLI recommendations with confidence, safety level, and evidence requirements.
308
+ - Added Memory Brain for evidence-backed long-term memory candidates, contradiction detection, dream maintenance, explicit promotion, and failure replay ingestion.
309
+ - Added Governance Dashboard to summarize runtime, eval, memory, resource, and HTML artifact evidence in a local HTML review surface.
310
+ - Fixed new `--dir` aware commands so relative `.scale` state resolves inside the target project instead of the caller workspace.
311
+
312
+ ### v0.19.0
313
+
314
+ - Added product smoke gates, runtime evidence learning settlement, memory context packs, workspace conflict blockers, and release-readiness demo coverage.
315
+
316
+ ### v0.18.0
317
+
318
+ - Governed HTML artifacts: `scale artifact render/doctor/settle/open`.
319
+ - Markdown remains the editable source of truth; generated HTML is traceable task evidence.
320
+ - Governance packs now include output policy and HTML artifact resource classification.
321
+ - Added tests for HTML artifact rendering, safety checks, settlement evidence, and generated template output.
322
+
323
+ ### v0.17.0
324
+
325
+ - Added active workflow command gates: `scale context`, `scale diagnose`, `scale tdd`, and `scale status`.
326
+ - Added required next-action queues so agents cannot silently skip context, debugging, TDD, or verification work.
327
+
328
+ ### v0.16.0
329
+
330
+ - Added governed skill repository, skill recommendation, install-safety checks, visual Vibe templates, and leadership presets.
331
+ - Strengthened tool orchestration and resource/engineering standards governance.
332
+
333
+ ### v0.15.1
334
+
335
+ - Added UI/UX, web research, browser automation, desktop automation, and external Agent CLI routing contracts.
336
+ - Added resource governance and engineering standards governance for generated project packs.
337
+
338
+ ### v0.11.1
339
+
340
+ - Phase Commands FSM blocking: `canTransition` + `process.exit(1)` for guard failures
341
+ - OWASP Top 10 Detector: 19 security detection patterns
342
+ - Browser QA Capability: Playwright MCP wrapper for E2E testing
343
+ - L6 Evolution: `Defect → Lesson → Rule → Hook` self-improve loop
344
+ - Evolution CLI: `scale evolution extract/improve/report/hooks`
345
+ - ReviewAnalyzer regex fix: avoid false positives on pattern definitions
346
+ - Vitest suite covered in release verification
347
+
348
+ ### v0.10.1
349
+
350
+ - Hardened `ship` so release commits stage only files covered by passing review records.
351
+ - Added `ship --no-commit` delivery reports for reviewable output without creating a Git commit.
352
+ - Added optional strict TDD evidence verification with `--tdd-evidence` and `--tdd-strict`.
353
+ - Added richer command evidence metadata: working directory, timestamps, stdout/stderr tails, and output hashes.
354
+ - Hardened deterministic review scanning for empty `catch`, `@ts-ignore`, focused tests, dangerous shell/Git commands, and security-sensitive changes without G7 evidence.
355
+ - Hardened built-in G7 security scanning with explainable file/line evidence and compatibility vs strict blocking modes.
356
+ - Added CLI/unit regression tests for `review -> ship`, unreviewed-file blocking, and security-scanner false-positive boundaries.
357
+ - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
358
+
359
+ ### v0.10.0
360
+
361
+ - Added phase-aligned workflow commands with FSM integration.
362
+ - Added persisted verification evidence and review records.
363
+ - Published `@hongmaple0820/scale-engine@0.10.0`.
364
+ - Verified `npm run build`, full Vitest suite, and `npm pack --dry-run` before release.
365
+
366
+ ## License
367
+
368
+ MIT