@hongmaple0820/scale-engine 0.21.1 → 0.23.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.en.md +39 -13
- package/README.md +61 -31
- package/dist/api/cli.js +291 -4
- package/dist/api/cli.js.map +1 -1
- package/dist/api/doctor.d.ts +1 -0
- package/dist/api/doctor.js +83 -0
- package/dist/api/doctor.js.map +1 -1
- package/dist/artifact/types.d.ts +1 -1
- package/dist/artifact/types.js.map +1 -1
- package/dist/cli/phaseCommands.js +25 -6
- package/dist/cli/phaseCommands.js.map +1 -1
- package/dist/cli/runCommand.d.ts +39 -0
- package/dist/cli/runCommand.js +113 -0
- package/dist/cli/runCommand.js.map +1 -0
- package/dist/config/profiles.d.ts +52 -0
- package/dist/config/profiles.js +162 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/context/ContextBudget.d.ts +25 -1
- package/dist/context/ContextBudget.js +72 -7
- package/dist/context/ContextBudget.js.map +1 -1
- package/dist/context/ProjectAnatomy.d.ts +18 -0
- package/dist/context/ProjectAnatomy.js +287 -0
- package/dist/context/ProjectAnatomy.js.map +1 -0
- package/dist/dashboard/DashboardServer.d.ts +3 -0
- package/dist/dashboard/DashboardServer.js +114 -0
- package/dist/dashboard/DashboardServer.js.map +1 -1
- package/dist/hooks/BugPatternDetector.d.ts +36 -0
- package/dist/hooks/BugPatternDetector.js +207 -0
- package/dist/hooks/BugPatternDetector.js.map +1 -0
- package/dist/hooks/HookGeneratorEnhanced.js +301 -5
- package/dist/hooks/HookGeneratorEnhanced.js.map +1 -1
- package/dist/hooks/WorkflowHooksManager.js +24 -0
- package/dist/hooks/WorkflowHooksManager.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge/CerebrumManager.d.ts +25 -0
- package/dist/knowledge/CerebrumManager.js +127 -0
- package/dist/knowledge/CerebrumManager.js.map +1 -0
- package/dist/knowledge/SQLiteKnowledgeBase.d.ts +1 -0
- package/dist/knowledge/SQLiteKnowledgeBase.js +31 -3
- package/dist/knowledge/SQLiteKnowledgeBase.js.map +1 -1
- package/dist/knowledge/TfidfIndex.d.ts +50 -0
- package/dist/knowledge/TfidfIndex.js +177 -0
- package/dist/knowledge/TfidfIndex.js.map +1 -0
- package/dist/skills/SkillDiscovery.js +1 -1
- package/dist/skills/SkillDiscovery.js.map +1 -1
- package/dist/tools/CommandOutputCompressor.d.ts +28 -0
- package/dist/tools/CommandOutputCompressor.js +242 -0
- package/dist/tools/CommandOutputCompressor.js.map +1 -0
- package/dist/tools/CommandRunLedger.d.ts +77 -0
- package/dist/tools/CommandRunLedger.js +111 -0
- package/dist/tools/CommandRunLedger.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/workflow/EngineeringStandards.js +91 -2
- package/dist/workflow/EngineeringStandards.js.map +1 -1
- package/dist/workflow/GovernanceTemplatePacks.js +2 -2
- package/dist/workflow/GovernanceTemplates.js +90 -89
- package/dist/workflow/GovernanceTemplates.js.map +1 -1
- package/dist/workflow/TaskLevelDetector.d.ts +41 -0
- package/dist/workflow/TaskLevelDetector.js +219 -0
- package/dist/workflow/TaskLevelDetector.js.map +1 -0
- package/dist/workflow/WorkflowOrchestrator.d.ts +59 -0
- package/dist/workflow/WorkflowOrchestrator.js +326 -0
- package/dist/workflow/WorkflowOrchestrator.js.map +1 -0
- package/dist/workflow/WorkspaceLifecycle.d.ts +19 -1
- package/dist/workflow/WorkspaceLifecycle.js +119 -3
- package/dist/workflow/WorkspaceLifecycle.js.map +1 -1
- package/dist/workflow/WorkspaceTopology.d.ts +6 -0
- package/dist/workflow/WorkspaceTopology.js +17 -6
- package/dist/workflow/WorkspaceTopology.js.map +1 -1
- package/dist/workflow/gates/GateSystem.d.ts +23 -6
- package/dist/workflow/gates/GateSystem.js +114 -25
- package/dist/workflow/gates/GateSystem.js.map +1 -1
- package/dist/workflow/gates/MetaGovernanceGates.d.ts +70 -0
- package/dist/workflow/gates/MetaGovernanceGates.js +617 -0
- package/dist/workflow/gates/MetaGovernanceGates.js.map +1 -0
- package/dist/workflow/types.d.ts +6 -1
- package/docs/GITLAB_FLOW.md +125 -0
- package/docs/README.md +3 -0
- package/docs/start/README.md +29 -3
- package/docs/start/artifact-lifecycle.md +326 -0
- package/docs/start/workflow-upgrade.md +150 -0
- package/image/wechat-public.jpg +0 -0
- package/image/wxPay.jpg +0 -0
- package/image/zfb.jpg +0 -0
- package/package.json +10 -8
package/dist/workflow/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type GateStage = 'G0' | 'G1' | 'G2' | 'G3' | 'G4' | 'G5' | 'G6' | 'G7' | 'G8';
|
|
1
|
+
export type GateStage = 'G0' | 'G1' | 'G2' | 'G3' | 'G4' | 'G5' | 'G6' | 'G7' | 'G8' | 'G9' | 'G10' | 'G11' | 'G12' | 'G13' | 'G14' | 'G15';
|
|
2
2
|
export type GateStatus = 'PENDING' | 'PASSED' | 'FAILED' | 'BLOCKED';
|
|
3
3
|
export type ModelTier = 'LOW' | 'MEDIUM' | 'HIGH';
|
|
4
4
|
export type Verdict = 'APPROVE' | 'ITERATE' | 'REJECT';
|
|
@@ -18,6 +18,11 @@ export interface GateEvidence {
|
|
|
18
18
|
stdoutTail?: string;
|
|
19
19
|
stderrTail?: string;
|
|
20
20
|
outputHash?: string;
|
|
21
|
+
rawEstimatedTokens?: number;
|
|
22
|
+
compressedEstimatedTokens?: number;
|
|
23
|
+
savedEstimatedTokens?: number;
|
|
24
|
+
compressionRatio?: number;
|
|
25
|
+
commandRunEvidenceId?: string;
|
|
21
26
|
source?: string;
|
|
22
27
|
}
|
|
23
28
|
export interface GateResult {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# GitLab Flow Branch and Worktree Policy
|
|
2
|
+
|
|
3
|
+
SCALE Engine uses a GitLab Flow variant for this repository:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
feat/* / fix/* / chore/* / docs/* / codex/*
|
|
7
|
+
-> dev
|
|
8
|
+
-> master
|
|
9
|
+
-> vX.Y.Z tag
|
|
10
|
+
-> npm publish
|
|
11
|
+
|
|
12
|
+
hotfix:
|
|
13
|
+
fix forward on dev first when possible
|
|
14
|
+
-> cherry-pick to hotfix/*
|
|
15
|
+
-> master
|
|
16
|
+
-> vX.Y.Z tag
|
|
17
|
+
-> sync master back to dev
|
|
18
|
+
|
|
19
|
+
selective release, only when dev contains work that must not ship:
|
|
20
|
+
master
|
|
21
|
+
-> release/vX.Y.Z
|
|
22
|
+
-> cherry-pick selected commits
|
|
23
|
+
-> master
|
|
24
|
+
-> vX.Y.Z tag
|
|
25
|
+
-> sync master back to dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Branch Roles
|
|
29
|
+
|
|
30
|
+
| Branch | Role | Rule |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `dev` | Integration and test branch | Merge reviewed short branches here. Do not create direct governed commits on `dev`. |
|
|
33
|
+
| `master` | Production branch | Only verified release/hotfix results land here. Publish from user-created `vX.Y.Z` tags on `master`. |
|
|
34
|
+
| `feat/*`, `feature/*` | Feature branches | Start from current `dev`, merge back to `dev`, then delete. |
|
|
35
|
+
| `fix/*` | Normal bug fix branches | Start from current `dev`, merge back to `dev`, then delete. |
|
|
36
|
+
| `chore/*`, `docs/*`, `codex/*` | Maintenance branches | Short-lived work branches that merge back to `dev`. |
|
|
37
|
+
| `hotfix/*` | Production patch branches | Use only for production fixes. Fix forward to `dev` first when possible, then cherry-pick to hotfix/master. |
|
|
38
|
+
| `release/*` | Selective release branch | Use only when `dev` contains work that must not ship. Start from `master` and cherry-pick the release list. |
|
|
39
|
+
|
|
40
|
+
## Required Checks
|
|
41
|
+
|
|
42
|
+
Run the release-grade verification set before merging to `master` or tagging:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run build
|
|
46
|
+
npx vitest run
|
|
47
|
+
git diff --check
|
|
48
|
+
npm pack --dry-run
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Every merge request should run the relevant build/lint/test checks before review is accepted. Do not wait until `master` to discover broken tests.
|
|
52
|
+
|
|
53
|
+
## Merge and Conflict Rules
|
|
54
|
+
|
|
55
|
+
- Public branches are not rebased: `dev`, `master`, `release/*`, and `hotfix/*` keep realistic history.
|
|
56
|
+
- Personal short branches may be rebased before merge, but only with `--force-with-lease` and only before review is accepted.
|
|
57
|
+
- Prefer squash merge from short branches into `dev` when one logical change should be easy to revert.
|
|
58
|
+
- Resolve conflicts on the source branch, rerun verification, then merge. Do not resolve release conflicts directly on `master`.
|
|
59
|
+
- Fix bugs forward first: land the fix on `dev` when possible, then cherry-pick the same commit to `hotfix/*` or the selected patch release branch.
|
|
60
|
+
- Commit messages should explain intent and why the chosen path was selected when the decision is not obvious.
|
|
61
|
+
|
|
62
|
+
## Ship Gate Rules
|
|
63
|
+
|
|
64
|
+
`scale ship <task-id>` now enforces the branch lifecycle:
|
|
65
|
+
|
|
66
|
+
- blocked on `dev`, `master`, `main`, and detached HEAD
|
|
67
|
+
- allowed on configured short branches such as `feat/*`, `fix/*`, `chore/*`, `docs/*`, `codex/*`, `release/*`, and `hotfix/*`
|
|
68
|
+
- still requires verification evidence, passing review evidence, and reviewed-file-only staging
|
|
69
|
+
- still blocks dirty or unsafe child repositories in MOE/submodule workspaces
|
|
70
|
+
|
|
71
|
+
Use:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
scale workspace status --summary
|
|
75
|
+
scale workspace finish --summary
|
|
76
|
+
scale workspace finish --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The report includes branch role, whether governed shipping is allowed, and cleanup blockers.
|
|
80
|
+
|
|
81
|
+
## Worktree Lifecycle
|
|
82
|
+
|
|
83
|
+
Temporary agent worktrees are safe to remove only when all of these are true:
|
|
84
|
+
|
|
85
|
+
- root worktree is clean
|
|
86
|
+
- child repositories are clean and pushed when required
|
|
87
|
+
- the temporary branch has no unpushed commits
|
|
88
|
+
- a branch with no upstream is already merged into `dev`/`master`, or it contains no unique work
|
|
89
|
+
|
|
90
|
+
Cleanup remains dry-run by default:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
scale workspace cleanup --dir <temporary-worktree> --dry-run --json
|
|
94
|
+
scale workspace cleanup --dir <temporary-worktree> --apply --confirm <branch-or-head> --json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If cleanup is blocked, push the branch, merge it, cherry-pick it into the selected release, or explicitly discard it before removing the worktree.
|
|
98
|
+
|
|
99
|
+
## Repository Bootstrap
|
|
100
|
+
|
|
101
|
+
This repository currently treats `dev` as the integration branch and `master` as production. If `dev` falls behind `master` and has no unique commits, fast-forward `dev` to `master` before starting new feature work:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
git fetch --all --prune
|
|
105
|
+
git switch dev
|
|
106
|
+
git merge --ff-only master
|
|
107
|
+
git push origin dev
|
|
108
|
+
git push github dev
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
After that, normal work should start from `dev`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git switch dev
|
|
115
|
+
git pull --ff-only origin dev
|
|
116
|
+
git switch -c feat/<short-name>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Before creating a normal release from `dev`, inspect the release delta:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git log --oneline master..dev
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
If every listed commit is intended for the next production release, merge `dev` through the normal release path. If any commit must be excluded, create `release/vX.Y.Z` from `master` and cherry-pick only the approved release list.
|
package/docs/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
| [start/README.md](start/README.md) | 入门路径总览 |
|
|
10
10
|
| [start/quickstart.md](start/quickstart.md) | 3 分钟快速开始 |
|
|
11
11
|
| [start/agent-governance-demo.md](start/agent-governance-demo.md) | 官方 demo walkthrough |
|
|
12
|
+
| [start/artifact-lifecycle.md](start/artifact-lifecycle.md) | Artifact 生命周期完整 walkthrough |
|
|
12
13
|
| [../README.md](../README.md) | 项目主页和能力总览 |
|
|
13
14
|
|
|
14
15
|
## 当前治理能力
|
|
@@ -28,6 +29,8 @@
|
|
|
28
29
|
| [UPGRADE_MANAGEMENT.md](UPGRADE_MANAGEMENT.md) | SCALE CLI、governance pack、skills、MCP 和 CLI 工具的安全升级流程 |
|
|
29
30
|
| [GOVERNANCE_DASHBOARD.md](GOVERNANCE_DASHBOARD.md) | Runtime、eval、memory、resource、HTML artifact 的统一治理面板 |
|
|
30
31
|
| [RELEASE_READINESS.md](RELEASE_READINESS.md) | 发版前质量门槛、官方 demo 和真实项目落地验收 |
|
|
32
|
+
| [DOCUMENT_STANDARDS.md](DOCUMENT_STANDARDS.md) | 文档编写与维护规范 |
|
|
33
|
+
| [GITLAB_FLOW.md](GITLAB_FLOW.md) | GitLab Flow 分支、发版、tag 和临时 worktree 生命周期规范 |
|
|
31
34
|
| [SKILL-REPOSITORY.md](SKILL-REPOSITORY.md) | 受治理 skill repository 和安装安全策略 |
|
|
32
35
|
| [VIBE-TEMPLATES.md](VIBE-TEMPLATES.md) | 可复制的 Vibe Coding 提示词模板 |
|
|
33
36
|
| [LEADERSHIP-PRESETS.md](LEADERSHIP-PRESETS.md) | CEO、CTO、PM、Architect 等内置领导者角色预设 |
|
package/docs/start/README.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# SCALE Engine 入门路径
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这个目录面向新用户。目标是先跑通一条最小路径,再理解完整体系,不要求一开始掌握所有命令。
|
|
4
4
|
|
|
5
5
|
## 推荐阅读顺序
|
|
6
6
|
|
|
7
7
|
1. [3 分钟快速开始](quickstart.md)
|
|
8
8
|
从空目录初始化治理工作流,看到 `.scale`、模板、验证 profile 和状态输出。
|
|
9
9
|
|
|
10
|
-
2. [
|
|
10
|
+
2. [Artifact 生命周期](artifact-lifecycle.md)
|
|
11
|
+
完整走一遍 Need → Spec → Plan → Task → Change → Evidence → Release,理解 FSM 和 Guard 如何用物理约束替代提示词建议。
|
|
12
|
+
|
|
13
|
+
3. [官方 Demo Walkthrough](agent-governance-demo.md)
|
|
11
14
|
用一个 OAuth state 加固任务演示:上下文对齐、诊断计划、TDD 切片、HTML artifact、资源治理和工程规范扫描。
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
4. 回到根目录 [README](../../README.md)
|
|
14
17
|
理解 SCALE Engine 的核心能力和 governance pack 选择。
|
|
15
18
|
|
|
16
19
|
4. [升级管理](../UPGRADE_MANAGEMENT.md)
|
|
@@ -19,6 +22,25 @@
|
|
|
19
22
|
5. 查看 [文档地图](../README.md)
|
|
20
23
|
区分哪些文档是用户指南、哪些是参考资料、哪些是历史规划和过程记录。
|
|
21
24
|
|
|
25
|
+
## 15 分钟学习路径
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @hongmaple0820/scale-engine
|
|
29
|
+
scale --version
|
|
30
|
+
mkdir scale-demo && cd scale-demo
|
|
31
|
+
scale init --governance-pack standard
|
|
32
|
+
scale preflight --preflight-profile quick
|
|
33
|
+
scale status
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
跑完后先回答三个问题:
|
|
37
|
+
|
|
38
|
+
- `.scale/verification.json` 里定义了哪些验证 profile?
|
|
39
|
+
- `docs/workflow/templates/` 里有哪些任务产物模板?
|
|
40
|
+
- `scale status` 建议下一步做什么?
|
|
41
|
+
|
|
42
|
+
如果这三个问题答不上来,先不要继续看高级命令。
|
|
43
|
+
|
|
22
44
|
## 你应该先看到什么
|
|
23
45
|
|
|
24
46
|
跑完 quickstart 后,至少应该能看到:
|
|
@@ -44,3 +66,7 @@
|
|
|
44
66
|
| 文档、报告、截图、脚本混乱 | `scale init --governance-pack resource-governance` |
|
|
45
67
|
| 工作流或第三方能力要升级 | `scale upgrade check && scale upgrade plan --html` |
|
|
46
68
|
|
|
69
|
+
|
|
70
|
+
## 工作流升级短路径
|
|
71
|
+
|
|
72
|
+
已有项目先看 [SCALE workflow upgrade guide](workflow-upgrade.md)。它说明 `scale init --interactive`、`scale upgrade check/plan/apply/rollback`、仓库本地 `make workflow-upgrade-*` 入口,以及生成文件更新和项目级验证之间的边界。
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Version: 1.0
|
|
3
|
+
Last Updated: 2026-05-19
|
|
4
|
+
Scope: Tutorial — Artifact lifecycle from Need to Release
|
|
5
|
+
Maintainer: SCALE Engine Team
|
|
6
|
+
-->
|
|
7
|
+
# Artifact Lifecycle Walkthrough
|
|
8
|
+
|
|
9
|
+
This tutorial walks through a **complete Artifact lifecycle**: Need → Spec → Plan → Task → Change → Evidence → Release. It demonstrates how SCALE's FSM, Gates, and Guardrails work together to enforce quality through physical constraints.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- SCALE Engine installed (`npm install -g @hongmaple0820/scale-engine`)
|
|
14
|
+
- Node.js 20+
|
|
15
|
+
- A project directory initialized with `scale init`
|
|
16
|
+
|
|
17
|
+
## The Scenario
|
|
18
|
+
|
|
19
|
+
You have a simple calculator library. The user requests: **"Add a multiply function"**. We'll trace this request through the entire SCALE lifecycle.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Step 1: Create a Need
|
|
24
|
+
|
|
25
|
+
Every request starts as a **Need** — the raw user intent.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
scale create need "Add multiply function to calculator"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Output:
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"id": "ART-need-20260519-0001",
|
|
35
|
+
"type": "Need",
|
|
36
|
+
"status": "DRAFT",
|
|
37
|
+
"title": "Add multiply function to calculator"
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The Need starts in `DRAFT` state. It's fuzzy — no success criteria, no scope boundaries.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
scale transition ART-need-20260519-0001 clarify \
|
|
45
|
+
--reason "Added success criteria and scope"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**FSM Path:** `DRAFT → CLARIFIED`
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Step 2: Create a Spec from the Need
|
|
53
|
+
|
|
54
|
+
A **Spec** is the requirements contract — WHAT to build, not HOW.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
scale create spec "Multiply function spec" \
|
|
58
|
+
--from ART-need-20260519-0001 \
|
|
59
|
+
--payload '{
|
|
60
|
+
"what": "Add multiply(a, b) function that returns the product of two numbers",
|
|
61
|
+
"successCriteria": [
|
|
62
|
+
"multiply(2, 3) returns 6",
|
|
63
|
+
"multiply(-1, 5) returns -5",
|
|
64
|
+
"multiply(0, 100) returns 0",
|
|
65
|
+
"multiply(2.5, 4) returns 10"
|
|
66
|
+
],
|
|
67
|
+
"outOfScope": ["Division", "Modulo", "Complex numbers"],
|
|
68
|
+
"edgeCases": ["Overflow", "NaN inputs", "Infinity"],
|
|
69
|
+
"northStar": "Reliable basic arithmetic operations"
|
|
70
|
+
}'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Output:
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"id": "ART-spec-20260519-0002",
|
|
77
|
+
"type": "Spec",
|
|
78
|
+
"status": "DRAFT",
|
|
79
|
+
"parents": ["ART-need-20260519-0001"]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Spec State Machine
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
┌──── reject ────┐
|
|
87
|
+
▼ │
|
|
88
|
+
DRAFT ──refine──▶ REVIEWING ──approve──▶ FROZEN
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The Spec must be **FROZEN** before downstream artifacts (Plan, Task) can be created. This prevents building on unstable requirements.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Move to review
|
|
95
|
+
scale transition ART-spec-20260519-0002 review --reason "Ready for review"
|
|
96
|
+
|
|
97
|
+
# Approve and freeze
|
|
98
|
+
scale transition ART-spec-20260519-0002 approve --reason "Requirements clear, scope defined"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**FSM Path:** `DRAFT → REVIEWING → FROZEN`
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Step 3: Create a Plan
|
|
106
|
+
|
|
107
|
+
A **Plan** is the technical approach — HOW to build it.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
scale create plan "Multiply implementation plan" \
|
|
111
|
+
--from ART-spec-20260519-0002 \
|
|
112
|
+
--payload '{
|
|
113
|
+
"approach": "Add multiply function to existing calculator module",
|
|
114
|
+
"techChoices": [
|
|
115
|
+
{
|
|
116
|
+
"decision": "Simple function, not a class method",
|
|
117
|
+
"rationale": "Consistent with existing add/subtract pattern",
|
|
118
|
+
"alternatives": ["Class method", "Operator overloading"]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"modules": [
|
|
122
|
+
{"path": "src/calculator.ts", "action": "modify", "reason": "Add multiply export"},
|
|
123
|
+
{"path": "tests/calculator.test.ts", "action": "modify", "reason": "Add multiply tests"}
|
|
124
|
+
],
|
|
125
|
+
"rollbackStrategy": "Revert git commit",
|
|
126
|
+
"estimatedComplexity": 0.2
|
|
127
|
+
}'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
scale transition ART-plan-20260519-0003 approve --reason "Plan is straightforward"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**FSM Path:** `DRAFT → APPROVED`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Step 4: Create and Execute a Task
|
|
139
|
+
|
|
140
|
+
A **Task** is the atomic execution unit.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
scale create task "Implement multiply function" \
|
|
144
|
+
--from ART-plan-20260519-0003 \
|
|
145
|
+
--payload '{
|
|
146
|
+
"description": "Write multiply function and tests",
|
|
147
|
+
"filesInvolved": ["src/calculator.ts", "tests/calculator.test.ts"],
|
|
148
|
+
"requiredRole": "implementer",
|
|
149
|
+
"requiredCapabilities": ["can_modify_code", "can_run_tests"]
|
|
150
|
+
}'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Task State Machine with Guards
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
PENDING ──schedule──▶ READY ──start──▶ RUNNING ──complete──▶ COMPLETED
|
|
157
|
+
│
|
|
158
|
+
└── BLOCKED by Guards
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The Task has **physical guards** that prevent false completion:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Schedule and start
|
|
165
|
+
scale transition ART-task-20260519-0004 schedule --reason "Ready"
|
|
166
|
+
scale transition ART-task-20260519-0004 start --reason "Starting implementation"
|
|
167
|
+
|
|
168
|
+
# Agent writes code (simulated)
|
|
169
|
+
# ... src/calculator.ts modified ...
|
|
170
|
+
|
|
171
|
+
# Agent tries to complete WITHOUT verification
|
|
172
|
+
scale transition ART-task-20260519-0004 complete --reason "Done"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Output (BLOCKED):**
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"success": false,
|
|
179
|
+
"blockedBy": [
|
|
180
|
+
{
|
|
181
|
+
"guard": "build_passed",
|
|
182
|
+
"message": "Task must pass build verification before completion. Run: scale verify-task <id>"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"guard": "lint_passed",
|
|
186
|
+
"message": "Task must pass lint before completion. Run: scale verify-task <id>"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"guard": "tests_passed",
|
|
190
|
+
"message": "Task must pass tests before completion. Run: scale verify-task <id>"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**The transition is physically blocked.** The agent cannot claim completion without running verification.
|
|
197
|
+
|
|
198
|
+
### Run Verification
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
scale verifyTask ART-task-20260519-0004
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Output:
|
|
205
|
+
```
|
|
206
|
+
Running build...
|
|
207
|
+
Build passed
|
|
208
|
+
|
|
209
|
+
Running lint...
|
|
210
|
+
Lint passed
|
|
211
|
+
|
|
212
|
+
Running tests...
|
|
213
|
+
Tests passed
|
|
214
|
+
|
|
215
|
+
Verification results:
|
|
216
|
+
Build: success (exit code: 0)
|
|
217
|
+
Lint: success
|
|
218
|
+
Tests: passed
|
|
219
|
+
|
|
220
|
+
All checks passed! Task can now be completed.
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Now the transition succeeds:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
scale transition ART-task-20260519-0004 complete --reason "Verified and all checks passed"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**FSM Path:** `PENDING → READY → RUNNING → COMPLETED`
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Step 5: Record the Change
|
|
234
|
+
|
|
235
|
+
A **Change** tracks the actual code modification (git commit/PR).
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
scale create change "Multiply function implementation" \
|
|
239
|
+
--from ART-task-20260519-0004 \
|
|
240
|
+
--payload '{
|
|
241
|
+
"commitSha": "abc123",
|
|
242
|
+
"filesChanged": [
|
|
243
|
+
{"path": "src/calculator.ts", "additions": 8, "deletions": 0},
|
|
244
|
+
{"path": "tests/calculator.test.ts", "additions": 20, "deletions": 0}
|
|
245
|
+
],
|
|
246
|
+
"diffSummary": "Added multiply function with type safety and edge case handling"
|
|
247
|
+
}'
|
|
248
|
+
|
|
249
|
+
scale transition ART-change-20260519-0005 commit --reason "Committed"
|
|
250
|
+
scale transition ART-change-20260519-0005 verify --reason "Tests pass"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**FSM Path:** `DRAFT → COMMITTED → VERIFIED`
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Step 6: Record Evidence
|
|
258
|
+
|
|
259
|
+
An **Evidence** artifact captures verification results.
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
scale create evidence "Multiply function test results" \
|
|
263
|
+
--from ART-change-20260519-0005 \
|
|
264
|
+
--payload '{
|
|
265
|
+
"testPlanId": "ART-testplan-...",
|
|
266
|
+
"toolUsed": "pnpm test",
|
|
267
|
+
"passed": true,
|
|
268
|
+
"output": "Tests: 4 passed, 4 total. Coverage: 95%",
|
|
269
|
+
"duration": 1200,
|
|
270
|
+
"artifacts": ["coverage/lcov-report/index.html"]
|
|
271
|
+
}'
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Step 7: Close the Release
|
|
277
|
+
|
|
278
|
+
A **Release** bundles everything together. It can only be created when all Defects are closed.
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
scale create release "v1.1.0 - Add multiply" \
|
|
282
|
+
--payload '{
|
|
283
|
+
"version": "v1.1.0",
|
|
284
|
+
"includesSpecs": ["ART-spec-20260519-0002"],
|
|
285
|
+
"includesChanges": ["ART-change-20260519-0005"],
|
|
286
|
+
"rolloutStrategy": "all_at_once"
|
|
287
|
+
}'
|
|
288
|
+
|
|
289
|
+
scale transition ART-release-20260519-0007 prepare --reason "Ready"
|
|
290
|
+
scale transition ART-release-20260519-0007 ship --reason "Deploying"
|
|
291
|
+
scale transition ART-release-20260519-0007 verify --reason "Deployed and verified"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**FSM Path:** `PLANNED → READY → DEPLOYING → DEPLOYED`
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## The Complete Artifact DAG
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
Need (CLARIFIED)
|
|
302
|
+
└── Spec (FROZEN)
|
|
303
|
+
└── Plan (APPROVED)
|
|
304
|
+
└── Task (COMPLETED)
|
|
305
|
+
└── Change (VERIFIED)
|
|
306
|
+
└── Evidence (PASS)
|
|
307
|
+
└── Release (DEPLOYED)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Every arrow represents a parent-child relationship. Every state transition went through the FSM with Guards. The agent **could not skip verification** — it was physically blocked.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Key Takeaways
|
|
315
|
+
|
|
316
|
+
1. **FSM enforces order** — You can't create a Plan from a non-FROZEN Spec
|
|
317
|
+
2. **Guards prevent false completion** — Task completion is blocked without verification
|
|
318
|
+
3. **Event sourcing records everything** — Every transition is logged as an immutable event
|
|
319
|
+
4. **Defects create feedback loops** — If Evidence fails, a Defect is created and the cycle continues
|
|
320
|
+
5. **Lessons are extracted** — After 3+ similar Defects, SCALE proposes a Lesson; after review, it becomes a Rule; after violation, it becomes a Hook
|
|
321
|
+
|
|
322
|
+
## Next Steps
|
|
323
|
+
|
|
324
|
+
- [Agent Governance Demo](agent-governance-demo.md) — See a real-world task walkthrough
|
|
325
|
+
- [Task Guard Workflow Demo](../TASK_GUARD_WORKFLOW_DEMO.md) — Deep dive into Guard mechanics
|
|
326
|
+
- [Data Model](../02-DATA-MODEL.md) — Understand Artifact types, events, and FSM definitions
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# SCALE 工作流升级指南
|
|
2
|
+
|
|
3
|
+
本文是已有仓库安装、更新、适配 SCALE 工作流资产的短路径。
|
|
4
|
+
|
|
5
|
+
适合三类人:
|
|
6
|
+
|
|
7
|
+
| 角色 | 关注点 |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 项目维护者 | 如何把 SCALE 接入已有仓库,并避免覆盖本地规则 |
|
|
10
|
+
| 普通开发者 | 拉取仓库后如何检查或安装正确的 SCALE 版本 |
|
|
11
|
+
| Agent 使用者 | 哪些步骤可以命令化,哪些必须人工或 Agent 审阅 |
|
|
12
|
+
|
|
13
|
+
## 哪些可以自动化
|
|
14
|
+
|
|
15
|
+
SCALE 把更新分成三层:
|
|
16
|
+
|
|
17
|
+
| 层级 | 命令支持 | 默认行为 |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| SCALE CLI | `npm install -g @hongmaple0820/scale-engine@latest` | 用户显式安装或升级 |
|
|
20
|
+
| 生成的工作流文件 | `scale upgrade check/plan/apply/rollback` | 先安全检查和生成计划,只有 `--confirm` 才应用 |
|
|
21
|
+
| 项目级验证 | 仓库 `make` 目标和 `scripts/workflow/*` | 必须保留项目语义;SCALE 不猜业务路由、凭据和服务拓扑 |
|
|
22
|
+
|
|
23
|
+
这意味着工作流适配不是 Codex-only。Codex 可以帮助审阅和处理 `manual-review`,但常规路径应该是命令驱动。
|
|
24
|
+
|
|
25
|
+
## 首次安装
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @hongmaple0820/scale-engine
|
|
29
|
+
scale --version
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
已有项目可以用交互式初始化选择最接近的 governance pack:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
scale init --interactive
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
也可以直接指定:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
scale init --governance-pack standard
|
|
42
|
+
scale init --governance-pack project-scaffold
|
|
43
|
+
scale init --governance-pack moe-workspace
|
|
44
|
+
scale init --governance-pack go-service-matrix
|
|
45
|
+
scale init --governance-pack node-library
|
|
46
|
+
scale init --governance-pack frontend-app
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
不确定时先用 `standard`。仓库形态明确时再用更具体的 pack。
|
|
50
|
+
|
|
51
|
+
## 更新已有工作流
|
|
52
|
+
|
|
53
|
+
按这个顺序运行:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
scale upgrade check --dir .
|
|
57
|
+
scale upgrade plan --dir . --html
|
|
58
|
+
scale upgrade apply --dir . --confirm
|
|
59
|
+
scale preflight --dir . --service all --preflight-profile quick
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
如果仓库已有本地封装,优先使用本地命令,因为它们编码了项目默认值:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
make workflow-upgrade-check
|
|
66
|
+
make workflow-upgrade-plan
|
|
67
|
+
make workflow-upgrade-apply
|
|
68
|
+
make workflow-upgrade-verify
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
回滚只撤回最近一次 SCALE 管理的安全应用:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
scale upgrade rollback --dir .
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 如何读取结果
|
|
78
|
+
|
|
79
|
+
| 结果 | 含义 | 下一步 |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| clean | 生成的工作流集合和 lock 文件一致 | 运行项目级验证 |
|
|
82
|
+
| missing | 生成文件缺失 | 通常可用 `apply --confirm` 恢复 |
|
|
83
|
+
| outdated | SCALE 有更新的生成模板 | 审阅计划,确认安全后应用 |
|
|
84
|
+
| manual-review | 生成文件已有本地修改 | 检查 diff,不要自动覆盖 |
|
|
85
|
+
|
|
86
|
+
`manual-review` 是有意设计。SCALE 不应该抹掉本地项目知识、服务命令或 Agent 规则。
|
|
87
|
+
|
|
88
|
+
## 项目级适配
|
|
89
|
+
|
|
90
|
+
生成文件更新后,再按真实仓库适配这些文件:
|
|
91
|
+
|
|
92
|
+
- `.scale/verification.json`: service matrix, required checks, optional UI or E2E checks.
|
|
93
|
+
- `.scale/workspace.json`: branch model, protected branches, monorepo or workspace boundaries.
|
|
94
|
+
- `AGENTS.md` and `CLAUDE.md`: short agent entry rules.
|
|
95
|
+
- `docs/workflow/README.md`: human-readable workflow and verification commands.
|
|
96
|
+
- Repository wrappers such as `Makefile` and `scripts/workflow/verify.ps1`.
|
|
97
|
+
|
|
98
|
+
对 `netdisk-project` 这类多服务产品,不能把 `/health` 当作充分验证。验证必须覆盖本次变更影响的真实产品路径,例如 gateway 路由、`/api/v1/*` 请求、OAuth callback、存储驱动、UI 调用和数据持久化。
|
|
99
|
+
|
|
100
|
+
## Agent 本地产物忽略规则
|
|
101
|
+
|
|
102
|
+
工作流资产和团队协作规则可以提交;Agent 平台的本地状态、临时 worktree、缓存、日志和会话产物不应提交。已有项目接入或升级 SCALE 时,检查根 `.gitignore` 是否至少覆盖这些本地产物:
|
|
103
|
+
|
|
104
|
+
```gitignore
|
|
105
|
+
.claude/worktrees/
|
|
106
|
+
.claude/tmp/
|
|
107
|
+
.claude/local/
|
|
108
|
+
.codex/worktrees/
|
|
109
|
+
.codex/tmp/
|
|
110
|
+
.codex-tmp/
|
|
111
|
+
.cursor/tmp/
|
|
112
|
+
.continue/
|
|
113
|
+
.aider*
|
|
114
|
+
.gemini/tmp/
|
|
115
|
+
.omc/
|
|
116
|
+
.roo/tmp/
|
|
117
|
+
.cline/tmp/
|
|
118
|
+
.windsurf/
|
|
119
|
+
.playwright-mcp/
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
不要为了省事直接忽略所有协作配置目录。像 `AGENTS.md`、`CLAUDE.md`、`.cursor/rules/`、团队共享的 `.claude/settings.json`、`.scale/governance.lock.json` 这类稳定规则可以进入版本库。
|
|
123
|
+
|
|
124
|
+
## 推荐仓库封装
|
|
125
|
+
|
|
126
|
+
接入 SCALE 的仓库建议暴露这些命令:
|
|
127
|
+
|
|
128
|
+
```makefile
|
|
129
|
+
workflow-upgrade-check:
|
|
130
|
+
scale upgrade check --dir .
|
|
131
|
+
workflow-upgrade-plan:
|
|
132
|
+
scale upgrade plan --dir . --html
|
|
133
|
+
workflow-upgrade-apply:
|
|
134
|
+
scale upgrade apply --dir . --confirm
|
|
135
|
+
workflow-upgrade-rollback:
|
|
136
|
+
scale upgrade rollback --dir .
|
|
137
|
+
workflow-upgrade-verify:
|
|
138
|
+
scale preflight --dir . --service all --preflight-profile quick
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
如果 Windows 环境没有 `make`,提供等价 PowerShell 脚本,或在文档里写清原始 `scale` 命令。
|
|
142
|
+
|
|
143
|
+
## 完成检查
|
|
144
|
+
|
|
145
|
+
- `scale --version` 输出预期版本。
|
|
146
|
+
- `scale upgrade check --dir .` 没有非预期 drift。
|
|
147
|
+
- 有变更时,`scale upgrade plan --dir . --html` 能生成可审阅计划。
|
|
148
|
+
- `scale upgrade apply --dir . --confirm` 只在审阅计划后使用。
|
|
149
|
+
- 项目级验证通过,或记录清楚已知失败。
|
|
150
|
+
- `README.md`、`AGENTS.md`、`CLAUDE.md`、`docs/workflow/README.md` 指向同一组工作流命令。
|
|
Binary file
|
package/image/wxPay.jpg
ADDED
|
Binary file
|
package/image/zfb.jpg
ADDED
|
Binary file
|