@hongmaple0820/scale-engine 0.26.0 → 0.27.1
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 +71 -3
- package/README.md +71 -3
- package/dist/api/cli.js +269 -12
- package/dist/api/cli.js.map +1 -1
- package/dist/cli/phaseCommands.js +8 -8
- package/dist/cli/phaseCommands.js.map +1 -1
- package/dist/context/ContextBudget.d.ts +14 -0
- package/dist/context/ContextBudget.js +50 -14
- package/dist/context/ContextBudget.js.map +1 -1
- package/dist/context/ContextCompiler.d.ts +34 -0
- package/dist/context/ContextCompiler.js +120 -0
- package/dist/context/ContextCompiler.js.map +1 -0
- package/dist/eval/WorkflowEval.js +4 -6
- package/dist/eval/WorkflowEval.js.map +1 -1
- package/dist/governance/GovernanceRoi.d.ts +6 -1
- package/dist/governance/GovernanceRoi.js +32 -0
- package/dist/governance/GovernanceRoi.js.map +1 -1
- package/dist/guardrails/DependencyAuditor.js +38 -0
- package/dist/guardrails/DependencyAuditor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/AiOsRuntime.d.ts +269 -0
- package/dist/runtime/AiOsRuntime.js +840 -0
- package/dist/runtime/AiOsRuntime.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/skills/routing/SkillPlanner.js +91 -3
- package/dist/skills/routing/SkillPlanner.js.map +1 -1
- package/dist/skills/routing/SkillRoutingTypes.d.ts +17 -0
- package/dist/tools/SafeCommandRunner.d.ts +16 -0
- package/dist/tools/SafeCommandRunner.js +83 -0
- package/dist/tools/SafeCommandRunner.js.map +1 -0
- package/dist/workflow/UpgradeManager.d.ts +4 -1
- package/dist/workflow/UpgradeManager.js +26 -0
- package/dist/workflow/UpgradeManager.js.map +1 -1
- package/dist/workflow/gates/GateSystem.js +3 -9
- package/dist/workflow/gates/GateSystem.js.map +1 -1
- package/docs/AI_ENGINEERING_OS_POSITIONING.md +560 -0
- package/docs/CONTEXT_BUDGET.md +43 -1
- package/docs/DEPENDENCY_AUDIT.md +29 -0
- package/docs/MEMORY_FABRIC.md +2 -0
- package/docs/README.md +1 -0
- package/docs/SKILL_RADAR.md +13 -0
- package/package.json +9 -2
package/README.en.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://img.shields.io/badge/version-0.
|
|
2
|
+
<img src="https://img.shields.io/badge/version-0.27.1-orange?style=flat-square" alt="version" />
|
|
3
3
|
<img src="https://img.shields.io/badge/platforms-22-blue?style=flat-square" alt="platforms" />
|
|
4
4
|
<img src="https://img.shields.io/badge/agents-12-blue?style=flat-square" alt="agents" />
|
|
5
5
|
<img src="https://img.shields.io/badge/workflows-10-green?style=flat-square" alt="workflows" />
|
|
6
6
|
<img src="https://img.shields.io/badge/detectors-19-red?style=flat-square" alt="detectors" />
|
|
7
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.
|
|
8
|
+
<img src="https://img.shields.io/badge/npm-0.27.1-cb3837?style=flat-square&logo=npm" alt="npm" />
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
# SCALE Engine v0.
|
|
11
|
+
# SCALE Engine v0.27.1
|
|
12
12
|
|
|
13
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
14
|
|
|
@@ -17,6 +17,74 @@ Mirror: https://gitee.com/hongmaple/scale-engine
|
|
|
17
17
|
npm: https://www.npmjs.com/package/@hongmaple0820/scale-engine
|
|
18
18
|
Language: [English](README.en.md) | [Chinese](README.md)
|
|
19
19
|
|
|
20
|
+
## 0.27.0 AI OS Runtime
|
|
21
|
+
|
|
22
|
+
0.27.0 turns the AI Engineering OS direction into one executable entry point: `scale ai-os plan`. It creates a unified task plan with progressive governance mode, Context Compiler budget output, Memory Provider recall, Skill Routing execution steps, and Governance ROI. An agent can see which context to load, which capabilities to use, what evidence is required, and which risks escalate gates before it starts the task.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
scale ai-os plan \
|
|
26
|
+
--task-id TASK-123 \
|
|
27
|
+
--task "Fix OAuth callback auth token handling and verify browser callback flow" \
|
|
28
|
+
--level L \
|
|
29
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
30
|
+
--budget 8000 \
|
|
31
|
+
--json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This is not a claim that SCALE replaces human judgment. It is the first testable, explainable, and measurable runtime planning layer for the AI Engineering OS direction.
|
|
35
|
+
|
|
36
|
+
The near-term target is a one-week push from `ai-os plan` to a runnable beta loop: `ai-os run`, memory providers, Context Compiler v2, Skill Router v2, Adaptive Workflow, Failure Learning, Dashboard, migration, and benchmark evidence. The long-range target is an AI Engineering OS beta in 8-12 weeks, a stable governance runtime in 3-6 months, and a cross-agent engineering operating layer in 6-12 months. See the full roadmap in [AI Engineering OS Strategic Positioning](docs/AI_ENGINEERING_OS_POSITIONING.md).
|
|
37
|
+
|
|
38
|
+
The current 0.27.0 beta runtime now includes the controlled run entry point: `scale ai-os run --dry-run` reuses the unified plan, produces execution steps, evidence requirements, next actions, and writes the run report to `.scale/ai-os/runs/`. When real verification is required, use guarded mode with explicit `--verify` commands. Commands run through the safe runner by default and are recorded as runtime evidence; failed verification returns a `blocked` JSON report and a non-zero CLI exit code.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
scale ai-os run \
|
|
42
|
+
--task-id TASK-123 \
|
|
43
|
+
--task "Fix OAuth callback auth token handling and verify browser callback flow" \
|
|
44
|
+
--level L \
|
|
45
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
46
|
+
--dry-run \
|
|
47
|
+
--json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
scale ai-os run \
|
|
52
|
+
--task-id TASK-123 \
|
|
53
|
+
--task "Fix OAuth callback auth token handling and verify browser callback flow" \
|
|
54
|
+
--level L \
|
|
55
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
56
|
+
--mode guarded \
|
|
57
|
+
--verify "npm test -- tests/auth/oauth.test.ts" \
|
|
58
|
+
--json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
After multiple runs, use the dashboard to summarize ready/blocked runs, verification commands, pending evidence, and failure learning:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
scale ai-os dashboard --json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Before a release or milestone review, run the fixed benchmark scenarios to compare context, memory, skill, governance, and dashboard metrics:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
scale ai-os benchmark --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Before adopting the 0.27.0 beta runtime in an existing project, create or verify the AI OS runtime state directories:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
scale ai-os migrate --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For project-level readiness, run the AI OS doctor. It checks runtime directories, run history, dashboard health, benchmark freshness, and prints the next required action in English or Chinese:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
scale ai-os doctor --lang en --json
|
|
83
|
+
scale ai-os doctor --lang zh
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The standard upgrade path also surfaces this readiness. `scale upgrade check --json` now includes the AI OS doctor result, and `scale upgrade plan --json` adds explicit `ai-os migrate` / `ai-os doctor` steps when a project has not yet adopted the runtime state.
|
|
87
|
+
|
|
20
88
|
## Community
|
|
21
89
|
|
|
22
90
|
SCALE Engine is an engineering workflow governance project for real AI-agent delivery. Contributions, issues, PRs, governance-pack ideas, and field reports are welcome through the source repositories. Chinese users can also follow the WeChat public account for updates, examples, and community entry points.
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://img.shields.io/badge/version-0.
|
|
2
|
+
<img src="https://img.shields.io/badge/version-0.27.1-orange?style=flat-square" alt="version" />
|
|
3
3
|
<img src="https://img.shields.io/badge/platforms-22-blue?style=flat-square" alt="platforms" />
|
|
4
4
|
<img src="https://img.shields.io/badge/agents-12-blue?style=flat-square" alt="agents" />
|
|
5
5
|
<img src="https://img.shields.io/badge/workflows-10-green?style=flat-square" alt="workflows" />
|
|
6
6
|
<img src="https://img.shields.io/badge/detectors-19-red?style=flat-square" alt="detectors" />
|
|
7
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.
|
|
8
|
+
<img src="https://img.shields.io/badge/npm-0.27.1-cb3837?style=flat-square&logo=npm" alt="npm" />
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
# SCALE Engine v0.
|
|
11
|
+
# SCALE Engine v0.27.1
|
|
12
12
|
|
|
13
13
|
SCALE Engine 让 AI Agent 不再只靠“自觉”遵守工程规范。它把探索、规划、实现、验证、评审、发版这些要求变成可执行的命令、门禁和证据文件,让人类可以看见 Agent 做了什么、跳过了什么、为什么能交付或不能交付。
|
|
14
14
|
|
|
@@ -17,6 +17,74 @@ 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
|
+
## 0.27.0 AI OS Runtime
|
|
21
|
+
|
|
22
|
+
0.27.0 把战略方向落成了一个可执行入口:`scale ai-os plan`。它会在一次命令里同时生成风险治理模式、Context Compiler 预算结果、Memory Provider 召回结果、Skill Routing 执行计划和 Governance ROI,让 Agent 在开始任务前就知道应该加载什么上下文、调用什么能力、补什么证据、哪些风险会升级门禁。
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
scale ai-os plan \
|
|
26
|
+
--task-id TASK-123 \
|
|
27
|
+
--task "修复 OAuth callback auth token 并验证浏览器回调流程" \
|
|
28
|
+
--level L \
|
|
29
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
30
|
+
--budget 8000 \
|
|
31
|
+
--json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
这不是“完全替代人类判断”的声明;它是把 AI Engineering OS 的核心闭环先做成可测试、可解释、可度量的运行时规划层。
|
|
35
|
+
|
|
36
|
+
短期目标是用一周冲刺把 `ai-os plan` 推进到可运行的 beta 闭环:`ai-os run`、记忆供应商、Context Compiler v2、Skill Router v2、Adaptive Workflow、Failure Learning、Dashboard、迁移和 benchmark。远景目标是 8-12 周形成 AI Engineering OS beta,3-6 个月进入稳定治理运行时,6-12 个月沉淀为跨 Agent 的工程操作层。完整路线图见 [AI Engineering OS 战略定位](docs/AI_ENGINEERING_OS_POSITIONING.md)。
|
|
37
|
+
|
|
38
|
+
当前 0.27.0 beta runtime 已包含受控运行入口:`scale ai-os run --dry-run` 会复用统一 plan,生成执行步骤、证据要求、下一步动作,并把运行报告写入 `.scale/ai-os/runs/`。需要真实验证时可切到 guarded 模式并显式传入 `--verify`,命令默认通过 safe runner 执行并写入 runtime evidence;验证失败时 JSON 报告会返回 `blocked`,CLI 退出码为非零。
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
scale ai-os run \
|
|
42
|
+
--task-id TASK-123 \
|
|
43
|
+
--task "修复 OAuth callback auth token 并验证浏览器回调流程" \
|
|
44
|
+
--level L \
|
|
45
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
46
|
+
--dry-run \
|
|
47
|
+
--json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
scale ai-os run \
|
|
52
|
+
--task-id TASK-123 \
|
|
53
|
+
--task "修复 OAuth callback auth token 并验证浏览器回调流程" \
|
|
54
|
+
--level L \
|
|
55
|
+
--files src/auth/oauth.ts,src/ui/callback.tsx \
|
|
56
|
+
--mode guarded \
|
|
57
|
+
--verify "npm test -- tests/auth/oauth.test.ts" \
|
|
58
|
+
--json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
运行多次后可以用 dashboard 汇总 ready/blocked、验证命令、pending evidence 和 failure learning:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
scale ai-os dashboard --json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
发版或阶段验收前,用 benchmark 固定样例对比 context、memory、skill、governance 和 dashboard 指标:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
scale ai-os benchmark --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
旧项目接入 0.27.0 beta runtime 前,可先创建或核验 AI OS 运行态目录:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
scale ai-os migrate --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
项目级就绪检查可使用 AI OS doctor。它会检查运行态目录、运行历史、dashboard 健康度、benchmark 新鲜度,并按中英文输出下一步动作:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
scale ai-os doctor --lang zh --json
|
|
83
|
+
scale ai-os doctor --lang en
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
标准升级入口也会带出这项检查。`scale upgrade check --json` 会包含 AI OS doctor 结果;当项目尚未接入运行态目录时,`scale upgrade plan --json` 会补充明确的 `ai-os migrate` / `ai-os doctor` 步骤。
|
|
87
|
+
|
|
20
88
|
## 先怎么学
|
|
21
89
|
|
|
22
90
|
如果你第一次接触 SCALE,不要从完整命令列表开始读。按这个顺序更容易掌握:
|
package/dist/api/cli.js
CHANGED
|
@@ -60,11 +60,12 @@ import { evaluateToolEvidenceGate } from '../tools/ToolEvidenceGate.js';
|
|
|
60
60
|
import { ToolEvidenceStore } from '../tools/ToolEvidenceStore.js';
|
|
61
61
|
import { ToolOrchestrator } from '../tools/ToolOrchestrator.js';
|
|
62
62
|
import { loadToolPolicy, toolPolicyTemplate } from '../tools/ToolPolicy.js';
|
|
63
|
+
import { runSafeCommand } from '../tools/SafeCommandRunner.js';
|
|
63
64
|
import { doctorHtmlArtifacts, renderHtmlArtifact, resolveHtmlArtifactForOpen, settleHtmlArtifacts, } from '../output/HTMLArtifactLayer.js';
|
|
64
65
|
import { renderGovernanceDashboard } from '../output/GovernanceDashboard.js';
|
|
65
66
|
import { cleanupWorkspaceLifecycle, inspectWorkspaceLifecycle, } from '../workflow/WorkspaceLifecycle.js';
|
|
66
67
|
import { inspectWorkspaceSafety } from '../workflow/WorkspaceSafety.js';
|
|
67
|
-
import { RuntimeEvidenceLedger, SessionLedger, doctorRuntimeEvidence, evaluateFinalReportReadiness, } from '../runtime/index.js';
|
|
68
|
+
import { RuntimeEvidenceLedger, SessionLedger, createAiOsBenchmark, createAiOsDashboard, createAiOsDoctor, createAiOsMigration, createAiOsPlan, createAiOsRun, doctorRuntimeEvidence, evaluateFinalReportReadiness, } from '../runtime/index.js';
|
|
68
69
|
import { MemoryFabric, MemoryBrain, doctorMemoryFabric, renderContextPackMarkdown, renderMemoryLearningCandidateMarkdown, inspectMemoryProviders, recallMemoryProviders, settleMemoryLearning, writeMemoryProvidersConfig, } from '../memory/index.js';
|
|
69
70
|
import { resolveWorkspaceTopology, workspaceTopologyPath, workspaceTopologyTemplate, } from '../workflow/WorkspaceTopology.js';
|
|
70
71
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
@@ -663,14 +664,13 @@ const verifyTask = defineCommand({
|
|
|
663
664
|
};
|
|
664
665
|
// Helper: run command and capture exit code
|
|
665
666
|
const runCmd = async (cmd) => {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
});
|
|
667
|
+
try {
|
|
668
|
+
const result = await runSafeCommand(cmd);
|
|
669
|
+
return { exitCode: result.exitCode, output: [result.stdout, result.stderr].filter(Boolean).join('\n') };
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
return { exitCode: 1, output: error instanceof Error ? error.message : String(error) };
|
|
673
|
+
}
|
|
674
674
|
};
|
|
675
675
|
// Run build
|
|
676
676
|
if (!args['skip-build']) {
|
|
@@ -2907,6 +2907,246 @@ const governance = defineCommand({
|
|
|
2907
2907
|
meta: { name: 'governance', description: 'Governance template pack tools' },
|
|
2908
2908
|
subCommands: { diff: governanceDiff, mode: governanceModeCommand, roi: governanceRoiCommand },
|
|
2909
2909
|
});
|
|
2910
|
+
const aiOsPlanCommand = defineCommand({
|
|
2911
|
+
meta: { name: 'plan', description: 'Create a unified AI OS runtime plan for governance, context, memory, skills, and ROI' },
|
|
2912
|
+
args: {
|
|
2913
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2914
|
+
'task-id': { type: 'string', description: 'Task id' },
|
|
2915
|
+
task: { type: 'string', required: true, description: 'Task or requirement description' },
|
|
2916
|
+
level: { type: 'string', default: 'M', description: 'Task level: S, M, L, or CRITICAL' },
|
|
2917
|
+
files: { type: 'string', description: 'Comma-separated changed or target files' },
|
|
2918
|
+
services: { type: 'string', description: 'Comma-separated affected services' },
|
|
2919
|
+
budget: { type: 'string', description: 'Maximum estimated tokens for the context compiler' },
|
|
2920
|
+
'requested-mode': { type: 'string', description: 'Requested governance mode: minimal, standard, expanded, or critical' },
|
|
2921
|
+
json: { type: 'boolean', default: false },
|
|
2922
|
+
},
|
|
2923
|
+
async run({ args }) {
|
|
2924
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
2925
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
2926
|
+
const plan = await createAiOsPlan({
|
|
2927
|
+
projectDir,
|
|
2928
|
+
scaleDir,
|
|
2929
|
+
taskId: args['task-id'] ? String(args['task-id']) : undefined,
|
|
2930
|
+
task: String(args.task),
|
|
2931
|
+
level: normalizeTaskArtifactLevel(args.level),
|
|
2932
|
+
files: parseCommaList(args.files),
|
|
2933
|
+
services: parseCommaList(args.services),
|
|
2934
|
+
budget: parsePositiveIntArg(args.budget, '--budget'),
|
|
2935
|
+
requestedMode: normalizeGovernanceMode(args['requested-mode']),
|
|
2936
|
+
});
|
|
2937
|
+
if (args.json) {
|
|
2938
|
+
console.log(JSON.stringify(plan, null, 2));
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2941
|
+
console.log('SCALE AI OS Runtime Plan');
|
|
2942
|
+
console.log(` Version: ${plan.version}`);
|
|
2943
|
+
console.log(` Task: ${plan.task.taskId ?? 'n/a'} ${plan.task.task}`);
|
|
2944
|
+
console.log(` Governance: ${plan.governance.effectiveMode}`);
|
|
2945
|
+
console.log(` Context: ${plan.context.totalEstimatedTokens}/${plan.context.task.budget} tokens; saved ${plan.context.compiler?.estimatedTokenSavings ?? 0}`);
|
|
2946
|
+
console.log(` Memory: ${plan.memory.items.length} item(s); providers ${plan.memory.providerOrder.join(' -> ')}`);
|
|
2947
|
+
console.log(` Skill steps: ${plan.skillPlan.executionPlan.steps.length}`);
|
|
2948
|
+
console.log(` ROI: ${plan.roi.summary.recommendation}`);
|
|
2949
|
+
for (const recommendation of plan.recommendations)
|
|
2950
|
+
console.log(` recommendation: ${recommendation}`);
|
|
2951
|
+
},
|
|
2952
|
+
});
|
|
2953
|
+
const aiOsRunCommand = defineCommand({
|
|
2954
|
+
meta: { name: 'run', description: 'Run the AI OS beta loop in dry-run or guarded mode and write an execution report' },
|
|
2955
|
+
args: {
|
|
2956
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
2957
|
+
'task-id': { type: 'string', description: 'Task id' },
|
|
2958
|
+
task: { type: 'string', required: true, description: 'Task or requirement description' },
|
|
2959
|
+
level: { type: 'string', default: 'M', description: 'Task level: S, M, L, or CRITICAL' },
|
|
2960
|
+
files: { type: 'string', description: 'Comma-separated changed or target files' },
|
|
2961
|
+
services: { type: 'string', description: 'Comma-separated affected services' },
|
|
2962
|
+
budget: { type: 'string', description: 'Maximum estimated tokens for the context compiler' },
|
|
2963
|
+
'requested-mode': { type: 'string', description: 'Requested governance mode: minimal, standard, expanded, or critical' },
|
|
2964
|
+
verify: { type: 'string', description: 'Comma-separated guarded verification commands to run without shell by default' },
|
|
2965
|
+
timeout: { type: 'string', description: 'Verification command timeout in milliseconds' },
|
|
2966
|
+
mode: { type: 'string', description: 'Run mode: dry-run or guarded' },
|
|
2967
|
+
'dry-run': { type: 'boolean', default: false, description: 'Force dry-run mode without executing external commands' },
|
|
2968
|
+
'allow-shell': { type: 'boolean', default: false, description: 'Allow shell execution for trusted local guarded runs' },
|
|
2969
|
+
json: { type: 'boolean', default: false },
|
|
2970
|
+
},
|
|
2971
|
+
async run({ args }) {
|
|
2972
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
2973
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
2974
|
+
const report = await createAiOsRun({
|
|
2975
|
+
projectDir,
|
|
2976
|
+
scaleDir,
|
|
2977
|
+
taskId: args['task-id'] ? String(args['task-id']) : undefined,
|
|
2978
|
+
task: String(args.task),
|
|
2979
|
+
level: normalizeTaskArtifactLevel(args.level),
|
|
2980
|
+
files: parseCommaList(args.files),
|
|
2981
|
+
services: parseCommaList(args.services),
|
|
2982
|
+
budget: parsePositiveIntArg(args.budget, '--budget'),
|
|
2983
|
+
requestedMode: normalizeGovernanceMode(args['requested-mode']),
|
|
2984
|
+
mode: normalizeAiOsRunMode(args.mode, Boolean(args['dry-run'])),
|
|
2985
|
+
verificationCommands: parseCommaList(args.verify),
|
|
2986
|
+
commandTimeoutMs: parsePositiveIntArg(args.timeout, '--timeout'),
|
|
2987
|
+
allowShell: Boolean(args['allow-shell']),
|
|
2988
|
+
});
|
|
2989
|
+
if (args.json) {
|
|
2990
|
+
console.log(JSON.stringify(report, null, 2));
|
|
2991
|
+
if (report.status === 'blocked')
|
|
2992
|
+
process.exitCode = 1;
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
console.log('SCALE AI OS Runtime Run');
|
|
2996
|
+
console.log(` Version: ${report.version}`);
|
|
2997
|
+
console.log(` Mode: ${report.mode}`);
|
|
2998
|
+
console.log(` Status: ${report.status}`);
|
|
2999
|
+
console.log(` Task: ${report.plan.task.taskId ?? 'n/a'} ${report.plan.task.task}`);
|
|
3000
|
+
console.log(` Steps: ${report.steps.filter(step => step.status === 'passed').length} passed, ${report.steps.filter(step => step.status === 'planned').length} planned, ${report.steps.filter(step => step.status === 'blocked').length} blocked`);
|
|
3001
|
+
console.log(` Verification: ${report.verification.commands.filter(command => command.status === 'passed').length}/${report.verification.commands.length} passed`);
|
|
3002
|
+
console.log(` Evidence: ${report.evidence.produced.length} produced, ${report.evidence.pending.length} pending`);
|
|
3003
|
+
console.log(` Report: ${report.artifacts.runReport}`);
|
|
3004
|
+
for (const action of report.nextActions.slice(0, 6))
|
|
3005
|
+
console.log(` next: ${action}`);
|
|
3006
|
+
if (report.status === 'blocked')
|
|
3007
|
+
process.exitCode = 1;
|
|
3008
|
+
},
|
|
3009
|
+
});
|
|
3010
|
+
const aiOsDashboardCommand = defineCommand({
|
|
3011
|
+
meta: { name: 'dashboard', description: 'Summarize AI OS runtime run reports and verification health' },
|
|
3012
|
+
args: {
|
|
3013
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3014
|
+
limit: { type: 'string', description: 'Maximum latest run rows to include' },
|
|
3015
|
+
json: { type: 'boolean', default: false },
|
|
3016
|
+
},
|
|
3017
|
+
run({ args }) {
|
|
3018
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3019
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3020
|
+
const dashboard = createAiOsDashboard({
|
|
3021
|
+
projectDir,
|
|
3022
|
+
scaleDir,
|
|
3023
|
+
limit: parsePositiveIntArg(args.limit, '--limit'),
|
|
3024
|
+
});
|
|
3025
|
+
if (args.json) {
|
|
3026
|
+
console.log(JSON.stringify(dashboard, null, 2));
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
3029
|
+
console.log('SCALE AI OS Dashboard');
|
|
3030
|
+
console.log(` Health: ${dashboard.health.status} (${dashboard.health.score})`);
|
|
3031
|
+
console.log(` Runs: ${dashboard.summary.totalRuns} total, ${dashboard.summary.readyRuns} ready, ${dashboard.summary.blockedRuns} blocked`);
|
|
3032
|
+
console.log(` Verification: ${dashboard.summary.verificationCommands} command(s), ${dashboard.summary.failedVerificationCommands} failed`);
|
|
3033
|
+
console.log(` Failure learning: ${dashboard.summary.failureLearningCandidates} candidate(s)`);
|
|
3034
|
+
for (const run of dashboard.latestRuns) {
|
|
3035
|
+
console.log(` [${run.status}] ${run.taskId ?? 'n/a'} ${run.task}`);
|
|
3036
|
+
}
|
|
3037
|
+
for (const recommendation of dashboard.recommendations)
|
|
3038
|
+
console.log(` recommendation: ${recommendation}`);
|
|
3039
|
+
for (const warning of dashboard.warnings)
|
|
3040
|
+
console.log(` warning: ${warning}`);
|
|
3041
|
+
},
|
|
3042
|
+
});
|
|
3043
|
+
const aiOsBenchmarkCommand = defineCommand({
|
|
3044
|
+
meta: { name: 'benchmark', description: 'Run fixed AI OS beta benchmark scenarios for context, memory, skill, governance, and dashboard metrics' },
|
|
3045
|
+
args: {
|
|
3046
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3047
|
+
budget: { type: 'string', description: 'Scenario context budget' },
|
|
3048
|
+
json: { type: 'boolean', default: false },
|
|
3049
|
+
},
|
|
3050
|
+
async run({ args }) {
|
|
3051
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3052
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3053
|
+
const benchmark = await createAiOsBenchmark({
|
|
3054
|
+
projectDir,
|
|
3055
|
+
scaleDir,
|
|
3056
|
+
budget: parsePositiveIntArg(args.budget, '--budget'),
|
|
3057
|
+
});
|
|
3058
|
+
if (args.json) {
|
|
3059
|
+
console.log(JSON.stringify(benchmark, null, 2));
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
console.log('SCALE AI OS Benchmark');
|
|
3063
|
+
console.log(` Scenarios: ${benchmark.summary.scenarios}`);
|
|
3064
|
+
console.log(` Tokens: ${benchmark.summary.totalEstimatedTokens}/${benchmark.summary.totalBudget}; saved ${benchmark.summary.totalEstimatedTokenSavings}`);
|
|
3065
|
+
console.log(` Memory items: ${benchmark.summary.totalMemoryItems}`);
|
|
3066
|
+
console.log(` Skill steps: ${benchmark.summary.totalSkillSteps} (${benchmark.summary.requiredSkillSteps} required)`);
|
|
3067
|
+
console.log(` Governance modes: ${benchmark.summary.governanceModes.join(', ') || 'none'}`);
|
|
3068
|
+
console.log(` Dashboard health: ${benchmark.dashboard.health.status}`);
|
|
3069
|
+
for (const scenario of benchmark.scenarios) {
|
|
3070
|
+
console.log(` [${scenario.governanceMode}] ${scenario.id}: tokens=${scenario.metrics.estimatedTokens}, skills=${scenario.metrics.skillSteps}, memory=${scenario.metrics.memoryItems}`);
|
|
3071
|
+
}
|
|
3072
|
+
for (const recommendation of benchmark.recommendations)
|
|
3073
|
+
console.log(` recommendation: ${recommendation}`);
|
|
3074
|
+
},
|
|
3075
|
+
});
|
|
3076
|
+
const aiOsMigrateCommand = defineCommand({
|
|
3077
|
+
meta: { name: 'migrate', description: 'Create or verify AI OS runtime state directories for this project' },
|
|
3078
|
+
args: {
|
|
3079
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3080
|
+
json: { type: 'boolean', default: false },
|
|
3081
|
+
},
|
|
3082
|
+
run({ args }) {
|
|
3083
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3084
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3085
|
+
const report = createAiOsMigration({ projectDir, scaleDir });
|
|
3086
|
+
if (args.json) {
|
|
3087
|
+
console.log(JSON.stringify(report, null, 2));
|
|
3088
|
+
return;
|
|
3089
|
+
}
|
|
3090
|
+
console.log('SCALE AI OS Migration');
|
|
3091
|
+
console.log(` Status: ${report.status}`);
|
|
3092
|
+
console.log(` Created: ${report.created.length}`);
|
|
3093
|
+
console.log(` Existing: ${report.existing.length}`);
|
|
3094
|
+
console.log(` Report: ${report.files.migrationReport}`);
|
|
3095
|
+
for (const action of report.nextActions)
|
|
3096
|
+
console.log(` next: ${action}`);
|
|
3097
|
+
for (const warning of report.warnings)
|
|
3098
|
+
console.log(` warning: ${warning}`);
|
|
3099
|
+
},
|
|
3100
|
+
});
|
|
3101
|
+
const aiOsDoctorCommand = defineCommand({
|
|
3102
|
+
meta: { name: 'doctor', description: 'Check AI OS beta runtime readiness, dashboard health, and benchmark freshness' },
|
|
3103
|
+
args: {
|
|
3104
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3105
|
+
lang: { type: 'string', default: 'en', description: 'Output language zh/en' },
|
|
3106
|
+
'benchmark-max-age-hours': { type: 'string', description: 'Maximum accepted benchmark report age in hours' },
|
|
3107
|
+
json: { type: 'boolean', default: false },
|
|
3108
|
+
},
|
|
3109
|
+
run({ args }) {
|
|
3110
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3111
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3112
|
+
const report = createAiOsDoctor({
|
|
3113
|
+
projectDir,
|
|
3114
|
+
scaleDir,
|
|
3115
|
+
lang: normalizeLangArg(args.lang),
|
|
3116
|
+
benchmarkMaxAgeHours: parsePositiveIntArg(args['benchmark-max-age-hours'], '--benchmark-max-age-hours'),
|
|
3117
|
+
});
|
|
3118
|
+
if (args.json) {
|
|
3119
|
+
console.log(JSON.stringify(report, null, 2));
|
|
3120
|
+
if (report.status === 'blocked')
|
|
3121
|
+
process.exitCode = 1;
|
|
3122
|
+
return;
|
|
3123
|
+
}
|
|
3124
|
+
console.log('SCALE AI OS Doctor');
|
|
3125
|
+
console.log(` Status: ${report.status}`);
|
|
3126
|
+
console.log(` Checks: ${report.summary.passedChecks} passed, ${report.summary.warningChecks} warning, ${report.summary.blockedChecks} blocked`);
|
|
3127
|
+
console.log(` Dashboard: ${report.dashboard.health.status} (${report.dashboard.health.score})`);
|
|
3128
|
+
console.log(` Benchmark: ${report.benchmark.status}`);
|
|
3129
|
+
for (const check of report.checks)
|
|
3130
|
+
console.log(` [${check.status}] ${check.id}: ${check.summary}`);
|
|
3131
|
+
for (const action of report.nextActions)
|
|
3132
|
+
console.log(` next: ${action}`);
|
|
3133
|
+
for (const warning of report.warnings)
|
|
3134
|
+
console.log(` warning: ${warning}`);
|
|
3135
|
+
if (report.status === 'blocked')
|
|
3136
|
+
process.exitCode = 1;
|
|
3137
|
+
},
|
|
3138
|
+
});
|
|
3139
|
+
const aiOs = defineCommand({
|
|
3140
|
+
meta: { name: 'ai-os', description: 'AI Engineering OS runtime planning and governance orchestration' },
|
|
3141
|
+
subCommands: {
|
|
3142
|
+
plan: aiOsPlanCommand,
|
|
3143
|
+
run: aiOsRunCommand,
|
|
3144
|
+
dashboard: aiOsDashboardCommand,
|
|
3145
|
+
benchmark: aiOsBenchmarkCommand,
|
|
3146
|
+
migrate: aiOsMigrateCommand,
|
|
3147
|
+
doctor: aiOsDoctorCommand,
|
|
3148
|
+
},
|
|
3149
|
+
});
|
|
2910
3150
|
// ============================================================================
|
|
2911
3151
|
// upgrade command - Safe workflow/template/capability update planning
|
|
2912
3152
|
// ============================================================================
|
|
@@ -2920,8 +3160,10 @@ const upgradeCheck = defineCommand({
|
|
|
2920
3160
|
},
|
|
2921
3161
|
run({ args }) {
|
|
2922
3162
|
const lang = normalizeLangArg(args.lang);
|
|
3163
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
2923
3164
|
const report = createUpgradeCheckReport({
|
|
2924
|
-
projectDir
|
|
3165
|
+
projectDir,
|
|
3166
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
2925
3167
|
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
2926
3168
|
});
|
|
2927
3169
|
if (args.json) {
|
|
@@ -2936,6 +3178,7 @@ const upgradeCheck = defineCommand({
|
|
|
2936
3178
|
console.log(` 治理包: ${report.governancePack.id ?? '无'} v${report.governancePack.currentVersion ?? '无'} -> v${report.governancePack.latestVersion ?? '无'}`);
|
|
2937
3179
|
console.log(` 受管生成文件: ${report.generatedFiles.clean} 个干净, ${report.generatedFiles.changed} 个本地改动, ${report.generatedFiles.missing} 个缺失`);
|
|
2938
3180
|
console.log(` 第三方能力策略: ${report.thirdParty.policy}; 需要人工审查: ${report.thirdParty.reviewRequired}`);
|
|
3181
|
+
console.log(` AI OS Runtime: ${report.aiOsRuntime.status}`);
|
|
2939
3182
|
console.log(' 下一步:');
|
|
2940
3183
|
}
|
|
2941
3184
|
else {
|
|
@@ -2946,6 +3189,7 @@ const upgradeCheck = defineCommand({
|
|
|
2946
3189
|
console.log(` Governance pack: ${report.governancePack.id ?? 'none'} v${report.governancePack.currentVersion ?? 'none'} -> v${report.governancePack.latestVersion ?? 'none'}`);
|
|
2947
3190
|
console.log(` Generated files: ${report.generatedFiles.clean} clean, ${report.generatedFiles.changed} changed, ${report.generatedFiles.missing} missing`);
|
|
2948
3191
|
console.log(` Third-party policy: ${report.thirdParty.policy}; review required: ${report.thirdParty.reviewRequired}`);
|
|
3192
|
+
console.log(` AI OS Runtime: ${report.aiOsRuntime.status}`);
|
|
2949
3193
|
console.log(' Next:');
|
|
2950
3194
|
}
|
|
2951
3195
|
for (const command of report.recommendedCommands)
|
|
@@ -2963,8 +3207,10 @@ const upgradePlan = defineCommand({
|
|
|
2963
3207
|
},
|
|
2964
3208
|
run({ args }) {
|
|
2965
3209
|
const lang = normalizeLangArg(args.lang);
|
|
3210
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
2966
3211
|
const report = createUpgradePlanReport({
|
|
2967
|
-
projectDir
|
|
3212
|
+
projectDir,
|
|
3213
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
2968
3214
|
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
2969
3215
|
});
|
|
2970
3216
|
const htmlPath = args.html ? writeUpgradePlanHtml(report, undefined, lang) : undefined;
|
|
@@ -3009,8 +3255,10 @@ const upgradeApply = defineCommand({
|
|
|
3009
3255
|
},
|
|
3010
3256
|
run({ args }) {
|
|
3011
3257
|
const lang = normalizeLangArg(args.lang);
|
|
3258
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3012
3259
|
const result = applyUpgradePlan({
|
|
3013
|
-
projectDir
|
|
3260
|
+
projectDir,
|
|
3261
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
3014
3262
|
confirm: isTruthyFlag(args.confirm),
|
|
3015
3263
|
});
|
|
3016
3264
|
if (args.json) {
|
|
@@ -5001,6 +5249,14 @@ function parseToolIds(value) {
|
|
|
5001
5249
|
function parseCommaList(value) {
|
|
5002
5250
|
return parseToolIds(value) ?? [];
|
|
5003
5251
|
}
|
|
5252
|
+
function normalizeAiOsRunMode(value, forceDryRun = false) {
|
|
5253
|
+
if (forceDryRun)
|
|
5254
|
+
return 'dry-run';
|
|
5255
|
+
const normalized = String(value ?? 'dry-run').trim().toLowerCase();
|
|
5256
|
+
if (normalized === 'dry-run' || normalized === 'guarded')
|
|
5257
|
+
return normalized;
|
|
5258
|
+
throw new Error(`Invalid AI OS run mode "${String(value)}"; expected dry-run or guarded.`);
|
|
5259
|
+
}
|
|
5004
5260
|
function createToolExecutionPlanFromArgs(args) {
|
|
5005
5261
|
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
5006
5262
|
const level = normalizeTaskArtifactLevel(args.level ?? 'M');
|
|
@@ -5437,6 +5693,7 @@ const main = defineCommand({
|
|
|
5437
5693
|
preflight,
|
|
5438
5694
|
upgrade,
|
|
5439
5695
|
governance,
|
|
5696
|
+
'ai-os': aiOs,
|
|
5440
5697
|
codegraph,
|
|
5441
5698
|
eval: evalCommand,
|
|
5442
5699
|
artifact,
|