scene-capability-engine 3.6.10 → 3.6.13

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,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.6.13] - 2026-03-06
11
+
12
+ ### Added
13
+ - Capability library reuse commands:
14
+ - `sce capability catalog list/search/show`
15
+ - `sce capability match`
16
+ - `sce capability use`
17
+ - Magicball capability library integration guide:
18
+ - `docs/magicball-capability-library.md`
19
+
20
+ ## [3.6.12] - 2026-03-06
21
+
22
+ ### Added
23
+ - Magicball task quality governance integration guide:
24
+ - `docs/magicball-task-quality-governance.md`
25
+
26
+ ## [3.6.11] - 2026-03-05
27
+
28
+ ### Added
29
+ - Task quality governance commands:
30
+ - `sce task draft`
31
+ - `sce task consolidate`
32
+ - `sce task score`
33
+ - `sce task promote`
34
+ - Task quality policy support:
35
+ - `.sce/config/task-quality-policy.json`
36
+ - policy overrides via `--policy <path>`
37
+ - Task promotion now emits acceptance suggestions when acceptance criteria are missing.
38
+
10
39
  ## [3.6.10] - 2026-03-05
11
40
 
12
41
  ### Added
package/README.md CHANGED
@@ -218,5 +218,5 @@ MIT. See [LICENSE](LICENSE).
218
218
 
219
219
  ---
220
220
 
221
- **Version**: 3.6.10
221
+ **Version**: 3.6.13
222
222
  **Last Updated**: 2026-03-05
package/README.zh.md CHANGED
@@ -218,5 +218,5 @@ MIT,见 [LICENSE](LICENSE)。
218
218
 
219
219
  ---
220
220
 
221
- **版本**:3.6.10
221
+ **版本**:3.6.13
222
222
  **最后更新**:2026-03-05
@@ -201,6 +201,26 @@ Task references and studio runtime events are persisted in SQLite state store:
201
201
  - In-memory fallback is restricted to `NODE_ENV=test` or `SCE_STATE_ALLOW_MEMORY_FALLBACK=1`.
202
202
  - If SQLite runtime support is unavailable outside fallback conditions, `task ref/show/rerun` and `studio events` persistence operations fail fast.
203
203
 
204
+ #### Task Quality Governance (draft -> score -> promote)
205
+
206
+ ```bash
207
+ # Create draft from dialogue
208
+ sce task draft --scene scene.customer-order --input "Fix checkout timeout and add retry dashboard" --json
209
+
210
+ # Consolidate drafts for a scene
211
+ sce task consolidate --scene scene.customer-order --json
212
+
213
+ # Score draft quality
214
+ sce task score --draft <draft-id> --json
215
+
216
+ # Promote into tasks.md (quality gate enforced unless --force)
217
+ sce task promote --draft <draft-id> --spec 02-00-checkout-optimization --json
218
+ ```
219
+
220
+ Policy file:
221
+ - `.sce/config/task-quality-policy.json`
222
+ - Fields: `min_quality_score`, `require_acceptance_criteria`, `allow_needs_split`, `auto_suggest_acceptance`, `max_sub_goals`
223
+
204
224
  ### Context & Prompts
205
225
 
206
226
  ```bash
@@ -1868,6 +1888,26 @@ Schema references:
1868
1888
  - UI contract: `docs/agent-runtime/capability-iteration-ui.schema.json`
1869
1889
  - Ontology mapping: `docs/ontology/capability-mapping.schema.json`
1870
1890
 
1891
+ ### Capability Library Reuse (query -> match -> use)
1892
+
1893
+ ```bash
1894
+ # List capability templates
1895
+ sce capability catalog list --json
1896
+
1897
+ # Search capability templates
1898
+ sce capability catalog search "customer order" --json
1899
+
1900
+ # Show capability template metadata + payload
1901
+ sce capability catalog show customer-order-core --json
1902
+
1903
+ # Match capability templates to a spec (uses problem-domain-chain.json)
1904
+ sce capability match --spec 01-02-customer-order --json
1905
+ sce capability match --spec 01-02-customer-order --query "订单 库存" --limit 5 --json
1906
+
1907
+ # Generate a usage plan for a spec
1908
+ sce capability use --template customer-order-core --spec 01-02-customer-order --json
1909
+ ```
1910
+
1871
1911
  ### Scene Package Batch Publish
1872
1912
 
1873
1913
  ```bash
