Skip to content

feat(cli): add gen and verify commands#12

Merged
nucleuskit merged 2 commits into
mainfrom
feat/gen
Jun 15, 2026
Merged

feat(cli): add gen and verify commands#12
nucleuskit merged 2 commits into
mainfrom
feat/gen

Conversation

@nucleuskit

Copy link
Copy Markdown
Owner

Summary

  • Add the nucleus gen CLI flow for reproducible contract and HTTP adapter artifacts, with human and JSON evidence output.
  • Add the nucleus verify CLI flow for validation, strict linting, generated freshness, go mod tidy, imports, builds, and tests with sanitized evidence.
  • Register the new commands, document gen, and refresh the bundled example/hello-http generated outputs and manifest metadata.

Why

This completes the next pieces of the AI-safe loop from describe -> plan -> gen -> lint -> verify, so generated artifacts and verification evidence can be produced through the CLI instead of ad hoc commands.

Affected Contracts and Manifests

  • Updates example/hello-http/nucleus.yaml with generated targets under ai.generated.
  • Adds generated files under example/hello-http/contract/gen and example/hello-http/internal/adapter/http/gen.
  • Updates contract and runtime/http submodule pointers for generation and freshness support.
  • No intended external HTTP or gRPC behavior change.

Verification

  • rtk go test ./... - passed, 39 tests in 8 packages.
  • rtk go test ./... -race -count=1 - passed, 39 tests in 8 packages.
  • rtk go run ./cmd/nucleus validate --dir example/hello-http - passed, 0 diagnostics.
  • rtk go run ./cmd/nucleus validate --dir example/hello-http --json - passed.
  • rtk go run ./cmd/nucleus lint --dir example/hello-http - passed, 0 findings.
  • rtk go run ./cmd/nucleus gen --dir example/hello-http --json - passed, 8 generated files, source hash 6399c0636543078a250f6ee503877d3a75637fe0242950245796a2299874b3a1.
  • rtk go run ./cmd/nucleus verify --dir example/hello-http --json - passed, 7/7 steps.

Notes on Default Root Commands

  • rtk go run ./cmd/nucleus validate --dir . - not applicable in the current repository root because nucleus.yaml is absent.
  • rtk go run ./cmd/nucleus lint --dir . - not applicable for the same root manifest absence.
  • rtk go run ./cmd/nucleus verify --dir . --json - fails at the validate step for the same reason.

Residual Risks

  • The root-level verify loop remains blocked until the repository root has a project manifest or the documented default commands are narrowed to service directories.
  • Submodule pointer updates require checkout with submodules for a complete local tree.

Anniext added 2 commits June 16, 2026 00:53
- 实现 ExportDocs 函数生成 OpenAPI 文档的 Markdown 格式
- 实现 ExportTypeScript 函数生成 TypeScript 类型声明
- 实现 ExportClientBundle 和 ExportClient 函数生成多语言客户端 SDK
- 实现 Generate 和 GenerateWithOptions 函数用于生成合约相关代码文件
- 添加 Result 和 Options 类型定义控制生成过程和输出
- 实现多种编程语言客户端生成包括 TypeScript、Dart、Java 和 Kotlin
- 添加单元测试验证代码生成功能的正确性
- 实现错误码、端点、路由参数等元数据的代码生成逻辑
- 添加文件写入、格式化和新鲜度标记等辅助功能
- 将默认验证命令从 go test ./... 替换为 nucleus verify --dir . --json
- 添加 --strict 参数到 lint 命令中以启用严格模式
- 在 GeneratedFreshnessForDir 中添加对生成目标路径的规范化和验证
- 引入 normalizeGeneratedTarget 函数防止路径遍历攻击
- 添加 generatedFreshnessReasonInvalidTarget 常量用于无效路径情况
- 新增 sanitizeCommandOutput 函数用于清理命令输出中的敏感信息
- 实现模块文件变更后的自动恢复功能
- 添加测试用例验证路径遍历防护和命令输出清理功能
@nucleuskit nucleuskit requested a review from spelens-gud June 15, 2026 17:09
@nucleuskit nucleuskit marked this pull request as ready for review June 15, 2026 17:11
@nucleuskit nucleuskit merged commit 329d6b8 into main Jun 15, 2026
4 checks passed
@nucleuskit nucleuskit deleted the feat/gen branch June 15, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants