feat(helpers): declarative LeafSpec command framework + devapp migration#676
feat(helpers): declarative LeafSpec command framework + devapp migration#676typefield wants to merge 4 commits into
Conversation
5645fe1 to
8d29f48
Compare
…umption separation
== LeafSpec command framework (internal/helpers/leaf.go) ==
Declarative command construction: LeafSpec/LeafFlag/NewLeafCommand with
Call (pluggable dispatch), LeafInt, PostMount, Trim, Validate. Collapses
per-command hand-written required validation, alias/env fallback, value
transform, and toolArgs assembly into one declarative path.
== devapp migration (28/31 commands) ==
All MCP-direct devapp leaf commands migrated to LeafSpec. Factories
(devAppCall/devAppCallCursor/devAppMeta) fold 33 repeated closures.
fakeDevAppRunner asserts toolArgs for every migrated command. 4 complex
commands (delete/robot submit/result/config) kept hand-written.
== Schema generation/consumption separation ==
- gen.go: isolated //go:generate pragmas from business code.
- command_meta.go: ResolveMeta(cliPath) -> CommandMeta{Identity,Safety,Selection}.
- command_safety.go: SafetyForCLIPath + RenderSafetyAnnotation; safety metadata
flows from embedded catalog into --help output.
- calendar.go HelpFunc fix: delegates to root HelpFunc at help-time.
- schema_catalog_structure.go: closed catalog structure validation gate.
== Registry + catalog per-product sharding ==
schema_command_registry and schema_catalog split into per-product shards,
eliminating concurrent-PR merge conflicts on these files.
== MCP metadata refresh tool ==
cmd/fetch_mcp_metadata: iterates 26 MCP server endpoints, merges with previous
data for cross-server interface_ref. make fetch-mcp-metadata target.
== AGENTS.md ==
Documents the generation/consumption split.
Verified: make policy exit 0, drift zero, all tests pass.
8d29f48 to
51dc237
Compare
|
已基于合并最新
|
概述
引入 LeafSpec 声明式命令框架(
internal/helpers/leaf.go),并把 devapp(dingtalk-dev)产品的 28/31 个命令迁移到该框架,统一此前各命令手写的 flag 注册、required 校验、别名/env 回退、值转换、toolArgs 装配与派发。命令名/flag/行为零变化(catalog drift 全程零漂移)。框架(LeafSpec)
NewLeafCommand(LeafSpec{...}):一条声明 = 一个命令。Flags(LeafString/LeafInt64/LeafInt;Required/MarkRequired/Aliases/EnvVar/ArgDefault/Bind/Transform/OmitEmpty/Trim)、Validate(跨 flag 钩子)、RunE(逃生舱)、PostMount(挂载后钩子)、Call(可插拔派发)、Server。internal/cli/schema_catalog_structure.gocatalog 封闭结构校验 +check-command-surface.sh硬门禁。devapp 迁移(28/31)
devapp 走
executor.Runner而非callMCPTool,通过Call注入runDevAppTool复用框架。迁移:credentials/lifecycle/member/version/webapp/robot/permission/event/security/app 系列(见各 commit)。保留手写 4 个(app delete 多步二次确认、robot submit/result 多步编排、robot config 自定义构造)——非声明式范畴,已加注释标注原因。
优化 + 测试
devAppCall/devAppCallCursor/devAppMeta工厂,折叠 33 处重复闭包。buildDevAppGetParams、runDevAppMemberMutation。fakeDevAppRunner(fake executor.Runner)捕获派发的 toolArgs,补齐运行时 toolArgs 等价断言(drift 只覆盖 flag 层)——含表驱动覆盖所有迁移命令 + OmitEmpty 缺席断言。验证
check-generated-drift.sh全程 ok(registry_hash 不变)——flag 层零漂移。go test ./internal/helpers全量绿;make policy全链路绿(rebase 到 upstream/main e69a108 后复核)。不做(边界)