dsh-soul 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -19
  3. package/README_EN.md +36 -19
  4. package/assets/personas/custom-placeholder.webp +0 -0
  5. package/assets/personas/placeholder.svg +16 -0
  6. package/assets/personas//344/270/245/346/240/274/344/273/243/347/240/201/345/256/241/351/230/205/350/200/205.webp +0 -0
  7. package/assets/personas//345/244/264/350/204/221/351/243/216/346/232/264/344/274/231/344/274/264.webp +0 -0
  8. package/assets/personas//346/225/231/345/255/246/345/236/213/350/256/262/350/247/243/350/200/205.webp +0 -0
  9. package/assets/personas//346/236/201/347/256/200/344/270/273/344/271/211/350/200/205.webp +0 -0
  10. package/assets/personas//350/207/252/351/251/261/345/236/213/345/215/217/344/275/234/350/200/205.webp +0 -0
  11. package/assets/personas//350/213/217/346/240/274/346/213/211/345/272/225/345/274/217/346/217/220/351/227/256/350/200/205.webp +0 -0
  12. package/assets/personas//350/265/204/346/267/261/346/236/266/346/236/204/345/270/210.webp +0 -0
  13. package/client/index.mjs +1169 -214
  14. package/index.mjs +732 -85
  15. package/lib/config.mjs +42 -6
  16. package/lib/injection.mjs +2 -2
  17. package/lib/personas.mjs +62 -25
  18. package/lib/store.mjs +125 -0
  19. package/locale/en.json +6 -0
  20. package/locale/zh.json +6 -0
  21. package/package.json +13 -2
  22. package/scripts/lib/skip-report.mjs +73 -0
  23. package/scripts/verify-client.mjs +1319 -0
  24. package/scripts/verify-compat.mjs +58 -9
  25. package/scripts/verify-config.mjs +2116 -44
  26. package/scripts/verify-e2e-prompt.mjs +627 -0
  27. package/scripts/verify-live-prompt.mjs +445 -0
  28. package/scripts/verify-nav-icon.mjs +35 -7
  29. package/scripts/verify-store.mjs +310 -0
  30. package/scripts/verify-trail.mjs +21 -8
@@ -33,6 +33,12 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
33
33
  import { dirname, join, resolve } from 'node:path'
34
34
  import { homedir } from 'node:os'
35
35
  import { createInjectionSource } from '../lib/injection.mjs'
36
+ import { skipExit, skipNote, assertCount } from './lib/skip-report.mjs'
37
+
38
+ // 定位到 DSH 时本脚本会跑出的检查数(peer 范围判定 + 运行时符号抽查 + 注入来源契约)。
39
+ // 各环境解析到的子包数量可能略有出入,因此这里只用于「跳过时如实说明少跑了多少」,
40
+ // 不做严格相等校验。
41
+ const NOMINAL_ASSERTIONS = 10
36
42
 
37
43
  const HERE = dirname(fileURLToPath(import.meta.url))
38
44
  const PKG_DIR = resolve(HERE, '..')
