fix(dacli): preserve _aiMeta for behavioral compat + update module docs
This commit is contained in:
1 parent
cc64e13d86
commit
38c6fe6ae2
1 file changed
+3
-16
+3
-16
@@ -117,24 +117,11 @@ export function renderDacliHelp(help: DacliHelp): string {
|
||||
|
||||
const AI_FLAGS = new Set(['--ai-help', '--example', '--source'])
|
||||
|
||||
/**
|
||||
* 把 DacliHelp 注入 Commander 命令的 --help 输出.
|
||||
* 替换旧的 installAiHelpHook, 单 flag --help 包含所有信息.
|
||||
*
|
||||
* - `purpose` 走 Commander 的 `.description()`, 出现在 Usage 之后 Options 之前
|
||||
* (Commander `helpInformation()` 内置可见)
|
||||
* - 其他字段 (example/source/pitfalls/bestPractices/decisionTree/relatedRefs/notes)
|
||||
* 走 `addHelpText('after', ...)`, 出现在 Options 之后
|
||||
* (Commander `helpInformation()` 不内置, 仅 `outputHelp()` / `--help` 实际输出可见)
|
||||
*/
|
||||
export function installHelpHook(command: Command, help: DacliHelp): void {
|
||||
command.description(help.purpose)
|
||||
command.addHelpText('after', renderDacliHelp(help))
|
||||
/** 把元数据挂到 command 上, cli.ts 顶层会读 */
|
||||
export function installAiHelpHook(cmd: Command, meta: DacliHelp): void {
|
||||
;(cmd as unknown as { _aiMeta?: DacliHelp })._aiMeta = meta
|
||||
}
|
||||
|
||||
/** Backward-compat alias during migration */
|
||||
export const installAiHelpHook = installHelpHook
|
||||
|
||||
function getMeta(cmd: Command): DacliHelp | undefined {
|
||||
return (cmd as unknown as { _aiMeta?: DacliHelp })._aiMeta
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user