scene-capability-engine 3.6.49 → 3.6.51

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 CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.6.51] - 2026-03-15
11
+
12
+ ### Changed
13
+ - Added a new core steering baseline rule requiring rewrite-style changes to remove obsolete code, dead branches, abandoned adapters, and stale references in the same change unless an explicit temporary compatibility plan exists.
14
+
15
+ ## [3.6.50] - 2026-03-14
16
+
17
+ ### Changed
18
+ - Switched the SCE co-work baseline to default-on: multi-agent config defaults to `enabled=true`, `init/adopt/takeover` now provision `.sce/config/multi-agent.json`, and adoption metadata defaults `multiUserMode` to true while keeping the central coordinator opt-in.
19
+ - Added `scripts/collab-governance-gate.js` and a shared collaboration-governance gate helper so co-work governance can run as a reusable push/publish preflight instead of remaining a report-only audit.
20
+ - Updated `sce timeline push` to fail fast on collaboration governance drift before creating a push checkpoint or executing `git push`, ensuring managed push flow respects `.gitignore` collaboration boundaries, runtime-state tracking hygiene, multi-agent config validity, legacy naming cleanup, and steering boundary rules.
21
+ - Wired `gate:collab-governance` into `prepublishOnly` so npm publish now enforces the same co-work governance baseline as managed push.
22
+
10
23
  ## [3.6.49] - 2026-03-14
11
24
 
12
25
  ### Changed
package/README.md CHANGED
@@ -142,6 +142,7 @@ SCE is opinionated by default.
142
142
  - When business scene/module/page/entity context is missing, SCE must route to clarification first; unknown business scope must not be turned into blanket disable.
143
143
  - `verify` and `release` enforce problem-closure and related gates when a spec is bound.
144
144
  - Autonomous program execution applies gate evaluation, fallback-chain logic, governance replay, and auto-remediation.
145
+ - Co-work baseline is enabled by default: initialized/adopted SCE projects provision `.sce/config/multi-agent.json` with `enabled=true`, while the central coordinator stays opt-in.
145
146
  - State persistence prefers SQLite, not ad hoc local caches.
146
147
  - Oversized source files must trigger periodic refactor assessment; SCE recommends project-specific thresholds, with `2000 / 4000 / 10000` as the default source-file fallback.
147
148
  - Release validation defaults to integration test coverage via `npm run test:release` for faster publish feedback.
@@ -217,5 +218,5 @@ MIT. See [LICENSE](LICENSE).
217
218
 
218
219
  ---
219
220
 
220
- **Version**: 3.6.49
221
- **Last Updated**: 2026-03-14
221
+ **Version**: 3.6.51
222
+ **Last Updated**: 2026-03-15
package/README.zh.md CHANGED
@@ -147,6 +147,7 @@ SCE 默认是强治理的。
147
147
  - 缺少业务场景/模块/页面/实体上下文时,SCE 必须先进入澄清,而不是把未知业务范围直接变成一刀切禁用
148
148
  - 当 spec 绑定时,`verify` 和 `release` 默认执行 problem-closure 等相关门禁
149
149
  - `close-loop-program` 默认带 gate 评估、fallback-chain、governance replay、auto-remediation
150
+ - co-work 基线默认开启:初始化或接管后的 SCE 项目会落地 `.sce/config/multi-agent.json` 且 `enabled=true`,但中央 coordinator 仍保持按需开启
150
151
  - 状态持久化默认优先走 SQLite,而不是零散本地缓存
151
152
  - 超大源文件必须定期触发重构评估;SCE 优先建议按项目给出阈值,若项目尚未设定,则默认参考 `2000 / 4000 / 10000`
152
153
  - 发布默认验证走 integration gate:`npm run test:release`
@@ -222,5 +223,5 @@ MIT,见 [LICENSE](LICENSE)。
222
223
 
223
224
  ---
224
225
 
225
- **版本**:3.6.49
226
- **最后更新**:2026-03-14
226
+ **版本**:3.6.51
227
+ **最后更新**:2026-03-15
@@ -2,8 +2,8 @@
2
2
 
3
3
  > Quick reference for all `sce` commands
4
4
 
5
- **Version**: 3.6.34
6
- **Last Updated**: 2026-03-08
5
+ **Version**: 3.6.51
6
+ **Last Updated**: 2026-03-15
7
7
 
8
8
  ---
9
9
 
@@ -127,7 +127,7 @@ sce timeline restore <snapshot-id> --prune --json
127
127
  # Update timeline policy
128
128
  sce timeline config --enabled true --interval 30 --max-entries 120 --json
129
129
 
130
- # Push with pre-push snapshot
130
+ # Push with co-work governance gate + pre-push snapshot
131
131
  sce timeline push origin main
132
132
  ```
133
133
 
@@ -135,6 +135,7 @@ Timeline policy:
135
135
  - default enabled with local retention under `.sce/timeline/snapshots/`
136
136
  - stage/key-event checkpoints are automatically captured for `studio` and `session` commands
137
137
  - interval auto-checkpoints are integrated in the same flow via timeline checkpoint capture
138
+ - `timeline push` now blocks before snapshot/push when collaboration governance drifts, so tracked runtime state, missing co-work ignore rules, legacy `.kiro*` references, invalid multi-agent config, or steering boundary drift cannot pass through managed push flow
138
139
 
139
140
  ### Value Metrics
140
141
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  > Enable multiple AI agents to work on the same sce project simultaneously without conflicts.
4
4
 
5
- **Version**: 1.44.0
6
- **Last Updated**: 2026-02-12
5
+ **Version**: 3.6.51
6
+ **Last Updated**: 2026-03-15
7
7
 
8
8
  ---
9
9
 
@@ -25,31 +25,31 @@ The Multi-Agent Parallel Coordination system solves this with six layers of prot
25
25
  10. **Spec Lifecycle Manager** — Spec state machine and auto-completion (v1.44.0)
26
26
  11. **Sync Barrier** — Agent Spec-switch synchronization (v1.44.0)
27
27
 
28
- All components are **zero overhead in single-agent mode** they become no-ops when multi-agent mode is not enabled.
28
+ SCE provisions the co-work baseline by default. If a project explicitly sets `enabled: false`, all components fall back to single-agent no-op behavior.
29
29
 
30
30
  ---
31
31
 
32
32
  ## Quick Start
33
33
 
34
- ### 1. Enable Multi-Agent Mode
34
+ ### 1. Review Multi-Agent Mode Baseline
35
35
 
36
- Create the configuration file `.sce/config/multi-agent.json`:
36
+ SCE provisions `.sce/config/multi-agent.json` by default:
37
37
 
38
38
  ```json
