@hongmaple0820/scale-engine 0.20.0 → 0.21.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 +2 -2
- package/README.md +38 -2
- 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.d.ts +1 -1
- package/dist/workflow/GovernanceTemplates.js +128 -18
- package/dist/workflow/GovernanceTemplates.js.map +1 -1
- package/dist/workflow/ResourceGovernance.js +10 -1
- package/dist/workflow/ResourceGovernance.js.map +1 -1
- package/dist/workflow/TaskArtifactScaffolder.js +43 -5
- package/dist/workflow/TaskArtifactScaffolder.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/RESOURCE_GOVERNANCE.md +92 -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 +2 -1
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { TOOL_CAPABILITY_CATALOG } from '../tools/ToolCapabilityRegistry.js';
|
|
4
|
+
import { SCALE_ENGINE_VERSION } from '../version.js';
|
|
5
|
+
import { computeGovernanceDrift, readGovernanceLock } from './GovernanceLock.js';
|
|
6
|
+
import { listGovernanceTemplatePacks, resolveGovernanceTemplatePack } from './GovernanceTemplatePacks.js';
|
|
7
|
+
import { writeGovernanceTemplates } from './GovernanceTemplates.js';
|
|
8
|
+
export function createUpgradeCheckReport(options = {}) {
|
|
9
|
+
const projectDir = resolve(options.projectDir ?? process.cwd());
|
|
10
|
+
const lock = readGovernanceLock(projectDir);
|
|
11
|
+
const drift = computeGovernanceDrift(projectDir);
|
|
12
|
+
const latestScaleVersion = normalizeTargetVersion(options.targetScaleVersion);
|
|
13
|
+
const pack = lock ? resolveGovernanceTemplatePack(lock.pack) : null;
|
|
14
|
+
const scaleUpToDate = Boolean(lock && lock.scaleVersion === latestScaleVersion);
|
|
15
|
+
const packUpToDate = Boolean(lock && pack && lock.packVersion === pack.version);
|
|
16
|
+
const generatedTotal = drift.clean.length + drift.changed.length + drift.missing.length;
|
|
17
|
+
const thirdParty = createThirdPartyUpdateReport();
|
|
18
|
+
const status = resolveUpgradeStatus({
|
|
19
|
+
hasLock: Boolean(lock),
|
|
20
|
+
hasLocalChanges: drift.changed.length > 0,
|
|
21
|
+
hasMissingFiles: drift.missing.length > 0,
|
|
22
|
+
scaleUpToDate,
|
|
23
|
+
packUpToDate,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
version: 1,
|
|
27
|
+
projectDir,
|
|
28
|
+
status,
|
|
29
|
+
scaleEngine: {
|
|
30
|
+
currentVersion: lock?.scaleVersion ?? null,
|
|
31
|
+
latestVersion: latestScaleVersion,
|
|
32
|
+
upToDate: scaleUpToDate,
|
|
33
|
+
},
|
|
34
|
+
governanceLock: {
|
|
35
|
+
exists: Boolean(lock),
|
|
36
|
+
path: join(projectDir, '.scale', 'governance.lock.json'),
|
|
37
|
+
},
|
|
38
|
+
governancePack: {
|
|
39
|
+
id: lock?.pack ?? null,
|
|
40
|
+
currentVersion: lock?.packVersion ?? null,
|
|
41
|
+
latestVersion: pack?.version ?? null,
|
|
42
|
+
upToDate: packUpToDate,
|
|
43
|
+
},
|
|
44
|
+
generatedFiles: {
|
|
45
|
+
total: generatedTotal,
|
|
46
|
+
clean: drift.clean.length,
|
|
47
|
+
changed: drift.changed.length,
|
|
48
|
+
missing: drift.missing.length,
|
|
49
|
+
},
|
|
50
|
+
drift,
|
|
51
|
+
thirdParty,
|
|
52
|
+
recommendedCommands: [
|
|
53
|
+
'scale upgrade plan --dir .',
|
|
54
|
+
'scale tools outdated --dir .',
|
|
55
|
+
'scale skill outdated --dir .',
|
|
56
|
+
'scale preflight --preflight-profile quick',
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function createUpgradePlanReport(options = {}) {
|
|
61
|
+
const check = createUpgradeCheckReport(options);
|
|
62
|
+
const blockers = [];
|
|
63
|
+
const steps = [];
|
|
64
|
+
if (!check.governanceLock.exists) {
|
|
65
|
+
blockers.push({
|
|
66
|
+
code: 'missing-governance-lock',
|
|
67
|
+
message: 'No governance lock exists; SCALE cannot determine which generated files are safe to upgrade.',
|
|
68
|
+
});
|
|
69
|
+
steps.push({
|
|
70
|
+
action: 'initialize-governance-lock',
|
|
71
|
+
risk: 'medium',
|
|
72
|
+
reason: 'Create a lock before upgrading generated governance assets.',
|
|
73
|
+
command: 'scale init --governance-pack standard',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (!check.scaleEngine.upToDate && check.scaleEngine.currentVersion) {
|
|
77
|
+
steps.push({
|
|
78
|
+
action: 'upgrade-scale-engine',
|
|
79
|
+
risk: 'low',
|
|
80
|
+
reason: `SCALE Engine changed from ${check.scaleEngine.currentVersion} to ${check.scaleEngine.latestVersion}.`,
|
|
81
|
+
command: 'npm install -g @hongmaple0820/scale-engine',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (!check.governancePack.upToDate && check.governancePack.id) {
|
|
85
|
+
steps.push({
|
|
86
|
+
action: 'upgrade-governance-pack',
|
|
87
|
+
risk: 'medium',
|
|
88
|
+
reason: `Governance pack ${check.governancePack.id} changed from v${check.governancePack.currentVersion} to v${check.governancePack.latestVersion}.`,
|
|
89
|
+
command: `scale init --governance-pack ${check.governancePack.id}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const entry of check.drift.missing) {
|
|
93
|
+
steps.push({
|
|
94
|
+
action: 'restore-missing-generated-file',
|
|
95
|
+
path: entry.path,
|
|
96
|
+
risk: 'low',
|
|
97
|
+
reason: 'The file is tracked by the governance lock but is missing locally.',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
for (const entry of check.drift.changed) {
|
|
101
|
+
blockers.push({
|
|
102
|
+
code: 'local-generated-file-changed',
|
|
103
|
+
path: entry.path,
|
|
104
|
+
message: 'Generated governance file has local edits and needs a three-way/manual review before upgrade.',
|
|
105
|
+
});
|
|
106
|
+
steps.push({
|
|
107
|
+
action: 'review-local-change',
|
|
108
|
+
path: entry.path,
|
|
109
|
+
risk: 'medium',
|
|
110
|
+
reason: 'Local edits must be preserved or intentionally replaced.',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const thirdPartyReview = check.thirdParty.entries.filter(entry => entry.updatePolicy !== 'check-only');
|
|
114
|
+
for (const entry of thirdPartyReview) {
|
|
115
|
+
steps.push({
|
|
116
|
+
action: 'review-third-party-capability',
|
|
117
|
+
risk: entry.trust === 'high-risk' ? 'high' : 'medium',
|
|
118
|
+
reason: `${entry.name} updates require ${entry.updatePolicy}; SCALE never auto-installs third-party capabilities.`,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
steps.push({
|
|
122
|
+
action: 'run-preflight',
|
|
123
|
+
risk: 'low',
|
|
124
|
+
reason: 'Validate the project after any accepted upgrade.',
|
|
125
|
+
command: 'scale preflight --preflight-profile quick',
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
version: 1,
|
|
129
|
+
projectDir: check.projectDir,
|
|
130
|
+
status: check.status,
|
|
131
|
+
applyMode: blockers.length === 0 ? 'safe' : 'manual-review',
|
|
132
|
+
blockers,
|
|
133
|
+
steps,
|
|
134
|
+
check,
|
|
135
|
+
recommendedCommands: [
|
|
136
|
+
'scale upgrade check --dir .',
|
|
137
|
+
'scale upgrade plan --dir . --html',
|
|
138
|
+
'scale preflight --preflight-profile quick',
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function applyUpgradePlan(options = {}) {
|
|
143
|
+
const projectDir = resolve(options.projectDir ?? process.cwd());
|
|
144
|
+
const plan = createUpgradePlanReport(options);
|
|
145
|
+
if (!options.confirm) {
|
|
146
|
+
return upgradeApplyResult(projectDir, plan, false, false, 'Review scale upgrade plan first, then rerun with --confirm.', []);
|
|
147
|
+
}
|
|
148
|
+
if (plan.applyMode !== 'safe') {
|
|
149
|
+
return upgradeApplyResult(projectDir, plan, false, false, 'Upgrade requires manual review because generated files have local changes or the lock is missing.', []);
|
|
150
|
+
}
|
|
151
|
+
if (!plan.check.governanceLock.exists || !plan.check.governancePack.id) {
|
|
152
|
+
return upgradeApplyResult(projectDir, plan, false, false, 'Cannot apply without a governance lock and pack id.', []);
|
|
153
|
+
}
|
|
154
|
+
if (!plan.check.governancePack.upToDate) {
|
|
155
|
+
return upgradeApplyResult(projectDir, plan, false, false, 'Governance pack version changes require manual review before automatic apply.', []);
|
|
156
|
+
}
|
|
157
|
+
const missingFiles = plan.check.drift.missing.map(entry => entry.path);
|
|
158
|
+
const shouldRefreshLock = !plan.check.scaleEngine.upToDate || missingFiles.length > 0;
|
|
159
|
+
if (!shouldRefreshLock) {
|
|
160
|
+
return upgradeApplyResult(projectDir, plan, true, false, 'No safe upgrade changes were needed.', []);
|
|
161
|
+
}
|
|
162
|
+
const backup = createUpgradeBackup(projectDir, uniqueStrings([...missingFiles, '.scale/governance.lock.json']));
|
|
163
|
+
const result = writeGovernanceTemplates(projectDir, { pack: plan.check.governancePack.id });
|
|
164
|
+
const createdFiles = result.created
|
|
165
|
+
.map(path => normalizeProjectRelativePath(projectDir, path))
|
|
166
|
+
.filter((path) => Boolean(path));
|
|
167
|
+
mergeCreatedFilesIntoBackup(backup.manifestPath, createdFiles);
|
|
168
|
+
const changedFiles = uniqueStrings([
|
|
169
|
+
...missingFiles.filter(path => existsSync(join(projectDir, path))),
|
|
170
|
+
...createdFiles,
|
|
171
|
+
'.scale/governance.lock.json',
|
|
172
|
+
]);
|
|
173
|
+
return {
|
|
174
|
+
version: 1,
|
|
175
|
+
projectDir,
|
|
176
|
+
ok: true,
|
|
177
|
+
applied: changedFiles.length > 0,
|
|
178
|
+
reason: changedFiles.length > 0 ? 'Safe upgrade changes were applied.' : 'No safe upgrade changes were needed.',
|
|
179
|
+
changedFiles,
|
|
180
|
+
backup,
|
|
181
|
+
plan: createUpgradePlanReport(options),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export function rollbackLatestUpgrade(options = {}) {
|
|
185
|
+
const projectDir = resolve(options.projectDir ?? process.cwd());
|
|
186
|
+
const backup = latestUpgradeBackup(projectDir);
|
|
187
|
+
if (!backup) {
|
|
188
|
+
return {
|
|
189
|
+
version: 1,
|
|
190
|
+
projectDir,
|
|
191
|
+
ok: false,
|
|
192
|
+
applied: false,
|
|
193
|
+
reason: 'No SCALE-managed upgrade backup was found.',
|
|
194
|
+
restoredFiles: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const manifest = JSON.parse(readFileSync(backup.manifestPath, 'utf-8'));
|
|
198
|
+
const restoredFiles = [];
|
|
199
|
+
for (const entry of manifest.files) {
|
|
200
|
+
const target = join(projectDir, entry.path);
|
|
201
|
+
if (entry.existed && entry.backupPath) {
|
|
202
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
203
|
+
copyFileSync(join(backup.dir, entry.backupPath), target);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
rmSync(target, { force: true, recursive: true });
|
|
207
|
+
}
|
|
208
|
+
restoredFiles.push(entry.path);
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
version: 1,
|
|
212
|
+
projectDir,
|
|
213
|
+
ok: true,
|
|
214
|
+
applied: true,
|
|
215
|
+
reason: 'Latest SCALE-managed upgrade backup was rolled back.',
|
|
216
|
+
backup,
|
|
217
|
+
restoredFiles: uniqueStrings(restoredFiles),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export function createThirdPartyUpdateReport(category) {
|
|
221
|
+
const selectedCategories = Array.isArray(category) ? new Set(category) : category ? new Set([category]) : undefined;
|
|
222
|
+
const entries = TOOL_CAPABILITY_CATALOG
|
|
223
|
+
.filter(tool => !selectedCategories || selectedCategories.has(tool.category))
|
|
224
|
+
.map(tool => {
|
|
225
|
+
const trust = classifyThirdPartyTrust(tool.category, tool.source);
|
|
226
|
+
const updatePolicy = updatePolicyForTrust(trust);
|
|
227
|
+
return {
|
|
228
|
+
id: tool.id,
|
|
229
|
+
name: tool.name,
|
|
230
|
+
category: tool.category,
|
|
231
|
+
source: tool.source,
|
|
232
|
+
trust,
|
|
233
|
+
updatePolicy,
|
|
234
|
+
installPolicy: 'never-auto-install',
|
|
235
|
+
latestVersion: 'unknown',
|
|
236
|
+
reason: updateReason(tool.category, trust),
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
const trusted = entries.filter(entry => entry.trust === 'trusted').length;
|
|
240
|
+
const community = entries.filter(entry => entry.trust === 'community').length;
|
|
241
|
+
const highRisk = entries.filter(entry => entry.trust === 'high-risk').length;
|
|
242
|
+
const blocked = entries.filter(entry => entry.updatePolicy === 'blocked').length;
|
|
243
|
+
const reviewRequired = entries.filter(entry => entry.updatePolicy !== 'check-only').length;
|
|
244
|
+
return {
|
|
245
|
+
version: 1,
|
|
246
|
+
policy: 'check-only',
|
|
247
|
+
summary: {
|
|
248
|
+
total: entries.length,
|
|
249
|
+
trusted,
|
|
250
|
+
community,
|
|
251
|
+
highRisk,
|
|
252
|
+
reviewRequired,
|
|
253
|
+
blocked,
|
|
254
|
+
},
|
|
255
|
+
reviewRequired,
|
|
256
|
+
entries,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function upgradeApplyResult(projectDir, plan, ok, applied, reason, changedFiles) {
|
|
260
|
+
return {
|
|
261
|
+
version: 1,
|
|
262
|
+
projectDir,
|
|
263
|
+
ok,
|
|
264
|
+
applied,
|
|
265
|
+
reason,
|
|
266
|
+
changedFiles,
|
|
267
|
+
plan,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function createUpgradeBackup(projectDir, relativePaths) {
|
|
271
|
+
const id = `upgrade-${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
272
|
+
const dir = join(projectDir, '.scale', 'backups', id);
|
|
273
|
+
const filesDir = join(dir, 'files');
|
|
274
|
+
mkdirSync(filesDir, { recursive: true });
|
|
275
|
+
const manifest = {
|
|
276
|
+
version: 1,
|
|
277
|
+
id,
|
|
278
|
+
createdAt: new Date().toISOString(),
|
|
279
|
+
projectDir,
|
|
280
|
+
files: uniqueStrings(relativePaths).map(path => {
|
|
281
|
+
const target = join(projectDir, path);
|
|
282
|
+
if (!existsSync(target))
|
|
283
|
+
return { path, existed: false };
|
|
284
|
+
const backupPath = join('files', path.replace(/^[\\/]+/, '').replace(/\\/g, '/'));
|
|
285
|
+
const backupTarget = join(dir, backupPath);
|
|
286
|
+
mkdirSync(dirname(backupTarget), { recursive: true });
|
|
287
|
+
copyFileSync(target, backupTarget);
|
|
288
|
+
return { path, existed: true, backupPath };
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
const manifestPath = join(dir, 'manifest.json');
|
|
292
|
+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
293
|
+
return { id, dir, manifestPath };
|
|
294
|
+
}
|
|
295
|
+
function mergeCreatedFilesIntoBackup(manifestPath, createdFiles) {
|
|
296
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
297
|
+
const existing = new Set(manifest.files.map(file => file.path));
|
|
298
|
+
for (const path of createdFiles) {
|
|
299
|
+
if (!existing.has(path)) {
|
|
300
|
+
manifest.files.push({ path, existed: false });
|
|
301
|
+
existing.add(path);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
305
|
+
}
|
|
306
|
+
function latestUpgradeBackup(projectDir) {
|
|
307
|
+
const backupsDir = join(projectDir, '.scale', 'backups');
|
|
308
|
+
if (!existsSync(backupsDir))
|
|
309
|
+
return null;
|
|
310
|
+
const candidates = readdirSync(backupsDir, { withFileTypes: true })
|
|
311
|
+
.filter(entry => entry.isDirectory() && entry.name.startsWith('upgrade-'))
|
|
312
|
+
.map(entry => ({
|
|
313
|
+
id: entry.name,
|
|
314
|
+
dir: join(backupsDir, entry.name),
|
|
315
|
+
manifestPath: join(backupsDir, entry.name, 'manifest.json'),
|
|
316
|
+
}))
|
|
317
|
+
.filter(entry => existsSync(entry.manifestPath))
|
|
318
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
319
|
+
return candidates.at(-1) ?? null;
|
|
320
|
+
}
|
|
321
|
+
function normalizeProjectRelativePath(projectDir, path) {
|
|
322
|
+
const normalizedProject = resolve(projectDir).replace(/\\/g, '/');
|
|
323
|
+
const normalizedPath = resolve(path).replace(/\\/g, '/');
|
|
324
|
+
if (!normalizedPath.startsWith(`${normalizedProject}/`))
|
|
325
|
+
return null;
|
|
326
|
+
return normalizedPath.slice(normalizedProject.length + 1);
|
|
327
|
+
}
|
|
328
|
+
function uniqueStrings(items) {
|
|
329
|
+
return [...new Set(items)];
|
|
330
|
+
}
|
|
331
|
+
export function writeUpgradePlanHtml(report, outputPath) {
|
|
332
|
+
const target = outputPath ?? join(report.projectDir, '.scale', 'reports', 'upgrade-plan.html');
|
|
333
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
334
|
+
writeFileSync(target, renderUpgradePlanHtml(report), 'utf-8');
|
|
335
|
+
return target;
|
|
336
|
+
}
|
|
337
|
+
export function listAvailableGovernancePackVersions() {
|
|
338
|
+
return listGovernanceTemplatePacks().map(pack => ({ id: pack.id, version: pack.version }));
|
|
339
|
+
}
|
|
340
|
+
function resolveUpgradeStatus(input) {
|
|
341
|
+
if (!input.hasLock)
|
|
342
|
+
return 'missing-lock';
|
|
343
|
+
if (input.hasLocalChanges)
|
|
344
|
+
return 'local-changes';
|
|
345
|
+
if (input.hasMissingFiles || !input.scaleUpToDate || !input.packUpToDate)
|
|
346
|
+
return 'updates-available';
|
|
347
|
+
return 'clean';
|
|
348
|
+
}
|
|
349
|
+
function normalizeTargetVersion(version) {
|
|
350
|
+
if (!version || version === 'latest')
|
|
351
|
+
return SCALE_ENGINE_VERSION;
|
|
352
|
+
return version;
|
|
353
|
+
}
|
|
354
|
+
function classifyThirdPartyTrust(category, source) {
|
|
355
|
+
if (category === 'desktop')
|
|
356
|
+
return 'high-risk';
|
|
357
|
+
if (!source)
|
|
358
|
+
return 'community';
|
|
359
|
+
if (source.includes('anthropics/') ||
|
|
360
|
+
source.includes('playwright.dev') ||
|
|
361
|
+
source.includes('openai/') ||
|
|
362
|
+
source.includes('google-gemini/') ||
|
|
363
|
+
source.includes('vercel-labs/'))
|
|
364
|
+
return 'trusted';
|
|
365
|
+
return 'community';
|
|
366
|
+
}
|
|
367
|
+
function updatePolicyForTrust(trust) {
|
|
368
|
+
if (trust === 'high-risk')
|
|
369
|
+
return 'blocked';
|
|
370
|
+
if (trust === 'community')
|
|
371
|
+
return 'manual-review';
|
|
372
|
+
return 'check-only';
|
|
373
|
+
}
|
|
374
|
+
function updateReason(category, trust) {
|
|
375
|
+
if (trust === 'high-risk')
|
|
376
|
+
return 'High-privilege desktop automation must be reviewed and confirmed by a human.';
|
|
377
|
+
if (trust === 'community')
|
|
378
|
+
return 'Community source requires source, script, and permission review before update.';
|
|
379
|
+
if (category === 'mcp')
|
|
380
|
+
return 'MCP updates must still be checked for command and permission changes.';
|
|
381
|
+
return 'Trusted source; check version and changelog before applying.';
|
|
382
|
+
}
|
|
383
|
+
function renderUpgradePlanHtml(report) {
|
|
384
|
+
const rows = report.steps.map(step => `
|
|
385
|
+
<tr>
|
|
386
|
+
<td>${escapeHtml(step.action)}</td>
|
|
387
|
+
<td>${escapeHtml(step.path ?? '')}</td>
|
|
388
|
+
<td>${escapeHtml(step.risk)}</td>
|
|
389
|
+
<td>${escapeHtml(step.reason)}</td>
|
|
390
|
+
<td><code>${escapeHtml(step.command ?? '')}</code></td>
|
|
391
|
+
</tr>`).join('');
|
|
392
|
+
const blockers = report.blockers.length
|
|
393
|
+
? report.blockers.map(blocker => `<li><strong>${escapeHtml(blocker.code)}</strong> ${escapeHtml(blocker.path ?? '')} ${escapeHtml(blocker.message)}</li>`).join('')
|
|
394
|
+
: '<li>No blockers detected.</li>';
|
|
395
|
+
return `<!doctype html>
|
|
396
|
+
<html lang="zh-CN">
|
|
397
|
+
<head>
|
|
398
|
+
<meta charset="utf-8" />
|
|
399
|
+
<title>SCALE Upgrade Plan</title>
|
|
400
|
+
<style>
|
|
401
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 32px; color: #1f2937; }
|
|
402
|
+
h1 { margin-bottom: 8px; }
|
|
403
|
+
table { border-collapse: collapse; width: 100%; margin-top: 16px; }
|
|
404
|
+
th, td { border: 1px solid #d1d5db; padding: 8px; text-align: left; vertical-align: top; }
|
|
405
|
+
th { background: #f3f4f6; }
|
|
406
|
+
code { white-space: pre-wrap; }
|
|
407
|
+
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2ff; }
|
|
408
|
+
</style>
|
|
409
|
+
</head>
|
|
410
|
+
<body>
|
|
411
|
+
<h1>SCALE Upgrade Plan</h1>
|
|
412
|
+
<p>Project: <code>${escapeHtml(report.projectDir)}</code></p>
|
|
413
|
+
<p>Status: <span class="badge">${escapeHtml(report.status)}</span> Apply mode: <span class="badge">${escapeHtml(report.applyMode)}</span></p>
|
|
414
|
+
<h2>Blockers</h2>
|
|
415
|
+
<ul>${blockers}</ul>
|
|
416
|
+
<h2>Steps</h2>
|
|
417
|
+
<table>
|
|
418
|
+
<thead><tr><th>Action</th><th>Path</th><th>Risk</th><th>Reason</th><th>Command</th></tr></thead>
|
|
419
|
+
<tbody>${rows}</tbody>
|
|
420
|
+
</table>
|
|
421
|
+
<h2>Third-party Policy</h2>
|
|
422
|
+
<p>Policy: ${escapeHtml(report.check.thirdParty.policy)}. Review required: ${report.check.thirdParty.reviewRequired}.</p>
|
|
423
|
+
</body>
|
|
424
|
+
</html>
|
|
425
|
+
`;
|
|
426
|
+
}
|
|
427
|
+
function escapeHtml(value) {
|
|
428
|
+
return value
|
|
429
|
+
.replace(/&/g, '&')
|
|
430
|
+
.replace(/</g, '<')
|
|
431
|
+
.replace(/>/g, '>')
|
|
432
|
+
.replace(/"/g, '"');
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=UpgradeManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpgradeManager.js","sourceRoot":"","sources":["../../src/workflow/UpgradeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC/G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,oCAAoC,CAAA;AACzG,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAA8B,MAAM,qBAAqB,CAAA;AAC5G,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAyB,MAAM,8BAA8B,CAAA;AAChI,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAqJnE,MAAM,UAAU,wBAAwB,CAAC,UAAiC,EAAE;IAC1E,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/D,MAA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,CAAC"}
|
package/docs/README.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
| [CODE_INTELLIGENCE.md](CODE_INTELLIGENCE.md) | CodeGraph、Graphify 和显式 fallback 的代码智能与探索 ROI |
|
|
26
26
|
| [WORKFLOW_EVAL.md](WORKFLOW_EVAL.md) | Workflow Eval、pass@k 指标、Failure Replay 和改进候选 |
|
|
27
27
|
| [SKILL_RADAR.md](SKILL_RADAR.md) | Skill Radar、能力置信度、证据要求和供应链安全检查 |
|
|
28
|
+
| [UPGRADE_MANAGEMENT.md](UPGRADE_MANAGEMENT.md) | SCALE CLI、governance pack、skills、MCP 和 CLI 工具的安全升级流程 |
|
|
28
29
|
| [GOVERNANCE_DASHBOARD.md](GOVERNANCE_DASHBOARD.md) | Runtime、eval、memory、resource、HTML artifact 的统一治理面板 |
|
|
29
30
|
| [RELEASE_READINESS.md](RELEASE_READINESS.md) | 发版前质量门槛、官方 demo 和真实项目落地验收 |
|
|
30
31
|
| [SKILL-REPOSITORY.md](SKILL-REPOSITORY.md) | 受治理 skill repository 和安装安全策略 |
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Resource Governance
|
|
2
|
+
|
|
3
|
+
SCALE now treats project outputs as governed resources instead of undifferentiated files.
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
Engineering agents generate many useful but noisy assets:
|
|
8
|
+
|
|
9
|
+
- maintained product and architecture docs
|
|
10
|
+
- task plans and verification notes
|
|
11
|
+
- E2E reports, screenshots, videos, logs, and coverage output
|
|
12
|
+
- temporary scripts and scratch files
|
|
13
|
+
- reusable automation scripts
|
|
14
|
+
- API contracts and ADRs
|
|
15
|
+
|
|
16
|
+
Without lifecycle rules these files drift, conflict with the real codebase, or get committed to Git when they should be local evidence only.
|
|
17
|
+
|
|
18
|
+
## Model
|
|
19
|
+
|
|
20
|
+
`scale assets scan` classifies resources into:
|
|
21
|
+
|
|
22
|
+
| Type | Default Git policy | Lifecycle |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| canonical-doc | commit | maintained |
|
|
25
|
+
| decision-record | commit | immutable |
|
|
26
|
+
| contract | commit | maintained |
|
|
27
|
+
| reusable-script | commit | maintained |
|
|
28
|
+
| task-artifact | review | task-scoped |
|
|
29
|
+
| evidence-report | ignore | generated |
|
|
30
|
+
| generated-media | review/external | generated or review-required |
|
|
31
|
+
| temporary | ignore | temporary |
|
|
32
|
+
|
|
33
|
+
`.scale/resource-policy.json` owns defaults such as owners, module mapping, runtime directories, and maximum Git file size.
|
|
34
|
+
|
|
35
|
+
`.scale/assets.json` is the explicit catalog for long-lived project assets and source-of-truth declarations.
|
|
36
|
+
Declared source-of-truth assets are checked by `assets doctor`; if the file disappears, the doctor fails. Maintained assets can also declare `lastReviewedAt` and `reviewIntervalDays` so product, architecture, workflow, and standards documents are rechecked against the current implementation instead of drifting silently:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"assets": [
|
|
41
|
+
{
|
|
42
|
+
"path": "docs/modules/auth/architecture.md",
|
|
43
|
+
"type": "canonical-doc",
|
|
44
|
+
"owner": "auth-team",
|
|
45
|
+
"module": "auth",
|
|
46
|
+
"sourceOfTruth": true,
|
|
47
|
+
"lifecycle": "maintained",
|
|
48
|
+
"gitPolicy": "commit",
|
|
49
|
+
"lastReviewedAt": "2026-05-15",
|
|
50
|
+
"reviewIntervalDays": 90
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
scale assets scan --json
|
|
60
|
+
scale assets doctor --json
|
|
61
|
+
scale assets settle --task-id <task-id> --artifact-dir .planning/tasks/<task>
|
|
62
|
+
scale init --governance-pack resource-governance
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`assets doctor` fails when runtime evidence or external media is already tracked by Git, or when a declared source-of-truth asset is missing. It warns on large tracked files, expired temporary outputs, ownerless canonical documentation, missing non-source catalog entries, and stale maintained assets.
|
|
66
|
+
|
|
67
|
+
`assets settle` runs the same checks and appends a settlement section to `resource-impact.md` when a task artifact directory is provided.
|
|
68
|
+
|
|
69
|
+
## Finish Rule
|
|
70
|
+
|
|
71
|
+
Before finishing M/L/CRITICAL work:
|
|
72
|
+
|
|
73
|
+
1. Promote final product, API, or architecture truth into maintained docs.
|
|
74
|
+
2. Keep task-scoped planning, runtime contracts, reality checks, cleanup notes, raw reports, logs, screenshots, videos, and scratch scripts out of long-lived `docs/` unless deliberately promoted.
|
|
75
|
+
3. Run `scale assets scan --json`.
|
|
76
|
+
4. Run `scale assets doctor --json`.
|
|
77
|
+
5. Run `scale assets settle --task-id <task-id> --artifact-dir <task-dir>`.
|
|
78
|
+
6. Delete or archive temporary resources that are no longer needed.
|
|
79
|
+
|
|
80
|
+
## Task Artifact Boundary
|
|
81
|
+
|
|
82
|
+
New SCALE task artifacts default to `.planning/tasks/<task>/`, not `docs/worklog/tasks/<task>/`.
|
|
83
|
+
|
|
84
|
+
Every M/L/CRITICAL task should keep these three evidence files alongside the normal explore/plan/verification/review/summary set:
|
|
85
|
+
|
|
86
|
+
| File | Purpose |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `runtime.md` | Records configuration source, topology, auth mode, and verification boundary. |
|
|
89
|
+
| `reality-check.md` | Separates confirmed behavior from not verified, stub/partial, credential-gated, and environment-gated claims. |
|
|
90
|
+
| `resource-cleanup.md` | Records which outputs stay task-scoped, which are promoted, and which should be deleted or archived. |
|
|
91
|
+
|
|
92
|
+
`docs/worklog/tasks/` remains a legacy-recognized task-artifact location for existing projects, but generated guidance now points new work to `.planning/tasks/`.
|
package/docs/start/README.md
CHANGED
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
3. 回到根目录 [README](../../README.md)
|
|
14
14
|
理解 SCALE Engine 的核心能力和 governance pack 选择。
|
|
15
15
|
|
|
16
|
-
4.
|
|
16
|
+
4. [升级管理](../UPGRADE_MANAGEMENT.md)
|
|
17
|
+
理解工作流更新、第三方 skills/MCP/CLI 更新时如何先检查、生成计划、避免覆盖本地改动。
|
|
18
|
+
|
|
19
|
+
5. 查看 [文档地图](../README.md)
|
|
17
20
|
区分哪些文档是用户指南、哪些是参考资料、哪些是历史规划和过程记录。
|
|
18
21
|
|
|
19
22
|
## 你应该先看到什么
|
|
@@ -39,4 +42,5 @@
|
|
|
39
42
|
| Go 多服务后端 | `scale init --governance-pack go-service-matrix` |
|
|
40
43
|
| 多仓库/MOE 工作区 | `scale init --governance-pack moe-workspace` |
|
|
41
44
|
| 文档、报告、截图、脚本混乱 | `scale init --governance-pack resource-governance` |
|
|
45
|
+
| 工作流或第三方能力要升级 | `scale upgrade check && scale upgrade plan --html` |
|
|
42
46
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# CONTEXT.md
|
|
2
|
+
|
|
3
|
+
Project: Agent Governance Demo
|
|
4
|
+
|
|
5
|
+
| Term | Definition | Examples | Aliases | Source |
|
|
6
|
+
|------|------------|----------|---------|--------|
|
|
7
|
+
| OAuth state | One-time callback correlation value that binds authorization return traffic to a user session | `state-123` | callback state | `src/oauth-state.ts` |
|
|
8
|
+
| Consumed state | A state record that has already been used and must not be accepted again | `consumedAt: 900` | replayed state | `tests/oauth-state.test.ts` |
|
|
9
|
+
| Evidence | A command result or artifact that proves what was verified | `npm test`, eval report, dashboard | verification proof | SCALE workflow |
|
|
10
|
+
|
|
11
|
+
## Rejected Meanings
|
|
12
|
+
|
|
13
|
+
- Do not treat an expired state as recoverable without a new authorization flow.
|
|
14
|
+
- Do not treat a dashboard or eval report as a substitute for the business test.
|