feat(ssw-loop): P7 — generate command reference from commander tree (kill drift)
Per DESIGN §6 / user catch: ssw-loop subagent templates hand-code dacli command syntax and drift (typ. missing --category). Command tree is now the single source. - src/program.ts: extract buildProgram() (assembles commander tree, no parse/side-effect) - src/cli.ts: slimmed to import buildProgram() + parse + top-level error handling - scripts/gen-command-reference.ts: walk tree → .claude/.../command-reference.generated.md (190 commands w/ all options + defaults, incl --category/--column-naming) Verified: tsc 0; cli entry smoke (form list) intact after refactor; generator emits 190 commands. (.claude side: generated ref + drift-check committed separately.) Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
7988ead926
commit
d4cc3d09db
3 files changed
+163
-91
No files matched your search
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* program.ts — 组装 commander 命令树 (与 CLI 入口解耦, P7 2026-07-24)
|
||||
*
|
||||
* cli.ts 从这里拿 buildProgram() 后 parseAsync;
|
||||
* scripts/gen-command-reference.ts 也从这里拿, 遍历命令树生成 ssw-loop 模板参考
|
||||
* (模板从 --help 生成, 永不漂移 — DESIGN §6)。
|
||||
* 关键: 本文件只组装、不 parse, import 无副作用。
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildFormCommand } from './commands/form/index.ts'
|
||||
import { buildDmCommand } from './commands/dm/index.ts'
|
||||
import { buildDictCommand } from './commands/dict/index.ts'
|
||||
import { buildMenuCommand } from './commands/menu/index.ts'
|
||||
import { buildDiCommand } from './commands/di/index.ts'
|
||||
import { buildWorkflowCommand } from './commands/workflow/index.ts'
|
||||
import { buildDocCommand } from './commands/doc/index.ts'
|
||||
import { buildApisCommand } from './commands/apis/index.ts'
|
||||
import { buildDatasourceCommand } from './commands/datasource/index.ts'
|
||||
import { buildReportCommand } from './commands/report/index.ts'
|
||||
import { buildPortalCommand } from './commands/portal/index.ts'
|
||||
import { buildBigscreenCommand } from './commands/bigscreen/index.ts'
|
||||
import { buildAppCommand } from './commands/app/index.ts'
|
||||
import { buildPrintCommand } from './commands/print/index.ts'
|
||||
import { buildRoleCommand } from './commands/role/index.ts'
|
||||
import { buildUserCommand } from './commands/user/index.ts'
|
||||
import { buildOrgCommand } from './commands/org/index.ts'
|
||||
import { buildMsgCommand } from './commands/msg/index.ts'
|
||||
import { buildScheduleCommand } from './commands/schedule/index.ts'
|
||||
import { buildMonitorCommand } from './commands/monitor/index.ts'
|
||||
import { buildLogCommand } from './commands/log/index.ts'
|
||||
import { buildIntegrationCommand } from './commands/integration/index.ts'
|
||||
import { buildStorageCommand } from './commands/storage/index.ts'
|
||||
import { buildTestCommand } from './commands/test/index.ts'
|
||||
import { buildSelfCheckCommand } from './commands/_selfcheck.ts'
|
||||
import { buildDriftCheckCommand } from './commands/_drift_check.ts'
|
||||
import { buildCoverageCommand } from './commands/_coverage.ts'
|
||||
import { buildKbCommand } from './commands/kb/index.ts'
|
||||
|
||||
export const VERSION = '0.1.0'
|
||||
|
||||
/** 组装完整 commander 命令树 (不 parse) */
|
||||
export function buildProgram(): Command {
|
||||
const program = new Command()
|
||||
.name('dacli')
|
||||
.description('dacli (TS 版) — AI 驱动的 JNPF CLI. ')
|
||||
.version(VERSION)
|
||||
.showHelpAfterError(true)
|
||||
|
||||
program.addCommand(buildFormCommand())
|
||||
program.addCommand(buildDmCommand())
|
||||
program.addCommand(buildDictCommand())
|
||||
program.addCommand(buildMenuCommand())
|
||||
program.addCommand(buildDiCommand())
|
||||
program.addCommand(buildWorkflowCommand())
|
||||
program.addCommand(buildDocCommand())
|
||||
program.addCommand(buildApisCommand())
|
||||
program.addCommand(buildDatasourceCommand())
|
||||
program.addCommand(buildReportCommand())
|
||||
program.addCommand(buildPortalCommand())
|
||||
program.addCommand(buildBigscreenCommand())
|
||||
program.addCommand(buildAppCommand())
|
||||
program.addCommand(buildPrintCommand())
|
||||
program.addCommand(buildRoleCommand())
|
||||
program.addCommand(buildUserCommand())
|
||||
program.addCommand(buildOrgCommand())
|
||||
program.addCommand(buildMsgCommand())
|
||||
program.addCommand(buildScheduleCommand())
|
||||
program.addCommand(buildMonitorCommand())
|
||||
program.addCommand(buildLogCommand())
|
||||
program.addCommand(buildIntegrationCommand())
|
||||
program.addCommand(buildStorageCommand())
|
||||
program.addCommand(buildTestCommand())
|
||||
program.addCommand(buildSelfCheckCommand())
|
||||
program.addCommand(buildDriftCheckCommand())
|
||||
program.addCommand(buildCoverageCommand())
|
||||
program.addCommand(buildKbCommand())
|
||||
|
||||
return program
|
||||
}
|
||||
Reference in new issue
Block a user