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 }