scene-capability-engine 3.6.65 → 3.6.67
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 +16 -0
- package/README.md +17 -6
- package/README.zh.md +18 -6
- package/bin/scene-capability-engine.js +4 -0
- package/docs/README.md +2 -2
- package/docs/command-reference.md +382 -6
- package/docs/document-governance.md +3 -2
- package/docs/integration-modes.md +62 -478
- package/docs/integration-philosophy.md +56 -263
- package/docs/magicball-project-portfolio-contract.md +114 -2
- package/docs/project-management/README.md +14 -0
- package/docs/project-management/assurance/backup.md +3 -0
- package/docs/project-management/assurance/config.md +3 -0
- package/docs/project-management/assurance/evidence/README.md +3 -0
- package/docs/project-management/assurance/incidents/README.md +3 -0
- package/docs/project-management/assurance/logs.md +3 -0
- package/docs/project-management/assurance/overview.md +3 -0
- package/docs/project-management/assurance/recovery/README.md +3 -0
- package/docs/project-management/assurance/resource.md +3 -0
- package/docs/project-management/assurance/runbooks/README.md +3 -0
- package/docs/project-management/delivery/acceptance/README.md +3 -0
- package/docs/project-management/delivery/acceptance/evidence/README.md +3 -0
- package/docs/project-management/delivery/acceptance/exceptions/README.md +3 -0
- package/docs/project-management/delivery/acceptance/reports/README.md +3 -0
- package/docs/project-management/delivery/documents/changes.md +3 -0
- package/docs/project-management/delivery/documents/issues.md +3 -0
- package/docs/project-management/delivery/documents/overview.md +3 -0
- package/docs/project-management/delivery/documents/planning.md +3 -0
- package/docs/project-management/delivery/documents/requirements.md +3 -0
- package/docs/project-management/delivery/documents/tracking.md +3 -0
- package/docs/project-management/delivery/handoffs/README.md +3 -0
- package/docs/project-management/delivery/handoffs/evidence/README.md +3 -0
- package/docs/project-management/delivery/handoffs/records/README.md +3 -0
- package/docs/project-management/delivery/overview.md +10 -0
- package/docs/project-management/delivery/releases/README.md +3 -0
- package/docs/project-management/delivery/releases/baselines/README.md +3 -0
- package/docs/project-management/delivery/releases/evidence/README.md +3 -0
- package/docs/project-management/delivery/tables/changes.md +3 -0
- package/docs/project-management/delivery/tables/issues.md +3 -0
- package/docs/project-management/delivery/tables/planning.md +3 -0
- package/docs/project-management/delivery/tables/requirements.md +3 -0
- package/docs/project-management/delivery/tables/tracking.md +3 -0
- package/docs/project-management/environment/agent-discovery.md +3 -0
- package/docs/project-management/environment/development.md +3 -0
- package/docs/project-management/environment/overview.md +10 -0
- package/docs/project-management/environment/testing.md +3 -0
- package/docs/project-management/environment/version-alignment.md +3 -0
- package/docs/quick-start-with-ai-tools.md +68 -308
- package/docs/releases/README.md +2 -0
- package/docs/releases/v3.6.66.md +23 -0
- package/docs/releases/v3.6.67.md +23 -0
- package/docs/steering-governance.md +64 -2
- package/docs/zh/README.md +2 -2
- package/docs/zh/releases/README.md +2 -0
- package/docs/zh/releases/v3.6.66.md +23 -0
- package/docs/zh/releases/v3.6.67.md +23 -0
- package/lib/commands/adopt.js +24 -0
- package/lib/commands/native.js +158 -0
- package/lib/commands/project.js +95 -0
- package/lib/commands/semantic.js +1459 -0
- package/lib/commands/session.js +74 -3
- package/lib/commands/spec-bootstrap.js +10 -1
- package/lib/commands/spec-gate.js +10 -1
- package/lib/commands/spec-pipeline.js +10 -1
- package/lib/commands/studio.js +405 -30
- package/lib/commands/task.js +141 -7
- package/lib/governance/supreme-principles.js +530 -0
- package/lib/problem/problem-evaluator.js +4 -0
- package/lib/project/candidate-inspection-service.js +24 -1
- package/lib/project/portfolio-projection-service.js +315 -5
- package/lib/project/project-channel-output.js +94 -0
- package/lib/project/project-channel-projection.js +181 -0
- package/lib/project/root-onboarding-service.js +60 -8
- package/lib/project/semantic-shared-source-projection.js +150 -0
- package/lib/project/supervision-action-model.js +277 -0
- package/lib/project/supervision-projection-service.js +305 -5
- package/lib/project/target-resolution-service.js +70 -5
- package/lib/project/visibility-policy.js +93 -0
- package/lib/runtime/multi-spec-scene-session.js +8 -1
- package/lib/runtime/project-channel-context-store.js +387 -0
- package/lib/runtime/project-channel-context.js +406 -0
- package/lib/runtime/scene-session-binding.js +46 -0
- package/lib/runtime/session-store.js +186 -0
- package/lib/runtime/steering-contract.js +7 -1
- package/lib/semantic/archive-report.js +283 -0
- package/lib/semantic/archive-routing.js +67 -0
- package/lib/semantic/backflow-report.js +245 -0
- package/lib/semantic/capability-contract.js +30 -0
- package/lib/semantic/delta-export.js +145 -0
- package/lib/semantic/interaction-observer.js +254 -0
- package/lib/semantic/kernel-loader.js +881 -0
- package/lib/semantic/native-runtime.js +359 -0
- package/lib/semantic/progress-ledger.js +433 -0
- package/lib/semantic/replay-evaluator.js +382 -0
- package/lib/semantic/shared-publication.js +592 -0
- package/lib/semantic/shared-source-config.js +183 -0
- package/lib/semantic/shared-source-connect.js +139 -0
- package/lib/semantic/shared-source-discovery.js +98 -0
- package/lib/semantic/shared-sync-export.js +413 -0
- package/lib/semantic/shared-sync-intake.js +592 -0
- package/lib/semantic/shared-sync-merge.js +547 -0
- package/lib/semantic/shared-sync-release.js +463 -0
- package/lib/semantic/supreme-intent-report.js +300 -0
- package/lib/state/sce-state-store.js +1360 -0
- package/lib/steering/context-sync-manager.js +276 -25
- package/lib/studio/spec-intake-governor.js +39 -3
- package/lib/studio/task-envelope.js +35 -2
- package/lib/workspace/takeover-baseline.js +342 -83
- package/package.json +7 -2
- package/scripts/agent-governance-baseline-audit.js +395 -0
- package/scripts/clarification-first-audit.js +9 -9
- package/scripts/deprecated-entry-audit.js +240 -0
- package/scripts/release-posture-report.js +262 -0
- package/template/.sce/README.md +62 -228
- package/template/.sce/config/semantic-shared-sources.json +5 -0
- package/template/.sce/config/supreme-principles-policy.json +105 -0
- package/template/.sce/config/takeover-baseline.json +7 -0
- package/template/.sce/steering/CORE_PRINCIPLES.md +23 -63
- package/template/.sce/steering/CURRENT_CONTEXT.md +4 -0
- package/template/.sce/steering/RULES_GUIDE.md +17 -9
- package/template/README.md +32 -96
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
const { getSceStateStore } = require('../state/sce-state-store');
|
|
2
|
+
|
|
3
|
+
function normalizeString(value) {
|
|
4
|
+
if (typeof value !== 'string') {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
return value.trim();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function normalizeInteger(value, fallback = 0) {
|
|
11
|
+
const parsed = Number.parseInt(`${value}`, 10);
|
|
12
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function percent(part, total) {
|
|
19
|
+
if (!Number.isFinite(part) || !Number.isFinite(total) || total <= 0) {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
return Number(((part / total) * 100).toFixed(2));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function incrementCounter(map, key, amount = 1) {
|
|
26
|
+
if (!key) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
map[key] = (map[key] || 0) + amount;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function countBy(items = [], getKey) {
|
|
33
|
+
const totals = {};
|
|
34
|
+
for (const item of items) {
|
|
35
|
+
const key = normalizeString(getKey(item));
|
|
36
|
+
incrementCounter(totals, key || 'unknown');
|
|
37
|
+
}
|
|
38
|
+
return Object.entries(totals)
|
|
39
|
+
.map(([key, count]) => ({ key, count }))
|
|
40
|
+
.sort((left, right) => {
|
|
41
|
+
if (right.count !== left.count) {
|
|
42
|
+
return right.count - left.count;
|
|
43
|
+
}
|
|
44
|
+
return left.key.localeCompare(right.key);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function listMatchedRuleIds(matchedRules = {}) {
|
|
49
|
+
const ids = new Set();
|
|
50
|
+
if (!matchedRules || typeof matchedRules !== 'object') {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
for (const value of Object.values(matchedRules)) {
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
for (const item of value) {
|
|
56
|
+
if (item && typeof item === 'object') {
|
|
57
|
+
const id = normalizeString(item.id || item.rule_id || item.ruleId);
|
|
58
|
+
if (id) {
|
|
59
|
+
ids.add(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (value && typeof value === 'object') {
|
|
66
|
+
const id = normalizeString(value.id || value.rule_id || value.ruleId);
|
|
67
|
+
if (id) {
|
|
68
|
+
ids.add(id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [...ids].sort((left, right) => left.localeCompare(right));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function rankGroupedItems(items = [], hotspotLimit = 5) {
|
|
76
|
+
return items
|
|
77
|
+
.sort((left, right) => {
|
|
78
|
+
if (right.governed_count !== left.governed_count) {
|
|
79
|
+
return right.governed_count - left.governed_count;
|
|
80
|
+
}
|
|
81
|
+
if (right.total !== left.total) {
|
|
82
|
+
return right.total - left.total;
|
|
83
|
+
}
|
|
84
|
+
return `${right.latest_at || ''}`.localeCompare(`${left.latest_at || ''}`);
|
|
85
|
+
})
|
|
86
|
+
.slice(0, hotspotLimit);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function buildScopeHotspots(items = [], hotspotLimit = 5) {
|
|
90
|
+
const scopes = new Map();
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
const key = [
|
|
93
|
+
normalizeString(item.project_id) || 'project:none',
|
|
94
|
+
normalizeString(item.channel_id) || 'channel:none',
|
|
95
|
+
normalizeString(item.scene_id) || 'scene:none',
|
|
96
|
+
normalizeString(item.spec_id) || 'spec:none'
|
|
97
|
+
].join('::');
|
|
98
|
+
if (!scopes.has(key)) {
|
|
99
|
+
scopes.set(key, {
|
|
100
|
+
project_id: normalizeString(item.project_id) || null,
|
|
101
|
+
channel_id: normalizeString(item.channel_id) || null,
|
|
102
|
+
scene_id: normalizeString(item.scene_id) || null,
|
|
103
|
+
spec_id: normalizeString(item.spec_id) || null,
|
|
104
|
+
total: 0,
|
|
105
|
+
allow: 0,
|
|
106
|
+
clarify: 0,
|
|
107
|
+
rewrite: 0,
|
|
108
|
+
narrow: 0,
|
|
109
|
+
refuse: 0,
|
|
110
|
+
governed_count: 0,
|
|
111
|
+
latest_at: null
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const scope = scopes.get(key);
|
|
115
|
+
const action = normalizeString(item.action) || 'unknown';
|
|
116
|
+
scope.total += 1;
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(scope, action)) {
|
|
118
|
+
scope[action] += 1;
|
|
119
|
+
}
|
|
120
|
+
if (action !== 'allow') {
|
|
121
|
+
scope.governed_count += 1;
|
|
122
|
+
}
|
|
123
|
+
const updatedAt = normalizeString(item.updated_at) || null;
|
|
124
|
+
if (!scope.latest_at || `${updatedAt || ''}` > `${scope.latest_at || ''}`) {
|
|
125
|
+
scope.latest_at = updatedAt;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return rankGroupedItems([...scopes.values()], hotspotLimit);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function buildMatchedRuleHotspots(items = [], hotspotLimit = 5) {
|
|
132
|
+
const rules = new Map();
|
|
133
|
+
for (const item of items) {
|
|
134
|
+
const ruleIds = listMatchedRuleIds(item.matched_rules);
|
|
135
|
+
for (const ruleId of ruleIds) {
|
|
136
|
+
if (!rules.has(ruleId)) {
|
|
137
|
+
rules.set(ruleId, {
|
|
138
|
+
rule_id: ruleId,
|
|
139
|
+
count: 0,
|
|
140
|
+
actions: {},
|
|
141
|
+
sources: {},
|
|
142
|
+
latest_at: null
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const record = rules.get(ruleId);
|
|
146
|
+
const action = normalizeString(item.action) || 'unknown';
|
|
147
|
+
const sourceKind = normalizeString(item.source_kind) || 'unknown';
|
|
148
|
+
record.count += 1;
|
|
149
|
+
incrementCounter(record.actions, action);
|
|
150
|
+
incrementCounter(record.sources, sourceKind);
|
|
151
|
+
const updatedAt = normalizeString(item.updated_at) || null;
|
|
152
|
+
if (!record.latest_at || `${updatedAt || ''}` > `${record.latest_at || ''}`) {
|
|
153
|
+
record.latest_at = updatedAt;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [...rules.values()]
|
|
158
|
+
.sort((left, right) => {
|
|
159
|
+
if (right.count !== left.count) {
|
|
160
|
+
return right.count - left.count;
|
|
161
|
+
}
|
|
162
|
+
return `${right.latest_at || ''}`.localeCompare(`${left.latest_at || ''}`);
|
|
163
|
+
})
|
|
164
|
+
.slice(0, hotspotLimit)
|
|
165
|
+
.map((item) => ({
|
|
166
|
+
...item,
|
|
167
|
+
actions: countBy(
|
|
168
|
+
Object.entries(item.actions).map(([key, count]) => ({ key, count })),
|
|
169
|
+
(entry) => entry.key
|
|
170
|
+
).map((entry) => ({ action: entry.key, count: item.actions[entry.key] || entry.count })),
|
|
171
|
+
sources: countBy(
|
|
172
|
+
Object.entries(item.sources).map(([key, count]) => ({ key, count })),
|
|
173
|
+
(entry) => entry.key
|
|
174
|
+
).map((entry) => ({ source_kind: entry.key, count: item.sources[entry.key] || entry.count }))
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function summarizeRecentItems(items = [], recentLimit = 10, actionFilter = '') {
|
|
179
|
+
const normalizedAction = normalizeString(actionFilter);
|
|
180
|
+
return items
|
|
181
|
+
.filter((item) => !normalizedAction || normalizeString(item.action) === normalizedAction)
|
|
182
|
+
.sort((left, right) => `${right.updated_at || ''}`.localeCompare(`${left.updated_at || ''}`))
|
|
183
|
+
.slice(0, recentLimit)
|
|
184
|
+
.map((item) => ({
|
|
185
|
+
assessment_id: item.assessment_id,
|
|
186
|
+
project_id: item.project_id,
|
|
187
|
+
channel_id: item.channel_id,
|
|
188
|
+
session_id: item.session_id,
|
|
189
|
+
scene_id: item.scene_id,
|
|
190
|
+
spec_id: item.spec_id,
|
|
191
|
+
job_id: item.job_id,
|
|
192
|
+
source_kind: item.source_kind,
|
|
193
|
+
action: item.action,
|
|
194
|
+
planning_allowed: item.planning_allowed,
|
|
195
|
+
execution_allowed: item.execution_allowed,
|
|
196
|
+
message: item.message,
|
|
197
|
+
matched_rule_ids: listMatchedRuleIds(item.matched_rules),
|
|
198
|
+
updated_at: item.updated_at
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function buildSupremeIntentGovernanceReport(options = {}, dependencies = {}) {
|
|
203
|
+
const projectPath = dependencies.projectPath || process.cwd();
|
|
204
|
+
const store = dependencies.stateStore || getSceStateStore(projectPath, {
|
|
205
|
+
fileSystem: dependencies.fileSystem,
|
|
206
|
+
env: dependencies.env,
|
|
207
|
+
sqliteModule: dependencies.sqliteModule,
|
|
208
|
+
noCache: dependencies.noCache === true
|
|
209
|
+
});
|
|
210
|
+
const scanLimit = normalizeInteger(options.limit, 200);
|
|
211
|
+
const hotspotLimit = normalizeInteger(options.hotspot_limit || options.hotspotLimit, 5);
|
|
212
|
+
const recentLimit = normalizeInteger(options.recent_limit || options.recentLimit, 10);
|
|
213
|
+
|
|
214
|
+
let items = await store.listSupremeIntentAssessments({
|
|
215
|
+
project_id: options.project_id || options.projectId,
|
|
216
|
+
channel_id: options.channel_id || options.channelId,
|
|
217
|
+
session_id: options.session_id || options.sessionId,
|
|
218
|
+
scene_id: options.scene_id || options.sceneId,
|
|
219
|
+
spec_id: options.spec_id || options.specId,
|
|
220
|
+
job_id: options.job_id || options.jobId,
|
|
221
|
+
source_kind: options.source_kind || options.sourceKind,
|
|
222
|
+
action: options.action,
|
|
223
|
+
limit: scanLimit
|
|
224
|
+
});
|
|
225
|
+
items = Array.isArray(items) ? items : [];
|
|
226
|
+
|
|
227
|
+
const governedItems = items.filter((item) => normalizeString(item.action) && normalizeString(item.action) !== 'allow');
|
|
228
|
+
const planningBlocked = items.filter((item) => item.planning_allowed !== true);
|
|
229
|
+
const executionBlocked = items.filter((item) => item.execution_allowed !== true);
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
mode: 'semantic-governance-report',
|
|
233
|
+
success: true,
|
|
234
|
+
generated_at: new Date().toISOString(),
|
|
235
|
+
filters: {
|
|
236
|
+
project_id: normalizeString(options.project_id || options.projectId) || null,
|
|
237
|
+
channel_id: normalizeString(options.channel_id || options.channelId) || null,
|
|
238
|
+
session_id: normalizeString(options.session_id || options.sessionId) || null,
|
|
239
|
+
scene_id: normalizeString(options.scene_id || options.sceneId) || null,
|
|
240
|
+
spec_id: normalizeString(options.spec_id || options.specId) || null,
|
|
241
|
+
job_id: normalizeString(options.job_id || options.jobId) || null,
|
|
242
|
+
source_kind: normalizeString(options.source_kind || options.sourceKind) || null,
|
|
243
|
+
action: normalizeString(options.action) || null,
|
|
244
|
+
limit: scanLimit,
|
|
245
|
+
hotspot_limit: hotspotLimit,
|
|
246
|
+
recent_limit: recentLimit
|
|
247
|
+
},
|
|
248
|
+
totals: {
|
|
249
|
+
total: items.length,
|
|
250
|
+
governed: governedItems.length,
|
|
251
|
+
allow: items.filter((item) => normalizeString(item.action) === 'allow').length,
|
|
252
|
+
clarify: items.filter((item) => normalizeString(item.action) === 'clarify').length,
|
|
253
|
+
rewrite: items.filter((item) => normalizeString(item.action) === 'rewrite').length,
|
|
254
|
+
narrow: items.filter((item) => normalizeString(item.action) === 'narrow').length,
|
|
255
|
+
refuse: items.filter((item) => normalizeString(item.action) === 'refuse').length,
|
|
256
|
+
planning_blocked: planningBlocked.length,
|
|
257
|
+
execution_blocked: executionBlocked.length,
|
|
258
|
+
governed_action_rate_percent: percent(governedItems.length, items.length)
|
|
259
|
+
},
|
|
260
|
+
top_actions: countBy(items, (item) => item.action)
|
|
261
|
+
.slice(0, hotspotLimit)
|
|
262
|
+
.map((item) => ({ action: item.key, count: item.count })),
|
|
263
|
+
top_sources: countBy(items, (item) => item.source_kind)
|
|
264
|
+
.slice(0, hotspotLimit)
|
|
265
|
+
.map((item) => ({ source_kind: item.key, count: item.count })),
|
|
266
|
+
top_projects: countBy(governedItems, (item) => item.project_id)
|
|
267
|
+
.slice(0, hotspotLimit)
|
|
268
|
+
.map((item) => ({ project_id: item.key === 'unknown' ? null : item.key, count: item.count })),
|
|
269
|
+
top_channels: countBy(governedItems, (item) => `${normalizeString(item.project_id) || 'unknown'}::${normalizeString(item.channel_id) || 'none'}`)
|
|
270
|
+
.slice(0, hotspotLimit)
|
|
271
|
+
.map((item) => {
|
|
272
|
+
const [projectId, channelId] = item.key.split('::');
|
|
273
|
+
return {
|
|
274
|
+
project_id: projectId === 'unknown' ? null : projectId,
|
|
275
|
+
channel_id: channelId === 'none' ? null : channelId,
|
|
276
|
+
count: item.count
|
|
277
|
+
};
|
|
278
|
+
}),
|
|
279
|
+
top_specs: countBy(governedItems, (item) => `${normalizeString(item.project_id) || 'unknown'}::${normalizeString(item.spec_id) || 'none'}`)
|
|
280
|
+
.slice(0, hotspotLimit)
|
|
281
|
+
.map((item) => {
|
|
282
|
+
const [projectId, specId] = item.key.split('::');
|
|
283
|
+
return {
|
|
284
|
+
project_id: projectId === 'unknown' ? null : projectId,
|
|
285
|
+
spec_id: specId === 'none' ? null : specId,
|
|
286
|
+
count: item.count
|
|
287
|
+
};
|
|
288
|
+
}),
|
|
289
|
+
top_scope_hotspots: buildScopeHotspots(governedItems, hotspotLimit),
|
|
290
|
+
top_matched_rules: buildMatchedRuleHotspots(governedItems, hotspotLimit),
|
|
291
|
+
recent_governed_items: summarizeRecentItems(governedItems, recentLimit),
|
|
292
|
+
recent_refusals: summarizeRecentItems(governedItems, recentLimit, 'refuse'),
|
|
293
|
+
recent_rewrites: summarizeRecentItems(governedItems, recentLimit, 'rewrite')
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
module.exports = {
|
|
298
|
+
buildSupremeIntentGovernanceReport,
|
|
299
|
+
listMatchedRuleIds
|
|
300
|
+
};
|