Files
hose-use/src/cli/README.cli.md
T
gitea a3b64d8c8d chore(repo): consolidate spec artifacts into specs/ and complete README coverage
- Move generated OpenAPI bundles out of dist/ into committed specs/
  (specs/openapi.json, specs/openapi.raw.json); source YAML tree moves
  openapi/ -> specs/openapi/; schemas/workflow-schema.json joins as
  specs/workflow-schema.json
- Update all generators/consumers: bundle-openapi, generate-raw-openapi,
  check-version-sync, bump-version, export-workflow-schema,
  packaging/embedded-openapi
- Rewrite stale .env.example with current HOSE_* environment variables
- Archive stale repo-local enterprise configs (superseded by
  ~/.config/hose-use/enterprises) out of the repo; root enterprises/
  keeps only the tracked example.json plus an explanatory README
- Add missing directory READMEs: approval/contact/message/task/events
  domains, cli/, http/, packaging/
- Fix stale domain doc links in README.domains.md and
  docs/modules/platform.md
2026-10-04 14:00:03 +08:00

1.7 KiB
Raw Blame History

CLI 引擎层说明

本目录是三个入口(src/cli.ts 主 CLI、src/aipro-cli.ts AI PRO CLI、src/server.ts MCP 网关)共享的命令引擎:声明式注册、参数解析、写防护、输出渲染与错误映射。入口层只做薄壳,业务编排统一在 domains/。

文件职责

  • registry.ts:CLI_COMMAND_REGISTRY 顶层命令唯一声明式注册表(area / aliases / standing 常驻属性 / handler)。新增命令先在此注册。
  • runner.ts:runCli 分发入口。按注册表查命令;非常驻命令经 runQueue 串行化执行,避免并发写冲突。
  • parser.ts:参数解析器(parseArgs / stringOption / booleanOption / outputOptions)。
  • printer.ts:输出渲染(printJson / printHelp / redactSensitiveText 敏感信息脱敏)。
  • errors.ts:classifyCliError 按 EkbError 子类与状态码映射退出码与恢复建议。
  • mutation.ts:写操作统一防护(确认/dry-run 语义),边界由 mutation-boundaries.test.ts 强制。
  • helpers.ts:横切运行时助手(initCorpRuntime / requireSelectedCorp / getSessionClientForRuntime)。
  • service.ts:常驻守护进程管理(安装/启停/状态)。
  • help.ts:帮助文本组织。
  • commands/:每个顶层命令域一个 handler 文件,与 src/domains/ 一一对应;复杂命令(如 aipro/)可用子目录形态。
  • architecture-boundaries.test.ts:分层导入约束的机器卡点(入口层禁触 domains/*/api.ts、域层禁反向依赖、core 白名单)。

约定

  • handler 统一签名 (parsed, runtime, options) => Promise<CliResult>。
  • 命令文件内部不重复做异常体系,只抛/透传 EkbError 子类。