dsh-muv-table 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.12 (2026-09-20)
4
+
5
+ ### 🐛 修复:发布包里缺 `test-cards.mjs`,导致随包发布的 `test-muv-parser.mjs` 装完跑不起来
6
+
7
+ `files` 字段列了 `test-muv-parser.mjs`,但它 `import` 的 `test-cards.mjs` **没被列进去**。
8
+ 从 npm 装下来的副本里跑它会直接
9
+ `ERR_MODULE_NOT_FOUND: .../node_modules/dsh-muv-table/test-cards.mjs`。
10
+ (**开发树里不会暴露这个问题** —— 仓库里那个文件一直都在。这是只有
11
+ 「装已发布的包再跑」才能发现的缺陷,也正是这条验证路径的价值所在。)
12
+ 纯打包修复,运行时代码一字未动。
13
+
3
14
  ## v0.2.11 (2026-09-20)
4
15
  ### 🐛 修复:世界书里「没有 `<initvar>` 标签、只有 `[initvar]` 注释前缀」的裸 YAML 变量树读不到
5
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-muv-table",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "MUV 变量表格编辑器 —— 树形变量面板、宏测试浮窗(random/pick/roll)、骰子快捷栏、pick 缓存管理;支持直接读取 SillyTavern PNG 角色卡(含正则脚本、世界书、变量表)。dsh-muv-engine 的伴生插件",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -10,7 +10,7 @@
10
10
  "./lib/*": "./lib/*",
11
11
  "./package.json": "./package.json"
12
12
  },
13
- "files": ["lib", "cordis.patch.yml", "CHANGELOG.md", "README.md", "test-png-card.mjs", "test-muv-parser.mjs", "test-preset-resolve.mjs"],
13
+ "files": ["lib", "cordis.patch.yml", "CHANGELOG.md", "README.md", "test-cards.mjs", "test-png-card.mjs", "test-muv-parser.mjs", "test-preset-resolve.mjs"],
14
14
  "keywords": ["dsh", "dsh-plugin", "deepseek-harness", "muv", "magvarupdate", "tavern", "variable-table"],
15
15
  "license": "PolyForm-Noncommercial-Copyleft-1.0.0",
16
16
  "dsh": {
package/test-cards.mjs ADDED
@@ -0,0 +1,58 @@
1
+ // Locate real character cards on this machine for the tests.
2
+ //
3
+ // The search roots mirror `MUV_CARD_DIRS` in lib/index.js so a test finds the
4
+ // same files the plugin would. Nothing here writes to disk; a missing card is a
5
+ // normal outcome (`null`) and callers turn that into a SKIP, never a failure —
6
+ // the tests must stay runnable on a machine without the sample library.
7
+
8
+ import fs from 'node:fs'
9
+ import path from 'node:path'
10
+ import os from 'node:os'
11
+
12
+ /** Directories worth searching for a sample card. */
13
+ export function cardDirs() {
14
+ const roots = [
15
+ 'C:/MySpecialFolder/SillyTavern',
16
+ path.join(os.homedir(), 'SillyTavern'),
17
+ path.join(os.homedir(), 'Documents', 'SillyTavern'),
18
+ ]
19
+ // Same order index.js uses: explicit download dir, env override, ST, then the
20
+ // usual download/desktop drop zones.
21
+ const out = ['E:/BaiduNetdiskDownload/EdgeDownload']
22
+ for (const d of String(process.env.DSH_MUV_CARD_DIRS || '').split(path.delimiter)) {
23
+ if (d.trim()) out.push(d.trim())
24
+ }
25
+
26
+ // SillyTavern keeps cards under data/<user>/characters.
27
+ for (const root of roots) {
28
+ const dataDir = path.join(root, 'data')
29
+ if (!fs.existsSync(dataDir)) continue
30
+ try {
31
+ for (const user of fs.readdirSync(dataDir)) {
32
+ const chars = path.join(dataDir, user, 'characters')
33
+ if (fs.existsSync(chars)) out.push(chars)
34
+ }
35
+ } catch (_) {}
36
+ }
37
+
38
+ out.push(path.join(os.homedir(), 'Downloads'), path.join(os.homedir(), 'Desktop'))
39
+
40
+ return out.filter((d, i, all) => all.indexOf(d) === i)
41
+ }
42
+
43
+ /**
44
+ * Find a card file by base name (without extension).
45
+ * @param {string} name - e.g. '苍玄界', '_足控天堂2'
46
+ * @returns {string} absolute path, or '' when not on this machine
47
+ */
48
+ export function findCard(name) {
49
+ const explicit = process.env.MUV_TEST_CARD_DIR
50
+ const dirs = explicit ? [explicit, ...cardDirs()] : cardDirs()
51
+ for (const dir of dirs) {
52
+ for (const ext of ['.png', '.json']) {
53
+ const p = path.join(dir, name + ext)
54
+ if (fs.existsSync(p)) return p
55
+ }
56
+ }
57
+ return ''
58
+ }