大改版,可以针对不同项目引擎进行初始化

This commit is contained in:
Nostars Developer
2026-07-27 15:09:13 +08:00
parent 6446261c69
commit 62efb3778c
112 changed files with 11020 additions and 899 deletions

View File

@@ -1,199 +1,132 @@
---
name: cursor-init
description: >-
初始化或重置项目的 .cursor 基础设施:保留 canonical Rules、Skills、Hooks 与
Godot baseline清除模板历史数据采集本机环境生成 .gitignore并在验证成功后
写入 .init-done。首次缺少 sentinel 时自动使用;也用于“初始化 cursor”、
“重置 cursor”、“补 gitignore”等请求。
按项目内 catalog 与 manifest 初始化或重置 Cursor 基础设施。首次缺少 sentinel
或用户要求初始化、重置、补齐 Git 忽略配置时使用;只展示当前 ready 的项目类型,
经 dry-run 确认后物化对应 Rules、Skills、Hooks 与本机配置。
---
# Cursor Init
模板仓库或复制来的 `.cursor/` 变成可安全使用、可重复执行的 Godot 项目基线。
详细白名单、清理模式、状态模板、sentinel 和 `.gitignore` 片段统一见
[reference.md](reference.md)。执行全流程或仅补 `.gitignore` 前都必须直接读取该文件,
不得凭记忆重建清单。
复制到目标仓库的 common Cursor 基线与惰性项目 bundle转换为只激活一个
`project_type` 的可重复状态。流程与安全契约见 [reference.md](reference.md),机器真相源位于
`.cursor/bootstrap/`
## 入口
### 首次自动初始化
- 首次会话:`.cursor/.init-done` 不存在,且用户同意初始化
- 手动全流程:`初始化 cursor``cursor init``重置 cursor``reset cursor`
- 只补 Git 配置:`补 gitignore``生成 .gitignore``gitignore 模板`
每次会话首次响应前由 `.cursor/rules/common/cursor-init-recall.mdc` 检查
`.cursor/.init-done`。若 sentinel 不存在:
1. 暂存用户原请求,说明需要先初始化。
2. 获得用户同意后执行本 Skill 的阶段 07。
3. 仅在阶段 6 全部通过后写 sentinel。
4. 初始化成功后继续原请求。
若用户暂时拒绝,尊重选择;不要写 sentinel下次会话仍会提醒。
### 手动全流程
触发词包括:`初始化 cursor``cursor init``重置 cursor``reset cursor`
“清理复制来的 .cursor”、“按基线归位”。
sentinel 已存在时必须先展示其元数据并再次确认;不得把手动触发当作无提示重置。
### 仅补 `.gitignore`
触发词包括:`补 gitignore``生成 .gitignore``gitignore 模板`
只执行阶段 5不得改动 `.cursor/` 的其他内容。若 sentinel 存在,只更新
`gitignore_generated`;若不存在,询问是否改跑完整初始化,不得只为补
`.gitignore` 创建 sentinel。
用户明确要求跳过时不得执行;本初始化框架源码仓也不得因缺少 sentinel 被自动初始化。
## 不可协商的安全契约
1. **先 dry-run后确认才写入**:删除、重置、移动、覆盖、追加都进入同一份预览清单
2. **canonical 永不删除**:尤其不得清空 `.cursor/rules/project/`;六个 Godot baseline
project rules 必须保留
3. **精确白名单**`.cursor/skills/` 最终只能有 reference 中列出的 8 个目录
4. **不触碰来源树**:只处理目标项目;不得删除或修改 `source/`
5. **幂等**:同一输入重复执行,第二次应只产生空或等价 dry-run
6. **失败不写 sentinel**:取消、异常、验证失败或未决冲突都不得创建/更新
`.cursor/.init-done`
7. **运行态不冒充 canonical**`.cursor/local-env.json``.cursor/changelog/.changelog-ack`
`.cursor/changelog/.session-start` 都是 gitignored 本机文件,不是 tracked 白名单项。
8. **文本规范**:新写文本使用 UTF-8 无 BOM、LF。
1. 先检查 Git 状态,再列出支持类型;未确认完整 dry-run 前不写文件
2. 类型选项只能来自脚本 `--list-types` 输出,不在对话中硬编码或展示 `draft` bundle。
3. `.cursor/bootstrap/**` 是自包含可信源,初始化、重置和 cleanup 永不删除或覆盖
4. common canonical 缺失、foreign Rule/Skill、用户修改过的 managed 文件或摘要变化都是阻塞项
5. Apply 必须携带用户确认的 `PLAN_DIGEST`;扫描变化后重新 dry-run
6. 失败、取消或验证未通过时不得写 `.cursor/.init-done`
7. 新写文本使用 UTF-8 无 BOM、LF不得安装第三方依赖。
8. 不运行本 Skill 自行初始化当前 CursorInitGeneral 源码仓
## 阶段 0前置检查
## 标准流程
1. 确认项目根存在 `.cursor/`;不存在则停止并说明缺失。
2. 读取 `.cursor/.init-done`
- 不存在:进入首次初始化。
- 存在:展示 `initialized_at``project_type``skill_version`,等待用户明确继续。
3. 执行 `git status`。有未提交改动时建议先 commit/stash并等待明确继续非 Git
仓库则建议备份,但可继续。
4. 读取 [reference.md](reference.md),声明本轮会保留、删除、重置、生成的范围。
5. 未获得明确确认前不得进入写入阶段。
### 阶段 0前置检查
## 阶段 1一次性采集本机配置
1. 检查项目根、`.cursor/bootstrap/catalog.json` 与脚本是否存在。
2. 读取现有 `.cursor/.init-done`;存在时展示 `project_type``skill_version`
`manifest_digest`,重置或换类型前再次确认。
3. 执行 `git status`;有未提交改动时提醒用户先处理,用户明确继续后才进入问卷。
4. 确认项目声明 Python 3.10+,再运行脚本;版本不满足时停止,不修改业务文件迁就环境。
在**一轮提问**中采集:
### 阶段 1动态问卷
1. `changelog-author`:稳定、适合文件名的作者 handle。
2. `shell``powershell``bash``zsh`;可把当前探测值作为默认。
3. `godot4_path`Godot 4 executable 的绝对路径;允许留空。
先运行:
同一轮可附带询问 `.gitignore` 的写入方式(新建 / 追加 / 替换 / 跳过)和自定义忽略项,
不要把三个环境字段拆成多轮追问。仅收集值,此阶段不写文件。
```bash
python .cursor/bootstrap/tools/cursor_init.py --list-types --json
```
## 阶段 2扫描、分类与 dry-run
仅把输出中的类型作为单选项。用户选择后运行:
递归扫描 `.cursor/`,按 reference 分为:
```bash
python .cursor/bootstrap/tools/cursor_init.py --describe-type --project-type <type> --json
```
- **A / canonical**:精确白名单,保留;缺失项记为阻塞错误。
- **B / cleanup**:历史 fragment、备份、缓存、设备配置、ack、临时文件和状态数据
- **C / foreign**:不属于 A/B 的文件。
在一轮提问中只采集 `collect_at_init` 未设为 `false` 且非 `sensitive`
`local_env_fields`,并询问是否跳过 `.gitignore` / `.gitattributes` managed block
敏感字段只展示键名和说明,要求用户稍后手工填写 `.cursor/local-env.json`,不得在聊天、
命令行或 `--set` 中索取。`general` 表示 common-onlycommon 不作为额外选项。
处理 C 组:
### 阶段 2dry-run
- 非白名单 Skill 必须从 `.cursor/skills/` 移除;如用户要保留,先迁出该目录再删原件。
- 非 baseline project rule 视为模板项目遗留;逐项预览,确认后删除或迁出。
- 通用 `.mdc` 可建议迁到 `.cursor/rules/common/`,但只有九个 common rule 属于本基线;
最终仍需用户明确决定。
- 重名冲突永远保留 canonical 版本;冲突副本只能在用户确认后临时放入
`.cursor/_init-backup/`,并须在阶段 6 前移出或删除。
把允许初始化采集的用户输入作为重复的 `--set KEY=VALUE` 传入;值含空格时按当前
shell 正确引用。不得用 `--set` 传入 sensitive 或 `collect_at_init: false` 字段:
输出一份合并 dry-run至少列出
```bash
python .cursor/bootstrap/tools/cursor_init.py \
--dry-run \
--project-type <type> \
--set shell=<shell> \
--set changelog-author=<handle>
```
- 保留及缺失的 canonical 项;
- 删除的文件/目录;
- 重置的状态文件;
- C 组迁移/删除动作;
- `local-env.json` 生成计划;
- registry 重写计划;
- `.gitignore` 新建/追加/替换计划。
用户选择跳过 Git 文件时附加 `--skip-git-files`。dry-run 必须完整展示:
等待用户对整份计划明确确认。分类不清就问,不得猜。
- 创建、更新、删除的 managed 文件;
- 状态模板和 changelog 历史 cleanup
- foreign、冲突、缺失 common canonical 与必填输入;
- `PLAN_DIGEST`
## 阶段 3执行 cleanup
任何阻塞项都先处理并重新 dry-run。让用户确认整份清单与 digest不拆成多次隐式确认。
严格按已确认 dry-run 和 reference 的 cleanup 表执行:
### 阶段 3Apply 与验证
1. 删除全部历史 changelog fragments只保留 `entries/.gitkeep`
2. 删除全部 backup、cache、编译缓存、ack、session marker、日志和 init 临时文件。
3. 删除旧 `.cursor/local-env.json`;后续从 example 重新生成。
4. 删除非白名单 Skill最终目录名必须恰好为 8 个。
5. 保留六个 Godot baseline project rules绝不执行“清空 rules/project”。
6. 重置 deferred、pitfalls、distillery、profile 状态文件。
7. 在 entries 为空后运行 `changelog_build.py`,确定性重建四个 changelog 视图。
使用与 dry-run 完全相同的类型、`--set` 和 skip 参数,并附确认摘要:
某一步失败立即停止;不要继续“尽量完成”,也不要写 sentinel。
```bash
python .cursor/bootstrap/tools/cursor_init.py \
--apply \
--project-type <type> \
--plan-digest <PLAN_DIGEST> \
--set shell=<shell> \
--set changelog-author=<handle>
```
## 阶段 4重建本机配置与 Registry
脚本会:
### `local-env.json`
1. 重算摘要并拒绝时序变化;
2. 重置模板状态、清理历史运行数据;
3. 只物化所选类型的 Rules/Skills移除未选 bundle 的未修改 managed 文件;
4. 生成 `local-env.example.json``local-env.json`、EPEE Registry 与 Hook scan profile
5. 更新 Git managed blocks未跳过时
6. 验证活动闭包,最后写 `.cursor/.init-state.json``.cursor/.init-done`
1. 读取 `.cursor/local-env.example.json`
2. 深拷贝其 JSON 结构到 `.cursor/local-env.json`,保留 example 中不认识的键。
3. 用阶段 1 的值设置 `changelog-author``shell``godot4_path`
4. `godot4_path` 留空时写空字符串,不伪造路径。
5. 验证 JSON 可解析,且 `.gitignore` 忽略该文件。
完成后运行:
不要引用或等待额外的环境检查 Rule本阶段就是唯一初始化入口。
```bash
python .cursor/bootstrap/tools/cursor_init.py --check
python .cursor/changelog/tools/changelog_build.py --check
```
### Skill Registry
任一失败都报告具体漂移,不手工伪造 sentinel。
`.cursor/skills/epee-orchestrator/registry.md` 校准为磁盘上的 8 个真实 Skill
## 只补 Git 配置
`cursor-init``deferred-decisions``dev-changelog``epee-orchestrator`
`pitfall-journal``problem-distillery``profile-memory``html-doc`
仍先动态列出并选择项目类型,再采集允许初始化采集的本机字段;敏感字段继续由用户
手工维护。使用正常 dry-run/apply但在确认清单中只允许 Git managed blocks 与必要生成文件
发生预期变化;若出现 cleanup、类型切换或活动文件变化询问用户是否改跑完整初始化
不得把它伪装成“只补 gitignore”。
不得保留这 8 项之外的条目或任何磁盘上不存在的 Skill。
每条的路径、类型、能力、触发场景、输出必须与对应 `SKILL.md` 一致。
## Bundle 就绪门槛
## 阶段 5生成或补齐 `.gitignore`
类型只有同时满足以下条件才能在 catalog 标记为 `ready`
使用 [reference.md](reference.md) 的片段,不得临时拼写:
- manifest、payload、Git 片段与 Hook scan 策略完整;
- manifest 引用的 Skill 在 `skills.json` 中登记且 payload 含完整 `SKILL.md` 目录;
- 初始化引擎与 Hook 双平台测试通过;
- `--check` 能验证该类型的活动闭包。
1. 固定加入 Cursor 运行态片段
2. 固定加入 Godot 片段:忽略 `.godot/`,但提交 `*.uid` 和资源 `*.import` sidecar。
3. 按用户 shell/OS 与自定义项补充其他片段。
4. 已有 `.gitignore` 时按阶段 1 的新建/追加/替换/跳过选择处理。
5. 写入前展示最终预览;用户调整后重新预览。
6. 清除与 `*.uid``*.import` 提交要求冲突的旧忽略规则;不要忽略
`.cursor/.init-done`
用户跳过时记录 `gitignore_generated: false`;这不等于流程失败,但报告中必须明确。
## 阶段 6验证
逐项验证,任何失败都回到修复或停止状态:
1. reference 中全部 canonical 文件存在。
2. 九个 common rules 和六个 Godot baseline project rules 全部存在。
3. `.cursor/skills/` 的一级目录集合与 8 项白名单**完全相等**。
4. 所有历史 fragments、backup、cache、旧 ack、session marker 和临时文件均不存在。
5. `entries/.gitkeep` 存在entries 下无其他文件。
6. 四个 changelog 视图与空 entries 经生成器重建的结果一致。
7. 状态文件等于 reference 模板。
8. `local-env.json` 可解析、字段与用户输入一致且被 Git 忽略。
9. registry 恰有 8 项,路径均存在,无三个排除项或旧项目名。
10. 所有 Skill frontmatter `name` 与目录一致description 同时说明 what + when。
11. Skill 内相对引用均存在;不存在环境检查 Rule 的悬空引用。
12. `.gitignore` 忽略 `.godot/``local-env.json`、ack、session marker同时不忽略 `*.uid`
资源 `*.import`
13. 本次写入的文本为 UTF-8 无 BOM、LF。
报告移动、删除、重置、生成、跳过和未解决项。未解决项不为空时不得进入阶段 7。
## 阶段 7写 sentinel
仅在阶段 6 全部通过后,按 reference 模板写 `.cursor/.init-done`。写入后再次读取并验证
字段。`project_type` 固定为 `godot``gitignore_generated` 反映阶段 5 实际结果。
最后提醒用户检查 `git status` 和 diff并提交 `.cursor/.init-done`;不要代替用户提交。
## 验收结果
完整初始化后:
- baseline 结构完整,六个 Godot project rules 仍在;
- `.cursor/skills/` 只有指定 8 个目录;
- 历史数据、backup、cache、ack 与临时文件已清;
- 状态模板与四视图已重置;
- `local-env.json` 已由 example 生成且 gitignored
- `.gitignore` 正确区分 Godot 缓存和需提交的 sidecar
- `.init-done` 只在所有验证通过后存在。
只有计划或空目录的类型必须保持 `draft`Roblox 在完成上述门槛前不得出现在用户问卷中

