From 0b79269b2c6a36f51deab4de918f42331346b178 Mon Sep 17 00:00:00 2001 From: figmar Date: Fri, 4 Sep 2026 21:21:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(apes-sidebar):=20inject=20=E6=94=B9?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E7=BB=84=EF=BC=88=E4=BF=AE=20DSH=20entry=20p?= =?UTF-8?q?ending=20=E2=86=92=20=E6=81=A2=E5=A4=8D=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:inject: ['logger'] 声明了 logger 为硬依赖 service,但 DSH host 没有 provider 注册 logger service → entry 永远 pending → '1 entry did not activate' → 插件树加载失败 → 恢复模式循环。 对比 dsh-better-sidebar:其 inject 是 host 实际提供的 service (webServer/sessions/webRuntime/tools)。apes-sidebar host half 只用 ctx.logger 做可选链调用(log?.info?.() 在 try/catch 里),logger 是 软便利不是硬依赖——不该出现在 inject 列表里。 修正:inject 改空数组 [],host half 不声明任何硬依赖 service。 同步更新 smoke.spec.ts 断言(inject toEqual([]))+ verify-mount.cjs 检查(inject === [])。 门禁:typecheck rc=0 · build rc=0 · test 29/29 --- scripts/verify-mount.cjs | 2 +- src/index.ts | 14 ++++++++++++-- tests/smoke.spec.ts | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/verify-mount.cjs b/scripts/verify-mount.cjs index 9122e05..6bd8b44 100644 --- a/scripts/verify-mount.cjs +++ b/scripts/verify-mount.cjs @@ -37,7 +37,7 @@ try { check('host entry 加载成功', true) check('导出 name (string)', typeof host.name === 'string', 'got ' + typeof host.name) check('导出 inject (string[])', Array.isArray(host.inject), 'got ' + typeof host.inject) - check('inject === [logger]', JSON.stringify(host.inject) === '["logger"]', JSON.stringify(host.inject)) + check('inject === [] (无硬依赖 service)', JSON.stringify(host.inject) === '[]', JSON.stringify(host.inject)) check('导出 apply (function)', typeof host.apply === 'function') check('无 default export(namespace 规则)', !('default' in host)) console.log(' name =', JSON.stringify(host.name)) diff --git a/src/index.ts b/src/index.ts index 0a32560..2fce6f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,8 +22,18 @@ */ export const name = 'apes-sidebar' -/** The cordis services the host half injects (Phase 0 minimal set). */ -export const inject = ['logger'] as const +/** + * The cordis services the host half injects. + * + * MUST stay empty: the host half uses `ctx.logger` only via optional-chaining + * (`log?.info?.()` inside try/catch) — it is a soft convenience, not a hard + * dependency. Declaring it in `inject` would make the entry wait on a + * `logger` service that no DSH host provider registers, leaving the entry + * `pending` forever and failing the plugin tree load (recovery mode). + * Compare dsh-better-sidebar, whose inject list is services the host + * actually provides (`webServer`/`sessions`/`webRuntime`/`tools`). + */ +export const inject = [] as const /** * The cordis effect entry: runs once per activation on the Node half. diff --git a/tests/smoke.spec.ts b/tests/smoke.spec.ts index aefab6c..4fcfa69 100644 --- a/tests/smoke.spec.ts +++ b/tests/smoke.spec.ts @@ -29,7 +29,11 @@ describe('apes-sidebar host plugin shape', () => { expect('default' in host).toBe(false) expect(typeof host.apply).toBe('function') expect(host.name).toBe('apes-sidebar') - expect(host.inject).toEqual(['logger']) + // inject MUST be empty: `logger` is used only via optional-chaining in + // apply(ctx) — declaring it as an injected service would make the entry + // wait on a provider DSH host does not register, blocking activation + // (recovery mode). See src/index.ts comment. + expect(host.inject).toEqual([]) }) it('apply mounts a logger line through the effect (Phase 0 minimal)', () => {