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)', () => {