dsh-dev-plan-presets 0.0.0-stage → 0.4.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.
- package/LICENSE +21 -0
- package/README.md +348 -2
- package/client.js +1634 -0
- package/cordis.patch.yml +24 -0
- package/detail.md +200 -0
- package/docs/flow-redesign.md +403 -0
- package/docs/v0.4-perf-optimization-plan.md +349 -0
- package/guard.js +547 -0
- package/icon.svg +12 -0
- package/index.js +791 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +53 -4
- package/preset.js +471 -0
- package/scripts/test-harness.mjs +290 -0
- package/scripts/verify-presets.mjs +1854 -0
- package/settings.js +208 -0
- package/test/plugin.test.mjs +1912 -0
|
@@ -0,0 +1,1854 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* verify-presets.mjs — 0.3.0 合同自检(不启动 DSH、不安装、不改 profile)
|
|
4
|
+
*
|
|
5
|
+
* 覆盖五层:
|
|
6
|
+
* 1. 打包层:package.json / exports / files / bundle patch / client manifest;
|
|
7
|
+
* 2. 声明层:动态 preset 的四个委派工具、任意可用预设与回退、主窗工具面、persona 合同;
|
|
8
|
+
* 3. 代码层:node --check + 真实模块 import + 假 ctx 驱动动态注册/守门/设置路由;
|
|
9
|
+
* 4. 文档层:README / detail / locale 必须写清回退、迁移、模型守门与未验证项;
|
|
10
|
+
* 5. 变异层:故意改坏关键点,断言上文检查确实会 FAIL(不是只写 smoke)。
|
|
11
|
+
*
|
|
12
|
+
* 它不能证明运行期宿主行为(preset 是否出现在选择器、子会话是否真的使用目标模型、
|
|
13
|
+
* 设置页在真实 GUI 中是否渲染)。那部分见 README「验证」的手工清单。
|
|
14
|
+
*
|
|
15
|
+
* 用法:
|
|
16
|
+
* node scripts/verify-presets.mjs
|
|
17
|
+
* node scripts/verify-presets.mjs --verbose
|
|
18
|
+
*
|
|
19
|
+
* 本脚本不依赖 js-yaml / @deepseek-ai/*,也不启动任何服务器。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { readFileSync, existsSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
|
|
23
|
+
import { dirname, join, resolve } from 'node:path'
|
|
24
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
25
|
+
import { spawnSync } from 'node:child_process'
|
|
26
|
+
import { loadModules, createFakeContext, createFakeRegistry, createFakeWebServer, createFakeConfigEditor, createFakeAgent, callRoute } from './test-harness.mjs'
|
|
27
|
+
|
|
28
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
29
|
+
const VERBOSE = process.argv.includes('--verbose')
|
|
30
|
+
const RUNTIME_FILES = ['index.js', 'preset.js', 'settings.js', 'guard.js', 'client.js']
|
|
31
|
+
const REQUIRED_FILES = [
|
|
32
|
+
'package.json',
|
|
33
|
+
'index.js',
|
|
34
|
+
'preset.js',
|
|
35
|
+
'settings.js',
|
|
36
|
+
'guard.js',
|
|
37
|
+
'client.js',
|
|
38
|
+
'cordis.patch.yml',
|
|
39
|
+
'locale/zh.json',
|
|
40
|
+
'locale/en.json',
|
|
41
|
+
'icon.svg',
|
|
42
|
+
'README.md',
|
|
43
|
+
'detail.md',
|
|
44
|
+
'docs/flow-redesign.md',
|
|
45
|
+
'LICENSE',
|
|
46
|
+
'scripts/verify-presets.mjs',
|
|
47
|
+
'test/plugin.test.mjs',
|
|
48
|
+
]
|
|
49
|
+
const SOCIAL_FILES = ['README.md', 'detail.md', 'LICENSE']
|
|
50
|
+
|
|
51
|
+
const readText = (rel) => {
|
|
52
|
+
try {
|
|
53
|
+
return readFileSync(join(ROOT, rel), 'utf8')
|
|
54
|
+
} catch {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const readJson = (rel) => {
|
|
60
|
+
const text = readText(rel)
|
|
61
|
+
if (text === null) return { value: null, error: `${rel} 不存在` }
|
|
62
|
+
try {
|
|
63
|
+
return { value: JSON.parse(text), error: null }
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return { value: null, error: `${rel} 不是合法 JSON:${error instanceof Error ? error.message : String(error)}` }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const flattenPlugins = (plugins, out = []) => {
|
|
70
|
+
for (const row of plugins ?? []) {
|
|
71
|
+
out.push(row)
|
|
72
|
+
if (Array.isArray(row?.config)) flattenPlugins(row.config, out)
|
|
73
|
+
}
|
|
74
|
+
return out
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const findPresetPlugin = (definition, id) => (definition?.plugins ?? []).find((row) => row?.id === id)
|
|
78
|
+
const findTool = (definition, toolName) =>
|
|
79
|
+
flattenPlugins(definition?.plugins).find(
|
|
80
|
+
(row) => row?.name === '@deepseek-ai/dsh-tool-subagent' && row?.config?.toolName === toolName,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const globCovers = (pattern, rel) => {
|
|
84
|
+
if (!pattern.includes('*')) {
|
|
85
|
+
const directory = pattern.replace(/\/+$/, '')
|
|
86
|
+
return pattern === rel || rel.startsWith(`${directory}/`)
|
|
87
|
+
}
|
|
88
|
+
const [prefix, suffix] = pattern.split('*')
|
|
89
|
+
return rel.startsWith(prefix) && rel.endsWith(suffix)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const fileCovered = (patterns, rel) => (patterns ?? []).some((pattern) => globCovers(String(pattern), rel))
|
|
93
|
+
|
|
94
|
+
/** 读取待检查面(真实文件 + 真实模块构建出的两个 definition)。 */
|
|
95
|
+
export async function loadSurface() {
|
|
96
|
+
const pkgRead = readJson('package.json')
|
|
97
|
+
const localeZh = readJson('locale/zh.json')
|
|
98
|
+
const localeEn = readJson('locale/en.json')
|
|
99
|
+
const files = {}
|
|
100
|
+
for (const rel of [...new Set([...REQUIRED_FILES, ...SOCIAL_FILES, ...RUNTIME_FILES])]) {
|
|
101
|
+
files[rel] = readText(rel)
|
|
102
|
+
}
|
|
103
|
+
const modules = await loadModules(ROOT)
|
|
104
|
+
const base = { ...modules.settings.DEFAULT_SETTINGS }
|
|
105
|
+
const standardMode = modules.preset.resolveDevelopMode({ requestedMode: 'standard' })
|
|
106
|
+
const fallbackMode = modules.preset.resolveDevelopMode({
|
|
107
|
+
requestedMode: 'deep-ptc',
|
|
108
|
+
presets: [],
|
|
109
|
+
catalogChecked: true,
|
|
110
|
+
})
|
|
111
|
+
const deepPtcMode = modules.preset.resolveDevelopMode({
|
|
112
|
+
requestedMode: 'deep-ptc',
|
|
113
|
+
presets: [{ id: 'deep-ptc', name: '深度 PTC' }],
|
|
114
|
+
catalogChecked: true,
|
|
115
|
+
})
|
|
116
|
+
const customMode = modules.preset.resolveDevelopMode({
|
|
117
|
+
requestedMode: 'team-builder',
|
|
118
|
+
presets: [{ id: 'team-builder', name: '团队施工' }],
|
|
119
|
+
catalogChecked: true,
|
|
120
|
+
})
|
|
121
|
+
const selfMode = modules.preset.resolveDevelopMode({
|
|
122
|
+
requestedMode: 'dev-plan',
|
|
123
|
+
presets: [{ id: 'dev-plan', name: '开发规划与交付' }],
|
|
124
|
+
catalogChecked: true,
|
|
125
|
+
})
|
|
126
|
+
const scoutSelfMode = modules.preset.resolveDevelopMode({
|
|
127
|
+
requestedMode: 'dev-plan-scout',
|
|
128
|
+
presets: [{ id: 'dev-plan-scout' }],
|
|
129
|
+
catalogChecked: true,
|
|
130
|
+
})
|
|
131
|
+
const scribeSelfMode = modules.preset.resolveDevelopMode({
|
|
132
|
+
requestedMode: 'dev-plan-scribe',
|
|
133
|
+
presets: [{ id: 'dev-plan-scribe' }],
|
|
134
|
+
catalogChecked: true,
|
|
135
|
+
})
|
|
136
|
+
const internalActive = { scout: false, scribe: false }
|
|
137
|
+
const standard = modules.preset.buildPresetDefinition({
|
|
138
|
+
settings: base,
|
|
139
|
+
mode: standardMode,
|
|
140
|
+
internalPresets: internalActive,
|
|
141
|
+
})
|
|
142
|
+
const standardFallbackSub = modules.preset.buildPresetDefinition({
|
|
143
|
+
settings: base,
|
|
144
|
+
mode: standardMode,
|
|
145
|
+
internalPresets: { scout: false, scribe: false },
|
|
146
|
+
})
|
|
147
|
+
const noneMode = modules.preset.buildPresetDefinition({
|
|
148
|
+
settings: { ...base, mainToolMode: 'none' },
|
|
149
|
+
mode: standardMode,
|
|
150
|
+
internalPresets: internalActive,
|
|
151
|
+
})
|
|
152
|
+
const readonlyMode = modules.preset.buildPresetDefinition({
|
|
153
|
+
settings: { ...base, mainToolMode: 'readonly' },
|
|
154
|
+
mode: standardMode,
|
|
155
|
+
internalPresets: internalActive,
|
|
156
|
+
})
|
|
157
|
+
const askEditMode = modules.preset.buildPresetDefinition({
|
|
158
|
+
settings: { ...base, mainToolMode: 'ask-edit' },
|
|
159
|
+
mode: standardMode,
|
|
160
|
+
internalPresets: internalActive,
|
|
161
|
+
})
|
|
162
|
+
const fallback = modules.preset.buildPresetDefinition({
|
|
163
|
+
settings: base,
|
|
164
|
+
mode: fallbackMode,
|
|
165
|
+
internalPresets: internalActive,
|
|
166
|
+
})
|
|
167
|
+
const deepPtc = modules.preset.buildPresetDefinition({
|
|
168
|
+
settings: base,
|
|
169
|
+
mode: deepPtcMode,
|
|
170
|
+
internalPresets: internalActive,
|
|
171
|
+
})
|
|
172
|
+
const custom = modules.preset.buildPresetDefinition({
|
|
173
|
+
settings: base,
|
|
174
|
+
mode: customMode,
|
|
175
|
+
internalPresets: internalActive,
|
|
176
|
+
})
|
|
177
|
+
const withEffort = modules.preset.buildPresetDefinition({
|
|
178
|
+
settings: { ...base, childReasoningEffort: 'high' },
|
|
179
|
+
mode: standardMode,
|
|
180
|
+
internalPresets: internalActive,
|
|
181
|
+
})
|
|
182
|
+
const scoutPreset = modules.preset.buildScoutPresetDefinition()
|
|
183
|
+
const scribePreset = modules.preset.buildScribePresetDefinition()
|
|
184
|
+
return {
|
|
185
|
+
root: ROOT,
|
|
186
|
+
pkg: pkgRead.value,
|
|
187
|
+
pkgError: pkgRead.error,
|
|
188
|
+
pkgText: readText('package.json'),
|
|
189
|
+
patchText: readText('cordis.patch.yml'),
|
|
190
|
+
locale: { zh: localeZh.value, en: localeEn.value },
|
|
191
|
+
localeErrors: { zh: localeZh.error, en: localeEn.error },
|
|
192
|
+
readme: readText('README.md'),
|
|
193
|
+
detail: readText('detail.md'),
|
|
194
|
+
files,
|
|
195
|
+
modules,
|
|
196
|
+
standard,
|
|
197
|
+
standardFallbackSub,
|
|
198
|
+
noneMode,
|
|
199
|
+
readonlyMode,
|
|
200
|
+
askEditMode,
|
|
201
|
+
scoutPreset,
|
|
202
|
+
scribePreset,
|
|
203
|
+
fallback,
|
|
204
|
+
deepPtc,
|
|
205
|
+
custom,
|
|
206
|
+
selfFallback: selfMode,
|
|
207
|
+
scoutSelfFallback: scoutSelfMode,
|
|
208
|
+
scribeSelfFallback: scribeSelfMode,
|
|
209
|
+
withEffort,
|
|
210
|
+
constants: {
|
|
211
|
+
presetId: modules.preset.PRESET_ID,
|
|
212
|
+
scoutPresetId: modules.preset.SCOUT_PRESET_ID,
|
|
213
|
+
scribePresetId: modules.preset.SCRIBE_PRESET_ID,
|
|
214
|
+
presetName: modules.preset.PRESET_NAME,
|
|
215
|
+
order: modules.preset.PRESET_ORDER,
|
|
216
|
+
deepPtcId: modules.preset.DEEP_PTC_PRESET_ID,
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 纯检查:给定 surface,返回 { ok, label, detail } 列表。 */
|
|
222
|
+
export function checksFor(surface) {
|
|
223
|
+
const results = []
|
|
224
|
+
const check = (ok, label, detail = '') => results.push({ ok: Boolean(ok), label, detail: String(detail) })
|
|
225
|
+
const {
|
|
226
|
+
pkg,
|
|
227
|
+
pkgError,
|
|
228
|
+
files,
|
|
229
|
+
standard,
|
|
230
|
+
standardFallbackSub,
|
|
231
|
+
noneMode,
|
|
232
|
+
readonlyMode,
|
|
233
|
+
askEditMode,
|
|
234
|
+
scoutPreset,
|
|
235
|
+
scribePreset,
|
|
236
|
+
fallback,
|
|
237
|
+
deepPtc,
|
|
238
|
+
custom,
|
|
239
|
+
withEffort,
|
|
240
|
+
readme,
|
|
241
|
+
detail,
|
|
242
|
+
locale,
|
|
243
|
+
} = surface
|
|
244
|
+
|
|
245
|
+
// ── 打包层 ────────────────────────────────────────────────────────────────
|
|
246
|
+
check(pkgError === null, 'package.json 是合法 JSON', pkgError ?? '')
|
|
247
|
+
check(pkg?.name === 'dsh-dev-plan-presets', 'package.json name', pkg?.name)
|
|
248
|
+
check(pkg?.version === '0.4.0', 'package.json version=0.4.0', pkg?.version)
|
|
249
|
+
check(pkg?.type === 'module', 'package.json type=module')
|
|
250
|
+
check(pkg?.private === false, 'package.json private=false(可开源发布)', String(pkg?.private))
|
|
251
|
+
check(pkg?.license === 'MIT', 'package.json license=MIT', pkg?.license)
|
|
252
|
+
check(pkg?.engines?.dsh === '>=0.2.2-rc.3', 'package.json engines.dsh 为已验证基线 >=0.2.2-rc.3', String(pkg?.engines?.dsh))
|
|
253
|
+
|
|
254
|
+
const patch = pkg?.dsh?.bundle?.patch
|
|
255
|
+
const patchList = Array.isArray(patch) ? patch : patch === undefined ? [] : [patch]
|
|
256
|
+
check(patchList.length === 1, 'dsh.bundle.patch 只有 1 个补丁', JSON.stringify(patch))
|
|
257
|
+
check(patchList[0] === './cordis.patch.yml', 'dsh.bundle.patch 指向 cordis.patch.yml', String(patchList[0]))
|
|
258
|
+
check(pkg?.dsh?.client?.platform === 'web', 'dsh.client.platform=web')
|
|
259
|
+
check(pkg?.dsh?.client?.immediately === true, 'dsh.client.immediately=true')
|
|
260
|
+
|
|
261
|
+
const exportsMap = pkg?.exports ?? {}
|
|
262
|
+
for (const required of ['.', './client', './preset', './settings', './package.json', './cordis.patch.yml', './locale/*.json', './icon']) {
|
|
263
|
+
check(Object.hasOwn(exportsMap, required), `exports 暴露 ${required}`)
|
|
264
|
+
}
|
|
265
|
+
for (const [key, target] of Object.entries(exportsMap)) {
|
|
266
|
+
if (typeof target !== 'string') {
|
|
267
|
+
check(false, `exports ${key} 是字符串`, typeof target)
|
|
268
|
+
continue
|
|
269
|
+
}
|
|
270
|
+
const clean = target.replace(/^\.\//, '')
|
|
271
|
+
const candidates = clean.includes('*')
|
|
272
|
+
? Object.keys(files).filter((rel) => globCovers(clean, rel))
|
|
273
|
+
: [clean]
|
|
274
|
+
check(
|
|
275
|
+
candidates.length > 0 && candidates.every((rel) => files[rel] !== null && files[rel] !== undefined),
|
|
276
|
+
`exports ${key} 指向真实文件`,
|
|
277
|
+
candidates.join(', ') || '无匹配',
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
check(exportsMap['.'] === './index.js', 'exports . 指向 index.js', exportsMap['.'])
|
|
281
|
+
check(exportsMap['./client'] === './client.js', 'exports ./client 指向 client.js', exportsMap['./client'])
|
|
282
|
+
|
|
283
|
+
const runtimeFiles = [...RUNTIME_FILES, 'cordis.patch.yml', 'locale/zh.json', 'locale/en.json', 'icon.svg', 'README.md', 'detail.md', 'docs/flow-redesign.md', 'LICENSE']
|
|
284
|
+
for (const rel of runtimeFiles) check(fileCovered(pkg?.files, rel), `files 覆盖 ${rel}`, rel)
|
|
285
|
+
for (const rel of REQUIRED_FILES) check(files[rel] !== null, `文件存在:${rel}`)
|
|
286
|
+
|
|
287
|
+
check(!existsSync(join(ROOT, 'presets/dev-plan.patch.yml')), '旧的静态 preset 补丁已删除')
|
|
288
|
+
check(!/\bjs-yaml\b|\byaml\b/.test(String(pkg?.dependencies ?? {})) && !/\bjs-yaml\b/.test(String(pkg?.devDependencies ?? {})), '不依赖 js-yaml')
|
|
289
|
+
check(!Object.keys(pkg?.dependencies ?? {}).some((name) => /deep-ptc|deep_ptc/.test(name)), '不依赖 deep-ptc 包')
|
|
290
|
+
check(!Object.keys(pkg?.dependencies ?? {}).length, '运行期零 dependencies', Object.keys(pkg?.dependencies ?? {}).join(', '))
|
|
291
|
+
check(!/\b@deepseek-ai\//.test(String((pkg?.peerDependencies ?? {}))) && !/\b@deepseek-ai\//.test(String((pkg?.dependencies ?? {}))), '不声明 @deepseek-ai/* 依赖')
|
|
292
|
+
|
|
293
|
+
// ── 根补丁:只挂根插件 ────────────────────────────────────────────────────
|
|
294
|
+
const patchText = String(surface.patchText ?? '')
|
|
295
|
+
// 只看非注释行:说明文字里出现 @deepseek-ai/dsh-agent-preset 是允许的。
|
|
296
|
+
const patchActiveText = patchText
|
|
297
|
+
.split(/\r?\n/)
|
|
298
|
+
.filter((line) => !/^\s*#/.test(line))
|
|
299
|
+
.join('\n')
|
|
300
|
+
check(/id:\s*dev-plan-presets/.test(patchActiveText), '根补丁挂 dev-plan-presets 行')
|
|
301
|
+
check(/name:\s*dsh-dev-plan-presets/.test(patchActiveText), '根补丁 name=dsh-dev-plan-presets')
|
|
302
|
+
check(!/@deepseek-ai\/dsh-agent-preset/.test(patchActiveText), '根补丁不再静态注册 dsh-agent-preset')
|
|
303
|
+
check(!/preset-dev-plan|preset-scout|preset-scribe/.test(patchActiveText), '根补丁没有旧 preset-* 行')
|
|
304
|
+
check(!/scout|scribe/i.test(patchActiveText), '根补丁不引用 scout/scribe')
|
|
305
|
+
check(/developMode:\s*standard/.test(patchText), '根补丁默认 developMode=standard')
|
|
306
|
+
check(/modelGuardMode:\s*pin/.test(patchText), '根补丁默认 modelGuardMode=pin')
|
|
307
|
+
check(/guardAllSubagents:\s*false/.test(patchText), '根补丁默认 guardAllSubagents=false')
|
|
308
|
+
check(/mainToolMode:\s*ask-edit/.test(patchText), '根补丁默认 mainToolMode=ask-edit')
|
|
309
|
+
check(/mainStepWarnThreshold:\s*6/.test(patchText), '根补丁默认 mainStepWarnThreshold=6')
|
|
310
|
+
check(/childProvider:\s*dsh-opencode-go/.test(patchText), '根补丁默认 provider=dsh-opencode-go')
|
|
311
|
+
check(/childModel:\s*deepseek-v4\.1-flash/.test(patchText), '根补丁默认 model=deepseek-v4.1-flash')
|
|
312
|
+
|
|
313
|
+
// ── 代码层:只允许宿主解析、不得手改 profile ───────────────────────────────
|
|
314
|
+
const indexSource = String(files['index.js'] ?? '')
|
|
315
|
+
const presetSource = String(files['preset.js'] ?? '')
|
|
316
|
+
const settingsSource = String(files['settings.js'] ?? '')
|
|
317
|
+
const guardSource = String(files['guard.js'] ?? '')
|
|
318
|
+
const clientSource = String(files['client.js'] ?? '')
|
|
319
|
+
for (const [name, source] of [
|
|
320
|
+
['index.js', indexSource],
|
|
321
|
+
['preset.js', presetSource],
|
|
322
|
+
['settings.js', settingsSource],
|
|
323
|
+
['guard.js', guardSource],
|
|
324
|
+
]) {
|
|
325
|
+
check(!/from\s+['"]@deepseek-ai\//.test(source), `${name} 不 import @deepseek-ai/*(link 安装可解析)`)
|
|
326
|
+
check(!/from\s+['"](?:js-yaml|yaml)['"]/.test(source), `${name} 不 import yaml 解析器`)
|
|
327
|
+
}
|
|
328
|
+
check(/ctx\.inject\(\['agentPresets'\]/.test(indexSource), 'index.js 通过 ctx.inject 等待 agentPresets')
|
|
329
|
+
check(/registry\.register\(definition\)/.test(indexSource), 'index.js 真的调用 agentPresets.register')
|
|
330
|
+
check(/releaseAll/.test(indexSource) && /child\.effect/.test(indexSource), '动态 preset disposer 交还给 ctx.effect')
|
|
331
|
+
check(/stateVersion/.test(indexSource) && /bumpState/.test(indexSource) && /etag/i.test(indexSource) && /304/.test(indexSource), 'index.js 支持 stateVersion + ETag 304')
|
|
332
|
+
check(/state\.mode\?\.fallback === true \|\| state\.presets\.checked !== true/.test(indexSource), 'index.js scheduleVerification 跳过已命中目标时的冗余二次全量探测')
|
|
333
|
+
check(/prewarmModelCatalog/.test(indexSource) && /installMainStepBudget/.test(indexSource), 'index.js 包含模型目录空闲预热与主窗步数软提醒')
|
|
334
|
+
check(/agent\/created/.test(guardSource), '模型守门监听 agent/created')
|
|
335
|
+
check(/agent\/pre-step/.test(guardSource), '模型守门监听 agent/pre-step')
|
|
336
|
+
check(/kind:\s*'reject'/.test(guardSource), '模型守门越界返回 reject')
|
|
337
|
+
check(/cancel\(\{\s*kind:\s*'user'/.test(guardSource), '模型守门越界 cancel 子代理')
|
|
338
|
+
check(/parent\?\.inject|parent\.inject/.test(guardSource), '模型守门通知父会话')
|
|
339
|
+
check(/parentSession/.test(guardSource) && /origin === 'subagent'/.test(guardSource), '模型守门只认子代理 header')
|
|
340
|
+
check(/agent\/disposed/.test(guardSource), '模型守门监听 agent/disposed 清理 step guard')
|
|
341
|
+
check(/installMainStepBudget/.test(guardSource) && /mainToolMode/.test(guardSource), 'guard.js 提供主窗步数预算软提醒(永不 select/cancel)')
|
|
342
|
+
check(/onDispose/.test(guardSource) && /if \(stopped\) return \{ kind: 'reject' \}/.test(guardSource), 'guard.js 支持 effect 同步清理 steps 与 stopped 前置短路')
|
|
343
|
+
check(
|
|
344
|
+
/guardAllSubagents !== true/.test(guardSource) && /presetForSession/.test(guardSource),
|
|
345
|
+
'guard 默认按父会话 dev-plan 限制,并优先用 presetForSession',
|
|
346
|
+
)
|
|
347
|
+
check(
|
|
348
|
+
/header\.origin === 'subagent'/.test(guardSource) &&
|
|
349
|
+
/delegationDepth/.test(guardSource) &&
|
|
350
|
+
!/if \(header\.parentSession\) return true/.test(guardSource),
|
|
351
|
+
'guard 只认 origin=subagent 或 delegationDepth>0,不把 fork 主对话当子代理',
|
|
352
|
+
)
|
|
353
|
+
check(
|
|
354
|
+
/MODEL_CATALOG_TTL_MS = 60_000/.test(indexSource) &&
|
|
355
|
+
/modelCatalogSnapshot/.test(indexSource) &&
|
|
356
|
+
!/await loadModelCatalog/.test(indexSource),
|
|
357
|
+
'模型目录使用 60s 快照 + 后台刷新,不阻塞 /state',
|
|
358
|
+
)
|
|
359
|
+
check(/const steps = new Map\(\)/.test(guardSource), '模型守门按 agent 跟踪 step guard disposer')
|
|
360
|
+
check(/for \(const dispose of pending\)/.test(guardSource), '模型守门总 disposer 卸载所有已装 step guard')
|
|
361
|
+
check(/configEditor/.test(indexSource) && /editor\.edit/.test(indexSource), '设置保存走 configEditor.edit')
|
|
362
|
+
check(!/cordis\.patch\.yml/.test(indexSource), 'Host 代码不手改 profile 的 cordis.patch.yml')
|
|
363
|
+
check(/originProblem/.test(indexSource) && /sec-fetch-site/.test(indexSource), 'Host 配置写路由做 Origin/Sec-Fetch-Site 校验')
|
|
364
|
+
check(/webServer\.getOrigin\(\)/.test(indexSource), 'Host 配置写路由使用 webServer.getOrigin() 权威 origin')
|
|
365
|
+
check(/origin-not-authoritative/.test(indexSource), 'Host 配置写路由拒绝非监听 Origin')
|
|
366
|
+
check(/LOOPBACK_HOSTS/.test(indexSource), 'Host 配置写路由仅对 loopback 别名做有限等价')
|
|
367
|
+
check(!/restartRequired/.test(indexSource), 'Host 保存成功不再误报 restartRequired')
|
|
368
|
+
check(/mediaTypeOf\(req\) !== 'application\/json'/.test(indexSource), 'Host 配置写路由只接受 application/json')
|
|
369
|
+
for (const code of ['unsupported-media-type', 'forbidden-origin', 'invalid-config', 'config-editor-unavailable']) {
|
|
370
|
+
check(indexSource.includes(`'${code}'`), `Host 配置写路由返回稳定 code ${code}`)
|
|
371
|
+
}
|
|
372
|
+
check(/errorCode: state\.error === null \? null : 'preset-registration-failed'/.test(indexSource), 'Host state 提供 registration 错误 code')
|
|
373
|
+
check(/guardAllSubagents:\s*false/.test(settingsSource), 'settings 默认 guardAllSubagents=false')
|
|
374
|
+
check(/probePresets/.test(indexSource) && /presets:\s*\{/.test(indexSource), 'Host 返回真实预设目录')
|
|
375
|
+
check(/listProviders\(\)/.test(indexSource) && /listModels\(provider\.id\)/.test(indexSource), 'Host 枚举 provider/model 目录')
|
|
376
|
+
check(/const failures = entries/.test(indexSource) && /failure:/.test(indexSource), 'Host 模型目录容忍单个 provider 失败')
|
|
377
|
+
|
|
378
|
+
// ── client 设置页 ─────────────────────────────────────────────────────────
|
|
379
|
+
check(/__ModuleLoader__\.load/.test(clientSource), 'client.js 是浏览器模块')
|
|
380
|
+
check(/id:\s*'dsh-dev-plan-presets'/.test(clientSource), 'client.js 模块 id 正确')
|
|
381
|
+
check(/plugins\.row\.config/.test(clientSource), 'client.js 注册 plugins.row.config')
|
|
382
|
+
check(
|
|
383
|
+
/key:\s*'dsh-dev-plan-presets#dev-plan-presets'/.test(clientSource),
|
|
384
|
+
'client 注册 key=dsh-dev-plan-presets#dev-plan-presets',
|
|
385
|
+
)
|
|
386
|
+
check(/fetch\(API \+ '\/state'/.test(clientSource), 'client 读取 Host state 路由')
|
|
387
|
+
check(/fetch\(API \+ '\/config'/.test(clientSource) && /method:\s*'POST'/.test(clientSource), 'client 通过 Host 路由保存配置')
|
|
388
|
+
check(!/subagent-model-pin/.test(clientSource), 'client 不复用旧插件 id/路由')
|
|
389
|
+
for (const marker of ['developMode', 'childProvider', 'childModel', 'childReasoningEffort', 'modelGuardMode', 'killOnViolation', 'honorExplicit', 'audit', 'guardAllSubagents', 'mainToolMode', 'mainStepWarnThreshold']) {
|
|
390
|
+
check(clientSource.includes(marker), `client 设置页包含字段 ${marker}`)
|
|
391
|
+
}
|
|
392
|
+
check(/if-none-match/.test(clientSource) && /304/.test(clientSource) && /stateVersion/.test(clientSource), 'client 支持 ETag/304 与 stateVersion 跳过重渲染')
|
|
393
|
+
check(/FAST_POLL_MS = 700/.test(clientSource) && /IDLE_POLL_MS = 30000/.test(clientSource) && /visibilitychange/.test(clientSource) && !/setInterval\(/.test(clientSource), 'client 使用自适应轮询与不可见暂停')
|
|
394
|
+
check(/React\.useMemo/.test(clientSource) && /timersRef/.test(clientSource) && /AbortController/.test(clientSource), 'client 使用 useMemo 与定时器/请求清理')
|
|
395
|
+
check(/state.presets/.test(clientSource) && /presetRows/.test(clientSource), 'client 从 /state 动态列出预设')
|
|
396
|
+
check(!/value: *'deep-ptc'/.test(clientSource), 'client 不再硬编码 deep-ptc 选项')
|
|
397
|
+
check(
|
|
398
|
+
/state\.modelCatalog/.test(clientSource) &&
|
|
399
|
+
/modelChoices/.test(clientSource) &&
|
|
400
|
+
/providerChoices/.test(clientSource) &&
|
|
401
|
+
/presetChoices/.test(clientSource),
|
|
402
|
+
'client 从 /state 读取模型目录并用纯选择函数',
|
|
403
|
+
)
|
|
404
|
+
check(/htmlFor/.test(clientSource) && /aria-describedby/.test(clientSource), 'client 使用 label for 与帮助文本关联')
|
|
405
|
+
check(/fieldset/.test(clientSource) && /legend/.test(clientSource), 'client 用 fieldset/legend 分组')
|
|
406
|
+
check(/type: *'button'/.test(clientSource), 'client 次级按钮显式 type=button')
|
|
407
|
+
check(!/configEditor/.test(clientSource), 'client 普通文案不出现 configEditor')
|
|
408
|
+
check(!/reasoningEffort(可空)/.test(clientSource), 'client 不把 reasoningEffort 当主标签')
|
|
409
|
+
check(/已回退 standard|Fell back to standard/.test(clientSource), 'client 显式显示回退 standard')
|
|
410
|
+
check(
|
|
411
|
+
['未安装', '未启用', '已被移除', '加载失败'].every((marker) => clientSource.includes(marker)),
|
|
412
|
+
'client 回退横幅涵盖不可用原因',
|
|
413
|
+
)
|
|
414
|
+
check(
|
|
415
|
+
clientSource.includes('not installed') && clientSource.includes('failed to load'),
|
|
416
|
+
'client 英文回退横幅涵盖不可用原因',
|
|
417
|
+
)
|
|
418
|
+
check(
|
|
419
|
+
clientSource.includes('施工方式列表读取超时') && /setup list timed out/i.test(clientSource),
|
|
420
|
+
'client 显示预设目录超时',
|
|
421
|
+
)
|
|
422
|
+
check(!/#[0-9a-fA-F]{3,8}|rgba?\(/.test(clientSource), 'client 不保留 hex/rgba 字面颜色')
|
|
423
|
+
check(!/navigator\.language/.test(clientSource), 'client 不使用 navigator.language')
|
|
424
|
+
check(
|
|
425
|
+
clientSource.includes('开发规划与交付 · 施工设置') &&
|
|
426
|
+
clientSource.includes('Development planning & delivery · development settings'),
|
|
427
|
+
'client 设置页标题使用预设名「开发规划与交付」',
|
|
428
|
+
)
|
|
429
|
+
check(/getSnapshot/.test(clientSource) && /\.subscribe\(/.test(clientSource), 'client 通过 locale getSnapshot/subscribe 跟随宿主语言')
|
|
430
|
+
check(/return locale\.subscribe/.test(clientSource), 'client 清理语言订阅')
|
|
431
|
+
check(!/outline\s*:/.test(clientSource), 'client 不覆盖宿主焦点环')
|
|
432
|
+
for (const token of [
|
|
433
|
+
'--dsw-alias-border-l2',
|
|
434
|
+
'--dsw-alias-label-primary',
|
|
435
|
+
'--dsw-alias-label-secondary',
|
|
436
|
+
'--dsw-alias-label-tertiary',
|
|
437
|
+
'--dsw-alias-state-error-primary',
|
|
438
|
+
'--dsw-alias-state-success-primary',
|
|
439
|
+
'--dsw-alias-state-idle-primary',
|
|
440
|
+
'--dsw-alias-state-warn-primary',
|
|
441
|
+
'--dsw-alias-button-primary-fill',
|
|
442
|
+
'--dsw-alias-label-on-color',
|
|
443
|
+
'--dsw-alias-card-fill',
|
|
444
|
+
'--dsw-radius-sm',
|
|
445
|
+
'--dsw-radius-xs',
|
|
446
|
+
'--ds-font-family-code',
|
|
447
|
+
]) {
|
|
448
|
+
check(clientSource.includes(token), `client 使用已核实主题 token ${token}`)
|
|
449
|
+
}
|
|
450
|
+
check(/role:\s*'status'/.test(clientSource) && /role:\s*'alert'/.test(clientSource), 'client 状态/错误使用 role=status/alert')
|
|
451
|
+
check(/aria-live/.test(clientSource), 'client 使用 aria-live')
|
|
452
|
+
check(/buttonDisabled/.test(clientSource) && /not-allowed/.test(clientSource), 'client 按钮有真实禁用态样式')
|
|
453
|
+
check(/未保存修改/.test(clientSource) && /已保存/.test(clientSource), 'client 常显保存状态')
|
|
454
|
+
check(/notice\.kind === 'saved'/.test(clientSource), 'client 仅在 notice.kind=saved 时显示已保存')
|
|
455
|
+
check(!/notice\.ok/.test(clientSource), 'client 不再用 notice.ok 判断成功')
|
|
456
|
+
check(/const update = \(patch\) => \{\s*setNotice\(null\)/.test(clientSource), 'client 修改字段时清除旧通知')
|
|
457
|
+
check(/kind:\s*'discarded'/.test(clientSource) && /已放弃修改/.test(clientSource), 'client 放弃修改有独立 kind/状态')
|
|
458
|
+
check(/无法连接 Host/.test(clientSource) && /Cannot reach the Host/.test(clientSource), 'client network 错误给可执行指引')
|
|
459
|
+
check(/仅 pin/.test(clientSource), 'client honorExplicit 标注仅 pin')
|
|
460
|
+
check(/hostFormatted/.test(clientSource) && /formatted \? raw :/.test(clientSource), 'client 不重复叠加“保存失败”前缀')
|
|
461
|
+
check(/放弃修改并刷新/.test(clientSource), 'client dirty 时刷新明确标记为放弃修改')
|
|
462
|
+
check(/设置路由未注册/.test(clientSource) && /settings route is not registered/i.test(clientSource), 'client 404 给出可执行指引')
|
|
463
|
+
check(/stopped\.current/.test(clientSource), 'client 连续 404 停止自动轮询')
|
|
464
|
+
check(/scheduleRefresh\(600\)/.test(clientSource) && /scheduleRefresh\(1800\)/.test(clientSource), 'client 保存后可在 HMR 404 后重试回读')
|
|
465
|
+
check(/registration === 'pending'/.test(clientSource) && /registration === 'failed'/.test(clientSource) && /registration === 'switching'/.test(clientSource), 'client 显示 pending/failed/switching 状态')
|
|
466
|
+
check(/施工方式/.test(clientSource) && /守门方式/.test(clientSource), 'client 两个模式 label 已区分')
|
|
467
|
+
check(/只记录,不阻止/.test(clientSource) && /记录详细日志/.test(clientSource), 'client 区分守门 audit 与审计日志开关')
|
|
468
|
+
check(/当前生效/.test(clientSource) && /保存后以回读值为准/.test(clientSource), 'client 展示当前生效路由与回读提示')
|
|
469
|
+
check(/overflowWrap/.test(clientSource), 'client 长原因可换行')
|
|
470
|
+
check(/inject:\s*\['slots',\s*'locale'\]/.test(clientSource), 'client 注入 slots 与 locale')
|
|
471
|
+
|
|
472
|
+
// ── 动态 preset:standard ────────────────────────────────────────────────
|
|
473
|
+
const standardRows = flattenPlugins(standard?.plugins)
|
|
474
|
+
check(standard?.id === surface.constants.presetId, 'preset id=dev-plan', standard?.id)
|
|
475
|
+
check(standard?.id === 'dev-plan', 'preset id 保持 dev-plan')
|
|
476
|
+
check(standard?.name === '开发规划与交付', 'preset 显示名为「开发规划与交付」', standard?.name)
|
|
477
|
+
check(surface.constants.presetName === '开发规划与交付', 'PRESET_NAME=开发规划与交付', surface.constants.presetName)
|
|
478
|
+
check(standard?.order === 10, 'preset order=10', String(standard?.order))
|
|
479
|
+
check(typeof standard?.description === 'string' && standard.description.length > 0, 'preset 有动态 description')
|
|
480
|
+
check(/standard/.test(standard?.description ?? ''), '默认 description 写明 standard')
|
|
481
|
+
|
|
482
|
+
const noneModeRows = flattenPlugins(noneMode?.plugins)
|
|
483
|
+
for (const forbidden of surface.modules.preset.FORBIDDEN_MAIN_PLUGINS) {
|
|
484
|
+
check(!noneModeRows.some((row) => row?.name === forbidden), `主窗(none)不挂载 ${forbidden}`)
|
|
485
|
+
}
|
|
486
|
+
for (const neverMain of [
|
|
487
|
+
'@deepseek-ai/dsh-tool-bash',
|
|
488
|
+
'@deepseek-ai/dsh-tool-pwsh',
|
|
489
|
+
'@deepseek-ai/dsh-tool-workflow',
|
|
490
|
+
'@deepseek-ai/dsh-tool-jobs',
|
|
491
|
+
'@deepseek-ai/dsh-tool-schedule',
|
|
492
|
+
'@deepseek-ai/dsh-tool-goal',
|
|
493
|
+
'@deepseek-ai/dsh-tool-skill',
|
|
494
|
+
'@deepseek-ai/dsh-tool-todo',
|
|
495
|
+
'@deepseek-ai/dsh-tool-present',
|
|
496
|
+
'@deepseek-ai/dsh-tool-subagent-fork',
|
|
497
|
+
'@deepseek-ai/dsh-skill-filesystem',
|
|
498
|
+
'@deepseek-ai/dsh-plan-mode',
|
|
499
|
+
]) {
|
|
500
|
+
check(!standardRows.some((row) => row?.name === neverMain), `主窗默认(ask-edit)不挂载 ${neverMain}`)
|
|
501
|
+
}
|
|
502
|
+
for (const required of [
|
|
503
|
+
'@deepseek-ai/dsh-persona',
|
|
504
|
+
'@deepseek-ai/dsh-agent-instructions',
|
|
505
|
+
'@deepseek-ai/dsh-time-context',
|
|
506
|
+
'@deepseek-ai/dsh-tool-ask-user',
|
|
507
|
+
'@deepseek-ai/dsh-tool-subagent-control',
|
|
508
|
+
]) {
|
|
509
|
+
check(standardRows.some((row) => row?.name === required), `主窗挂载 ${required}`)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const toolRows = flattenPlugins(standard?.plugins).filter((row) => row?.name === '@deepseek-ai/dsh-tool-subagent')
|
|
513
|
+
check(toolRows.length === 4, '主窗恰好 4 个委派工具', String(toolRows.length))
|
|
514
|
+
const toolNames = toolRows.map((row) => row?.config?.toolName)
|
|
515
|
+
check(JSON.stringify([...toolNames].sort()) === JSON.stringify(['develop', 'recon', 'review', 'scribe']), '四个委派工具是 recon/review/scribe/develop', toolNames.join(', '))
|
|
516
|
+
check(new Set(toolNames).size === toolNames.length, 'toolName 互不重复')
|
|
517
|
+
check(
|
|
518
|
+
toolRows.find((row) => row?.config?.toolName === 'develop')?.config?.agentPreset === 'standard',
|
|
519
|
+
'develop 默认使用 standard',
|
|
520
|
+
)
|
|
521
|
+
for (const name of ['recon', 'review', 'scribe']) {
|
|
522
|
+
check(
|
|
523
|
+
toolRows.find((row) => row?.config?.toolName === name)?.config?.agentPreset === 'standard',
|
|
524
|
+
`${name} 使用 standard(避免在预设下拉暴露额外选项)`,
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// ── mainToolMode 三档与内部轻量子预设插件面 ─────────────────────────────
|
|
529
|
+
const forbiddenSubagentPkgs = [
|
|
530
|
+
'@deepseek-ai/dsh-tool-bash',
|
|
531
|
+
'@deepseek-ai/dsh-tool-pwsh',
|
|
532
|
+
'@deepseek-ai/dsh-tool-workflow',
|
|
533
|
+
'@deepseek-ai/dsh-tool-jobs',
|
|
534
|
+
'@deepseek-ai/dsh-tool-schedule',
|
|
535
|
+
'@deepseek-ai/dsh-tool-goal',
|
|
536
|
+
'@deepseek-ai/dsh-tool-skill',
|
|
537
|
+
'@deepseek-ai/dsh-tool-todo',
|
|
538
|
+
'@deepseek-ai/dsh-tool-subagent',
|
|
539
|
+
'@deepseek-ai/dsh-plan-mode',
|
|
540
|
+
]
|
|
541
|
+
const scoutRows = flattenPlugins(scoutPreset?.plugins)
|
|
542
|
+
const scribeRows = flattenPlugins(scribePreset?.plugins)
|
|
543
|
+
for (const pkgName of forbiddenSubagentPkgs) {
|
|
544
|
+
check(!scoutRows.some((r) => r?.name === pkgName), `dev-plan-scout 不含 ${pkgName}`)
|
|
545
|
+
check(!scribeRows.some((r) => r?.name === pkgName), `dev-plan-scribe 不含 ${pkgName}`)
|
|
546
|
+
}
|
|
547
|
+
check(
|
|
548
|
+
scoutRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs')?.config?.applyPatch === false &&
|
|
549
|
+
scoutRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs-search')?.config?.sampleOverCapGlobResults === false &&
|
|
550
|
+
scoutRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-web')?.config?.fetch === true,
|
|
551
|
+
'dev-plan-scout 仅挂载只读 fs/search/web 且带宿主必需配置',
|
|
552
|
+
)
|
|
553
|
+
const scribeCompaction = (scribePreset?.plugins ?? []).find((r) => r?.id === 'compaction')
|
|
554
|
+
check(
|
|
555
|
+
scribeCompaction?.group === true &&
|
|
556
|
+
scribeCompaction?.isolate?.compaction === true &&
|
|
557
|
+
scribeRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs')?.config?.applyPatch === false &&
|
|
558
|
+
!scribeRows.some((r) => r?.name === '@deepseek-ai/dsh-tool-fs-search') &&
|
|
559
|
+
!scribeRows.some((r) => r?.name === '@deepseek-ai/dsh-tool-web'),
|
|
560
|
+
'dev-plan-scribe 仅挂载 tool-fs 且 compaction 带 isolate 隔离组',
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
const readonlyRows = flattenPlugins(readonlyMode?.plugins)
|
|
564
|
+
const askEditRows = flattenPlugins(askEditMode?.plugins)
|
|
565
|
+
check(
|
|
566
|
+
readonlyRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs-search')?.config?.sampleOverCapGlobResults === false &&
|
|
567
|
+
!readonlyRows.some((r) => r?.name === '@deepseek-ai/dsh-tool-fs'),
|
|
568
|
+
'mainToolMode=readonly 仅新增带有效配置的 tool-fs-search,不含 tool-fs',
|
|
569
|
+
)
|
|
570
|
+
check(
|
|
571
|
+
askEditRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs')?.config?.applyPatch === false &&
|
|
572
|
+
askEditRows.find((r) => r?.name === '@deepseek-ai/dsh-tool-fs-search')?.config?.sampleOverCapGlobResults === false,
|
|
573
|
+
'mainToolMode=ask-edit 仅新增 tool-fs(applyPatch:false) + 带有效配置的 tool-fs-search',
|
|
574
|
+
)
|
|
575
|
+
for (const pkgName of [
|
|
576
|
+
'@deepseek-ai/dsh-tool-bash',
|
|
577
|
+
'@deepseek-ai/dsh-tool-pwsh',
|
|
578
|
+
'@deepseek-ai/dsh-tool-workflow',
|
|
579
|
+
'@deepseek-ai/dsh-tool-jobs',
|
|
580
|
+
'@deepseek-ai/dsh-tool-schedule',
|
|
581
|
+
'@deepseek-ai/dsh-tool-goal',
|
|
582
|
+
'@deepseek-ai/dsh-tool-skill',
|
|
583
|
+
'@deepseek-ai/dsh-tool-todo',
|
|
584
|
+
'@deepseek-ai/dsh-plan-mode',
|
|
585
|
+
]) {
|
|
586
|
+
check(!readonlyRows.some((r) => r?.name === pkgName), `readonly 永不挂载 ${pkgName}`)
|
|
587
|
+
check(!askEditRows.some((r) => r?.name === pkgName), `ask-edit 永不挂载 ${pkgName}`)
|
|
588
|
+
}
|
|
589
|
+
for (const row of toolRows) {
|
|
590
|
+
const cfg = row.config ?? {}
|
|
591
|
+
const name = cfg.toolName
|
|
592
|
+
check(cfg.provider === 'spawn', `${name} provider=spawn`)
|
|
593
|
+
check(cfg.maxDepth === 1, `${name} maxDepth=1`, String(cfg.maxDepth))
|
|
594
|
+
check(cfg.modelSelection === false, `${name} 关闭 modelSelection`)
|
|
595
|
+
check(cfg.modelDiscovery === false, `${name} 关闭 modelDiscovery`)
|
|
596
|
+
check(cfg.allowedAgentPresets === undefined, `${name} 不设 allowedAgentPresets`)
|
|
597
|
+
check(
|
|
598
|
+
JSON.stringify(cfg.agentOptions) === JSON.stringify({ provider: 'dsh-opencode-go', model: 'deepseek-v4.1-flash' }),
|
|
599
|
+
`${name} agentOptions 与默认设置一致`,
|
|
600
|
+
JSON.stringify(cfg.agentOptions),
|
|
601
|
+
)
|
|
602
|
+
}
|
|
603
|
+
const defaultRoute = JSON.stringify({ provider: 'dsh-opencode-go', model: 'deepseek-v4.1-flash' })
|
|
604
|
+
check(
|
|
605
|
+
toolRows.every((row) => JSON.stringify(row.config.agentOptions) === defaultRoute),
|
|
606
|
+
'四个工具共用同一路由(同一设置真源)',
|
|
607
|
+
)
|
|
608
|
+
|
|
609
|
+
// ── 动态 preset:deep-ptc / 回退 / reasoningEffort ────────────────────────
|
|
610
|
+
check(
|
|
611
|
+
findTool(deepPtc, 'develop')?.config?.agentPreset === 'deep-ptc',
|
|
612
|
+
'deep-ptc 模式只把 develop 切到 deep-ptc',
|
|
613
|
+
)
|
|
614
|
+
for (const name of ['recon', 'review', 'scribe']) {
|
|
615
|
+
check(
|
|
616
|
+
findTool(deepPtc, name)?.config?.agentPreset === 'standard',
|
|
617
|
+
`deep-ptc 模式下 ${name} 仍是 standard`,
|
|
618
|
+
)
|
|
619
|
+
}
|
|
620
|
+
check(/deep-ptc/.test(deepPtc?.description ?? ''), 'deep-ptc description 写明模式')
|
|
621
|
+
check(/已回退 standard/.test(fallback?.description ?? ''), '回退 description 写明「已回退 standard」')
|
|
622
|
+
check(
|
|
623
|
+
/没有可用的施工方式|未安装|未启用|已被移除/.test(fallback?.description ?? ''),
|
|
624
|
+
'回退原因涵盖目录缺失而非误断为未安装',
|
|
625
|
+
fallback?.description ?? '',
|
|
626
|
+
)
|
|
627
|
+
check(
|
|
628
|
+
findTool(custom, 'develop')?.config?.agentPreset === 'team-builder',
|
|
629
|
+
'任意有效 preset 可作 develop',
|
|
630
|
+
)
|
|
631
|
+
check(/团队施工/.test(custom?.description ?? ''), '自定义 preset 名称进入 description')
|
|
632
|
+
check(
|
|
633
|
+
surface.selfFallback.fallback === true && /递归派工|内部预设/.test(surface.selfFallback.reason ?? ''),
|
|
634
|
+
'dev-plan 自身被拒绝,避免递归',
|
|
635
|
+
)
|
|
636
|
+
check(
|
|
637
|
+
surface.scoutSelfFallback?.fallback === true && surface.scribeSelfFallback?.fallback === true,
|
|
638
|
+
'dev-plan-scout 与 dev-plan-scribe 也被拒绝作 developMode',
|
|
639
|
+
)
|
|
640
|
+
check(
|
|
641
|
+
surface.modules.settings.DEFAULT_SETTINGS.guardAllSubagents === false,
|
|
642
|
+
'默认 guardAllSubagents=false(只守 dev-plan 子代理)',
|
|
643
|
+
)
|
|
644
|
+
check(/已回退 standard/.test(findPresetPlugin(fallback, 'persona')?.config?.prefix ?? ''), '回退 persona 写明「已回退 standard」')
|
|
645
|
+
check(/回退显式可见/.test(findPresetPlugin(fallback, 'persona')?.config?.prefix ?? ''), '回退说明显式可见')
|
|
646
|
+
check(
|
|
647
|
+
JSON.stringify(findTool(withEffort, 'develop')?.config?.agentOptions) ===
|
|
648
|
+
JSON.stringify({ provider: 'dsh-opencode-go', model: 'deepseek-v4.1-flash', reasoningEffort: 'high' }),
|
|
649
|
+
'childReasoningEffort 非空时进入 agentOptions',
|
|
650
|
+
JSON.stringify(findTool(withEffort, 'develop')?.config?.agentOptions),
|
|
651
|
+
)
|
|
652
|
+
check(
|
|
653
|
+
!Object.hasOwn(findTool(standard, 'develop')?.config?.agentOptions ?? {}, 'reasoningEffort'),
|
|
654
|
+
'childReasoningEffort 为空时省略该键',
|
|
655
|
+
)
|
|
656
|
+
|
|
657
|
+
// ── compaction / persona ─────────────────────────────────────────────────
|
|
658
|
+
const compaction = flattenPlugins(standard?.plugins).find((row) => row?.id === 'compaction')
|
|
659
|
+
check(compaction?.group === true, 'compaction 是 group')
|
|
660
|
+
check(compaction?.isolate?.compaction === true && compaction?.isolate?.toolResultPruner === true, 'compaction isolate 两个键都为 true')
|
|
661
|
+
check(
|
|
662
|
+
['@deepseek-ai/dsh-compaction-basic', '@deepseek-ai/dsh-command-compact', '@deepseek-ai/dsh-compaction-tool-result-pruner'].every(
|
|
663
|
+
(name) => flattenPlugins(compaction?.config).some((row) => row?.name === name),
|
|
664
|
+
),
|
|
665
|
+
'compaction 组含三行',
|
|
666
|
+
)
|
|
667
|
+
|
|
668
|
+
const personaRow = findPresetPlugin(standard, 'persona')
|
|
669
|
+
const personaPrefix = personaRow?.config?.prefix ?? ''
|
|
670
|
+
const personaSuffix = personaRow?.config?.suffix ?? ''
|
|
671
|
+
const persona = `${personaPrefix}${personaSuffix}`
|
|
672
|
+
const personaLength = personaPrefix.length + personaSuffix.length
|
|
673
|
+
check(
|
|
674
|
+
typeof personaPrefix === 'string' && personaPrefix.length > 1000 && personaLength <= 6000,
|
|
675
|
+
'persona 长度在性能预算内(1000 < total <= 6000 字符)',
|
|
676
|
+
`${personaLength} chars`,
|
|
677
|
+
)
|
|
678
|
+
check(
|
|
679
|
+
!personaPrefix.includes('ROLE-TEMPLATE:SCOUT:BEGIN') && !personaPrefix.includes('ROLE-TEMPLATE:SCRIBE:BEGIN'),
|
|
680
|
+
'主窗 prefix 不再使用旧的千字长模板',
|
|
681
|
+
)
|
|
682
|
+
check(
|
|
683
|
+
personaPrefix.includes('仅给子代理用') &&
|
|
684
|
+
personaPrefix.includes('【仅子代理用 · 侦察/复核约束】') &&
|
|
685
|
+
personaPrefix.includes('【仅子代理用 · 文书落盘约束】'),
|
|
686
|
+
'主窗 persona 嵌入紧凑版子代理模板并标注仅给子代理用',
|
|
687
|
+
)
|
|
688
|
+
check(typeof personaSuffix === 'string' && personaSuffix.length > 100, 'persona.suffix 非空(不遮蔽部署级 suffix)')
|
|
689
|
+
check(!/\{\{/.test(persona), 'persona 不含模板变量')
|
|
690
|
+
|
|
691
|
+
const nonePersonaPrefix = findPresetPlugin(noneMode, 'persona')?.config?.prefix ?? ''
|
|
692
|
+
check(nonePersonaPrefix.includes('永不亲自读写仓库、写代码或跑 Shell'), 'persona(none) 说明主窗永不亲自写代码')
|
|
693
|
+
for (const [marker, label] of [
|
|
694
|
+
['永远禁止跑 Shell/测试命令(无 Shell 工具)', 'persona(默认 ask-edit) 严禁跑 Shell/测试命令'],
|
|
695
|
+
['必须先获用户本轮明确同意“主窗直接改”', 'persona(默认 ask-edit) 写改必须先获用户同意'],
|
|
696
|
+
['默认只规划与复核', 'persona 说明默认只规划/复核'],
|
|
697
|
+
['开工/施工/修复', 'persona 只在用户明确开工时派 develop'],
|
|
698
|
+
['name=developer', 'persona 固定 developer'],
|
|
699
|
+
['send_message', 'persona 用 send_message 续派'],
|
|
700
|
+
['不反复请示', 'persona 普通实现不反复请示'],
|
|
701
|
+
['独立 review', 'persona 施工后可派独立 review'],
|
|
702
|
+
['仅范围扩大、风险变化或宿主权限要求', 'persona 仅范围/风险/权限变化重确认'],
|
|
703
|
+
['不向人类提问', 'develop 不向人类提问'],
|
|
704
|
+
['不得把子代理自述当自己跑过测试', 'persona 禁止把子代理自述当成自己运行测试'],
|
|
705
|
+
['同一任务严禁混用 develop 与 rework_task/ask_worker', '双通道互斥'],
|
|
706
|
+
// P0 流程提效与单契约复用
|
|
707
|
+
['快速路径', 'P0 风险路由含快速路径'],
|
|
708
|
+
['标准路径', 'P0 风险路由含标准路径'],
|
|
709
|
+
['高风险路径', 'P0 风险路由含高风险路径'],
|
|
710
|
+
['歧义', 'P0 判定维度含歧义'],
|
|
711
|
+
['影响面', 'P0 判定维度含影响面'],
|
|
712
|
+
['可逆性', 'P0 判定维度含可逆性'],
|
|
713
|
+
['可验证性', 'P0 判定维度含可验证性'],
|
|
714
|
+
['必须升级路径', 'P0 证据不足时提高风险等级'],
|
|
715
|
+
['绝不因验证困难降级', 'P0 绝不因验证困难降级'],
|
|
716
|
+
['分层变更证据', 'P0 完工必须附分层变更证据'],
|
|
717
|
+
['只有文件清单或口头摘要不算审过 diff', 'P0 不能只给文件清单'],
|
|
718
|
+
['不得声称核对过 diff', 'P0 摘要不得冒充 diff 审查'],
|
|
719
|
+
['补证据', 'P0 缺证据要同一 developer 补证据'],
|
|
720
|
+
['开工契约', 'P0 一次性开工契约'],
|
|
721
|
+
['目标', '任务书含目标'],
|
|
722
|
+
['非目标', '任务书含非目标'],
|
|
723
|
+
['允许与禁止改动路径', '任务书含允许改动路径'],
|
|
724
|
+
['接口与兼容约束', '任务书含接口/依赖'],
|
|
725
|
+
['验收标准', '任务书含验收标准'],
|
|
726
|
+
['检查命令', '任务书含检查命令'],
|
|
727
|
+
['风险', '任务书含风险/回退'],
|
|
728
|
+
['最小切片', 'P0 验收前置含最小切片'],
|
|
729
|
+
['语法/静态契约', 'P0 验收排序含语法/静态契约'],
|
|
730
|
+
['针对性测试', 'P0 验收排序含针对性测试'],
|
|
731
|
+
['必要运行/GUI', 'P0 验收排序含必要运行/GUI'],
|
|
732
|
+
['静态检查/单测不等于真实运行验收', 'P0 禁止静态检查冒充真实验证'],
|
|
733
|
+
['非阻塞协作', 'P0 非阻塞协作'],
|
|
734
|
+
['不轮询', 'P0 主窗不轮询'],
|
|
735
|
+
['不 `sleep`', 'P0 主窗不忙等'],
|
|
736
|
+
['不重复施工', 'P0 主窗不重复施工'],
|
|
737
|
+
['读写 developer 正在改的文件', 'P0 主窗不重复读取 developer 文件'],
|
|
738
|
+
['developer 仅在阻塞、范围冲突或关键契约决策时打断', 'P0 developer 打断边界'],
|
|
739
|
+
['verified|partial|failed|未验证', 'P0 汇报含验证状态分级'],
|
|
740
|
+
['阻塞', 'P0 阻塞问题返工'],
|
|
741
|
+
['不无限打磨', 'P0 非阻塞建议不无限打磨'],
|
|
742
|
+
['review 不替代主窗最终审查', 'P0 最终审查责任不外包'],
|
|
743
|
+
['name=scout', 'recon 首次固定 name=scout 复用上下文'],
|
|
744
|
+
['文本不是派工', 'P0 文本不是派工'],
|
|
745
|
+
['实际调用 develop', 'P0 授权后必须实际调用 develop'],
|
|
746
|
+
['已派出 developer', 'P0 工具接受后才可称已派出'],
|
|
747
|
+
['未派工:原因', 'P0 未派工如实报告'],
|
|
748
|
+
['实际调用 send_message', 'P0 返工必须实际 send_message'],
|
|
749
|
+
// 施工目录/权限防护
|
|
750
|
+
['施工目录边界', 'persona 写明施工目录与权限'],
|
|
751
|
+
['cwd', 'persona 明确 cwd 参数'],
|
|
752
|
+
['可写工作区', 'persona 派工前检查可写工作区'],
|
|
753
|
+
['已存在的父目录', 'persona 允许工作区内未建子目录以父目录 cwd 派工自建'],
|
|
754
|
+
['working_directory', 'persona 禁止先建后 cd'],
|
|
755
|
+
['父会话事后提权不扩大已有子代理权限', 'persona 不假设权限会扩大'],
|
|
756
|
+
['沙箱', 'persona 权限失败记录沙箱模式'],
|
|
757
|
+
['原错', 'persona 权限失败记录真实错误'],
|
|
758
|
+
]) {
|
|
759
|
+
check(persona.includes(marker), label, marker)
|
|
760
|
+
}
|
|
761
|
+
check(
|
|
762
|
+
!persona.includes('降低路径等级并补验收'),
|
|
763
|
+
'P0 没有“证据不足就降低路径等级”的回退指令',
|
|
764
|
+
)
|
|
765
|
+
check(
|
|
766
|
+
!/只有改动摘要也算证据|只给文件清单(?:也)?可以/.test(persona),
|
|
767
|
+
'P0 没有“摘要/文件清单就是证据”的错误说法',
|
|
768
|
+
)
|
|
769
|
+
check(
|
|
770
|
+
!/文本也能算派工|没有调用也可以说已派出|文本任务书即视为已派工/.test(persona),
|
|
771
|
+
'P0 没有“文本任务书即视为已派工”的错误说法',
|
|
772
|
+
)
|
|
773
|
+
|
|
774
|
+
const scoutPersona = findPresetPlugin(scoutPreset, 'persona')?.config?.prefix ?? ''
|
|
775
|
+
const scribePersona = findPresetPlugin(scribePreset, 'persona')?.config?.prefix ?? ''
|
|
776
|
+
check(
|
|
777
|
+
['read', 'read_image', 'glob', 'grep', 'web_search', 'web_fetch'].every((tool) => scoutPersona.includes(tool)),
|
|
778
|
+
'dev-plan-scout 内置 persona 声明六项只读工具',
|
|
779
|
+
)
|
|
780
|
+
check(
|
|
781
|
+
scribePersona.includes('read、write、edit') && scribePersona.includes('超出文书子代理职责'),
|
|
782
|
+
'dev-plan-scribe 内置 persona 限定只写规划/复核文档',
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
// ── locale / README / detail ─────────────────────────────────────────────
|
|
786
|
+
for (const [name, value, error] of [
|
|
787
|
+
['locale/zh.json', locale.zh, surface.localeErrors.zh],
|
|
788
|
+
['locale/en.json', locale.en, surface.localeErrors.en],
|
|
789
|
+
]) {
|
|
790
|
+
check(error === null, `${name} 是合法 JSON`, error ?? '')
|
|
791
|
+
check(typeof value?.meta?.title === 'string' && value.meta.title.length > 0, `${name} 有 meta.title`)
|
|
792
|
+
check(typeof value?.meta?.description === 'string' && value.meta.description.length > 0, `${name} 有 meta.description`)
|
|
793
|
+
check(value?.meta?.detail === 'detail.md', `${name} meta.detail=detail.md`)
|
|
794
|
+
}
|
|
795
|
+
check(
|
|
796
|
+
locale.zh?.meta?.title === '开发规划与交付模式',
|
|
797
|
+
'locale/zh 插件显示名为「开发规划与交付模式」',
|
|
798
|
+
locale.zh?.meta?.title,
|
|
799
|
+
)
|
|
800
|
+
check(
|
|
801
|
+
locale.en?.meta?.title === 'Development planning & delivery Mode',
|
|
802
|
+
'locale/en 插件显示名为 Development planning & delivery Mode',
|
|
803
|
+
locale.en?.meta?.title,
|
|
804
|
+
)
|
|
805
|
+
for (const marker of ['develop', 'standard', 'deep-ptc', '模型守门']) {
|
|
806
|
+
check(String(locale.zh?.meta?.description ?? '').includes(marker), `locale/zh 说明 ${marker}`)
|
|
807
|
+
}
|
|
808
|
+
for (const marker of ['develop', 'standard', 'deep-ptc', 'model guard']) {
|
|
809
|
+
check(String(locale.en?.meta?.description ?? '').toLowerCase().includes(marker.toLowerCase()), `locale/en 说明 ${marker}`)
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
for (const marker of [
|
|
813
|
+
'0.4.0',
|
|
814
|
+
'develop',
|
|
815
|
+
'standard',
|
|
816
|
+
'deep-ptc',
|
|
817
|
+
'仅给子代理用',
|
|
818
|
+
'mainToolMode',
|
|
819
|
+
'ctx.agentPresets.register',
|
|
820
|
+
'cordis.patch.yml 只挂根插件',
|
|
821
|
+
'模型守门',
|
|
822
|
+
'只管理子代理',
|
|
823
|
+
'绝不钉主会话',
|
|
824
|
+
'dsh-subagent-model-pin',
|
|
825
|
+
'先验证本插件,再禁用旧插件',
|
|
826
|
+
'现有会话',
|
|
827
|
+
'新建会话',
|
|
828
|
+
'回退',
|
|
829
|
+
'已回退 standard',
|
|
830
|
+
'未验证',
|
|
831
|
+
'node scripts/verify-presets.mjs',
|
|
832
|
+
'node --test',
|
|
833
|
+
]) {
|
|
834
|
+
check(String(readme ?? '').includes(marker), `README 含关键说明:${marker}`)
|
|
835
|
+
}
|
|
836
|
+
check(/settings|插件页/.test(String(readme ?? '')), 'README 说明设置入口')
|
|
837
|
+
check(/js-yaml/.test(String(readme ?? '')), 'README 说明不依赖 js-yaml')
|
|
838
|
+
for (const marker of [
|
|
839
|
+
'docs/flow-redesign.md',
|
|
840
|
+
'快速路径',
|
|
841
|
+
'标准路径',
|
|
842
|
+
'高风险路径',
|
|
843
|
+
'一次性开工契约',
|
|
844
|
+
'验收前置',
|
|
845
|
+
'非阻塞协作',
|
|
846
|
+
'verified/partial/failed',
|
|
847
|
+
'实际变更证据',
|
|
848
|
+
'不能只给文件清单',
|
|
849
|
+
'接口/依赖',
|
|
850
|
+
'检查命令',
|
|
851
|
+
'风险/回退',
|
|
852
|
+
]) {
|
|
853
|
+
check(String(readme ?? '').includes(marker), `README 含 P0 说明:${marker}`)
|
|
854
|
+
}
|
|
855
|
+
check(/接口\/依赖[::]/.test(String(readme ?? '')), 'README 任务书模板含接口/依赖字段')
|
|
856
|
+
check(/风险\/回退[::]/.test(String(readme ?? '')), 'README 任务书模板含风险/回退字段')
|
|
857
|
+
check(String(readme ?? '').includes('显示名已定'), 'README 写明显式显示名已定')
|
|
858
|
+
check(!String(readme ?? '').includes('显示名未定'), 'README 不再声称显示名未定')
|
|
859
|
+
check(String(readme ?? '').includes('开发规划与交付'), 'README 使用新显示名')
|
|
860
|
+
for (const marker of ['已安装 → 开发规划与交付模式', '404', '仍无条件注册设置页', 'config-editor-unavailable', '--dsw-alias-', 'guard 卸载', 'dsh-client-locale', 'getOrigin']) {
|
|
861
|
+
check(String(readme ?? '').includes(marker), `README 含 UI/降级/安全说明:${marker}`)
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
for (const marker of [
|
|
865
|
+
'0.4.0',
|
|
866
|
+
'develop',
|
|
867
|
+
'standard',
|
|
868
|
+
'deep-ptc',
|
|
869
|
+
'仅给子代理用',
|
|
870
|
+
'mainToolMode',
|
|
871
|
+
'模型守门',
|
|
872
|
+
'已回退 standard',
|
|
873
|
+
'未验证',
|
|
874
|
+
'ctx.agentPresets.register',
|
|
875
|
+
]) {
|
|
876
|
+
check(String(detail ?? '').includes(marker), `detail.md 含关键说明:${marker}`)
|
|
877
|
+
}
|
|
878
|
+
for (const marker of [
|
|
879
|
+
'docs/flow-redesign.md',
|
|
880
|
+
'快速路径',
|
|
881
|
+
'非阻塞协作',
|
|
882
|
+
'P0',
|
|
883
|
+
'实际变更证据',
|
|
884
|
+
'不能只给文件清单',
|
|
885
|
+
'接口/依赖',
|
|
886
|
+
'检查命令',
|
|
887
|
+
'风险/回退',
|
|
888
|
+
]) {
|
|
889
|
+
check(String(detail ?? '').includes(marker), `detail.md 含 P0 说明:${marker}`)
|
|
890
|
+
}
|
|
891
|
+
for (const marker of ['已安装 → 开发规划与交付模式', '404', 'application/json', '--dsw-alias-', 'guard']) {
|
|
892
|
+
check(String(detail ?? '').includes(marker), `detail.md 含设置页行为说明:${marker}`)
|
|
893
|
+
}
|
|
894
|
+
check(String(detail ?? '').length > 1000, 'detail.md 是实质文档', `${String(detail ?? '').length} chars`)
|
|
895
|
+
|
|
896
|
+
const flowDoc = String(files['docs/flow-redesign.md'] ?? '')
|
|
897
|
+
check(flowDoc.length > 5000, 'docs/flow-redesign.md 是实质开发文档', `${flowDoc.length} chars`)
|
|
898
|
+
for (const marker of [
|
|
899
|
+
'背景与目标',
|
|
900
|
+
'P0 范围与非目标',
|
|
901
|
+
'风险路由矩阵',
|
|
902
|
+
'一次性开工契约',
|
|
903
|
+
'developer 执行与证据报告合同',
|
|
904
|
+
'主窗非阻塞、审查与返工规则',
|
|
905
|
+
'配置与工具影响',
|
|
906
|
+
'可测试的行为断言',
|
|
907
|
+
'真实验证矩阵',
|
|
908
|
+
'与调研报告 P0 的逐项追踪',
|
|
909
|
+
'P0-1',
|
|
910
|
+
'P0-2',
|
|
911
|
+
'P0-3',
|
|
912
|
+
'P0-4',
|
|
913
|
+
'P0-5',
|
|
914
|
+
'不做',
|
|
915
|
+
'P1',
|
|
916
|
+
'P2',
|
|
917
|
+
'verified / partial / failed',
|
|
918
|
+
'主窗最终审查责任不外包',
|
|
919
|
+
'绝不因验证困难降低路径等级',
|
|
920
|
+
'实际变更证据',
|
|
921
|
+
'不能只给文件清单',
|
|
922
|
+
'不得声称审过实际 diff',
|
|
923
|
+
]) {
|
|
924
|
+
check(flowDoc.includes(marker), `docs/flow-redesign.md 含关键说明:${marker}`)
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
return results
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/** 真实模块行为检查:用假 ctx 驱动,而不是只读源码。 */
|
|
931
|
+
async function behaviorChecks() {
|
|
932
|
+
const results = []
|
|
933
|
+
const check = (ok, label, detail = '') => results.push({ ok: Boolean(ok), label, detail: String(detail) })
|
|
934
|
+
const registry = createFakeRegistry()
|
|
935
|
+
const webServer = createFakeWebServer()
|
|
936
|
+
const configEditor = createFakeConfigEditor()
|
|
937
|
+
const ctx = createFakeContext({ registry, webServer, configEditor })
|
|
938
|
+
const modules = await loadModules(ROOT)
|
|
939
|
+
const { index } = modules
|
|
940
|
+
try {
|
|
941
|
+
index.apply(ctx.ctx, { ...modules.settings.DEFAULT_SETTINGS }, { verificationDelayMs: 0 })
|
|
942
|
+
await ctx.flush()
|
|
943
|
+
check(
|
|
944
|
+
registry.definitions.length === 1 &&
|
|
945
|
+
registry.definitions[0]?.id === 'dev-plan',
|
|
946
|
+
'apply 只动态注册 1 个 preset(dev-plan,不在公开列表暴露内部子预设)',
|
|
947
|
+
registry.definitions.map((d) => d.id).join(','),
|
|
948
|
+
)
|
|
949
|
+
check(registry.definitions.some((d) => d.id === 'dev-plan'), '动态注册 id=dev-plan')
|
|
950
|
+
check(typeof webServer.handlers.get === 'function', 'webServer 路由注册接口存在')
|
|
951
|
+
const stateHandler = webServer.handlers.get('/plugins/dev-plan-presets/state')
|
|
952
|
+
check(typeof stateHandler === 'function', '注册 /plugins/dev-plan-presets/state')
|
|
953
|
+
const state = await callRoute(stateHandler, 'GET')
|
|
954
|
+
check(state.code === 200, 'state 路由 GET 200', String(state.code))
|
|
955
|
+
check(state.body?.effectiveMode === 'standard', 'state 默认 effectiveMode=standard', String(state.body?.effectiveMode))
|
|
956
|
+
check(state.body?.fallback?.active === false, 'state 默认无回退')
|
|
957
|
+
check(typeof state.headers?.etag === 'string' && state.headers.etag.length > 0, 'state 响应头带 etag')
|
|
958
|
+
const state304 = await callRoute(stateHandler, 'GET', undefined, { 'if-none-match': state.headers.etag })
|
|
959
|
+
check(state304.code === 304 && state304.body === null, 'state 命中 If-None-Match 返回 304 空体', String(state304.code))
|
|
960
|
+
|
|
961
|
+
const configHandler = webServer.handlers.get('/plugins/dev-plan-presets/config')
|
|
962
|
+
check(typeof configHandler === 'function', '注册 /plugins/dev-plan-presets/config')
|
|
963
|
+
const invalid = await callRoute(configHandler, 'POST', { modelGuardMode: 'nonsense' })
|
|
964
|
+
check(invalid.code === 400, 'config 路由拒绝非法枚举(400)', String(invalid.code))
|
|
965
|
+
const valid = await callRoute(configHandler, 'POST', {
|
|
966
|
+
developMode: 'deep-ptc',
|
|
967
|
+
childProvider: 'p',
|
|
968
|
+
childModel: 'm',
|
|
969
|
+
modelGuardMode: 'audit',
|
|
970
|
+
})
|
|
971
|
+
check(valid.code === 200, 'config 路由接受合法配置(200)', String(valid.code))
|
|
972
|
+
check(configEditor.edits.length === 1, 'config 路由通过 configEditor.edit 写回', String(configEditor.edits.length))
|
|
973
|
+
check(configEditor.edits[0]?.next?.developMode === 'deep-ptc', '写回值包含 developMode=deep-ptc')
|
|
974
|
+
|
|
975
|
+
const textPlain = await callRoute(configHandler, 'POST', { modelGuardMode: 'audit' }, { 'content-type': 'text/plain' })
|
|
976
|
+
check(textPlain.code === 415, 'config 路由拒绝 text/plain(415)', String(textPlain.code))
|
|
977
|
+
const crossSite = await callRoute(
|
|
978
|
+
configHandler,
|
|
979
|
+
'POST',
|
|
980
|
+
{ modelGuardMode: 'audit' },
|
|
981
|
+
{ 'content-type': 'application/json', 'sec-fetch-site': 'cross-site' },
|
|
982
|
+
)
|
|
983
|
+
check(crossSite.code === 403, 'config 路由拒绝 cross-site(403)', String(crossSite.code))
|
|
984
|
+
const badOrigin = await callRoute(
|
|
985
|
+
configHandler,
|
|
986
|
+
'POST',
|
|
987
|
+
{ modelGuardMode: 'audit' },
|
|
988
|
+
{ 'content-type': 'application/json', origin: 'https://evil.example', host: '127.0.0.1:1162' },
|
|
989
|
+
)
|
|
990
|
+
check(badOrigin.code === 403, 'config 路由拒绝错误 Origin(403)', String(badOrigin.code))
|
|
991
|
+
check(configEditor.edits.length === 1, '被拒绝的配置写请求不调用 configEditor', String(configEditor.edits.length))
|
|
992
|
+
const sameOrigin = await callRoute(
|
|
993
|
+
configHandler,
|
|
994
|
+
'POST',
|
|
995
|
+
{ modelGuardMode: 'audit' },
|
|
996
|
+
{
|
|
997
|
+
'content-type': 'application/json; charset=utf-8',
|
|
998
|
+
origin: 'http://127.0.0.1:1162',
|
|
999
|
+
host: '127.0.0.1:1162',
|
|
1000
|
+
'sec-fetch-site': 'same-origin',
|
|
1001
|
+
},
|
|
1002
|
+
)
|
|
1003
|
+
check(sameOrigin.code === 200, 'config 路由允许同源 Origin', String(sameOrigin.code))
|
|
1004
|
+
const noOrigin = await callRoute(configHandler, 'POST', { modelGuardMode: 'audit' }, { 'content-type': 'application/json' })
|
|
1005
|
+
check(noOrigin.code === 200, 'config 路由允许无 Origin 的非浏览器客户端', String(noOrigin.code))
|
|
1006
|
+
check(configEditor.edits.length === 3, '同源与无 Origin 请求各写入一次', String(configEditor.edits.length))
|
|
1007
|
+
} catch (error) {
|
|
1008
|
+
check(false, '行为检查执行失败', String(error?.stack ?? error))
|
|
1009
|
+
} finally {
|
|
1010
|
+
await ctx.dispose()
|
|
1011
|
+
check(registry.released.includes('dev-plan'), 'dispose 时交还动态 preset disposer', registry.released.join(', '))
|
|
1012
|
+
check(webServer.handlers.size === 0, 'dispose 时移除设置页路由', String(webServer.handlers.size))
|
|
1013
|
+
check(!ctx.listeners.get('agent/created')?.length, 'dispose 时移除 agent/created 监听')
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// deep-ptc:entry 只做诊断,registry 才算可用
|
|
1017
|
+
{
|
|
1018
|
+
const entryRegistry = createFakeRegistry({ rows: [] })
|
|
1019
|
+
const entryWeb = createFakeWebServer()
|
|
1020
|
+
const entryCtx = createFakeContext({
|
|
1021
|
+
registry: entryRegistry,
|
|
1022
|
+
webServer: entryWeb,
|
|
1023
|
+
entries: [{ id: 'deep-ptc-settings', options: { name: 'dsh-deep-ptc-mode' }, fiber: { state: 1 } }],
|
|
1024
|
+
})
|
|
1025
|
+
index.apply(entryCtx.ctx, { ...modules.settings.DEFAULT_SETTINGS, developMode: 'deep-ptc' }, { verificationDelayMs: 0 })
|
|
1026
|
+
await entryCtx.flush()
|
|
1027
|
+
const entryDefinition = entryRegistry.definitions.find((d) => d.id === 'dev-plan')
|
|
1028
|
+
check(
|
|
1029
|
+
entryDefinition?.plugins.find((row) => row.id === 'tool-subagent-develop')?.config?.agentPreset === 'standard',
|
|
1030
|
+
'只有 loader entry(LOADING)时保守回退 standard',
|
|
1031
|
+
)
|
|
1032
|
+
const entryState = await callRoute(entryWeb.handlers.get('/plugins/dev-plan-presets/state'), 'GET')
|
|
1033
|
+
check(entryState.body?.fallback?.active === true, 'entry-only 时 state 显式回退')
|
|
1034
|
+
check(/没有可用的施工方式|未安装|未启用|已被移除/.test(entryState.body?.fallback?.reason ?? ''), '回退原因涵盖目录缺失', entryState.body?.fallback?.reason)
|
|
1035
|
+
await entryCtx.dispose()
|
|
1036
|
+
}
|
|
1037
|
+
{
|
|
1038
|
+
const goodRegistry = createFakeRegistry({ rows: [{ id: 'deep-ptc' }] })
|
|
1039
|
+
const goodCtx = createFakeContext({ registry: goodRegistry })
|
|
1040
|
+
index.apply(goodCtx.ctx, { ...modules.settings.DEFAULT_SETTINGS, developMode: 'deep-ptc' }, { verificationDelayMs: 0 })
|
|
1041
|
+
await goodCtx.flush()
|
|
1042
|
+
const goodDefinition = goodRegistry.definitions.find((d) => d.id === 'dev-plan')
|
|
1043
|
+
check(
|
|
1044
|
+
goodDefinition?.plugins.find((row) => row.id === 'tool-subagent-develop')?.config?.agentPreset === 'deep-ptc',
|
|
1045
|
+
'registry 中存在 deep-ptc 时 develop 使用 deep-ptc',
|
|
1046
|
+
)
|
|
1047
|
+
check(
|
|
1048
|
+
goodDefinition?.plugins.find((row) => row.id === 'tool-subagent-recon')?.config?.agentPreset === 'standard',
|
|
1049
|
+
'deep-ptc 时 recon 仍使用 standard',
|
|
1050
|
+
)
|
|
1051
|
+
await goodCtx.dispose()
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// 守门:pin
|
|
1055
|
+
{
|
|
1056
|
+
const registry2 = createFakeRegistry()
|
|
1057
|
+
const child = createFakeAgent({ id: 'child-x', parentSession: 'main', origin: 'subagent', current: undefined })
|
|
1058
|
+
const parent = createFakeAgent({ id: 'main', agentPreset: 'dev-plan', current: { provider: 'expensive', model: 'big' } })
|
|
1059
|
+
const ctx2 = createFakeContext({ registry: registry2, agents: { get: (id) => (id === 'main' ? parent.agent : child.agent) } })
|
|
1060
|
+
index.apply(ctx2.ctx, { ...modules.settings.DEFAULT_SETTINGS }, { verificationDelayMs: 0 })
|
|
1061
|
+
await ctx2.flush()
|
|
1062
|
+
const listener = ctx2.listeners.get('agent/created')?.[0]
|
|
1063
|
+
check(typeof listener === 'function', 'pin 模式注册 agent/created')
|
|
1064
|
+
listener({ agent: child.agent })
|
|
1065
|
+
check(
|
|
1066
|
+
child.selects.length === 1 && child.selects[0].provider === 'dsh-opencode-go',
|
|
1067
|
+
'pin 模式创建时选择目标路由',
|
|
1068
|
+
JSON.stringify(child.selects),
|
|
1069
|
+
)
|
|
1070
|
+
const decision = await child.stepHandlers[0](
|
|
1071
|
+
{ modelSelection: { provider: 'other', model: 'expensive' } },
|
|
1072
|
+
async () => ({ kind: 'enter', messages: [] }),
|
|
1073
|
+
)
|
|
1074
|
+
check(decision?.kind === 'reject', 'pre-step 越界返回 reject', JSON.stringify(decision))
|
|
1075
|
+
check(child.cancelled.length === 1, 'pre-step 越界 cancel 子代理')
|
|
1076
|
+
check(parent.injected.length === 1, 'pre-step 越界通知父会话')
|
|
1077
|
+
listener({ agent: parent.agent })
|
|
1078
|
+
check(parent.selects.length === 0, '主会话永不被 select')
|
|
1079
|
+
check(child.stepHandlers.length === 1, 'pin 创建后 child 有 pre-step 守卫')
|
|
1080
|
+
await ctx2.dispose()
|
|
1081
|
+
check(child.stepHandlers.length === 0, '插件卸载时真正移除 child 的 pre-step 守卫')
|
|
1082
|
+
check(!ctx2.listeners.get('agent/created')?.length, '插件卸载时移除 agent/created 监听')
|
|
1083
|
+
check(!ctx2.listeners.get('agent/disposed')?.length, '插件卸载时移除 agent/disposed 监听')
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// 守门:select 不可用时仍保留 guard(kill=false 不 cancel,但后续越界要记录)
|
|
1087
|
+
{
|
|
1088
|
+
const registry2b = createFakeRegistry()
|
|
1089
|
+
const child = createFakeAgent({ id: 'child-no-select', parentSession: 'main', origin: 'subagent', current: undefined, select: null })
|
|
1090
|
+
const parent = createFakeAgent({ id: 'main', agentPreset: 'dev-plan', current: { provider: 'p', model: 'm' } })
|
|
1091
|
+
const web = createFakeWebServer()
|
|
1092
|
+
const ctx2b = createFakeContext({
|
|
1093
|
+
registry: registry2b,
|
|
1094
|
+
webServer: web,
|
|
1095
|
+
agents: { get: (id) => (id === 'main' ? parent.agent : child.agent) },
|
|
1096
|
+
})
|
|
1097
|
+
index.apply(ctx2b.ctx, { ...modules.settings.DEFAULT_SETTINGS, killOnViolation: false }, { verificationDelayMs: 0 })
|
|
1098
|
+
await ctx2b.flush()
|
|
1099
|
+
ctx2b.listeners.get('agent/created')[0]({ agent: child.agent })
|
|
1100
|
+
check(child.cancelled.length === 0, 'select 缺失 + kill=false 不 cancel 子代理')
|
|
1101
|
+
check(child.stepHandlers.length === 1, 'select 缺失 + kill=false 仍装 pre-step 守卫')
|
|
1102
|
+
const decision = await child.stepHandlers[0](
|
|
1103
|
+
{ modelSelection: { provider: 'other', model: 'expensive' } },
|
|
1104
|
+
async () => ({ kind: 'enter', messages: [] }),
|
|
1105
|
+
)
|
|
1106
|
+
check(decision?.kind === 'enter', 'select 缺失 + kill=false 不打断后续 pre-step')
|
|
1107
|
+
const state = await callRoute(web.handlers.get('/plugins/dev-plan-presets/state'), 'GET')
|
|
1108
|
+
check(state.body?.violations?.some((entry) => /越界/.test(entry.text)), 'select 缺失后守卫仍记录越界')
|
|
1109
|
+
await ctx2b.dispose()
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
// 守门:audit / off / honorExplicit
|
|
1113
|
+
{
|
|
1114
|
+
const registry3 = createFakeRegistry()
|
|
1115
|
+
const child = createFakeAgent({ id: 'child-a', parentSession: 'main', origin: 'subagent', current: { provider: 'x', model: 'y' } })
|
|
1116
|
+
const parent = createFakeAgent({ id: 'main', agentPreset: 'dev-plan', current: { provider: 'p', model: 'm' } })
|
|
1117
|
+
const ctx3 = createFakeContext({ registry: registry3, agents: { get: (id) => (id === 'main' ? parent.agent : child.agent) } })
|
|
1118
|
+
index.apply(ctx3.ctx, { ...modules.settings.DEFAULT_SETTINGS, modelGuardMode: 'audit' }, { verificationDelayMs: 0 })
|
|
1119
|
+
await ctx3.flush()
|
|
1120
|
+
ctx3.listeners.get('agent/created')[0]({ agent: child.agent })
|
|
1121
|
+
check(child.selects.length === 0, 'audit 模式不 select')
|
|
1122
|
+
const decision = await child.stepHandlers[0](
|
|
1123
|
+
{ modelSelection: { provider: 'x', model: 'y' } },
|
|
1124
|
+
async () => ({ kind: 'enter', messages: [] }),
|
|
1125
|
+
)
|
|
1126
|
+
check(decision?.kind === 'enter', 'audit 模式不打断')
|
|
1127
|
+
await ctx3.dispose()
|
|
1128
|
+
}
|
|
1129
|
+
{
|
|
1130
|
+
const ctx4 = createFakeContext({ registry: createFakeRegistry() })
|
|
1131
|
+
index.apply(
|
|
1132
|
+
ctx4.ctx,
|
|
1133
|
+
{ ...modules.settings.DEFAULT_SETTINGS, modelGuardMode: 'off', mainToolMode: 'none' },
|
|
1134
|
+
{ verificationDelayMs: 0 },
|
|
1135
|
+
)
|
|
1136
|
+
await ctx4.flush()
|
|
1137
|
+
check(!ctx4.listeners.get('agent/created'), 'off 模式不注册 agent/created')
|
|
1138
|
+
await ctx4.dispose()
|
|
1139
|
+
}
|
|
1140
|
+
{
|
|
1141
|
+
const registry5 = createFakeRegistry()
|
|
1142
|
+
const child = createFakeAgent({ id: 'child-e', parentSession: 'main', origin: 'subagent', current: { provider: 'explicit', model: 'route' } })
|
|
1143
|
+
const parent = createFakeAgent({ id: 'main', agentPreset: 'dev-plan', current: { provider: 'p', model: 'm' } })
|
|
1144
|
+
const ctx5 = createFakeContext({ registry: registry5, agents: { get: (id) => (id === 'main' ? parent.agent : child.agent) } })
|
|
1145
|
+
index.apply(ctx5.ctx, { ...modules.settings.DEFAULT_SETTINGS, honorExplicit: true }, { verificationDelayMs: 0 })
|
|
1146
|
+
await ctx5.flush()
|
|
1147
|
+
ctx5.listeners.get('agent/created')[0]({ agent: child.agent })
|
|
1148
|
+
check(child.selects.length === 0, 'honorExplicit 尊重显式路由(不 select)')
|
|
1149
|
+
check(child.stepHandlers.length === 0, 'honorExplicit 不为显式路由挂打断守卫')
|
|
1150
|
+
await ctx5.dispose()
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// 守门范围:默认只守 dev-plan 父会话;global 恢复全局;父 preset 未知时跳过。
|
|
1154
|
+
{
|
|
1155
|
+
const runScope = async (parentPreset, global) => {
|
|
1156
|
+
const registry = createFakeRegistry()
|
|
1157
|
+
const child = createFakeAgent({ id: 'child-scope', parentSession: 'main', origin: 'subagent', current: undefined })
|
|
1158
|
+
const parent = createFakeAgent({
|
|
1159
|
+
id: 'main',
|
|
1160
|
+
agentPreset: parentPreset,
|
|
1161
|
+
current: { provider: 'p', model: 'm' },
|
|
1162
|
+
})
|
|
1163
|
+
const ctx = createFakeContext({
|
|
1164
|
+
registry,
|
|
1165
|
+
agents: { get: (id) => (id === 'main' ? parent.agent : child.agent) },
|
|
1166
|
+
})
|
|
1167
|
+
index.apply(ctx.ctx, { ...modules.settings.DEFAULT_SETTINGS, guardAllSubagents: global }, { verificationDelayMs: 0 })
|
|
1168
|
+
await ctx.flush()
|
|
1169
|
+
ctx.listeners.get('agent/created')[0]({ agent: child.agent })
|
|
1170
|
+
const guarded = child.stepHandlers.length === 1
|
|
1171
|
+
await ctx.dispose()
|
|
1172
|
+
return guarded
|
|
1173
|
+
}
|
|
1174
|
+
check((await runScope('dev-plan', false)) === true, '默认守 dev-plan 父会话的子代理')
|
|
1175
|
+
check((await runScope('standard', false)) === false, '默认跳过非 dev-plan 父会话')
|
|
1176
|
+
check((await runScope(undefined, false)) === false, '父 preset 未知时跳过守门')
|
|
1177
|
+
check((await runScope('standard', true)) === true, 'guardAllSubagents=true 恢复全局守门')
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// fork 形主对话:有 parentSession 但 depth 0、无 origin,不得被守。
|
|
1181
|
+
{
|
|
1182
|
+
const registry = createFakeRegistry()
|
|
1183
|
+
const fork = createFakeAgent({
|
|
1184
|
+
id: 'fork-main',
|
|
1185
|
+
parentSession: 'main',
|
|
1186
|
+
isSeeded: true,
|
|
1187
|
+
delegationDepth: 0,
|
|
1188
|
+
current: undefined,
|
|
1189
|
+
})
|
|
1190
|
+
const parent = createFakeAgent({ id: 'main', agentPreset: 'dev-plan', current: { provider: 'p', model: 'm' } })
|
|
1191
|
+
const ctx = createFakeContext({
|
|
1192
|
+
registry,
|
|
1193
|
+
agents: { get: (id) => (id === 'main' ? parent.agent : fork.agent) },
|
|
1194
|
+
})
|
|
1195
|
+
index.apply(ctx.ctx, { ...modules.settings.DEFAULT_SETTINGS, guardAllSubagents: true }, { verificationDelayMs: 0 })
|
|
1196
|
+
await ctx.flush()
|
|
1197
|
+
ctx.listeners.get('agent/created')[0]({ agent: fork.agent })
|
|
1198
|
+
check(fork.selects.length === 0, 'fork 主对话不被 select(即使 global)')
|
|
1199
|
+
check(fork.stepHandlers.length === 0, 'fork 主对话不挂 pre-step(即使 global)')
|
|
1200
|
+
await ctx.dispose()
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// 模型目录:真实枚举 + 单 provider 失败局部降级。
|
|
1204
|
+
{
|
|
1205
|
+
const registry = createFakeRegistry()
|
|
1206
|
+
const web = createFakeWebServer()
|
|
1207
|
+
const llm = {
|
|
1208
|
+
listProviders: () => [
|
|
1209
|
+
{ id: 'alpha', name: 'Alpha' },
|
|
1210
|
+
{ id: 'broken', name: 'Broken' },
|
|
1211
|
+
],
|
|
1212
|
+
listModels: async (id) => {
|
|
1213
|
+
if (id === 'broken') throw new Error('missing credentials')
|
|
1214
|
+
return [{ id: 'alpha-1', name: 'Alpha One' }]
|
|
1215
|
+
},
|
|
1216
|
+
}
|
|
1217
|
+
const ctx = createFakeContext({ registry, webServer: web, llm })
|
|
1218
|
+
index.apply(ctx.ctx, { ...modules.settings.DEFAULT_SETTINGS }, { verificationDelayMs: 0 })
|
|
1219
|
+
await ctx.flush()
|
|
1220
|
+
const stateHandler = web.handlers.get('/plugins/dev-plan-presets/state')
|
|
1221
|
+
await callRoute(stateHandler, 'GET')
|
|
1222
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
1223
|
+
await ctx.flush()
|
|
1224
|
+
const state = await callRoute(stateHandler, 'GET')
|
|
1225
|
+
check(state.body?.modelCatalog?.providers?.length === 2, 'state 返回 2 个 provider', String(state.body?.modelCatalog?.providers?.length))
|
|
1226
|
+
check(
|
|
1227
|
+
state.body?.modelCatalog?.providers?.find((item) => item.provider === 'alpha')?.models?.[0]?.model === 'alpha-1',
|
|
1228
|
+
'state 返回 provider 下的 model',
|
|
1229
|
+
)
|
|
1230
|
+
check(
|
|
1231
|
+
state.body?.modelCatalog?.failures?.some((item) => item.provider === 'broken'),
|
|
1232
|
+
'单 provider 失败进入 failures',
|
|
1233
|
+
)
|
|
1234
|
+
await ctx.dispose()
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
return results
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
function syntaxCheck(file) {
|
|
1241
|
+
const result = spawnSync(process.execPath, ['--check', file], { stdio: 'ignore' })
|
|
1242
|
+
return { ok: result.status === 0, status: result.status, error: result.error?.message }
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// ── 变异层 ──────────────────────────────────────────────────────────────────
|
|
1246
|
+
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
1247
|
+
|
|
1248
|
+
const MUTATIONS = [
|
|
1249
|
+
{
|
|
1250
|
+
name: 'develop 工具被改名(四工具合同破坏)',
|
|
1251
|
+
expect: '四个委派工具是 recon/review/scribe/develop',
|
|
1252
|
+
mutate(surface) {
|
|
1253
|
+
findTool(surface.standard, 'develop').config.toolName = 'subagent'
|
|
1254
|
+
},
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
name: 'develop 默认改成非 standard',
|
|
1258
|
+
expect: 'develop 默认使用 standard',
|
|
1259
|
+
mutate(surface) {
|
|
1260
|
+
findTool(surface.standard, 'develop').config.agentPreset = 'ptc'
|
|
1261
|
+
},
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
name: '主窗(none)被加回 fs 工具',
|
|
1265
|
+
expect: '主窗(none)不挂载',
|
|
1266
|
+
mutate(surface) {
|
|
1267
|
+
surface.noneMode.plugins.push({ id: 'tool-fs', name: '@deepseek-ai/dsh-tool-fs' })
|
|
1268
|
+
},
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
name: 'persona(none) 删掉“永不亲自写代码”',
|
|
1272
|
+
expect: 'persona(none) 说明主窗永不亲自写代码',
|
|
1273
|
+
mutate(surface) {
|
|
1274
|
+
const row = findPresetPlugin(surface.noneMode, 'persona')
|
|
1275
|
+
row.config.prefix = row.config.prefix.replaceAll('永不亲自读写仓库、写代码或跑 Shell', '应当亲自写代码')
|
|
1276
|
+
},
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
name: 'persona(默认 ask-edit) 删掉“必须先获用户本轮明确同意”',
|
|
1280
|
+
expect: 'persona(默认 ask-edit) 写改必须先获用户同意',
|
|
1281
|
+
mutate(surface) {
|
|
1282
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1283
|
+
row.config.prefix = row.config.prefix.replaceAll('必须先获用户本轮明确同意“主窗直接改”', '可以直接改代码')
|
|
1284
|
+
},
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
name: 'persona 删掉固定 developer 名',
|
|
1288
|
+
expect: 'persona 固定 developer',
|
|
1289
|
+
mutate(surface) {
|
|
1290
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1291
|
+
row.config.prefix = row.config.prefix.replaceAll('name=developer', 'name=worker')
|
|
1292
|
+
row.config.suffix = row.config.suffix.replaceAll('name=developer', 'name=worker')
|
|
1293
|
+
},
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
name: 'persona 删掉“不向人类提问”',
|
|
1297
|
+
expect: 'develop 不向人类提问',
|
|
1298
|
+
mutate(surface) {
|
|
1299
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1300
|
+
row.config.prefix = row.config.prefix.replaceAll('不向人类提问', '可以直接问人类')
|
|
1301
|
+
},
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
name: '回退描述被静默(删掉“已回退 standard”)',
|
|
1305
|
+
expect: '回退 description 写明「已回退 standard」',
|
|
1306
|
+
mutate(surface) {
|
|
1307
|
+
surface.fallback.description = surface.fallback.description.replaceAll('已回退 standard', 'standard')
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
name: '四个工具路由不一致',
|
|
1312
|
+
expect: '四个工具共用同一路由',
|
|
1313
|
+
mutate(surface) {
|
|
1314
|
+
findTool(surface.standard, 'recon').config.agentOptions.model = 'deepseek-chat'
|
|
1315
|
+
},
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
name: '给 develop 加 allowedAgentPresets',
|
|
1319
|
+
expect: '不设 allowedAgentPresets',
|
|
1320
|
+
mutate(surface) {
|
|
1321
|
+
findTool(surface.standard, 'develop').config.allowedAgentPresets = ['standard', 'deep-ptc']
|
|
1322
|
+
},
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
name: '根补丁重新静态注册 preset',
|
|
1326
|
+
expect: '根补丁不再静态注册 dsh-agent-preset',
|
|
1327
|
+
mutate(surface) {
|
|
1328
|
+
surface.patchText += "\n- id: preset-dev-plan\n name: '@deepseek-ai/dsh-agent-preset'\n"
|
|
1329
|
+
},
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
name: 'README 删掉旧模型钉迁移说明',
|
|
1333
|
+
expect: 'README 含关键说明:dsh-subagent-model-pin',
|
|
1334
|
+
mutate(surface) {
|
|
1335
|
+
surface.readme = surface.readme.replaceAll('dsh-subagent-model-pin', 'some-old-plugin')
|
|
1336
|
+
},
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
name: 'package.json 增加 deep-ptc 依赖',
|
|
1340
|
+
expect: '不依赖 deep-ptc 包',
|
|
1341
|
+
mutate(surface) {
|
|
1342
|
+
surface.pkg.dependencies = { 'dsh-deep-ptc-mode': '^1.0.0' }
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
name: 'client 注册 key 写错',
|
|
1347
|
+
expect: 'client 注册 key=dsh-dev-plan-presets#dev-plan-presets',
|
|
1348
|
+
mutate(surface) {
|
|
1349
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1350
|
+
'dsh-dev-plan-presets#dev-plan-presets',
|
|
1351
|
+
'dsh-subagent-model-pin#subagent-model-pin',
|
|
1352
|
+
)
|
|
1353
|
+
},
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
name: 'persona 超过 6000 字符预算',
|
|
1357
|
+
expect: 'persona 长度在性能预算内',
|
|
1358
|
+
mutate(surface) {
|
|
1359
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1360
|
+
row.config.prefix += '冗余文本'.repeat(1000)
|
|
1361
|
+
},
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
name: '主窗重新内联 ROLE-TEMPLATE 长模板',
|
|
1365
|
+
expect: '主窗 prefix 不再使用旧的千字长模板',
|
|
1366
|
+
mutate(surface) {
|
|
1367
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1368
|
+
row.config.prefix += '\n===== ROLE-TEMPLATE:SCOUT:BEGIN =====\n'
|
|
1369
|
+
},
|
|
1370
|
+
},
|
|
1371
|
+
{
|
|
1372
|
+
name: '子代理模板缺少“仅给子代理用”标注',
|
|
1373
|
+
expect: '主窗 persona 嵌入紧凑版子代理模板并标注仅给子代理用',
|
|
1374
|
+
mutate(surface) {
|
|
1375
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1376
|
+
row.config.prefix = row.config.prefix.replaceAll('仅给子代理用', '给主窗用')
|
|
1377
|
+
},
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
name: 'dev-plan-scout 混入 bash 工具',
|
|
1381
|
+
expect: 'dev-plan-scout 不含 @deepseek-ai/dsh-tool-bash',
|
|
1382
|
+
mutate(surface) {
|
|
1383
|
+
surface.scoutPreset.plugins.push({ id: 'tool-bash', name: '@deepseek-ai/dsh-tool-bash' })
|
|
1384
|
+
},
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
name: 'ask-edit 混入 bash 工具',
|
|
1388
|
+
expect: 'ask-edit 永不挂载 @deepseek-ai/dsh-tool-bash',
|
|
1389
|
+
mutate(surface) {
|
|
1390
|
+
surface.askEditMode.plugins.push({ id: 'tool-bash', name: '@deepseek-ai/dsh-tool-bash' })
|
|
1391
|
+
},
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
name: '双通道互斥说明被删除',
|
|
1395
|
+
expect: '双通道互斥',
|
|
1396
|
+
mutate(surface) {
|
|
1397
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1398
|
+
row.config.prefix = row.config.prefix.replaceAll(
|
|
1399
|
+
'同一任务严禁混用 develop 与 rework_task/ask_worker',
|
|
1400
|
+
'可以同时使用 develop 和 rework_task',
|
|
1401
|
+
)
|
|
1402
|
+
},
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
name: 'README 任务书退回旧 6 项摘要',
|
|
1406
|
+
expect: 'README 任务书模板含接口/依赖字段',
|
|
1407
|
+
mutate(surface) {
|
|
1408
|
+
surface.readme = String(surface.readme)
|
|
1409
|
+
.replaceAll('接口/依赖:', '接口:')
|
|
1410
|
+
.replaceAll('检查命令:', '命令:')
|
|
1411
|
+
.replaceAll('风险/回退:', '风险:')
|
|
1412
|
+
},
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
name: 'P0 证据不足时改为降低路径等级(风险方向写反)',
|
|
1416
|
+
expect: 'P0 没有“证据不足就降低路径等级”的回退指令',
|
|
1417
|
+
mutate(surface) {
|
|
1418
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1419
|
+
row.config.prefix += '\n- 可验证性:不能证明就降低路径等级并补验收。\n'
|
|
1420
|
+
},
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
name: 'P0 允许只有改动摘要也算证据',
|
|
1424
|
+
expect: 'P0 没有“摘要/文件清单就是证据”的错误说法',
|
|
1425
|
+
mutate(surface) {
|
|
1426
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1427
|
+
row.config.prefix += '\n只有改动摘要也算证据,主窗可以直接通过。\n'
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
name: 'P0 完工证据退化为改动摘要',
|
|
1432
|
+
expect: 'P0 完工必须附分层变更证据',
|
|
1433
|
+
mutate(surface) {
|
|
1434
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1435
|
+
row.config.prefix = row.config.prefix.replaceAll('分层变更证据', '改动摘要')
|
|
1436
|
+
},
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
name: 'P0 文件清单被当成证据',
|
|
1440
|
+
expect: 'P0 不能只给文件清单',
|
|
1441
|
+
mutate(surface) {
|
|
1442
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1443
|
+
row.config.prefix = row.config.prefix.replaceAll('只有文件清单或口头摘要不算审过 diff', '只给文件清单也可以作为证据')
|
|
1444
|
+
},
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
name: 'client 回退横幅漏掉加载失败',
|
|
1448
|
+
expect: 'client 回退横幅涵盖不可用原因',
|
|
1449
|
+
mutate(surface) {
|
|
1450
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('加载失败', '加载中')
|
|
1451
|
+
},
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
name: 'client 重复叠加保存失败前缀',
|
|
1455
|
+
expect: 'client 不重复叠加“保存失败”前缀',
|
|
1456
|
+
mutate(surface) {
|
|
1457
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1458
|
+
'formatted ? raw :',
|
|
1459
|
+
'false ? raw :',
|
|
1460
|
+
)
|
|
1461
|
+
},
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
name: 'client 保存状态回退为 notice.ok',
|
|
1465
|
+
expect: 'client 仅在 notice.kind=saved 时显示已保存',
|
|
1466
|
+
mutate(surface) {
|
|
1467
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1468
|
+
"notice.kind === 'saved'",
|
|
1469
|
+
'notice.ok',
|
|
1470
|
+
)
|
|
1471
|
+
},
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
name: 'client 修改字段不清旧通知',
|
|
1475
|
+
expect: 'client 修改字段时清除旧通知',
|
|
1476
|
+
mutate(surface) {
|
|
1477
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1478
|
+
'const update = (patch) => {\n setNotice(null)\n',
|
|
1479
|
+
'const update = (patch) => {\n',
|
|
1480
|
+
)
|
|
1481
|
+
},
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
name: 'client 删除网络错误指引',
|
|
1485
|
+
expect: 'client network 错误给可执行指引',
|
|
1486
|
+
mutate(surface) {
|
|
1487
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('无法连接 Host', '读取失败')
|
|
1488
|
+
},
|
|
1489
|
+
},
|
|
1490
|
+
{
|
|
1491
|
+
name: '配置写路由删除权威 origin 校验',
|
|
1492
|
+
expect: 'Host 配置写路由使用 webServer.getOrigin() 权威 origin',
|
|
1493
|
+
mutate(surface) {
|
|
1494
|
+
surface.files['index.js'] = String(surface.files['index.js']).replaceAll(
|
|
1495
|
+
'webServer.getOrigin()',
|
|
1496
|
+
'webServer.port',
|
|
1497
|
+
)
|
|
1498
|
+
},
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
name: 'client 恢复硬编码颜色',
|
|
1502
|
+
expect: 'client 不保留 hex/rgba 字面颜色',
|
|
1503
|
+
mutate(surface) {
|
|
1504
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1505
|
+
'var(--dsw-alias-label-primary)',
|
|
1506
|
+
'#333333',
|
|
1507
|
+
)
|
|
1508
|
+
},
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
name: 'client 恢复 navigator.language',
|
|
1512
|
+
expect: 'client 不使用 navigator.language',
|
|
1513
|
+
mutate(surface) {
|
|
1514
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1515
|
+
"const API = '/plugins/dev-plan-presets'",
|
|
1516
|
+
"const API = '/plugins/dev-plan-presets'\nconst legacy = navigator.language",
|
|
1517
|
+
)
|
|
1518
|
+
},
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
name: 'client 404 指引被删除',
|
|
1522
|
+
expect: 'client 404 给出可执行指引',
|
|
1523
|
+
mutate(surface) {
|
|
1524
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('设置路由未注册', '路由错误')
|
|
1525
|
+
},
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
name: 'guard 回到 parentSession 判定 fork 为主对话',
|
|
1529
|
+
expect: 'guard 只认 origin=subagent 或 delegationDepth>0',
|
|
1530
|
+
mutate(surface) {
|
|
1531
|
+
surface.files['guard.js'] = String(surface.files['guard.js']).replace(
|
|
1532
|
+
"if (header.origin === 'subagent') return true",
|
|
1533
|
+
"if (header.parentSession) return true",
|
|
1534
|
+
)
|
|
1535
|
+
},
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
name: '模型目录 TTL 退回 8s(/state 周期性阻塞)',
|
|
1539
|
+
expect: '模型目录使用 60s 快照 + 后台刷新',
|
|
1540
|
+
mutate(surface) {
|
|
1541
|
+
surface.files['index.js'] = String(surface.files['index.js']).replace(
|
|
1542
|
+
'MODEL_CATALOG_TTL_MS = 60_000',
|
|
1543
|
+
'MODEL_CATALOG_TTL_MS = 8000',
|
|
1544
|
+
)
|
|
1545
|
+
},
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
name: 'client 删除 presetChoices 纯函数',
|
|
1549
|
+
expect: 'client 从 /state 读取模型目录并用纯选择函数',
|
|
1550
|
+
mutate(surface) {
|
|
1551
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll(
|
|
1552
|
+
'presetChoices',
|
|
1553
|
+
'removedChoices',
|
|
1554
|
+
)
|
|
1555
|
+
},
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
name: 'guard 不再监听 agent/disposed',
|
|
1559
|
+
expect: '模型守门监听 agent/disposed 清理 step guard',
|
|
1560
|
+
mutate(surface) {
|
|
1561
|
+
surface.files['guard.js'] = String(surface.files['guard.js']).replaceAll("'agent/disposed'", "'agent/ignored'")
|
|
1562
|
+
},
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
name: '配置写路由删除 Sec-Fetch-Site 校验',
|
|
1566
|
+
expect: 'Host 配置写路由做 Origin/Sec-Fetch-Site 校验',
|
|
1567
|
+
mutate(surface) {
|
|
1568
|
+
surface.files['index.js'] = String(surface.files['index.js']).replaceAll('sec-fetch-site', 'sec-fetch-mode')
|
|
1569
|
+
},
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
name: 'P0 授权后只写任务书、不实际调用 develop',
|
|
1573
|
+
expect: 'P0 授权后必须实际调用 develop',
|
|
1574
|
+
mutate(surface) {
|
|
1575
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1576
|
+
row.config.prefix = row.config.prefix.replaceAll('实际调用 develop', '实际写任务书')
|
|
1577
|
+
row.config.suffix = row.config.suffix.replaceAll('实际调用 develop', '实际写任务书')
|
|
1578
|
+
},
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
name: 'P0 文本任务书被当成派工事实',
|
|
1582
|
+
expect: 'P0 文本不是派工',
|
|
1583
|
+
mutate(surface) {
|
|
1584
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1585
|
+
row.config.prefix = row.config.prefix.replaceAll('文本不是派工', '文本也能算派工')
|
|
1586
|
+
row.config.suffix = row.config.suffix.replaceAll('文本不是派工', '文本也能算派工')
|
|
1587
|
+
},
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
name: 'P0 工具未接受也可声称已派出',
|
|
1591
|
+
expect: 'P0 工具接受后才可称已派出',
|
|
1592
|
+
mutate(surface) {
|
|
1593
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1594
|
+
row.config.prefix = row.config.prefix.replaceAll('已派出 developer', '已直接派出')
|
|
1595
|
+
row.config.suffix = row.config.suffix.replaceAll('已派出 developer', '已直接派出')
|
|
1596
|
+
},
|
|
1597
|
+
},
|
|
1598
|
+
{
|
|
1599
|
+
name: 'P0 删除未派工报告',
|
|
1600
|
+
expect: 'P0 未派工如实报告',
|
|
1601
|
+
mutate(surface) {
|
|
1602
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1603
|
+
row.config.prefix = row.config.prefix.replaceAll('未派工:原因', '已派工')
|
|
1604
|
+
row.config.suffix = row.config.suffix.replaceAll('未派工:原因', '已派工')
|
|
1605
|
+
},
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
name: 'preset 显示名回退为旧名',
|
|
1609
|
+
expect: 'preset 显示名为「开发规划与交付」',
|
|
1610
|
+
mutate(surface) {
|
|
1611
|
+
surface.standard.name = '开发规划'
|
|
1612
|
+
},
|
|
1613
|
+
},
|
|
1614
|
+
{
|
|
1615
|
+
name: 'locale/zh 插件显示名回退为旧名',
|
|
1616
|
+
expect: 'locale/zh 插件显示名为「开发规划与交付模式」',
|
|
1617
|
+
mutate(surface) {
|
|
1618
|
+
surface.locale.zh.meta.title = '开发规划与交付'
|
|
1619
|
+
},
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
name: 'client 标题回退为旧名',
|
|
1623
|
+
expect: 'client 设置页标题使用预设名「开发规划与交付」',
|
|
1624
|
+
mutate(surface) {
|
|
1625
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll(
|
|
1626
|
+
'开发规划与交付 · 施工设置',
|
|
1627
|
+
'开发规划 · 施工设置',
|
|
1628
|
+
)
|
|
1629
|
+
},
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
name: 'README 重新声称显示名未定',
|
|
1633
|
+
expect: 'README 不再声称显示名未定',
|
|
1634
|
+
mutate(surface) {
|
|
1635
|
+
surface.readme = String(surface.readme).replace('显示名已定', '显示名未定')
|
|
1636
|
+
},
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
name: 'P0 快速路径被删除',
|
|
1640
|
+
expect: 'P0 风险路由含快速路径',
|
|
1641
|
+
mutate(surface) {
|
|
1642
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1643
|
+
row.config.prefix = row.config.prefix.replaceAll('快速路径', '慢速路径')
|
|
1644
|
+
},
|
|
1645
|
+
},
|
|
1646
|
+
{
|
|
1647
|
+
name: 'P0 一次性契约的接口/依赖字段被删除',
|
|
1648
|
+
expect: '任务书含接口/依赖',
|
|
1649
|
+
mutate(surface) {
|
|
1650
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1651
|
+
row.config.prefix = row.config.prefix.replaceAll('接口与兼容约束', '接口')
|
|
1652
|
+
},
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
name: 'P0 静态检查冒充真实验证的禁令被删除',
|
|
1656
|
+
expect: 'P0 禁止静态检查冒充真实验证',
|
|
1657
|
+
mutate(surface) {
|
|
1658
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1659
|
+
row.config.prefix = row.config.prefix.replaceAll('静态检查/单测不等于真实运行验收', '静态检查可以代表真实验证')
|
|
1660
|
+
},
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
name: 'P0 主窗非阻塞(不轮询)被删除',
|
|
1664
|
+
expect: 'P0 主窗不轮询',
|
|
1665
|
+
mutate(surface) {
|
|
1666
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1667
|
+
row.config.prefix = row.config.prefix.replaceAll('不轮询', '可以轮询')
|
|
1668
|
+
},
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
name: 'P0 验证状态分级被改成二值',
|
|
1672
|
+
expect: 'P0 汇报含验证状态分级',
|
|
1673
|
+
mutate(surface) {
|
|
1674
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1675
|
+
row.config.prefix = row.config.prefix.replaceAll('verified|partial|failed|未验证', '通过/失败')
|
|
1676
|
+
},
|
|
1677
|
+
},
|
|
1678
|
+
{
|
|
1679
|
+
name: 'P0 最终审查责任被外包',
|
|
1680
|
+
expect: 'P0 最终审查责任不外包',
|
|
1681
|
+
mutate(surface) {
|
|
1682
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1683
|
+
row.config.prefix = row.config.prefix.replaceAll('review 不替代主窗最终审查', '主窗最终审查可外包给 review')
|
|
1684
|
+
},
|
|
1685
|
+
},
|
|
1686
|
+
{
|
|
1687
|
+
name: '版本号未更新',
|
|
1688
|
+
expect: 'version=0.4.0',
|
|
1689
|
+
mutate(surface) {
|
|
1690
|
+
surface.pkg.version = '0.3.0'
|
|
1691
|
+
},
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
name: 'index 恢复冗余二次复检条件',
|
|
1695
|
+
expect: 'index.js scheduleVerification 跳过已命中目标时的冗余二次全量探测',
|
|
1696
|
+
mutate(surface) {
|
|
1697
|
+
surface.files['index.js'] = String(surface.files['index.js']).replace(
|
|
1698
|
+
'state.mode?.fallback === true || state.presets.checked !== true',
|
|
1699
|
+
"settings.developMode !== 'standard' || state.presets.checked !== true",
|
|
1700
|
+
)
|
|
1701
|
+
},
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
name: 'client 删除 mainToolMode 控件',
|
|
1705
|
+
expect: 'client 设置页包含字段 mainToolMode',
|
|
1706
|
+
mutate(surface) {
|
|
1707
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('mainToolMode', 'removedMode')
|
|
1708
|
+
},
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
name: '默认 guardAllSubagents 改成全局',
|
|
1712
|
+
expect: 'settings 默认 guardAllSubagents=false',
|
|
1713
|
+
mutate(surface) {
|
|
1714
|
+
surface.files['settings.js'] = String(surface.files['settings.js']).replace(
|
|
1715
|
+
'guardAllSubagents: false,',
|
|
1716
|
+
'guardAllSubagents: true,',
|
|
1717
|
+
)
|
|
1718
|
+
},
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
name: 'client 硬编码 deep-ptc 选项',
|
|
1722
|
+
expect: 'client 不再硬编码 deep-ptc 选项',
|
|
1723
|
+
mutate(surface) {
|
|
1724
|
+
surface.files['client.js'] = String(surface.files['client.js']).replace(
|
|
1725
|
+
"const API = '/plugins/dev-plan-presets'",
|
|
1726
|
+
"const API = '/plugins/dev-plan-presets'\nconst legacyPreset = { value: 'deep-ptc' }",
|
|
1727
|
+
)
|
|
1728
|
+
},
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
name: 'client 不再读取模型目录',
|
|
1732
|
+
expect: 'client 从 /state 读取模型目录',
|
|
1733
|
+
mutate(surface) {
|
|
1734
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('state.modelCatalog', 'state.models')
|
|
1735
|
+
},
|
|
1736
|
+
},
|
|
1737
|
+
{
|
|
1738
|
+
name: 'client 删除 label/帮助文本关联',
|
|
1739
|
+
expect: 'client 使用 label for 与帮助文本关联',
|
|
1740
|
+
mutate(surface) {
|
|
1741
|
+
surface.files['client.js'] = String(surface.files['client.js']).replaceAll('htmlFor', 'data-for')
|
|
1742
|
+
},
|
|
1743
|
+
},
|
|
1744
|
+
{
|
|
1745
|
+
name: '权限防护规则被删除',
|
|
1746
|
+
expect: 'persona 禁止先建后 cd',
|
|
1747
|
+
mutate(surface) {
|
|
1748
|
+
const row = findPresetPlugin(surface.standard, 'persona')
|
|
1749
|
+
row.config.prefix = row.config.prefix.replaceAll('working_directory', 'other_dir')
|
|
1750
|
+
},
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
name: 'dev-plan 自引用不再回退',
|
|
1754
|
+
expect: 'dev-plan 自身被拒绝,避免递归',
|
|
1755
|
+
mutate(surface) {
|
|
1756
|
+
surface.selfFallback.fallback = false
|
|
1757
|
+
surface.selfFallback.reason = ''
|
|
1758
|
+
},
|
|
1759
|
+
},
|
|
1760
|
+
{
|
|
1761
|
+
name: '任意 preset 被限制回 standard',
|
|
1762
|
+
expect: '任意有效 preset 可作 develop',
|
|
1763
|
+
mutate(surface) {
|
|
1764
|
+
findTool(surface.custom, 'develop').config.agentPreset = 'standard'
|
|
1765
|
+
},
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
name: 'Host 不返回预设目录',
|
|
1769
|
+
expect: 'Host 返回真实预设目录',
|
|
1770
|
+
mutate(surface) {
|
|
1771
|
+
surface.files['index.js'] = String(surface.files['index.js']).replaceAll('presets:', 'presetRows:')
|
|
1772
|
+
},
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
name: '代码里重新引入 @deepseek-ai import',
|
|
1776
|
+
expect: 'index.js 不 import @deepseek-ai/*',
|
|
1777
|
+
mutate(surface) {
|
|
1778
|
+
surface.files['index.js'] = "import z from '@deepseek-ai/schemastery'\n" + surface.files['index.js']
|
|
1779
|
+
},
|
|
1780
|
+
},
|
|
1781
|
+
]
|
|
1782
|
+
|
|
1783
|
+
async function main() {
|
|
1784
|
+
const surface = await loadSurface()
|
|
1785
|
+
const results = checksFor(surface)
|
|
1786
|
+
for (const item of results) {
|
|
1787
|
+
if (!item.ok) console.log(`FAIL ${item.label}${item.detail ? ` — ${item.detail}` : ''}`)
|
|
1788
|
+
else if (VERBOSE) console.log(`PASS ${item.label}${item.detail ? ` — ${item.detail}` : ''}`)
|
|
1789
|
+
}
|
|
1790
|
+
const failures = results.filter((item) => !item.ok).length
|
|
1791
|
+
console.log('')
|
|
1792
|
+
console.log(`静态合同检查:${results.length - failures} 通过 / ${failures} 失败`)
|
|
1793
|
+
|
|
1794
|
+
// 语法层
|
|
1795
|
+
let syntaxOk = true
|
|
1796
|
+
for (const file of RUNTIME_FILES) {
|
|
1797
|
+
const result = syntaxCheck(join(ROOT, file))
|
|
1798
|
+
console.log(`node --check ${file}:${result.ok ? 'PASS' : `FAIL(status=${result.status}${result.error ? `, ${result.error}` : ''})`}`)
|
|
1799
|
+
if (!result.ok) syntaxOk = false
|
|
1800
|
+
}
|
|
1801
|
+
// 元检查:证明 --check 闸门不是恒通过。故意写坏一个临时文件,必须 FAIL。
|
|
1802
|
+
const metaDir = join(ROOT, '.verify-tmp')
|
|
1803
|
+
mkdirSync(metaDir, { recursive: true })
|
|
1804
|
+
const brokenFile = join(metaDir, 'broken-syntax.mjs')
|
|
1805
|
+
writeFileSync(brokenFile, 'export const = ;\n', 'utf8')
|
|
1806
|
+
const brokenSyntax = syntaxCheck(brokenFile)
|
|
1807
|
+
rmSync(metaDir, { recursive: true, force: true })
|
|
1808
|
+
const syntaxGateOk = !brokenSyntax.ok
|
|
1809
|
+
console.log(`语法闸门自检(坏文件必须 FAIL):${syntaxGateOk ? 'PASS' : 'FAIL'}`)
|
|
1810
|
+
syntaxOk = syntaxOk && syntaxGateOk
|
|
1811
|
+
|
|
1812
|
+
// 行为层
|
|
1813
|
+
const behavior = await behaviorChecks()
|
|
1814
|
+
for (const item of behavior) {
|
|
1815
|
+
if (!item.ok) console.log(`FAIL ${item.label}${item.detail ? ` — ${item.detail}` : ''}`)
|
|
1816
|
+
else if (VERBOSE) console.log(`PASS ${item.label}`)
|
|
1817
|
+
}
|
|
1818
|
+
const behaviorFailures = behavior.filter((item) => !item.ok).length
|
|
1819
|
+
console.log(`真实模块行为检查:${behavior.length - behaviorFailures} 通过 / ${behaviorFailures} 失败`)
|
|
1820
|
+
|
|
1821
|
+
// 变异层
|
|
1822
|
+
let detected = 0
|
|
1823
|
+
const missed = []
|
|
1824
|
+
for (const mutation of MUTATIONS) {
|
|
1825
|
+
const mutated = clone(surface)
|
|
1826
|
+
let outcome
|
|
1827
|
+
try {
|
|
1828
|
+
mutation.mutate(mutated)
|
|
1829
|
+
outcome = checksFor(mutated)
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
missed.push(`${mutation.name}(变异本身抛错:${String(error?.message ?? error)})`)
|
|
1832
|
+
continue
|
|
1833
|
+
}
|
|
1834
|
+
const hits = outcome.filter((item) => !item.ok && item.label.includes(mutation.expect))
|
|
1835
|
+
if (hits.length > 0) {
|
|
1836
|
+
detected += 1
|
|
1837
|
+
if (VERBOSE) console.log(`PASS 变异:${mutation.name} ← ${hits.map((item) => item.label).join(';')}`)
|
|
1838
|
+
} else {
|
|
1839
|
+
missed.push(`${mutation.name}(期望 ${mutation.expect} 报错,实际未报)`)
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
console.log(`负向变异:${detected}/${MUTATIONS.length} 检出`)
|
|
1843
|
+
for (const item of missed) console.log(`FAIL ${item}`)
|
|
1844
|
+
|
|
1845
|
+
const ok = failures === 0 && syntaxOk && behaviorFailures === 0 && missed.length === 0
|
|
1846
|
+
console.log('')
|
|
1847
|
+
console.log(`结论:${ok ? 'PASS(声明层 + 代码层 + 行为层;宿主/GUI 运行期行为见 README「验证」手工清单)' : 'FAIL'}`)
|
|
1848
|
+
process.exit(ok ? 0 : 1)
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
const invokedDirectly =
|
|
1852
|
+
process.argv[1] &&
|
|
1853
|
+
pathToFileURL(resolve(process.argv[1])).href === pathToFileURL(fileURLToPath(import.meta.url)).href
|
|
1854
|
+
if (invokedDirectly) await main()
|