dsh-project-flow 0.9.0 → 0.9.2
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 +0 -0
- package/README.md +58 -11
- package/cordis.patch.yml +30 -11
- package/docs/DETAIL.md +6 -6
- package/docs/FEATURES.md +12 -5
- package/docs/LAUNCH.md +3 -3
- package/docs/MOMENTS.md +4 -4
- package/docs/USAGE.md +2 -2
- package/domains.mjs +1 -1
- package/evidence.mjs +19 -3
- package/flow.schema.mjs +192 -35
- package/gate.mjs +49 -23
- package/index.js +639 -120
- package/locale/en.json +15 -4
- package/locale/zh.json +17 -6
- package/package.json +5 -3
- package/tests/_heartbeat-regression.test.mjs +124 -0
- package/tests/aesthetic.test.mjs +534 -0
- package/tests/assertions-e2e.mjs +234 -0
- package/tests/bench-check.mjs +32 -0
- package/tests/client-bundle.test.mjs +707 -0
- package/tests/contract.test.mjs +137 -0
- package/tests/desktop.test.mjs +130 -0
- package/tests/domains.test.mjs +220 -0
- package/tests/e2e.mjs +300 -0
- package/tests/evidence.test.mjs +408 -0
- package/tests/extra-phase.test.mjs +133 -0
- package/tests/feedback.test.mjs +187 -0
- package/tests/flow-create.test.mjs +168 -0
- package/tests/flow-gate.test.mjs +232 -0
- package/tests/flow-schema.test.mjs +213 -0
- package/tests/gate.test.mjs +246 -0
- package/tests/issue-loop.test.mjs +254 -0
- package/tests/issues-e2e.mjs +246 -0
- package/tests/panel-independence.test.mjs +78 -0
- package/tests/panel-report.test.mjs +129 -0
- package/tests/patch-ledger.test.mjs +280 -0
- package/tests/paths.mjs +100 -0
- package/tests/preview-path.test.mjs +69 -0
- package/tests/qa-assertions.test.mjs +352 -0
- package/tests/run-all.mjs +90 -0
- package/tests/stage-model.test.mjs +120 -0
- package/tests/stop-resume.test.mjs +260 -0
- package/tests/watch-root.test.mjs +167 -0
- package/tests/watchdog-tokens.test.mjs +53 -0
- package/tests/watchdog.test.mjs +305 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把 client.js 真跑一遍,不靠浏览器。
|
|
3
|
+
*
|
|
4
|
+
* 前面几轮出过的两个错,都能被这一条挡住:
|
|
5
|
+
* 1. 挂错槽位(`composer.dock` 是输入框**下面**,用户要的是上面)
|
|
6
|
+
* 2. 没项目时 `return null` —— 装好了等于没装
|
|
7
|
+
*
|
|
8
|
+
* 做法:给一个假的 `window.__ModuleLoader__` 接住 factory,喂一个极简 React,
|
|
9
|
+
* 拿到 apply 后调一次,再渲染一次组件,看它到底返回什么。
|
|
10
|
+
* 这不是「真渲染」,但能证明 bundle 能加载、能注册、且一定不会返回 null。
|
|
11
|
+
*/
|
|
12
|
+
import { readFile } from 'node:fs/promises'
|
|
13
|
+
import { readFileSync } from 'node:fs'
|
|
14
|
+
import { join, dirname } from 'node:path'
|
|
15
|
+
import { fileURLToPath } from 'node:url'
|
|
16
|
+
import { LIVE_DIR } from './paths.mjs'
|
|
17
|
+
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
19
|
+
const source = await readFile(join(LIVE_DIR, 'client.js'), 'utf8')
|
|
20
|
+
|
|
21
|
+
const results = []
|
|
22
|
+
const check = (label, fn) => {
|
|
23
|
+
let ok = false
|
|
24
|
+
let detail = ''
|
|
25
|
+
try {
|
|
26
|
+
const out = fn()
|
|
27
|
+
ok = out === true || (out && out.ok === true)
|
|
28
|
+
detail = out && out.detail ? String(out.detail) : ''
|
|
29
|
+
} catch (error) {
|
|
30
|
+
ok = false
|
|
31
|
+
detail = error.message
|
|
32
|
+
}
|
|
33
|
+
results.push({ label, ok, detail })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 异步断言:排到队里,最后按顺序结算,位置不变。 */
|
|
37
|
+
const pendingChecks = []
|
|
38
|
+
const checkAsync = (label, fn) => { pendingChecks.push({ label, fn }) }
|
|
39
|
+
|
|
40
|
+
// ── 假 React:只够组件函数跑完一圈 ──────────────────────
|
|
41
|
+
|
|
42
|
+
// 组件第一次渲染时 useState 的初值由这里灌进去,用来模拟「有项目」的状态
|
|
43
|
+
let seeds = []
|
|
44
|
+
let seedIndex = 0
|
|
45
|
+
|
|
46
|
+
function resetSeeds(next) {
|
|
47
|
+
seeds = next ?? []
|
|
48
|
+
seedIndex = 0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function fakeReact() {
|
|
52
|
+
return {
|
|
53
|
+
Fragment: Symbol('Fragment'),
|
|
54
|
+
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children }),
|
|
55
|
+
useState: initial => {
|
|
56
|
+
const value = seedIndex < seeds.length ? seeds[seedIndex] : initial
|
|
57
|
+
seedIndex += 1
|
|
58
|
+
return [value, () => {}]
|
|
59
|
+
},
|
|
60
|
+
useEffect: () => {},
|
|
61
|
+
useRef: initial => ({ current: initial }),
|
|
62
|
+
useCallback: fn => fn,
|
|
63
|
+
useMemo: fn => fn(),
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** 在元素树里按条件收集节点。 */
|
|
68
|
+
function collect(node, predicate, out = []) {
|
|
69
|
+
if (node === null || node === undefined || node === false) return out
|
|
70
|
+
if (Array.isArray(node)) {
|
|
71
|
+
for (const item of node) collect(item, predicate, out)
|
|
72
|
+
return out
|
|
73
|
+
}
|
|
74
|
+
if (typeof node !== 'object') return out
|
|
75
|
+
if (predicate(node)) out.push(node)
|
|
76
|
+
for (const child of node.children ?? []) collect(child, predicate, out)
|
|
77
|
+
return out
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 把元素树里的纯文本拼起来,用来断言文案。 */
|
|
81
|
+
function textOf(node) {
|
|
82
|
+
if (node === null || node === undefined || node === false) return ''
|
|
83
|
+
if (Array.isArray(node)) return node.map(textOf).join('')
|
|
84
|
+
if (typeof node === 'string' || typeof node === 'number') return String(node)
|
|
85
|
+
if (typeof node !== 'object') return ''
|
|
86
|
+
return (node.children ?? []).map(textOf).join('')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ── 假加载器:接住 factory ──────────────────────────────
|
|
90
|
+
|
|
91
|
+
let captured
|
|
92
|
+
const fakeWindow = {
|
|
93
|
+
__ModuleLoader__: {
|
|
94
|
+
load(entry) { captured = entry },
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
check('client.js 调用了 window.__ModuleLoader__.load', () => {
|
|
99
|
+
// eslint-disable-next-line no-new-func
|
|
100
|
+
new Function('window', source)(fakeWindow)
|
|
101
|
+
return { ok: captured !== undefined, detail: '没有被接住' }
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
check('注册的 id 与包名一致', () => ({
|
|
105
|
+
ok: captured?.id === 'dsh-project-flow',
|
|
106
|
+
detail: String(captured?.id),
|
|
107
|
+
}))
|
|
108
|
+
|
|
109
|
+
check('factory 是函数', () => typeof captured?.factory === 'function')
|
|
110
|
+
|
|
111
|
+
let exported
|
|
112
|
+
check('factory 跑完返回 { inject, apply }', () => {
|
|
113
|
+
exported = captured.factory(name => {
|
|
114
|
+
if (name === 'react') return fakeReact()
|
|
115
|
+
if (name === 'react/jsx-runtime') return { jsx: fakeReact().createElement }
|
|
116
|
+
throw new Error(`不该 require 的东西:${name}`)
|
|
117
|
+
})
|
|
118
|
+
return {
|
|
119
|
+
ok: typeof exported?.apply === 'function' && Array.isArray(exported?.inject),
|
|
120
|
+
detail: JSON.stringify(exported === undefined ? null : { inject: exported.inject }),
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
check('一个服务都不声明——写了名字却不存在会让 apply 永远不跑', () => ({
|
|
125
|
+
ok: JSON.stringify(exported?.inject) === '[]',
|
|
126
|
+
detail: JSON.stringify(exported?.inject),
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
// ── 调 apply,看它挂到哪个槽 ────────────────────────────
|
|
130
|
+
|
|
131
|
+
let injectedName
|
|
132
|
+
let registeredDef
|
|
133
|
+
let registeredComponent
|
|
134
|
+
const collectedRegistrations = []
|
|
135
|
+
const fakeSlots = {
|
|
136
|
+
inject(name, callback) {
|
|
137
|
+
// 只记第一个:它就是主槽位。兜底的那些不影响判断。
|
|
138
|
+
if (injectedName === undefined) injectedName = name
|
|
139
|
+
callback()
|
|
140
|
+
return () => {}
|
|
141
|
+
},
|
|
142
|
+
register(definition, component) {
|
|
143
|
+
registeredDef = definition
|
|
144
|
+
registeredComponent = component
|
|
145
|
+
collectedRegistrations.push(definition)
|
|
146
|
+
return () => {}
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const logs = []
|
|
151
|
+
const warns = []
|
|
152
|
+
const originalLog = console.log
|
|
153
|
+
const originalError = console.error
|
|
154
|
+
console.log = (...args) => { logs.push(args.join(' ')) }
|
|
155
|
+
console.error = (...args) => { warns.push(args.join(' ')) }
|
|
156
|
+
|
|
157
|
+
let applyError
|
|
158
|
+
try {
|
|
159
|
+
exported.apply({ slots: fakeSlots, remote: { workspaceFiles: { list: async () => undefined }, commands: { execute: async () => ({ ok: true, value: { kind: 'success' } }) } } })
|
|
160
|
+
} catch (error) {
|
|
161
|
+
applyError = error
|
|
162
|
+
}
|
|
163
|
+
console.log = originalLog
|
|
164
|
+
console.error = originalError
|
|
165
|
+
|
|
166
|
+
check('apply 没抛错', () => ({ ok: applyError === undefined, detail: applyError?.message ?? '' }))
|
|
167
|
+
check('第一个注册的是会话标题栏(用户要的位置)', () => ({
|
|
168
|
+
ok: collectedRegistrations[0]?.name === 'conversation.session.header.actions',
|
|
169
|
+
detail: `实际第一个是 ${collectedRegistrations[0]?.name}`,
|
|
170
|
+
}))
|
|
171
|
+
check('只挂标题栏一个槽位,不再往输入框上下重复挂', () => {
|
|
172
|
+
const start = source.indexOf('const SLOT_CANDIDATES')
|
|
173
|
+
const block = source.slice(start, source.indexOf(']', start))
|
|
174
|
+
const names = [...block.matchAll(/'([^']+)'/gu)].map(match => match[1])
|
|
175
|
+
return {
|
|
176
|
+
ok: names.length === 1 && names[0] === 'conversation.session.header.actions',
|
|
177
|
+
detail: JSON.stringify(names),
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
check('只注册一次,不会出现同样的东西三份', () => ({
|
|
181
|
+
ok: collectedRegistrations.length === 1,
|
|
182
|
+
detail: JSON.stringify(collectedRegistrations.map(def => def.id)),
|
|
183
|
+
}))
|
|
184
|
+
check('chip 底纹是透明的', () => {
|
|
185
|
+
const chipRule = source.slice(source.indexOf('.pfchip{'), source.indexOf('\n', source.indexOf('.pfchip{')))
|
|
186
|
+
return {
|
|
187
|
+
ok: chipRule.includes('background:transparent'),
|
|
188
|
+
detail: chipRule.includes('background:transparent') ? '' : chipRule.slice(0, 160),
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
check('按钮外观被抹掉,不叠系统样式', () => {
|
|
192
|
+
const chipRule = source.slice(source.indexOf('.pfchip{'), source.indexOf('\n', source.indexOf('.pfchip{')))
|
|
193
|
+
return {
|
|
194
|
+
ok: chipRule.includes('appearance:none') && chipRule.includes('box-shadow:none'),
|
|
195
|
+
detail: chipRule.slice(0, 120),
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
check('字体整套继承,不自己定字号字重', () => {
|
|
199
|
+
// 它和「标准模式」「N 个子智能体」同一排,必须是同一行字。
|
|
200
|
+
// 只要自己写一个 font-size,两边就会差一档,看着像插进去的小控件。
|
|
201
|
+
const chipRule = source.slice(source.indexOf('.pfchip{'), source.indexOf('\n', source.indexOf('.pfchip{')))
|
|
202
|
+
const inherits = ['font-family', 'font-size', 'font-weight', 'line-height', 'letter-spacing']
|
|
203
|
+
.every(prop => chipRule.includes(`${prop}:inherit`))
|
|
204
|
+
const ownSize = /\bfont-size:\s*\d/u.test(chipRule)
|
|
205
|
+
return {
|
|
206
|
+
ok: inherits && !ownSize && !/opacity:\s*0?\.\d/u.test(chipRule),
|
|
207
|
+
detail: `继承=${inherits} 自定字号=${ownSize}`,
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
check('打了一行能对上的日志', () => ({
|
|
211
|
+
ok: logs.some(line => line.includes('[project-flow] 状态栏挂了')),
|
|
212
|
+
detail: logs.join(' | ') || warns.join(' | '),
|
|
213
|
+
}))
|
|
214
|
+
|
|
215
|
+
// ── 渲染:收起是一格 chip,点开是浮层 ───────────────────
|
|
216
|
+
|
|
217
|
+
const DEFAULT_PANEL = { projects: [], routes: undefined, inside: false }
|
|
218
|
+
|
|
219
|
+
const project = over => ({
|
|
220
|
+
project: 'demo',
|
|
221
|
+
stage: 2,
|
|
222
|
+
status: 'planning',
|
|
223
|
+
rework: 0,
|
|
224
|
+
maxRework: 2,
|
|
225
|
+
routes: { plan: 'spawn/deepseek-v4.1-flash', build: 'spawn/hy4flash', check: 'spawn/deepseek-v4.1-flash' },
|
|
226
|
+
updatedAt: '2026-11-30T10:00:00.000Z',
|
|
227
|
+
running: true,
|
|
228
|
+
...over,
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
/** 组件拿到的文件服务桩:只要不是 undefined,就不算「接不上」。 */
|
|
232
|
+
const filesStub = {
|
|
233
|
+
list: async () => undefined,
|
|
234
|
+
read: async () => undefined,
|
|
235
|
+
stat: async () => undefined,
|
|
236
|
+
changes: async () => [],
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 组件的 state 顺序是 panel → open → busy → notice,按位灌进去。
|
|
241
|
+
* @param panel 面板数据,不传就是组件自己的初值
|
|
242
|
+
* @param open 是否处于展开态
|
|
243
|
+
* @param files 文件服务;传 null 表示没接上
|
|
244
|
+
*/
|
|
245
|
+
const render = (panel, open, files = filesStub, catalog = [], runCommand = undefined) => {
|
|
246
|
+
// state 顺序:panel → open → busy → notice → catalog
|
|
247
|
+
resetSeeds([panel ?? DEFAULT_PANEL, open === true, false, '', catalog])
|
|
248
|
+
return registeredComponent({ sessionId: 'session-test', files, runCommand }, {})
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** 一份假的本机模型清单。 */
|
|
252
|
+
const CATALOG = [
|
|
253
|
+
{ id: 'spawn', name: 'Spawn', models: [{ id: 'deepseek-v4.1-flash', name: 'DeepSeek V4.1 Flash' }, { id: 'hy4flash', name: 'hy4flash' }] },
|
|
254
|
+
{ id: 'deepseek', name: 'DeepSeek', models: [{ id: 'deepseek-v4.1-flash', name: 'DeepSeek V4.1 Flash' }] },
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
const chipOf = element => collect(element, node => node.type === 'button'
|
|
258
|
+
&& typeof node.props?.className === 'string'
|
|
259
|
+
&& node.props.className.startsWith('pfchip'))[0]
|
|
260
|
+
|
|
261
|
+
const popOf = element => collect(element, node => node.props?.className === 'pfpop')[0]
|
|
262
|
+
|
|
263
|
+
const segsOf = element => collect(element, node => node.type === 'span'
|
|
264
|
+
&& typeof node.props?.className === 'string'
|
|
265
|
+
&& node.props.className.startsWith('pfseg '))
|
|
266
|
+
|
|
267
|
+
check('收起态渲染出一格 chip,不是 null', () => {
|
|
268
|
+
const chip = chipOf(render(undefined, false))
|
|
269
|
+
return { ok: chip !== undefined, detail: JSON.stringify(render(undefined, false))?.slice(0, 160) ?? 'null' }
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
check('chip 是个可点的按钮,带 aria 展开状态', () => {
|
|
273
|
+
const chip = chipOf(render(undefined, false))
|
|
274
|
+
return {
|
|
275
|
+
ok: chip?.props?.['aria-haspopup'] === 'dialog' && chip?.props?.['aria-expanded'] === false,
|
|
276
|
+
detail: JSON.stringify({ haspopup: chip?.props?.['aria-haspopup'], expanded: chip?.props?.['aria-expanded'] }),
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
check('收起状态也加载样式表,否则按钮露出浏览器默认灰底', () => {
|
|
281
|
+
// 之前 <style> 只放在展开的浮层里,收起时整份 CSS 没加载,
|
|
282
|
+
// <button> 就露出系统默认的灰底加边框——看上去像样式没生效。
|
|
283
|
+
const styles = collect(render(undefined, false), node => node.type === 'style')
|
|
284
|
+
return {
|
|
285
|
+
ok: styles.length === 1 && textOf(styles[0]).includes('.pfchip{'),
|
|
286
|
+
detail: `找到 ${styles.length} 个 style`,
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
check('接不上宿主时写「未接上」,不谎称「未启用」', () => {
|
|
291
|
+
// 这两个是不同的病:目录不对 vs 这一层连接没建立。
|
|
292
|
+
// 混成一句话,用户会以为目录有问题,然后一直去改目录。
|
|
293
|
+
const text = textOf(chipOf(render({ inside: false, projects: [], routes: undefined }, false, null)))
|
|
294
|
+
return { ok: text.includes('未接上') && !text.includes('未启用'), detail: text }
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
check('只有文件服务和命令服务都断了才算「未接上」', () => {
|
|
298
|
+
// 这个构建里 remote.workspaceFiles 取不到,remote.commands 能取到。
|
|
299
|
+
// 有一条能走就不该说接不上——那会让人以为整个插件没工作。
|
|
300
|
+
const withCommand = textOf(chipOf(render(
|
|
301
|
+
{ inside: false, projects: [], routes: undefined },
|
|
302
|
+
false,
|
|
303
|
+
null,
|
|
304
|
+
[],
|
|
305
|
+
async () => ({ ok: true, text: '{}' }),
|
|
306
|
+
)))
|
|
307
|
+
const withNothing = textOf(chipOf(render({ inside: false, projects: [], routes: undefined }, false, null)))
|
|
308
|
+
return {
|
|
309
|
+
ok: !withCommand.includes('未接上') && withNothing.includes('未接上'),
|
|
310
|
+
detail: `有命令=${withCommand} / 都没=${withNothing}`,
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
check('取面板数据只用 HTTP,绝不调命令(否则对话框里会多一条)', () => {
|
|
314
|
+
// 用户报了两轮的那个毛病:点一下状态栏,对话框里就多一段看不懂的字。
|
|
315
|
+
// 根子是「打开面板时自动调一次 /flow-panel」,而命令服务每次执行都会往
|
|
316
|
+
// 会话里追加 command/run 和 command/done,界面当消息渲染出来。
|
|
317
|
+
// 所以:整个文件里 runCommand 只能出现在用户点击的那一条路上。
|
|
318
|
+
const calls = [...source.matchAll(/runCommand\(/gu)]
|
|
319
|
+
const touchesPanel = source.includes("runCommand('/flow-panel')")
|
|
320
|
+
const hasHttpFetcher = source.includes('refreshPanel')
|
|
321
|
+
return {
|
|
322
|
+
ok: calls.length === 1 && touchesPanel === false && hasHttpFetcher,
|
|
323
|
+
detail: `runCommand 调用点=${calls.length} 调 flow-panel=${touchesPanel} 有HTTP取数=${hasHttpFetcher}`,
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
checkAsync('宿主那边 /flow-panel 命令已下线', async () => {
|
|
328
|
+
const { readFile } = await import('node:fs/promises')
|
|
329
|
+
const { join } = await import('node:path')
|
|
330
|
+
const { LIVE_DIR } = await import('./paths.mjs')
|
|
331
|
+
const hostSource = await readFile(join(LIVE_DIR, 'index.js'), 'utf8')
|
|
332
|
+
const registered = hostSource.includes("name: 'flow-panel'")
|
|
333
|
+
return { ok: registered === false, detail: `还注册着=${registered}` }
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
check('在工作流目录但还没跑过项目时,chip 写「就绪」而不是 0/4', () => {
|
|
337
|
+
// 0/4 看着像「一个阶段都没走完」,但这里其实是「目录对了,还没开工」。
|
|
338
|
+
const text = textOf(chipOf(render({ inside: true, ranBefore: false, projects: [], routes: undefined }, false)))
|
|
339
|
+
return { ok: text.includes('就绪'), detail: text }
|
|
340
|
+
})
|
|
341
|
+
check('跑过项目、现在一个都没有:也说就绪,不写 0/4', () => {
|
|
342
|
+
// 0/4 是「一个阶段都没走完」,但空目录里根本没项目可走
|
|
343
|
+
const text = textOf(chipOf(render({ inside: true, ranBefore: true, projects: [], routes: undefined }, false)))
|
|
344
|
+
return { ok: !text.includes('0/4') && text.includes('就绪'), detail: text }
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
check('第 2 阶在跑时,chip 写状态词「进行中」', () => {
|
|
348
|
+
// 用户要的是判词,不是计数:已通过 / 未通过 / 进行中
|
|
349
|
+
const text = textOf(chipOf(render({ inside: true, projects: [project()], routes: undefined }, false)))
|
|
350
|
+
return { ok: text.includes('进行中'), detail: text }
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
check('全部走完的项目:chip 写「已通过」', () => {
|
|
354
|
+
const done = { ...project(), stage: 4, status: 'passed', running: false }
|
|
355
|
+
const text = textOf(chipOf(render({ inside: true, projects: [done], routes: undefined }, false)))
|
|
356
|
+
return { ok: text.includes('已通过'), detail: text }
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
check('阶段跑挂了:chip 写「出错了」,不跟「未通过」混', () => {
|
|
360
|
+
// 子会话报错/超时是故障,「跑完了但质检判 FAIL」是结论,两件事
|
|
361
|
+
const bad = { ...project(), status: '实施失败:error', running: false }
|
|
362
|
+
const text = textOf(chipOf(render({ inside: true, projects: [bad], routes: undefined }, false)))
|
|
363
|
+
return { ok: text.includes('出错了') && !text.includes('未通过'), detail: text }
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
check('质检判 FAIL(跑完了):chip 写「未通过」', () => {
|
|
367
|
+
const failed = { ...project(), stage: 4, status: 'qa-failed', running: false }
|
|
368
|
+
const text = textOf(chipOf(render({ inside: true, projects: [failed], routes: undefined }, false)))
|
|
369
|
+
return { ok: text.includes('未通过'), detail: text }
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
check('停住了的项目:chip 写「已停止」,不能写「进行中」', () => {
|
|
373
|
+
// 真踩过:项目两小时前就停了,状态栏一直显示「进行中」,
|
|
374
|
+
// 用户以为还在跑,等着。停下来的必须说停。
|
|
375
|
+
const halted = { ...project(), stage: 3, status: 'stopped', running: false }
|
|
376
|
+
const text = textOf(chipOf(render({ inside: true, projects: [halted], routes: undefined }, false)))
|
|
377
|
+
return { ok: text.includes('已停止') && !text.includes('进行中'), detail: text }
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
check('收起态不渲染浮层——不占地方', () => {
|
|
381
|
+
return { ok: popOf(render({ inside: true, projects: [project()], routes: undefined }, false)) === undefined }
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
// ── 点开后的全貌 ────────────────────────────────────────
|
|
385
|
+
|
|
386
|
+
const OPEN = { inside: true, projects: [project()], routes: undefined }
|
|
387
|
+
|
|
388
|
+
check('点开后渲染出浮层', () => ({ ok: popOf(render(OPEN, true)) !== undefined }))
|
|
389
|
+
|
|
390
|
+
check('浮层里四段齐全,一阶一段', () => {
|
|
391
|
+
const segs = segsOf(render(OPEN, true))
|
|
392
|
+
return { ok: segs.length === 4, detail: `实际 ${segs.length} 段` }
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
check('第 2 阶在跑:已过 / 进行中 / 没到 / 没到', () => {
|
|
396
|
+
const classes = segsOf(render(OPEN, true)).map(node => node.props.className)
|
|
397
|
+
return {
|
|
398
|
+
ok: JSON.stringify(classes) === JSON.stringify([
|
|
399
|
+
'pfseg is-done',
|
|
400
|
+
'pfseg is-active',
|
|
401
|
+
'pfseg is-idle',
|
|
402
|
+
'pfseg is-idle',
|
|
403
|
+
]),
|
|
404
|
+
detail: JSON.stringify(classes),
|
|
405
|
+
}
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
check('每段都写明这一阶叫什么、现在什么状态', () => {
|
|
409
|
+
const texts = segsOf(render(OPEN, true)).map(node => textOf(node))
|
|
410
|
+
return {
|
|
411
|
+
ok: ['需求', '规划', '实施', '质检'].every(label => texts.some(text => text.includes(label)))
|
|
412
|
+
&& texts.some(text => text.includes('已过'))
|
|
413
|
+
&& texts.some(text => text.includes('进行中')),
|
|
414
|
+
detail: JSON.stringify(texts),
|
|
415
|
+
}
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
check('浮层里能改三阶模型', () => {
|
|
419
|
+
const element = render(OPEN, true)
|
|
420
|
+
const selects = collect(element, node => node.type === 'select')
|
|
421
|
+
const labels = collect(element, node => node.type === 'label').map(node => textOf(node))
|
|
422
|
+
return {
|
|
423
|
+
ok: selects.length === 3
|
|
424
|
+
&& ['规划', '实施', '质检'].every(label => labels.some(text => text.startsWith(label))),
|
|
425
|
+
detail: `select=${selects.length} labels=${JSON.stringify(labels)}`,
|
|
426
|
+
}
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
check('正在跑的时候,按钮是「停止第 2 阶」', () => {
|
|
430
|
+
const text = textOf(popOf(render(OPEN, true)))
|
|
431
|
+
return { ok: text.includes('停止第 2 阶'), detail: text }
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
check('停住的时候,按钮是「从第 3 阶继续」', () => {
|
|
435
|
+
const element = render({ inside: true, projects: [project({ stage: 3, status: 'stopped', running: false })], routes: undefined }, true)
|
|
436
|
+
const text = textOf(popOf(element))
|
|
437
|
+
return { ok: text.includes('从第 3 阶继续') && text.includes('停在这一阶'), detail: text }
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
check('走完的时候,按钮禁用且写「四阶已经走完」', () => {
|
|
441
|
+
const element = render({ inside: true, projects: [project({ stage: 4, status: 'passed', running: false })], routes: undefined }, true)
|
|
442
|
+
const text = textOf(popOf(element))
|
|
443
|
+
const disabled = collect(element, node => node.type === 'button'
|
|
444
|
+
&& textOf(node).includes('四阶已经走完'))[0]?.props?.disabled
|
|
445
|
+
return { ok: text.includes('四阶已经走完') && disabled === true, detail: text }
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
check('不在工作流目录时,浮层说清工作流到底在哪', () => {
|
|
449
|
+
// 只说「未启用」等于把人丢在原地。要给出具体路径,否则用户不知道该往哪切。
|
|
450
|
+
//
|
|
451
|
+
// 而且给的必须是「工作流在哪个盘」——以前显示的是会话目录,
|
|
452
|
+
// 人在默认工作区(C 盘)打开就会写成「当前工作区:C:\…」,
|
|
453
|
+
// 用户当场就问「我的工作流不是在 D 盘吗」。现在用宿主算出来的 wherePath。
|
|
454
|
+
const text = textOf(popOf(render({
|
|
455
|
+
inside: false,
|
|
456
|
+
ranBefore: false,
|
|
457
|
+
projects: [],
|
|
458
|
+
routes: undefined,
|
|
459
|
+
cwd: 'C:\\Users\\ASUS\\OneDrive\\ドキュメント\\deepseek-harness\\default-workspace',
|
|
460
|
+
wherePath: 'D:\\新建文件夹 (4)\\工作流',
|
|
461
|
+
}, true)))
|
|
462
|
+
return {
|
|
463
|
+
ok: text.includes('不在工作流目录')
|
|
464
|
+
&& text.includes('工作流在:D:\\新建文件夹 (4)\\工作流')
|
|
465
|
+
&& !text.includes('当前工作区:')
|
|
466
|
+
&& !text.includes('停止第'),
|
|
467
|
+
detail: text,
|
|
468
|
+
}
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
check('路径里已经有「工作流」就算启用——不必等它跑过一次项目', () => {
|
|
472
|
+
// 之前只看 .project-flow 存不存在,新建的工作流目录永远显示「未启用」。
|
|
473
|
+
const text = textOf(chipOf(render({
|
|
474
|
+
inside: true,
|
|
475
|
+
ranBefore: false,
|
|
476
|
+
nameMatch: true,
|
|
477
|
+
rootPath: 'D:\\工作流',
|
|
478
|
+
suggestPath: 'D:\\工作流',
|
|
479
|
+
projects: [],
|
|
480
|
+
routes: undefined,
|
|
481
|
+
}, false)))
|
|
482
|
+
return { ok: text.includes('就绪'), detail: text }
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
check('客户端的目录名常量和宿主一致', () => {
|
|
486
|
+
const host = readFileSync(join(LIVE_DIR, 'index.js'), 'utf8')
|
|
487
|
+
const hostName = /const FLOW_DIR_NAME = '([^']+)'/u.exec(host)?.[1]
|
|
488
|
+
const clientName = /const FLOW_DIR_NAME = '([^']+)'/u.exec(source)?.[1]
|
|
489
|
+
return {
|
|
490
|
+
ok: hostName !== undefined && hostName === clientName,
|
|
491
|
+
detail: `宿主=${hostName} 客户端=${clientName}`,
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
check('四段长条带流动斜纹的关键帧', () => ({
|
|
496
|
+
ok: source.includes('@keyframes pfflow') && source.includes('.pfseg.is-active::before'),
|
|
497
|
+
detail: source.includes('@keyframes pfflow') ? '' : '没有流动动画',
|
|
498
|
+
}))
|
|
499
|
+
|
|
500
|
+
check('不赌新语法:不用 color-mix', () => ({
|
|
501
|
+
ok: !source.includes('color-mix'),
|
|
502
|
+
detail: '还有 color-mix,老 Chromium 上会整条边框失效',
|
|
503
|
+
}))
|
|
504
|
+
|
|
505
|
+
check('浮层里有命令按钮,不用回输入框打斜杠', () => {
|
|
506
|
+
const element = render(OPEN, true)
|
|
507
|
+
const buttons = collect(element, node => node.type === 'button'
|
|
508
|
+
&& typeof node.props?.className === 'string'
|
|
509
|
+
&& node.props.className === 'pfcmd')
|
|
510
|
+
const labels = buttons.map(node => textOf(node))
|
|
511
|
+
const lines = buttons.map(node => node.props.title.split(' —— ')[0])
|
|
512
|
+
return {
|
|
513
|
+
// 面板上出现了「花费」,去掉了「面板」:前者是用户真要看的东西,
|
|
514
|
+
// 后者返回的是一段 JSON,贴在浮层里没人看得懂。
|
|
515
|
+
ok: buttons.length === 8
|
|
516
|
+
&& ['状态', '模型', '花费', '费率', '体检', '快照', '接续', '自检'].every(label => labels.includes(label))
|
|
517
|
+
&& !labels.includes('面板')
|
|
518
|
+
&& lines.includes('/flow-status')
|
|
519
|
+
&& lines.includes('/flow-cost')
|
|
520
|
+
&& lines.includes('/flow-diag'),
|
|
521
|
+
detail: `${buttons.length} 个:${labels.join('/')}`,
|
|
522
|
+
}
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
checkAsync('点命令按钮会真的把命令发出去', async () => {
|
|
526
|
+
const sent = []
|
|
527
|
+
resetSeeds([OPEN, true, false, ''])
|
|
528
|
+
const element = registeredComponent({
|
|
529
|
+
sessionId: 'session-test',
|
|
530
|
+
files: filesStub,
|
|
531
|
+
runCommand: async line => {
|
|
532
|
+
sent.push(line)
|
|
533
|
+
return { ok: true, text: '好了' }
|
|
534
|
+
},
|
|
535
|
+
}, {})
|
|
536
|
+
const buttons = collect(element, node => node.props?.className === 'pfcmd')
|
|
537
|
+
const status = buttons.find(node => textOf(node) === '状态')
|
|
538
|
+
status.props.onClick()
|
|
539
|
+
return { ok: sent[0] === '/flow-status', detail: JSON.stringify(sent) }
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
check('收起再打开,下方提示条必须是空的(不能残留上次那句)', () => {
|
|
543
|
+
// 用户报的:工作模式未启用时点一下,下方自己冒出一段字。
|
|
544
|
+
// 根因是清提示只挂在切换按钮那一条路上——点 ×、按 Esc、点外面都不清,
|
|
545
|
+
// 旧提示就留到下次打开。现在 open 一变就清,这里钉住它。
|
|
546
|
+
const clearsOnToggle = /useEffect\(\(\) => \{\s*setNotice\(''\)\s*\}, \[open\]\)/u.test(source)
|
|
547
|
+
const clearsInToggleHandler = /if \(open === true\) setNotice\(''\)/u.test(source)
|
|
548
|
+
return {
|
|
549
|
+
ok: clearsOnToggle && clearsInToggleHandler === false,
|
|
550
|
+
detail: `打开收起都清=${clearsOnToggle} 还挂在旧路径上=${clearsInToggleHandler}`,
|
|
551
|
+
}
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
check('未启用状态下根本不渲染提示条(硬保证)', () => {
|
|
555
|
+
// 光靠「收起时清空」还不够:只要别处留下过一个非空字符串,
|
|
556
|
+
// 未启用状态还是会把它显示出来。所以渲染那一步也要挡一道。
|
|
557
|
+
const gate = /notice === '' \|\| blind \|\| \(panel\.inside === false && panel\.projects\.length === 0\)/u.test(source)
|
|
558
|
+
return {
|
|
559
|
+
ok: gate,
|
|
560
|
+
detail: `渲染处有状态门控=${gate}`,
|
|
561
|
+
}
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
check('未启用状态下没有会写提示的调用', () => {
|
|
565
|
+
// 那个分支里没有任何按钮能触发 act(),所以只要不在打开时残留,
|
|
566
|
+
// 未启用状态下就永远不该出现提示条。
|
|
567
|
+
const marker = 'panel.inside === false && panel.projects.length === 0'
|
|
568
|
+
const from = source.indexOf(marker)
|
|
569
|
+
const branch = from === -1 ? '' : source.slice(from, from + 1200)
|
|
570
|
+
return {
|
|
571
|
+
ok: branch !== '' && branch.includes('setNotice') === false,
|
|
572
|
+
detail: `分支长度=${branch.length} 含 setNotice=${branch.includes('setNotice')}`,
|
|
573
|
+
}
|
|
574
|
+
})
|
|
575
|
+
check('下拉里的模型来自本机检测,不是写死的', () => {
|
|
576
|
+
const element = render(OPEN, true, filesStub, CATALOG)
|
|
577
|
+
const selects = collect(element, node => node.type === 'select')
|
|
578
|
+
const options = collect(selects[0], node => node.type === 'option').map(node => node.props.value)
|
|
579
|
+
return {
|
|
580
|
+
ok: options.includes('spawn/hy4flash') && options.includes('deepseek/deepseek-v4.1-flash'),
|
|
581
|
+
detail: JSON.stringify(options),
|
|
582
|
+
}
|
|
583
|
+
})
|
|
584
|
+
check('本机一个模型都没有时如实说「没检测到」,不编几个出来', () => {
|
|
585
|
+
const element = render(OPEN, true, filesStub, [])
|
|
586
|
+
const selects = collect(element, node => node.type === 'select')
|
|
587
|
+
const labels = collect(selects[0], node => node.type === 'option').map(node => textOf(node))
|
|
588
|
+
return {
|
|
589
|
+
ok: labels.includes('没检测到可用模型'),
|
|
590
|
+
detail: JSON.stringify(labels),
|
|
591
|
+
}
|
|
592
|
+
})
|
|
593
|
+
check('源码里没有写死的模型名', () => {
|
|
594
|
+
const hardcoded = ['hy4flash', 'kimi-k3.1-pro', 'deepseek-v4.1-flash']
|
|
595
|
+
.filter(name => source.includes(`'${name}'`))
|
|
596
|
+
return { ok: hardcoded.length === 0, detail: hardcoded.join(', ') }
|
|
597
|
+
})
|
|
598
|
+
check('模型清单从宿主那条路由取', () => ({
|
|
599
|
+
ok: source.includes('plugins/dsh-project-flow/models'),
|
|
600
|
+
detail: source.includes('plugins/dsh-project-flow/models') ? '' : '没有请求模型清单的路由',
|
|
601
|
+
}))
|
|
602
|
+
check('命令表里不重复放已经做成按钮的', () => {
|
|
603
|
+
// 停止和继续在底部已经有按钮,模型在三个下拉里。
|
|
604
|
+
// 再列一遍只是让浮层更挤,没有别的用处。
|
|
605
|
+
const duplicate = ['/flow-stop', '/flow-continue', '/flow-set']
|
|
606
|
+
.filter(line => source.includes(`line: '${line}'`))
|
|
607
|
+
return { ok: duplicate.length === 0, detail: duplicate.join(', ') }
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
check('命令结果不再贴进浮层,只留一句短确认', () => {
|
|
611
|
+
// 用户的反馈是:点状态栏下方会冒出一段看不懂的字,应该只在日志里出现。
|
|
612
|
+
// 所以成功时只给一句固定确认,正文(状态表、花费表、体检清单)留在会话日志。
|
|
613
|
+
const keepsAllLines = source.includes('setNotice(result.text.slice(0, 1200))')
|
|
614
|
+
const shortConfirm = source.includes("setNotice('已执行 · 结果见会话日志')")
|
|
615
|
+
const errorOnlyFirstLine = source.includes('reason.split')
|
|
616
|
+
return {
|
|
617
|
+
ok: keepsAllLines === false && shortConfirm && errorOnlyFirstLine,
|
|
618
|
+
detail: `还在贴正文=${keepsAllLines} 短确认=${shortConfirm} 错误截首行=${errorOnlyFirstLine}`,
|
|
619
|
+
}
|
|
620
|
+
})
|
|
621
|
+
|
|
622
|
+
// ── 四列面板(T5)──────────────────────────────────────
|
|
623
|
+
//
|
|
624
|
+
// 这一段验的是「新加的东西真的画出来了」,不是样式好不好看。
|
|
625
|
+
// 面板上面的数据来自 /panel 的 report 字段,喂进去不能崩、该出现的字得出现。
|
|
626
|
+
|
|
627
|
+
const openWith = (panel) => render(panel, true)
|
|
628
|
+
const PANEL_BASE = { version: '0.8.3', inside: true, routes: undefined }
|
|
629
|
+
|
|
630
|
+
check('展开态画出四列表格', () => {
|
|
631
|
+
const pop = popOf(openWith({ ...PANEL_BASE, projects: [project()] }))
|
|
632
|
+
const grid = collect(pop, node => node.props?.className === 'pfgrid')
|
|
633
|
+
return { ok: grid.length === 1, detail: `找到 ${grid.length} 个 pfgrid` }
|
|
634
|
+
})
|
|
635
|
+
|
|
636
|
+
check('四列的表头是「阶段 / 状态 / 门禁 / 问题」', () => {
|
|
637
|
+
const text = textOf(popOf(openWith({ ...PANEL_BASE, projects: [project()] })))
|
|
638
|
+
const ok = text.includes('阶段') && text.includes('状态') && text.includes('门禁')
|
|
639
|
+
return { ok, detail: text.slice(0, 200) }
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
check('顶部一条带版本号', () => {
|
|
643
|
+
const text = textOf(popOf(openWith({ ...PANEL_BASE, projects: [project()] })))
|
|
644
|
+
return { ok: text.includes('v0.8.3'), detail: text.slice(0, 200) }
|
|
645
|
+
})
|
|
646
|
+
|
|
647
|
+
check('项目带 report 时,两个折叠块都在', () => {
|
|
648
|
+
const withReport = project({
|
|
649
|
+
report: {
|
|
650
|
+
issues: [{ id: 'Q-001', severity: 'P0', claim: '没实现', detect: 'npm test' }],
|
|
651
|
+
assertions: { total: 2, pass: 1, fail: 1, unverified: 0 },
|
|
652
|
+
failed: [{ req: 2, cmd: 'npm test', exit: 1, status: 'fail' }],
|
|
653
|
+
},
|
|
654
|
+
})
|
|
655
|
+
const text = textOf(popOf(openWith({ ...PANEL_BASE, projects: [withReport] })))
|
|
656
|
+
return {
|
|
657
|
+
ok: text.includes('本轮没闭环 1 条') && text.includes('没过的命令 1 条'),
|
|
658
|
+
detail: text.slice(0, 320),
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
|
|
662
|
+
check('没有 report 字段也不崩——老项目的返回里没有这一项', () => {
|
|
663
|
+
const text = textOf(popOf(openWith({ ...PANEL_BASE, projects: [project()] })))
|
|
664
|
+
const ok = typeof text === 'string' && text.length > 0 && !text.includes('本轮没闭环')
|
|
665
|
+
return { ok, detail: text.slice(0, 160) }
|
|
666
|
+
})
|
|
667
|
+
|
|
668
|
+
check('report 里没有问题时不画折叠块,不占地方', () => {
|
|
669
|
+
const empty = project({ report: { issues: [], assertions: { total: 0, pass: 0, fail: 0, unverified: 0 }, failed: [] } })
|
|
670
|
+
const text = textOf(popOf(openWith({ ...PANEL_BASE, projects: [empty] })))
|
|
671
|
+
return { ok: !text.includes('本轮没闭环') && !text.includes('没过的命令'), detail: text.slice(0, 200) }
|
|
672
|
+
})
|
|
673
|
+
|
|
674
|
+
check('耗时算得出来才显示,算不出来就不写假数字', () => {
|
|
675
|
+
// 只取汇总那一行的文本。取整个浮层的话会连 <style> 里的 CSS 一起拿到,
|
|
676
|
+
// 断言就成了在 CSS 里找「5 分」,测的不是这件事。
|
|
677
|
+
const sumOf = element => collect(element, node => node.props?.className === 'pfsum')[0]
|
|
678
|
+
const long = project({ startedAt: '2026-11-30T09:55:00.000Z', updatedAt: '2026-11-30T10:00:00.000Z' })
|
|
679
|
+
const withTime = textOf(sumOf(openWith({ ...PANEL_BASE, projects: [long] })))
|
|
680
|
+
const withoutStart = textOf(sumOf(openWith({ ...PANEL_BASE, projects: [project({ startedAt: null })] })))
|
|
681
|
+
return {
|
|
682
|
+
ok: withTime.includes('5 分') && !withoutStart.includes('分'),
|
|
683
|
+
detail: `有耗时="${withTime}"|无耗时="${withoutStart}"`,
|
|
684
|
+
}
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
for (const item of pendingChecks) {
|
|
688
|
+
let ok = false
|
|
689
|
+
let detail = ''
|
|
690
|
+
try {
|
|
691
|
+
const out = await item.fn()
|
|
692
|
+
ok = out === true || (out && out.ok === true)
|
|
693
|
+
detail = out && out.detail ? String(out.detail) : ''
|
|
694
|
+
} catch (error) {
|
|
695
|
+
ok = false
|
|
696
|
+
detail = error.message
|
|
697
|
+
}
|
|
698
|
+
results.push({ label: item.label, ok, detail })
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
let failed = 0
|
|
702
|
+
for (const r of results) {
|
|
703
|
+
console.log(`${r.ok ? '✔' : '✖'} ${r.label}${r.ok || r.detail === '' ? '' : `\n → ${r.detail}`}`)
|
|
704
|
+
if (!r.ok) failed += 1
|
|
705
|
+
}
|
|
706
|
+
console.log(`\n${results.length - failed}/${results.length} 通过`)
|
|
707
|
+
process.exit(failed === 0 ? 0 : 1)
|