dsh-muv-table 0.2.2 → 0.2.3
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 +17 -0
- package/lib/index.js +44 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.2.3 (2026-09-13)
|
|
4
|
+
|
|
5
|
+
### 🐛 修复
|
|
6
|
+
|
|
7
|
+
- **DSH 装到非默认位置时读不到预设**:`PRESETS_ROOT` 等路径写死为 `~/.dsh`。
|
|
8
|
+
DSH 本体按 `$DSH_HOME`(非空)→ `~/.dsh` 解析 home,用户预设目录是
|
|
9
|
+
`<dshHome>/.agent-presets`。`DSH_HOME` 非默认时本插件扫的是错误目录,
|
|
10
|
+
角色卡列表恒为空。
|
|
11
|
+
|
|
12
|
+
现在与酒馆插件保持一致:`apply()` 时优先取 DSH 的 `dshHomePath` 服务,
|
|
13
|
+
拿不到再按环境变量解析,并同步绑定 `PRESETS_ROOT` / `TAVERN_PRESET_DIR`
|
|
14
|
+
/ `session-bindings.json`。
|
|
15
|
+
|
|
16
|
+
> 未改动任何许可证内容。
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
3
20
|
## v0.2.2 (2026-09-13)
|
|
4
21
|
|
|
5
22
|
### 🐛 修复
|
package/lib/index.js
CHANGED
|
@@ -12,8 +12,46 @@ import { fileURLToPath } from 'node:url'
|
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
13
13
|
let PANEL_HTML = ''
|
|
14
14
|
try { PANEL_HTML = fs.readFileSync(path.join(__dirname, 'panel.html'), 'utf8') } catch (_) {}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
// ── DSH home 解析 ─────────────────────────────────────────
|
|
17
|
+
// 与 @deepseek-ai/dsh-home-paths 的 resolveDshHome() 一致:
|
|
18
|
+
// 优先级 = 显式配置 → $DSH_HOME(非空)→ ~/.dsh。
|
|
19
|
+
// 用户预设目录 = <dshHome>/.agent-presets(酒馆插件也用同一份)。
|
|
20
|
+
// 写死 ~/.dsh 会让 DSH_HOME 指向非默认位置的部署读不到预设。
|
|
21
|
+
function expandHomePrefix(p) {
|
|
22
|
+
if (p === '~') return os.homedir()
|
|
23
|
+
if (p.startsWith('~/') || p.startsWith('~\\')) return path.join(os.homedir(), p.slice(2))
|
|
24
|
+
return p
|
|
25
|
+
}
|
|
26
|
+
function resolveDshHome() {
|
|
27
|
+
const env = process.env.DSH_HOME
|
|
28
|
+
if (typeof env === 'string' && env.trim().length > 0) return path.resolve(expandHomePrefix(env.trim()))
|
|
29
|
+
return path.join(os.homedir(), '.dsh')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// apply() 时按 DSH 实际 home 重新绑定
|
|
33
|
+
let DSH_HOME = resolveDshHome()
|
|
34
|
+
let PRESETS_ROOT = path.join(DSH_HOME, '.agent-presets')
|
|
35
|
+
let TAVERN_PRESET_DIR = path.join(PRESETS_ROOT, 'tavern-lite')
|
|
36
|
+
let SESSION_BINDINGS_FILE = path.join(PRESETS_ROOT, 'session-bindings.json')
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 绑定路径到 DSH 实际 home:优先用 DSH 的 dshHomePath 服务,拿不到再自行解析。
|
|
40
|
+
* @param {object} ctx - cordis 上下文
|
|
41
|
+
*/
|
|
42
|
+
function bindDshPaths(ctx) {
|
|
43
|
+
let home = ''
|
|
44
|
+
try {
|
|
45
|
+
const fn = ctx && typeof ctx.get === 'function' ? ctx.get('dshHomePath') : undefined
|
|
46
|
+
if (typeof fn === 'function') home = String(fn() || '')
|
|
47
|
+
} catch {}
|
|
48
|
+
if (!home) home = resolveDshHome()
|
|
49
|
+
DSH_HOME = home
|
|
50
|
+
PRESETS_ROOT = path.join(home, '.agent-presets')
|
|
51
|
+
TAVERN_PRESET_DIR = path.join(PRESETS_ROOT, 'tavern-lite')
|
|
52
|
+
SESSION_BINDINGS_FILE = path.join(PRESETS_ROOT, 'session-bindings.json')
|
|
53
|
+
}
|
|
54
|
+
|
|
17
55
|
const MUV_CARD_DIRS = ['E:/BaiduNetdiskDownload/EdgeDownload']
|
|
18
56
|
|
|
19
57
|
/** Read a YAML/yml file with encoding detection (GBK → UTF-8 fallback). */
|
|
@@ -64,7 +102,7 @@ function scanAllPresetCards() {
|
|
|
64
102
|
.filter(d => d.isDirectory())
|
|
65
103
|
.map(d => path.join(PRESETS_ROOT, d.name))
|
|
66
104
|
// Also scan the DSH root (presets like anchored-standard live there too)
|
|
67
|
-
for (const dir of [...dirs,
|
|
105
|
+
for (const dir of [...dirs, DSH_HOME]) {
|
|
68
106
|
const ymlPath = path.join(dir, 'agent.cordis.yml')
|
|
69
107
|
if (!fs.existsSync(ymlPath)) continue
|
|
70
108
|
try {
|
|
@@ -81,7 +119,7 @@ function scanAllPresetCards() {
|
|
|
81
119
|
/** Resolve preset dir for a session id via session-bindings.json */
|
|
82
120
|
function presetDirForSession(sessionId) {
|
|
83
121
|
try {
|
|
84
|
-
const bindPath =
|
|
122
|
+
const bindPath = SESSION_BINDINGS_FILE
|
|
85
123
|
if (sessionId && fs.existsSync(bindPath)) {
|
|
86
124
|
const bind = JSON.parse(fs.readFileSync(bindPath, 'utf8'))
|
|
87
125
|
const preset = bind[sessionId]
|
|
@@ -188,6 +226,8 @@ function readBody(req) {
|
|
|
188
226
|
}
|
|
189
227
|
|
|
190
228
|
export function apply(ctx) {
|
|
229
|
+
bindDshPaths(ctx)
|
|
230
|
+
console.log('[dsh-muv-table] DSH_HOME = ' + DSH_HOME + ' 预设目录 = ' + PRESETS_ROOT)
|
|
191
231
|
const routes = [
|
|
192
232
|
{
|
|
193
233
|
kind: 'exact',
|