From 355c905026b554de157e15bf160ac649e75e3e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BD=97?= Date: Sat, 6 Jun 2026 09:47:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=E5=B7=A5=E5=85=B7=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=86=85=E5=B5=8C=E5=AE=8C=E6=95=B4=E8=A7=84?= =?UTF-8?q?=E5=88=99=20=E2=80=94=20=E6=89=93=E5=BC=80=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=8D=B3=E8=87=AA=E5=8A=A8=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改为单一信源+内容嵌入模式: - RULES.md: 唯一规范信源(218行) - scripts/sync-ai-rules.sh: 一键同步脚本 - 7个工具配置文件全部内嵌完整规则内容(非引用) 支持的AI工具(打开项目自动加载): - AGENTS.md → Codex CLI / Claude Code - .cursorrules → Cursor IDE - .github/copilot-instructions.md → GitHub Copilot - .windsurfrules → Windsurf / Codeium - .clinerules → Cline - .qwenrules → Qwen Coder / 通义灵码 - .aider.conf.yml → Aider 使用: 编辑 RULES.md 后运行 bash scripts/sync-ai-rules.sh --- .aider.conf.yml | 224 +++++++++++++++++++++++++++++- .clinerules | 229 +++++++++++++++++++++++++++++- .cursorrules | 239 ++++++++++++++++++++++++++++++-- .github/copilot-instructions.md | 235 +++++++++++++++++++++++++++++-- .qwenrules | 233 ++++++++++++++++++++++++++++++- .windsurfrules | 233 ++++++++++++++++++++++++++++++- AGENTS.md | 237 ++++++++++++++++++++++++++++--- scripts/sync-ai-rules.sh | 156 +++++++++++++++++++++ 8 files changed, 1727 insertions(+), 59 deletions(-) create mode 100755 scripts/sync-ai-rules.sh diff --git a/.aider.conf.yml b/.aider.conf.yml index 4f09f9997..c9ee0b111 100644 --- a/.aider.conf.yml +++ b/.aider.conf.yml @@ -1,4 +1,222 @@ # Aider configuration for HealthLink-HIS -# Aider reads instructions from the files listed below -instruction-files: - - RULES.md +# Aider 自动读取此文件获取开发规范 + +instructions: | + # HealthLink-HIS — AI 开发规范(自动加载) + + > 🤖 **本文件供所有 AI 编码工具自动读取**。无论使用 Claude Code、Cursor、Codex CLI、Copilot、Qwen、Cline 还是其他工具,进入本项目后必须遵守以下规范。 + + --- + + ## 一、项目概览 + + | 属性 | 值 | + |------|------| + | 项目名 | HealthLink-HIS(医院信息系统) | + | 后端路径 | `healthlink-his-server/` | + | 前端路径 | `healthlink-his-ui/` | + | 文档路径 | `MD/` | + | JDK | 25 (OpenJDK) | + | Spring Boot | 4.0.6 | + | Vue | 3.x + Vite + Element Plus | + | 数据库 | PostgreSQL 15+ | + | 包名 | `com.healthlink.his` | + + --- + + ## 二、铁律(必须遵守,违反即失败) + + ### 🔴 P0 铁律 — 不可违反 + + **铁律1: 修改完必须测试** + ``` + 后端: mvn clean compile -DskipTests → mvn install -DskipTests → mvn test + 前端: npm run build:dev → npm run lint + ``` + - 白盒:编译通过,无 ERROR + - 黑盒:关键接口返回 `{code:200, data:...}` + - 冒烟:应用正常启动,核心流程通畅 + + **铁律2: Flyway 数据库迁移** + - 凡是新建表、新增字段,必须创建 Flyway 迁移脚本 + - 路径:`healthlink-his-domain/src/main/resources/db/migration/` + - 命名:`V{版本号}__{描述}.sql`(双下划线) + - 禁止直接在数据库执行 SQL 不走 Flyway + + **铁律3: 测试通过后才提交** + - 编译 + 测试全部通过后才能 git commit + - 不提交未完成的功能、调试代码、临时文件 + + **铁律4: 前后端API路径对齐** + - 后端前缀:`/healthlink-his/api/v1/` + - 前端 `request.js` 的 baseURL 必须与后端匹配 + - 接口变更必须同步更新前后端代码 + + ### 🟡 P1 铁律 — 强烈建议 + + **铁律5: 先分解再行动** + - 修改超过3个文件、涉及多模块、数据库变更,必须先制定计划 + + **铁律6: 验证后信** + - 每次修改后必须验证编译通过,不信记忆 + - 重新编译命令:`mvn clean compile -DskipTests` + + **铁律7: 文档统一管理** + - 所有文档存储在 `MD/` 目录 + - 文件名:大写英文+下划线(如 `BACKEND_CHECKLIST.md`) + - 文档头部必须包含元数据块(文档类型、版本、日期) + + **铁律8: 规范文档在 MD/specs/** + - 完整铁律:`MD/specs/IRON_RULES.md` + - 后端规范:`MD/specs/BACKEND_DEVELOPMENT_STANDARD.md` + - 前端规范:`MD/specs/FRONTEND_DEVELOPMENT_STANDARD.md` + + --- + + ## 三、后端开发规范 + + ### 分层架构 + ``` + Controller → AppService → Service → Mapper → Entity + 接收请求 编排业务 单表CRUD 数据访问 实体定义 + ``` + + ### 命名规范 + | 类型 | 规则 | 示例 | + |------|------|------| + | Controller | `XxxController` | `RegistrationController` | + | AppService | `IXxxAppService` / `XxxAppServiceImpl` | `IRegistrationAppService` | + | Service | `IXxxService` / `XxxServiceImpl` | `IRegistrationService` | + | Mapper | `XxxMapper` | `RegistrationMapper` | + | Entity | `Xxx` | `Registration` | + | DTO | `XxxDto` / `XxxQueryDto` | `RegistrationDto` | + + ### 包结构 + ``` + com.healthlink.his.web.{module}.controller + com.healthlink.his.web.{module}.appservice + com.healthlink.his.web.{module}.service + com.healthlink.his.web.{module}.mapper + com.healthlink.his.web.{module}.dto + com.healthlink.his.domain.{module} + com.healthlink.his.common.enums + ``` + + ### 统一返回格式 + ```java + // 成功 + AjaxResult.success(data) + // 失败 + AjaxResult.error("错误信息") + // 列表 + getDataTable(list) + ``` + + ### 关键约束 + - 所有查询使用 `LambdaQueryWrapper`,禁止字符串拼接 SQL + - `@Transactional(rollbackFor = Exception.class)` 管理事务 + - 所有接口标注 `@PreAuthorize` 权限控制 + - 患者敏感信息(身份证、手机号)在日志中脱敏 + - 扩展功能不要修改原有函数签名,新建 Service/AppService + + --- + + ## 四、前端开发规范 + + ### 技术栈 + - Vue 3 + Vite + Element Plus + Pinia + Axios + - 基于 RuoYi-Vue3 框架 + + ### 目录结构 + ``` + src/api/{module}/ # API接口(kebab-case路径) + src/views/{module}/ # 页面组件 + src/store/modules/ # Pinia状态管理 + src/components/ # 公共组件 + ``` + + ### API 路径规范 + ```javascript + // 统一前缀 /healthlink-his/api/v1/ + export function listXxx(query) { + return request({ url: '/healthlink-his/api/v1/xxx/list', method: 'get', params: query }) + } + ``` + + ### 组件规范 + - 页面组件使用 `