dsh-progress-union 0.7.0-rc.2 → 0.7.0

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.
@@ -0,0 +1,165 @@
1
+ /**
2
+ * 0.7.0 rc.3 验收:R4 任务板重大(结构性)变更 → 输入队列。
3
+ * 只有 add/remove/order 触发;running 走 agent.steer(next-step 黄档),
4
+ * idle 走 agent.followup(next-turn);消息 source.kind='user' 才过 isHumanSteer;
5
+ * 同回合合并、同 rev 不重投;关掉开关或板未启用时一条都不发。
6
+ */
7
+ import assert from 'node:assert/strict'
8
+ import fs from 'node:fs'
9
+ import os from 'node:os'
10
+ import path from 'node:path'
11
+ import test from 'node:test'
12
+
13
+ process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
14
+ const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.mjs')
15
+
16
+ /**
17
+ * @param {{config?: object, detachAgent?: boolean}} [opts] detachAgent=true 让
18
+ * 板已建好但 liveAgentOf 查不到活 agent(会话 id 从 agent 上挪走,两条查找路径同时落空)。
19
+ */
20
+ async function booted({ config = {}, detachAgent = false } = {}) {
21
+ const harness = createHarness({ config })
22
+ await harness.run()
23
+ await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
24
+ await harness.toolMap.get('progress_update').definition.execute(
25
+ { changes: [{ title: '接数据面', status: 'doing' }, { title: '写面板' }] },
26
+ { agent: harness.agent },
27
+ )
28
+ harness.steers = []
29
+ harness.agent.steer = (message) => { harness.steers.push(message); harness.inbox.nextStep.push(message) }
30
+ if (detachAgent) harness.agent.session.id = 'some-other-session'
31
+ return harness
32
+ }
33
+
34
+ /** 走「用户在面板改板」这条真实入口(origin='user')。 */
35
+ async function userEdit(harness, changes, expectedRevision) {
36
+ const res = await callRoute(harness, '/progress-union/action', jsonReq('POST', '/progress-union/action', { sessionId: SESSION, changes, expectedRevision }))
37
+ return res.json()
38
+ }
39
+
40
+ test('idle + 用户新增项 → followup 落队列,正文带 <progress-major-change rev="N">', async () => {
41
+ const harness = await booted()
42
+ const before = await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} }).then((r) => r.json())
43
+ const out = await userEdit(harness, [{ title: '补下载子条' }], before.revision)
44
+ assert.equal(out.ok, true)
45
+ assert.equal(out.notified, true, '/action 必须把服务端是否已落队列告知客户端')
46
+ assert.equal(harness.followups.length, 1, 'idle 必须走 followup')
47
+ const msg = harness.followups[0]
48
+ assert.equal(msg.role, 'user')
49
+ assert.deepEqual(msg.source, { kind: 'user', producer: 'dsh-progress-union', rev: out.revision })
50
+ assert.equal(msg.content[0].type, 'text')
51
+ const text = msg.content[0].text
52
+ assert.match(text, new RegExp(`<progress-major-change rev="${out.revision}">`))
53
+ assert.match(text, /<\/progress-major-change>/)
54
+ assert.match(text, /\+ 新增:补下载子条/)
55
+ assert.match(text, /- \[~\] 接数据面/, '正文要裹进当前清单,模型不用重新拉板')
56
+ assert.match(text, /不要按旧顺序推进/)
57
+ })
58
+
59
+ test('running + agent.steer → 走 next-step 黄档,不排 followup', async () => {
60
+ const harness = await booted()
61
+ harness.agent.status = 'running'
62
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
63
+ const out = await userEdit(harness, [{ id: before.items[1].id, remove: true }], before.revision)
64
+ assert.equal(out.ok, true)
65
+ assert.equal(harness.steers.length, 1, 'running 必须走 steer(本回合 next-step)')
66
+ assert.equal(harness.followups.length, 0, 'running 时不该另起新回合')
67
+ assert.match(harness.steers[0].content[0].text, /- 删除:写面板/)
68
+ })
69
+
70
+ test('只有非结构性改动(current/percent/status)时一条都不发', async () => {
71
+ const harness = await booted()
72
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
73
+ const out = await userEdit(harness, [
74
+ { id: before.items[0].id, current: '手工补的当前', percent: 60, status: 'doing' },
75
+ ], before.revision)
76
+ assert.equal(out.ok, true)
77
+ assert.equal(out.changed.length, 1)
78
+ assert.equal(harness.followups.length + harness.steers.length, 0, '改字段不算重大变更')
79
+ })
80
+
81
+ test('同回合连续两次结构性改板 → 合并成一条(同 rev 不重投)', async () => {
82
+ const harness = await booted()
83
+ let rev = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json().revision
84
+ const first = await userEdit(harness, [{ title: 'A' }], rev)
85
+ assert.equal(first.notified, true, '首次结构性改板必须回执 notified=true,客户端据此不再另发 wake 消息')
86
+ rev = first.revision
87
+ const second = await userEdit(harness, [{ title: 'B' }], rev)
88
+ assert.equal(second.notified, false, '同回合第两次被合并,不得假装已投递')
89
+ rev = second.revision
90
+ const third = await userEdit(harness, [{ title: 'C' }], rev)
91
+ assert.equal(third.notified, false)
92
+ rev = third.revision
93
+ assert.equal(harness.followups.length, 1, '同一回合只提一次')
94
+ // 已发的那条对应第一次的 rev;后续 rev 不再补投
95
+ assert.equal(harness.followups.filter((m) => m.source && m.source.producer === 'dsh-progress-union').length, 1)
96
+ })
97
+
98
+ test('开新回合后可以再提(提醒窗口按回合走)', async () => {
99
+ const harness = await booted()
100
+ let rev = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json().revision
101
+ rev = (await userEdit(harness, [{ title: 'A' }], rev)).revision
102
+ assert.equal(harness.followups.length, 1)
103
+ rev = (await userEdit(harness, [{ title: 'B' }], rev)).revision
104
+ assert.equal(harness.followups.length, 1, '同回合仍只一条')
105
+ harness.emit('turn/start', {})
106
+ rev = (await userEdit(harness, [{ title: 'C' }], rev)).revision
107
+ assert.equal(harness.followups.length, 2, '新回合必须能再提醒')
108
+ const revs = harness.followups.map((m) => m.source.rev)
109
+ assert.equal(new Set(revs).size, 2, '同 rev 绝不重投')
110
+ })
111
+
112
+ test('notifyMajorChanges:false 一条都不发(逐字退回 0.6.x 行为)', async () => {
113
+ const harness = await booted({ config: { notifyMajorChanges: false } })
114
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
115
+ const out = await userEdit(harness, [{ title: '关掉提醒' }], before.revision)
116
+ assert.equal(out.ok, true, '改板本身必须照常成功')
117
+ assert.equal(harness.followups.length + harness.steers.length, 0)
118
+ })
119
+
120
+ test('板未启用(关板)时不发;主模型自己写板(origin=agent)也不发', async () => {
121
+ const harness = await booted()
122
+ await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: false, source: 'command' }))
123
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
124
+ const out = await userEdit(harness, [{ title: '关板后新增' }], before.revision)
125
+ assert.equal(out.ok, true, '关板后改板本身仍要照常落盘')
126
+ assert.equal(out.items.some((i) => i.title === '关板后新增'), true)
127
+ assert.equal(harness.followups.length + harness.steers.length, 0, '关板不该往队列里丢东西')
128
+
129
+ const h2 = await booted()
130
+ await h2.toolMap.get('progress_update').definition.execute({ changes: [{ title: '模型自己新增的项' }] }, { agent: h2.agent })
131
+ assert.equal(h2.followups.length + h2.steers.length, 0, '主模型知道刚写了什么,不要回灌给它')
132
+ })
133
+
134
+ test('没有活着的 agent / steer 抛错:只吞不炸,改板照常落盘', async () => {
135
+ const harness = await booted({ detachAgent: true })
136
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
137
+ const out = await userEdit(harness, [{ title: '无 agent 也要能改板' }], before.revision)
138
+ assert.equal(out.ok, true)
139
+ assert.equal(out.items.some((i) => i.title === '无 agent 也要能改板'), true)
140
+ assert.equal(harness.followups.length, 0)
141
+
142
+ const h2 = await booted()
143
+ h2.agent.status = 'running'
144
+ h2.agent.steer = () => { throw new Error('inbox 满了') }
145
+ const b2 = (await callRoute(h2, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
146
+ const r2 = await userEdit(h2, [{ title: '派发失败也要落盘' }], b2.revision)
147
+ assert.equal(r2.ok, true, '提醒失败绝不能连带让改板失败')
148
+ assert.equal(r2.items.some((i) => i.title === '派发失败也要落盘'), true)
149
+ assert.equal(h2.followups.length, 0, 'steer 抛错后不得退回 followup 补发(避免同一变更两条队列消息)')
150
+ })
151
+
152
+ test('提醒只占一条队列消息,不叠加催办也不接管滞后面板计时', async () => {
153
+ const harness = await booted()
154
+ for (let i = 0; i < 3; i += 1) harness.emit('step/start', {})
155
+ const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
156
+ assert.match(harness.contexts.get('progress-union-observer')(), /synced="3 步前"/)
157
+
158
+ const out = await userEdit(harness, [{ title: '用户插入一项' }], before.revision)
159
+ assert.equal(out.ok, true)
160
+ assert.equal(harness.followups.length, 1, '只那一条重大变更提醒,不得叠加自动催办')
161
+ assert.equal(harness.inbox.nextTurn.length, 1, '提醒之外不另起轮次')
162
+ // 用户写板本身把 stepsSinceModel 归零(origin='user' 算一次同步),提醒不能再额外减步
163
+ harness.emit('step/start', {})
164
+ assert.match(harness.contexts.get('progress-union-observer')(), /synced="1 步前"/)
165
+ })
@@ -0,0 +1,243 @@
1
+ /**
2
+ * 0.7.0 rc.3 验收:R3 侧边栏 LLM 任务操作。
3
+ * validateBoard 纯函数 + /ops/providers + /ops 四操作(refine/mutate/ask/validate)。
4
+ * 硬约束:不新开顶级标签、零新增依赖;模型返回非法数据一律不落盘;
5
+ * origin='ops' 不得让主模型看起来「刚刚同步过板」(stepsSinceModel 不归零)。
6
+ */
7
+ import assert from 'node:assert/strict'
8
+ import fs from 'node:fs'
9
+ import os from 'node:os'
10
+ import path from 'node:path'
11
+ import test from 'node:test'
12
+
13
+ process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
14
+ const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.mjs')
15
+ const { validateBoard } = await import('../index.js')
16
+
17
+ const OPS = '/progress-union/ops'
18
+
19
+ function llmMock(reply, calls) {
20
+ return {
21
+ async *stream(options) {
22
+ if (calls) calls.push(options)
23
+ yield { type: 'text-delta', text: typeof reply === 'function' ? reply() : reply }
24
+ yield { type: 'finish', reason: { kind: 'stop' } }
25
+ },
26
+ }
27
+ }
28
+
29
+ async function booted({ config = {}, reply = '{}', calls = [], providers = undefined } = {}) {
30
+ const llm = { ...llmMock(reply, calls), ...(providers ? { listProviders: async () => providers } : {}) }
31
+ const harness = createHarness({
32
+ config: { assistant: { mode: 'registered', provider: 'local', model: 'qwen', minIntervalMs: 0 }, ...config },
33
+ llm,
34
+ })
35
+ await harness.run()
36
+ await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
37
+ await harness.toolMap.get('progress_update').definition.execute(
38
+ { changes: [{ title: '接数据面', status: 'doing' }, { title: '写面板', percent: 30 }, { title: '补测试' }] },
39
+ { agent: harness.agent },
40
+ )
41
+ return harness
42
+ }
43
+
44
+ async function snapshot(harness) {
45
+ const res = await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })
46
+ return res.json()
47
+ }
48
+
49
+ async function ops(harness, body) {
50
+ const res = await callRoute(harness, OPS, jsonReq('POST', OPS, body))
51
+ return { status: res.status, json: res.json() }
52
+ }
53
+
54
+ // ── validateBoard(纯函数)──────────────────────────────────────────────
55
+
56
+ test('validateBoard:合法板通过,接受数组或 {items}', () => {
57
+ const ok = validateBoard([{ id: 'a', title: '甲', status: 'doing', percent: 20, order: 0 }, { id: 'b', title: '乙', status: 'todo', order: 1 }])
58
+ assert.equal(ok.ok, true, ok.errors.join(';'))
59
+ assert.equal(ok.count, 2)
60
+ assert.deepEqual(ok.warnings, [])
61
+ assert.equal(validateBoard({ items: [{ title: '甲' }] }).ok, true)
62
+ })
63
+
64
+ test('validateBoard:硬错逐项拦下(项数/title/status 枚举/done⇒100/percent 越界)', () => {
65
+ assert.equal(validateBoard('nope').ok, false, '非数组必须是硬错')
66
+ const tooMany = validateBoard(Array.from({ length: 61 }, (_, i) => ({ title: 't' + i })))
67
+ assert.match(tooMany.errors.join(' '), /项数 61 超过上限 60/)
68
+ assert.match(validateBoard([{ status: 'doing' }]).errors.join(' '), /缺少 title/)
69
+ assert.match(validateBoard([{ title: '很长的'.repeat(70) }]).errors.join(' '), /title 过长/)
70
+ assert.match(validateBoard([{ title: '甲', status: 'pending-ish' }]).errors.join(' '), /status 非法/)
71
+ assert.match(validateBoard([{ title: '甲', status: 'done', percent: 50 }]).errors.join(' '), /done 但 percent=50/)
72
+ assert.match(validateBoard([{ title: '甲', percent: 140 }]).errors.join(' '), /percent 越界/)
73
+ assert.match(validateBoard([{ title: '甲', order: 'x' }]).errors.join(' '), /order 不是数字/)
74
+ assert.match(validateBoard(['nope']).errors.join(' '), /不是对象/)
75
+ })
76
+
77
+ test('validateBoard:可疑但可写的只进 warnings(空板/重复 title/order 重复/多 doing)', () => {
78
+ const empty = validateBoard([])
79
+ assert.equal(empty.ok, true)
80
+ assert.match(empty.warnings.join(' '), /空板/)
81
+ const dup = validateBoard([{ title: '甲', status: 'doing', order: 0 }, { title: '甲', status: 'doing', order: 0 }])
82
+ assert.equal(dup.ok, true)
83
+ assert.match(dup.warnings.join(' '), /title 与前面重复/)
84
+ assert.match(dup.warnings.join(' '), /order 重复:0/)
85
+ assert.match(dup.warnings.join(' '), /同时 doing 2 项/)
86
+ })
87
+
88
+ // ── /ops/providers ──────────────────────────────────────────────────────
89
+
90
+ test('providers:llm.listProviders 有值就列出来;服务缺失退回空数组不报错', async () => {
91
+ const harness = await booted({ providers: [{ id: 'local', models: [{ id: 'qwen', label: 'Qwen 3' }, 'deepseek'] }, { name: 'other' }] })
92
+ const res = await callRoute(harness, `${OPS}/providers`, { method: 'GET', url: `${OPS}/providers`, headers: {} })
93
+ const json = res.json()
94
+ assert.equal(json.ok, true)
95
+ assert.deepEqual(json.providers.map((p) => p.id), ['local', 'other'])
96
+ assert.deepEqual(json.providers[0].models.map((m) => m.id), ['qwen', 'deepseek'])
97
+ assert.equal(json.default.provider, 'local', '无宿主默认选择时退回设置页')
98
+
99
+ const bare = await booted({ reply: '{}' })
100
+ const j2 = (await callRoute(bare, `${OPS}/providers`, { method: 'GET', url: `${OPS}/providers`, headers: {} })).json()
101
+ assert.deepEqual(j2.providers, [], 'listProviders 不存在必须给空数组')
102
+ assert.equal(j2.configured.mode, 'registered')
103
+
104
+ const wrong = await callRoute(harness, `${OPS}/providers`, { method: 'POST', url: `${OPS}/providers`, headers: {} })
105
+ assert.equal(wrong.status, 405)
106
+ })
107
+
108
+ // ── /ops validate:本地活,不进 LLM ────────────────────────────────────
109
+
110
+ test('op=validate 纯本地跑,一次 llm 调用都不发', async () => {
111
+ const calls = []
112
+ const harness = await booted({ reply: '{"changes":[]}', calls })
113
+ const r = await ops(harness, { sessionId: SESSION, op: 'validate' })
114
+ assert.equal(r.status, 200)
115
+ assert.equal(r.json.ok, true)
116
+ assert.equal(r.json.applied, false)
117
+ assert.equal(r.json.validation.count, 3)
118
+ assert.equal(calls.length, 0, 'validate 不得花 token')
119
+ })
120
+
121
+ // ── /ops refine / mutate:落盘 + 护栏 ──────────────────────────────────
122
+
123
+ test('op=refine 落盘 add+edit(order),并回 snapshot;updatedBy 走 ops 通道', async () => {
124
+ const calls = []
125
+ const harness = await booted({
126
+ calls,
127
+ reply: JSON.stringify({
128
+ changes: [
129
+ { kind: 'add', title: '拆:解析 tool/result', status: 'todo', percent: 0 },
130
+ { kind: 'edit', id: 'not-a-real-id', status: 'done' },
131
+ { kind: 'add', title: '' },
132
+ ],
133
+ answer: '已按数据面拆成两步',
134
+ }),
135
+ })
136
+ const before = await snapshot(harness)
137
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine' })
138
+ assert.equal(r.json.ok, true)
139
+ assert.equal(r.json.applied, true)
140
+ assert.equal(r.json.changes.length, 1, '假 id 与空 title 必须被丢掉')
141
+ assert.equal(r.json.changes[0].change, 'add')
142
+ assert.equal(r.json.answer, '已按数据面拆成两步')
143
+ assert.equal(calls.length, 1)
144
+ assert.equal(calls[0].provider, 'local')
145
+ assert.equal(calls[0].model, 'qwen')
146
+ const after = await snapshot(harness)
147
+ assert.equal(after.items.length, before.items.length + 1)
148
+ assert.equal(after.revision, before.revision + 1)
149
+ })
150
+
151
+ test('op=mutate 能把指令翻成删除(只认板上真 id),并触发 R4 队列提醒', async () => {
152
+ let reply = '{}'
153
+ const harness = await booted({ reply: () => reply })
154
+ const snap = await snapshot(harness)
155
+ const last = snap.items.find((i) => i.title === '补测试')
156
+ reply = JSON.stringify({ changes: [{ kind: 'remove', id: last.id }, { kind: 'remove', id: 'ghost-id' }], answer: '删掉了' })
157
+ const r = await ops(harness, { sessionId: SESSION, op: 'mutate', question: '把补测试删掉' })
158
+ assert.equal(r.json.applied, true)
159
+ assert.deepEqual(r.json.changes, [{ id: last.id, title: '补测试', removed: true }], '不存在的 id 必须被丢掉')
160
+ const after = await snapshot(harness)
161
+ assert.equal(after.items.some((i) => i.title === '补测试'), false)
162
+ // R4:删除是结构性变更 → idle 走 followup 落队列
163
+ const notice = harness.followups.at(-1)
164
+ assert.ok(notice, '结构性变更必须落输入队列')
165
+ assert.equal(notice.source.kind, 'user', 'isHumanSteer 只认 kind=user')
166
+ assert.match(notice.content[0].text, /<progress-major-change rev="\d+">/)
167
+ })
168
+
169
+ test('op=mutate/ask 缺 question、未知 op、缺 sessionId 一律 400', async () => {
170
+ const harness = await booted({ reply: '{"changes":[]}' })
171
+ assert.equal((await ops(harness, { sessionId: SESSION, op: 'mutate' })).status, 400)
172
+ assert.equal((await ops(harness, { sessionId: SESSION, op: 'ask' })).status, 400)
173
+ assert.equal((await ops(harness, { sessionId: SESSION, op: 'teleport' })).status, 400)
174
+ assert.equal((await ops(harness, { sessionId: '', op: 'validate' })).status, 400)
175
+ })
176
+
177
+ test('未配置辅助模型 → 400,且不落任何改动', async () => {
178
+ const harness = await booted({ config: { assistant: { mode: '' } }, reply: '{"changes":[{"kind":"add","title":"x"}]}' })
179
+ const before = await snapshot(harness)
180
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine' })
181
+ assert.equal(r.status, 400)
182
+ assert.match(r.json.error, /辅助模型未配置/)
183
+ const after = await snapshot(harness)
184
+ assert.equal(after.revision, before.revision, '拿不到模型就不许动板')
185
+ })
186
+
187
+ test('模型乱答(无 JSON)→ 502,板不变', async () => {
188
+ const harness = await booted({ reply: '我觉得可以拆成三步,你先看看代码' })
189
+ const before = await snapshot(harness)
190
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine' })
191
+ assert.equal(r.status, 502)
192
+ assert.match(r.json.error, /无法解析|没有返回/)
193
+ assert.equal((await snapshot(harness)).revision, before.revision)
194
+ })
195
+
196
+ test('模型给超过 8 条改动只应用前 8 条', async () => {
197
+ const many = Array.from({ length: 12 }, (_, i) => ({ kind: 'add', title: '拆项 ' + i }))
198
+ const harness = await booted({ reply: JSON.stringify({ changes: many, answer: 'ok' }) })
199
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine' })
200
+ assert.equal(r.json.changes.length, 8)
201
+ assert.equal((await snapshot(harness)).items.length, 3 + 8)
202
+ })
203
+
204
+ // ── ask:只回文本 ──────────────────────────────────────────────────────
205
+
206
+ test('op=ask 只回文本:模型硬塞 changes 也不落盘', async () => {
207
+ const calls = []
208
+ const harness = await booted({
209
+ calls,
210
+ reply: JSON.stringify({ changes: [{ kind: 'add', title: '不该出现' }], answer: '三项里只有「接数据面」在做' }),
211
+ })
212
+ const before = await snapshot(harness)
213
+ const r = await ops(harness, { sessionId: SESSION, op: 'ask', question: '现在卡在哪' })
214
+ assert.equal(r.json.ok, true)
215
+ assert.equal(r.json.applied, false)
216
+ assert.equal(r.json.changes.length, 0)
217
+ assert.match(r.json.answer, /只有「接数据面」/)
218
+ assert.equal(calls.length, 1)
219
+ const after = await snapshot(harness)
220
+ assert.equal(after.revision, before.revision, 'ask 绝不改板')
221
+ })
222
+
223
+ test('喂给模型的板必须带 id(否则它无法指认 edit/remove 哪一项)', async () => {
224
+ const calls = []
225
+ const harness = await booted({ calls, reply: '{"changes":[],"answer":"x"}' })
226
+ const snap = await snapshot(harness)
227
+ await ops(harness, { sessionId: SESSION, op: 'refine' })
228
+ const user = calls[0].messages[0].content[0].text
229
+ for (const item of snap.items) assert.ok(user.includes(item.id), `提示里必须含板上项 id ${item.id}`)
230
+ assert.match(user, /<progress-board ids="true">/)
231
+ })
232
+
233
+ // ── origin='ops' 不冒充主模型 ──────────────────────────────────────────
234
+
235
+ test('ops 落盘不重置 stepsSinceModel:催办仍按原步数报滞后', async () => {
236
+ const harness = await booted({ reply: JSON.stringify({ changes: [{ kind: 'add', title: '拆项' }], answer: 'ok' }) })
237
+ for (let i = 0; i < 4; i += 1) harness.emit('step/start', {})
238
+ const text = () => harness.contexts.get('progress-union-observer')()
239
+ assert.match(text(), /synced="4 步前"/)
240
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine' })
241
+ assert.equal(r.json.applied, true)
242
+ assert.match(text(), /synced="4 步前"/, '侧边栏 LLM 操作不算「模型已同步」')
243
+ })