Files
CursorInitGeneral/.cursor/rules/common/cursor-init-recall.mdc
2026-04-21 17:08:42 +08:00

80 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: 引导 Agent 在首次会话自动、后续通过关键词手动触发 cursor-init Skill
globs:
alwaysApply: true
---
## 首次初始化自检(最高优先级 · 必须最先执行)
**每一次会话的首次用户消息响应之前**Agent 必须先检查工作区是否存在 `.cursor/.init-done`
### 判定逻辑
```
IF .cursor/.init-done 不存在:
→ 本仓库是"clone 模板后的首次会话"
→ 必须在处理用户原始请求之前先完成 cursor-init
ELSE:
→ 已 init 过,跳过本自检
→ 仅当用户命中下方"手动触发关键词"时才再次执行本 Skill
```
### 首次触发的执行方式
1. **暂存用户原始请求**,明确告诉用户:
> "检测到当前仓库刚从模板 clone 下来,还未完成 .cursor 初始化。需要先跑一遍 cursor-init
> (清理模板遗留数据、配置项目画像、可选生成 .gitignore。完成后再处理你的请求{原始请求概要}。"
2. 等用户明确回复"继续/OK"后,读取 `.cursor/skills/cursor-init/SKILL.md` 并严格执行阶段 0 → 7
3. **init 完成后**(阶段 7 写入 `.init-done` 成功后),回到被暂存的用户原始请求继续处理
4. 若用户说"先不做 init就处理我的请求"
- 尊重用户选择,跳过本次 init
- 但仍在本次回复中明确说明 sentinel 缺失,并提示"下次会话还会再次提醒"
### 自检成本说明
已 init 项目:每次会话仅多一次 `Read .cursor/.init-done`(极低成本)。
若 Read 失败或路径不存在,即按"首次"处理。
---
## 手动触发关键词(任意时刻,已 init 仓库也可用)
### A. 全流程重置(阶段 0 → 7
匹配任一:
- "初始化 cursor" / "初始化cursor" / "cursor 初始化"
- "重置 cursor" / "reset cursor"
- "cursor init" / "init cursor"
- "把复制过来的 .cursor 清理一下" / "按 baserule 归位一下"
**执行方式**:读取 `.cursor/skills/cursor-init/SKILL.md`,按阶段 0 → 7 执行。
若 `.cursor/.init-done` 已存在,阶段 0 会展示其元数据并要求用户二次确认。
### B. 仅补 .gitignore只跑阶段 5.5
匹配任一:
- "补 gitignore" / "补一下 gitignore" / "补个 gitignore"
- "生成 gitignore" / "生成 .gitignore"
- "gitignore 模板" / "来份 gitignore"
**执行方式**:读取 SKILL.md 的**阶段 5.5 章节**单独执行,不触碰其他阶段。
完成后更新 `.init-done` 中的 `gitignore_generated: true`。
---
## 执行原则
1. **稳定准确优先于 token 成本**
2. 破坏性操作(删除、重置、移动)前必须给用户 dry-run 清单
3. 分类不清的文件必须逐条询问用户,不要猜
4. 开始前先执行 `git status` 并提醒用户 commit/stash
5. 设计为幂等——重复运行在已干净状态下不应造成破坏
---
## 不触发本 Skill 的情况
- 用户只是问"cursor 有什么 skill" —— 这是浏览需求,走 `epee-orchestrator` 的操作 A
- 用户只是想初始化某个具体数据文件(如"初始化画像")—— 走对应 Skill`profile-memory` 等),不涉及全局重置
- `.cursor/.init-done` 存在 且 用户请求中**没有**任一 A/B 组关键词 —— 正常响应用户,不提 init