Files
shaw 7d67eb083a docs(refactor): 插件化改造各阶段完成报告与审计记录归档
issues/plugin-refactor/:Phase-0~2 的任务完成报告、阶段总结、
两轮内核审计报告、Phase-2 接缝设计双视角评审与实施后对抗审计、调用点清单。
2026-06-11 23:00:19 +08:00

28 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 完成报告: [TASK-003] 模块脚手架生成器
- **完成状态**: Success
- **关联任务规格**: [链接](../../../.claude/plugin-refactor/phases/phase-1.5_devkit/TASK-003_scaffold.md)
- **完成日期**: 2026-06-11
## 1. 任务完成简报
`make new-module ID=job.foo` 落地:embed 模板渲染生成 `internal/modules/foo/{foo.go,foo_test.go}`(四生命周期骨架 + 编译期断言 + EnabledByDefault=false + 示例私有配置 + 9 处 TODO;测试模板基于 plugintest),打印 next steps(确切 import 行 / config 启用示例 / 作者指南链接),**不自动改 imports.go**(显式插装可 review)。真实演示验证:job.demo 生成 → 插装 → `go build` + 5 测试全过 → 清理后 git status 与演示前 diff 为空。
## 2. 文件变更详情
- **创建**: `backend/tools/newmodule/main.go`、`templates/module.go.tmpl`、`templates/module_test.go.tmpl`、`main_test.go`(6 用例)
- **修改**: `backend/Makefile`(new-module 目标,ifndef ID 守卫)
## 3. 关键裁量
- **ID 校验走内核导出口径**(`plugin.ParseConfig` 间接复用 `ModuleID.validate()`):零规则复制,内核演进自动跟随;
- 包名校验 `go/token.IsIdentifier` + 拒绝 `_`(内核 ID 合法但包名非法的情形);
- **渲染即 `go/format.Source`**:模板腐化当场报错不写盘(防模板随内核演进静默腐化);
- 失败原子性:校验先于建目录,第二文件失败回滚整个目录;`-dir` flag 使单测渲染进 t.TempDir。
## 4. 验证记录(主控复跑确认)
- `go test ./tools/...` ✅(6 用例:产物 gofmt/内容/import 行、非法 ID×5、非法包名×4、已存在拒绝、缺参提示,拒绝路径断言无残留);
- 演示链路全过且清理干净(imports.go md5 一致、`internal/modules/` 仅 hello/standard——主控 ls 复核);
- `make test-invariants`、全量 unit(43 包)✅;vet 零问题。