chore(migration): Cursor → Claude Code 反向迁移 + 单轨化(v2)
- 删除 5 个 AGENTS.md(根 + 4 子模块)与 .cursor/、.cursorignore,全部已备份 - 在 CLAUDE.md 末尾追加 5 节迁移必需内容(CLI/Shell 中文与编码、Claude Code 资产入口、Hook 与权限、不破坏原则、历史追溯),保留用户选定的 226 行项目规则全集 - 用户级 12 个 skills 从 ~/.cursor/skills/ 剥包装回迁到 ~/.claude/skills/(neozqyy-cursor-migration → neozqyy-claude-code-migration) - docs/ai-env-history/ 顶层 10 文件入仓(含 conversation_index.csv、file_impact_index.csv,已脱敏);sessions/ 原文继续本地保留 - 新增 tools/claude-code/migrate_ai_environment.py(--check 14/14 通过) - 新增 docs/claude_code_migration.md 与 docs/audit/changes/2026-05-02__claude_code_migration.md - .gitignore 调整:开放 2 个 CSV 索引入仓,保留 sessions/ 与 claude-history/ 排除 - 不混入 124 个业务变更(AI 模块重构、runtime_context、sandbox 等保持 unstaged) - 备份位置:~/.claude/backups/pre-claude-code-migration-2026-05-02/ 第二轮迁移(第一轮 commit 6facb2d 已被 git reset 回滚;本轮策略为追加而非重写 CLAUDE.md)
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
# AGENTS.md - Backend (FastAPI)
|
||||
|
||||
进入本目录时自动加载。
|
||||
|
||||
## 架构模式
|
||||
|
||||
### 全局响应包装
|
||||
|
||||
`ResponseWrapperMiddleware` 把所有 2xx 响应包为 `{ "code": 0, "data": <payload> }`。
|
||||
非 2xx 响应保持原样。前端统一通过 `response.data` 解包。
|
||||
|
||||
### 序列化
|
||||
|
||||
`CamelModel` 基类:snake_case -> camelCase 自动转换(小程序 API 用)。
|
||||
后端代码始终用 snake_case,JSON 输出自动转驼峰。
|
||||
|
||||
### JWT 双认证
|
||||
|
||||
| 认证方式 | 用途 | 表 | JWT aud |
|
||||
|---------|------|-----|---------|
|
||||
| 用户名+密码 | admin-web 登录 | `auth.admin_users` | `admin` |
|
||||
| 微信 code | 小程序登录 | `auth.users` | `miniapp` |
|
||||
| 用户名+密码 | tenant-admin 登录 | `auth.tenant_admins` | `tenant-admin` |
|
||||
|
||||
待审核用户有 limited token(仅可访问审核状态接口)。
|
||||
|
||||
### AI 集成
|
||||
|
||||
8 个千问应用通过 DashScope SDK:
|
||||
chat / finance / clue / analysis / tactics / note / customer / consolidate
|
||||
|
||||
特性:熔断(连续失败自动断路)、限流(每分钟/每日)、预算追踪、对话缓存。
|
||||
|
||||
### 后台服务(lifespan)
|
||||
|
||||
- `TaskQueue`:按 site_id 消费,FIFO 队列
|
||||
- `Scheduler`:读 `meta.scheduled_tasks` 自动入队
|
||||
- 4 个触发器:日结/月结/工资/关系指数
|
||||
|
||||
### 数据库访问
|
||||
|
||||
- 业务库通过 `APP_DB_DSN` 直连 `zqyy_app`
|
||||
- ETL 数据通过 FDW 映射的 `app.v_*` RLS 视图访问
|
||||
- 查询前必须 `SET LOCAL app.current_site_id = :site_id`
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
cd apps/backend && pytest tests/ -v
|
||||
```
|
||||
|
||||
使用测试库(`TEST_APP_DB_DSN`),禁止连正式库。
|
||||
Reference in New Issue
Block a user