@hongmaple0820/scale-engine 0.38.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/api/cli.js +142 -40
- package/dist/api/cli.js.map +1 -1
- package/dist/api/doctor.js +1 -1
- package/dist/api/doctor.js.map +1 -1
- package/dist/bootstrap/DependencyBootstrap.d.ts +22 -1
- package/dist/bootstrap/DependencyBootstrap.js +420 -32
- package/dist/bootstrap/DependencyBootstrap.js.map +1 -1
- package/dist/bootstrap/DependencyBootstrapRenderer.d.ts +3 -0
- package/dist/bootstrap/DependencyBootstrapRenderer.js +140 -0
- package/dist/bootstrap/DependencyBootstrapRenderer.js.map +1 -0
- package/dist/cli/gateStatusCommands.d.ts +1 -0
- package/dist/cli/gateStatusCommands.js +52 -0
- package/dist/cli/gateStatusCommands.js.map +1 -0
- package/dist/cli/phaseCommands.js +15 -3
- package/dist/cli/phaseCommands.js.map +1 -1
- package/dist/cli/promptCommands.d.ts +1 -0
- package/dist/cli/promptCommands.js +57 -0
- package/dist/cli/promptCommands.js.map +1 -0
- package/dist/cli/scoreCommands.d.ts +1 -0
- package/dist/cli/scoreCommands.js +112 -0
- package/dist/cli/scoreCommands.js.map +1 -0
- package/dist/codegraph/CodeIntelligence.js +1 -1
- package/dist/codegraph/CodeIntelligence.js.map +1 -1
- package/dist/context/SessionStartSequence.js +13 -4
- package/dist/context/SessionStartSequence.js.map +1 -1
- package/dist/core/ExternalCommand.js +18 -4
- package/dist/core/ExternalCommand.js.map +1 -1
- package/dist/env/EnvironmentDoctor.d.ts +66 -0
- package/dist/env/EnvironmentDoctor.js +365 -0
- package/dist/env/EnvironmentDoctor.js.map +1 -0
- package/dist/i18n/Language.d.ts +9 -0
- package/dist/i18n/Language.js +38 -0
- package/dist/i18n/Language.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/MemoryProviders.js +38 -5
- package/dist/memory/MemoryProviders.js.map +1 -1
- package/dist/prompts/PromptOptimizer.d.ts +42 -0
- package/dist/prompts/PromptOptimizer.js +309 -0
- package/dist/prompts/PromptOptimizer.js.map +1 -0
- package/dist/setup/SetupWizard.d.ts +42 -0
- package/dist/setup/SetupWizard.js +156 -0
- package/dist/setup/SetupWizard.js.map +1 -0
- package/dist/skills/SkillRepository.js +2 -2
- package/dist/skills/SkillRepository.js.map +1 -1
- package/dist/testing/DiffTestSelector.js +1 -1
- package/dist/testing/DiffTestSelector.js.map +1 -1
- package/dist/tools/ToolCapabilityRegistry.d.ts +4 -0
- package/dist/tools/ToolCapabilityRegistry.js +11 -6
- package/dist/tools/ToolCapabilityRegistry.js.map +1 -1
- package/dist/workflow/CommitDiscipline.js +8 -7
- package/dist/workflow/CommitDiscipline.js.map +1 -1
- package/dist/workflow/CrossRepoOrchestrator.js +15 -7
- package/dist/workflow/CrossRepoOrchestrator.js.map +1 -1
- package/dist/workflow/GateCatalog.d.ts +61 -0
- package/dist/workflow/GateCatalog.js +212 -0
- package/dist/workflow/GateCatalog.js.map +1 -0
- package/dist/workflow/GovernanceTemplatePacks.js +19 -4
- package/dist/workflow/GovernanceTemplatePacks.js.map +1 -1
- package/dist/workflow/SessionPreamble.js +7 -2
- package/dist/workflow/SessionPreamble.js.map +1 -1
- package/dist/workflow/TaskScoreEngine.d.ts +42 -0
- package/dist/workflow/TaskScoreEngine.js +181 -0
- package/dist/workflow/TaskScoreEngine.js.map +1 -0
- package/dist/workflow/WorkspaceTopology.d.ts +3 -0
- package/dist/workflow/WorkspaceTopology.js +40 -3
- package/dist/workflow/WorkspaceTopology.js.map +1 -1
- package/dist/workflow/gates/GateSystem.js +2 -2
- package/dist/workflow/gates/GateSystem.js.map +1 -1
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.js +2 -0
- package/dist/workflow/index.js.map +1 -1
- package/docs/CODE_INTELLIGENCE.md +27 -2
- package/docs/MEMORY_FABRIC.md +22 -1
- package/docs/THIRD_PARTY_SKILLS.md +50 -1
- package/docs/guides/GETTING_STARTED.md +24 -0
- package/docs/start/quickstart.md +103 -76
- package/docs/workflow/GATES_AND_SCORE.md +56 -0
- package/docs/workflow/PROMPT_OPTIMIZATION.md +44 -0
- package/docs/workflow/README.md +7 -0
- package/docs/workflow/node-library.md +3 -3
- package/package.json +11 -4
- package/scripts/workflow/provider-rehearsal.mjs +425 -0
- package/scripts/workflow/setup-smoke.mjs +299 -0
package/docs/MEMORY_FABRIC.md
CHANGED
|
@@ -129,7 +129,8 @@ scale ai-os plan --task "Fix OAuth callback Redis state" --files src/auth/oauth.
|
|
|
129
129
|
|
|
130
130
|
Provider rules:
|
|
131
131
|
|
|
132
|
-
- `gbrain` is the default external-first provider.
|
|
132
|
+
- `gbrain` is the default external-first provider. SCALE now treats CLI existence as insufficient: `scale memory provider status --json` requires `gbrain doctor --json` to pass before marking it available. If the CLI exists but no brain is configured, the status remains unavailable and points to `gbrain init --pglite`.
|
|
133
|
+
- The preferred remote production path is the official thin-client flow: run `gbrain serve --http` on the host, then configure the local CLI with `gbrain init --mcp-only` so SCALE can keep calling `gbrain query` through the thin client instead of inventing a separate ad-hoc REST contract.
|
|
133
134
|
- `agentmemory` remains optional and can be added as a second provider when teams want cross-agent shared memory.
|
|
134
135
|
- `memory provider use <id>` is the fast path for switching the default route without hand-editing `.scale/memory-providers.json`.
|
|
135
136
|
- External providers are read-only by default. Writes require an explicit provider policy change.
|
|
@@ -138,3 +139,23 @@ Provider rules:
|
|
|
138
139
|
- `ai-os plan` includes both the provider recall summary and the Memory Fabric context pack, so agents can route memory before planning without pretending external memory is always available.
|
|
139
140
|
|
|
140
141
|
This keeps agents flexible: they can ask the router for memory before planning, verification, review, or release, while SCALE still records which provider was used and why fallback was required.
|
|
142
|
+
|
|
143
|
+
Setup shortcut:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
scale setup --pack memory
|
|
147
|
+
scale setup --pack memory --memory-provider scale-local --json
|
|
148
|
+
scale setup --pack memory --memory-provider gbrain --memory-mode external-first --json
|
|
149
|
+
scale memory provider status --json
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`setup --memory-provider` is the preferred UX for provider switching during onboarding. It writes the same routing file as `scale memory provider use`, returns `memoryProviderSwitch` in JSON, and keeps external writes disabled unless `--allow-external-write` is explicitly passed.
|
|
153
|
+
|
|
154
|
+
Remote replay validation:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run smoke:gbrain
|
|
158
|
+
node scripts/workflow/provider-rehearsal.mjs --skip-graphify --require-gbrain
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This is intentionally stronger than `scale memory provider status --json`: it requires a real configured gbrain, writes a temporary page, then reads and queries it through separate CLI processes. If no remote/thin-client brain is configured, the rehearsal must report `blocked` or fail under `--require-gbrain`; falling back to `scale-local` is not a valid substitute for cross-session provider validation.
|
|
@@ -17,7 +17,12 @@ This document records external skill projects that SCALE may learn from, recomme
|
|
|
17
17
|
| --- | --- | --- | --- | --- |
|
|
18
18
|
| Planning with Files | MIT | [OthmanAdi/planning-with-files](https://github.com/OthmanAdi/planning-with-files) | Adapt concepts for file-backed plans, findings, progress logs, active-plan routing, and plan attestation. | Not vendored. |
|
|
19
19
|
| agentmemory | Apache-2.0 | [rohitg00/agentmemory](https://github.com/rohitg00/agentmemory) | Optional external memory provider via REST or MCP for teams that need cross-agent persistent memory beyond local SCALE Memory Brain. | Not vendored. |
|
|
20
|
-
| GBrain | MIT | [garrytan/gbrain](https://github.com/garrytan/gbrain) |
|
|
20
|
+
| GBrain | MIT | [garrytan/gbrain](https://github.com/garrytan/gbrain) | Default memory provider route for graph-backed cross-session recall. SCALE verifies `gbrain doctor --json`; CLI existence alone is not enough. | Not vendored. |
|
|
21
|
+
| awesome-design-md | MIT | [VoltAgent/awesome-design-md](https://github.com/VoltAgent/awesome-design-md) | DESIGN.md catalog for brand, visual language, typography, and design-system direction. SCALE syncs it as an external catalog, not as copied source. | Not vendored by default. |
|
|
22
|
+
| ui-ux-pro-max | Upstream project license | [nextlevelbuilder/ui-ux-pro-max-skill](https://github.com/nextlevelbuilder/ui-ux-pro-max-skill) | UX, UI state, accessibility, responsive, and acceptance-review skill. SCALE uses the official `uipro-cli` path. | Not vendored by default. |
|
|
23
|
+
| RTK | Upstream project license | [rtk-ai/rtk](https://github.com/rtk-ai/rtk) | Governed CLI proxy for shell-output compression and token savings. SCALE checks `rtk gain` and hook initialization. | External CLI only. |
|
|
24
|
+
| Graphify | Upstream project license | [safishamsi/graphify](https://github.com/safishamsi/graphify) | Knowledge graph artifact provider. SCALE expects `graphify-out/graph.json` and Codex hook/skill freshness before relying on it. | Generated artifacts are project-local. |
|
|
25
|
+
| CodeGraph | Upstream project license | [colbymchenry/codegraph](https://github.com/colbymchenry/codegraph) | Code structure provider for symbol/context exploration. SCALE expects a project `.codegraph/` index. | External CLI/index only. |
|
|
21
26
|
|
|
22
27
|
Other referenced skills, MCP servers, CLIs, discovery candidates, and adapter targets are listed in [External Reference Inventory](EXTERNAL_REFERENCES.md). Unknown licenses stay `review-required`; do not treat a repository link as redistribution permission.
|
|
23
28
|
|
|
@@ -55,3 +60,47 @@ External memory providers must not be enabled silently. Before use, record:
|
|
|
55
60
|
- whether provider writes are disabled, candidate-only, or explicitly enabled
|
|
56
61
|
|
|
57
62
|
External planning skills must not replace SCALE task evidence. They can improve the plan artifact shape, but final delivery still requires verification output, changed-file evidence, and explicit unverified-risk notes.
|
|
63
|
+
|
|
64
|
+
## User-Facing Setup
|
|
65
|
+
|
|
66
|
+
Use the governed installer instead of asking users to discover every upstream command manually:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
scale setup --pack full
|
|
70
|
+
scale setup --pack full --yes
|
|
71
|
+
scale setup --pack full --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Default language is Chinese. Use `--lang en` or `SCALE_LANG=en` for English output.
|
|
75
|
+
|
|
76
|
+
`setup` and `bootstrap deps` now expose report-level `runtimeChecks` before any install command runs. Missing `python`, `bun`, `cargo`, `uv/pipx`, or `node/npm/npx` is shown with a targeted install hint, so users can fix the environment before `--yes`/`--apply`.
|
|
77
|
+
|
|
78
|
+
Memory provider routing can be configured during setup:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
scale setup --pack memory --memory-provider scale-local --json
|
|
82
|
+
scale setup --pack memory --memory-provider gbrain --memory-mode external-first --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Repository maintainers should run the setup smoke before release or after changing installer behavior:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm run smoke:setup
|
|
89
|
+
make setup-smoke
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The smoke is intentionally non-destructive: it validates bilingual output, `runtimeChecks`, memory-provider routing writes in a temp `.scale`, and CodeGraph/Graphify status discovery without running third-party installers.
|
|
93
|
+
|
|
94
|
+
For OS-specific failures, run:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
scale doctor env --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This reports platform, shell discovery, PATH shape, core tools, package managers, and optional third-party runtimes in one machine-readable payload.
|
|
101
|
+
|
|
102
|
+
`frontend-design` is no longer part of the default UI install path. The default UI stack is:
|
|
103
|
+
|
|
104
|
+
- `awesome-design-md` for brand, visual language, and `DESIGN.md`.
|
|
105
|
+
- `ui-ux-pro-max` for UX flow, UI state, accessibility, and responsive acceptance.
|
|
106
|
+
- `frontend-design` only when explicitly requested with `--include frontend-design`.
|
|
@@ -34,6 +34,30 @@ make verify PROFILE=default
|
|
|
34
34
|
git diff --check
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
如果改动影响安装、第三方能力、skills、记忆或知识库入口,还要跑安装烟测:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
make setup-smoke
|
|
41
|
+
npm run smoke:setup
|
|
42
|
+
npm run smoke:providers
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`smoke:setup` 负责安装入口和配置路径;`smoke:providers` 负责真实 gbrain/graphify 回放。没有远端 gbrain 或大项目 Graphify 环境时,默认报告 `blocked` 并给出修复命令;如果要把它作为强制门禁,使用 `npm run smoke:gbrain` 或 `npm run smoke:graphify -- --large-project <path>`。
|
|
46
|
+
|
|
47
|
+
准备发版本仓库时,直接跑完整发布门禁:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm run release:check
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
如果全量测试卡住或需要定位顺序相关问题,再用 `npm run test:serial` 做排障;不要把它当成默认发布门禁。
|
|
54
|
+
|
|
55
|
+
如果失败和本机 shell、PATH、Python、Bun、Cargo 或第三方 CLI 有关,先跑:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
scale doctor env --json
|
|
59
|
+
```
|
|
60
|
+
|
|
37
61
|
## 你应该看到什么
|
|
38
62
|
|
|
39
63
|
- `.scale/workspace.json` 明确了 `dev -> master` 的仓库分支策略。
|
package/docs/start/quickstart.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# 3 分钟快速开始
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
目标:在一个项目里安装 SCALE 工作流,完成依赖检查,并看到可验证的治理产物。
|
|
4
4
|
|
|
5
5
|
## 前置条件
|
|
6
6
|
|
|
7
|
-
- Node.js 20
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- Node.js 20+
|
|
8
|
+
- npm
|
|
9
|
+
- Git
|
|
10
|
+
- Windows PowerShell、Git Bash、macOS/Linux shell 均可
|
|
11
|
+
|
|
12
|
+
Python、Bun、Rust/Cargo、uv/pipx 不是启动 SCALE 的硬要求。只有启用 Graphify、GBrain、RTK 等第三方能力时,安装器才会提示缺少哪些运行时以及可执行的修复命令。
|
|
10
13
|
|
|
11
14
|
## 1. 安装 CLI
|
|
12
15
|
|
|
@@ -15,13 +18,13 @@ npm install -g @hongmaple0820/scale-engine
|
|
|
15
18
|
scale --version
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
本仓库开发时也可以直接运行源码入口:
|
|
19
22
|
|
|
20
23
|
```bash
|
|
21
|
-
node E:/project/scale-engine/
|
|
24
|
+
node --import tsx E:/project/scale-engine/src/api/cli.ts --help
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
## 2.
|
|
27
|
+
## 2. 初始化项目
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
30
|
mkdir scale-demo
|
|
@@ -29,56 +32,93 @@ cd scale-demo
|
|
|
29
32
|
scale init --governance-pack standard
|
|
30
33
|
```
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
初始化会生成 `.scale/`、`docs/`、`scripts/` 以及对应 Agent 入口文件。已有项目升级不要盲目重跑 `init`,优先使用:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
scale upgrade check --dir . --lang zh
|
|
39
|
+
scale upgrade plan --dir . --html --lang zh
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 3. 交互式安装第三方能力
|
|
43
|
+
|
|
44
|
+
默认输出语言是中文。需要英文时加 `--lang en`,也可以设置 `SCALE_LANG=en`。
|
|
45
|
+
|
|
46
|
+
推荐先只查看计划:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
scale setup --pack full
|
|
50
|
+
```
|
|
33
51
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
确认后安装:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
scale setup --pack full --yes
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
机器可读输出:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
scale setup --pack full --json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`setup` 和 `bootstrap deps` 都会输出 `runtimeChecks`。如果机器缺少 `python`、`bun`、`cargo`、`uv/pipx`、`node/npm/npx`,会先显示缺失项和修复建议,再决定是否执行 `--yes` 或 `--apply`,避免安装中途卡住。
|
|
65
|
+
|
|
66
|
+
记忆供应商可以在安装入口直接切换,不需要手改 `.scale/memory-providers.json`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
scale setup --pack memory --memory-provider scale-local --json
|
|
70
|
+
scale setup --pack memory --memory-provider gbrain --memory-mode external-first --json
|
|
39
71
|
```
|
|
40
72
|
|
|
41
|
-
|
|
73
|
+
第三方能力的职责边界:
|
|
42
74
|
|
|
43
|
-
|
|
|
44
|
-
| --- | --- |
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
| `
|
|
75
|
+
| 能力 | 默认定位 | 关键验证 |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `awesome-design-md` | 品牌、视觉语言、`DESIGN.md` 来源 | 是否同步上游 DESIGN.md catalog |
|
|
78
|
+
| `ui-ux-pro-max` | UX、状态、可访问性、响应式验收 | 是否通过官方 `uipro-cli` 安装 |
|
|
79
|
+
| `frontend-design` | 可选实现灵感,不再是 UI 默认必装项 | 需要时显式 `--include frontend-design` |
|
|
80
|
+
| `rtk` | CLI proxy/token 节省能力 | `rtk gain` 和 `rtk init -g --codex` |
|
|
81
|
+
| `gbrain` | 默认记忆供应商 | `gbrain doctor --json`,未初始化会提示 `gbrain init --pglite` |
|
|
82
|
+
| `graphify` | 知识图谱产物供应商 | `graphify install --platform codex` 和 `graphify-out/graph.json` |
|
|
83
|
+
| `codegraph` | 代码结构索引供应商 | `codegraph init -i` 和 `.codegraph/` |
|
|
51
84
|
|
|
52
|
-
|
|
85
|
+
低层命令仍可直接使用:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
scale bootstrap deps --profile advanced --governance-pack frontend-app --lang zh
|
|
89
|
+
scale bootstrap deps --profile advanced --governance-pack frontend-app --apply --lang zh
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 4. 验证闭环
|
|
53
93
|
|
|
54
94
|
```bash
|
|
55
|
-
scale bootstrap deps --pack external-cli --json
|
|
56
95
|
scale doctor
|
|
57
96
|
scale preflight --preflight-profile quick
|
|
58
97
|
scale status
|
|
59
98
|
scale assets scan --dir .
|
|
60
99
|
scale standards scan --dir .
|
|
61
100
|
scale runtime doctor --level S
|
|
101
|
+
scale memory provider status --json
|
|
102
|
+
scale codegraph status --json
|
|
62
103
|
```
|
|
63
104
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- `preflight` 能说明当前治理文件是否完整。
|
|
67
|
-
- `bootstrap deps` 会告诉你第三方 skills、RTK、记忆/知识图谱依赖哪些已经装好,哪些只是治理规则已经生成。
|
|
68
|
-
- `status` 会告诉 Agent 下一步应该做什么。
|
|
69
|
-
- `assets scan` 会把文档、模板、脚本、报告等资源分类。
|
|
70
|
-
- `standards scan` 会扫描日志噪音、敏感信息、危险输入、测试和架构风险。
|
|
71
|
-
- `runtime doctor` 会检查本地运行时证据目录和最终交付证据状态。
|
|
72
|
-
|
|
73
|
-
建议再跑一次 `scale doctor`。现在它会按当前 profile 输出 `bootstrap` 建议,并把 `gbrain / codegraph / graphify` 的状态一起列出来。
|
|
105
|
+
未运行验证,不要声称通过。`setup --json` 和 `bootstrap deps --json` 只代表依赖计划可解析,不等于第三方服务已经可用。
|
|
74
106
|
|
|
75
|
-
|
|
107
|
+
真实第三方能力需要单独跑回放验证。默认命令会把未配置的远端能力标记为 `blocked`,但不会让本地发布门禁误失败;需要作为强制门禁时使用对应 npm script 或加 `--require-*`。
|
|
76
108
|
|
|
77
109
|
```bash
|
|
78
|
-
|
|
110
|
+
npm run smoke:providers
|
|
111
|
+
npm run smoke:gbrain
|
|
112
|
+
npm run smoke:graphify -- --large-project /path/to/large-project
|
|
79
113
|
```
|
|
80
114
|
|
|
81
|
-
|
|
115
|
+
验证语义:
|
|
116
|
+
|
|
117
|
+
- `smoke:gbrain` 会先执行真实 `gbrain doctor --json`,通过后写入一个临时记忆页,再用独立 CLI 进程 `get/query/search` 回放,证明不是本地 mock。
|
|
118
|
+
- `smoke:graphify` 会对真实项目执行 `graphify extract ... --out <temp>/graphify-out --no-cluster`,检查 `graph.json`,再执行 `graphify query`。
|
|
119
|
+
- `graphify-out/` 是生成产物,不应该提交到 Git;长期知识沉淀应进入经过评审的 `memory/`、docs 或规则文件。
|
|
120
|
+
|
|
121
|
+
## 5. 建立任务上下文
|
|
82
122
|
|
|
83
123
|
```bash
|
|
84
124
|
scale context init --name "Scale Demo"
|
|
@@ -88,14 +128,7 @@ scale diagnose plan --task-id 2026-05-18-oauth-hardening --symptom "callback 在
|
|
|
88
128
|
scale tdd slice --task-id 2026-05-18-oauth-hardening --behavior "拒绝过期 OAuth state" --public-interface "GET /oauth/callback" --failing-test "expired state returns 401" --test-file tests/oauth.test.ts --impl-files src/oauth.ts
|
|
89
129
|
```
|
|
90
130
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
- `context grill`:逼 Agent 先澄清上下文、成功标准和风险。
|
|
94
|
-
- `diagnose plan`:遇到问题先诊断,不允许盲修。
|
|
95
|
-
- `tdd slice`:把行为、公共接口、失败测试和实现文件绑定成一个可检查切片。
|
|
96
|
-
- `runtime start`:建立会话 ledger,后续命令、工具和验证证据可以绑定到同一个任务。
|
|
97
|
-
|
|
98
|
-
完成真实验证后记录运行时证据:
|
|
131
|
+
任务完成后记录验证证据并沉淀候选经验:
|
|
99
132
|
|
|
100
133
|
```bash
|
|
101
134
|
scale runtime record --title "quick preflight" --kind command --status passed --command "scale preflight --preflight-profile quick" --exit-code 0 --summary "quick preflight passed"
|
|
@@ -104,51 +137,45 @@ scale memory pack --task-id 2026-05-18-oauth-hardening --session-id 2026-05-18-o
|
|
|
104
137
|
scale memory settle --task-id 2026-05-18-oauth-hardening --session-id 2026-05-18-oauth-hardening --task "继续加固 OAuth callback" --level M
|
|
105
138
|
```
|
|
106
139
|
|
|
107
|
-
`memory
|
|
140
|
+
`memory settle` 默认只生成学习候选,不会自动把一次会话判断提升成长线规则。存在失败证据时,候选会要求先解决失败,避免把未闭环问题沉淀成经验。
|
|
141
|
+
|
|
142
|
+
## 6. MOE/多仓工作区
|
|
108
143
|
|
|
109
|
-
|
|
144
|
+
多仓项目使用:
|
|
110
145
|
|
|
111
146
|
```bash
|
|
112
|
-
scale
|
|
113
|
-
scale artifact doctor --artifact-dir docs/worklog/tasks/2026-05-18-oauth-hardening
|
|
114
|
-
scale artifact open --task-id 2026-05-18-oauth-hardening --artifact-dir docs/worklog/tasks/2026-05-18-oauth-hardening
|
|
147
|
+
scale init --governance-pack moe-workspace
|
|
115
148
|
```
|
|
116
149
|
|
|
117
|
-
|
|
150
|
+
MOE 默认把子工程配置为兄弟仓库或绝对路径,不建议把独立 Git 子工程放在主工程根目录下。`.scale/workspace.json` 中的典型写法:
|
|
118
151
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"topology": "moe",
|
|
155
|
+
"repositories": [
|
|
156
|
+
{ "name": "root", "path": ".", "role": "root", "required": true },
|
|
157
|
+
{ "name": "api", "path": "../api", "role": "external", "required": true, "remote": "origin" }
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
```
|
|
122
161
|
|
|
123
|
-
|
|
162
|
+
这样可以避免子工程 Git 状态、分支、提交和主工程互相污染。
|
|
124
163
|
|
|
125
|
-
|
|
164
|
+
## 7. 安装烟测
|
|
126
165
|
|
|
127
|
-
|
|
166
|
+
仓库开发和发版前可以一键验证安装入口:
|
|
128
167
|
|
|
129
168
|
```bash
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
scale init --governance-pack moe-workspace
|
|
134
|
-
scale init --governance-pack resource-governance
|
|
169
|
+
npm run smoke:setup
|
|
170
|
+
npm run smoke:providers
|
|
171
|
+
make setup-smoke
|
|
135
172
|
```
|
|
136
173
|
|
|
137
|
-
|
|
174
|
+
`smoke:setup` 只验证安装计划、双语输出、运行时依赖诊断、记忆供应商切换和 CodeGraph/Graphify 状态路径,不会执行真实第三方安装。
|
|
175
|
+
`smoke:providers` 会执行真实供应商回放;未配置 gbrain 或 graphify 时输出 `blocked` 和修复命令,只有 `smoke:gbrain`/`smoke:graphify` 或显式 `--require-*` 才会失败退出。
|
|
138
176
|
|
|
139
|
-
|
|
140
|
-
scale upgrade check --dir . --lang zh
|
|
141
|
-
scale upgrade plan --dir . --html --lang zh
|
|
142
|
-
scale upgrade apply --dir . --confirm --lang zh
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
如果升级计划提示 AI OS runtime 尚未接入,用一键接入命令生成运行态目录、首份 dry-run、benchmark 和 doctor 报告:
|
|
177
|
+
遇到跨系统命令兼容、PATH 或运行时依赖问题时,先导出环境诊断:
|
|
146
178
|
|
|
147
179
|
```bash
|
|
148
|
-
scale
|
|
180
|
+
scale doctor env --json
|
|
149
181
|
```
|
|
150
|
-
|
|
151
|
-
需要英文输出时把 `--lang zh` 换成 `--lang en`。干净的 SCALE 受管文件可以自动刷新;已有本地改动的文件会进入人工审阅,不会被自动覆盖。
|
|
152
|
-
|
|
153
|
-
继续阅读 [官方 Demo Walkthrough](agent-governance-demo.md),看一个真实任务如何从需求到验证证据。
|
|
154
|
-
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Gates and Task Score
|
|
2
|
+
|
|
3
|
+
This document records the first deterministic optimization layer for gate visibility, architecture conformance, and task scoring.
|
|
4
|
+
|
|
5
|
+
## Gate Status
|
|
6
|
+
|
|
7
|
+
Use `scale gates status` to inspect the active gate catalog.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
scale gates status --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The report separates three concepts that were previously easy to confuse:
|
|
14
|
+
|
|
15
|
+
- Core gates: `G0-G8`, used by workflow verification, preflight, and product smoke profiles.
|
|
16
|
+
- Meta-governance gates: `G9-G15`, used by `scale meta-governance`.
|
|
17
|
+
- Extension gates: policy-backed checks such as engineering standards, product smoke policy, and tool evidence.
|
|
18
|
+
|
|
19
|
+
`scale gates status` is intentionally read-only. It does not execute checks; it explains which checks exist and which policies are blocking.
|
|
20
|
+
|
|
21
|
+
## Architecture Standards Gate
|
|
22
|
+
|
|
23
|
+
Architecture and engineering standards are driven by project configuration:
|
|
24
|
+
|
|
25
|
+
- `.scale/verification.json` controls whether `engineeringStandardsGate` is `off`, `warn`, or `block`.
|
|
26
|
+
- `.scale/engineering-standards.json` controls standards rules and baselines.
|
|
27
|
+
- `.scale/frameworks.json` records project-specific framework and architecture conventions.
|
|
28
|
+
|
|
29
|
+
Preflight now uses changed-file standards scope when the target is inside a Git worktree. Non-Git projects keep the old full-scan behavior so bootstrap and fixture projects still get complete feedback.
|
|
30
|
+
|
|
31
|
+
## Task Score
|
|
32
|
+
|
|
33
|
+
Use `scale score task` to produce an algorithmic completion score.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
scale score task --changed --json
|
|
37
|
+
scale score task --task-id TASK-123 --level L --changed-files src/api/foo.ts,src/workflow/bar.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The score is computed from evidence, not from a model:
|
|
41
|
+
|
|
42
|
+
- Verification: recent gate pass rate.
|
|
43
|
+
- Architecture standards: deterministic standards doctor result.
|
|
44
|
+
- Evidence completeness: persisted gate evidence records.
|
|
45
|
+
- Context and memory: CodeGraph/code intelligence readiness and memory provider readiness.
|
|
46
|
+
- Cost efficiency: governance ROI and cache/context savings.
|
|
47
|
+
- Risk control: task level, blocking standards, and blocking extension gates.
|
|
48
|
+
|
|
49
|
+
Default thresholds:
|
|
50
|
+
|
|
51
|
+
- `S`: 65
|
|
52
|
+
- `M`: 75
|
|
53
|
+
- `L`: 85
|
|
54
|
+
- `CRITICAL`: 90
|
|
55
|
+
|
|
56
|
+
Use `--warn-only` when the score should be reported without failing the command.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Prompt Optimization
|
|
2
|
+
|
|
3
|
+
`scale prompt optimize` is the deterministic pre-execution prompt rewrite layer for coding tasks. It turns a raw user instruction into a structured, professional, executable prompt before the workflow asks an agent to plan or implement.
|
|
4
|
+
|
|
5
|
+
## Why It Exists
|
|
6
|
+
|
|
7
|
+
- Reduce model ambiguity before expensive model calls.
|
|
8
|
+
- Preserve the user's real intent instead of inventing a new requirement.
|
|
9
|
+
- Add missing execution structure: objective, context, boundaries, acceptance criteria, validation, deliverables, and risks.
|
|
10
|
+
- Make `scale define` start from a higher-quality requirement, so downstream planning and verification have clearer input.
|
|
11
|
+
|
|
12
|
+
## CLI
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
scale prompt optimize --input "Build a CLI prompt optimizer that rewrites raw coding requests" --json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Useful options:
|
|
19
|
+
|
|
20
|
+
- `--language auto|zh|en`: choose output language. `auto` detects Chinese vs English.
|
|
21
|
+
- `--title "Prompt Optimizer"`: add a task title to the optimized objective.
|
|
22
|
+
- `--files "src/api/cli.ts,src/prompts/PromptOptimizer.ts"`: add known file scope.
|
|
23
|
+
- `--service "api,workflow"`: add known service scope.
|
|
24
|
+
- `--success-criteria "structured prompt,preserves intent,validation evidence"`: seed acceptance criteria.
|
|
25
|
+
|
|
26
|
+
## Workflow Integration
|
|
27
|
+
|
|
28
|
+
`scale define` now runs prompt optimization before ambiguity scoring and spec creation:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
scale define "Prompt Optimizer" \
|
|
32
|
+
--description "用户输入后自动整理成专业 coding prompt,要保留真实意图" \
|
|
33
|
+
--success-criteria "生成结构化提示词,保留用户原始意图,输出验收标准" \
|
|
34
|
+
--json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The JSON result includes `promptOptimization`, and `spec.payload.what` stores the optimized prompt used by the rest of the workflow.
|
|
38
|
+
|
|
39
|
+
## Governance Rules
|
|
40
|
+
|
|
41
|
+
- The optimizer is algorithmic and does not call a model.
|
|
42
|
+
- It must not silently change the user's scope.
|
|
43
|
+
- It may add generic execution standards, validation requirements, and clarification questions.
|
|
44
|
+
- Vague input is still accepted, but the `quality.missingInfo` list must expose missing acceptance criteria, affected scope, or constraints.
|
package/docs/workflow/README.md
CHANGED
|
@@ -18,6 +18,9 @@ make explore FILES='AGENTS.md CLAUDE.md README.md package.json' MSG='main contra
|
|
|
18
18
|
make gate-workflow
|
|
19
19
|
make gate-quality
|
|
20
20
|
make verify PROFILE=default
|
|
21
|
+
scale gates status --json
|
|
22
|
+
scale score task --changed --json
|
|
23
|
+
scale prompt optimize --input "raw coding request" --json
|
|
21
24
|
```
|
|
22
25
|
|
|
23
26
|
PowerShell:
|
|
@@ -26,6 +29,10 @@ PowerShell:
|
|
|
26
29
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/workflow/verify.ps1 -Profile default
|
|
27
30
|
```
|
|
28
31
|
|
|
32
|
+
See [GATES_AND_SCORE.md](GATES_AND_SCORE.md) for gate catalog visibility, architecture standards gate scope, and deterministic task scoring.
|
|
33
|
+
|
|
34
|
+
See [PROMPT_OPTIMIZATION.md](PROMPT_OPTIMIZATION.md) for the deterministic prompt rewrite layer used by `scale prompt optimize` and `scale define`.
|
|
35
|
+
|
|
29
36
|
## 门禁说明
|
|
30
37
|
|
|
31
38
|
| Gate | 作用 |
|
|
@@ -28,7 +28,7 @@ powershell -NoProfile -ExecutionPolicy Bypass -File scripts/workflow/verify.ps1
|
|
|
28
28
|
## Default Verification Matrix
|
|
29
29
|
|
|
30
30
|
- quick loop: `npm run build`, `npm run lint`, `npm test`
|
|
31
|
-
- release loop: add `npm run typecheck`, `git diff --check`, and `npm pack --dry-run`
|
|
31
|
+
- release loop: run `npm run release:check` when available; otherwise add `npm run typecheck`, `npm run smoke:setup`, `npm audit --omit=dev`, `git diff --check`, and `npm pack --dry-run`
|
|
32
32
|
- product smoke: enable a real probe in `.scale/product-smoke.json` instead of treating a health endpoint as completion proof
|
|
33
33
|
|
|
34
34
|
## Branch Policy
|
|
@@ -47,6 +47,6 @@ Before a package release or demo handoff:
|
|
|
47
47
|
|
|
48
48
|
1. Run `bash scripts/preflight/all.sh` or the PowerShell equivalent.
|
|
49
49
|
2. Run `scale preflight --preflight-profile full --json`.
|
|
50
|
-
3. Run `npm pack
|
|
51
|
-
4. Run `git diff --check
|
|
50
|
+
3. Run `npm run release:check` when the package exposes it, or run the equivalent build/test/smoke/audit/pack commands explicitly.
|
|
51
|
+
4. Run `git diff --check` if it is not already included in the release command.
|
|
52
52
|
5. Confirm runtime evidence and review artifacts for M/L/CRITICAL work.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hongmaple0820/scale-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "Executable AI agent governance with workflow gates, evidence, skill/tool orchestration, and traceable HTML artifacts",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
"docs/start",
|
|
48
48
|
"docs/workflow",
|
|
49
49
|
"image",
|
|
50
|
-
"examples/demo-projects/agent-governance-demo"
|
|
50
|
+
"examples/demo-projects/agent-governance-demo",
|
|
51
|
+
"scripts/workflow/setup-smoke.mjs",
|
|
52
|
+
"scripts/workflow/provider-rehearsal.mjs"
|
|
51
53
|
],
|
|
52
54
|
"publishConfig": {
|
|
53
55
|
"access": "public"
|
|
@@ -55,10 +57,15 @@
|
|
|
55
57
|
"scripts": {
|
|
56
58
|
"build": "tsc",
|
|
57
59
|
"dev": "bun --watch src/api/cli.ts",
|
|
58
|
-
"test": "vitest run --reporter dot --pool=forks --
|
|
60
|
+
"test": "vitest run --reporter dot --pool=forks --maxWorkers=4 --minWorkers=1",
|
|
61
|
+
"test:serial": "vitest run --reporter dot --pool=forks --poolOptions.forks.maxForks=1 --poolOptions.forks.minForks=1",
|
|
59
62
|
"typecheck": "tsc --noEmit",
|
|
60
63
|
"lint": "eslint src/**/*.ts",
|
|
61
|
-
"
|
|
64
|
+
"smoke:setup": "node scripts/workflow/setup-smoke.mjs",
|
|
65
|
+
"smoke:providers": "node scripts/workflow/provider-rehearsal.mjs",
|
|
66
|
+
"smoke:gbrain": "node scripts/workflow/provider-rehearsal.mjs --skip-graphify --require-gbrain",
|
|
67
|
+
"smoke:graphify": "node scripts/workflow/provider-rehearsal.mjs --skip-gbrain --require-graphify",
|
|
68
|
+
"release:check": "npm run typecheck && npm run lint && npm test && npm run smoke:setup && npm run build && npm audit --omit=dev && git diff --check && npm pack --dry-run",
|
|
62
69
|
"mcp": "node dist/api/mcp.js",
|
|
63
70
|
"serve": "node dist/api/http.js"
|
|
64
71
|
},
|