39
39
  {
40
40
  "enabled": true,
41
- "coordinator": false,
42
- "heartbeatIntervalMs": 30000,
43
- "heartbeatTimeoutMs": 120000
41
+ "coordinatorEnabled": false,
42
+ "heartbeatIntervalMs": 60000,
43
+ "heartbeatTimeoutMs": 180000
44
44
  }
45
45
  ```
46
46
 
47
47
  | Field | Description | Default |
48
48
  |-------|-------------|---------|
49
- | `enabled` | Enable multi-agent coordination | `false` |
50
- | `coordinator` | Enable central task assignment | `false` |
51
- | `heartbeatIntervalMs` | Heartbeat interval in ms | `30000` |
52
- | `heartbeatTimeoutMs` | Agent considered inactive after this | `120000` |
49
+ | `enabled` | Enable multi-agent coordination | `true` |
50
+ | `coordinatorEnabled` | Enable central task assignment | `false` |
51
+ | `heartbeatIntervalMs` | Heartbeat interval in ms | `60000` |
52
+ | `heartbeatTimeoutMs` | Agent considered inactive after this | `180000` |
53
53
 
54
54
  ### 2. Each Agent Registers Itself
55
55
 
@@ -504,9 +504,9 @@ All components check `MultiAgentConfig.isEnabled()` before doing anything:
504
504
  ```json
505
505
  {
506
506
  "enabled": true,
507
- "coordinator": false,
508
- "heartbeatIntervalMs": 30000,
509
- "heartbeatTimeoutMs": 120000
507
+ "coordinatorEnabled": false,
508
+ "heartbeatIntervalMs": 60000,
509
+ "heartbeatTimeoutMs": 180000
510
510
  }
511
511
  ```
512
512
 
@@ -0,0 +1,21 @@
1
+ # v3.6.50 Release Notes
2
+
3
+ Release date: 2026-03-14
4
+
5
+ ## Highlights
6
+
7
+ - Switched the SCE co-work baseline to default-on: initialized/adopted/takeover-aligned projects now provision `.sce/config/multi-agent.json` with `enabled=true`, while the central coordinator remains opt-in.
8
+ - Added a reusable `collab-governance-gate` and wired it into both `sce timeline push` and `prepublishOnly`, so managed push/publish flow now blocks on co-work governance drift instead of relying on report-only auditing.
9
+ - Synced template/runtime release metadata and multi-agent guidance so shipped documentation reflects the new default co-work baseline and the current package version.
10
+
11
+ ## Validation
12
+
13
+ - `npx jest tests/unit/scripts/collab-governance-gate.test.js tests/unit/commands/timeline.test.js --runInBand`
14
+ - `npx jest tests/unit/collab/multi-agent-config.test.js tests/unit/workspace/takeover-baseline.test.js tests/integration/takeover-baseline-cli.integration.test.js --runInBand`
15
+ - `node scripts/collab-governance-gate.js --json`
16
+ - `npm run prepublishOnly`
17
+
18
+ ## Release Notes
19
+
20
+ - This patch closes the gap where SCE had co-work governance rules and auditing, but initialized/adopted projects still defaulted to a disabled multi-agent baseline.
21
+ - Managed push and publish now share the same co-work governance gate, which prevents collaboration boundary drift from slipping through one path while being caught by another.
@@ -0,0 +1,18 @@
1
+ # v3.6.51 Release Notes
2
+
3
+ Release date: 2026-03-15
4
+
5
+ ## Highlights
6
+
7
+ - Added a new SCE core principle that requires rewrite-style feature, UI, and module changes to remove obsolete implementations in the same change instead of leaving dead code behind.
8
+ - Extended takeover baseline repair so adopted projects automatically regain this obsolete-code-cleanup principle if their steering baseline drifts.
9
+ - Synced package and documentation version metadata for the new release, including runtime/template README footers and current-version guide headers.
10
+
11
+ ## Validation
12
+
13
+ - `npx jest tests/unit/workspace/takeover-baseline.test.js --runInBand`
14
+
15
+ ## Release Notes
16
+
17
+ - This patch tightens SCE's default governance against AI-generated garbage code by making dead-code cleanup an explicit baseline requirement rather than an optional style preference.
18
+ - The rule applies across all SCE-managed projects and clarifies that temporary retention is allowed only when compatibility or rollback constraints are documented with a concrete cleanup plan.
@@ -102,7 +102,7 @@ Your steering strategy choice is saved in `.sce/adoption-config.json`:
102
102
  "adoptedAt": "2026-01-23T10:00:00.000Z",
103
103
  "steeringStrategy": "use-sce",
104
104
  "steeringBackupId": "steering-2026-01-23T10-00-00-000Z",
105
- "multiUserMode": false,
105
+ "multiUserMode": true,
106
106
  "lastUpdated": "2026-01-23T10:00:00.000Z"
107
107
  }
108
108
  ```