@@ -176,6 +182,10 @@ const isCheckedPeer = (name) => name === '@deepseek-ai/dsh' || name.startsWith('
176
182
  // ==================== 主流程 ====================
177
183
 
178
184
  async function main() {
185
+ // 本次真正执行 / 因环境缺失未执行的断言数(尾部对账用,见文件末说明)
186
+ let passed = 0
187
+ let skipped = 0
188
+ let strictSkips = 0
179
189
  console.log(`dsh-soul v${MANIFEST.version} — DSH 兼容性自检`)
180
190
  console.log('')
181
191
 
@@ -211,9 +221,12 @@ async function main() {
211
221
  }
212
222
 
213
223
  if (!runtimeVersion) {
214
- console.log('跳过:未能定位 DSH 运行时。')
215
- console.log('可用 --dsh <目录> 指定 DSH 安装目录,或用 --runtime <版本> 直接给出运行时版本。')
216
- process.exit(0)
224
+ skipExit(
225
+ 'verify-compat(兼容性判定)',
226
+ NOMINAL_ASSERTIONS,
227
+ '未能定位 DSH 运行时',
228
+ '--dsh <目录> 指定 DSH 安装目录,或用 --runtime <版本> 直接给出运行时版本'
229
+ )
217
230
  }
218
231
 
219
232
  console.log(`DSH 运行时版本:${runtimeVersion}`)
@@ -236,6 +249,7 @@ async function main() {
236
249
  console.log(` – 忽略 ${name.padEnd(30)} ${range} (DSH 不校验此类 peer)`)
237
250
  continue
238
251
  }
252
+ passed += 1
239
253
  let ok
240
254
  if (evalFn) {
241
255
  const issue = evalFn({ name: MANIFEST.name, version: MANIFEST.version, peerDependencies: { [name]: range } }, {}, runtimeVersion)
@@ -257,14 +271,26 @@ async function main() {
257
271
  ]
258
272
  for (const [spec, symbols] of audits) {
259
273
  const hit = await loadModule(searchAnchors, spec)
260
- if (!hit) { console.log(` – ${spec}:未解析到,跳过`); continue }
274
+ if (!hit) {
275
+ // 环境能力缺失 ⇒ 走 skipNote(--strict 下判失败),并计入「未执行」以便对账
276
+ skipped += 1
277
+ if (!skipNote('verify-compat', 1, `${spec} 未解析到,符号抽查跳过`, '安装 DSH 后重跑')) strictSkips += 1
278
+ continue
279
+ }
261
280
  const missing = symbols.filter((s) => !(s in hit.mod))
262
281
  if (missing.length) symbolMissing += missing.length
282
+ passed += 1
263
283
  console.log(` ${missing.length ? '✗' : '✓'} ${spec}:${missing.length ? '缺少 ' + missing.join(', ') : '符号齐备'}`)
264
284
  }
265
285
  for (const spec of MANIFEST.dsh?.client?.inject || []) {
266
286
  const hit = await loadModule(searchAnchors, spec)
267
- console.log(` ${hit ? '✓' : '–'} ${spec}:${hit ? '已解析' : '未解析到,跳过'}`)
287
+ if (!hit) {
288
+ skipped += 1
289
+ if (!skipNote('verify-compat', 1, `${spec} 未解析到,客户端注入项跳过`, '安装 DSH 后重跑')) strictSkips += 1
290
+ continue
291
+ }
292
+ passed += 1
293
+ console.log(` ✓ ${spec}:已解析`)
268
294
  }
269
295
 
270
296
  // ---- 注入来源契约 ----
@@ -288,6 +314,7 @@ async function main() {
288
314
  }
289
315
  for (const issue of shapeIssues) console.log(` ✗ 形状:${issue}`)
290
316
  contractFailures += shapeIssues.length
317
+ passed += 1
291
318
  if (shapeIssues.length === 0) {
292
319
  console.log(` ✓ 形状:kind=${source.kind} / form=${source.form} / sections=${source.sections.length}`)
293
320
  }
@@ -308,16 +335,23 @@ async function main() {
308
335
  source
309
336
  })
310
337
  console.log(' ✓ 构造:已用本机 dsh-llm 的 createUserMessage 生成真实注入消息')
338
+ passed += 1
311
339
  } catch (err) {
312
340
  contractFailures += 1
313
341
  console.log(` ✗ 构造:createUserMessage 拒绝了当前 source:${String((err && err.message) || err)}`)
314
342
  }
315
343
  } else {
316
- console.log(' – 构造:本机未解析到 @deepseek-ai/dsh-llm,改用形状字面量判定')
344
+ // 退化为形状字面量判定:这一项(真实构造)没验证到
345
+ skipped += 1
346
+ if (!skipNote('verify-compat', 1, '本机未解析到 @deepseek-ai/dsh-llm,改用形状字面量判定', '安装 DSH 后重跑')) strictSkips += 1
317
347
  }
318
348
 