View File

@@ -1,552 +1,198 @@
# Cursor Init Reference
本文件是 `cursor-init` 的精确数据契约。`SKILL.md` 负责流程,本文件负责 canonical、
cleanup、状态模板、sentinel 与 `.gitignore` 片段。路径均相对项目根
本文件说明多类型初始化的数据契约和验收规则。机器真相源`.cursor/bootstrap/*.json`
流程入口是 [SKILL.md](SKILL.md)。不得在本文件重新维护固定 Rule/Skill 数量
## 1. Canonical 白名单
canonical 是初始化期间必须保留的 tracked 基线。缺失项应报错并从可信模板恢复,
不得用空文件伪造。除这里列出的 8 个 Skill 目录外,`.cursor/skills/` 不允许有其他
一级目录。
### 1.1 顶层配置与生成标记
## 1. 目录边界
```text
.cursor/hooks.json
.cursor/local-env.example.json
.cursor/.init-done
.cursor/
├─ bootstrap/ # tracked、惰性、自包含可信源
│ ├─ catalog.json # 支持类型与状态
│ ├─ common.manifest.json # common canonical、重置与公共策略
│ ├─ skills.json # 全部 Skill 与 Registry 元数据
│ ├─ fragments/ # common Git managed block 片段
│ ├─ templates/ # 状态与空 changelog 模板
│ ├─ tools/cursor_init.py # dry-run/apply/check 引擎
│ ├─ tests/test_cursor_init.py
│ └─ types/<type>/
│ ├─ manifest.json
│ ├─ fragments/
│ └─ payload/ # 未选时不会进入 Cursor 活动目录
├─ rules/common/ # 始终活动
├─ rules/project/ # 只含所选类型general 时仅 .gitkeep
├─ skills/ # common + 所选类型 Skill
├─ hooks/changelog-scan.json # 按类型生成的活动扫描策略
├─ .init-state.json # managed payload 文件 hash
└─ .init-done # 全部验证通过后的提交标记
```
说明:
### 保护边界
- `.cursor/.init-done` 是阶段 7 生成后需要提交的文件;模板源在首次 init 前可以没有
- `.cursor/local-env.json` 是由 example 生成的 gitignored 运行态,不是 canonical
- `.cursor/changelog/.changelog-ack` 是 gitignored hook 运行态,不是 canonical
- `.cursor/changelog/.session-start` 是 sessionStart hook 刷新的 gitignored 运行态,不是 canonical
- `.cursor/bootstrap/**` 永不被 cleanup、类型切换或 reset 修改
- common 只在活动层保存一份;缺失时阻塞,不从不明来源生成空文件
- payload 中的 `.mdc` / `SKILL.md` 不位于 Cursor 活动路径,未选类型不得物化
- `source/` 和业务目录不属于初始化管理范围
### 1.2 Common Rules恰好 9 个基线项)
## 2. Catalog
`.cursor/bootstrap/catalog.json` 字段:
- `schema_version`:当前为 `1`
- `skill_version`sentinel 使用的初始化契约版本;
- `common_manifest``skills_catalog`:相对 bootstrap 的安全路径;
- `types[]``id`、用户标签 `label``status` 与 manifest 路径。
合法状态只有:
- `ready`payload 和片段完整且可通过校验;会出现在 `--list-types`
- `draft`:允许保留设计占位,但不会暴露给用户,也不能 dry-run/apply。
Agent 只能展示脚本返回的 ready 类型不从文档、MCP 或目录名猜测支持范围。
## 3. Common Manifest
`.cursor/bootstrap/common.manifest.json` 是跨类型契约:
- `canonical_files`:必须存在的活动 common 文件;
- `skills`:始终活动的 Skill ID
- `local_env_fields`:所有类型都声明的本机字段;是否由初始化采集由字段元数据决定;
- `scan`Hook 公共扫描策略;
- `gitignore_fragments` / `gitattributes_fragments`:公共 Git 片段;
- `reset_files`:初始化时恢复为空模板的状态文件;
- `cleanup_globs`:确认后删除的历史 fragment、缓存、备份和运行标记。
所有路径必须是项目根或 manifest 根内的相对路径;`..` 与绝对路径非法。
## 4. Type Manifest
每个 `.cursor/bootstrap/types/<type>/manifest.json` 声明:
- `id``version`
- `readiness`:是否允许空 payload以及 ready 时是否强制要求 scan / gitignore
- `files[]`:单文件 source → 活动 target
- `trees[]`:完整目录 source → 活动 target适合项目专属 Skill
- `skills[]`:该类型激活的 Skill ID
- `local_env_fields`:仅选择该类型时生成;是否由初始化采集由字段元数据决定;
- `scan`:与 common 合并的 Hook 文件名、扩展名和排除目录;
- Git managed block 片段。
`general` 表示 common-only不物化 project Rule/Skill。类型切换时只删除已知 managed
且 hash 未被用户修改的旧 bundle 文件;用户改动过的文件必须成为阻塞项。
## 5. Skill Registry
`.cursor/bootstrap/skills.json` 保存每个 Skill 的:
- `id``scope`、活动 `target`
- Registry 的类型、能力、触发场景和输出。
common manifest 和 type manifest 只引用 Skill ID。初始化脚本按活动 ID 生成
`.cursor/skills/epee-orchestrator/registry.md`,并验证对应目录存在 `SKILL.md`
创建、删除、重命名或实质修改 Skill 时,先更新 `skills.json` 与所属 manifest再重新生成 Registry。
## 6. Dry-run 与所有权
dry-run 至少包含:
```text
.cursor/rules/common/baserule.mdc
.cursor/rules/common/changelog-recall.mdc
.cursor/rules/common/cursor-init-recall.mdc
.cursor/rules/common/deferred-recall.mdc
.cursor/rules/common/distillery-recall.mdc
.cursor/rules/common/epee-orchestrator.mdc
.cursor/rules/common/pitfall-recall.mdc
.cursor/rules/common/profile-recall.mdc
.cursor/rules/common/dependency-governance.mdc
创建 / 更新 / 删除
Foreign
阻塞
PLAN_DIGEST
```
### 1.3 Godot baseline Project Rules首次 init 必须保留)
阻塞条件包括:
- common canonical、ready payload 或片段缺失;
- 活动目录存在 manifest 未登记的 Rule/Skill
- managed 文件内容既不等于 payload也不等于 `.init-state.json` 记录的安装 hash
- 本机必填字段缺失;
- Git managed block 标记缺失一端、重复或损坏;
- 路径越界或 schema 无效。
Apply 必须重算同一份计划并比对 digest。只有无阻塞计划才可执行。
## 7. 生成文件
### `local-env.example.json` / `local-env.json`
common 与所选类型的 `local_env_fields` 按顺序合并。每个字段可使用:
- `required`:初始化完成前是否必须提供;
- `sensitive`:值是否属于密钥等敏感信息;
- `collect_at_init`:初始化问卷和 `--set` 是否允许采集。
example 可提交且只能包含占位值local-env 保留未知键和已有用户值,并由 `.gitignore`
忽略。只有非 sensitive 且 `collect_at_init` 未设为 `false` 的字段才允许通过
`--set KEY=VALUE` 提供。敏感字段不阻塞初始化,也不参与状态漂移,真实值必须由用户
手工写入 `.cursor/local-env.json`不得保存密码、Cookie 或会话令牌。
### `changelog-scan.json`
common + type 的 `included_names``included_extensions``excluded_directories` 去重合并。
PowerShell/Bash Hook 只读取此文件会话标记、Git 内容状态与 mtime 的守卫逻辑留在脚本中。
### Git managed blocks
脚本只维护以下标记之间的内容:
```text
.cursor/rules/project/godot-architecture.mdc
.cursor/rules/project/godot-assets.mdc
.cursor/rules/project/godot-data-systems.mdc
.cursor/rules/project/godot-gdscript-style.mdc
.cursor/rules/project/godot-scene-conventions.mdc
.cursor/rules/project/godot-testing.mdc
# >>> cursor-init managed >>>
...
# <<< cursor-init managed <<<
```
禁止用 `.cursor/rules/project/*.mdc` 之类的通配删除覆盖这些文件。
标记外用户内容不得覆盖。选择 `--skip-git-files` 时不改 `.gitignore` / `.gitattributes`
sentinel 写 `gitignore_generated: false`
### 1.4 Skills最终恰好 8 个目录)
### `.init-state.json`
```text
.cursor/skills/cursor-init/
.cursor/skills/deferred-decisions/
.cursor/skills/dev-changelog/
.cursor/skills/epee-orchestrator/
.cursor/skills/pitfall-journal/
.cursor/skills/problem-distillery/
.cursor/skills/profile-memory/
.cursor/skills/html-doc/
```
记录当前项目类型、bundle 版本、manifest digest 与已物化 payload 文件 hash用于区分
bundle 升级和用户修改。它需要提交,不能包含本机绝对路径或秘密。
目录内 canonical 文件:
## 8. Sentinel
```text
.cursor/skills/cursor-init/SKILL.md
.cursor/skills/cursor-init/reference.md
.cursor/skills/deferred-decisions/SKILL.md
.cursor/skills/dev-changelog/SKILL.md
.cursor/skills/epee-orchestrator/SKILL.md
.cursor/skills/epee-orchestrator/registry.md
.cursor/skills/pitfall-journal/SKILL.md
.cursor/skills/problem-distillery/SKILL.md
.cursor/skills/profile-memory/SKILL.md
.cursor/skills/html-doc/SKILL.md
.cursor/skills/html-doc/assets/theme.css
.cursor/skills/html-doc/assets/annotate.js
.cursor/skills/html-doc/templates/skeleton.html
```
### 1.5 Hooks 全套
```text
.cursor/hooks.json
.cursor/hooks/README.md
.cursor/hooks/run-hook.ps1
.cursor/hooks/session-init.ps1
.cursor/hooks/session-init.sh
.cursor/hooks/check-changelog.ps1
.cursor/hooks/check-changelog.sh
```
### 1.6 Changelog tools 全套
```text
.cursor/changelog/tools/changelog_build.py
.cursor/changelog/tools/migrate_changelog.py
.cursor/changelog/tools/install-git-hooks.ps1
.cursor/changelog/tools/install-git-hooks.sh
.cursor/changelog/tools/merge-import.ps1
.cursor/changelog/tools/merge-import.sh
.cursor/changelog/tools/git-hooks/pre-commit
.cursor/changelog/tools/git-hooks/post-merge
```
`tools/__pycache__/``*.pyc` 永远不是 canonical。
### 1.7 Changelog 四视图与 entries 占位
```text
.cursor/changelog/changelog-full.md
.cursor/changelog/changelog-recent.md
.cursor/changelog/changelog-headlines.md
.cursor/changelog/changelog-by-author.md
.cursor/changelog/entries/.gitkeep
```
四视图由 `changelog_build.py` 生成,不手改。初始化时先清空 entries保留
`.gitkeep`),再运行生成器得到空视图。
### 1.8 状态模板文件
```text
.cursor/deferred/registry.md
.cursor/pitfalls/pitfalls.md
.cursor/distillery/problems.md
.cursor/distillery/insights.md
.cursor/distillery/golden-rules.md
.cursor/profile/project-profile.md
.cursor/profile/project-profile-log.md
```
## 2. Cleanup 清单
### 2.1 强制删除
下面内容必须进入 dry-run确认后删除
```text
# 全部历史 changelog fragment唯一例外是 entries/.gitkeep
.cursor/changelog/entries/**
!.cursor/changelog/entries/.gitkeep
# 历史备份
.cursor/changelog/_backup/**
.cursor/_init-backup/**
.cursor/**/_backup/**
.cursor/**/*.bak
.cursor/**/*.backup
# 缓存和编译产物
.cursor/**/__pycache__/**
.cursor/**/*.pyc
.cursor/**/*.pyo
.cursor/**/*.cache
.cursor/**/.cache/**
# 设备绑定与 hook 运行态
.cursor/local-env.json
.cursor/changelog/.changelog-ack
.cursor/changelog/.session-start
# init / 调试临时产物
.cursor/_gitignore-preview
.cursor/**/*.tmp
.cursor/**/*.temp
.cursor/**/*.log
.cursor/debug-*.log
```
模式中的 `!` 只是“例外”说明,不表示可把这段直接交给任意删除命令。实现时必须先枚举
实际文件并逐项比对白名单,防止通配误删。
此外:
- 删除 `.cursor/skills/` 下所有非 8 项白名单目录。
- 删除或迁出非 baseline project rules但必须逐项确认六个 baseline 永不删除。
- 删除任何非 8 项白名单 Skill。
- 不删除 `source/`,不修改项目根 Git 文件(`.gitignore` 仅在用户明确选择时例外)。
### 2.2 重置而非删除
以下文件保留路径并重置为第 3 节模板:
```text
.cursor/deferred/registry.md
.cursor/pitfalls/pitfalls.md
.cursor/distillery/problems.md
.cursor/distillery/insights.md
.cursor/distillery/golden-rules.md
.cursor/profile/project-profile.md
.cursor/profile/project-profile-log.md
```
四个 changelog 视图不使用手写模板覆盖:删除 fragments 后运行生成器重建。
### 2.3 环境配置入口
本机环境只由 `cursor-init` 阶段 1 和阶段 4 一次性采集、生成,不依赖额外环境检查 Rule。
## 3. 状态模板
写入时替换 `{{DATE}}` 为本地日期 `YYYY-MM-DD`
### 3.1 `.cursor/deferred/registry.md`
```markdown
# Deferred Decisions Registry
## Active Items
(暂无延期方案)
---
## Completed / Cancelled Items
(暂无已完成或已废弃的方案)
```
### 3.2 `.cursor/pitfalls/pitfalls.md`
```markdown
# Pitfall Journal
开发过程中踩过的坑,按时间倒序排列。
Agent 进入 Debug mode 或遇到运行时错误时自动检索匹配。
---
```
### 3.3 `.cursor/distillery/problems.md`
```markdown
# Problem Distillery — Problems
反复出现的顽固问题追踪记录,按时间倒序排列。
<!-- 新条目追加在此行下方 -->
```
### 3.4 `.cursor/distillery/insights.md`
```markdown
# Problem Distillery — Insights
从已解决的顽固问题中蒸馏出的精炼方法论。
<!-- 新条目追加在此行下方 -->
---
last_distill_date: {{DATE}}
```
### 3.5 `.cursor/distillery/golden-rules.md`
```markdown
# Golden Rules
经过实践验证(权重 >= 5的精炼认知每次新会话自动注入。
<!-- 当条目达到权重阈值后由 Agent 自动写入 -->
```
### 3.6 `.cursor/profile/project-profile.md`
```markdown
# Project Profile
## 项目定位
## 技术栈与架构
## 设计约定
## 产品方向
```
### 3.7 `.cursor/profile/project-profile-log.md`
```markdown
# Project Profile Log
详细记录每次项目画像更新的完整上下文,按时间正序追加。
## 记录
```
## 4. 空 Changelog 四视图
`.cursor/changelog/tools/changelog_build.py` 的输出为准。entries 仅有 `.gitkeep` 时,
生成结果应具备以下固定头部且无条目:
### 4.1 `changelog-headlines.md`
```markdown
# Dev Changelog — Headlines
最近 ~50 次改动的一句话概要,按时间倒序排列。每次会话自动注入上下文。
> 本文件由 `tools/changelog_build.py` 从 `entries/` 自动生成,请勿手改。
```
### 4.2 `changelog-recent.md`
```markdown
# Dev Changelog — Recent
最近 ~20 次改动的摘要记录,按时间倒序排列。
当 Agent 检测到当前任务与近期改动相关时自动读取。
> 本文件由 `tools/changelog_build.py` 从 `entries/` 自动生成,请勿手改。
```
### 4.3 `changelog-full.md`
```markdown
# Dev Changelog — Full
完整的开发改动记录,按时间倒序排列。作为主动 RAG 的数据源,用户手动唤醒时读取。
> 本文件由 `tools/changelog_build.py` 从 `entries/` 自动生成,请勿手改;新增/修改请编辑 `entries/<author>/<id>.md` 后重跑生成器。
## 记录
```
### 4.4 `changelog-by-author.md`
```markdown
# Dev Changelog — By Author
按作者聚合的贡献概览,便于多人协作时区分提交来源。
> 本文件由 `tools/changelog_build.py` 自动生成,请勿手改。
```
生成器统一以单个 LF 结尾,不保留多余空白行;验证应比较生成器实际输出,不自行 trim 后回写。
## 5. `local-env.json` 生成契约
必须读取 `.cursor/local-env.example.json`,复制完整 JSON 结构,再覆盖三个键:
```json
{
"shell": "{{SHELL}}",
"changelog-author": "{{CHANGELOG_AUTHOR}}",
"godot4_path": "{{GODOT4_EXECUTABLE_OR_EMPTY}}"
}
```
规则:
- example 中其他键原样保留,不以这段最小示例覆盖整个文件。
- `godot4_path` 可为空字符串。
- 不写用户未确认的自动猜测值。
- 文件必须能被 JSON parser 读取,并由 `.gitignore` 忽略。
- 不提交 `local-env.json`
## 6. `.init-done` 模板
仅在全部验证通过后写入:
`.cursor/.init-done` 仅在 apply 后活动闭包再次验证通过时写入:
```yaml
# .cursor/.init-done — cursor-init 写入的初始化标记
# 必须提交此文件,避免 clone 后重复触发初始化
initialized_at: {{ISO_DATETIME}}
initialized_by: cursor-init
skill_version: 3
project_type: godot
gitignore_generated: {{BOOL}}
initialized_at: <ISO_DATETIME>
schema_version: 1
skill_version: <catalog.skill_version>
project_type: <single-ready-type>
bundle_version: <type-manifest.version>
manifest_digest: <sha256>
gitignore_generated: true|false
```
`{{BOOL}}` 只能是 `true``false`。流程失败、取消或存在未解决项时不得写入。
sentinel 和 `.init-state.json` 字段必须与当前 manifest 一致。取消、摘要变化、部分写入或验证失败
都不得创建/更新 sentinel。
## 7. `.gitignore` 片段
## 9. Hook 契约
拼装顺序
`check-changelog.ps1``.sh` 必须保持相同行为
1. Cursor runtime
2. Godot
3. OS / IDE / Language如用户需要
4. Custom
1. 非 Agent mode、缺 changelog、缺 scan config、缺 `.session-start` 时返回 `{}`
2. Git 不可用、状态失败或工作区无内容差异时返回 `{}`
3. 只扫描活动配置命中的文件,并要求 mtime 晚于 session/changelog
4. 候选路径还必须被 `git status --porcelain` 判定为未提交改动;
5. 任意解析或运行错误 fail-open不阻断用户。
追加到已有文件时,用以下分隔
回归测试入口
```gitignore
# --- 以下由 cursor-init 追加 ---
```bash
python .cursor/hooks/tests/test_check_changelog.py
```
### 7.1 Cursor runtime固定
## 10. 验收
```gitignore
# === Cursor runtime ===
.cursor/local-env.json
.cursor/changelog/.changelog-ack
.cursor/changelog/.session-start
.cursor/_init-backup/
.cursor/_gitignore-preview
初始化或重置完成后:
# .cursor/.init-done 是需提交的完成标记,不得忽略
```
### 7.2 Godot固定
```gitignore
# === Godot ===
# 编辑器导入缓存可重建,不提交
.godot/
# Godot 4 UID sidecar 与资源导入配置是项目元数据,必须提交
!*.uid
!**/*.uid
!*.import
!**/*.import
```
写入前检查并移除或修正已有的冲突规则,例如 `*.uid``*.import``**/*.uid`
`**/*.import`。不要把 `.godot/` 内的生成缓存误认为资源旁的 `*.import` sidecar。
### 7.3 Windows
```gitignore
# === OS: Windows ===
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
Desktop.ini
$RECYCLE.BIN/
*.stackdump
*.lnk
```
### 7.4 macOS
```gitignore
# === OS: macOS ===
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
```
### 7.5 Linux
```gitignore
# === OS: Linux ===
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*
```
### 7.6 VS Code
```gitignore
# === IDE: VS Code ===
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
.history/
*.vsix
```
### 7.7 JetBrains
```gitignore
# === IDE: JetBrains ===
.idea/
*.iml
*.ipr
*.iws
.idea_modules/
```
### 7.8 Visual Studio
```gitignore
# === IDE: Visual Studio ===
.vs/
*.user
*.suo
*.userprefs
bin/
obj/
[Dd]ebug/
[Rr]elease/
x64/
x86/
```
### 7.9 Vim / Emacs
```gitignore
# === IDE: Vim / Emacs ===
*.swp
*.swo
*.swn
Session.vim
.netrwhist
*~
\#*\#
.\#*
```
### 7.10 Custom
```gitignore
# === Custom ===
# 在此追加项目专属忽略项
```
## 8. Dry-run 输出格式
```markdown
## cursor-init dry-run
### 保留
- path — canonical
### 缺失(阻塞)
- path — 需要从可信模板恢复
### 删除
- path — cleanup 原因
### 重置
- path — 使用的模板
### 迁移 / 冲突
- from → to — 原因与是否需要用户选择
### 生成
- .cursor/local-env.json — 输入字段摘要(不要泄露不必要的本机信息)
- .cursor/skills/epee-orchestrator/registry.md — 8 项
- .gitignore — 新建 / 追加 / 替换 / 跳过
- .cursor/.init-done — 仅验证成功后
```
确认必须覆盖整份 dry-run。dry-run 后扫描结果变化时应重新生成清单并再次确认。
- `python .cursor/bootstrap/tools/cursor_init.py --check` 通过;
- 活动 project Rules/Skills 与单选类型闭包完全一致,未选 payload 仍惰性保留;
- Registry、scan config、local-env example、Git managed blocks 与 manifest 一致;
- cleanup 后 changelog entries 仅有 `.gitkeep`,状态文件等于模板;
- `python .cursor/changelog/tools/changelog_build.py --check` 通过;
- Hook 双实现测试、初始化引擎测试、`git diff --check` 通过;
- 本轮写入文本为 UTF-8 无 BOM、LF。

View File

@@ -84,17 +84,18 @@ description: >-
```
1. 读取目标 Skill 的 SKILL.md
2. 从 frontmatter 提取 name 和 description
3. 从正文提取核心能力和触发场景关键词
4. 读取 registry.md
5. 新增或更新对应条目,遵循 registry.md 中定义的条目格式
6. 写回 registry.md
2. 更新 .cursor/bootstrap/skills.json 中对应条目的作用域、能力、触发场景和输出
3. 若 Skill 是项目类型专属,同时更新所属 type manifest 的 skills 与 payload 文件树
4. 若 Skill 是 common同时更新 common.manifest.json 的 skills 与 canonical_files
5. 运行:
python .cursor/bootstrap/tools/cursor_init.py --sync-registry
6. 运行初始化引擎测试与 --check确认 Registry 和磁盘活动 Skill 一致
```
### 条目格式
参见 [registry.md](registry.md) 中的条目结构。Registry 条目必须对应磁盘上真实存在的
Skill删除 Skill 时同步移除条目
机读格式见 `.cursor/bootstrap/skills.json`[registry.md](registry.md) 是生成视图,不手改。
Registry 条目必须对应磁盘上真实存在的活动 Skill删除 Skill 时同步移除机读条目和 manifest 引用
## Skill 创建价值判断标准
@@ -116,7 +117,7 @@ Skill删除 Skill 时同步移除条目。
| `create-skill` Skill | 下游委托 | 操作 B 创建流程的执行者 |
| `deferred-decisions` Skill | 下游工具 | 操作 B 延期记录的执行者 |
| `deferred-recall` Rule | 协同 | 延期建议通过 deferred-recall 在未来自动提醒 |
| `cursor-init` Skill | 校准 | 初始化时把 Registry 校准为实际 8 个 Skill |
| `cursor-init` Skill | 校准 | 初始化时按 common + 所选项目类型生成活动 Registry |
## 自迭代日志
@@ -126,4 +127,4 @@ Skill删除 Skill 时同步移除条目。
1. **收尾动作级联遗漏** — 当 Agent 遗漏了一个收尾动作(如 changelog 写入)后,
后续的 Registry 同步也容易遗漏。每次创建、删除或实质修改 Skill 后都应把
Registry 同步作为独立检查项。
`skills.json`、所属 manifest 与生成 Registry 同步作为独立检查项。

View File

@@ -1,66 +1,56 @@
# EPEE Skill Registry
> 本文件由 EPEE Skill Orchestrator 维护,只登记磁盘上真实存在的 Skill
> 创建、删除或实质修改 Skill 后必须同步更新。
## 条目格式
- **类型**:基础设施 / 个人级
- **能力**:该 Skill 做什么
- **触发场景**:何时使用
- **输出**:实际产出
- **路径**:存在的 `SKILL.md` 相对路径
---
> 本文件由 `.cursor/bootstrap/tools/cursor_init.py` 根据 `skills.json` 生成
> 创建、删除或实质修改 Skill 后必须更新机读源并重新生成
## 已注册 Skill
### cursor-init
- **类型**: 基础设施
- **能力**: 以精确 canonical 白名单初始化或重置 `.cursor/`,保留 Godot baseline清理历史运行数据生成本机配置与 `.gitignore`,并在验证成功后写 sentinel
- **触发场景**: 首次缺少 `.cursor/.init-done`、"初始化 cursor"、"cursor init"、"重置 cursor"、"补 gitignore"
- **输出**: 干净且通过验证的 `.cursor/` 基线、gitignored `local-env.json`、可选 `.gitignore``.cursor/.init-done`
- **能力**: 按机读 catalog 与 manifest 安全初始化或重置 Cursor 基础设施,并校验活动 Rules、Skills、Hooks 与项目类型配置
- **触发场景**: 首次缺少 .cursor/.init-done初始化 cursorcursor init重置 cursor补 gitignore
- **输出**: 通过验证的 common 基线、所选项目类型活动文件、本机配置、Git managed blocks 与 .cursor/.init-done
- **路径**: .cursor/skills/cursor-init/SKILL.md
### deferred-decisions
- **类型**: 基础设施
- **能力**: 记录和追踪延期的技术方案或决策,并在关联任务出现时提醒
- **触发场景**: "以后再做"、"先不做"、"defer"、延期方案管理、延期回顾
- **输出**: `.cursor/deferred/registry.md` 条目及状态更新
- **触发场景**: 以后再做、先不做、defer、延期方案管理、延期回顾
- **输出**: .cursor/deferred/registry.md 条目及状态更新
- **路径**: .cursor/skills/deferred-decisions/SKILL.md
### dev-changelog
- **类型**: 基础设施
- **能力**: 以一条一文件的 fragment 记录开发改动,并确定性重建完整、近期、概要和作者四个视图
- **触发场景**: 实质代码或配置改动完成后、"开发日志"、"changelog"、"最近改了什么"、"回顾改动"
- **输出**: `.cursor/changelog/entries/<author>/<id>.md` 与四个生成视图
- **触发场景**: 实质代码或配置改动完成后、开发日志changelog最近改了什么回顾改动
- **输出**: .cursor/changelog/entries/<author>/<id>.md 与四个生成视图
- **路径**: .cursor/skills/dev-changelog/SKILL.md
### epee-orchestrator
- **类型**: 基础设施
- **能力**: 匹配已有 Skill、发现可复用工作流缺口并维护与磁盘一致的 Skill Registry
- **能力**: 匹配已有 Skill、发现可复用工作流缺口并维护与活动 Skill 集合一致的 Registry
- **触发场景**: 手动配置密集、重复模式明确、步骤繁多、Skill 缺口发现、Registry 同步
- **输出**: Skill 分流或创建建议,以及 `.cursor/skills/epee-orchestrator/registry.md` 更新
- **输出**: Skill 分流或创建建议,以及由 skills.json 生成的 registry.md
- **路径**: .cursor/skills/epee-orchestrator/SKILL.md
### pitfall-journal
- **类型**: 基础设施
- **能力**: 记录非显而易见问题的症状、根因、解法和防御措施,并在同类问题出现时检索
- **触发场景**: debug 完成、问题反复出现、"踩坑"、"之前遇到过"、进入 Debug mode
- **输出**: `.cursor/pitfalls/pitfalls.md` 条目或匹配到的既有经验
- **触发场景**: debug 完成、问题反复出现、踩坑之前遇到过、进入 Debug mode
- **输出**: .cursor/pitfalls/pitfalls.md 条目或匹配到的既有经验
- **路径**: .cursor/skills/pitfall-journal/SKILL.md
### problem-distillery
- **类型**: 基础设施
- **能力**: 追踪反复未解决的问题,蒸馏方法论,并把经验证的 insight 升级为 Golden Rule
- **触发场景**: "还有问题"、"没解决"、"还是一样"、同一问题尝试两次以上、"蒸馏"、"总结经验"
- **输出**: `.cursor/distillery/problems.md``insights.md``golden-rules.md`
- **触发场景**: 还有问题、没解决、还是一样、同一问题尝试两次以上、蒸馏总结经验
- **输出**: .cursor/distillery/problems.mdinsights.mdgolden-rules.md
- **路径**: .cursor/skills/problem-distillery/SKILL.md
### profile-memory
- **类型**: 个人级
- **能力**: 检测并经确认持久化用户偏好与项目画像,支持查看、修改、删除和溯源
- **触发场景**: 持久偏好或项目决策出现、"画像"、"profile"、"我的偏好"、"查看项目画像"
- **触发场景**: 持久偏好或项目决策出现、画像profile我的偏好查看项目画像
- **输出**: 用户与项目的精简 Profile 及详细 Log
- **路径**: .cursor/skills/profile-memory/SKILL.md
@@ -68,5 +58,5 @@
- **类型**: 个人级
- **能力**: 生成统一深色主题的单文件 HTML 文档,并可选提供本地暂存和回传批注功能
- **触发场景**: HTML 参考手册、说明页、报告、清单、统一 HTML 样式、可批注文档
- **输出**: 内联 CSS/JS 的自包含 `.html` 文档
- **输出**: 内联 CSS/JS 的自包含 .html 文档
- **路径**: .cursor/skills/html-doc/SKILL.md