@@ -0,0 +1,21 @@
1
+ # v3.6.50 发布说明
2
+
3
+ 发布日期:2026-03-14
4
+
5
+ ## 重点变化
6
+
7
+ - 将 SCE 的 co-work 基线切换为默认开启:`init` / `adopt` / `takeover` 对齐后的项目现在都会落地 `.sce/config/multi-agent.json` 且 `enabled=true`,中央 coordinator 仍保持按需开启。
8
+ - 新增可复用的 `collab-governance-gate`,并接入 `sce timeline push` 与 `prepublishOnly`,让托管 push / publish 在 co-work 治理漂移时直接阻断,而不是只做报告型审计。
9
+ - 同步更新模板、运行时说明和版本元数据,确保发出的文档与默认 co-work 基线、当前包版本保持一致。
10
+
11
+ ## 验证
12
+
13
+ - `npx jest tests/unit/scripts/collab-governance-gate.test.js tests/unit/commands/timeline.test.js --runInBand`
14
+ - `npx jest tests/unit/collab/multi-agent-config.test.js tests/unit/workspace/takeover-baseline.test.js tests/integration/takeover-baseline-cli.integration.test.js --runInBand`
15
+ - `node scripts/collab-governance-gate.js --json`
16
+ - `npm run prepublishOnly`
17
+
18
+ ## 发布说明
19
+
20
+ - 这个补丁版补齐了一个关键缺口:SCE 虽然已经具备 co-work 治理规则和审计能力,但此前新接入项目默认仍可能落在关闭态。
21
+ - 现在托管 push 与 publish 共用同一条 co-work governance gate,避免一条链路能放过的协作治理漂移,在另一条链路才被发现。
@@ -0,0 +1,18 @@
1
+ # v3.6.51 发布说明
2
+
3
+ 发布日期:2026-03-15
4
+
5
+ ## 重点变化
6
+
7
+ - 新增一条 SCE 核心原则:功能、UI 或模块发生重写/替换时,失效旧实现必须在同一轮变更中清理,不能继续把废弃代码留在仓库里。
8
+ - 扩展 takeover baseline 修复逻辑;接管项目若缺失这条“清理废弃代码”原则,SCE 会自动补齐基线。
9
+ - 同步更新本次版本的包信息和文档版本元数据,包括运行时/模板 README 尾注以及当前版本说明文档。
10
+
11
+ ## 验证
12
+
13
+ - `npx jest tests/unit/workspace/takeover-baseline.test.js --runInBand`
14
+
15
+ ## 发布说明
16
+
17
+ - 这个补丁版把“禁止 AI 制造垃圾代码并把旧实现遗留在仓库里”提升为 SCE 的默认治理要求,而不再只是编码习惯建议。
18
+ - 若确实因为兼容、灰度或回滚需要临时保留旧实现,也必须明确说明保留理由、适用边界、退出条件和后续清理计划。
@@ -2,8 +2,8 @@
2
2
  * Multi-Agent Configuration Manager
3
3
  *
4
4
  * Manages `.sce/config/multi-agent.json` for multi-Agent parallel coordination.
5
- * When the config file does not exist or is corrupted, returns a default
6
- * disabled configuration so that single-Agent mode is completely unaffected.
5
+ * Co-work baseline is enabled by default for SCE-managed projects; a project
6
+ * can still opt out explicitly by setting `enabled: false`.
7
7
  *
8
8
  * Requirements: 7.1 (no extra files when disabled), 7.4 (auto-init on first enable)
9
9
  */
@@ -16,7 +16,7 @@ const CONFIG_DIR = '.sce/config';
16
16
 
17
17
  /** @type {import('./multi-agent-config').MultiAgentConfigData} */
