docs: translate AGENTS.md to Chinese

This commit is contained in:
2026-08-28 14:45:32 +08:00
parent 620b9e051f
commit 376f9a4d9d
+33 -33
View File
@@ -1,43 +1,43 @@
# Repository Guidelines
# 仓库规范
- Keep changes small, independently reviewable, and covered by the smallest relevant check.
- Use the approved stack below; within it, prefer existing code, standard libraries, and native platform features before adding dependencies or abstractions.
- Treat platform responses, webhooks, account data, proxies, and credentials as untrusted or sensitive external input.
- Preserve idempotency and backward compatibility at integration boundaries; document retry and failure behavior.
- Never commit secrets, production credentials, or personal account data.
- Do not add instructions or features for bypassing detection, evading platform risk controls, or violating platform rules.
- When referencing upstream projects, record the source and license, then implement independently unless the license explicitly permits reuse.
- 保持变更小而独立可评审,并附带覆盖该变更的最小相关检查。
- 使用下方已批准的技术栈;在栈内优先复用现有代码、标准库和平台原生能力,而非新增依赖或抽象。
- 将平台响应、Webhook、账号数据、代理和凭据视为不可信或敏感的外部输入。
- 在集成边界保持幂等性和向后兼容;文档化重试与失败行为。
- 永不提交密钥、生产凭据或个人账号数据。
- 不添加用于绕过检测、规避平台风控或违反平台规则的指令或功能。
- 引用上游项目时,记录其来源与许可证;除非许可证明确允许复用,否则须独立实现。
## Approved Stack
## 已批准的技术栈
### Go backend
### Go 后端
- Use Go 1.26, Fiber v3 for HTTP routing and service lifecycle, Viper for configuration, Logrus for application logging, and Cobra for executable entrypoints. Keep the exact dependency versions locked by `go.mod` and `go.sum`.
- Keep mature standard-library integrations, such as the reverse proxy and Docker HTTP client, instead of rewriting them. When a `net/http` handler crosses the Fiber boundary, use Fiber's official adapter.
- Create a local `viper.New()` instance, bind only supported inputs, apply defaults explicitly, and validate all configuration before network, filesystem, or Docker side effects. Do not use Viper's global singleton, remote providers, or live reload without an approved requirement.
- Emit structured JSON through Logrus with stable fields such as `service`; never log credentials, proxies, account data, request bodies, or other sensitive values. Return errors from reusable code and log them once at the service boundary.
- Give each service one minimal Cobra root command. Add subcommands, persistent flags, generators, or completion only when a real operator workflow requires them.
- Do not add an ORM, Redis, a task framework, or another HTTP/config/logging/CLI stack without a reviewed requirement.
- 使用 Go 1.26Fiber v3(HTTP 路由与服务生命周期)、Viper(配置)、Logrus(应用日志)、Cobra(可执行入口)。依赖版本由 `go.mod` `go.sum` 精确锁定。
- 保留成熟的标准库集成,如反向代理和 Docker HTTP 客户端,不重复造轮子。`net/http` handler 跨越 Fiber 边界时,使用 Fiber 官方适配器。
- 创建局部 `viper.New()` 实例,只绑定支持的输入,显式应用默认值,并在产生网络、文件系统或 Docker 副作用前完成全部配置校验。未经评审的需求批准,不使用 Viper 全局单例、远程 provider 或热加载。
- 通过 Logrus 输出结构化 JSON 日志,保持 `service` 等稳定字段;绝不记录凭据、代理、账号数据、请求体等敏感值。可复用代码只返回错误,并在服务边界记录一次。
- 每个服务只保留一个最小化的 Cobra 根命令。仅当存在真实的运维工作流需求时,才添加子命令、持久化 flag、代码生成器或补全。
- 未经评审的需求批准,不添加 ORMRedis、任务框架或另一套 HTTP/配置/日志/CLI 技术栈。
### React frontend
### React 前端
- Use React 19, Vite 8, `react-admin` 5.15.x, and MUI 9. Lock exact installed versions in `web/package-lock.json`.
- Use only the open-source react-admin and MUI packages for the initial implementation. Enterprise Edition and MUI X Pro/Premium require separate product and license review.
- Own the visual system in CreatorHub: keep brand tokens in the project theme and keep navigation/chrome in project-owned Layout, AppBar, and Menu components. Mantis Free may be consulted as MIT-licensed visual reference, but do not import or fork the full template.
- Do not mix Ant Design, Arco, or another component system into the react-admin/MUI application.
- Preserve domain actions such as start, stop, and recycle as explicit actions; do not disguise them as generic CRUD updates merely to fit react-admin conventions.
- 使用 React 19Vite 8`react-admin` 5.15.x MUI 9。在 `web/package-lock.json` 中锁定精确的已安装版本。
- 初始实现只使用开源版 react-admin MUI 包。Enterprise Edition MUI X Pro/Premium 需单独的产品与许可证评审。
- 视觉体系由 CreatorHub 自有掌控:品牌 token 保留在项目主题中,导航/外壳保留在项目自有的 LayoutAppBar Menu 组件中。Mantis Free 可作为 MIT 许可的视觉参考,但不得导入或 fork 整个模板。
- 不将 Ant DesignArco 或其他组件体系混入 react-admin/MUI 应用。
- 将启动、停止、回收等领域动作保留为显式动作;不得为迎合 react-admin 惯例而伪装成通用 CRUD 更新。
## UI Replacement Boundary
## UI 替换边界
- Limit a future UI switch to the project-owned MUI theme, Layout/AppBar/Menu, and react-admin `dataProvider` boundary. Keep API calls and response mapping in the data provider, not in presentation components.
- Do not build a parallel design system, framework-neutral component layer, or speculative adapter hierarchy now. Introduce a new boundary only when a concrete replacement cannot be contained by the existing three seams.
- A switch away from MUI or react-admin requires user review before implementation. Replace the current UI stack rather than running two component systems side by side.
- 未来 UI 切换仅限于项目自有的 MUI 主题、Layout/AppBar/Menu,以及 react-admin `dataProvider` 边界。API 调用与响应映射放在 data provider 中,不放展示组件里。
- 现阶段不构建并行设计系统、框架中立的组件层或投机性的适配器层级。仅当具体替换方案无法被现有三处缝隙(seam)容纳时,才引入新边界。
- MUI react-admin 切换出去前必须经用户评审。替换现有 UI 栈,而非两套组件体系并行运行。
## Verification and Delivery
## 验证与交付
- Add the smallest regression test that would fail without each non-trivial behavior change. Cover success, validation, failure, and compatibility paths at trust and integration boundaries.
- Backend changes must pass `go test ./...`, `go vet ./...`, and builds for both `./cmd/control-plane` and `./cmd/docker-gateway`; run `go test -race ./...` for concurrency, lifecycle, or shared-state changes. Docker or Compose changes must also pass `docker compose config --quiet`.
- Frontend changes must install from the lockfile, pass the repository's non-interactive test command, and pass `npm --prefix web run build`. Changes to theme, Layout, navigation, resource actions, or the data provider require focused interaction coverage, including error and disabled states where applicable.
- Preserve existing API and Docker lifecycle behavior unless the issue explicitly approves a contract change. Document any status-code, payload, configuration, migration, security, or retry impact in the PR.
- Keep each PR scoped to one issue, include the issue key in its title, body, or branch, and report the exact validation commands and results. Do not use close intent unless the issue explicitly requests it.
- Every code PR requires independent review. P0/P1 findings must be fixed and re-reviewed; record P2 findings as follow-up work. The implementation agent must not merge, deploy, publish, or change production configuration; hand an approved PR to the designated delivery role.
- 每个非平凡行为变更附带最小的回归测试,且该测试在无此变更时会失败。在信任与集成边界覆盖成功、校验、失败和兼容路径。
- 后端变更必须通过 `go test ./...``go vet ./...`,并完成 `./cmd/control-plane` `./cmd/docker-gateway` 双端构建;涉及并发、生命周期或共享状态的变更须运行 `go test -race ./...`Docker Compose 变更还须通过 `docker compose config --quiet`
- 前端变更必须从 lockfile 安装、通过仓库的非交互式测试命令,并通过 `npm --prefix web run build`。主题、Layout、导航、资源动作或 data provider 的变更需要聚焦的交互覆盖,包括适用的错误与禁用状态。
- 除非 issue 明确批准契约变更,保持既有 API Docker 生命周期行为不变。在 PR 中文档化任何状态码、载荷、配置、迁移、安全或重试方面的影响。
- 每个 PR 限定于单个 issue,标题、正文或分支名中包含 issue 编号,并报告确切的验证命令与结果。除非 issue 明确要求,不使用 close intent。
- 每个代码 PR 均需独立评审。P0/P1 问题必须修复并复审;P2 问题记录为后续工作。实现 agent 不得合并、部署、发布或修改生产配置;将已批准的 PR 移交指定交付角色。