feat(cli): add migrate planning command#19
Merged
Merged
Conversation
- 在根命令中注册 migrate 子命令 - 实现迁移计划和检查功能 - 添加迁移结果的 JSON 输出格式 - 创建迁移相关的常量定义文件 - 实现迁移命令的输出渲染逻辑 - 添加报告路径解析和安全路径处理 - 实现迁移规则解析和执行逻辑 - 添加迁移命令的测试用例 - 创建迁移结果的 JSON Schema 定义 - 实现迁移 Schema 的有效性验证测试
- 在根命令中注册 migrate 子命令 - 实现迁移计划和检查功能 - 添加迁移结果的 JSON 输出格式 - 创建迁移相关的常量定义文件 - 实现迁移命令的输出渲染逻辑 - 添加报告路径解析和安全路径处理 - 实现迁移规则解析和执行逻辑 - 添加迁移命令的测试用例 - 创建迁移结果的 JSON Schema 定义 - 实现迁移 Schema 的有效性验证测试
spelens-gud
approved these changes
Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
nucleus migrateas a first-class CLI subcommand for version migration planning and readiness checks.The command now follows the established CLI package shape used by
report,scenario, andverify: root only wires the command, whilecmd/nucleus/internal/migrateowns flags, execution, typed output, report writing, diagnostics, and tests.Motivation / Why
The previous migrate logic was too thin for a large open-source project: it lived in
root.go, returned an ad-hoc map, and produced a generic suggested-edit list that did not behave like the rest of the CLI.This PR turns it into an auditable, contract-first migration planning command that can be consumed by humans and automation without mutating service code.
Affected Areas
cmd/nucleus/internal/migrate: new command package withcommand.go,run.go,output.go,paths.go, constants, package docs, and command tests.cmd/nucleus/internal/root: thin command wiring plus root-level migrate wiring test.docs/concepts/migrate-command.md: public command behavior and output contract docs.contractsubmodule pointer: updated to a contract main commit that containscontract/schema/migrate.schema.json.Behavior / Output Contract
--from-versionand--to-version.--json,--pretty,--check, and--report.result_kind: nucleus.migrate_resultschema_version: migrate.v1schema_ref: contract/schema/migrate.schema.jsonok,mode,summary,diagnostics, andmigration.--checkconverts readiness failures into diagnostics and a non-zero exit path.--reportwrites the same JSON envelope only when the target path resolves inside the service directory.Compatibility
This is additive CLI surface area. Existing commands and public Go APIs are not changed.
The migration rules intentionally remain CLI-internal for now. The PR does not add a public
contract/migrationpackage or expand contract module API surface.Validation
rtk go test ./...from repository root: 121 passed in 17 packages.rtk go test ./...fromcontract: 93 passed in 10 packages.rtk go run ./cmd/nucleus migrate --dir example/hello-http --from-version v0.1.0 --to-version v0.2.0 --check --json --pretty: emittedok: truewith 6 checks and 0 diagnostics.rtk go run ./cmd/nucleus verify --dir example/hello-http --json: 7/7 verification steps passed.Review Notes / Residual Risks
migrateis intentionally not an auto-upgrader; service owners still apply edits through the normaldescribe -> plan -> gen -> lint -> verifyloop.bridge,cap, andcore; these are excluded from the PR compare.