dsh-maoying 0.1.3 → 0.1.4

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/docs/design.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-maoying(毛颖)设计文档
2
2
 
3
- 网文创作辅助 DSH 插件。全部实现原创,以 MIT 发布。
3
+ 网文创作辅助 DSH 插件。以 MIT 发布。
4
4
 
5
5
  命名:毛颖,典出韩愈《毛颖传》——毛笔拟人得名「毛颖」。
6
6
 
package/index.mjs CHANGED
@@ -198,6 +198,32 @@ export function hostRejectsInlineDelegation(version) {
198
198
 
199
199
  /** 宿主包版本:从 <home>/node_modules require('@deepseek-ai/dsh/package.json')。 */
200
200
  export function readHostVersion(dshHome) {
201
+ // ① 运行入口锚定(最真):argv[1] 是宿主自己的入口脚本——CLI 下是
202
+ // @deepseek-ai/dsh 包里的 bin/入口,桌面应用下是 app.asar/dsh 内的入口
203
+ // (Electron 主进程的 fs 能透读 asar)。向上找最近的 @deepseek-ai/dsh
204
+ // package.json,读到的就是当前进程真实版本。home 全局安装的版本可能
205
+ // 陈旧(例如 CLI 升级前留下的 rc.7),绝不能只信它。
206
+ try {
207
+ let dir = path.dirname(path.resolve(process.argv?.[1] ?? ''))
208
+ for (let i = 0; i < 8 && dir && dir !== path.dirname(dir); i++, dir = path.dirname(dir)) {
209
+ const pkgPath = path.join(dir, 'package.json')
210
+ if (!existsSync(pkgPath)) continue
211
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
212
+ if (pkg?.name === '@deepseek-ai/dsh' && typeof pkg.version === 'string' && pkg.version !== '') {
213
+ return pkg.version
214
+ }
215
+ }
216
+ } catch { /* 入口缺失或不可读时落下一档 */ }
217
+ // ② Electron 主进程:桌面应用版本即其内置 dsh 的版本。纯 Node 下 require
218
+ // ('electron') 得到的是路径字符串(或直接找不到),类型守卫天然挡掉。
219
+ try {
220
+ const electron = createRequire(import.meta.url)('electron')
221
+ if (electron && typeof electron === 'object' && typeof electron.app?.getVersion === 'function') {
222
+ const v = electron.app.getVersion()
223
+ if (typeof v === 'string' && v !== '') return v
224
+ }
225
+ } catch { /* 非 Electron 环境常态 */ }
226
+ // ③ 兜底:home 全局安装(老 CLI 链路;可能陈旧,只在①②都拿不到时兜底)
201
227
  try {
202
228
  const req = createRequire(path.join(dshHome, 'node_modules', 'package.json'))
203
229
  const pkg = req('@deepseek-ai/dsh/package.json')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-maoying",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "毛颖 — DSH 网文创作辅助插件:主编 + 五帮手编排(大纲/写手/审校/设定/考据),novel/ 结构化文件为数据库",
5
5
  "type": "module",
6
6
  "license": "MIT",