18
18
  const DEFAULT_CONFIG = Object.freeze({
19
- enabled: false,
19
+ enabled: true,
20
20
  heartbeatIntervalMs: 60000,
21
21
  heartbeatTimeoutMs: 180000,
22
22
  coordinatorEnabled: false,
@@ -36,7 +36,7 @@ class MultiAgentConfig {
36
36
 
37
37
  /**
38
38
  * Read the current configuration.
39
- * Returns the default (disabled) config when the file is missing or corrupted.
39
+ * Returns the default config when the file is missing or corrupted.
40
40
  *
41
41
  * @returns {Promise<object>} Resolved configuration
42
42
  */
@@ -5,6 +5,10 @@ const {
5
5
  ProjectTimelineStore,
6
6
  captureTimelineCheckpoint
7
7
  } = require('../runtime/project-timeline');
8
+ const {
9
+ evaluateCollabGovernanceGate,
10
+ formatCollabGovernanceGateBlockMessage
11
+ } = require('../workspace/collab-governance-gate');
8
12
  const {
9
13
  summarizeTimelineAttention,
10
14
  buildTimelineEntryViewModel,
@@ -172,8 +176,21 @@ async function runTimelineConfigCommand(options = {}, dependencies = {}) {
172
176
 
173
177
  async function runTimelinePushCommand(gitArgs = [], options = {}, dependencies = {}) {
174
178
  const projectPath = dependencies.projectPath || process.cwd();
179
+ const collabGovernanceGate = dependencies.evaluateCollabGovernanceGate || evaluateCollabGovernanceGate;
180
+ const checkpointRunner = dependencies.captureTimelineCheckpoint || captureTimelineCheckpoint;
181
+ const runGitPush = dependencies.spawnSync || spawnSync;
182
+
183
+ const gatePayload = await collabGovernanceGate({
184
+ projectPath
185
+ }, dependencies);
186
+ if (!gatePayload.passed) {
187
+ const error = new Error(formatCollabGovernanceGateBlockMessage(gatePayload));
188
+ error.exitCode = 2;
189
+ error.gate = gatePayload;
190
+ throw error;
191
+ }
175
192
 
176
- const checkpoint = await captureTimelineCheckpoint({
193
+ const checkpoint = await checkpointRunner({
177
194
  trigger: 'push',
178
195
  event: 'git.push.preflight',
179
196
  summary: normalizeText(options.summary) || 'pre-push timeline checkpoint',
@@ -183,7 +200,7 @@ async function runTimelinePushCommand(gitArgs = [], options = {}, dependencies =
183
200
  fileSystem: dependencies.fileSystem
184
201
  });
185
202
 
186
- const result = spawnSync('git', ['push', ...(Array.isArray(gitArgs) ? gitArgs : [])], {
203
+ const result = runGitPush('git', ['push', ...(Array.isArray(gitArgs) ? gitArgs : [])], {
187
204
  cwd: projectPath,
188
205
  stdio: 'inherit',
189
206
  windowsHide: true
@@ -277,7 +294,7 @@ function registerTimelineCommands(program) {
277
294
 
278
295
  timeline
279
296
  .command('push [gitArgs...]')
280
- .description('Create a pre-push timeline snapshot, then run git push')
297
+ .description('Run collaboration governance gate, create a pre-push timeline snapshot, then run git push')
281
298
  .option('--summary <text>', 'Summary for pre-push checkpoint')
282
299
  .option('--json', 'Output as JSON')
283
300
  .action(async (gitArgs, options) => safeRun(runTimelinePushCommand, options, gitArgs));
@@ -73,7 +73,7 @@ class AdoptionConfig {
73
73
  config = {
74
74
  version: '1.0.0',
75
75
  adoptedAt: new Date().toISOString(),
76
- multiUserMode: false
76
+ multiUserMode: true
77
77
  };
78
78
  }
79
79
 
@@ -139,7 +139,7 @@ class AdoptionConfig {
139
139
  */
140
140
  async isMultiUserMode() {
141
141
  const config = await this.read();
142
- return config ? (config.multiUserMode || false) : false;
142
+ return config ? (typeof config.multiUserMode === 'boolean' ? config.multiUserMode : true) : true;
143
143
  }
144
144
 
145
145
  /**
@@ -153,7 +153,7 @@ class AdoptionConfig {
153
153
  version: '1.0.0',
154
154
  adoptedAt: new Date().toISOString(),
155
155
  steeringStrategy: options.steeringStrategy || 'use-sce',
156
- multiUserMode: options.multiUserMode || false,
156
+ multiUserMode: typeof options.multiUserMode === 'boolean' ? options.multiUserMode : true,
157
157
  ...options
158
158
  };
159
159
 
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ const { auditCollabGovernance } = require('./collab-governance-audit');
4
+
5
+ async function evaluateCollabGovernanceGate(options = {}, dependencies = {}) {
6
+ const projectPath = options.projectPath || dependencies.projectPath || process.cwd();
7
+ const audit = await (dependencies.auditCollabGovernance || auditCollabGovernance)(
8
+ projectPath,
9
+ options,
10
+ dependencies
11
+ );
12
+
13
+ return {
14
+ mode: 'collab-governance-gate',
15
+ project_path: projectPath,
16
+ passed: audit.passed === true,
17
+ reason: audit.reason || (audit.passed === true ? 'passed' : 'violations'),
18
+ summary: audit.summary || {},
19
+ warnings: Array.isArray(audit.warnings) ? audit.warnings : [],
20
+ violations: Array.isArray(audit.violations) ? audit.violations : [],
21
+ audit
22
+ };
23
+ }
24
+
25
+ function formatCollabGovernanceGateBlockMessage(payload = {}, maxViolations = 3) {
26
+ const violations = Array.isArray(payload.violations) ? payload.violations.filter(Boolean) : [];
27
+ if (violations.length === 0) {
28
+ return 'collaboration governance gate blocked push';
29
+ }
30
+
31
+ const visibleViolations = violations.slice(0, Math.max(1, maxViolations));
32
+ const suffix = violations.length > visibleViolations.length
33
+ ? ` (+${violations.length - visibleViolations.length} more)`
34
+ : '';
35
+ return `collaboration governance gate blocked push: ${visibleViolations.join('; ')}${suffix}`;
36
+ }
37
+
38
+ async function runCollabGovernanceGate(options = {}, dependencies = {}) {
39
+ const payload = await evaluateCollabGovernanceGate(options, dependencies);
40
+
41
+ if (options.json) {
42
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
43
+ } else if (payload.passed) {
44
+ process.stdout.write('[collab-governance-gate] passed\n');
45
+ process.stdout.write(
46
+ `[collab-governance-gate] missing-ignore-rules=${payload.summary.missing_gitignore_rules || 0} legacy-references=${payload.summary.legacy_reference_count || 0}\n`
47
+ );
48
+ } else {
49
+ process.stdout.write('[collab-governance-gate] blocked\n');
50
+ payload.violations.forEach((item) => {
51
+ process.stdout.write(`[collab-governance-gate] violation=${item}\n`);
52
+ });
53
+ }
54
+
55
+ return {
56
+ ...payload,
57
+ exit_code: options.failOnViolation && !payload.passed ? 2 : 0
58
+ };
59
+ }
60
+
61
+ module.exports = {
62
+ evaluateCollabGovernanceGate,
63
+ formatCollabGovernanceGateBlockMessage,
64
+ runCollabGovernanceGate
65
+ };
@@ -10,6 +10,9 @@ const {
10
10
  const {
11
11
  cloneStateStoragePolicyDefaults
12
12
  } = require('../state/state-storage-policy');
13
+ const {
14
+ DEFAULT_CONFIG: MULTI_AGENT_CONFIG_DEFAULTS
15
+ } = require('../collab/multi-agent-config');
13
16
 
14
17
  const TAKEOVER_BASELINE_SCHEMA_VERSION = '1.0';
15
18
  const CLARIFICATION_FIRST_CORE_PRINCIPLE_HEADING = '## 11. 业务场景未知时必须先澄清,禁止直接彻底禁用';
@@ -45,6 +48,18 @@ const BACKEND_API_PRECEDENCE_CORE_PRINCIPLE_SECTION = [
45
48
  '- 除非明确要求新建接口或修改后端接口,否则禁止为了迁就前端错误调用去随意改后端实现或契约。',
46
49
  '- 默认优先修正前端请求、映射、类型和兼容处理,使其与后端接口保持一致;若怀疑后端契约错误,应先确认再改。'
47
50
  ].join('\n');
51
+ const DELIVERY_SYNC_CORE_PRINCIPLE_HEADING = '## 6. 测试、文档、代码必须同步闭环';
52
+ const DELIVERY_SYNC_REQUIRED_LINES = Object.freeze([
53
+ '- 代码变更必须跑相关验证;发布前不得忽略失败。',
54
+ '- 重要功能、命令、配置变化必须同步更新 README、用户文档或发布说明。',
55
+ '- 功能修改、UI 重写、模块替换时,已失效的旧实现、旧样式、死分支、失效适配层和无效引用必须在同一轮变更中清理,不得继续留作“保险”。',
56
+ '- 若因兼容、灰度或回滚必须暂时保留旧实现,必须明确保留理由、适用边界、退出条件和后续清理计划。'
57
+ ]);
58
+ const DELIVERY_SYNC_CORE_PRINCIPLE_SECTION = [
59
+ DELIVERY_SYNC_CORE_PRINCIPLE_HEADING,
60
+ '',
61
+ ...DELIVERY_SYNC_REQUIRED_LINES
62
+ ].join('\n');
48
63
  const LARGE_FILE_REFACTOR_CORE_PRINCIPLE_HEADING = '## 15. 单文件规模过大必须触发重构评估,禁止无限堆积';
49
64
  const LARGE_FILE_REFACTOR_CORE_PRINCIPLE_SECTION = [
50
65
  LARGE_FILE_REFACTOR_CORE_PRINCIPLE_HEADING,
@@ -56,6 +71,10 @@ const LARGE_FILE_REFACTOR_CORE_PRINCIPLE_SECTION = [
56
71
  '- 行数阈值只是强触发信号,不代表低于阈值就可以忽略耦合、职责混杂、测试失控和理解成本问题;若复杂度已明显失控,应提前启动重构。'
57
72
  ].join('\n');
58
73
  const REQUIRED_CORE_PRINCIPLE_SECTIONS = Object.freeze([
74
+ {
75
+ heading: DELIVERY_SYNC_CORE_PRINCIPLE_HEADING,
76
+ section: DELIVERY_SYNC_CORE_PRINCIPLE_SECTION
77
+ },
59
78
  {
60
79
  heading: CLARIFICATION_FIRST_CORE_PRINCIPLE_HEADING,
61
80
  section: CLARIFICATION_FIRST_CORE_PRINCIPLE_SECTION
@@ -349,6 +368,10 @@ const TAKEOVER_DEFAULTS = Object.freeze({
349
368
  max_direct_fix_rounds_before_debug: 2,
350
369
  forbid_bypass_workarounds: true
351
370
  },
371
+ collaboration: {
372
+ multi_user_mode: true,
373
+ multi_agent: _clone(MULTI_AGENT_CONFIG_DEFAULTS)
374
+ },
352
375
  errorbook_convergence: _clone(ERRORBOOK_CONVERGENCE_DEFAULTS),
353
376
  migration_policy: {
354
377
  legacy_kiro_supported: false,
@@ -440,7 +463,7 @@ function _buildAdoptionConfig(existing, nowIso, sceVersion) {
440
463
  steeringStrategy: typeof base.steeringStrategy === 'string' && base.steeringStrategy.trim()
441
464
  ? base.steeringStrategy
442
465
  : 'use-sce',
443
- multiUserMode: base.multiUserMode === true,
466
+ multiUserMode: typeof base.multiUserMode === 'boolean' ? base.multiUserMode : true,
444
467
  runtimePolicy: {
445
468
  agent_parity_permissions: true,
446
469
  autonomous_default: true
@@ -456,6 +479,14 @@ function _buildAdoptionConfig(existing, nowIso, sceVersion) {
456
479
  };
457
480
  }
458
481
 
482
+ function _buildMultiAgentConfig(existing) {
483
+ const base = _isObject(existing) ? _clone(existing) : {};
484
+ return {
485
+ ..._clone(MULTI_AGENT_CONFIG_DEFAULTS),
486
+ ...base
487
+ };
488
+ }
489
+
459
490
  function _buildTakeoverBaselineConfig(existing, sceVersion) {
460
491
  const base = _isObject(existing) ? _clone(existing) : {};
461
492
  return {
@@ -643,22 +674,54 @@ async function _reconcileSteeringContract(projectPath, options = {}) {
643
674
  };
644
675
  }
645
676
 
677
+ function _appendLinesToSection(content, heading, lines) {
678
+ if (!content || !heading || !Array.isArray(lines) || lines.length === 0) {
679
+ return content;
680
+ }
681
+
682
+ const startIndex = content.indexOf(heading);
683
+ if (startIndex === -1) {
684
+ return content;
685
+ }
686
+
687
+ const sectionBodyStart = startIndex + heading.length;
688
+ const nextHeadingIndex = content.indexOf('\n## ', sectionBodyStart);
689
+ const sectionEnd = nextHeadingIndex === -1 ? content.length : nextHeadingIndex;
690
+ const section = content.slice(startIndex, sectionEnd).trimEnd();
691
+ const missingLines = lines.filter((line) => !section.includes(line));
692
+
693
+ if (missingLines.length === 0) {
694
+ return content;
695
+ }
696
+
697
+ const updatedSection = `${section}\n${missingLines.join('\n')}`;
698
+ return `${content.slice(0, startIndex)}${updatedSection}${content.slice(sectionEnd)}`;
699
+ }
700
+
646
701
  async function _reconcileCorePrinciplesBaseline(projectPath, options = {}) {
647
702
  const { apply, fileSystem } = options;
648
703
  const corePrinciplesPath = path.join(projectPath, SCE_STEERING_DIR, DEFAULT_LAYER_FILES.core_principles);
649
704
  const exists = await fileSystem.pathExists(corePrinciplesPath);
650
705
  const existingContent = exists ? await fileSystem.readFile(corePrinciplesPath, 'utf8') : '';
651
706
  const missingSections = REQUIRED_CORE_PRINCIPLE_SECTIONS.filter(({ heading }) => !existingContent.includes(heading));
652
- const changed = missingSections.length > 0;
707
+ const missingDeliverySyncLines = existingContent.includes(DELIVERY_SYNC_CORE_PRINCIPLE_HEADING)
708
+ ? DELIVERY_SYNC_REQUIRED_LINES.filter((line) => !existingContent.includes(line))
709
+ : [];
710
+ const changed = missingSections.length > 0 || missingDeliverySyncLines.length > 0;
653
711
 
654
712
  if (apply && changed) {
655
- const normalized = `${existingContent || ''}`.trimEnd();
713
+ let nextContent = `${existingContent || ''}`.trimEnd();
656
714
  const appendedSections = missingSections.map((item) => item.section).join('\n\n');
657
- const nextContent = normalized
658
- ? `${normalized}\n\n${appendedSections}\n`
659
- : `${appendedSections}\n`;
715
+ if (appendedSections) {
716
+ nextContent = nextContent
717
+ ? `${nextContent}\n\n${appendedSections}`
718
+ : appendedSections;
719
+ }
720
+ if (missingDeliverySyncLines.length > 0) {
721
+ nextContent = _appendLinesToSection(nextContent, DELIVERY_SYNC_CORE_PRINCIPLE_HEADING, missingDeliverySyncLines);
722
+ }
660
723
  await fileSystem.ensureDir(path.dirname(corePrinciplesPath));
661
- await fileSystem.writeFile(corePrinciplesPath, nextContent, 'utf8');
724
+ await fileSystem.writeFile(corePrinciplesPath, `${nextContent}\n`, 'utf8');
662
725
  }
663
726
 
664
727
  return {
@@ -669,6 +732,7 @@ async function _reconcileCorePrinciplesBaseline(projectPath, options = {}) {
669
732
  managed_by: 'takeover-baseline',
670
733
  details: {
671
734
  missing_required_headings_before: missingSections.map((item) => item.heading),
735
+ missing_delivery_sync_lines_before: missingDeliverySyncLines,
672
736
  required_headings: REQUIRED_CORE_PRINCIPLE_SECTIONS.map((item) => item.heading)
673
737
  }
674
738
  };
@@ -749,6 +813,7 @@ async function applyTakeoverBaseline(projectPath = process.cwd(), options = {})
749
813
  const autoConfigPath = path.join(sceRoot, 'auto', 'config.json');
750
814
  const takeoverConfigPath = path.join(sceRoot, 'config', 'takeover-baseline.json');
751
815
  const errorbookRegistryPath = path.join(sceRoot, 'config', 'errorbook-registry.json');
816
+ const multiAgentConfigPath = path.join(sceRoot, 'config', 'multi-agent.json');
752
817
  const sessionGovernancePath = path.join(sceRoot, 'config', 'session-governance.json');
753
818
  const specDomainPolicyPath = path.join(sceRoot, 'config', 'spec-domain-policy.json');
754
819
  const problemEvalPolicyPath = path.join(sceRoot, 'config', 'problem-eval-policy.json');
@@ -762,6 +827,7 @@ async function applyTakeoverBaseline(projectPath = process.cwd(), options = {})
762
827
  const existingAuto = await _readJsonSafe(autoConfigPath, fileSystem);
763
828
  const existingTakeover = await _readJsonSafe(takeoverConfigPath, fileSystem);
764
829
  const existingErrorbookRegistry = await _readJsonSafe(errorbookRegistryPath, fileSystem);
830
+ const existingMultiAgentConfig = await _readJsonSafe(multiAgentConfigPath, fileSystem);
765
831
  const existingSessionGovernance = await _readJsonSafe(sessionGovernancePath, fileSystem);
766
832
  const existingSpecDomainPolicy = await _readJsonSafe(specDomainPolicyPath, fileSystem);
767
833
  const existingProblemEvalPolicy = await _readJsonSafe(problemEvalPolicyPath, fileSystem);
@@ -772,6 +838,7 @@ async function applyTakeoverBaseline(projectPath = process.cwd(), options = {})
772
838
  const desiredAutoConfig = _buildAutoConfig(existingAuto);
773
839
  const desiredTakeover = _buildTakeoverBaselineConfig(existingTakeover, sceVersion);
774
840
  const desiredErrorbookRegistry = _buildErrorbookRegistryConfig(existingErrorbookRegistry);
841
+ const desiredMultiAgentConfig = _buildMultiAgentConfig(existingMultiAgentConfig);
775
842
  const desiredSessionGovernance = _deepMerge(existingSessionGovernance || {}, SESSION_GOVERNANCE_DEFAULTS);
776
843
  const desiredSpecDomainPolicy = _deepMerge(existingSpecDomainPolicy || {}, SPEC_DOMAIN_POLICY_DEFAULTS);
777
844
  const desiredProblemEvalPolicy = _deepMerge(existingProblemEvalPolicy || {}, PROBLEM_EVAL_POLICY_DEFAULTS);
@@ -802,6 +869,11 @@ async function applyTakeoverBaseline(projectPath = process.cwd(), options = {})
802
869
  apply,
803
870
  fileSystem
804
871
  }));
872
+ fileResults.push(await _reconcileJsonFile(multiAgentConfigPath, desiredMultiAgentConfig, {
873
+ projectPath,
874
+ apply,
875
+ fileSystem
876
+ }));
805
877
  fileResults.push(await _reconcileJsonFile(sessionGovernancePath, desiredSessionGovernance, {
806
878
  projectPath,
807
879
  apply,
@@ -900,6 +972,8 @@ module.exports = {
900
972
  STEERING_CHANGE_EVALUATION_CORE_PRINCIPLE_SECTION,
901
973
  BACKEND_API_PRECEDENCE_CORE_PRINCIPLE_HEADING,
902
974
  BACKEND_API_PRECEDENCE_CORE_PRINCIPLE_SECTION,
975
+ DELIVERY_SYNC_CORE_PRINCIPLE_HEADING,
976
+ DELIVERY_SYNC_REQUIRED_LINES,
903
977
  LARGE_FILE_REFACTOR_CORE_PRINCIPLE_HEADING,
904
978
  LARGE_FILE_REFACTOR_CORE_PRINCIPLE_SECTION,
905
979
  REQUIRED_CORE_PRINCIPLE_SECTIONS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scene-capability-engine",
3
- "version": "3.6.49",
3
+ "version": "3.6.51",
4
4
  "description": "SCE (Scene Capability Engine) - A CLI tool and npm package for spec-driven development with AI coding assistants.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -44,11 +44,13 @@
44
44
  "audit:refactor-trigger": "node scripts/refactor-trigger-audit.js",
45
45
  "audit:steering": "node scripts/steering-content-audit.js --fail-on-error",
46
46
  "audit:clarification-first": "node scripts/clarification-first-audit.js --fail-on-violation",
47
+ "gate:collab-governance": "node scripts/collab-governance-gate.js --fail-on-violation",
47
48
  "audit:state-storage": "node scripts/state-storage-tiering-audit.js",
48
49
  "report:release-docs": "node scripts/release-doc-version-audit.js --json",
49
50
  "report:refactor-trigger": "node scripts/refactor-trigger-audit.js --json",
50
51
  "report:steering-audit": "node scripts/steering-content-audit.js --json",
51
52
  "report:clarification-first-audit": "node scripts/clarification-first-audit.js --json",
53
+ "report:collab-governance": "node scripts/collab-governance-gate.js --json",
52
54
  "report:state-storage": "node scripts/state-storage-tiering-audit.js --json",
53
55
  "report:interactive-approval-projection": "node scripts/interactive-approval-event-projection.js --action doctor --json",
54
56
  "audit:interactive-approval-projection": "node scripts/interactive-approval-event-projection.js --action doctor --fail-on-drift --fail-on-parse-error",
@@ -90,7 +92,7 @@
90
92
  "gate:release-asset-integrity": "node scripts/release-asset-integrity-check.js",
91
93
  "report:release-risk-remediation": "node scripts/release-risk-remediation-bundle.js --json",
92
94
  "report:moqui-core-regression": "node scripts/moqui-core-regression-suite.js --json",
93
- "prepublishOnly": "npm run test:release && npm run test:skip-audit && npm run test:sce-tracking && npm run gate:npm-runtime-assets && npm run test:brand-consistency && npm run audit:release-docs && npm run audit:steering && npm run audit:clarification-first && npm run gate:git-managed && npm run gate:errorbook-registry-health && npm run gate:errorbook-release && npm run report:interactive-governance -- --fail-on-alert",
95
+ "prepublishOnly": "npm run test:release && npm run test:skip-audit && npm run test:sce-tracking && npm run gate:npm-runtime-assets && npm run test:brand-consistency && npm run audit:release-docs && npm run audit:steering && npm run audit:clarification-first && npm run gate:collab-governance && npm run gate:git-managed && npm run gate:errorbook-registry-health && npm run gate:errorbook-release && npm run report:interactive-governance -- --fail-on-alert",
94
96
  "publish:manual": "npm publish --access public",
95
97
  "install-global": "npm install -g .",
96
98
  "uninstall-global": "npm uninstall -g scene-capability-engine"
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const path = require('path');
5
+ const { runCollabGovernanceGate } = require('../lib/workspace/collab-governance-gate');
6
+
7
+ function parseArgs(argv = []) {
8
+ const options = {
9
+ projectPath: process.cwd(),
10
+ failOnViolation: false,
11
+ json: false,
12
+ help: false
13
+ };
14
+
15
+ for (let index = 0; index < argv.length; index += 1) {
16
+ const token = argv[index];
17
+ const next = argv[index + 1];
18
+
19
+ if (token === '--project-path' && next) {
20
+ options.projectPath = path.resolve(next);
21
+ index += 1;
22
+ } else if (token === '--fail-on-violation') {
23
+ options.failOnViolation = true;
24
+ } else if (token === '--json') {
25
+ options.json = true;
26
+ } else if (token === '--help' || token === '-h') {
27
+ options.help = true;
28
+ }
29
+ }
30
+
31
+ return options;
32
+ }
33
+
34
+ function printHelp() {
35
+ const lines = [
36
+ 'Usage: node scripts/collab-governance-gate.js [options]',
37
+ '',
38
+ 'Options:',
39
+ ' --project-path <path> Project path (default: cwd)',
40
+ ' --fail-on-violation Exit with code 2 when violations exist',
41
+ ' --json Print JSON payload',
42
+ ' -h, --help Show help'
43
+ ];
44
+ process.stdout.write(`${lines.join('\n')}\n`);
45
+ }
46
+
47
+ if (require.main === module) {
48
+ const options = parseArgs(process.argv.slice(2));
49
+ if (options.help) {
50
+ printHelp();
51
+ process.exit(0);
52
+ }
53
+
54
+ runCollabGovernanceGate(options)
55
+ .then((result) => {
56
+ process.exitCode = result.exit_code;
57
+ })
58
+ .catch((error) => {
59
+ const payload = {
60
+ mode: 'collab-governance-gate',
61
+ passed: false,
62
+ error: error.message
63
+ };
64
+ if (options.json) {
65
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
66
+ } else {
67
+ process.stderr.write(`[collab-governance-gate] error=${error.message}\n`);
68
+ }
69
+ process.exitCode = 1;
70
+ });
71
+ }
72
+
73
+ module.exports = {
74
+ parseArgs,
75
+ runCollabGovernanceGate
76
+ };
@@ -71,8 +71,8 @@ When multiple AI agents work on the same project simultaneously:
71
71
  - **SteeringFileLock** (`lib/lock`) — Steering file write serialization
72
72
  - **MergeCoordinator** (`lib/collab`) — Git branch isolation per agent
73
73
  - **Coordinator** (`lib/collab`) — Central task assignment (optional)
74
- - Config: `.sce/config/multi-agent.json` (`enabled: true` to activate)
75
- - All components are no-ops in single-agent mode (zero overhead)
74
+ - Config: `.sce/config/multi-agent.json` (default `enabled: true`; set `enabled: false` to opt out)
75
+ - If a project opts out with `enabled: false`, all components fall back to single-agent no-op behavior
76
76
  - See `docs/multi-agent-coordination-guide.md` for full API reference
77
77
 
78
78
  ### Spec-Level Steering & Context Sync
@@ -83,7 +83,7 @@ Fourth steering layer (L4) and Spec lifecycle coordination for multi-agent scena
83
83
  - **SpecLifecycleManager** (`lib/collab`) — Spec state machine (planned → assigned → in-progress → completed → released) with auto-completion detection
84
84
  - **SyncBarrier** (`lib/collab`) — Agent Spec-switch synchronization barrier (uncommitted changes check, steering reload)
85
85
  - **Coordinator Integration** — `completeTask` auto-checks Spec completion; `assignTask` runs SyncBarrier
86
- - All components are no-ops in single-agent mode (zero overhead)
86
+ - If needed, a project can still opt out by setting `enabled: false`, which restores single-agent no-op behavior
87
87
  - See `docs/multi-agent-coordination-guide.md` for full API reference
88
88
 
89
89
  ### Autonomous Control
@@ -151,7 +151,7 @@ Look in .sce/specs/ directory
151
151
 
152
152
  ### When Working in Multi-Agent Mode
153
153
 
154
- If `.sce/config/multi-agent.json` exists with `enabled: true`:
154
+ By default `.sce/config/multi-agent.json` is provisioned with `enabled: true`:
155
155
  1. Register with AgentRegistry before starting work
156
156
  2. Acquire task locks before modifying any task
157
157
  3. Use TaskStatusStore for concurrent-safe tasks.md updates
@@ -243,6 +243,6 @@ A Spec is a complete feature definition with three parts:
243
243
  ---
244
244
 
245
245
  **Project Type**: Spec-driven development
246
- **sce Version**: 3.6.49
247
- **Last Updated**: 2026-03-14
246
+ **sce Version**: 3.6.51
247
+ **Last Updated**: 2026-03-15
248
248
  **Purpose**: Guide AI tools to work effectively with this project
@@ -0,0 +1,8 @@
1
+ {
2
+ "enabled": true,
3
+ "heartbeatIntervalMs": 60000,
4
+ "heartbeatTimeoutMs": 180000,
5
+ "coordinatorEnabled": false,
6
+ "maxRetries": 5,
7
+ "retryBaseDelayMs": 100
8
+ }
@@ -112,6 +112,17 @@
112
112
  "max_direct_fix_rounds_before_debug": 2,
113
113
  "forbid_bypass_workarounds": true
114
114
  },
115
+ "collaboration": {
116
+ "multi_user_mode": true,
117
+ "multi_agent": {
118
+ "enabled": true,
119
+ "heartbeatIntervalMs": 60000,
120
+ "heartbeatTimeoutMs": 180000,
121
+ "coordinatorEnabled": false,
122
+ "maxRetries": 5,
123
+ "retryBaseDelayMs": 100
124
+ }
125
+ },
115
126
  "migration_policy": {
116
127
  "legacy_kiro_supported": false,
117
128
  "require_manual_legacy_migration_confirmation": true
@@ -29,6 +29,8 @@
29
29
 
30
30
  - 禁止靠跳过测试、关闭校验、吞错回退来伪装成功。
31
31
  - 临时兜底必须附带退出条件、清理任务与截止时间。
32
+ - 重写或替换实现时,同步删除失效旧代码、旧样式、死分支和无效引用,不要把废弃实现留在仓库里当“保险”。
33
+ - 如果因为兼容、灰度或回滚必须临时保留旧实现,必须写明保留理由、边界、退出条件和后续清理计划。
32
34
 
33
35
  ## 6. 定期净化 steering
34
36