From 4f30cf35adb9bfbdbf6538c35ad76b24c311fd51 Mon Sep 17 00:00:00 2001 From: ssw Date: Mon, 20 Jul 2026 19:48:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(help):=20=E8=A1=A5=E5=8A=A0=20installHelpHo?= =?UTF-8?q?okWithPatterns=20export=20(merge=20=E5=90=8E=20main=20=E8=B7=91?= =?UTF-8?q?=E4=B8=8D=E8=B5=B7=E6=9D=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 来源: 2026-07-20 合并 p1-8-browser-auto-login 到 main 后, 跑 dacli form info 报 'installHelpHookWithPatterns is not exported' 根因: merge 时 help.ts 没冲突 (main 没有这个 export) 所以保留 main 原状态, 但 create.ts / info.ts 在 p1-8 上改用 installHelpHookWithPatterns (d659fa2 加的) 合并后 import 找不到对应 export 修复: 在 help.ts 加 import { enrichHelp } from '../commands/_anti_patterns' + 加 installHelpHookWithPatterns 函数 (单函数, 调用 enrichHelp 增强 help) 验证: dacli form info --summary 跑通 Co-Authored-By: Claude --- src/core/help.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/core/help.ts b/src/core/help.ts index f0ba9a1..235d6fe 100644 --- a/src/core/help.ts +++ b/src/core/help.ts @@ -12,6 +12,7 @@ * - AI_FLAGS / getMeta / maybeInterceptAiHelp / renderAiHelp 是遗留代码 */ import type { Command } from 'commander' +import { enrichHelp } from '../commands/_anti_patterns' export interface DacliHelp { purpose: string @@ -150,6 +151,24 @@ export function installHelpHook(command: Command, help: DacliHelp): void { /** Backward-compat alias during migration */ export const installAiHelpHook = installHelpHook +/** + * 增强版 installHelpHook: 自动从 ANTI_PATTERNS 注入反模式. + * 在所有 migrate 完成的命令中使用, 以启用 Pitfalls / Best Practices / Decision Tree / Related Refs. + * + * v0.22+ (2026-07-20 main merge): 补加 — 原 main help.ts 只有 installHelpHook, + * 但 p1-8 上 create.ts/info.ts 用 installHelpHookWithPatterns. merge 时 help.ts + * 没冲突所以保留 main 原状态, 但这条函数没引入 → 跑 dacli form info 报 + * "installHelpHookWithPatterns is not exported". 修复: 在 main help.ts 加它. + */ +export function installHelpHookWithPatterns( + command: Command, + fullCmd: string, + help: DacliHelp, +): void { + const enriched = enrichHelp(fullCmd, help) + installHelpHook(command, enriched) +} + function getMeta(cmd: Command): DacliHelp | undefined { return (cmd as unknown as { _aiMeta?: DacliHelp })._aiMeta }