diff --git a/skills/plan/project-init/SKILL.md b/skills/plan/project-init/SKILL.md index ab03e04..3144ac9 100644 --- a/skills/plan/project-init/SKILL.md +++ b/skills/plan/project-init/SKILL.md @@ -9,9 +9,7 @@ allowed-tools: Read Write Glob Edit Skill Bash(node *) Bash(git init) Bash(git r ## 执行步骤 -### A. 幂等复制模板文件(用 Glob + Read + Write,跨平台无 shell) - -对下表每个文件:先用 `Glob` 判断目标路径是否已存在;**已存在则跳过**;不存在则用 `Read` 读模板、用 `Write` **原样**写到目标路径(`Write` 会自动创建缺失的父目录)。 +### A. 幂等复制模板文件 | 模板 | 目标路径 | |---|---| @@ -20,63 +18,25 @@ allowed-tools: Read Write Glob Edit Skill Bash(node *) Bash(git init) Bash(git r | `${CLAUDE_SKILL_DIR}/templates/docs-04-stack-template.md` | `docs/04-技术规范.md` | | `${CLAUDE_SKILL_DIR}/templates/docs-08-initial-template.md` | `docs/08-模块任务管理.md` | -完成后,用 `Edit` 在 `docs/08-模块任务管理.md` 中勾选: +完成后,在 `docs/08-模块任务管理.md` 中勾选: - ` - [ ] 项目文件骨架已创建(CLAUDE.md + docs/01-需求清单/index.md + docs/04-技术规范.md)` -### B. 依赖检查(跨平台,只检测不自动安装) - -检测 git/mysql/node 是否在 PATH; 缺失则打印 OS 对应安装指引并停下. - -用 `Bash` 跑下面这段 `node` 脚本: - -```bash -node -e ' -const { spawnSync } = require("node:child_process"); -const plat = process.platform; -const has = (cmd) => { - const r = plat === "win32" - ? spawnSync("where", [cmd], { stdio: "ignore" }) - : spawnSync("sh", ["-c", "command -v " + cmd], { stdio: "ignore" }); - return r.status === 0; -}; -const guide = { - darwin: { git: "xcode-select --install 或 brew install git", - mysql: "brew install mysql", - node: "brew install node 或见 https://nodejs.org" }, - linux: { git: "sudo apt-get install git / sudo yum install git / sudo apk add git", - mysql: "sudo apt-get install mysql-client / sudo yum install mysql", - node: "sudo apt-get install nodejs 或见 https://nodejs.org" }, - win32: { git: "winget install Git.Git 或见 https://git-scm.com/download/win", - mysql: "winget install Oracle.MySQL 或见 https://dev.mysql.com/downloads/", - node: "winget install OpenJS.NodeJS 或见 https://nodejs.org" }, -}[plat] || {}; -const tools = ["git", "mysql", "node"]; -const missing = tools.filter((t) => !has(t)); -const mark = (t) => (missing.includes(t) ? "✗" : "✓"); -console.log("[project-init] 依赖检查 (" + plat + "): " + tools.map((t) => t + " " + mark(t)).join(" ")); -if (missing.length) { - console.error("[project-init] 缺失依赖,请先安装后重跑:"); - for (const t of missing) console.error(" - " + t + " : " + (guide[t] || "见对应官网")); - process.exit(1); -} -' -``` +### B. 依赖检查 -- 退出码 `0`(全部 ✓)→ 进入步骤 C -- 退出码 `1`(有缺失)→ 已打印缺失工具 + OS 安装指引,**停下**,提示用户安装后重跑本 skill +检测 git/mysql/node 是否在 PATH; 缺失则自动安装;如果安装失败失败再停下并提示用户. -完成后,用 `Edit` 在 `docs/08-模块任务管理.md` 中勾选: +完成后,在 `docs/08-模块任务管理.md` 中勾选: - ` - [ ] 依赖检查通过` ### C. 初始化 Git(如尚未初始化) -用 `Bash` 执行 `git rev-parse --is-inside-work-tree`。 +执行 `git rev-parse --is-inside-work-tree`。 - 退出码 `0` 且 stdout 为 `true` → 已在 git 仓库中,跳过。 - 非 `0` → 用 `Bash` 执行 `git init`。 不要用 `.git/` 目录是否存在判断:git worktree / 子模块 / 某些托管环境会使用 `.git` 文件,目录探测会误判。 -完成后,用 `Edit` 在 `docs/08-模块任务管理.md` 中勾选(A0 子项 + A0 顶层): +在 `docs/08-模块任务管理.md` 中勾选(A0 子项 + A0 顶层): - ` - [ ] Git 已初始化` - `- [ ] A0 项目初始化 — project-init` diff --git a/skills/plan/project-init/templates/CLAUDE-template.md b/skills/plan/project-init/templates/CLAUDE-template.md index 2f9b875..ef339ff 100644 --- a/skills/plan/project-init/templates/CLAUDE-template.md +++ b/skills/plan/project-init/templates/CLAUDE-template.md @@ -13,20 +13,6 @@ --- -## 🔄 B 阶段开发流程 - -B 阶段由 `/erp-workflow:coding-start` 启动 `workflows/coding.mjs`:按模块循环跑 spec → plan → tdd → verify → review(同构 `featureLoop`),后端每模块一个里程碑 tag,前端整体一个里程碑 tag。里程碑字段与子项清单记录在 `docs/08 § 二`(后端)/ `§ 三`(前端);阶段完成判定以 `里程碑:` / `整体里程碑:` 字段 + 本地 `git tag -l 'milestone/'` 为准,子项勾选只作可视化进度。详细路由 / testGate / 中断行为见 `README.md` 与 `workflows/coding.mjs`。 - ---- - -## 🏷️ 占位符统一约定 - -项目文档里两种人工填写占位: -- `【人工填写:<简短说明>】` — 仅 A 阶段文档;B 阶段 plan/spec 禁止出现,查不到真值时用 `AskUserQuestion` 问用户。 -- `TBD(<责任人>)` — 由对应 skill / `coding.mjs` stage 自动就地补填(如 `TBD(A3 自动补)`);模块完成报告 § ⑦ 检查 `TBD(CC 补)` 残留。 - ---- - ## 📐 编码行为约束 ### 你必须做的 ✅ @@ -36,12 +22,10 @@ B 阶段由 `/erp-workflow:coding-start` 启动 `workflows/coding.mjs`:按模 3. **每个后端接口** 必须先在 `docs/05-API接口契约.md` 定义,再编码实现 4. **每个功能可追溯到 `REQ-XXX-NNN`**——commit tag + 代码注释(如 `// REQ-SYS-001: 用户登录`)+ plan/spec 文件名均用此 tag 5. **遇到跨模块改动**(动到非当前模块的代码)——按 § 🟡 软规则 **S2** 执行(允许改,但必须留痕) -6. **遇到技术栈外组件引入**(`docs/04 § 零` 技术栈表外的框架 / 中间件 / 关键库),按 § 🟡 软规则 **S1** 执行(允许引入,但必须先 AskUserQuestion) ### 你禁止做的 🚫 1. **主会话直接 `mysql -e` 跑业务 DDL**(只读查询 / 临时本地调试除外)——业务 schema 必须走 `sql/migrations/V_n__*.sql`,详见下方 Schema 演化规约 -2. **手动 Edit `docs/08 § 二/§ 三` 的 `里程碑:` / `整体里程碑:` 字段**,必须要由 `coding.mjs` 的 milestone stage 自动回写 ### Schema 演化规约(Flyway migration) @@ -77,34 +61,3 @@ B 阶段由 `/erp-workflow:coding-start` 启动 `workflows/coding.mjs`:按模 | `test` | **只动测试代码**——补用例 / 修 fixture,不碰实现 | | `chore` | **流程维护**——构建 / 依赖 / 工具 / 证据档案 / 里程碑元数据等非业务动作 | ---- - -## 🚩 中断机制 - -功能循环(每个功能 REQ-XXX 的 Brainstorm → Plan → TDD → Verify → AI 自审)默认 **静默编程**,但触发以下任何一条必须**立刻停下、记录原因、等人决策**,不得自行绕过: - -| # | 中断 | 例子 | -| - | --- | --- | -| 1 | **测试反复失败** | 同一测试同一功能内连续 **10 次**修复失败 | -| 2 | **要改密钥 / 账密 / 包名** | 密钥 / 账密 在 `.env.local`、包名 / 命名空间 / 端口等在 `config-vars.yaml` 里由人工标注必须填的字段(规则见 `docs/07-环境配置.md`) | -| 3 | **外部接口不可达** | 第三方 API 无法连接、证书失效等环境问题,并无法自行解决 | - -> 其余需要人类判断的场景一律走普通 `AskUserQuestion` Q&A,不中断、不写 Blocker 文件。 - -**触发中断时的固定动作:** - -1. `coding.mjs` 子代理在当前功能的 plan 文件里追加一节 `## 🚩 Blocker`(记录原因 / 阻塞点),并 throw 进入 HALT 终止态 -2. 整阶段 fail-fast:halt 后停止后续所有模块/功能的静默执行 -3. Workflow 返回结构化诊断(halt 原因 + blocker 文件路径),等人修复后重跑 `/erp-workflow:coding-start` 从断点续跑 - ---- - -## 🟡 软规则(允许继续,但有强制后续动作) - -以下情况 **不触发中断**,CC 可自行继续推进,但必须在约定位置留痕,模块完成时统一审计。 - -| # | 软规则 | 允许动作 | 强制后续 | -| - | ----- | ------- | ------- | -| S1 | **技术栈外组件引入** | 用 `AskUserQuestion` 给用户三选一:接受引入 / 换方案 / 拒绝 | ① **接受** → 同会话直接在 `docs/04 § 零` 追加一行 → 继续流程 ② **换方案 / 拒绝** → 视为常规歧义澄清,继续 Q&A 收敛 ③ 不写 Blocker、不中断流程 | -| S2 | **跨模块改动** | **默认不改**,仅为当前模块实现所必需时允许修改 | `coding.mjs` 的 cross-module stage 在模块循环内记录改动并补「原因 / 影响评估」,「跨模块改动」节完整贴入《模块完成报告》 | - diff --git a/skills/plan/project-init/templates/docs-01-index-template.md b/skills/plan/project-init/templates/docs-01-index-template.md index 884a637..372d784 100644 --- a/skills/plan/project-init/templates/docs-01-index-template.md +++ b/skills/plan/project-init/templates/docs-01-index-template.md @@ -8,7 +8,3 @@ |----------|----------|--------------------| | 【人工填写:模块代码】 | 【人工填写:模块名称】 | 【人工填写:核心功能点】 | | SYS | 系统管理 | 用户/角色/权限/部门/字典 等 | - -## 填写说明 - -填完模块行后运行 `/erp-workflow:plan-start`。