迁移 Claude/Codex/Cursor 开发环境与追溯资产
Co-Authored-By: OpenAI Codex <codex@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# 变更审计记录:Codex 深度迁移与 Claude 历史摘要归档
|
||||
|
||||
| 字段 | 值 |
|
||||
|------|-----|
|
||||
| 日期 | 2026-04-29 03:57:55 |
|
||||
|
||||
## 操作摘要
|
||||
|
||||
本轮将 Claude Code 的项目规则、用户习惯、skills、agents、rules 和 NeoZQYY 项目历史会话迁移到 Codex 可读取的结构。迁移目标是让 Codex 尊重用户此前的使用习惯,并在后续修改代码时能追溯“哪次 Claude 会话改了什么、影响了什么”。
|
||||
|
||||
迁移没有把 Claude 原始对话全文注入 Prompt,而是生成脱敏摘要、会话索引和文件反向索引,避免过时信息和敏感信息污染日常上下文。
|
||||
|
||||
## 变更文件
|
||||
|
||||
### 新增
|
||||
|
||||
- `AGENTS.md`:根项目 Codex 工作规范。
|
||||
- `apps/backend/AGENTS.md`:后端模块 Codex 规则。
|
||||
- `apps/etl/connectors/feiqiu/AGENTS.md`:ETL 飞球模块 Codex 规则。
|
||||
- `apps/demo-miniprogram/AGENTS.md`:demo 小程序模块保护规则。
|
||||
- `db/AGENTS.md`:数据库目录 Codex 规则。
|
||||
- `tools/codex/mcp-postgres.ps1`:Codex PostgreSQL MCP 启动脚本,按变量名读取 `.env` / `.env.local` / 当前环境。
|
||||
- `tools/codex/migrate_claude_assets.py`:Claude 资产迁移脚本。
|
||||
- `docs/codex_migration.md`:Codex 迁移状态说明。
|
||||
- `docs/claude-history/`:Claude 会话摘要归档、会话索引和文件反向索引。
|
||||
|
||||
## 改动注解
|
||||
|
||||
- `tools/codex/migrate_claude_assets.py`:实现可重复迁移流程,转换 Claude skills、agents、rules,生成全局 Codex 习惯文件,并对 Claude JSONL 历史做脱敏摘要和索引。
|
||||
- `tools/codex/mcp-postgres.ps1`:避免把数据库 DSN 明文写入 Codex 配置,支持 `-ValidateOnly` 做环境巡检。
|
||||
- `docs/claude-history/session_index.csv`:记录 94 个 Claude 会话的时间范围、影响范围、风险标签和摘要文件。
|
||||
- `docs/claude-history/file_index.csv`:记录 246 个被编辑文件与 Claude 会话的关联,支持按文件追溯。
|
||||
- `docs/codex_migration.md`:同步迁移结果、验证方式和追溯入口。
|
||||
- `db/AGENTS.md`:高风险目录规则文件,仅迁移原 Claude DB 指令,没有修改 DDL 或迁移 SQL。
|
||||
|
||||
## 数据库变更
|
||||
|
||||
无数据库 schema 变更。未新增迁移 SQL,未修改 DDL。
|
||||
|
||||
## 风险与回滚
|
||||
|
||||
- 中:Claude 历史摘要为脚本自动提取,可能遗漏自然语言中描述的影响。回溯关键问题时仍需查看原始 JSONL、git diff、审计记录和测试结果。
|
||||
- 中:Claude skill 中部分内容包含 Claude Code 专属命令或 agent 概念,已迁移为 Codex skill/reference,但使用时需要按 Codex 工具等价替换。
|
||||
- 低:Codex hooks 未默认启用,原 Claude hooks 的强校验不是一比一恢复;当前由 AGENTS 规则和审计流程承接。
|
||||
- 回滚:删除新增的 `AGENTS.md` / `docs/claude-history/` / `docs/codex_migration.md` / `tools/codex/*`,并恢复 `C:\Users\Administrator\.codex` 下自动生成前的备份。
|
||||
|
||||
## 验证
|
||||
|
||||
- `python scripts/audit/prescan.py --files "<本次迁移文件列表>"`:审计预扫描通过,未发现缺失文档同步。
|
||||
- `python -m py_compile tools/codex/migrate_claude_assets.py`:迁移脚本语法通过。
|
||||
- `powershell.exe -NoProfile -ExecutionPolicy Bypass -File tools\codex\mcp-postgres.ps1 TEST_DB_DSN -ValidateOnly`:PostgreSQL MCP 启动配置检查通过。
|
||||
- Codex skill 校验:12/12 个迁移后的 skill 通过 `quick_validate.py`。
|
||||
- 历史归档校验:生成 94 个会话摘要、94 条会话索引、246 个文件反向索引。
|
||||
- 敏感信息扫描:生成的历史摘要、迁移说明和 Codex skills 未发现常见 DSN/API key/密码形态。
|
||||
|
||||
## 合规检查
|
||||
|
||||
- 文档同步:已同步到 `docs/codex_migration.md` 和 `docs/claude-history/README.md`。
|
||||
- 数据库文档:不适用,本轮无 schema 变更。
|
||||
- 审计记录:已落盘。
|
||||
47
docs/audit/changes/2026-05-01__cursor_migration.md
Normal file
47
docs/audit/changes/2026-05-01__cursor_migration.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# 变更审计记录:Cursor AI 开发环境迁移
|
||||
|
||||
| 字段 | 值 |
|
||||
|------|-----|
|
||||
| 日期 | 2026-05-02 00:05:37 |
|
||||
|
||||
## 操作摘要
|
||||
|
||||
本轮将 Claude Code 与 Codex 中已经沉淀的 AI 开发习惯迁移到 Cursor 原生结构。迁移目标是让 Cursor 继承中文沟通、前置调研、验证、审计、子代理审查、MCP 测试库优先和历史追溯习惯,同时避免把长规则和原始对话全文堆入常规上下文。
|
||||
|
||||
## 变更文件
|
||||
|
||||
### 新增/修改
|
||||
|
||||
- `tools/cursor/migrate_ai_environment.py`:可重复迁移脚本。
|
||||
- `.cursor/rules/`:Cursor 项目级短规则。
|
||||
- `.cursor/skills/`:审计、前置调研、文档同步和 spec 收尾流程技能。
|
||||
- `.cursor/hooks.json`、`.cursor/hooks/ai_env_guard.py`:轻量提醒/保护 hooks。
|
||||
- `docs/cursor_migration.md`:Cursor 迁移说明。
|
||||
- `docs/ai-env-history/`:Claude/Codex/Cursor 原始对话精简索引和逐会话摘要。
|
||||
- `AGENTS.md` / `CLAUDE.md`:补充 CLI / Shell 中文编码处理规则,要求 UTF-8、乱码复核、中文路径正确加引号。
|
||||
- `C:\Users\Administrator\.cursor\skills`:用户级技能迁移。
|
||||
- `C:\Users\Administrator\.cursor\agents`:用户级子代理迁移。
|
||||
|
||||
## 数据库变更
|
||||
|
||||
无数据库 schema 变更。未执行 DDL,未修改迁移 SQL。
|
||||
|
||||
## 风险与回滚
|
||||
|
||||
- 中:Cursor hooks 与 Claude hooks 事件字段不完全一致,本轮只启用轻量提醒和 ask,不启用强阻断。
|
||||
- 中:历史摘要从原始 JSONL 自动分析,仍可能遗漏自然语言里的隐含决策;关键判断需回看原文和当前代码。
|
||||
- 低:用户级 Cursor 资产覆盖前已备份,可从 manifest 恢复。
|
||||
- 低:Windows 终端中文输出可能受代码页影响;已在根规则和 Cursor 核心规则中要求 UTF-8、乱码不采信、必要时重跑。
|
||||
|
||||
## 验证
|
||||
|
||||
- 运行 `python tools/cursor/migrate_ai_environment.py --check` 校验生成结构。
|
||||
- 运行 `python scripts/audit/prescan.py --files "<本轮迁移文件>"` 做审计预扫描。
|
||||
- 解析 `.mcp.json`、`.cursor/hooks.json`、skill/subagent frontmatter。
|
||||
- 运行 `.venv\Scripts\python.exe scripts\audit\prescan.py --files "AGENTS.md,CLAUDE.md,.cursor/rules/neozqyy-core.mdc,tools/cursor/migrate_ai_environment.py"` 校验中文规则增量。
|
||||
|
||||
## 合规检查
|
||||
|
||||
- 文档同步:已新增 `docs/cursor_migration.md` 和 `docs/ai-env-history/README.md`。
|
||||
- 数据库文档:不适用,本轮无 schema 变更。
|
||||
- 审计记录:已落盘。
|
||||
Reference in New Issue
Block a user