@@ -0,0 +1,117 @@
1
+ # Magicball 能力库复用对接说明(SCE)
2
+
3
+ > 目标:在 Magicball UI 中提供“能力库检索/匹配/使用”闭环,加速场景能力落地。
4
+
5
+ ## 1. 能力库复用流程
6
+
7
+ 1. **查询**能力库(列表/搜索)
8
+ 2. **匹配**当前 spec 的问题域(基于 problem-domain-chain 里的 ontology)
9
+ 3. **使用**能力模板(生成可执行的 usage plan)
10
+
11
+ ## 2. SCE CLI 支持(对 Magicball 的最小封装)
12
+
13
+ ### 2.1 查询与搜索
14
+
15
+ ```bash
16
+ sce capability catalog list --json
17
+ sce capability catalog search "customer order" --json
18
+ sce capability catalog show <template-id> --json
19
+ ```
20
+
21
+ ### 2.2 匹配(基于 spec ontology)
22
+
23
+ ```bash
24
+ sce capability match --spec <spec-id> --json
25
+ sce capability match --spec <spec-id> --query "订单 库存" --limit 5 --json
26
+ ```
27
+
28
+ 匹配会读取:
29
+ - `.sce/specs/<spec>/custom/problem-domain-chain.json`
30
+
31
+ 若该文件缺失,默认仍返回结果,但 `warnings` 中会标记缺失。
32
+
33
+ ### 2.3 使用(生成 usage plan)
34
+
35
+ ```bash
36
+ sce capability use --template <template-id> --spec <spec-id> --json
37
+ ```
38
+
39
+ 输出:`capability-use-plan`(用于 UI 展示和后续手工应用)。
40
+
41
+ ## 3. API 封装建议(CLI -> HTTP)
42
+
43
+ 建议 Magicball 后端封装为:
44
+
45
+ - `POST /api/sce/capability/catalog/list`
46
+ - `POST /api/sce/capability/catalog/search`
47
+ - `POST /api/sce/capability/catalog/show`
48
+ - `POST /api/sce/capability/match`
49
+ - `POST /api/sce/capability/use`
50
+
51
+ 请求体示例:
52
+
53
+ ```json
54
+ {
55
+ "specId": "01-02-customer-order",
56
+ "query": "订单 库存",
57
+ "limit": 5
58
+ }
59
+ ```
60
+
61
+ ## 4. UI 行为建议(Magicball)
62
+
63
+ ### 4.1 能力库入口
64
+ - 顶部图标入口
65
+ - Tabs:`能力库` / `匹配结果` / `使用计划`
66
+
67
+ ### 4.2 能力库列表
68
+ - 支持筛选:category / risk / source
69
+ - 展示关键信息:`name` / `description` / `ontology_scope`
70
+
71
+ ### 4.3 匹配结果
72
+ - 展示 `score` + `score_components`
73
+ - 支持一键生成 usage plan
74
+
75
+ ### 4.4 使用计划
76
+ - 展示 `recommended_tasks`
77
+ - 可手工转为当前 spec 的任务
78
+
79
+ ## 5. 输出结构(关键字段)
80
+
81
+ ### capability-match
82
+ ```json
83
+ {
84
+ "mode": "capability-match",
85
+ "spec_id": "01-02-customer-order",
86
+ "scene_id": "scene.customer-order",
87
+ "match_count": 12,
88
+ "matches": [
89
+ {
90
+ "template_id": "customer-order-core",
91
+ "score": 82,
92
+ "score_components": {
93
+ "ontology": 0.72,
94
+ "scenario": 1,
95
+ "keyword": 0.35
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ ```
101
+
102
+ ### capability-use-plan
103
+ ```json
104
+ {
105
+ "mode": "capability-use-plan",
106
+ "template": {"id": "customer-order-core", "name": "Customer Order Core"},
107
+ "spec_id": "01-02-customer-order",
108
+ "recommended_tasks": [
109
+ {"title": "Define order entity"},
110
+ {"title": "Implement order lifecycle"}
111
+ ]
112
+ }
113
+ ```
114
+
115
+ ---
116
+
117
+ 若需要“自动落地写入 spec 任务”的强制执行模式,可以在后续版本加 `--apply` 开关。
@@ -0,0 +1,301 @@
1
+ # Magicball 任务质量治理对接说明(SCE)
2
+
3
+ > 适用于:Magicball AI 助手任务卡 UI 的质量治理增强与 SCE Task 质量闭环对接。
4
+
5
+ ## 1. 背景与目标
6
+
7
+ 任务由对话生成,容易出现「多事项混杂、目标不清晰、验收缺失」等问题,导致执行偏移或兜底编程。
8
+ SCE 新增「任务质量治理」闭环能力,保证每个任务可执行、可验收、可追踪。
9
+
10
+ 目标:
11
+ - 让 Magicball UI 在**同一任务卡**内完成“草案 -> 评分 -> 修正 -> Promote”的闭环
12
+ - 通过质量门禁(Policy)强制任务可执行、可验收
13
+ - 保留用户原始输入,避免信息丢失
14
+
15
+ ## 2. SCE 新增能力概览
16
+
17
+ 新增 CLI:
18
+ - `sce task draft`
19
+ - `sce task consolidate`
20
+ - `sce task score`
21
+ - `sce task promote`
22
+
23
+ 新增策略文件:
24
+ - `.sce/config/task-quality-policy.json`
25
+ - 支持 `--policy <path>` 覆盖
26
+
27
+ 默认门禁(可配置):
28
+ - acceptance_criteria 必须存在
29
+ - needs_split 必须为 false
30
+ - min_score >= 70
31
+
32
+ ## 3. 推荐交互流程(最短闭环)
33
+
34
+ 1. 用户输入 -> `sce task draft`
35
+ 2. 多轮输入合并 -> `sce task consolidate`
36
+ 3. 评分 -> `sce task score`
37
+ 4. 通过门禁 -> `sce task promote`
38
+ 5. 成功写入 `tasks.md`
39
+
40
+ ## 4. 字段契约(建议 Magicball 消费)
41
+
42
+ 核心字段:
43
+ - `task_ref`(草案阶段可为空)
44
+ - `title_norm`
45
+ - `raw_request`
46
+ - `goal`
47
+ - `sub_goals`
48
+ - `acceptance_criteria`
49
+ - `needs_split`
50
+ - `confidence`
51
+ - `next_action`
52
+ - `handoff`
53
+ - `score`
54
+
55
+ 示例(草案阶段):
56
+ ```json
57
+ {
58
+ "task_ref": null,
59
+ "title_norm": "生成客户-订单-库存演示数据流程",
60
+ "raw_request": "帮我做一个客户订单库存的demo",
61
+ "goal": "生成可运行的客户-订单-库存演示流程",
62
+ "sub_goals": ["定义实体关系", "生成测试数据", "配置页面展示"],
63
+ "acceptance_criteria": [],
64
+ "needs_split": true,
65
+ "confidence": 0.68,
66
+ "next_action": "split",
67
+ "handoff": "needs_split=true, acceptance_criteria empty"
68
+ }
69
+ ```
70
+
71
+ 评分示例:
72
+ ```json
73
+ {
74
+ "score": 62,
75
+ "missing_items": ["acceptance_criteria", "split_required"]
76
+ }
77
+ ```
78
+
79
+ Promote 成功:
80
+ ```json
81
+ {
82
+ "success": true,
83
+ "task_ref": "01.02.03",
84
+ "message": "promoted"
85
+ }
86
+ ```
87
+
88
+ Promote 失败:
89
+ ```json
90
+ {
91
+ "success": false,
92
+ "message": "quality gate failed",
93
+ "reasons": ["acceptance_criteria missing", "needs_split=true"]
94
+ }
95
+ ```
96
+
97
+ ## 5. UI 行为规范(强制)
98
+
99
+ - 草案页:默认显示**评分卡 + 缺失项**
100
+ - `needs_split=true`:必须拆分或补充,**禁止 promote**
101
+ - `acceptance_criteria` 为空:**阻断 promote**
102
+ - promote 失败时提示固定文案:**“质量门禁未通过”**
103
+
104
+ ## 6. 基于现有任务 UI 的最小改动建议
105
+
106
+ 当前 UI:单卡片 + 事件流 + 文件变更 + 错误信息。
107
+ 在不改整体布局的前提下,建议:
108
+
109
+ 1) 任务头部
110
+ - 显示 `title_norm`
111
+ - `raw_request` 置于标题下方(可折叠)
112
+ - 状态徽标:Draft / Needs Split / Missing Acceptance / Ready / Failed Gate
113
+
114
+ 2) 评分卡(插入到事件流上方)
115
+ - 展示 `score / missing_items / next_action`
116
+ - 点击展开查看策略阈值与建议
117
+
118
+ 3) 强制阻断逻辑
119
+ - needs_split 或 acceptance 缺失 => promote 按钮置灰
120
+ - 展示原因与修复入口
121
+
122
+ 4) Promote 失败提示
123
+ - 固定文案 “质量门禁未通过”
124
+ - 展示失败原因列表
125
+
126
+ 5) 原有事件流保留,增强复制能力
127
+ - 错误日志一键复制,便于诊断
128
+
129
+ ## 7. 参考命令(Magicball 封装为 API 即可)
130
+
131
+ ```bash
132
+ sce task draft --spec <specPath> --input "<user text>"
133
+ sce task consolidate --spec <specPath>
134
+ sce task score --spec <specPath>
135
+ sce task promote --spec <specPath>
136
+ ```
137
+
138
+ ## 8. 版本与发布说明
139
+
140
+ 该能力自 **SCE v3.6.11** 开始提供,若 Magicball 需要兼容老版本,请做版本检测与能力降级处理。
141
+
142
+ ---
143
+
144
+ 如需进一步输出 UI 页面原型或字段映射表,可直接在此文档上增补。
145
+ ## 9. 字段映射表(SCE -> Magicball UI)
146
+
147
+ | SCE 字段 | UI 位置 | 展示方式 | 规则 |
148
+ | --- | --- | --- | --- |
149
+ | task_ref | 任务卡标题前 | 小号标签 | 无则隐藏 |
150
+ | title_norm | 任务卡标题 | 主标题 | 必填 |
151
+ | raw_request | 标题下方 | 灰色可折叠 | 保留原文 |
152
+ | goal | 详情区 | 主目标段落 | 若空提示补齐 |
153
+ | sub_goals | 详情区 | 列表 | needs_split=true 时高亮 |
154
+ | acceptance_criteria | 详情区 | 验收列表 | 为空阻断 promote |
155
+ | needs_split | 状态徽标 | Needs Split | true 则阻断 |
156
+ | confidence | 评分卡 | 低/中/高 | <0.6 高亮 |
157
+ | score | 评分卡 | 数值 + 色阶 | <阈值红色 |
158
+ | missing_items | 评分卡 | 缺失列表 | 点击展开 |
159
+ | next_action | 评分卡 | 下一步 | 生成操作建议 |
160
+ | handoff | 详情区 | 灰色提示 | 展示门禁原因 |
161
+ | errors | 事件流 | 错误块 | 一键复制 |
162
+ | file_changes | 文件变更区 | 文件列表 | diff 快捷入口 |
163
+
164
+ ## 10. 前端组件建议
165
+
166
+ ### 10.1 TaskCard(现有卡片增强)
167
+ - Header:`task_ref + title_norm`,`raw_request` 折叠显示。
168
+ - StatusBadge:Draft / Needs Split / Missing Acceptance / Ready / Failed Gate。
169
+ - QuickActions:Score / Promote / Split / Fix Acceptance。
170
+
171
+ ### 10.2 QualityScorePanel
172
+ - 固定显示 `score / missing_items / next_action`。
173
+ - 展开显示 policy 阈值与建议。
174
+ - 禁止 promote 时显示红色提示条。
175
+
176
+ ### 10.3 AcceptanceEditor
177
+ - 为空时自动提示“请补齐验收标准”。
178
+ - 提供“自动补齐建议”按钮(由 SCE 生成)。
179
+
180
+ ### 10.4 PromoteGuard
181
+ - 拦截条件:needs_split=true 或 acceptance_criteria 为空。
182
+ - 拦截弹窗文案固定:“质量门禁未通过”。
183
+
184
+ ### 10.5 ErrorStream
185
+ - 事件流右侧增加复制按钮。
186
+ - 错误日志折叠/展开。
187
+
188
+ ## 11. 建议的调用顺序(前端按钮)
189
+
190
+ - 点击“生成草案”:`sce task draft`
191
+ - 点击“合并输入”:`sce task consolidate`
192
+ - 点击“评分”:`sce task score`
193
+ - 点击“Promote”:`sce task promote`
194
+
195
+ ---
196
+ ## 12. 示例 UI 结构(JSON/DSL)
197
+
198
+ ```json
199
+ {
200
+ "type": "TaskCard",
201
+ "props": {
202
+ "taskRef": "01.02.03",
203
+ "titleNorm": "生成客户-订单-库存演示数据流程",
204
+ "rawRequest": "帮我做一个客户订单库存的demo",
205
+ "status": "NeedsSplit",
206
+ "score": 62,
207
+ "missingItems": ["acceptance_criteria", "split_required"],
208
+ "nextAction": "split"
209
+ },
210
+ "children": [
211
+ {
212
+ "type": "QualityScorePanel",
213
+ "props": {
214
+ "score": 62,
215
+ "minScore": 70,
216
+ "missingItems": ["acceptance_criteria", "split_required"],
217
+ "nextAction": "split"
218
+ }
219
+ },
220
+ {
221
+ "type": "TaskDetails",
222
+ "props": {
223
+ "goal": "生成可运行的客户-订单-库存演示流程",
224
+ "subGoals": ["定义实体关系", "生成测试数据", "配置页面展示"],
225
+ "acceptanceCriteria": [],
226
+ "handoff": "needs_split=true, acceptance_criteria empty"
227
+ }
228
+ },
229
+ {
230
+ "type": "EventStream",
231
+ "props": {
232
+ "events": [
233
+ {"ts": "23:59:01", "level": "error", "message": "auto-fix blocked", "copyable": true},
234
+ {"ts": "23:59:02", "level": "info", "message": "Task completed"}
235
+ ]
236
+ }
237
+ },
238
+ {
239
+ "type": "FileChanges",
240
+ "props": {
241
+ "files": [
242
+ {"path": "src/app.ts", "diffRef": "diff:123", "reason": "adjust task acceptance"}
243
+ ]
244
+ }
245
+ }
246
+ ]
247
+ }
248
+ ```
249
+
250
+ ## 13. 前端 API 封装建议(CLI -> HTTP)
251
+
252
+ 建议 Magicball 在后端封装 SCE CLI,前端统一调用 HTTP。
253
+
254
+ ### 13.1 路由定义
255
+
256
+ - `POST /api/sce/task/draft`
257
+ - `POST /api/sce/task/consolidate`
258
+ - `POST /api/sce/task/score`
259
+ - `POST /api/sce/task/promote`
260
+
261
+ ### 13.2 请求体
262
+
263
+ ```json
264
+ {
265
+ "specPath": "scenes/01/specs/02/spec.md",
266
+ "input": "帮我做一个客户订单库存的demo",
267
+ "policyPath": ".sce/config/task-quality-policy.json"
268
+ }
269
+ ```
270
+
271
+ ### 13.3 响应体(统一包裹)
272
+
273
+ ```json
274
+ {
275
+ "success": true,
276
+ "data": {
277
+ "task_ref": "01.02.03",
278
+ "title_norm": "生成客户-订单-库存演示数据流程",
279
+ "raw_request": "帮我做一个客户订单库存的demo",
280
+ "goal": "生成可运行的客户-订单-库存演示流程",
281
+ "sub_goals": ["定义实体关系", "生成测试数据", "配置页面展示"],
282
+ "acceptance_criteria": ["前端能展示客户列表"],
283
+ "needs_split": false,
284
+ "confidence": 0.81,
285
+ "score": 78,
286
+ "missing_items": [],
287
+ "next_action": "promote",
288
+ "handoff": "ready"
289
+ },
290
+ "errors": []
291
+ }
292
+ ```
293
+
294
+ ### 13.4 前端调用顺序(建议)
295
+
296
+ 1. `draft` -> 渲染草案 + 评分卡
297
+ 2. `consolidate` -> 合并多轮输入(可选)
298
+ 3. `score` -> 质量评分
299
+ 4. `promote` -> 写入 tasks.md
300
+
301
+ ---