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,395 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const REQUIRED_CHECKS = [
|
|
8
|
+
{
|
|
9
|
+
path: 'lib/workspace/takeover-baseline.js',
|
|
10
|
+
requiredSnippets: [
|
|
11
|
+
'FOUR_SENTENCE_TEACHING_CORE_PRINCIPLE_HEADING',
|
|
12
|
+
'SUPREME_ONLY_CORE_PRINCIPLE_HEADING',
|
|
13
|
+
'LITTLE_NINE_CORE_PRINCIPLE_HEADING',
|
|
14
|
+
'RULES_GUIDE_BASELINE_HEADING',
|
|
15
|
+
'RULES_GUIDE_REQUIRED_LINES',
|
|
16
|
+
'REQUIRED_CORE_PRINCIPLE_SECTION_LINES',
|
|
17
|
+
'REQUIRED_RULES_GUIDE_SECTIONS',
|
|
18
|
+
'先在 `errorbook` 记录或更新 incident,再用二分法配合 debug 日志/埋点快速收敛范围',
|
|
19
|
+
'所有由 Agent 生成的脚本、报告、诊断、调试日志、测试脚本、临时分析和验证产物默认归档到当前 `.sce/specs/<spec>/` 的对应子目录'
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: '.sce/steering/CORE_PRINCIPLES.md',
|
|
24
|
+
requiredSnippets: [
|
|
25
|
+
'四句教:先判断该不该做',
|
|
26
|
+
'知善知恶是良知',
|
|
27
|
+
'最高原则只保留四句教 + 小九条',
|
|
28
|
+
'勤奋推进,不偷懒,不跳步',
|
|
29
|
+
'按第一性原理先做计划并自主持续推进',
|
|
30
|
+
'保持项目活地图',
|
|
31
|
+
'否则不中途停在“等你指示”',
|
|
32
|
+
'若某条内容不能直接提升道德判断、目标理解、调查质量、判断质量或闭环效率,就不应继续占用最高原则层。'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
path: 'template/.sce/steering/CORE_PRINCIPLES.md',
|
|
37
|
+
requiredSnippets: [
|
|
38
|
+
'四句教:先判断该不该做',
|
|
39
|
+
'知善知恶是良知',
|
|
40
|
+
'最高原则只保留四句教 + 小九条',
|
|
41
|
+
'勤奋推进,不偷懒,不跳步',
|
|
42
|
+
'按第一性原理先做计划并自主持续推进',
|
|
43
|
+
'保持项目活地图',
|
|
44
|
+
'否则不中途停在“等你指示”',
|
|
45
|
+
'若某条内容不能直接提升道德判断、目标理解、调查质量、判断质量或闭环效率,就不应继续占用最高原则层。'
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: '.sce/steering/RULES_GUIDE.md',
|
|
50
|
+
requiredSnippets: [
|
|
51
|
+
'治理基线(非最高原则)',
|
|
52
|
+
'所有需求先落 Spec;所有由 Agent 生成的脚本、报告、诊断、调试日志、测试脚本、临时分析和验证产物默认归档到当前 `.sce/specs/<spec>/` 的对应子目录',
|
|
53
|
+
'先在 `errorbook` 记录或更新 incident,再用二分法配合 debug 日志/埋点快速收敛范围',
|
|
54
|
+
'业务场景未知时先澄清,不得把未知范围直接变成一刀切禁用',
|
|
55
|
+
'可复用执行经验、阈值、案例和策略,优先写入 `docs/steering-governance.md` 或 `.sce/knowledge/lessons/`'
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: 'template/.sce/steering/RULES_GUIDE.md',
|
|
60
|
+
requiredSnippets: [
|
|
61
|
+
'治理基线(非最高原则)',
|
|
62
|
+
'所有需求先落 Spec;所有由 Agent 生成的脚本、报告、诊断、调试日志、测试脚本、临时分析和验证产物默认归档到当前 `.sce/specs/<spec>/` 的对应子目录',
|
|
63
|
+
'先在 `errorbook` 记录或更新 incident,再用二分法配合 debug 日志/埋点快速收敛范围',
|
|
64
|
+
'业务场景未知时先澄清,不得把未知范围直接变成一刀切禁用',
|
|
65
|
+
'可复用执行经验、阈值、案例和策略,优先写入 `docs/steering-governance.md` 或 `.sce/knowledge/lessons/`'
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
path: '.sce/config/supreme-principles-policy.json',
|
|
70
|
+
requiredSnippets: [
|
|
71
|
+
'"allow_planning_actions"',
|
|
72
|
+
'"allow_execution_actions"',
|
|
73
|
+
'"clarify_question"',
|
|
74
|
+
'"refuse_rules"',
|
|
75
|
+
'"rewrite_rules"',
|
|
76
|
+
'"narrow_rules"'
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
path: 'template/.sce/config/supreme-principles-policy.json',
|
|
81
|
+
requiredSnippets: [
|
|
82
|
+
'"allow_planning_actions"',
|
|
83
|
+
'"allow_execution_actions"',
|
|
84
|
+
'"clarify_question"',
|
|
85
|
+
'"refuse_rules"',
|
|
86
|
+
'"rewrite_rules"',
|
|
87
|
+
'"narrow_rules"'
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
path: '.sce/steering/CURRENT_CONTEXT.md',
|
|
92
|
+
requiredSnippets: [
|
|
93
|
+
'单项目多协作通道默认成立',
|
|
94
|
+
'`focusedChannelId` 只表示当前 UI 焦点',
|
|
95
|
+
'多个 `channel/session` 同时推进',
|
|
96
|
+
'`channel/session` 继续作为用户可见协作单元',
|
|
97
|
+
'每个 `project + channel/session` 独立保存 `scene/spec/doc/session/tabs/tree/draft/runState`',
|
|
98
|
+
'同项目双通道并行不串现场'
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
path: 'template/.sce/steering/CURRENT_CONTEXT.md',
|
|
103
|
+
requiredSnippets: [
|
|
104
|
+
'单项目多协作通道默认成立',
|
|
105
|
+
'`focusedChannelId` 仅表示当前 UI 焦点',
|
|
106
|
+
'多个 `channel/session` 并行推进',
|
|
107
|
+
'每个 `project + channel/session` 独立保存 `scene/spec/doc/session/tabs/tree/draft/runState`',
|
|
108
|
+
'同项目双通道并行不串现场'
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
path: 'docs/steering-governance.md',
|
|
113
|
+
requiredSnippets: [
|
|
114
|
+
'所有由 Agent 生成的脚本、报告、诊断、调试日志、测试脚本、临时分析和验证产物,默认进入当前 `.sce/specs/<spec>/` 的对应子目录。',
|
|
115
|
+
'没有明确 Spec 时,先使用通用 Spec 承接,再允许生成过程资产。',
|
|
116
|
+
'最高原则只保留“四句教 + 小九条”',
|
|
117
|
+
'世界观:无善无恶心之始。',
|
|
118
|
+
'以下内容仍然重要,但默认属于“治理基线”而不是“最高原则”',
|
|
119
|
+
'Spec 承载与 Agent 产物归档位置',
|
|
120
|
+
'勤奋推进,不偷懒,不跳步。',
|
|
121
|
+
'按第一性原理先做计划并自主持续推进',
|
|
122
|
+
'保持项目活地图,知道当前结构、边界、依赖和风险点。',
|
|
123
|
+
'否则不中途停在“等你指示”',
|
|
124
|
+
'若项目当前实践已进入“单项目多协作通道默认成立”,`CURRENT_CONTEXT.md` 必须显式写明',
|
|
125
|
+
'项目层最多只允许一个 `focusedChannelId` 作为当前 UI 焦点',
|
|
126
|
+
'同项目双通道并行不串现场'
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
path: 'docs/document-governance.md',
|
|
131
|
+
requiredSnippets: [
|
|
132
|
+
'Agent-generated artifacts, debug logs, test scripts, reports, and analysis notes must stay in the active Spec subdirectories',
|
|
133
|
+
'Temporary documents (like `*-SUMMARY.md`, `SESSION-*.md`) must live under the active Spec while in use and must be deleted after use',
|
|
134
|
+
'Keep Agent Output Scoped'
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
path: 'lib/governance/supreme-principles.js',
|
|
139
|
+
requiredSnippets: [
|
|
140
|
+
'DEFAULT_SUPREME_PRINCIPLES_POLICY_PATH',
|
|
141
|
+
'evaluateSupremeIntent',
|
|
142
|
+
'assessSupremeIntent',
|
|
143
|
+
'buildSupremeRefusalError',
|
|
144
|
+
'buildNativeGovernedReply',
|
|
145
|
+
'writeSupremeIntentEvidence',
|
|
146
|
+
'recordSupremeIntentAssessment',
|
|
147
|
+
'无善无恶心之始',
|
|
148
|
+
'有善有恶意之动',
|
|
149
|
+
'知善知恶是良知',
|
|
150
|
+
'为善去恶是格物'
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
path: 'lib/commands/studio.js',
|
|
155
|
+
requiredSnippets: [
|
|
156
|
+
'const supremeAssessment = await assessSupremeIntent({',
|
|
157
|
+
'persistStudioSupremeIntentAssessment',
|
|
158
|
+
'throw buildSupremeRefusalError(supremeAssessment);',
|
|
159
|
+
'goal_original: goal || null',
|
|
160
|
+
'supreme_principles: supremeAssessment',
|
|
161
|
+
'supreme_intent_evidence: supremeEvidence ? supremeEvidence.relative_path : null',
|
|
162
|
+
'supreme_intent_record ='
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
path: 'lib/studio/spec-intake-governor.js',
|
|
167
|
+
requiredSnippets: [
|
|
168
|
+
'const supremeAssessment = options.supreme_principles',
|
|
169
|
+
'effective_goal: effectiveGoal || null',
|
|
170
|
+
'supreme_principles: supremeAssessment',
|
|
171
|
+
"action: 'refuse'",
|
|
172
|
+
"source: 'supreme-principles'"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: 'lib/semantic/native-runtime.js',
|
|
177
|
+
requiredSnippets: [
|
|
178
|
+
'const supremeAssessment = await assessSupremeIntent({',
|
|
179
|
+
'const governedReply = buildNativeGovernedReply(supremeAssessment);',
|
|
180
|
+
'recordSupremeIntentAssessment',
|
|
181
|
+
'if (supremeAssessment.execution_allowed) {',
|
|
182
|
+
'supreme_intent_evidence: supremeEvidence ? supremeEvidence.relative_path : null',
|
|
183
|
+
'supreme_principles: {',
|
|
184
|
+
'supreme_intent_record: supremeLedgerEntry'
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
path: 'lib/problem/problem-evaluator.js',
|
|
189
|
+
requiredSnippets: [
|
|
190
|
+
'Record or update an errorbook staging incident before the next patch attempt.',
|
|
191
|
+
'Use bisection-style debug logs to halve the failing scope by module, call path, data slice, or change set on each iteration.'
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
path: 'README.md',
|
|
196
|
+
requiredSnippets: [
|
|
197
|
+
'`studio plan`, `studio intake`, and `native ask` pass through the Four Teachings supreme-intent gate first',
|
|
198
|
+
'`CORE_PRINCIPLES.md` keeps only `Four Teachings + Little Nine` in the supreme-principle layer',
|
|
199
|
+
'After two failed localization rounds, record/update an `errorbook` incident and use bisection-style debug logs',
|
|
200
|
+
'Agent-generated scripts, reports, debug logs, test scripts, and temporary analysis default to the active Spec subdirectories'
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
path: 'README.zh.md',
|
|
205
|
+
requiredSnippets: [
|
|
206
|
+
'连续两轮以上仍未成功定位问题时,SCE 默认要求先补 `errorbook` incident,再用二分式 debug 日志快速收敛范围',
|
|
207
|
+
'Agent 生成的脚本、报告、调试日志、测试脚本和临时分析默认进入当前 Spec 子目录;没有明确 Spec 时先用通用 Spec 承接',
|
|
208
|
+
'默认遵守“小九条”执行姿态',
|
|
209
|
+
'`CORE_PRINCIPLES.md` 的最高原则层默认只保留“四句教 + 小九条”'
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
path: 'docs/command-reference.md',
|
|
214
|
+
requiredSnippets: [
|
|
215
|
+
'`studio plan` / `studio intake` first pass through the Four Teachings supreme-intent gate',
|
|
216
|
+
'`native ask` also passes through the same supreme-intent gate before semantic activation',
|
|
217
|
+
'Supreme policy file: `.sce/config/supreme-principles-policy.json`',
|
|
218
|
+
'When a bound spec already exists, the assessment is written to `.sce/specs/<spec>/custom/supreme-intent-assessment.json`.',
|
|
219
|
+
'The same assessment is also written into the SQLite/state supreme-intent ledger',
|
|
220
|
+
'Reports supreme-intent ledger counts (`allow|clarify|rewrite|narrow|refuse`) plus governed-action rate across the filtered scope',
|
|
221
|
+
'`node scripts/agent-governance-baseline-audit.js [--project-path <path>] [--out <path>] [--fail-on-violation] [--json]`'
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
227
|
+
const options = {
|
|
228
|
+
projectPath: process.cwd(),
|
|
229
|
+
json: false,
|
|
230
|
+
failOnViolation: false,
|
|
231
|
+
out: null
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
235
|
+
const token = argv[index];
|
|
236
|
+
const next = argv[index + 1];
|
|
237
|
+
if (token === '--project-path' && next) {
|
|
238
|
+
options.projectPath = path.resolve(next);
|
|
239
|
+
index += 1;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (token === '--json') {
|
|
243
|
+
options.json = true;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (token === '--fail-on-violation') {
|
|
247
|
+
options.failOnViolation = true;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (token === '--out' && next) {
|
|
251
|
+
options.out = path.resolve(next);
|
|
252
|
+
index += 1;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (token === '--help' || token === '-h') {
|
|
256
|
+
printHelpAndExit(0);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return options;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function printHelpAndExit(code) {
|
|
264
|
+
const lines = [
|
|
265
|
+
'Usage: node scripts/agent-governance-baseline-audit.js [options]',
|
|
266
|
+
'',
|
|
267
|
+
'Options:',
|
|
268
|
+
' --project-path <path> Project root to audit (default: current directory)',
|
|
269
|
+
' --json Print JSON payload',
|
|
270
|
+
' --fail-on-violation Exit code 2 when any violation is found',
|
|
271
|
+
' --out <path> Write JSON payload to file',
|
|
272
|
+
' -h, --help Show this help'
|
|
273
|
+
];
|
|
274
|
+
console.log(lines.join('\n'));
|
|
275
|
+
process.exit(code);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function normalizeSlashes(value) {
|
|
279
|
+
return `${value || ''}`.replace(/\\/g, '/');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function isOptionalLocalBaselineFile(relativePath) {
|
|
283
|
+
return relativePath === '.sce/steering/CURRENT_CONTEXT.md';
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function pushViolation(violations, severity, rule, file, message) {
|
|
287
|
+
violations.push({
|
|
288
|
+
severity,
|
|
289
|
+
rule,
|
|
290
|
+
file,
|
|
291
|
+
message
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function auditAgentGovernanceBaseline(options = {}) {
|
|
296
|
+
const projectPath = path.resolve(options.projectPath || process.cwd());
|
|
297
|
+
const violations = [];
|
|
298
|
+
const checkedFiles = [];
|
|
299
|
+
|
|
300
|
+
for (const check of REQUIRED_CHECKS) {
|
|
301
|
+
const relativePath = normalizeSlashes(check.path);
|
|
302
|
+
const absolutePath = path.join(projectPath, relativePath);
|
|
303
|
+
checkedFiles.push(relativePath);
|
|
304
|
+
if (!fs.existsSync(absolutePath)) {
|
|
305
|
+
if (isOptionalLocalBaselineFile(relativePath)) {
|
|
306
|
+
pushViolation(
|
|
307
|
+
violations,
|
|
308
|
+
'warning',
|
|
309
|
+
'missing_optional_local_baseline_file',
|
|
310
|
+
relativePath,
|
|
311
|
+
`Optional local-only agent-governance baseline file is absent in this checkout: ${relativePath}`
|
|
312
|
+
);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
pushViolation(
|
|
316
|
+
violations,
|
|
317
|
+
'error',
|
|
318
|
+
'missing_required_file',
|
|
319
|
+
relativePath,
|
|
320
|
+
`Required agent-governance baseline file is missing: ${relativePath}`
|
|
321
|
+
);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
326
|
+
for (const snippet of check.requiredSnippets) {
|
|
327
|
+
if (!content.includes(snippet)) {
|
|
328
|
+
pushViolation(
|
|
329
|
+
violations,
|
|
330
|
+
'error',
|
|
331
|
+
'missing_required_snippet',
|
|
332
|
+
relativePath,
|
|
333
|
+
`Missing required agent-governance snippet: ${snippet}`
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const errorCount = violations.filter((item) => item.severity === 'error').length;
|
|
340
|
+
return {
|
|
341
|
+
mode: 'agent-governance-baseline-audit',
|
|
342
|
+
project_path: projectPath,
|
|
343
|
+
checked_files: checkedFiles,
|
|
344
|
+
violation_count: violations.length,
|
|
345
|
+
error_count: errorCount,
|
|
346
|
+
warning_count: violations.filter((item) => item.severity === 'warning').length,
|
|
347
|
+
passed: errorCount === 0,
|
|
348
|
+
violations
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function writeReportIfNeeded(report, outPath) {
|
|
353
|
+
if (!outPath) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const resolved = path.resolve(outPath);
|
|
357
|
+
fs.mkdirSync(path.dirname(resolved), { recursive: true });
|
|
358
|
+
fs.writeFileSync(resolved, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function main() {
|
|
362
|
+
const options = parseArgs(process.argv.slice(2));
|
|
363
|
+
const report = auditAgentGovernanceBaseline(options);
|
|
364
|
+
writeReportIfNeeded(report, options.out);
|
|
365
|
+
|
|
366
|
+
if (options.json) {
|
|
367
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
368
|
+
} else if (report.passed) {
|
|
369
|
+
console.log('[agent-governance-baseline-audit] passed');
|
|
370
|
+
} else {
|
|
371
|
+
console.error(`[agent-governance-baseline-audit] failed with ${report.violation_count} violation(s)`);
|
|
372
|
+
for (const violation of report.violations) {
|
|
373
|
+
console.error(`[agent-governance-baseline-audit] ${violation.rule} ${violation.file}: ${violation.message}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (options.failOnViolation && !report.passed) {
|
|
378
|
+
process.exitCode = 2;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (require.main === module) {
|
|
383
|
+
try {
|
|
384
|
+
main();
|
|
385
|
+
} catch (error) {
|
|
386
|
+
console.error(`[agent-governance-baseline-audit] ${error.message}`);
|
|
387
|
+
process.exit(1);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
module.exports = {
|
|
392
|
+
REQUIRED_CHECKS,
|
|
393
|
+
parseArgs,
|
|
394
|
+
auditAgentGovernanceBaseline
|
|
395
|
+
};
|
|
@@ -24,9 +24,9 @@ const REQUIRED_CHECKS = [
|
|
|
24
24
|
{
|
|
25
25
|
path: 'lib/workspace/takeover-baseline.js',
|
|
26
26
|
requiredSnippets: [
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
27
|
+
'CLARIFICATION_FIRST_RULE_GUIDE_LINE',
|
|
28
|
+
'_reconcileRulesGuideBaseline',
|
|
29
|
+
'业务场景未知时先澄清,不得把未知范围直接变成一刀切禁用;修改问题前先建立问题契约和证据,不得靠猜测碰运气。'
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -37,17 +37,17 @@ const REQUIRED_CHECKS = [
|
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
path: '.sce/steering/
|
|
40
|
+
path: '.sce/steering/RULES_GUIDE.md',
|
|
41
41
|
requiredSnippets: [
|
|
42
|
-
'
|
|
43
|
-
'
|
|
42
|
+
'业务场景未知时先澄清,不得把未知范围直接变成一刀切禁用',
|
|
43
|
+
'修改问题前先建立问题契约和证据,不得靠猜测碰运气。'
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
path: 'template/.sce/steering/
|
|
47
|
+
path: 'template/.sce/steering/RULES_GUIDE.md',
|
|
48
48
|
requiredSnippets: [
|
|
49
|
-
'
|
|
50
|
-
'
|
|
49
|
+
'业务场景未知时先澄清,不得把未知范围直接变成一刀切禁用',
|
|
50
|
+
'修改问题前先建立问题契约和证据,不得靠猜测碰运气。'
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
53
|
{
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const ENTRY_CHECKS = [
|
|
8
|
+
{
|
|
9
|
+
path: 'docs/quick-start-with-ai-tools.md',
|
|
10
|
+
requiredSnippets: [
|
|
11
|
+
'host tools are collaboration shells, not the source of project truth',
|
|
12
|
+
'Use this path only when direct governed execution is unavailable. It is a compatibility bridge, not the long-term primary model.'
|
|
13
|
+
],
|
|
14
|
+
prohibitedPatterns: [
|
|
15
|
+
/sce\s+不是独立开发工具/,
|
|
16
|
+
/sce\s+是 AI 工具的增强器/,
|
|
17
|
+
/手动导出上下文(Claude\/ChatGPT)- 当前方式/,
|
|
18
|
+
/AI 主动调用 sce(Windsurf\/Cline)- 最佳/
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
path: 'docs/integration-philosophy.md',
|
|
23
|
+
requiredSnippets: [
|
|
24
|
+
'SCE should not silently fall back from explicit `project + channel` input to unrelated global guesses.',
|
|
25
|
+
'The long-term direction is SCE-native semantic/runtime capability with governed backflow and operator control.',
|
|
26
|
+
'top-level docs must describe the current mainline first'
|
|
27
|
+
],
|
|
28
|
+
prohibitedPatterns: [
|
|
29
|
+
/sce\s+不是独立开发工具/,
|
|
30
|
+
/sce\s+是 AI 工具的增强器/
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
path: 'docs/integration-modes.md',
|
|
35
|
+
requiredSnippets: [
|
|
36
|
+
'## Mode 1: Takeover Mode',
|
|
37
|
+
'## Mode 2: Compatibility Export Mode',
|
|
38
|
+
'Do not default backward to compatibility mode when direct governed execution is available.'
|
|
39
|
+
],
|
|
40
|
+
prohibitedPatterns: [
|
|
41
|
+
/AI 主动调用 sce(Windsurf\/Cline)- 最佳/,
|
|
42
|
+
/手动导出上下文(Claude\/ChatGPT)- 当前方式/
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
path: 'template/README.md',
|
|
47
|
+
requiredSnippets: [
|
|
48
|
+
'It is not an old `ultrawork_enhancer.py` walkthrough anymore.',
|
|
49
|
+
'One project supports multiple collaboration channels/sessions in parallel by default'
|
|
50
|
+
],
|
|
51
|
+
prohibitedPatterns: [
|
|
52
|
+
/Sisyphus Ultrawork/i,
|
|
53
|
+
/ultrawork_enhancer\.py requirements/i
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
path: 'template/.sce/README.md',
|
|
58
|
+
requiredSnippets: [
|
|
59
|
+
'Treat `.sce/steering/CURRENT_CONTEXT.md` as a summary, not the truth source',
|
|
60
|
+
'All agent-generated logs, reports, debug artifacts, and test scripts default into the active Spec subtree'
|
|
61
|
+
],
|
|
62
|
+
prohibitedPatterns: [
|
|
63
|
+
/create-spec <name>/,
|
|
64
|
+
/sce context export <spec-name>/,
|
|
65
|
+
/sce prompt generate <spec> <task>/,
|
|
66
|
+
/📋 Available Workflows/
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
72
|
+
const options = {
|
|
73
|
+
projectPath: process.cwd(),
|
|
74
|
+
json: false,
|
|
75
|
+
failOnViolation: false,
|
|
76
|
+
out: null
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
80
|
+
const token = argv[index];
|
|
81
|
+
const next = argv[index + 1];
|
|
82
|
+
if (token === '--project-path' && next) {
|
|
83
|
+
options.projectPath = path.resolve(next);
|
|
84
|
+
index += 1;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (token === '--json') {
|
|
88
|
+
options.json = true;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (token === '--fail-on-violation') {
|
|
92
|
+
options.failOnViolation = true;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (token === '--out' && next) {
|
|
96
|
+
options.out = path.resolve(next);
|
|
97
|
+
index += 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (token === '--help' || token === '-h') {
|
|
101
|
+
printHelpAndExit(0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return options;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function printHelpAndExit(code) {
|
|
109
|
+
const lines = [
|
|
110
|
+
'Usage: node scripts/deprecated-entry-audit.js [options]',
|
|
111
|
+
'',
|
|
112
|
+
'Options:',
|
|
113
|
+
' --project-path <path> Project root to audit (default: current directory)',
|
|
114
|
+
' --json Print JSON payload',
|
|
115
|
+
' --fail-on-violation Exit code 2 when any violation is found',
|
|
116
|
+
' --out <path> Write JSON payload to file',
|
|
117
|
+
' -h, --help Show this help'
|
|
118
|
+
];
|
|
119
|
+
console.log(lines.join('\n'));
|
|
120
|
+
process.exit(code);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function normalizeSlashes(value) {
|
|
124
|
+
return `${value || ''}`.replace(/\\/g, '/');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function pushViolation(violations, severity, rule, file, message) {
|
|
128
|
+
violations.push({
|
|
129
|
+
severity,
|
|
130
|
+
rule,
|
|
131
|
+
file,
|
|
132
|
+
message
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function auditDeprecatedEntry(options = {}) {
|
|
137
|
+
const projectPath = path.resolve(options.projectPath || process.cwd());
|
|
138
|
+
const violations = [];
|
|
139
|
+
const checkedFiles = [];
|
|
140
|
+
|
|
141
|
+
for (const check of ENTRY_CHECKS) {
|
|
142
|
+
const relativePath = normalizeSlashes(check.path);
|
|
143
|
+
const absolutePath = path.join(projectPath, relativePath);
|
|
144
|
+
checkedFiles.push(relativePath);
|
|
145
|
+
|
|
146
|
+
if (!fs.existsSync(absolutePath)) {
|
|
147
|
+
pushViolation(
|
|
148
|
+
violations,
|
|
149
|
+
'error',
|
|
150
|
+
'missing_required_file',
|
|
151
|
+
relativePath,
|
|
152
|
+
`Required entry document is missing: ${relativePath}`
|
|
153
|
+
);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
158
|
+
for (const snippet of check.requiredSnippets || []) {
|
|
159
|
+
if (!content.includes(snippet)) {
|
|
160
|
+
pushViolation(
|
|
161
|
+
violations,
|
|
162
|
+
'error',
|
|
163
|
+
'missing_required_snippet',
|
|
164
|
+
relativePath,
|
|
165
|
+
`Missing required entry-governance snippet: ${snippet}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
for (const pattern of check.prohibitedPatterns || []) {
|
|
171
|
+
pattern.lastIndex = 0;
|
|
172
|
+
const match = pattern.exec(content);
|
|
173
|
+
if (match) {
|
|
174
|
+
pushViolation(
|
|
175
|
+
violations,
|
|
176
|
+
'error',
|
|
177
|
+
'prohibited_legacy_entry_phrase',
|
|
178
|
+
relativePath,
|
|
179
|
+
`Deprecated entry phrase matched: ${match[0]}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const errorCount = violations.filter((item) => item.severity === 'error').length;
|
|
186
|
+
return {
|
|
187
|
+
mode: 'deprecated-entry-audit',
|
|
188
|
+
project_path: projectPath,
|
|
189
|
+
checked_files: checkedFiles,
|
|
190
|
+
violation_count: violations.length,
|
|
191
|
+
error_count: errorCount,
|
|
192
|
+
passed: violations.length === 0,
|
|
193
|
+
violations
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function writeReportIfNeeded(report, outPath) {
|
|
198
|
+
if (!outPath) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const resolved = path.resolve(outPath);
|
|
202
|
+
fs.mkdirSync(path.dirname(resolved), { recursive: true });
|
|
203
|
+
fs.writeFileSync(resolved, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function main() {
|
|
207
|
+
const options = parseArgs(process.argv.slice(2));
|
|
208
|
+
const report = auditDeprecatedEntry(options);
|
|
209
|
+
writeReportIfNeeded(report, options.out);
|
|
210
|
+
|
|
211
|
+
if (options.json) {
|
|
212
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
213
|
+
} else if (report.passed) {
|
|
214
|
+
console.log('[deprecated-entry-audit] passed');
|
|
215
|
+
} else {
|
|
216
|
+
console.error(`[deprecated-entry-audit] failed with ${report.violation_count} violation(s)`);
|
|
217
|
+
for (const violation of report.violations) {
|
|
218
|
+
console.error(`[deprecated-entry-audit] ${violation.rule} ${violation.file}: ${violation.message}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (options.failOnViolation && !report.passed) {
|
|
223
|
+
process.exitCode = 2;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (require.main === module) {
|
|
228
|
+
try {
|
|
229
|
+
main();
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error(`[deprecated-entry-audit] ${error.message}`);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
module.exports = {
|
|
237
|
+
ENTRY_CHECKS,
|
|
238
|
+
parseArgs,
|
|
239
|
+
auditDeprecatedEntry
|
|
240
|
+
};
|