dsh-maoying 0.1.7 → 0.1.9

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/index.mjs CHANGED
@@ -53,6 +53,7 @@
53
53
 
54
54
  import { closeSync, copyFileSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, rmSync, writeFileSync } from 'node:fs'
55
55
  import { createHash } from 'node:crypto'
56
+ import { pathToFileURL } from 'node:url'
56
57
  import { readFile } from 'node:fs/promises'
57
58
  import { createRequire } from 'node:module'
58
59
  import os from 'node:os'
@@ -459,6 +460,24 @@ export function parsePresetRows(yaml, agentCordisV2Text) {
459
460
  * reason 区分 'yaml-unavailable' / 'compose-failed'),由调用方走既有的「只落
460
461
  * 文件、跳过声明行并 warn、下次自愈」分支。
461
462
  */
463
+ /**
464
+ * preset 声明行里的本地插件名换成 file:// 绝对地址。相对名按「声明方 baseUrl」
465
+ * 解析——home 托管块的声明基座在宿主 asar 内部,'./x.mjs' 在桌面应用里永远
466
+ * 落空(注册表审计报 never started,0.1.8 host-debug 实测坐实)。Node ESM 对
467
+ * file:// URL 是合法模块说明符,指向 <home>/.agent-presets/maoying/ 安装副本
468
+ * (真实文件系统,任何进程可读)。
469
+ */
470
+ function absolutizeLocalPluginNames(rows, presetDir) {
471
+ for (const row of rows ?? []) {
472
+ for (const p of row?.config?.plugins ?? []) {
473
+ if (typeof p?.name === 'string' && p.name.startsWith('./')) {
474
+ p.name = pathToFileURL(path.join(presetDir, p.name.slice(2))).href
475
+ }
476
+ }
477
+ }
478
+ return rows
479
+ }
480
+
462
481
  export function composeManagedRows(home, logger = console) {
463
482
  const hostVersion = readHostVersion(home)
464
483
  const useV2 = hostVersion !== null && hostRejectsInlineDelegation(hostVersion)
@@ -466,16 +485,17 @@ export function composeManagedRows(home, logger = console) {
466
485
  const yaml = loadYamlLib(home)
467
486
  if (!yaml) return { shape, rows: null, hostVersion, yaml: null, reason: 'yaml-unavailable' }
468
487
  try {
488
+ const installedDir = path.join(home, '.agent-presets', PRESET_ID)
469
489
  if (useV2) {
470
490
  const text = readFileSync(path.join(PLUGIN_ROOT, 'presets', PRESET_ID, AGENT_CORDIS_V2_FILE), 'utf8')
471
- return { shape, rows: parsePresetRows(yaml, text), hostVersion, yaml, reason: null }
491
+ return { shape, rows: absolutizeLocalPluginNames(parsePresetRows(yaml, text), installedDir), hostVersion, yaml, reason: null }
472
492
  }
473
493
  const sourceDir = path.join(PLUGIN_ROOT, 'presets', PRESET_ID)
474
494
  const meta = parsePresetMeta(yaml, readFileSync(path.join(sourceDir, 'preset.yml'), 'utf8'))
475
495
  const plugins = parseAgentPlugins(yaml, readFileSync(path.join(sourceDir, 'agent.cordis.yml'), 'utf8'))
476
496
  // rows 统一为 insert 列表(stringifyManagedBlock 据此渲染同一 - insert: 结构;
477
497
  // 与 v1 历史产物逐字节同形,老 home 升级零抖动)
478
- return { shape, rows: buildPresetRow({ meta, plugins }).insert, hostVersion, yaml, reason: null }
498
+ return { shape, rows: absolutizeLocalPluginNames(buildPresetRow({ meta, plugins }).insert, installedDir), hostVersion, yaml, reason: null }
479
499
  } catch (err) {
480
500
  logger.warn?.(`maoying-installer: 组合源解析失败(${shape} 形态,已跳过声明行): ${err?.message ?? err}`)
481
501
  return { shape, rows: null, hostVersion, yaml, reason: 'compose-failed' }
@@ -835,29 +855,21 @@ export async function registerCreatorRoutes(ctx) {
835
855
  } catch { return '[unserializable]' }
836
856
  }
837
857
  const registryDump = {}
838
- for (const svcName of ['agent-preset-registry', 'agentPresets', 'presets']) {
839
- try {
840
- const svc = typeof ctx.get === 'function' ? ctx.get(svcName) : null
841
- if (!svc) continue
842
- const entry = { __type: typeof svc, __keys: Object.keys(svc).slice(0, 60) }
843
- for (const m of ['list', 'read', 'all', 'definitions', 'inventory', 'entries']) {
844
- if (typeof svc[m] === 'function') {
845
- try {
846
- const r = svc[m]()
847
- entry[m] = r && typeof r.then === 'function' ? '[async]' : jsonSafe(r)
848
- } catch (e) { entry[m] = `throw: ${e?.message ?? e}` }
849
- }
850
- }
851
- registryDump[svcName] = entry
852
- } catch { /* 逐个吞错 */ }
853
- }
858
+ try {
859
+ const svc = typeof ctx.get === 'function' ? ctx.get('agentPresets') : null
860
+ if (svc && typeof svc.list === 'function') {
861
+ // list() 返回每张 preset 的 {id,name,order,broken}——broken 即
862
+ // 面板上显示的逐行激活诊断(注册表自带审计,一行一条不可用原因)。
863
+ const rows = await svc.list()
864
+ registryDump.presets = jsonSafe(rows)
865
+ }
866
+ } catch (e) { registryDump.error = String(e?.message ?? e) }
854
867
  json(res, 200, {
855
868
  ok: true,
856
869
  hostVersion: dbg.version,
857
870
  trace: dbg.trace,
858
871
  shape,
859
872
  registry: registryDump,
860
- ctxKeys: (() => { try { return Object.keys(ctx).slice(0, 80) } catch { return [] } })(),
861
873
  runtime: {
862
874
  argv: process.argv,
863
875
  execPath: process.execPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-maoying",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "毛颖 — DSH 网文创作辅助插件:主编 + 五帮手编排(大纲/写手/审校/设定/考据),novel/ 结构化文件为数据库",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -393,6 +393,8 @@
393
393
  name: "@deepseek-ai/dsh-tool-ask-user"
394
394
  - id: tool-todo
395
395
  name: "@deepseek-ai/dsh-tool-todo"
396
+ config:
397
+ allowParallelInProgress: true
396
398
  # ── 角色 preset:设定管理员(continuable)─────────────────────────────────
397
399
  # persona 逐字复制 v1 delegation-lore;工具面同大纲师。
398
400
  - id: preset-maoying-lore
@@ -491,3 +493,5 @@
491
493
  name: "@deepseek-ai/dsh-tool-ask-user"
492
494
  - id: tool-todo
493
495
  name: "@deepseek-ai/dsh-tool-todo"
496
+ config:
497
+ allowParallelInProgress: true