@hongmaple0820/scale-engine 0.27.0 → 0.28.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 +74 -3
- package/README.md +75 -3
- package/dist/api/cli.js +376 -7
- package/dist/api/cli.js.map +1 -1
- package/dist/runtime/AiOsRuntime.d.ts +291 -0
- package/dist/runtime/AiOsRuntime.js +1031 -1
- package/dist/runtime/AiOsRuntime.js.map +1 -1
- package/dist/workflow/GovernanceTemplatePacks.js +10 -3
- package/dist/workflow/GovernanceTemplatePacks.js.map +1 -1
- package/dist/workflow/UpgradeManager.d.ts +4 -1
- package/dist/workflow/UpgradeManager.js +35 -0
- package/dist/workflow/UpgradeManager.js.map +1 -1
- package/docs/AI_ENGINEERING_OS_POSITIONING.md +141 -11
- package/docs/README.md +1 -1
- package/docs/start/README.md +2 -1
- package/docs/start/quickstart.md +6 -0
- package/docs/start/workflow-upgrade.md +17 -0
- package/docs/workflow/README.md +2 -1
- package/package.json +1 -1
package/dist/api/cli.js
CHANGED
|
@@ -65,7 +65,7 @@ import { doctorHtmlArtifacts, renderHtmlArtifact, resolveHtmlArtifactForOpen, se
|
|
|
65
65
|
import { renderGovernanceDashboard } from '../output/GovernanceDashboard.js';
|
|
66
66
|
import { cleanupWorkspaceLifecycle, inspectWorkspaceLifecycle, } from '../workflow/WorkspaceLifecycle.js';
|
|
67
67
|
import { inspectWorkspaceSafety } from '../workflow/WorkspaceSafety.js';
|
|
68
|
-
import { RuntimeEvidenceLedger, SessionLedger, createAiOsPlan, doctorRuntimeEvidence, evaluateFinalReportReadiness, } from '../runtime/index.js';
|
|
68
|
+
import { RuntimeEvidenceLedger, SessionLedger, createAiOsAdoption, createAiOsBenchmark, createAiOsDashboard, createAiOsDoctor, createAiOsMigration, createAiOsPlan, createAiOsRun, createAiOsStatus, doctorRuntimeEvidence, evaluateFinalReportReadiness, } from '../runtime/index.js';
|
|
69
69
|
import { MemoryFabric, MemoryBrain, doctorMemoryFabric, renderContextPackMarkdown, renderMemoryLearningCandidateMarkdown, inspectMemoryProviders, recallMemoryProviders, settleMemoryLearning, writeMemoryProvidersConfig, } from '../memory/index.js';
|
|
70
70
|
import { resolveWorkspaceTopology, workspaceTopologyPath, workspaceTopologyTemplate, } from '../workflow/WorkspaceTopology.js';
|
|
71
71
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
@@ -2950,9 +2950,342 @@ const aiOsPlanCommand = defineCommand({
|
|
|
2950
2950
|
console.log(` recommendation: ${recommendation}`);
|
|
2951
2951
|
},
|
|
2952
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 aiOsAdoptCommand = defineCommand({
|
|
3140
|
+
meta: { name: 'adopt', description: 'Prepare a project for AI OS runtime use by running migrate, first dry-run, benchmark, and doctor' },
|
|
3141
|
+
args: {
|
|
3142
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3143
|
+
'task-id': { type: 'string', description: 'Task id for the first adoption dry-run report' },
|
|
3144
|
+
task: { type: 'string', required: true, description: 'Task or adoption scenario description' },
|
|
3145
|
+
level: { type: 'string', default: 'M', description: 'Task level: S, M, L, or CRITICAL' },
|
|
3146
|
+
files: { type: 'string', description: 'Comma-separated changed or target files' },
|
|
3147
|
+
services: { type: 'string', description: 'Comma-separated affected services' },
|
|
3148
|
+
budget: { type: 'string', description: 'Maximum estimated tokens for the adoption plan and benchmark' },
|
|
3149
|
+
'requested-mode': { type: 'string', description: 'Requested governance mode: minimal, standard, expanded, or critical' },
|
|
3150
|
+
lang: { type: 'string', default: 'en', description: 'Output language zh/en' },
|
|
3151
|
+
'benchmark-max-age-hours': { type: 'string', description: 'Maximum accepted benchmark report age in hours' },
|
|
3152
|
+
json: { type: 'boolean', default: false },
|
|
3153
|
+
},
|
|
3154
|
+
async run({ args }) {
|
|
3155
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3156
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3157
|
+
const lang = normalizeLangArg(args.lang);
|
|
3158
|
+
const report = await createAiOsAdoption({
|
|
3159
|
+
projectDir,
|
|
3160
|
+
scaleDir,
|
|
3161
|
+
taskId: args['task-id'] ? String(args['task-id']) : undefined,
|
|
3162
|
+
task: String(args.task),
|
|
3163
|
+
level: normalizeTaskArtifactLevel(args.level),
|
|
3164
|
+
files: parseCommaList(args.files),
|
|
3165
|
+
services: parseCommaList(args.services),
|
|
3166
|
+
budget: parsePositiveIntArg(args.budget, '--budget'),
|
|
3167
|
+
requestedMode: normalizeGovernanceMode(args['requested-mode']),
|
|
3168
|
+
lang,
|
|
3169
|
+
benchmarkMaxAgeHours: parsePositiveIntArg(args['benchmark-max-age-hours'], '--benchmark-max-age-hours'),
|
|
3170
|
+
});
|
|
3171
|
+
if (args.json) {
|
|
3172
|
+
console.log(JSON.stringify(report, null, 2));
|
|
3173
|
+
if (report.status === 'blocked')
|
|
3174
|
+
process.exitCode = 1;
|
|
3175
|
+
return;
|
|
3176
|
+
}
|
|
3177
|
+
if (lang === 'zh') {
|
|
3178
|
+
console.log('SCALE AI OS 接入');
|
|
3179
|
+
console.log(` 状态: ${report.status}`);
|
|
3180
|
+
console.log(` 迁移: ${report.migration.status}`);
|
|
3181
|
+
console.log(` 首次运行: ${report.run.status} (${report.run.mode})`);
|
|
3182
|
+
console.log(` 基准: ${report.benchmark.summary.scenarios} 个场景`);
|
|
3183
|
+
console.log(` Doctor: ${report.doctor.status}`);
|
|
3184
|
+
console.log(` 报告: ${report.artifacts.adoptionReport}`);
|
|
3185
|
+
for (const phase of report.phases)
|
|
3186
|
+
console.log(` [${phase.status}] ${phase.id}: ${phase.summary}`);
|
|
3187
|
+
for (const action of report.nextActions)
|
|
3188
|
+
console.log(` 下一步: ${action}`);
|
|
3189
|
+
for (const warning of report.warnings)
|
|
3190
|
+
console.log(` 警告: ${warning}`);
|
|
3191
|
+
}
|
|
3192
|
+
else {
|
|
3193
|
+
console.log('SCALE AI OS Adoption');
|
|
3194
|
+
console.log(` Status: ${report.status}`);
|
|
3195
|
+
console.log(` Migration: ${report.migration.status}`);
|
|
3196
|
+
console.log(` First run: ${report.run.status} (${report.run.mode})`);
|
|
3197
|
+
console.log(` Benchmark: ${report.benchmark.summary.scenarios} scenario(s)`);
|
|
3198
|
+
console.log(` Doctor: ${report.doctor.status}`);
|
|
3199
|
+
console.log(` Report: ${report.artifacts.adoptionReport}`);
|
|
3200
|
+
for (const phase of report.phases)
|
|
3201
|
+
console.log(` [${phase.status}] ${phase.id}: ${phase.summary}`);
|
|
3202
|
+
for (const action of report.nextActions)
|
|
3203
|
+
console.log(` next: ${action}`);
|
|
3204
|
+
for (const warning of report.warnings)
|
|
3205
|
+
console.log(` warning: ${warning}`);
|
|
3206
|
+
}
|
|
3207
|
+
if (report.status === 'blocked')
|
|
3208
|
+
process.exitCode = 1;
|
|
3209
|
+
},
|
|
3210
|
+
});
|
|
3211
|
+
const aiOsStatusCommand = defineCommand({
|
|
3212
|
+
meta: { name: 'status', description: 'Show AI OS closed-loop readiness across runtime, run, verification, dashboard, benchmark, and adoption evidence' },
|
|
3213
|
+
args: {
|
|
3214
|
+
dir: { type: 'string', default: PROJECT_DIR, description: 'Project directory' },
|
|
3215
|
+
lang: { type: 'string', default: 'en', description: 'Output language zh/en' },
|
|
3216
|
+
'benchmark-max-age-hours': { type: 'string', description: 'Maximum accepted benchmark report age in hours' },
|
|
3217
|
+
json: { type: 'boolean', default: false },
|
|
3218
|
+
},
|
|
3219
|
+
run({ args }) {
|
|
3220
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3221
|
+
const scaleDir = resolveScaleDirForProject(projectDir);
|
|
3222
|
+
const lang = normalizeLangArg(args.lang);
|
|
3223
|
+
const report = createAiOsStatus({
|
|
3224
|
+
projectDir,
|
|
3225
|
+
scaleDir,
|
|
3226
|
+
benchmarkMaxAgeHours: parsePositiveIntArg(args['benchmark-max-age-hours'], '--benchmark-max-age-hours'),
|
|
3227
|
+
lang,
|
|
3228
|
+
});
|
|
3229
|
+
if (args.json) {
|
|
3230
|
+
console.log(JSON.stringify(report, null, 2));
|
|
3231
|
+
if (report.status === 'blocked')
|
|
3232
|
+
process.exitCode = 1;
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
if (lang === 'zh') {
|
|
3236
|
+
console.log('SCALE AI OS 状态');
|
|
3237
|
+
console.log(` 状态: ${report.status}`);
|
|
3238
|
+
console.log(` 检查: ${report.summary.ready} ready, ${report.summary.warning} warning, ${report.summary.blocked} blocked`);
|
|
3239
|
+
console.log(` Dashboard: ${report.dashboard.health.status} (${report.dashboard.health.score})`);
|
|
3240
|
+
console.log(` Doctor: ${report.doctor.status}`);
|
|
3241
|
+
for (const check of report.checks)
|
|
3242
|
+
console.log(` [${check.status}] ${check.id}: ${check.summary}`);
|
|
3243
|
+
if (report.verificationRecommendations.length > 0) {
|
|
3244
|
+
console.log(' 验证建议:');
|
|
3245
|
+
for (const recommendation of report.verificationRecommendations) {
|
|
3246
|
+
console.log(` - ${recommendation.command} (${recommendation.source})`);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
for (const action of report.nextActions)
|
|
3250
|
+
console.log(` 下一步: ${action}`);
|
|
3251
|
+
for (const warning of report.warnings)
|
|
3252
|
+
console.log(` 警告: ${warning}`);
|
|
3253
|
+
}
|
|
3254
|
+
else {
|
|
3255
|
+
console.log('SCALE AI OS Status');
|
|
3256
|
+
console.log(` Status: ${report.status}`);
|
|
3257
|
+
console.log(` Checks: ${report.summary.ready} ready, ${report.summary.warning} warning, ${report.summary.blocked} blocked`);
|
|
3258
|
+
console.log(` Dashboard: ${report.dashboard.health.status} (${report.dashboard.health.score})`);
|
|
3259
|
+
console.log(` Doctor: ${report.doctor.status}`);
|
|
3260
|
+
for (const check of report.checks)
|
|
3261
|
+
console.log(` [${check.status}] ${check.id}: ${check.summary}`);
|
|
3262
|
+
if (report.verificationRecommendations.length > 0) {
|
|
3263
|
+
console.log(' Verification recommendations:');
|
|
3264
|
+
for (const recommendation of report.verificationRecommendations) {
|
|
3265
|
+
console.log(` - ${recommendation.command} (${recommendation.source})`);
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
for (const action of report.nextActions)
|
|
3269
|
+
console.log(` next: ${action}`);
|
|
3270
|
+
for (const warning of report.warnings)
|
|
3271
|
+
console.log(` warning: ${warning}`);
|
|
3272
|
+
}
|
|
3273
|
+
if (report.status === 'blocked')
|
|
3274
|
+
process.exitCode = 1;
|
|
3275
|
+
},
|
|
3276
|
+
});
|
|
2953
3277
|
const aiOs = defineCommand({
|
|
2954
3278
|
meta: { name: 'ai-os', description: 'AI Engineering OS runtime planning and governance orchestration' },
|
|
2955
|
-
subCommands: {
|
|
3279
|
+
subCommands: {
|
|
3280
|
+
adopt: aiOsAdoptCommand,
|
|
3281
|
+
status: aiOsStatusCommand,
|
|
3282
|
+
plan: aiOsPlanCommand,
|
|
3283
|
+
run: aiOsRunCommand,
|
|
3284
|
+
dashboard: aiOsDashboardCommand,
|
|
3285
|
+
benchmark: aiOsBenchmarkCommand,
|
|
3286
|
+
migrate: aiOsMigrateCommand,
|
|
3287
|
+
doctor: aiOsDoctorCommand,
|
|
3288
|
+
},
|
|
2956
3289
|
});
|
|
2957
3290
|
// ============================================================================
|
|
2958
3291
|
// upgrade command - Safe workflow/template/capability update planning
|
|
@@ -2967,8 +3300,10 @@ const upgradeCheck = defineCommand({
|
|
|
2967
3300
|
},
|
|
2968
3301
|
run({ args }) {
|
|
2969
3302
|
const lang = normalizeLangArg(args.lang);
|
|
3303
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
2970
3304
|
const report = createUpgradeCheckReport({
|
|
2971
|
-
projectDir
|
|
3305
|
+
projectDir,
|
|
3306
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
2972
3307
|
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
2973
3308
|
});
|
|
2974
3309
|
if (args.json) {
|
|
@@ -2983,6 +3318,7 @@ const upgradeCheck = defineCommand({
|
|
|
2983
3318
|
console.log(` 治理包: ${report.governancePack.id ?? '无'} v${report.governancePack.currentVersion ?? '无'} -> v${report.governancePack.latestVersion ?? '无'}`);
|
|
2984
3319
|
console.log(` 受管生成文件: ${report.generatedFiles.clean} 个干净, ${report.generatedFiles.changed} 个本地改动, ${report.generatedFiles.missing} 个缺失`);
|
|
2985
3320
|
console.log(` 第三方能力策略: ${report.thirdParty.policy}; 需要人工审查: ${report.thirdParty.reviewRequired}`);
|
|
3321
|
+
console.log(` AI OS Runtime: ${report.aiOsRuntime.status}`);
|
|
2986
3322
|
console.log(' 下一步:');
|
|
2987
3323
|
}
|
|
2988
3324
|
else {
|
|
@@ -2993,10 +3329,11 @@ const upgradeCheck = defineCommand({
|
|
|
2993
3329
|
console.log(` Governance pack: ${report.governancePack.id ?? 'none'} v${report.governancePack.currentVersion ?? 'none'} -> v${report.governancePack.latestVersion ?? 'none'}`);
|
|
2994
3330
|
console.log(` Generated files: ${report.generatedFiles.clean} clean, ${report.generatedFiles.changed} changed, ${report.generatedFiles.missing} missing`);
|
|
2995
3331
|
console.log(` Third-party policy: ${report.thirdParty.policy}; review required: ${report.thirdParty.reviewRequired}`);
|
|
3332
|
+
console.log(` AI OS Runtime: ${report.aiOsRuntime.status}`);
|
|
2996
3333
|
console.log(' Next:');
|
|
2997
3334
|
}
|
|
2998
3335
|
for (const command of report.recommendedCommands)
|
|
2999
|
-
console.log(` ${command}`);
|
|
3336
|
+
console.log(` ${formatUpgradeCommand(command, lang)}`);
|
|
3000
3337
|
},
|
|
3001
3338
|
});
|
|
3002
3339
|
const upgradePlan = defineCommand({
|
|
@@ -3010,8 +3347,10 @@ const upgradePlan = defineCommand({
|
|
|
3010
3347
|
},
|
|
3011
3348
|
run({ args }) {
|
|
3012
3349
|
const lang = normalizeLangArg(args.lang);
|
|
3350
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3013
3351
|
const report = createUpgradePlanReport({
|
|
3014
|
-
projectDir
|
|
3352
|
+
projectDir,
|
|
3353
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
3015
3354
|
targetScaleVersion: args['target-version'] ? String(args['target-version']) : undefined,
|
|
3016
3355
|
});
|
|
3017
3356
|
const htmlPath = args.html ? writeUpgradePlanHtml(report, undefined, lang) : undefined;
|
|
@@ -3039,7 +3378,7 @@ const upgradePlan = defineCommand({
|
|
|
3039
3378
|
console.log(lang === 'zh' ? ' 步骤:' : ' Steps:');
|
|
3040
3379
|
for (const step of report.steps) {
|
|
3041
3380
|
const path = step.path ? ` ${step.path}` : '';
|
|
3042
|
-
const command = step.command ? ` -> ${step.command}` : '';
|
|
3381
|
+
const command = step.command ? ` -> ${formatUpgradeCommand(step.command, lang)}` : '';
|
|
3043
3382
|
console.log(` [${step.risk}] ${step.action}${path}: ${formatUpgradeStepReason(step.action, step.reason, lang)}${command}`);
|
|
3044
3383
|
}
|
|
3045
3384
|
if (htmlPath)
|
|
@@ -3056,8 +3395,10 @@ const upgradeApply = defineCommand({
|
|
|
3056
3395
|
},
|
|
3057
3396
|
run({ args }) {
|
|
3058
3397
|
const lang = normalizeLangArg(args.lang);
|
|
3398
|
+
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
3059
3399
|
const result = applyUpgradePlan({
|
|
3060
|
-
projectDir
|
|
3400
|
+
projectDir,
|
|
3401
|
+
scaleDir: resolveScaleDirForProject(projectDir),
|
|
3061
3402
|
confirm: isTruthyFlag(args.confirm),
|
|
3062
3403
|
});
|
|
3063
3404
|
if (args.json) {
|
|
@@ -3138,12 +3479,32 @@ function formatUpgradeStepReason(action, fallback, lang) {
|
|
|
3138
3479
|
return fallback
|
|
3139
3480
|
.replace('updates require manual-review; SCALE never auto-installs third-party capabilities.', '更新需要人工审阅;SCALE 不会自动安装第三方能力。')
|
|
3140
3481
|
.replace('updates require blocked; SCALE never auto-installs third-party capabilities.', '更新默认阻断;SCALE 不会自动安装第三方能力。');
|
|
3482
|
+
case 'adopt-ai-os-runtime':
|
|
3483
|
+
return '运行 AI OS 一键接入路径,生成运行态目录、首份 dry-run、benchmark 和 doctor 报告。';
|
|
3484
|
+
case 'migrate-ai-os-runtime':
|
|
3485
|
+
return 'AI OS 运行态目录缺失;接入 beta runtime 前先创建目录结构。';
|
|
3486
|
+
case 'check-ai-os-runtime':
|
|
3487
|
+
return '依赖 AI OS beta 编排前,先复核运行态就绪状态。';
|
|
3141
3488
|
case 'run-preflight':
|
|
3142
3489
|
return '完成已接受的升级后,运行项目级预检。';
|
|
3143
3490
|
default:
|
|
3144
3491
|
return fallback;
|
|
3145
3492
|
}
|
|
3146
3493
|
}
|
|
3494
|
+
function formatUpgradeCommand(command, lang) {
|
|
3495
|
+
if (command === 'scale ai-os adopt --dir . --task "Adopt AI OS runtime" --json') {
|
|
3496
|
+
return lang === 'zh'
|
|
3497
|
+
? 'scale ai-os adopt --dir . --task "接入 AI OS runtime" --lang zh'
|
|
3498
|
+
: 'scale ai-os adopt --dir . --task "Adopt AI OS runtime" --lang en';
|
|
3499
|
+
}
|
|
3500
|
+
if (command === 'scale ai-os doctor --dir . --json') {
|
|
3501
|
+
return lang === 'zh' ? 'scale ai-os doctor --dir . --lang zh' : 'scale ai-os doctor --dir . --lang en';
|
|
3502
|
+
}
|
|
3503
|
+
if (command === 'scale ai-os migrate --dir . --json') {
|
|
3504
|
+
return 'scale ai-os migrate --dir .';
|
|
3505
|
+
}
|
|
3506
|
+
return command;
|
|
3507
|
+
}
|
|
3147
3508
|
function formatUpgradeApplyReason(reason, lang) {
|
|
3148
3509
|
if (lang !== 'zh')
|
|
3149
3510
|
return reason;
|
|
@@ -5048,6 +5409,14 @@ function parseToolIds(value) {
|
|
|
5048
5409
|
function parseCommaList(value) {
|
|
5049
5410
|
return parseToolIds(value) ?? [];
|
|
5050
5411
|
}
|
|
5412
|
+
function normalizeAiOsRunMode(value, forceDryRun = false) {
|
|
5413
|
+
if (forceDryRun)
|
|
5414
|
+
return 'dry-run';
|
|
5415
|
+
const normalized = String(value ?? 'dry-run').trim().toLowerCase();
|
|
5416
|
+
if (normalized === 'dry-run' || normalized === 'guarded')
|
|
5417
|
+
return normalized;
|
|
5418
|
+
throw new Error(`Invalid AI OS run mode "${String(value)}"; expected dry-run or guarded.`);
|
|
5419
|
+
}
|
|
5051
5420
|
function createToolExecutionPlanFromArgs(args) {
|
|
5052
5421
|
const projectDir = resolve(String(args.dir ?? PROJECT_DIR));
|
|
5053
5422
|
const level = normalizeTaskArtifactLevel(args.level ?? 'M');
|