319
349
  if (admit === null) {
320
- console.log(` – ${FORMAT_PKG}:准入校验器不可用,跳过运行时判定(仅检查形状)`)
350
+ // 校验器不可用 ⇒ 本次「运行时准入」这一项没验证。必须走 skipNote:
351
+ // 早前这里只打印一行「– 跳过」后继续,--strict 也照样 exit 0(M2)。
352
+ // 记 2 项:校验器有效性自检(guardLive)与运行时准入本身都无从判定。
353
+ skipped += 2
354
+ if (!skipNote('verify-compat', 2, `${FORMAT_PKG} 准入校验器不可用,仅检查形状(少跑:校验器自检 + 运行时准入)`, '安装含该包的 DSH 后重跑')) strictSkips += 1
321
355
  } else {
322
356
  // 有真实消息就用它,否则退回形状字面量
323
357
  const currentRow = realMessage === null
@@ -331,9 +365,14 @@ async function main() {
331
365
  guardLive = true
332
366
  }
333
367
  if (!guardLive) {
334
- console.log(' – 校验器未拒绝已废弃形态,本次判定不可信,跳过运行时判定')
368
+ // 校验器对已废弃形态不报错 ⇒ 本次判定没有判断力,不能算「通过」
369
+ skipped += 1
370
+ if (!skipNote('verify-compat', 1, '校验器未拒绝已废弃形态,运行时判定不可信', '升级 DSH 至含该准入校验的版本')) strictSkips += 1
335
371
  } else {
336
372
  console.log(" ✓ 校验器有效:已废弃的 kind:'plugin' 确实被拒绝(issue #1 的复现条件)")
373
+ passed += 1
374
+ // 运行时准入这一项**已执行**(无论通过与否都算跑过;不通过会进 contractFailures)
375
+ passed += 1
337
376
  try {
338
377
  admit(currentRow, new Set(['user/message']))
339
378
  console.log(` ✓ 通过 ${source.kind}:当前注入来源可被本运行时接纳`)
@@ -345,14 +384,24 @@ async function main() {
345
384
  }
346
385
 
347
386
  console.log('')
348
- if (failures.length === 0 && contractFailures === 0) {
387
+ // 断言数必须与声明对上:此前 NOMINAL_ASSERTIONS 只在 skipExit 里被当事实打印,
388
+ // 通过时**完全无人校验**(改成 999 仍 exit 0,M1)。现在逐项累加:
389
+ // passed = 本次真正执行过的断言数
390
+ // skipped = 因环境能力缺失未执行的项(走 skipNote,--strict 下按失败处理)
391
+ // 声明数按未执行项下修,与 verify-store「inode 缺失时 18→17」同一口径。
392
+ const declared = NOMINAL_ASSERTIONS - skipped
393
+ const countOk = assertCount('verify-compat', passed, declared)
394
+ if (failures.length === 0 && contractFailures === 0 && countOk && strictSkips === 0) {
349
395
  console.log('结果:兼容。')
350
396
  if (symbolMissing > 0) console.log(`注意:仍有 ${symbolMissing} 个运行时符号缺失,需同步适配代码。`)
397
+ if (skipped > 0) console.log(`注意:本次有 ${skipped} 项因环境能力缺失未执行(详见上方 ⚠ 行),跳过不等于通过。`)
351
398
  process.exit(0)
352
399
  }
353
400
  console.log('结果:不兼容')
354
401
  for (const [name, range] of failures) console.log(` peer 范围未覆盖 ${runtimeVersion}:${name} ${range}`)
355
402
  if (contractFailures > 0) console.log(` 注入来源契约不满足:${contractFailures} 项(见上方 ✗ 行)`)
403
+ if (strictSkips > 0) console.log(` --strict:本次有 ${strictSkips} 项因环境能力缺失未执行,按失败处理`)
404
+ if (!countOk) console.log(` 断言数对账失败:实际 ${passed} 项 / 声明 ${declared} 项`)
356
405
  console.log('')
357
406
  console.log('处理方式:')
358
407
  console.log(' 1. 修正代码或 peer 声明使其满足上面的约束,然后升版本重新发布;')