-
Notifications
You must be signed in to change notification settings - Fork 231
feat: add guidelines and coding standards for Kratos Layout Agent #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||
| # Kratos Layout Agent 指南 | ||||||||||||||||||
|
|
||||||||||||||||||
| ## 目的 | ||||||||||||||||||
| 本文档用于定义 AI Agent 或开发助手在 Kratos 项目中的工作规范。 确保所有代码符合 Kratos 项目结构,保持清晰的分层架构,提高代码可维护性与一致性。适用于:代码生成、功能开发、重构、API 设计与修改、配置变更、测试与文档 | ||||||||||||||||||
|
|
||||||||||||||||||
| ## 核心原则 | ||||||||||||||||||
| - 面向职责分包:代码必须按职责划分,而不是随意命名; | ||||||||||||||||||
| - 分层必须严格:必须保证,业务逻辑、数据访问、接口层彻底分离; | ||||||||||||||||||
| - 最小变更原则:实现需求时,修改最少文件、保持现有风格、不随意重构架构; | ||||||||||||||||||
| - 不修改生成代码:禁止直接修改 protobuf、wire 等生成文件,如需修改应调整源文件并重新生成; | ||||||||||||||||||
| - 代码风格一致:必须遵守 Go 语言规范,保持代码风格一致,避免引入不必要的依赖或复杂性。 | ||||||||||||||||||
|
|
||||||||||||||||||
| ## 项目布局 | ||||||||||||||||||
| 必需遵守 Kratos 官方推荐的项目布局,顶层目录包含: | ||||||||||||||||||
|
||||||||||||||||||
| 必需遵守 Kratos 官方推荐的项目布局,顶层目录包含: | |
| 必须遵守 Kratos 官方推荐的项目布局,顶层目录包含: |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第 19 行的加粗写法为“** Zero dependencies **”,两侧多余空格会导致 Markdown 渲染不一致。建议改为“Zero dependencies”。
| - `biz/`:核心业务层,遵守 ** Zero dependencies ** 原则,包含 usecase、domain model(DO) 和 repo 接口定义,不依赖 service 和 data,不使用 proto 结构。 | |
| - `biz/`:核心业务层,遵守 **Zero dependencies** 原则,包含 usecase、domain model(DO) 和 repo 接口定义,不依赖 service 和 data,不使用 proto 结构。 |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第 20、22、23 行的目录说明分隔符使用了半角“:”(例如“data/:”),而第 15-18、24 行使用的是全角“:”。建议统一一种标点(中文文档通常用“:”)以保持格式一致。
| - `data/`: 数据访问层,包含数据库访问、外部 API 调用等实现,实现 biz 层 repo 接口定义,禁止包含业务逻辑。 | |
| - `service/`:接口实现层,包含 gRPC、HTTP 等接口实现,负责请求编排、参数校验、DTO 到 DO 转换。调用 biz 层实现业务逻辑,不允许包含复杂业务逻辑。 | |
| - `server/`: HTTP/gRPC 服务器实现,包含路由、服务、中间件注册等,保持简洁,不允许包含业务逻辑。 | |
| - `conf/`: 使用 proto 定义的配置结构体,保持与 `configs/` 目录下的配置文件一致,使用 `make config` 命令生成更新。 | |
| - `data/`:数据访问层,包含数据库访问、外部 API 调用等实现,实现 biz 层 repo 接口定义,禁止包含业务逻辑。 | |
| - `service/`:接口实现层,包含 gRPC、HTTP 等接口实现,负责请求编排、参数校验、DTO 到 DO 转换。调用 biz 层实现业务逻辑,不允许包含复杂业务逻辑。 | |
| - `server/`:HTTP/gRPC 服务器实现,包含路由、服务、中间件注册等,保持简洁,不允许包含业务逻辑。 | |
| - `conf/`:使用 proto 定义的配置结构体,保持与 `configs/` 目录下的配置文件一致,使用 `make config` 命令生成更新。 |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第 27 行单独出现的“›”看起来是误入的字符,会污染文档内容并可能影响渲染/复制。建议删除该行。
| 必须保持该目录结构,不允许随意新增或删除顶层目录,以保证项目的规范性和可维护性。 | |
| › | |
| 必须保持该目录结构,不允许随意新增或删除顶层目录,以保证项目的规范性和可维护性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第 4 行“工作规范。 确保”中句号后存在多余空格,影响排版一致性。建议去掉该空格并按需补充句末标点/分号分隔(例如在最后补“。”或用列表列出“适用于”项)。