scene-capability-engine 3.6.32 → 3.6.36
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/CHANGELOG.md +86 -1
- package/README.md +119 -122
- package/README.zh.md +123 -121
- package/bin/scene-capability-engine.js +11 -0
- package/docs/README.md +21 -32
- package/docs/auto-refactor-index.md +384 -0
- package/docs/command-reference.md +94 -2
- package/docs/magicball-adaptation-task-checklist-v1.md +385 -0
- package/docs/magicball-app-bundle-sqlite-and-command-draft.md +539 -0
- package/docs/magicball-capability-iteration-api.md +2 -0
- package/docs/magicball-capability-iteration-ui.md +2 -0
- package/docs/magicball-capability-library.md +2 -0
- package/docs/magicball-cli-invocation-examples.md +336 -0
- package/docs/magicball-frontend-state-and-command-mapping.md +244 -0
- package/docs/magicball-integration-doc-index.md +137 -0
- package/docs/magicball-integration-issue-tracker.md +218 -0
- package/docs/magicball-mode-home-and-ontology-empty-state-playbook.md +249 -0
- package/docs/magicball-sce-adaptation-guide.md +203 -0
- package/docs/magicball-three-mode-alignment-plan.md +551 -0
- package/docs/magicball-ui-surface-checklist.md +126 -0
- package/docs/magicball-write-auth-adaptation-guide.md +328 -0
- package/docs/refactor-completion-roadmap.md +116 -0
- package/docs/zh/README.md +27 -30
- package/docs/zh/refactor-completion-roadmap.md +116 -0
- package/lib/app/registry-config.js +73 -0
- package/lib/app/registry-sync-service.js +228 -0
- package/lib/auto/archive-schema-service.js +276 -0
- package/lib/auto/archive-summary.js +60 -0
- package/lib/auto/batch-goal-input-service.js +543 -0
- package/lib/auto/batch-output.js +201 -0
- package/lib/auto/batch-summary-storage-service.js +110 -0
- package/lib/auto/close-loop-batch-service.js +116 -0
- package/lib/auto/close-loop-controller-service.js +287 -0
- package/lib/auto/close-loop-program-service.js +283 -0
- package/lib/auto/close-loop-recovery-service.js +191 -0
- package/lib/auto/close-loop-session-storage-service.js +50 -0
- package/lib/auto/controller-lock-service.js +55 -0
- package/lib/auto/controller-output.js +32 -0
- package/lib/auto/controller-queue-service.js +127 -0
- package/lib/auto/controller-session-storage-service.js +105 -0
- package/lib/auto/governance-advisory-service.js +208 -0
- package/lib/auto/governance-close-loop-service.js +411 -0
- package/lib/auto/governance-maintenance-presenter.js +162 -0
- package/lib/auto/governance-maintenance-service.js +112 -0
- package/lib/auto/governance-session-presenter.js +70 -0
- package/lib/auto/governance-session-storage-service.js +198 -0
- package/lib/auto/governance-signals.js +139 -0
- package/lib/auto/governance-stats-presenter.js +337 -0
- package/lib/auto/governance-stats-service.js +115 -0
- package/lib/auto/governance-summary.js +703 -0
- package/lib/auto/handoff-capability-matrix-service.js +281 -0
- package/lib/auto/handoff-evidence-review-service.js +251 -0
- package/lib/auto/handoff-release-evidence-service.js +190 -0
- package/lib/auto/handoff-release-gate-history-loaders-service.js +502 -0
- package/lib/auto/handoff-release-gate-history-service.js +257 -0
- package/lib/auto/handoff-reporting-service.js +1407 -0
- package/lib/auto/handoff-run-service.js +486 -0
- package/lib/auto/handoff-snapshots-service.js +645 -0
- package/lib/auto/observability-service.js +132 -0
- package/lib/auto/output-writer.js +34 -0
- package/lib/auto/program-auto-remediation-service.js +130 -0
- package/lib/auto/program-diagnostics.js +138 -0
- package/lib/auto/program-governance-helpers.js +306 -0
- package/lib/auto/program-governance-loop-service.js +413 -0
- package/lib/auto/program-output.js +106 -0
- package/lib/auto/program-summary.js +183 -0
- package/lib/auto/recovery-memory-service.js +684 -0
- package/lib/auto/recovery-selection-service.js +52 -0
- package/lib/auto/retention-policy.js +98 -0
- package/lib/auto/session-persistence-service.js +106 -0
- package/lib/auto/session-presenter.js +105 -0
- package/lib/auto/session-prune-service.js +190 -0
- package/lib/auto/session-query-service.js +249 -0
- package/lib/auto/spec-protection.js +141 -0
- package/lib/commands/app.js +911 -0
- package/lib/commands/assurance.js +212 -0
- package/lib/commands/auto.js +1091 -11063
- package/lib/commands/mode.js +321 -0
- package/lib/commands/ontology.js +415 -0
- package/lib/commands/pm.js +422 -0
- package/lib/ontology/seed-profiles.js +160 -0
- package/lib/state/sce-state-store.js +3369 -1200
- package/package.json +1 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const { getSceStateStore } = require('../state/sce-state-store');
|
|
4
|
+
|
|
5
|
+
function normalizeString(value) {
|
|
6
|
+
if (typeof value !== 'string') {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
return value.trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function normalizePositiveInteger(value, fallback = 100, max = 1000) {
|
|
13
|
+
const parsed = Number.parseInt(`${value}`, 10);
|
|
14
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
return Math.min(parsed, max);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createStore(dependencies = {}) {
|
|
21
|
+
const projectPath = dependencies.projectPath || process.cwd();
|
|
22
|
+
const fileSystem = dependencies.fileSystem || fs;
|
|
23
|
+
const env = dependencies.env || process.env;
|
|
24
|
+
return dependencies.stateStore || getSceStateStore(projectPath, {
|
|
25
|
+
fileSystem,
|
|
26
|
+
env
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function countBy(items = [], key = 'status') {
|
|
31
|
+
return items.reduce((acc, item) => {
|
|
32
|
+
const value = normalizeString(item && item[key]) || 'unknown';
|
|
33
|
+
acc[value] = (acc[value] || 0) + 1;
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function buildStatus(statusLabel, attentionLevel, blockingSummary = '', recommendedAction = '') {
|
|
39
|
+
return {
|
|
40
|
+
attention_level: attentionLevel,
|
|
41
|
+
status_tone: attentionLevel === 'high' ? 'warning' : (attentionLevel === 'medium' ? 'info' : 'success'),
|
|
42
|
+
status_label: statusLabel,
|
|
43
|
+
blocking_summary: blockingSummary,
|
|
44
|
+
recommended_action: recommendedAction
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function attachResourceViewModel(items = []) {
|
|
49
|
+
return items.map((item) => ({
|
|
50
|
+
...item,
|
|
51
|
+
mb_status: buildStatus(
|
|
52
|
+
item.status === 'healthy' ? '正常' : '关注',
|
|
53
|
+
item.status === 'blocked' || item.status === 'degraded' ? 'high' : 'low',
|
|
54
|
+
item.summary || '',
|
|
55
|
+
'继续检查资源状态与恢复策略'
|
|
56
|
+
)
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function attachLogViewModel(items = []) {
|
|
61
|
+
return items.map((item) => ({
|
|
62
|
+
...item,
|
|
63
|
+
mb_status: buildStatus(
|
|
64
|
+
item.status === 'ready' ? '可查看' : '待处理',
|
|
65
|
+
item.status === 'error' ? 'high' : 'low',
|
|
66
|
+
item.summary || '',
|
|
67
|
+
'继续查看日志摘要与过滤视图'
|
|
68
|
+
)
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function attachBackupViewModel(items = []) {
|
|
73
|
+
return items.map((item) => ({
|
|
74
|
+
...item,
|
|
75
|
+
mb_status: buildStatus(
|
|
76
|
+
item.recoverable === true ? '可恢复' : '仅归档',
|
|
77
|
+
item.recoverable === true ? 'low' : 'medium',
|
|
78
|
+
item.summary || '',
|
|
79
|
+
'继续核对备份可恢复性'
|
|
80
|
+
)
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function attachConfigViewModel(items = []) {
|
|
85
|
+
return items.map((item) => ({
|
|
86
|
+
...item,
|
|
87
|
+
mb_status: buildStatus(
|
|
88
|
+
item.status === 'aligned' ? '已对齐' : '待确认',
|
|
89
|
+
item.status === 'drift' ? 'high' : 'medium',
|
|
90
|
+
item.summary || '',
|
|
91
|
+
'继续核对 desired/actual state'
|
|
92
|
+
)
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function buildTablePayload(mode, query, items, columns) {
|
|
97
|
+
return {
|
|
98
|
+
mode,
|
|
99
|
+
query,
|
|
100
|
+
summary: {
|
|
101
|
+
total: items.length,
|
|
102
|
+
by_status: countBy(items, 'status')
|
|
103
|
+
},
|
|
104
|
+
items,
|
|
105
|
+
filters: [],
|
|
106
|
+
sort: [{ key: 'updated_at', direction: 'desc' }],
|
|
107
|
+
view_model: {
|
|
108
|
+
type: 'table',
|
|
109
|
+
columns
|
|
110
|
+
},
|
|
111
|
+
mb_status: {
|
|
112
|
+
status_label: items.length > 0 ? '有数据' : '空状态',
|
|
113
|
+
attention_level: items.length > 0 ? 'low' : 'medium'
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function printPayload(payload, options = {}, title = 'Assurance') {
|
|
119
|
+
if (options.json) {
|
|
120
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
console.log(chalk.blue(title));
|
|
124
|
+
if (payload.mode) console.log(` Mode: ${payload.mode}`);
|
|
125
|
+
if (payload.summary && typeof payload.summary === 'object') {
|
|
126
|
+
for (const [key, value] of Object.entries(payload.summary)) {
|
|
127
|
+
console.log(` ${key}: ${typeof value === 'object' ? JSON.stringify(value) : value}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function runAssuranceResourceStatusCommand(options = {}, dependencies = {}) {
|
|
133
|
+
const store = createStore(dependencies);
|
|
134
|
+
const items = attachResourceViewModel(await store.listAssuranceResourceSnapshots({
|
|
135
|
+
limit: normalizePositiveInteger(options.limit, 100, 1000),
|
|
136
|
+
status: options.status
|
|
137
|
+
}) || []);
|
|
138
|
+
const payload = buildTablePayload('assurance-resource-status', { space: normalizeString(options.space) || 'engineering', resource: 'resource' }, items, ['snapshot_id', 'resource_type', 'resource_name', 'status', 'summary', 'updated_at']);
|
|
139
|
+
printPayload(payload, options, 'Assurance Resource Status');
|
|
140
|
+
return payload;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function runAssuranceLogsViewsCommand(options = {}, dependencies = {}) {
|
|
144
|
+
const store = createStore(dependencies);
|
|
145
|
+
const items = attachLogViewModel(await store.listAssuranceLogViews({
|
|
146
|
+
limit: normalizePositiveInteger(options.limit, 100, 1000),
|
|
147
|
+
status: options.status
|
|
148
|
+
}) || []);
|
|
149
|
+
const payload = buildTablePayload('assurance-logs-views', { space: normalizeString(options.space) || 'engineering', resource: 'logs' }, items, ['view_id', 'title', 'source', 'status', 'summary', 'path_ref', 'updated_at']);
|
|
150
|
+
printPayload(payload, options, 'Assurance Logs Views');
|
|
151
|
+
return payload;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function runAssuranceBackupListCommand(options = {}, dependencies = {}) {
|
|
155
|
+
const store = createStore(dependencies);
|
|
156
|
+
const items = attachBackupViewModel(await store.listAssuranceBackupRecords({
|
|
157
|
+
limit: normalizePositiveInteger(options.limit, 100, 1000),
|
|
158
|
+
status: options.status
|
|
159
|
+
}) || []);
|
|
160
|
+
const payload = buildTablePayload('assurance-backup-list', { space: normalizeString(options.space) || 'engineering', resource: 'backup' }, items, ['backup_id', 'title', 'backup_type', 'scope', 'status', 'recoverable', 'generated_at', 'updated_at']);
|
|
161
|
+
printPayload(payload, options, 'Assurance Backup List');
|
|
162
|
+
return payload;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function runAssuranceConfigSwitchesCommand(options = {}, dependencies = {}) {
|
|
166
|
+
const store = createStore(dependencies);
|
|
167
|
+
const items = attachConfigViewModel(await store.listAssuranceConfigSwitches({
|
|
168
|
+
limit: normalizePositiveInteger(options.limit, 100, 1000),
|
|
169
|
+
status: options.status
|
|
170
|
+
}) || []);
|
|
171
|
+
const payload = buildTablePayload('assurance-config-switches', { space: normalizeString(options.space) || 'engineering', resource: 'config' }, items, ['switch_id', 'title', 'scope', 'switch_key', 'desired_state', 'actual_state', 'status', 'updated_at']);
|
|
172
|
+
printPayload(payload, options, 'Assurance Config Switches');
|
|
173
|
+
return payload;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function safeRun(handler, options = {}, context = 'assurance command') {
|
|
177
|
+
Promise.resolve(handler(options))
|
|
178
|
+
.catch((error) => {
|
|
179
|
+
if (options.json) {
|
|
180
|
+
console.log(JSON.stringify({ success: false, error: error.message }, null, 2));
|
|
181
|
+
} else {
|
|
182
|
+
console.error(chalk.red(`${context} failed:`), error.message);
|
|
183
|
+
}
|
|
184
|
+
process.exitCode = 1;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function registerAssuranceCommands(program) {
|
|
189
|
+
const assurance = program
|
|
190
|
+
.command('assurance')
|
|
191
|
+
.description('Engineering assurance data plane for MagicBall engineering mode');
|
|
192
|
+
|
|
193
|
+
const resource = assurance.command('resource').description('Resource status views');
|
|
194
|
+
resource.command('status').option('--space <space>', 'Space name', 'engineering').option('--limit <n>', 'Maximum rows', '100').option('--status <status>', 'Filter by status').option('--json', 'Print machine-readable JSON output').action((options) => safeRun(runAssuranceResourceStatusCommand, options, 'assurance resource status'));
|
|
195
|
+
|
|
196
|
+
const logs = assurance.command('logs').description('Log view summaries');
|
|
197
|
+
logs.command('views').option('--space <space>', 'Space name', 'engineering').option('--limit <n>', 'Maximum rows', '100').option('--status <status>', 'Filter by status').option('--json', 'Print machine-readable JSON output').action((options) => safeRun(runAssuranceLogsViewsCommand, options, 'assurance logs views'));
|
|
198
|
+
|
|
199
|
+
const backup = assurance.command('backup').description('Backup and restore summaries');
|
|
200
|
+
backup.command('list').option('--space <space>', 'Space name', 'engineering').option('--limit <n>', 'Maximum rows', '100').option('--status <status>', 'Filter by status').option('--json', 'Print machine-readable JSON output').action((options) => safeRun(runAssuranceBackupListCommand, options, 'assurance backup list'));
|
|
201
|
+
|
|
202
|
+
const config = assurance.command('config').description('Config switch summaries');
|
|
203
|
+
config.command('switches').option('--space <space>', 'Space name', 'engineering').option('--limit <n>', 'Maximum rows', '100').option('--status <status>', 'Filter by status').option('--json', 'Print machine-readable JSON output').action((options) => safeRun(runAssuranceConfigSwitchesCommand, options, 'assurance config switches'));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports = {
|
|
207
|
+
runAssuranceResourceStatusCommand,
|
|
208
|
+
runAssuranceLogsViewsCommand,
|
|
209
|
+
runAssuranceBackupListCommand,
|
|
210
|
+
runAssuranceConfigSwitchesCommand,
|
|
211
|
+
registerAssuranceCommands
|
|
212
|
+
};
|