@hongmaple0820/scale-engine 0.20.0 → 0.21.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 +36 -0
- package/dist/api/cli.js +181 -1
- package/dist/api/cli.js.map +1 -1
- package/dist/memory/MemoryBrain.js +52 -52
- package/dist/output/GovernanceDashboard.js +44 -44
- package/dist/workflow/GovernanceTemplates.js +26 -0
- package/dist/workflow/GovernanceTemplates.js.map +1 -1
- package/dist/workflow/UpgradeManager.d.ts +140 -0
- package/dist/workflow/UpgradeManager.js +434 -0
- package/dist/workflow/UpgradeManager.js.map +1 -0
- package/docs/README.md +1 -0
- package/docs/start/README.md +5 -1
- package/examples/demo-projects/agent-governance-demo/CONTEXT.md +14 -0
- package/examples/demo-projects/agent-governance-demo/README.md +32 -21
- package/examples/demo-projects/agent-governance-demo/docs/CONTEXT-MAP.md +14 -0
- package/examples/demo-projects/agent-governance-demo/package.json +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,18 @@ SCALE Engine 让 AI Agent 不再只靠“自觉”遵守工程规范。它把探
|
|
|
17
17
|
npm:https://www.npmjs.com/package/@hongmaple0820/scale-engine
|
|
18
18
|
语言:[中文](README.md) | [English](README.en.md)
|
|
19
19
|
|
|
20
|
+
## 🌐 社区与推广
|
|
21
|
+
|
|
22
|
+
### 链接
|
|
23
|
+
|
|
24
|
+
| 平台 | 链接 | 说明 |
|
|
25
|
+
|------|------|------|
|
|
26
|
+
| 🌐 **官网** | [https://scale-os.vercel.app](https://scale-os.vercel.app) | 在线配置器 + 完整文档 |
|
|
27
|
+
| 📦 **GitHub** | [https://github.com/hongmaple0820/scale-os](https://github.com/hongmaple0820/scale-os) | 源码 + Issues + PR |
|
|
28
|
+
| 🔧 **Gitee** | [https://gitee.com/hongmaple/scale-engine](https://gitee.com/hongmaple/scale-engine) | 国内镜像 |
|
|
29
|
+
| 📦 **npm** | [https://www.npmjs.com/package/@hongmaple0820/scale-engine](https://www.npmjs.com/package/@hongmaple0820/scale-engine) | 包下载 |
|
|
30
|
+
| 🧰 **项目脚手架** | [https://github.com/hongmaple0820/project-scaffold](https://github.com/hongmaple0820/project-scaffold) | 工程化工作流实践脚手架 |
|
|
31
|
+
|
|
20
32
|
## 它解决什么问题
|
|
21
33
|
|
|
22
34
|
AI 编码真正难的不是“写代码”,而是持续稳定地遵守工程纪律:
|
|
@@ -90,6 +102,30 @@ scale --version
|
|
|
90
102
|
|
|
91
103
|
需要 Node.js 20 或更高版本。
|
|
92
104
|
|
|
105
|
+
## 更新工作流
|
|
106
|
+
|
|
107
|
+
SCALE 把升级分成三层:CLI 自身、已生成到项目里的 governance pack 文件、第三方 skills/MCP/CLI 能力。默认只检查和生成计划,不自动覆盖用户改过的文件,也不自动安装第三方工具。
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
scale upgrade check --dir .
|
|
111
|
+
scale upgrade plan --dir . --html
|
|
112
|
+
scale upgrade apply --dir . --confirm
|
|
113
|
+
scale upgrade rollback --dir .
|
|
114
|
+
scale tools outdated --dir .
|
|
115
|
+
scale skill outdated --dir .
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
升级原则:
|
|
119
|
+
|
|
120
|
+
- `scale upgrade check` 读取 `.scale/governance.lock.json`,判断当前项目是干净、缺文件、模板过期,还是存在本地改动。
|
|
121
|
+
- `scale upgrade plan` 生成非破坏性计划;遇到用户改过的生成文件时标记 `manual-review`。
|
|
122
|
+
- `scale upgrade apply --confirm` 只恢复缺失生成文件和刷新锁文件,先写 `.scale/backups/upgrade-*` 回滚点。
|
|
123
|
+
- `scale upgrade rollback` 只撤回最近一次 SCALE 管理的安全应用。
|
|
124
|
+
- `scale tools outdated` 和 `scale skill outdated` 只列出更新面、来源、信任等级和安全策略,不做自动安装。
|
|
125
|
+
- 第三方社区来源默认人工评审,高权限桌面自动化默认阻断自动升级。
|
|
126
|
+
|
|
127
|
+
详细说明见 [升级管理](docs/UPGRADE_MANAGEMENT.md)。
|
|
128
|
+
|
|
93
129
|
## Governance Pack
|
|
94
130
|
|
|
95
131
|
在已有项目中安装治理工作流:
|
package/dist/api/cli.js
CHANGED
|
@@ -37,6 +37,7 @@ import { WorkflowEngine } from '../workflow/WorkflowEngine.js';
|
|
|
37
37
|
import { resolveVerificationTargets, } from '../workflow/VerificationProfile.js';
|
|
38
38
|
import { writeGovernanceTemplates } from '../workflow/GovernanceTemplates.js';
|
|
39
39
|
import { computeGovernanceDrift } from '../workflow/GovernanceLock.js';
|
|
40
|
+
import { applyUpgradePlan, createThirdPartyUpdateReport, createUpgradeCheckReport, createUpgradePlanReport, rollbackLatestUpgrade, writeUpgradePlanHtml, } from '../workflow/UpgradeManager.js';
|
|
40
41
|
import { createGovernanceRoiReport } from '../governance/GovernanceRoi.js';
|
|
41
42
|
import { evaluateProgressiveGovernance, normalizeGovernanceMode } from '../governance/ProgressiveGovernance.js';
|
|
42
43
|
import { baselineEngineeringStandards, doctorEngineeringStandards, scanEngineeringStandards, settleEngineeringStandards, } from '../workflow/EngineeringStandards.js';
|
|
@@ -2505,6 +2506,133 @@ const governance = defineCommand({
|
|
|
2505
2506
|
subCommands: { diff: governanceDiff, mode: governanceModeCommand, roi: governanceRoiCommand },
|
|
2506
2507
|
});
|
|
2507
2508
|
// ============================================================================
|
|
2509
|
+
// upgrade command - Safe workflow/template/capability update planning
|
|
2510
|
+
// ============================================================================
|
|
2511
|
+
const upgradeCheck = defineCommand({
|
|
2512
|
+
meta: { name: 'check', description: 'Check SCALE workflow, governance pack, and third-party capability update status' },
|
|
2513
|
+
args: {
|
|
2514
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2515
|
+
'target-version': { type: 'string', description: 'Target SCALE Engine version; defaults to the running CLI version' },
|
|
2516
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
2517
|
+
},
|
|
2518
|
+
run({ args }) {
|
|
2519
|
+
const report = createUpgradeCheckReport({
|
|
2520
|
+
projectDir: args.dir,
|
|
2521
|
+
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
2522
|
+
});
|
|
2523
|
+
if (args.json) {
|
|
2524
|
+
console.log(JSON.stringify(report, null, 2));
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
console.log('SCALE Upgrade Check');
|
|
2528
|
+
console.log(` Project: ${report.projectDir}`);
|
|
2529
|
+
console.log(` Status: ${report.status}`);
|
|
2530
|
+
console.log(` SCALE Engine: ${report.scaleEngine.currentVersion ?? 'none'} -> ${report.scaleEngine.latestVersion}`);
|
|
2531
|
+
console.log(` Governance pack: ${report.governancePack.id ?? 'none'} v${report.governancePack.currentVersion ?? 'none'} -> v${report.governancePack.latestVersion ?? 'none'}`);
|
|
2532
|
+
console.log(` Generated files: ${report.generatedFiles.clean} clean, ${report.generatedFiles.changed} changed, ${report.generatedFiles.missing} missing`);
|
|
2533
|
+
console.log(` Third-party policy: ${report.thirdParty.policy}; review required: ${report.thirdParty.reviewRequired}`);
|
|
2534
|
+
console.log(' Next:');
|
|
2535
|
+
for (const command of report.recommendedCommands)
|
|
2536
|
+
console.log(` ${command}`);
|
|
2537
|
+
},
|
|
2538
|
+
});
|
|
2539
|
+
const upgradePlan = defineCommand({
|
|
2540
|
+
meta: { name: 'plan', description: 'Create a non-destructive SCALE upgrade plan' },
|
|
2541
|
+
args: {
|
|
2542
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2543
|
+
'target-version': { type: 'string', description: 'Target SCALE Engine version; defaults to the running CLI version' },
|
|
2544
|
+
html: { type: 'boolean', default: false, description: 'Write .scale/reports/upgrade-plan.html' },
|
|
2545
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
2546
|
+
},
|
|
2547
|
+
run({ args }) {
|
|
2548
|
+
const report = createUpgradePlanReport({
|
|
2549
|
+
projectDir: args.dir,
|
|
2550
|
+
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
2551
|
+
});
|
|
2552
|
+
const htmlPath = args.html ? writeUpgradePlanHtml(report) : undefined;
|
|
2553
|
+
if (args.json) {
|
|
2554
|
+
console.log(JSON.stringify({ ...report, htmlPath }, null, 2));
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
console.log('SCALE Upgrade Plan');
|
|
2558
|
+
console.log(` Project: ${report.projectDir}`);
|
|
2559
|
+
console.log(` Status: ${report.status}`);
|
|
2560
|
+
console.log(` Apply mode: ${report.applyMode}`);
|
|
2561
|
+
if (report.blockers.length > 0) {
|
|
2562
|
+
console.log(' Blockers:');
|
|
2563
|
+
for (const blocker of report.blockers)
|
|
2564
|
+
console.log(` [${blocker.code}] ${blocker.path ?? ''} ${blocker.message}`);
|
|
2565
|
+
}
|
|
2566
|
+
console.log(' Steps:');
|
|
2567
|
+
for (const step of report.steps) {
|
|
2568
|
+
const path = step.path ? ` ${step.path}` : '';
|
|
2569
|
+
const command = step.command ? ` -> ${step.command}` : '';
|
|
2570
|
+
console.log(` [${step.risk}] ${step.action}${path}: ${step.reason}${command}`);
|
|
2571
|
+
}
|
|
2572
|
+
if (htmlPath)
|
|
2573
|
+
console.log(` HTML: ${htmlPath}`);
|
|
2574
|
+
},
|
|
2575
|
+
});
|
|
2576
|
+
const upgradeApply = defineCommand({
|
|
2577
|
+
meta: { name: 'apply', description: 'Guarded entrypoint for applying an upgrade plan' },
|
|
2578
|
+
args: {
|
|
2579
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2580
|
+
confirm: { type: 'boolean', default: false, description: 'Confirm that the current plan was reviewed' },
|
|
2581
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
2582
|
+
},
|
|
2583
|
+
run({ args }) {
|
|
2584
|
+
const result = applyUpgradePlan({
|
|
2585
|
+
projectDir: args.dir,
|
|
2586
|
+
confirm: isTruthyFlag(args.confirm),
|
|
2587
|
+
});
|
|
2588
|
+
if (args.json) {
|
|
2589
|
+
console.log(JSON.stringify(result, null, 2));
|
|
2590
|
+
if (!result.ok)
|
|
2591
|
+
process.exitCode = 1;
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
console.log('SCALE Upgrade Apply');
|
|
2595
|
+
console.log(` Applied: ${result.applied}`);
|
|
2596
|
+
console.log(` Reason: ${result.reason}`);
|
|
2597
|
+
console.log(` Apply mode: ${result.plan.applyMode}`);
|
|
2598
|
+
if (result.backup)
|
|
2599
|
+
console.log(` Backup: ${result.backup.manifestPath}`);
|
|
2600
|
+
for (const path of result.changedFiles)
|
|
2601
|
+
console.log(` changed: ${path}`);
|
|
2602
|
+
if (!result.ok)
|
|
2603
|
+
process.exitCode = 1;
|
|
2604
|
+
},
|
|
2605
|
+
});
|
|
2606
|
+
const upgradeRollback = defineCommand({
|
|
2607
|
+
meta: { name: 'rollback', description: 'Explain rollback state for SCALE upgrades' },
|
|
2608
|
+
args: {
|
|
2609
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2610
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
2611
|
+
},
|
|
2612
|
+
run({ args }) {
|
|
2613
|
+
const result = rollbackLatestUpgrade({ projectDir: args.dir });
|
|
2614
|
+
if (args.json) {
|
|
2615
|
+
console.log(JSON.stringify(result, null, 2));
|
|
2616
|
+
if (!result.ok)
|
|
2617
|
+
process.exitCode = 1;
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
console.log('SCALE Upgrade Rollback');
|
|
2621
|
+
console.log(` Applied: ${result.applied}`);
|
|
2622
|
+
console.log(` Reason: ${result.reason}`);
|
|
2623
|
+
if (result.backup)
|
|
2624
|
+
console.log(` Backup: ${result.backup.manifestPath}`);
|
|
2625
|
+
for (const path of result.restoredFiles)
|
|
2626
|
+
console.log(` restored: ${path}`);
|
|
2627
|
+
if (!result.ok)
|
|
2628
|
+
process.exitCode = 1;
|
|
2629
|
+
},
|
|
2630
|
+
});
|
|
2631
|
+
const upgrade = defineCommand({
|
|
2632
|
+
meta: { name: 'upgrade', description: 'Safe update planning for SCALE workflow, generated templates, skills, MCP, and CLI tools' },
|
|
2633
|
+
subCommands: { check: upgradeCheck, plan: upgradePlan, apply: upgradeApply, rollback: upgradeRollback },
|
|
2634
|
+
});
|
|
2635
|
+
// ============================================================================
|
|
2508
2636
|
// assets command - Resource lifecycle governance
|
|
2509
2637
|
// ============================================================================
|
|
2510
2638
|
const assetsScan = defineCommand({
|
|
@@ -4167,6 +4295,30 @@ const skillRecommendCommand = defineCommand({
|
|
|
4167
4295
|
console.log(` - ${reason}`);
|
|
4168
4296
|
},
|
|
4169
4297
|
});
|
|
4298
|
+
const skillOutdatedCommand = defineCommand({
|
|
4299
|
+
meta: { name: 'outdated', description: 'List skill update surfaces without installing or upgrading anything' },
|
|
4300
|
+
args: {
|
|
4301
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
4302
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
4303
|
+
},
|
|
4304
|
+
run({ args }) {
|
|
4305
|
+
const report = createThirdPartyUpdateReport('skill');
|
|
4306
|
+
if (args.json) {
|
|
4307
|
+
console.log(JSON.stringify({ ...report, projectDir: resolve(String(args.dir ?? PROJECT_DIR)) }, null, 2));
|
|
4308
|
+
return;
|
|
4309
|
+
}
|
|
4310
|
+
console.log('\nSCALE Skill Outdated');
|
|
4311
|
+
console.log(` Policy: ${report.policy}`);
|
|
4312
|
+
console.log(` Skills: ${report.summary.total}`);
|
|
4313
|
+
console.log(` Review required: ${report.reviewRequired}`);
|
|
4314
|
+
for (const entry of report.entries) {
|
|
4315
|
+
console.log(` [${entry.updatePolicy}] ${entry.id} trust=${entry.trust} latest=${entry.latestVersion}`);
|
|
4316
|
+
if (entry.source)
|
|
4317
|
+
console.log(` source: ${entry.source}`);
|
|
4318
|
+
console.log(` reason: ${entry.reason}`);
|
|
4319
|
+
}
|
|
4320
|
+
},
|
|
4321
|
+
});
|
|
4170
4322
|
const skill = defineCommand({
|
|
4171
4323
|
meta: { name: 'skill', description: 'Skill discovery and management' },
|
|
4172
4324
|
subCommands: {
|
|
@@ -4178,6 +4330,7 @@ const skill = defineCommand({
|
|
|
4178
4330
|
safety: skillSafetyCommand,
|
|
4179
4331
|
radar: skillRadarCommand,
|
|
4180
4332
|
recommend: skillRecommendCommand,
|
|
4333
|
+
outdated: skillOutdatedCommand,
|
|
4181
4334
|
},
|
|
4182
4335
|
});
|
|
4183
4336
|
// ============================================================================
|
|
@@ -4423,9 +4576,34 @@ const toolEvidenceCommand = defineCommand({
|
|
|
4423
4576
|
process.exitCode = 1;
|
|
4424
4577
|
},
|
|
4425
4578
|
});
|
|
4579
|
+
const toolOutdatedCommand = defineCommand({
|
|
4580
|
+
meta: { name: 'outdated', description: 'List MCP, browser, desktop, and external CLI update surfaces without installing anything' },
|
|
4581
|
+
args: {
|
|
4582
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
4583
|
+
json: { type: 'boolean', default: false, description: 'Print JSON output' },
|
|
4584
|
+
},
|
|
4585
|
+
run({ args }) {
|
|
4586
|
+
const report = createThirdPartyUpdateReport(['cli', 'mcp', 'browser', 'desktop']);
|
|
4587
|
+
if (args.json) {
|
|
4588
|
+
console.log(JSON.stringify({ ...report, projectDir: resolve(String(args.dir ?? PROJECT_DIR)) }, null, 2));
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
4591
|
+
console.log('\nSCALE Tool Outdated');
|
|
4592
|
+
console.log(` Policy: ${report.policy}`);
|
|
4593
|
+
console.log(` Tools: ${report.summary.total}`);
|
|
4594
|
+
console.log(` Review required: ${report.reviewRequired}`);
|
|
4595
|
+
console.log(` Blocked: ${report.summary.blocked}`);
|
|
4596
|
+
for (const entry of report.entries) {
|
|
4597
|
+
console.log(` [${entry.updatePolicy}] ${entry.id} category=${entry.category} trust=${entry.trust} latest=${entry.latestVersion}`);
|
|
4598
|
+
if (entry.source)
|
|
4599
|
+
console.log(` source: ${entry.source}`);
|
|
4600
|
+
console.log(` reason: ${entry.reason}`);
|
|
4601
|
+
}
|
|
4602
|
+
},
|
|
4603
|
+
});
|
|
4426
4604
|
const tool = defineCommand({
|
|
4427
4605
|
meta: { name: 'tool', description: 'Skills, MCP, browser, desktop, and external CLI governance' },
|
|
4428
|
-
subCommands: { policy: toolPolicyCommand, doctor: toolDoctorCommand, plan: toolPlanCommand, run: toolRunCommand, evidence: toolEvidenceCommand },
|
|
4606
|
+
subCommands: { policy: toolPolicyCommand, doctor: toolDoctorCommand, plan: toolPlanCommand, run: toolRunCommand, evidence: toolEvidenceCommand, outdated: toolOutdatedCommand },
|
|
4429
4607
|
});
|
|
4430
4608
|
// ============================================================================
|
|
4431
4609
|
// agent commands — Multi-Agent 协作系统 (Phase 9)
|
|
@@ -4604,6 +4782,7 @@ const main = defineCommand({
|
|
|
4604
4782
|
evolve,
|
|
4605
4783
|
stats,
|
|
4606
4784
|
preflight,
|
|
4785
|
+
upgrade,
|
|
4607
4786
|
governance,
|
|
4608
4787
|
codegraph,
|
|
4609
4788
|
eval: evalCommand,
|
|
@@ -4621,6 +4800,7 @@ const main = defineCommand({
|
|
|
4621
4800
|
diagnose,
|
|
4622
4801
|
tdd,
|
|
4623
4802
|
tool,
|
|
4803
|
+
tools: tool,
|
|
4624
4804
|
skill,
|
|
4625
4805
|
skills: skill,
|
|
4626
4806
|
agent,
|