diff --git a/README.md b/README.md index 7f91a4c..f74086c 100644 --- a/README.md +++ b/README.md @@ -2,49 +2,107 @@ 仓库:`davidxiaodev/workflow`。 -一个 Claude Code 插件:把一个需求从"说清楚要什么"一路带到"可以合并",每一步之间都有能真正执行的关卡。 -AI 先说清楚"做成什么样算对",按项目的约定去做,在独立验证之前不能说"做完了",并且把每次犯过的错变成下次能自动拦住的检查。 +一套给日常 AI 编码用的轻量工作流(Claude Code 插件)。你只描述要做什么,它决定走哪些步骤、该用哪个 skill、 +什么时候停下来问你;简单的改动保持简单,有风险的改动才严格检查。 -人不再逐行读 diff,而是看证据包:验收标准逐条由独立评审标记,机器检查只认真实退出码,合并分档由脚本计算。 +> 让 AI 适应工程流程,而不是让开发者为了用 AI 去适应复杂的流程。 -## 整套流程 +## 快速开始 -前端(frontend:用户直接接触的客户端,Web 和 React Native / Expo 移动端)和后端(backend)走同一套流程,只是每一步用的约定、检查和评审方式不同。 -项目里每一个客户端或服务叫一个 **lane**,一个仓库可以有多条,比如 `web`、`app`、`api`,各自标明 `kind` 是 `frontend` 还是 `backend`。 +```bash +/plugin marketplace add davidxiaodev/workflow +/plugin install dx-workflow@dx-workflow +``` -| 步骤 | 做什么 | frontend lane | backend lane | -| --- | --- | --- | --- | -| 0 准备 | 每个项目一次:写约定、接检查、加 lint 护栏、标出 `sensitive` 路径 | `docs/design.md` + token 文件 | `docs/backend.md` + 契约文件(OpenAPI 等)+ 迁移目录 | -| 1 定义(L) | 写规格 `docs/specs/<名字>.md`:问题、目标 `S1…`、不做什么、决定、未决问题,以及整个功能的验收标准;你同意(`Status: agreed`)后才往下走 | 同左 | 同左 | -| 2 验收标准 | 每条可观察、写明用什么证明,L 的写在规格里并标注对应哪个目标;逐项过一遍异常情况清单;可选写明怎么回滚、能否撤回 | 无效输入、键盘、慢请求、双击提交、390 宽;移动端:大字号、断网、切后台…… | 边界值、越权、重复请求、并发写、下游失败…… | -| 3 拆任务(L) | `docs/specs/<名字>.tasks.md`:每个任务一个 PR(S 或 M),写明 lane、负责哪几条验收标准、依赖、预估风险档;开工时由脚本生成这个任务的 `.verify/acceptance.md` | 同左 | 同左 | -| 4 实现 | 按约定做,先写测试;没有依赖关系的任务可以各开一个 worktree 并行做 | 需要时出 3 个结构不同的原型 | 先改契约,再按验收标准一条条先写测试后写实现 | -| 4′ 调试 | 同一个检查连续两次失败,`run-verify` 就要求停下来先找根因(`shared/debug.md`),根因写进 `.verify/debug.md`,再修 | 同左 | 同左 | -| 5 机器检查 | `run-verify.mjs` 按 lane 跑,只认真实退出码,遇到第一个失败就停 | 样式、类型、截图 + 可访问性、用户路径(Web 用 Playwright;移动端用模拟器截图 `rn-look.mjs` 和 Maestro) | 类型、单元、真实数据库的集成测试、**负向检查**、契约、迁移、用户路径 | -| 6 独立评审 | `review-brief.mjs` 写 brief,交给没参与实现的子代理;逐条标记验收标准和触发的清单项;最多 3 轮 | `design-review.md` 看截图,再用前端版 `code-review.md` 看代码(状态、请求竞态、错误态、XSS、可访问性) | `code-review.md` 看 diff,按专项逐一检查,并跑一遍证明关键事实 | -| 7 证据和分档 | `make-evidence.mjs` 生成证据包:验收标准和机器检查分开写,算合并分档,写明能否撤回、影响范围、怎么回滚 | 前后对比截图、录屏 | 检查日志、负向检查结果、契约与迁移改动 | -| 8 沉淀 | 评审的 Blocker、回滚、你的纠正,按 `shared/ratchet.md` 变成检查或清单项 | 同左 | 同左 | +在项目里接入一次(从 `package.json`、`pyproject.toml`、`go.mod` 里找出已有的测试、lint、类型检查命令,生成 `.verify/config.json`): -入口是 `flow` 技能(`dx-workflow:flow`),它先给改动定大小,再决定走哪些步骤: +```bash +node /scripts/init.mjs +node /scripts/run-verify.mjs --config working # 在未改动的代码上跑一遍,应该全部通过;然后提交 .verify/config.json +``` -| 大小 | 什么时候 | 步骤 | -| --- | --- | --- | -| S | 改文案、颜色、一行修复、配置值;不碰契约、迁移、鉴权、原生 | 验收标准 1–3 条 → 实现 → 验证,评审一般是 quick | -| M | 一两条 lane 内、一个 PR 放得下(约 400 行)的功能或修复,不改契约 | 验收标准 + 异常情况 → 实现 → 验证 | -| L | 新流程;接口、数据或设计契约变更;迁移;鉴权或支付;原生改动;超过一个 PR;或者还说不清怎样算做完 | 定义 → 规格里的验收标准 → 拆任务 → 每个任务按 M 走 | +之后就正常提需求,比如"`/workflow` 给订单列表加按日期筛选",或者直接说需求。设计约定、截图检查、用户路径这些都是需要时再加。 -步骤之间的关卡是能执行的命令: +推荐同时安装(装了就会用上,没装也能工作): ```bash -node /scripts/flow-check.mjs spec docs/specs/x.md # 规格:你已同意、没有未决问题、每个目标都有验收标准 -node /scripts/flow-check.mjs tasks docs/specs/x.tasks.md # 任务:每条验收标准都有任务负责、没有循环依赖、没有超过 M 的任务 -node /scripts/flow-check.mjs next docs/specs/x.tasks.md --done T1 # 现在可以开工的任务 -node /scripts/flow-check.mjs acceptance docs/specs/x.md T2 --write # 生成这个任务的 .verify/acceptance.md +/plugin install superpowers@claude-plugins-official # brainstorming、写计划、TDD、调试、worktree +/plugin install mattpocock-skills@claude-plugins-official # grilling、架构、代码质量 ``` -生成的验收文件会带上 `Spec:` 和 `Task:`,证据包和 PR 描述里也会写明,所以评审的每一条标记都能追溯到你同意过的目标。 +## 它怎么工作 + +```text +理解 → 计划 → 实现 → 验证 → 完成 +``` + +两件事决定走哪些步骤,而且分开判断: + +**大小**由 AI 从需求判断,决定要做多少计划: + +| 大小 | 例子 | 理解 | 计划 | 会写的文件 | +| --- | --- | --- | --- | --- | +| Small | 修个 bug、改文案、改样式、一个小函数 | 复述一句 | 不需要 | 不写任何文件 | +| Medium | 一个功能或修复,一个 PR 放得下 | 有不清楚的才问 1–3 个问题 | 有多个部分时写几条要点 | `.verify/acceptance.md`(不提交) | +| Large | 新流程、跨模块改动、要拆成多个 PR | brainstorming / grilling | 规格(含简短的架构)+ 任务列表 | `docs/specs/<名字>.md`、`.tasks.md` | + +**风险**由脚本从 diff 算出来,决定要验证多严(`node /scripts/level.mjs` 随时可以看): + +| 级别 | 什么时候 | 要求 | +| --- | --- | --- | +| light | 小改动(默认 ≤40 行、≤3 个文件),什么风险都没碰 | 检查通过就行。不写验收文件、不派评审、不生成证据包 | +| standard | 其余的改动 | 验收标准 + 检查 + 一次独立评审;证据包自动生成 | +| strict | 不管多小,只要碰到鉴权、支付、权限、迁移、接口契约、原生配置、`sensitive` 路径,或者改了检查本身 | 再加深度评审和安全检查;合并前由 owner 确认(3 档) | + +风险不用配置也能识别:按路径(`auth/`、`payment`、`migrations/`、`.sql`、`.env` 等)和代码内容(Stripe、JWT、bcrypt、`DROP TABLE`、 +`dangerouslySetInnerHTML`、权限判断等)判断;可以在配置的 `risk` 里调整或关掉。所以改动再小,碰了登录也会走严格验证;AI 也没法自称"这是小改动"来跳过。 + +评审也按改动来:代码评审每次都做;UI 截图评审只在界面相关的文件改了时才做;改了接口契约时检查兼容性;有风险时加安全检查。 +评审最多两轮,还不通过就交给你。 + +**什么时候停下来问你**:需求有两种理解、猜错代价大;Large 的规格写好了(你同意后才拆任务、写代码);改动是 strict;诊断之后检查还是失败; +两轮评审都没通过;正确的修法需要改契约、迁移或原生,而你没提到。其余时候它直接往下做,不会每一步都来问。 + +大的改动按 `skills/workflow/large.md` 走:规格 → 任务 → 每个任务一个 PR。步骤之间的关卡是能执行的命令 +(`flow-check.mjs spec`、`tasks`、`next`、`acceptance --write`),生成的验收文件带着 `Spec:` 和 `Task:`, +所以评审的每一条标记都能追溯到你同意过的目标。同一个检查连续两次失败,会要求先找根因再修(`shared/debug.md`)。 + +## 和 superpowers、Matt Pocock 的 skills 一起用 + +这个插件负责流程编排和质量保障,不重复实现别人已经做好的能力: + +| 步骤 | 交给(装了才用) | +| --- | --- | +| 理解大需求 | `superpowers:brainstorming`、`mattpocock-skills:grilling` | +| 架构 | `mattpocock-skills:codebase-design`、`improve-codebase-architecture` | +| 计划 | `superpowers:writing-plans`、`mattpocock-skills:to-tickets` | +| 先写测试 | `superpowers:test-driven-development`、`mattpocock-skills:tdd` | +| 并行 | `superpowers:using-git-worktrees`、`dispatching-parallel-agents` | +| 调试 | `superpowers:systematic-debugging`、`mattpocock-skills:diagnosing-bugs` | +| 代码质量、复盘 | `mattpocock-skills:improve-codebase-architecture`、`code-review`、`retro` | + +dx-workflow 自己负责:工作流编排、验证、独立评审、证据包、ratchet。重叠的地方以 dx-workflow 为准("做完"看 Stop 钩子, +独立评审看 `review-brief.mjs`,合并看分档),详见 `shared/skill-packs.md`。 -上线(部署、灰度、监控、回滚)这一步还没做:目前按合并分档决定谁批准合并,之后的流程按你们团队现有的做法。 +上线(部署、灰度、监控、回滚)还没做:目前按合并分档决定谁批准合并,之后按你们团队现有的流程。 + +--- + +以下是细节,日常使用不需要读。 + +## 各 lane 的检查 + +项目里每一个客户端或服务叫一个 **lane**(比如 `web`、`app`、`api`),标明 `kind` 是 `frontend` 还是 `backend`。 +`init.mjs` 会生成最基本的检查;需要时再加: + +| | frontend | backend | +| --- | --- | --- | +| 约定 | `docs/design.md` + token 文件(`frontend/setup.md`) | `docs/backend.md` + 契约文件 + 迁移目录(`backend/setup.md`) | +| 检查 | 写死的样式、类型、lint、截图 + 可访问性、用户路径(Web 用 Playwright) | 类型、lint、单元、真实数据库的集成测试、契约、迁移、用户路径 | +| 评审 | 有界面改动时看截图(`design-review.md`),代码看 `frontend/code-review.md` | `backend/code-review.md` | + +**负向检查**:把这条 lane 里的源码改动退回到基线、保留新测试,再跑一遍测试,测试必须失败。 +测试在没有实现时也能通过,说明它没测到这次改动。 **移动端(React Native / Expo)**:lane 写 `"kind": "frontend", "platform": "react-native"`,默认覆盖全部 JS/TS 代码和 `app.json`、`ios/`、`android/` 等原生配置。和 Web 的区别: @@ -63,38 +121,15 @@ node /scripts/flow-check.mjs acceptance docs/specs/x.md T2 --write # 生 **负向检查**:把这条 lane 里的源码改动退回到基线、保留新测试,再跑一遍测试,测试必须失败。 测试在没有实现时也能通过,说明它没测到这次改动。 -## 和其他 skill 包一起用 - -装了 Matt Pocock 的 skills、superpowers 或 agent-skills 的话,`flow` 会把某些步骤里的具体工作交给它们, -关卡和作为记录的文件仍以 dx-workflow 为准(详见 `shared/skill-packs.md`): - -| 步骤 | 交给(装了才用) | -| --- | --- | -| 定义、访谈 | `mattpocock-skills:grilling` / `grill-with-docs`,`agent-skills:interview-me` / `spec-driven-development`,`superpowers:brainstorming` | -| 拆任务 | `agent-skills:planning-and-task-breakdown`,`superpowers:writing-plans`,`mattpocock-skills:to-tickets` | -| 先写测试 | `mattpocock-skills:tdd`,`superpowers:test-driven-development`,`agent-skills:test-driven-development` | -| 并行 | `superpowers:using-git-worktrees` / `dispatching-parallel-agents` | -| 调试 | `mattpocock-skills:diagnosing-bugs`,`superpowers:systematic-debugging`,`agent-skills:debugging-and-error-recovery` | -| 浏览器排查 | `agent-skills:browser-testing-with-devtools` | -| 架构和清理 | `mattpocock-skills:improve-codebase-architecture` / `codebase-design`,`agent-skills:code-simplification` | - -冲突时以 dx-workflow 为准: -- 规格和任务以 `docs/specs/` 下的文件为准,别的 skill 写到 `docs/superpowers/`、`SPEC.md`、`tasks/todo.md` 或 issue 里的只算草稿; -- "做完"以 Stop 钩子放行为准,别的 skill 的"测试过了就算完"只是其中一部分; -- 独立评审以 `review-brief.mjs` 派出的为准,它们的评审只能作为额外的检查; -- 合并按分档来,证据包出来之前不在本地 merge,也不开可以直接合并的 PR。 - -安装命令和锁定的版本见 `vendor.lock.json` 的 `routed`。 - ## 合并分档 脚本算,不能手动改。 | 分档 | 条件 | 谁要看 | | --- | --- | --- | -| 1 | 检查全过、评审通过、验收标准全部满足,且没有下面的情况 | 扫一眼证据包即可合并 | +| 1 | light 改动检查全过;或者检查全过、评审通过、验收标准全部满足,且没有下面的情况 | 扫一眼证据包即可合并 | | 2 | 改了截图基线或共享模块(`shared`);有验收标准"未验证";改了源码却没改测试;代码里新增了 `@ts-ignore`、`eslint-disable`、`noqa` 这类关掉检查的注释,或者加了重试 | 你要看前后对比和标出来的部分 | -| 3 | 改了设计约定、后端约定、接口契约或迁移;改了 `sensitive` 路径;移动端的原生改动;**改了检查本身**(见下) | 你确认之后才能合并 | +| 3 | strict 改动:改了设计约定、后端约定、接口契约或迁移;改了 `sensitive` 路径或被识别为有风险的代码;移动端的原生改动;**改了检查本身**(见下) | 你确认之后才能合并 | | 未就绪 | 检查失败、评审未通过、有验收标准未满足或没被评审;运行或评审对应的不是当前磁盘上的内容 | 不合并 | 证据包和 PR 描述里还有一节"合并风险":能否撤回(有迁移是单向的,改了接口契约对已接入的调用方也是单向的)、 @@ -117,14 +152,16 @@ node /scripts/flow-check.mjs acceptance docs/specs/x.md T2 --write # 生 ## 评审 -`review-brief.mjs` 给每条 lane 的评审写同一份输入,交给一个新的子代理(能换模型就换),不带任何实现过程: +standard 和 strict 改动才评审。`review-brief.mjs` 给每条 lane 的评审写同一份输入,交给一个新的子代理(能换模型就换),不带任何实现过程: + +- **要做哪些评审**:代码评审每次都做;有界面改动才看截图;改了契约要查兼容性;有风险时加安全检查。 - **内容哈希**:要评的是哪一份内容,没在 git 里的新文件单独列出。 -- **深度**:quick(≤30 行、没碰共享模块)、standard、deep。契约、迁移、`sensitive` 路径、改了检查本身, - 或者超过 400 行,都走 deep;deep 里每个 Blocker 都要先尝试推翻它,推不翻才写。 +- **深度**:quick(≤30 行、没碰共享模块)、standard、deep。strict 的改动或者超过 400 行,都走 deep; + deep 里每个 Blocker 都要先尝试推翻它,推不翻才写,评审文件要写 `Depth: deep`。 - **清单项**:`docs/checklist.md` 里被这次 diff 触发的条目(每条写明触发条件、检查什么、来自哪次事故),评审逐条标"成立 / 不成立"。 - **轮次**:从第 2 轮起,附上上一轮的发现,评审只看上次评审之后新增的 diff,旧发现逐条标"已修 / 仍未修 / 延后", - 不换个说法重复提。第 4 轮直接拒绝,交给你决定。 + 不换个说法重复提。最多两轮,第 3 轮直接拒绝,交给你决定。 发现分为 Blocker、Should-fix、Note,以及 `Pre-existing`:这次改动没碰到的代码里的问题照样报告,但不挡合并, 会单独列在证据包里。同一类问题要列出所有出现的地方,让作者一次修完。 @@ -148,9 +185,9 @@ lint 规则、类型或约束 > 由 diff 触发的清单项 > 写进约定文件 ## 收尾检查和提交盖章 -**Stop 钩子**:这一轮改动了某条 lane 的文件(内容和这一轮开始时不同,由 UserPromptSubmit 钩子记录),而 -这条 lane 的 `run-verify` 没通过或对应的不是当前内容,独立评审缺失、未通过或对应的不是当前内容,验收标准或清单项 -没有全部标记,或者证据包不是当前内容的,第一次结束会被拦下。仍未通过就结束时,AI 必须写明"未验证" +**Stop 钩子**:这一轮改动了某条 lane 的文件(内容和这一轮开始时不同,由 UserPromptSubmit 钩子记录)时,按级别检查: +light 只要求这条 lane 的 `run-verify` 在当前内容上通过;standard 还要求独立评审针对当前内容且已通过、验收标准和清单项都已标记; +strict 还要求评审是 deep。证据包由钩子自己生成,其他条件都满足时它会自动跑 `make-evidence`。不满足时第一次结束会被拦下。仍未通过就结束时,AI 必须写明"未验证" (钩子只拦一次,避免无限循环)。只聊天、没改内容的一轮不会被拦。 `DX_WORKFLOW_GATE`:`enforce`(默认,拦截)、`observe`(只记录本来会拦什么,用来先看误报)、`off`(关闭)。 @@ -173,14 +210,9 @@ git log --format='%h %s%n %(trailers:key=Verified,valueonly)' origin/main.. CI 里目前不跑独立评审,分档会标明"checks only"。评审放进 CI 有两种做法(把 `.verify/review-*.md` 提交进 PR, 或者在 CI 里跑 reviewer),还没定。 -## 安装 - -```bash -/plugin marketplace add davidxiaodev/workflow -/plugin install dx-workflow@dx-workflow -``` +## 可选的界面工具 -可选但推荐(插件会自动找到它们,见 `vendor.lock.json` 里锁定的版本): +插件会自动找到这些(见 `vendor.lock.json` 里锁定的版本): ```bash /plugin marketplace add Leonxlnx/taste-skill @@ -191,18 +223,6 @@ CI 里目前不跑独立评审,分档会标明"checks only"。评审放进 CI baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含有未授权的 Anthropic 材料)。 -## 在一个项目里开始 - -- 前端:对 Claude 说"用 dx-workflow 的 frontend 技能给这个项目建立设计约定和检查"。 -- 后端:对 Claude 说"用 dx-workflow 的 backend 技能给这个项目建立后端约定和检查"。 - -两者都会写约定文件、接好 `.verify/config.json`、加 lint 护栏、建一个空的 `docs/checklist.md`、和你一起填 `sensitive` 路径; -没有可脚本化的用户路径时生成 `ctl` 控制命令;最后用 `run-verify.mjs --config working` 在未改动的代码上跑一遍全部检查 -(配置合进默认分支之后,就不再需要 `--config working`)。之后正常提需求即可:`flow` 技能会先给改动定大小, -大的改动先和你一起写规格、拆任务,再一个任务一个 PR 地做。 - -接着可以做的:装提交盖章钩子、接 CI 模板。 - ## 环境变量 | 变量 | 作用 | @@ -216,13 +236,13 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含 | 路径 | 作用 | | --- | --- | -| `plugins/dx-workflow/skills/flow/` | 入口:给改动定大小,按步骤和关卡走完整个流程,按步骤分派给其他 skill 包 | +| `plugins/dx-workflow/skills/workflow/` | 入口:`SKILL.md`(大小、风险级别、五个阶段、什么时候问人)、`large.md`(规格、架构、任务) | | `plugins/dx-workflow/skills/frontend/` | 前端:`SKILL.md`(入口)、`setup.md`、`build.md`、`verify.md`、`mobile.md`(React Native / Expo)、`design-review.md`(截图评审)、`code-review.md`(前端代码评审)、`templates/`(design.md、Web 截图测试、页面清单、`rn-look.json`、Maestro journey) | | `plugins/dx-workflow/skills/backend/` | 后端:`SKILL.md`(入口)、`setup.md`、`build.md`、`verify.md`、`code-review.md`(代码评审)、`templates/backend.md` | | `plugins/dx-workflow/shared/acceptance.md` | 怎么写验收标准、异常情况清单、评审怎么标记 | | `plugins/dx-workflow/shared/ctl.md` | 生成项目的控制命令(读写分开),以及 `verify-` skill 和用户路径 | -| `plugins/dx-workflow/shared/spec.md`、`tasks.md`、`debug.md` | 定义、拆任务、调试三步的做法和文件格式 | -| `plugins/dx-workflow/shared/skill-packs.md` | 和 Matt Pocock、superpowers、agent-skills 一起用:谁做哪一步,冲突时以谁为准 | +| `plugins/dx-workflow/shared/debug.md` | 检查连续失败时怎么找根因 | +| `plugins/dx-workflow/shared/skill-packs.md` | 和 superpowers、Matt Pocock 的 skills 一起用:谁做哪一步,冲突时以谁为准 | | `plugins/dx-workflow/shared/ratchet.md` | 把犯过的错变成检查:分类、准入、单独提交、清理;清单格式 | | `plugins/dx-workflow/shared/verify.config.json` | `.verify/config.json` 模板(frontend 和 backend 两条 lane) | | `plugins/dx-workflow/shared/verify-ci.yml` | 项目用的 CI 模板 | @@ -233,6 +253,8 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含 | --- | --- | | `plugins/dx-workflow/hooks/hooks.json` | 注册 UserPromptSubmit 和 Stop 两个钩子 | | `plugins/dx-workflow/scripts/run-verify.mjs` | 按 lane 跑检查(含负向检查),记录退出码和内容哈希;`--config working`、`--keep-going`、`--restore` | +| `plugins/dx-workflow/scripts/init.mjs` | 接入:找出已有的检查命令,生成最小的 `.verify/config.json` | +| `plugins/dx-workflow/scripts/level.mjs`、`lib/level.mjs` | 这次改动的验证级别(light / standard / strict)和原因 | | `plugins/dx-workflow/scripts/flow-check.mjs` | 步骤之间的关卡:规格、任务、下一步可做的任务、生成任务的验收文件 | | `plugins/dx-workflow/scripts/lib/flow.mjs` | 解析规格和任务文件 | | `plugins/dx-workflow/scripts/review-brief.mjs` | 写评审 brief:内容哈希、深度、触发的清单项、轮次 | @@ -264,7 +286,7 @@ npm test # node evals/run.mjs all --reviewer "claude -p --permission-mode acceptEdits" # 改 code-review.md、brief 或换模型之前先跑,和 evals/results/ 里上一次比 ``` -发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.6.0`),CI 模板按 tag 锁定插件版本。 +发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.7.0`),CI 模板按 tag 锁定插件版本。 升级第三方工具:一次只升一个,读它的改动,在两个项目上各跑一次 `run-verify.mjs`,结果没变差再改 `vendor.lock.json` 里的 commit。 diff --git a/docs/adr/0007-light-by-default.md b/docs/adr/0007-light-by-default.md new file mode 100644 index 0000000..ac46a83 --- /dev/null +++ b/docs/adr/0007-light-by-default.md @@ -0,0 +1,42 @@ +# 7. Light by default, strict where it matters + +Date: 2026-11-22 · Status: accepted + +## Context + +By 0.6 every lane change, however small, needed an acceptance file, a run, a brief, a review +subagent, a review naming the tree and an evidence pack before the Stop gate let the turn end, and +setup asked for design and backend contracts, ctl, journeys, lint guardrails and a checklist first. +Each step had a reason; together they were the kind of process developers abandon. Size and risk +were also mixed: a one-line change to a login check was "small". + +## Decision + +- One entry, the `workflow` skill (`/workflow`): understand, plan, implement, verify, complete. The + developer describes the change; the skill sizes it, picks the steps and the installed skills, and + says when it will stop to ask. +- Size (judged by the agent from the request) decides planning: Small writes no file, Medium only + `.verify/acceptance.md` (with a short plan when needed), Large a spec with an architecture + section and a task list. +- Risk (computed from the diff by `lib/level.mjs`, shown by `level.mjs`) decides verification: + light (at most 40 lines and 3 files, nothing risky) needs only passing checks; standard adds + acceptance and one independent review; strict (contracts, migrations, sensitive or native paths, + the checks themselves, and, without any config, risky paths and code: auth, payments, permissions, + destructive SQL, raw HTML) adds a deep review with a security pass and merge tier 3. +- The Stop gate, the brief and the evidence pack follow the level. The gate writes the evidence pack + itself when that is all that is missing. Reviews stop after two rounds. The brief asks only for the + reviews the diff needs: code always, screenshots when something visual changed, contract + compatibility, security. +- superpowers and Matt Pocock's skills do brainstorming, planning, TDD, worktrees, debugging, + architecture and code quality; agent-skills is no longer routed. This plugin keeps orchestration, + verification, independent review, evidence and the ratchet. +- `init.mjs` writes a working `.verify/config.json` from the project's existing commands; the full + setup is for when a change needs it. + +## Consequences + +A light change ends with no review: a small, non-risky bug can merge on its checks alone. The light +limits and the risk heuristics are defaults a project can tune (`risk` in the config); the +heuristics will flag some harmless files (an `author.ts`) as risky, which costs a deeper review, not +a wrong merge. Earlier docs (`flow`, `shared/spec.md`, `shared/tasks.md`) are folded into +`skills/workflow/`. diff --git a/plugins/dx-workflow/.claude-plugin/plugin.json b/plugins/dx-workflow/.claude-plugin/plugin.json index 09c1ae4..303da27 100644 --- a/plugins/dx-workflow/.claude-plugin/plugin.json +++ b/plugins/dx-workflow/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "dx-workflow", - "version": "0.6.0", - "description": "A request to a mergeable change with a gate between every step: size the change, spec and tasks for large ones (flow-check), acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. Works with Matt Pocock's skills, superpowers and agent-skills for the work inside a step.", + "version": "0.7.0", + "description": "One workflow from request to mergeable change, light by default and strict where it matters: the developer describes the change; it sizes it, computes how strictly to check it from the diff (light, standard, strict), uses superpowers and Matt Pocock's skills inside steps, acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. ", "author": { "name": "davidxiaodev" }, diff --git a/plugins/dx-workflow/scripts/flow-check.mjs b/plugins/dx-workflow/scripts/flow-check.mjs index ab196ac..1d2846c 100644 --- a/plugins/dx-workflow/scripts/flow-check.mjs +++ b/plugins/dx-workflow/scripts/flow-check.mjs @@ -27,7 +27,7 @@ const specPathFor = (tasksFile) => tasksFile.replace(/\.tasks\.md$/, ".md"); const read = (p) => readFileSync(p, "utf8"); if (cmd === "spec") { - report("spec", checkSpec(parseSpec(read(path))), `the spec is agreed and complete: write the task list (shared/tasks.md) or, for one pull request, the acceptance: flow-check.mjs acceptance ${rel(path)} --write`); + report("spec", checkSpec(parseSpec(read(path))), `the spec is agreed and complete: write the task list (skills/workflow/large.md) or, for one pull request, the acceptance: flow-check.mjs acceptance ${rel(path)} --write`); } else if (cmd === "tasks") { const specFile = specPathFor(path); if (specFile === path || !existsSync(specFile)) fail(`flow-check: a task list is .tasks.md next to its spec; no ${rel(specFile)}.`); diff --git a/plugins/dx-workflow/scripts/init.mjs b/plugins/dx-workflow/scripts/init.mjs new file mode 100644 index 0000000..293d315 --- /dev/null +++ b/plugins/dx-workflow/scripts/init.mjs @@ -0,0 +1,164 @@ +#!/usr/bin/env node +// Day-one setup: find the apps and services in this repo and the checks they already have, and write +// a minimal .verify/config.json from them. Nothing else is required to start; design contracts, +// screenshots, journeys and checklists are added later, when a change needs them. +// +// node init.mjs [--dry-run] [--force] +// +// It looks at the repo root and one level of apps/, packages/, services/ and the top-level folders: +// package.json web (next, react, vue, svelte, vite, astro, remix, solid…) → frontend lane +// expo / react-native → frontend lane, platform react-native +// express, fastify, koa, hono, nest, a server with no UI → backend lane +// its scripts: typecheck, lint, test (and tsc --noEmit when there is a tsconfig) +// pyproject.toml / requirements.txt → backend lane: ruff, mypy, pytest when configured +// go.mod → backend lane: go vet, go test +// Every lane with a test command also gets the negative check. +import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; +import { join, relative } from "node:path"; +import { gitRoot } from "./lib/verify-config.mjs"; + +const args = process.argv.slice(2); +const root = gitRoot(process.cwd()); +if (!root) fail("init: run this inside a git repository."); +const target = join(root, ".verify", "config.json"); +if (existsSync(target) && !args.includes("--force") && !args.includes("--dry-run")) fail(`init: ${relative(process.cwd(), target) || target} exists (use --force to replace it).`); + +const WEB = ["next", "react", "react-dom", "vue", "nuxt", "svelte", "@sveltejs/kit", "vite", "astro", "@remix-run/react", "solid-js", "@angular/core", "preact"]; +const RN = ["expo", "react-native"]; +const SERVER = ["express", "fastify", "koa", "hono", "@nestjs/core", "@hapi/hapi", "restify", "elysia", "@trpc/server", "apollo-server", "@apollo/server"]; + +const candidates = [".", ...["apps", "packages", "services"].flatMap((d) => subdirs(d).map((s) => `${d}/${s}`)), ...subdirs(".").filter((d) => !["apps", "packages", "services", "node_modules", "docs", "scripts", "e2e", "test", "tests"].includes(d))]; +const pm = existsSync(join(root, "pnpm-lock.yaml")) ? "pnpm" : existsSync(join(root, "yarn.lock")) ? "yarn" : existsSync(join(root, "bun.lockb")) || existsSync(join(root, "bun.lock")) ? "bun" : "npm"; +const lanes = {}; +const found = []; + +for (const dir of [...new Set(candidates)]) { + const abs = join(root, dir); + const node = readJsonFile(join(abs, "package.json")); + if (node) addNode(dir, node); + else if (existsSync(join(abs, "pyproject.toml")) || existsSync(join(abs, "requirements.txt"))) addPython(dir); + else if (existsSync(join(abs, "go.mod"))) addGo(dir); +} +// In a monorepo (workspaces, pnpm-workspace.yaml, turbo.json, nx.json) the root package.json is the +// workspace, not an app: its files overlap every app's, and its scripts run every app's checks again. +for (const [name, lane] of Object.entries(lanes)) if (lane.atRoot && Object.keys(lanes).length > 1) delete lanes[name]; +for (const lane of Object.values(lanes)) delete lane.atRoot; +const kept = new Set(Object.keys(lanes)); +found.splice(0, found.length, ...found.filter((f) => kept.has(f.split(" ")[0]))); + +if (!Object.keys(lanes).length) fail("init: found no package.json, pyproject.toml, requirements.txt or go.mod to build lanes from. Write .verify/config.json from the plugin's shared/verify.config.json."); + +const config = { lanes }; +const text = JSON.stringify(config, null, 2) + "\n"; +console.log(`init: ${found.length} lane(s):`); +for (const f of found) console.log(`- ${f}`); +if (args.includes("--dry-run")) { + process.stdout.write(text); + process.exit(0); +} +mkdirSync(join(root, ".verify"), { recursive: true }); +writeFileSync(target, text); +const gi = join(root, ".gitignore"); +const ignore = existsSync(gi) ? readFileSync(gi, "utf8") : ""; +const missing = [".verify/*", "!.verify/config.json"].filter((l) => !ignore.split("\n").includes(l)); +if (missing.length) writeFileSync(gi, `${ignore}${ignore && !ignore.endsWith("\n") ? "\n" : ""}${missing.join("\n")}\n`); +console.log(`init: wrote .verify/config.json${missing.length ? " and .gitignore lines" : ""}.`); +console.log("Next: run `node /scripts/run-verify.mjs --config working` once on the unchanged code; every check should pass. Commit .verify/config.json."); +console.log("Later, only when a change needs it: docs/design.md and screenshots (frontend setup.md), docs/backend.md (backend setup.md), sensitive paths, docs/checklist.md."); + +function addNode(dir, pkg) { + const deps = { ...pkg.dependencies, ...pkg.devDependencies }; + const has = (list) => list.some((d) => d in deps); + const scripts = pkg.scripts ?? {}; + const kind = has(RN) ? "rn" : has(WEB) ? "web" : has(SERVER) || pkg.main || scripts.start || existsSync(join(root, dir, "tsconfig.json")) ? "backend" : null; + if (!kind) return; + const run = (name) => (pm === "npm" ? `npm run ${name}` : `${pm} run ${name}`); + const pick = (...names) => names.find((n) => scripts[n] && !/no test specified/.test(scripts[n])); + const checks = []; + const typecheck = pick("typecheck", "type-check", "types", "check-types", "tsc"); + if (typecheck) checks.push({ name: "types", run: run(typecheck) }); + else if (existsSync(join(root, dir, "tsconfig.json"))) checks.push({ name: "types", run: "npx tsc --noEmit" }); + const lint = pick("lint"); + if (lint) checks.push({ name: "lint", run: run(lint) }); + const test = pick("test:unit", "test"); + if (test) checks.push({ name: "unit", run: run(test) }, { name: "negative", negative: { test: run(test) } }); + for (const c of checks) if (dir !== ".") c.cwd = dir; + for (const c of checks) if (c.negative && dir !== ".") c.negative.cwd = dir; + const name = laneName(dir, kind === "backend" ? "api" : kind === "rn" ? "app" : "web"); + const prefix = dir === "." ? "" : `${dir}/`; + lanes[name] = + kind === "backend" + ? { kind: "backend", files: [`${prefix}**/*.{ts,js,mjs,cjs,mts}`, ...(dir === "." ? [] : [`${prefix}package.json`])], checks } + : kind === "rn" + ? { kind: "frontend", platform: "react-native", files: [`${prefix}**/*.{ts,tsx,js,jsx}`, `${prefix}app.json`, `${prefix}app.config.{js,ts}`, `${prefix}ios/**`, `${prefix}android/**`], native: [`${prefix}app.json`, `${prefix}app.config.{js,ts}`, `${prefix}eas.json`, `${prefix}ios/**`, `${prefix}android/**`], checks } + : { kind: "frontend", files: [`${prefix}**/*.{tsx,jsx,ts,js,vue,svelte,astro,css,scss}`], checks }; + const workspace = pkg.workspaces || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "turbo.json")) || existsSync(join(root, "nx.json")); + if (dir === ".") Object.assign(lanes[name], { ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.next/**"], atRoot: Boolean(workspace) }); + found.push(`${name} (${kind === "rn" ? "React Native / Expo" : kind === "web" ? "web frontend" : "Node backend"}, ${dir === "." ? "repo root" : dir}): ${checks.map((c) => c.name).join(", ") || "no checks found: add them to the lane"}`); +} + +function addPython(dir) { + const abs = join(root, dir); + const py = [readText(join(abs, "pyproject.toml")), readText(join(abs, "requirements.txt")), readText(join(abs, "requirements-dev.txt"))].join("\n"); + const checks = []; + if (/\bruff\b/.test(py)) checks.push({ name: "lint", run: "ruff check ." }); + if (/\bmypy\b/.test(py)) checks.push({ name: "types", run: "mypy ." }); + if (/\bpytest\b/.test(py) || existsSync(join(abs, "tests"))) checks.push({ name: "unit", run: "pytest -q" }, { name: "negative", negative: { test: "pytest -q" } }); + for (const c of checks) { + if (dir !== ".") c.cwd = dir; + if (c.negative && dir !== ".") c.negative.cwd = dir; + } + const name = laneName(dir, "api"); + lanes[name] = { kind: "backend", files: [`${dir === "." ? "" : `${dir}/`}**/*.py`], checks }; + found.push(`${name} (Python backend, ${dir === "." ? "repo root" : dir}): ${checks.map((c) => c.name).join(", ") || "no checks found: add them to the lane"}`); +} + +function addGo(dir) { + const cwd = dir === "." ? {} : { cwd: dir }; + const checks = [ + { name: "vet", run: "go vet ./...", ...cwd }, + { name: "unit", run: "go test ./...", ...cwd }, + { name: "negative", negative: { test: "go test ./...", ...cwd } }, + ]; + const name = laneName(dir, "api"); + lanes[name] = { kind: "backend", files: [`${dir === "." ? "" : `${dir}/`}**/*.go`], checks }; + found.push(`${name} (Go backend, ${dir === "." ? "repo root" : dir}): vet, unit, negative`); +} + +function laneName(dir, fallback) { + const base = dir === "." ? (Object.keys(lanes).length ? "root" : fallback) : dir.split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-"); + let name = base; + for (let i = 2; lanes[name]; i++) name = `${base}-${i}`; + return name; +} + +function subdirs(d) { + try { + return readdirSync(join(root, d), { withFileTypes: true }) + .filter((e) => e.isDirectory() && !e.name.startsWith(".")) + .map((e) => e.name); + } catch { + return []; + } +} + +function readJsonFile(p) { + try { + return JSON.parse(readFileSync(p, "utf8")); + } catch { + return null; + } +} + +function readText(p) { + try { + return readFileSync(p, "utf8"); + } catch { + return ""; + } +} + +function fail(message) { + console.error(message); + process.exit(2); +} diff --git a/plugins/dx-workflow/scripts/level.mjs b/plugins/dx-workflow/scripts/level.mjs new file mode 100644 index 0000000..a27c4ff --- /dev/null +++ b/plugins/dx-workflow/scripts/level.mjs @@ -0,0 +1,29 @@ +#!/usr/bin/env node +// What does the current change need? Prints the verification level (light, standard, strict) and why. +// +// node level.mjs [--json] +// +// light: the checks must pass, nothing else. standard: acceptance, one independent review, evidence. +// strict: also a deep review with a security pass, and the owner approves the merge. +import { changeLevel } from "./lib/level.mjs"; +import { gitRoot, loadConfig } from "./lib/verify-config.mjs"; + +const root = gitRoot(process.cwd()); +const cfg = root && loadConfig(root); +if (!cfg) { + console.error("level: no .verify/config.json here (run init.mjs first)."); + process.exit(2); +} +const l = changeLevel(cfg); +if (process.argv.includes("--json")) console.log(JSON.stringify(l, null, 2)); +else { + console.log(`level: ${l.level} · ${l.files} lane file(s), ${l.lines} changed line(s)${l.lanes.length ? ` · lanes: ${l.lanes.join(", ")}` : ""}`); + for (const r of l.reasons) console.log(`- ${r}`); + console.log( + { + light: "needs: the lane checks pass (run-verify.mjs). No acceptance file, no review.", + standard: "needs: .verify/acceptance.md, run-verify.mjs, one independent review (review-brief.mjs). The evidence pack is made for you.", + strict: "needs: as standard, with a deep review and a security pass; merge tier 3 (the owner approves).", + }[l.level], + ); +} diff --git a/plugins/dx-workflow/scripts/lib/flow.mjs b/plugins/dx-workflow/scripts/lib/flow.mjs index 1cc80b5..5faa3b0 100644 --- a/plugins/dx-workflow/scripts/lib/flow.mjs +++ b/plugins/dx-workflow/scripts/lib/flow.mjs @@ -25,6 +25,7 @@ const field = (text, name) => new RegExp(`^${name}:\\s*(.+)$`, "im").exec(text)? export function parseSpec(text) { const goals = items(section(text, "Goals"), "S"); const nonGoals = (section(text, "Non-goals") ?? []).filter((l) => /^\s*-\s*\S/.test(l) && !/^\s*-\s* l.trim() && !/^\s* ({ ...q, @@ -35,7 +36,7 @@ export function parseSpec(text) { refs: [...new Set([...c.text.matchAll(/\bS\d+\b/g)].map((m) => m[0]))], proof: /·\s*proof:\s*\S/i.test(c.text), })); - return { title: /^#\s*Spec:\s*(.+)$/m.exec(text)?.[1].trim() ?? null, status: field(text, "Status"), goals, nonGoals, decisions, questions, criteria }; + return { title: /^#\s*Spec:\s*(.+)$/m.exec(text)?.[1].trim() ?? null, status: field(text, "Status"), goals, nonGoals, architecture, decisions, questions, criteria }; } /** Problems that keep a spec from gating into acceptance and tasks. */ @@ -44,6 +45,7 @@ export function checkSpec(spec) { if (!/^agreed$/i.test(spec.status ?? "")) p.push(`Status is "${spec.status ?? "missing"}": the user agrees the spec before building ("Status: agreed").`); if (!spec.goals.length) p.push("no goals (## Goals with - S1 …): what outcome makes this worth doing?"); if (!spec.nonGoals.length) p.push("no non-goals (## Non-goals): say what this does not do, so nobody builds it."); + if (!spec.architecture.length) p.push("no architecture (## Architecture): the modules or screens involved, their interfaces, the data and who owns it; a few lines."); for (const q of spec.questions.filter((q) => !q.resolved)) p.push(`${q.id} is open: answer it (→ D), or write "· deferred: ".`); if (!spec.criteria.length) p.push("no acceptance criteria (## Acceptance with - A1 … (S1) · proof: …)."); const goalIds = new Set(spec.goals.map((g) => g.id)); diff --git a/plugins/dx-workflow/scripts/lib/level.mjs b/plugins/dx-workflow/scripts/lib/level.mjs new file mode 100644 index 0000000..c0dd5d1 --- /dev/null +++ b/plugins/dx-workflow/scripts/lib/level.mjs @@ -0,0 +1,117 @@ +// How much verification a change needs, computed from the diff so nobody has to choose it and an +// agent cannot talk itself down: +// +// light small and nothing risky: the lane's checks pass on the tree on disk; nothing else +// standard everything else: a short acceptance file, one independent review, the evidence pack +// strict risky whatever its size (contract, migration, auth, payments, native, the checks +// themselves, sensitive paths): a deep review with a security pass; the owner approves +// +// Size decides how much planning a change needs (the workflow skill); this decides how hard it is checked. +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { changedSince, contractPaths, gitLines, guardChanges, inLane, matchAny, VERIFY_DIR } from "./verify-config.mjs"; + +export const LIGHT_MAX_LINES = 40; +export const LIGHT_MAX_FILES = 3; + +// Risky by name, even in a project that has not listed its sensitive paths. +export const RISK_PATHS = [ + "**/{auth,authn,authz,login,logout,signin,signup,session,sessions,oauth,sso,permissions,rbac,acl}/**", + "**/*{auth,Auth,login,Login,password,Password,session,Session,permission,Permission,oauth,OAuth}*.*", + "**/{payment,payments,billing,checkout,subscription,subscriptions,invoice,invoices,stripe,wallet}/**", + "**/*{payment,Payment,billing,Billing,checkout,Checkout,stripe,Stripe,invoice,Invoice,refund,Refund}*.*", + "**/{migrations,migrate,db/migrate}/**", + "**/*.sql", + "**/schema.prisma", + "**/{.env,.env.*}", +]; + +// Risky by content: lines added or removed that touch money, secrets, identity, destructive SQL or raw HTML. +export const RISK_LINES = [ + [/\b(?:stripe|paypal|braintree|adyen|paddle|lemonsqueezy)\b/i, "payments"], + [/\b(?:jwt|jsonwebtoken|bcrypt|argon2|scrypt|oauth|saml|csrf|passport|next-auth|lucia|clerk|supabase\.auth)\b/i, "authentication"], + [/\b(?:createHash|createHmac|randomBytes|timingSafeEqual|setCookie|httpOnly|sameSite)\b/, "secrets or cookies"], + [/\b(?:DROP|TRUNCATE)\s+(?:TABLE|COLUMN|INDEX|DATABASE)\b|\bALTER\s+TABLE\b|\bDELETE\s+FROM\b/i, "destructive SQL"], + [/dangerouslySetInnerHTML|\.innerHTML\s*=|v-html|\beval\s*\(|new Function\s*\(/, "raw HTML or eval"], + [/\b(?:isAdmin|role\s*===?|hasPermission|can\(|authorize|requireAuth|@PreAuthorize|@login_required)\b/, "authorisation"], +]; + +/** + * { level, reasons, lines, files, lanes } for the change since base. `reasons` say why it is not light. + * A project can tune it in .verify/config.json: "risk": { "paths": [], "lightMaxLines": 40, "lightMaxFiles": 3, "heuristics": true }. + */ +export function changeLevel(cfg, changes = changedSince(cfg.root, cfg.base)) { + const risk = cfg.config.risk ?? {}; + const maxLines = risk.lightMaxLines ?? LIGHT_MAX_LINES; + const maxFiles = risk.lightMaxFiles ?? LIGHT_MAX_FILES; + const heuristics = risk.heuristics !== false; + const visible = changes.filter((c) => !c.path.startsWith(`${VERIFY_DIR}/`) || c.path === `${VERIFY_DIR}/config.json`); + const laneOf = (p) => cfg.lanes.filter((l) => inLane(l, p)); + const laneFiles = visible.filter((c) => laneOf(c.path).length); + const lanes = cfg.lanes.filter((l) => laneFiles.some((c) => inLane(l, c.path))); + const strict = []; + const standard = []; + + const add = (list, why) => !list.includes(why) && list.push(why); + for (const g of guardChanges(cfg, changes).filter((g) => g.tier === 3)) add(strict, `the checks changed: ${g.path}`); + for (const l of lanes) { + for (const c of visible) { + if (matchAny(contractPaths(l), c.path)) add(strict, `contract: ${c.path}`); + if (matchAny(l.migrations ?? [], c.path)) add(strict, `migration: ${c.path}`); + if (matchAny(l.sensitive ?? [], c.path)) add(strict, `sensitive: ${c.path}`); + if (matchAny(l.native ?? [], c.path)) add(strict, `native: ${c.path}`); + if (inLane(l, c.path) && matchAny(l.shared ?? [], c.path)) add(standard, `shared: ${c.path}`); + } + } + if (heuristics) { + for (const c of laneFiles) if (matchAny([...RISK_PATHS, ...(risk.paths ?? [])], c.path)) add(strict, `risky path: ${c.path}`); + } else for (const c of laneFiles) if (matchAny(risk.paths ?? [], c.path)) add(strict, `risky path: ${c.path}`); + + const { lines, byFile } = diffLines(cfg.root, cfg.base, laneFiles); + if (heuristics) { + for (const [path, ls] of byFile) { + for (const [re, what] of RISK_LINES) { + const hit = ls.find((l) => re.test(l)); + if (hit) add(strict, `${what} in ${path}: "${hit.trim().slice(0, 60)}"`); + } + } + } + const changedLines = lines; + if (changedLines > maxLines) add(standard, `${changedLines} changed lines (light is at most ${maxLines})`); + if (laneFiles.length > maxFiles) add(standard, `${laneFiles.length} files (light is at most ${maxFiles})`); + if (laneFiles.some((c) => c.status === "D")) add(standard, "a file was deleted"); + + const level = strict.length ? "strict" : standard.length ? "standard" : "light"; + return { level, reasons: strict.length ? strict : standard, lines: changedLines, files: laneFiles.length, lanes: lanes.map((l) => l.name) }; +} + +/** Added plus removed lines per lane file since base (untracked files: all their lines). */ +function diffLines(root, base, files) { + const byFile = new Map(); + let lines = 0; + if (!files.length) return { lines, byFile }; + const tracked = new Set(gitLines(root, ["ls-files", "--", ...files.map((f) => f.path)])); + let current = null; + for (const l of gitLines(root, ["diff", "--unified=0", "--no-color", "--no-renames", base ?? "HEAD", "--", ...files.map((f) => f.path)])) { + if (l.startsWith("diff --git ")) { + current = / b\/(.+)$/.exec(l)?.[1] ?? null; + if (current && !byFile.has(current)) byFile.set(current, []); + } else if (l.startsWith("+++ ") || l.startsWith("--- ")) continue; + else if (current && /^[+-]/.test(l)) { + byFile.get(current).push(l.slice(1)); + lines++; + } + } + for (const f of files.filter((f) => f.status !== "D" && !tracked.has(f.path))) { + try { + const text = readFileSync(join(root, f.path), "utf8"); + const ls = text.split("\n"); + if (ls.at(-1) === "") ls.pop(); + byFile.set(f.path, ls); + lines += ls.length; + } catch { + // unreadable: counted by path only + } + } + return { lines, byFile }; +} diff --git a/plugins/dx-workflow/scripts/lib/negative.mjs b/plugins/dx-workflow/scripts/lib/negative.mjs index 83b5d80..11684de 100644 --- a/plugins/dx-workflow/scripts/lib/negative.mjs +++ b/plugins/dx-workflow/scripts/lib/negative.mjs @@ -63,7 +63,7 @@ export function runNegative({ root, dir, lane, tests, spec, timeoutMs, env }) { } const run = (label) => { - const r = spawnSync(test, { cwd: root, shell: true, encoding: "utf8", timeout: timeoutMs, maxBuffer: 64 << 20, env }); + const r = spawnSync(test, { cwd: spec.cwd ? join(root, spec.cwd) : root, shell: true, encoding: "utf8", timeout: timeoutMs, maxBuffer: 64 << 20, env }); const code = r.status ?? (r.signal ? 124 : 1); log.push(`== ${label}: $ ${test} → exit ${code}`, r.stdout ?? "", r.stderr ?? "", ""); return code; diff --git a/plugins/dx-workflow/scripts/make-evidence.mjs b/plugins/dx-workflow/scripts/make-evidence.mjs index 87e44ec..1c0dbe9 100644 --- a/plugins/dx-workflow/scripts/make-evidence.mjs +++ b/plugins/dx-workflow/scripts/make-evidence.mjs @@ -34,6 +34,7 @@ import { readJson, treeHash, } from "./lib/verify-config.mjs"; +import { changeLevel } from "./lib/level.mjs"; const args = process.argv.slice(2); const rootArg = args.indexOf("--root"); @@ -54,6 +55,9 @@ const allChanges = changedSince(root, cfg.base); const changes = allChanges.filter((c) => !c.path.startsWith(".verify/")); const touched = changes.map((c) => c.path); const guarded = guardChanges(cfg, allChanges); // .verify/config.json is a guard file +const lvl = changeLevel(cfg, allChanges); +// A light change (small, nothing risky) needs no review or acceptance file: its checks are the evidence. +const reviewsOptional = checksOnly || lvl.level === "light"; const current = treeHash(root); const short = (h) => (h ? h.slice(0, 12) : "none"); @@ -62,7 +66,7 @@ let lanes = cfg.lanes.filter((l) => touched.some((f) => inLane(l, f))); if (lanes.length === 0) lanes = cfg.lanes.filter((l) => last.lanes[l.name]); // Reviews, one per lane. -const reviews = (checksOnly ? [] : lanes).map((lane) => { +const reviews = (reviewsOptional ? [] : lanes).map((lane) => { const path = join(cfg.dir, `review-${lane.name}.md`); const text = existsSync(path) ? readFileSync(path, "utf8") : ""; const lines = text.split("\n"); @@ -118,7 +122,7 @@ const reviewsReady = reviews.every((r) => /^approved\b/i.test(r.verdict) && r.op const sameTree = staleRuns.length === 0 && staleReviews.length === 0; const guard3 = guarded.filter((g) => g.tier === 3); const guard2 = guarded.filter((g) => g.tier === 2); -const acceptanceReady = checksOnly || (criteria.length > 0 && criteria.every((c) => c.status === "met" || c.status === "not checked")); +const acceptanceReady = reviewsOptional || (criteria.length > 0 && criteria.every((c) => c.status === "met" || c.status === "not checked")); const why2 = [ baselineChanges.length && "screenshot baselines changed", sharedChanges.length && "shared parts changed", @@ -131,6 +135,10 @@ const why3 = [ sensitiveChanges.length && `a sensitive path changed (${sensitiveChanges.join(", ")})`, nativeChanges.length && `a native change needs a new store build (${nativeChanges.join(", ")})`, guard3.length && `the checks themselves changed (${[...new Set(guard3.map((g) => `${g.path}: ${g.why}`))].join("; ")})`, + ...(() => { + const more = lvl.reasons.filter((r) => lvl.level === "strict" && !/^(contract|sensitive|native|the checks changed):/.test(r)); + return more.length ? [`a risky change (${more.join("; ")})`] : []; + })(), ].filter(Boolean); const notReady = [ !lanesReady && "a lane's checks did not pass", @@ -144,7 +152,9 @@ const tier = notReady.length ? { id: "3", rule: `${why3.join("; ")}. The owner must confirm before merge.` } : why2.length ? { id: "2", rule: `Look before merge: ${why2.join("; ")}.` } - : { id: "1", rule: "Verified and contained. A glance at this page is enough to merge." }; + : lvl.level === "light" + ? { id: "1", rule: `Light change (${lvl.lines} line(s), nothing risky): the checks passed, no review was needed. Merge.` } + : { id: "1", rule: "Verified and contained. A glance at this page is enough to merge." }; if (checksOnly) tier.rule = `${tier.rule} (Checks only: no independent review ran here.)`; @@ -198,7 +208,7 @@ for (const f of [acceptancePath, ...reviews.map((r) => r.path)]) if (existsSync( const md = []; md.push(`# Evidence: ${basename(runDir)}`, ""); md.push(`**Merge tier: ${tier.id}.** ${tier.rule}`, ""); -md.push(`Tree: ${current ?? "unknown"}`, `Base: ${cfg.base ?? "none"}`, ""); +md.push(`Tree: ${current ?? "unknown"}`, `Base: ${cfg.base ?? "none"}`, `Level: ${lvl.level}${lvl.reasons.length ? ` (${lvl.reasons.slice(0, 4).join("; ")})` : ""}`, ""); // Where this change comes from: the spec and task its acceptance was generated from (flow-check). const specRef = /^Spec:\s*(.+)$/m.exec(acceptanceText)?.[1].trim(); const taskRef = /^Task:\s*(.+)$/m.exec(acceptanceText)?.[1].trim(); diff --git a/plugins/dx-workflow/scripts/review-brief.mjs b/plugins/dx-workflow/scripts/review-brief.mjs index ccffc0d..70a89c3 100644 --- a/plugins/dx-workflow/scripts/review-brief.mjs +++ b/plugins/dx-workflow/scripts/review-brief.mjs @@ -7,7 +7,7 @@ // node review-brief.mjs --lane frontend --request "…" --scope "" --baselines "" // // Prints the brief (pass it verbatim to a fresh subagent) and saves it to .verify/brief-.md. -// Exit 0 with a brief; 3 when three rounds ran without approval (stop and hand the findings to the +// Exit 0 with a brief; 3 when two rounds ran without approval (stop and hand the findings to the // user); 2 when inputs are missing (no run of this lane on the current tree). // // Rounds: a review of an older tree is archived to .verify/rounds/-.md when the next brief is @@ -17,9 +17,10 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { CHECKLIST_PATH, matchChecklist, parseChecklist } from "./lib/checklist.mjs"; +import { changeLevel } from "./lib/level.mjs"; import { changedSince, contractPaths, gitLines, gitShow, guardChanges, inLane, loadConfig, matchAny, OPEN_LINE, readJson, treeHash } from "./lib/verify-config.mjs"; -const MAX_ROUNDS = 3; +const MAX_ROUNDS = 2; const PLUGIN = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const args = process.argv.slice(2); const opt = (name) => { @@ -70,9 +71,24 @@ const reasons3 = [ native.length && `native (needs a store build): ${native.join(", ")}`, guarded.some((g) => g.tier === 3) && `checks changed: ${guarded.filter((g) => g.tier === 3).map((g) => g.path).join(", ")}`, ].filter(Boolean); +const lvl = changeLevel(cfg); +// The level adds what the lane config does not name: risky paths and lines found by the heuristics, migrations. +if (lvl.level === "strict") reasons3.push(...lvl.reasons.filter((r) => !/^(contract|sensitive|native|the checks changed):/.test(r))); const depth = reasons3.length || size > 400 ? "deep" : size <= 30 && !shared.length ? "quick" : "standard"; const depthWhy = reasons3.length ? reasons3.join("; ") : size > 400 ? `${size} changed lines` : depth === "quick" ? `${size} changed lines, nothing shared` : `${size} changed lines${shared.length ? `, shared: ${shared.join(", ")}` : ""}`; +// Which reviews this change needs: only what the diff touched. +const VISUAL_FILE = /\.(css|scss|sass|less)$|(^|\/)(tailwind\.config|theme|tokens?)\.|-snapshots\/|(^|\/)docs\/design\.md$/; +const VISUAL_LINE = /className=|class=|style=|StyleSheet|styled\.|<[A-Z][A-Za-z]*[\s/>]|<(div|span|button|input|section|header|footer|nav|ul|li|img|View|Text|Pressable)\b/; +const visual = lane.kind === "frontend" && (lanePaths.some((p) => VISUAL_FILE.test(p)) || diffLines.some((l) => VISUAL_LINE.test(l))); +const securityWhy = lvl.level === "strict" ? lvl.reasons.filter((r) => !/^(native|the checks changed|migration):/.test(r)) : []; +const reviews = [ + "code", + ...(visual ? ["UI (screenshots)"] : []), + ...(contract.length ? ["contract compatibility"] : []), + ...(securityWhy.length ? ["security"] : []), +]; + // Checklist items this diff triggers, from the base commit's checklist. const checklistText = gitShow(root, cfg.base ?? "HEAD", CHECKLIST_PATH) ?? (existsSync(join(root, CHECKLIST_PATH)) ? readFileSync(join(root, CHECKLIST_PATH), "utf8") : ""); const items = parseChecklist(checklistText); @@ -116,7 +132,9 @@ const deferredPath = join(cfg.dir, `deferred-${lane.name}.md`); const deferred = existsSync(deferredPath) ? readFileSync(deferredPath, "utf8").trim() : ""; const guides = lane.kind === "frontend" - ? `${join(PLUGIN, "skills/frontend/design-review.md")} for the screenshots, then ${join(PLUGIN, "skills/frontend/code-review.md")} for the code (one review file, one Findings list)` + ? visual + ? `${join(PLUGIN, "skills/frontend/design-review.md")} for the screenshots, then ${join(PLUGIN, "skills/frontend/code-review.md")} for the code (one review file, one Findings list)` + : `${join(PLUGIN, "skills/frontend/code-review.md")} (nothing visual changed: no screenshot review)` : join(PLUGIN, "skills/backend/code-review.md"); const contractDoc = lane.kind === "frontend" ? "docs/design.md" : "docs/backend.md"; @@ -132,7 +150,14 @@ out.push(`- the change: \`git diff ${short(cfg.base)}\` (${lanePaths.length} fil const newFiles = lanePaths.filter((p) => untracked.has(p)); if (newFiles.length) out.push(`- new files not yet in git, so not in that diff (read them whole): ${newFiles.join(", ")}`); out.push(`- Tree under review: ${current}. Write "Tree: ${current}" under the title.`, ""); -out.push(`## Depth: ${depth} (${depthWhy})`); +out.push(`## Reviews: ${reviews.join(", ")}`); +if (contract.length) out.push(`- Contract compatibility: ${contract.join(", ")} changed. Check that every existing caller (other services, the web app, app builds already installed) still works, or that the break is in the acceptance and agreed.`); +if (securityWhy.length) + out.push( + `- Security (${securityWhy.slice(0, 3).join("; ")}): who may call it and on whose data (authorisation on every object read or written), input validation and injection, secrets and tokens (never logged, never in the client), session and cookie flags, what an attacker sees in errors. Each finding needs the request or input that shows it.`, + ); +out.push(""); +out.push(`## Depth: ${depth} (${depthWhy})`, `Write "Depth: ${depth}" under the title.`); if (depth === "quick") out.push("Mark every acceptance criterion; run only the lenses whose subject is in the diff; skip the safety fact unless a finding needs one."); if (depth === "standard") out.push("Mark every acceptance criterion; run each lens whose subject is in the diff; name and prove the safety fact for the riskiest part."); if (depth === "deep") diff --git a/plugins/dx-workflow/scripts/stop-gate.mjs b/plugins/dx-workflow/scripts/stop-gate.mjs index 15be270..5320bf8 100644 --- a/plugins/dx-workflow/scripts/stop-gate.mjs +++ b/plugins/dx-workflow/scripts/stop-gate.mjs @@ -1,11 +1,13 @@ #!/usr/bin/env node // Claude Code Stop hook. In a project with .verify/config.json it blocks the end of a turn that -// changed files of a lane (frontend, backend, …) when that lane is not verified for exactly the content on -// disk now: -// - its last run-verify did not pass, or ran on a different tree (content hash, not file times); -// - its independent review is missing, open, not approved, or names a different tree; -// - the acceptance criteria are missing or not all accounted for in a review; -// - the evidence pack is missing, names a different tree, or is older than a review. +// changed files of a lane (frontend, backend, …) when the change is not verified for exactly the +// content on disk now. What "verified" means depends on the change's level (lib/level.mjs): +// light every touched lane's last run-verify passed on this tree. Nothing else. +// standard also: an independent review of this tree, approved with no open line; the acceptance +// criteria all accounted for in a review; the evidence pack (the gate makes it itself +// when that is all that is missing). +// strict also: the review was deep ("Depth: deep", which review-brief.mjs asks for). +// A run or review counts only for the tree it names (content hash, not file times). // "Changed" means: the files differ from the base commit (committed on this branch or not, deletions // included), and the tree differs from the one recorded when the turn started (turn-start.mjs), so a // turn that only talked is not stopped. @@ -13,8 +15,11 @@ // It blocks once per stop (stop_hook_active lets the second attempt through, so a turn cannot loop // forever). DX_WORKFLOW_GATE: "enforce" (default) blocks; "observe" only logs what it would have // blocked; "off" does nothing. Every decision is appended to .verify/gate.log. +import { spawnSync } from "node:child_process"; import { appendFileSync, existsSync, readFileSync, statSync } from "node:fs"; -import { join } from "node:path"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { changeLevel } from "./lib/level.mjs"; import { acceptanceIds, acceptanceLines, @@ -47,6 +52,7 @@ const current = treeHash(root); const turn = readJson(join(cfg.dir, "turn.json")); if (current && turn?.tree === current) process.exit(0); // this turn changed nothing +const lvl = changeLevel(cfg, changes); const last = readJson(join(cfg.dir, "last-run.json")); const problems = []; const reviewTimes = []; @@ -65,6 +71,7 @@ for (const { lane, files } of required) { } if (run.result !== "pass") problems.push(`${label}: the last run-verify result is "${run.result}", not "pass".`); if (run.tree !== current) problems.push(`${label}: files changed since the last run-verify (it checked tree ${short(run.tree)}, the tree is now ${short(current)}).`); + if (lvl.level === "light") continue; if (!existsSync(reviewPath)) { problems.push(`${label}: .verify/review-${lane.name}.md is missing (independent review).`); continue; @@ -77,11 +84,14 @@ for (const { lane, files } of required) { const open = review.split("\n").filter(OPEN_LINE); if (open.length) problems.push(`${label}: its review still has ${open.length} open or failing line(s).`); if (!/^Verdict:\s*approved\b/im.test(review)) problems.push(`${label}: its review does not say "Verdict: approved".`); + if (lvl.level === "strict" && !/^Depth:\s*deep\b/im.test(review)) problems.push(`${label}: the change is strict (${lvl.reasons[0]}), so its review must be deep: write a new brief with review-brief.mjs and dispatch a fresh reviewer.`); for (const l of acceptanceLines(review)) for (const m of l.matchAll(/\bA\d+\b/gi)) coveredIds.add(m[0].toUpperCase()); } const acceptancePath = join(cfg.dir, "acceptance.md"); -if (!existsSync(acceptancePath)) problems.push(".verify/acceptance.md is missing: write the observable criteria for this change (shared/acceptance.md)."); +if (lvl.level === "light") { + // nothing beyond passing checks +} else if (!existsSync(acceptancePath)) problems.push(".verify/acceptance.md is missing: write the observable criteria for this change (shared/acceptance.md)."); else { const ids = acceptanceIds(readFileSync(acceptancePath, "utf8")); if (ids.length === 0) problems.push(".verify/acceptance.md has no criteria (lines starting with `- A1`)."); @@ -89,16 +99,28 @@ else { if (missing.length && reviewTimes.length) problems.push(`acceptance criteria ${missing.join(", ")} appear in no review's "## Acceptance" section.`); } -const evidencePath = last?.runDir ? join(last.runDir, "evidence.md") : ""; -if (!evidencePath || !existsSync(evidencePath)) problems.push("the evidence pack is missing: run make-evidence.mjs after the reviews."); -else { +// The evidence pack is bookkeeping, not a step: when everything else holds, make it here. +if (lvl.level !== "light") { + let evidence = evidenceProblems(); + if (evidence.length && problems.length === 0) { + spawnSync(process.execPath, [join(dirname(fileURLToPath(import.meta.url)), "make-evidence.mjs"), "--root", root], { cwd: root, stdio: "ignore", timeout: 20_000 }); + evidence = evidenceProblems(); + } + problems.push(...evidence); +} + +function evidenceProblems() { + const evidencePath = last?.runDir ? join(last.runDir, "evidence.md") : ""; + if (!evidencePath || !existsSync(evidencePath)) return ["the evidence pack is missing: run make-evidence.mjs after the reviews."]; + const out = []; const evidenceTree = /^Tree:\s*([0-9a-f]+)/im.exec(readFileSync(evidencePath, "utf8"))?.[1]; - if (evidenceTree !== current) problems.push("the evidence pack is of another tree: run make-evidence.mjs again."); - if (reviewTimes.some((t) => statSync(evidencePath).mtimeMs < t)) problems.push("the evidence pack is older than a review: run make-evidence.mjs again."); + if (evidenceTree !== current) out.push("the evidence pack is of another tree: run make-evidence.mjs again."); + if (reviewTimes.some((t) => statSync(evidencePath).mtimeMs < t)) out.push("the evidence pack is older than a review: run make-evidence.mjs again."); + return out; } if (problems.length === 0) { - log("pass", []); + log(`pass (${lvl.level})`, []); process.exit(0); } if (input.stop_hook_active) { @@ -111,9 +133,11 @@ if (mode === "observe") { } log("block", problems); block([ - "Changes are not verified:", + `Changes are not verified (level ${lvl.level}${lvl.reasons.length ? `: ${lvl.reasons.slice(0, 3).join("; ")}` : ""}):`, ...problems.map((p) => `- ${p}`), - "Follow the lane's skill (ui: frontend verify.md; api: backend verify.md): run run-verify.mjs, get an independent review written to .verify/review-.md that names the run's tree and accounts for every acceptance criterion, then run make-evidence.mjs.", + lvl.level === "light" + ? "A light change needs only its checks: run run-verify.mjs and fix what fails." + : "Run run-verify.mjs, then an independent review: review-brief.mjs writes the brief for a fresh subagent, which writes .verify/review-.md. The gate makes the evidence pack itself.", "If you cannot verify (no browser, no database, server will not start), say so plainly to the user instead of claiming the work is done.", ]); diff --git a/plugins/dx-workflow/shared/acceptance.md b/plugins/dx-workflow/shared/acceptance.md index 3c659b2..f1f0ee6 100644 --- a/plugins/dx-workflow/shared/acceptance.md +++ b/plugins/dx-workflow/shared/acceptance.md @@ -1,7 +1,9 @@ # Acceptance: decide what "done" looks like before building -Every change gets `.verify/acceptance.md` before any product code is written. It lists what a user -or a caller can observe when the change works, each item with the proof that will show it. The +Every Medium or Large change gets `.verify/acceptance.md` before any product code is written (a +Small change states its one to three criteria in a sentence to the developer and writes no file; +a light change needs none). It lists what a user or a caller can observe when the change works, +each item with the proof that will show it. The builder writes it; an independent reviewer later marks each item met, not met or not checked; the evidence pack shows those marks apart from the machine checks, because tests passing is not the same as the requirement being met. @@ -10,9 +12,9 @@ as the requirement being met. | Change | Acceptance | | --- | --- | -| Copy, a colour, a one-line fix | 1 to 3 criteria, no interview | -| A feature inside one lane, no contract change | the criteria plus the adverse cases below that apply | -| A new flow, an API or data contract change, a migration, auth | a spec first (`shared/spec.md`, size L in the `flow` skill): the criteria live in the spec and each task's file is generated from it | +| Small: copy, a colour, a one-line fix | 1 to 3 criteria said to the developer, no file, no interview | +| Medium: one feature or fix, one pull request | the file: criteria plus the adverse cases below that apply; a `## Plan` of a few bullets only when the change has several parts | +| Large: a new flow, more than one pull request | a spec first (`skills/workflow/large.md`): the criteria live in the spec and each task's file is generated from it | ## Interview first when the change is big diff --git a/plugins/dx-workflow/shared/debug.md b/plugins/dx-workflow/shared/debug.md index 929f57b..5074124 100644 --- a/plugins/dx-workflow/shared/debug.md +++ b/plugins/dx-workflow/shared/debug.md @@ -1,43 +1,20 @@ # Debug: find the cause before the next fix -`run-verify.mjs` prints "failed again" when the same check has failed two runs in a row. From then -on, another change made to see if it helps is guessing: it costs a run, can pass by luck, and leaves -the real cause in the code. Stop, and diagnose. The same applies to any bug the user reports. +`run-verify.mjs` prints "failed again" when a check fails two runs in a row. Another change made to +see if it helps is guessing. Stop and diagnose; the same goes for a bug the developer reports. -If one of these is installed, follow it for the loop below (`shared/skill-packs.md`): -`mattpocock-skills:diagnosing-bugs`, `superpowers:systematic-debugging`, -`agent-skills:debugging-and-error-recovery`. Whichever you use, the result goes in `.verify/debug.md`. +Use `superpowers:systematic-debugging` or `mattpocock-skills:diagnosing-bugs` when installed. +Otherwise: reproduce it with one command that fails every time; read the whole error and the diff +since it last passed; test the cheapest hypothesis first, one change at a time; bisect when stuck; +fix the cause once and keep the reproduction as a test. -## The loop - -1. **Reproduce it on demand.** The smallest command that fails every time: one test, one request, one - journey step, with the log. If it does not fail every time, the first job is to find what makes it - fail (order, timing, data, environment), not to fix it. -2. **Read the evidence.** The full error and stack, the log around it, the screenshot or trace, the - diff since it last passed (`git diff `). Write down what you see, - not what you expect. -3. **List causes and test the cheapest first.** Two or three hypotheses, each with the observation - that would rule it out. Add logging or a breakpoint, change one thing, rerun the reproduction. -4. **Narrow mechanically when stuck.** Bisect the diff (revert half, rerun), bisect the input, or - compare with the last passing run's logs line by line. -5. **Fix the cause, once.** Keep the reproduction as a test (it must fail before the fix and pass - after). Remove the temporary logging. -6. **Record it** in `.verify/debug.md` (the evidence pack shows it): +Write the result in `.verify/debug.md` (the evidence pack shows it): ```markdown -# Debug - check: backend/integration · failed 3 runs in a row -- symptom: POST /orders returns 500 on the second call with the same Idempotency-Key -- cause: the unique index is on (key) but the lookup filters by (key, user_id), so a retry by the same user misses and inserts -- proof: test "same key twice returns the first order" failed before, passes after -- ratchet: checklist item C4 (shared/ratchet.md) +- cause: the unique index is on (key) but the lookup filters by (key, user_id) +- proof: "same key twice returns the first order" failed before, passes after ``` -## Never - -- rerun until it passes, add a sleep or a retry, raise a timeout, loosen an assertion or a screenshot - threshold, skip or delete the test (each of these is also a guarded change: merge tier 2 or 3); -- fix two things at once, so you cannot tell which one mattered; -- call it flaky without the reproduction that shows the race or the shared state. - -A cause that a check could have caught goes through `shared/ratchet.md`. +Never rerun until green, add a sleep or a retry, loosen an assertion or a threshold, or skip the +test. A cause a check could have caught goes through `shared/ratchet.md`. diff --git a/plugins/dx-workflow/shared/skill-packs.md b/plugins/dx-workflow/shared/skill-packs.md index 5068ac9..21419d8 100644 --- a/plugins/dx-workflow/shared/skill-packs.md +++ b/plugins/dx-workflow/shared/skill-packs.md @@ -1,52 +1,36 @@ -# Working with other skill packs +# Working with superpowers and Matt Pocock's skills -Matt Pocock's skills, superpowers and agent-skills each cover the whole path from idea to merge, and -do several steps very well. Inside this plugin's flow they do the work of a step; this plugin keeps the -files of record and the gates. Use a skill below only when it appears in your available skills -(installed as a plugin they show as `mattpocock-skills:`, `superpowers:`, -`agent-skills:`); otherwise follow this plugin's own instructions for the step. +dx-workflow orchestrates and verifies; it does not redo what these do well. When one is in your +available skills, use it for the work inside a step. When it is not, follow this plugin's short +fallback for that step. -## Who does which step - -| Step | Use, if installed (first match) | This plugin's file of record and gate | +| Step | Use | Fallback | | --- | --- | --- | -| Define: interview, spec | `mattpocock-skills:grilling` · `grill-with-docs`; `agent-skills:interview-me` · `spec-driven-development`; `superpowers:brainstorming` | `docs/specs/.md`, `flow-check.mjs spec` (`shared/spec.md`) | -| Domain language | `mattpocock-skills:domain-modeling` · `grill-with-docs` | `GLOSSARY.md` | -| Tasks | `agent-skills:planning-and-task-breakdown`; `superpowers:writing-plans`; `mattpocock-skills:to-tickets` | `docs/specs/.tasks.md`, `flow-check.mjs tasks` (`shared/tasks.md`) | -| Test first | `mattpocock-skills:tdd`; `superpowers:test-driven-development`; `agent-skills:test-driven-development` | the negative check in `run-verify.mjs` | -| Parallel tasks | `superpowers:using-git-worktrees` · `dispatching-parallel-agents` | one task, one worktree, one `.verify/`, one pull request | -| Debug | `mattpocock-skills:diagnosing-bugs`; `superpowers:systematic-debugging`; `agent-skills:debugging-and-error-recovery` | `.verify/debug.md` (`shared/debug.md`) | -| Browser inspection | `agent-skills:browser-testing-with-devtools` (console errors, failed requests, performance) | findings go into the frontend review | -| Architecture, cleanup | `mattpocock-skills:improve-codebase-architecture` · `codebase-design`; `agent-skills:code-simplification` | its own change; old patterns removed (`shared/ratchet.md`) | -| Security, performance depth | `agent-skills:security-and-hardening` · `performance-optimization` | findings feed the review lenses and `docs/checklist.md` | +| Understand a Large request | `superpowers:brainstorming`, `mattpocock-skills:grilling` (`grill-with-docs` also builds a glossary) | interview, one question at a time (`workflow/SKILL.md`) | +| Architecture | `mattpocock-skills:codebase-design`, `improve-codebase-architecture` | the spec's Architecture section (`workflow/large.md`) | +| Plan | `superpowers:writing-plans`, `mattpocock-skills:to-tickets` | the task list (`workflow/large.md`) | +| Tests first | `superpowers:test-driven-development`, `mattpocock-skills:tdd` | the lane's `build.md` | +| Parallel tasks | `superpowers:using-git-worktrees`, `dispatching-parallel-agents` | one task at a time | +| Debug | `superpowers:systematic-debugging`, `mattpocock-skills:diagnosing-bugs` | `shared/debug.md` | +| Code quality, cleanup | `mattpocock-skills:improve-codebase-architecture`, `code-review` (as an extra pass) | `shared/ratchet.md` | | Retro | `mattpocock-skills:retro` | `shared/ratchet.md` | -## Where they disagree with this plugin, this plugin wins - -- **Files of record.** Specs live in `docs/specs/.md` and tasks in `docs/specs/.tasks.md`, - in the formats `flow-check.mjs` reads. A pack that writes elsewhere (`docs/superpowers/specs/`, - `SPEC.md`, `tasks/todo.md`, `.scratch/`, issue tracker tickets) is a draft or a mirror: carry the - content over and link it under `Sources:`. -- **Done.** A change is done when this plugin's Stop gate lets it end: `run-verify.mjs` passed on the - tree on disk, an independent review of that tree approved it from `review-brief.mjs`, and the evidence - pack has a merge tier. "Tests pass" (`superpowers:verification-before-completion`) or a pack's own - definition of done is part of that, not a replacement for it. -- **Review.** The independent review comes from `review-brief.mjs`. A pack's reviewers - (`superpowers:requesting-code-review`, `agent-skills:code-review-and-quality`, - `mattpocock-skills:code-review`, the task reviewer in `superpowers:subagent-driven-development`) may - run as extra passes while building; their verdicts do not replace it and are not "Verdict: approved". -- **Merge.** The merge tier decides who must look. Do not merge locally or open a ready pull request - before the evidence pack exists (`superpowers:finishing-a-development-branch` options "merge locally" - and "push and create a PR" wait for it). A pack's `/ship` checklist adds to the tier; it cannot lower it. -- **Commits.** Plans that commit after each step are fine on the task's branch; the commit stamp - (`stamp.mjs`) records whether each was verified. -- **Session start.** Meta-skills that route every message (`superpowers:using-superpowers`, - `agent-skills:using-agent-skills`) may stay on; when one routes work in a project with - `.verify/config.json`, start from this plugin's `flow` skill. -- **Never weaken a check** to satisfy a pack's step: a skipped test, a loosened threshold or an - edited `.verify/config.json` is a guarded change whatever skill asked for it. +## Where they overlap with this plugin, this plugin decides -## Versions +- **Done** is the Stop gate letting the turn end: the checks passed on the tree on disk and, for + standard and strict changes, the independent review from `review-brief.mjs` approved it. "Tests + pass" (`superpowers:verification-before-completion`) is part of that. +- **The independent review** is the one `review-brief.mjs` writes. Reviews inside other skills + (`superpowers:requesting-code-review`, the reviewer in `superpowers:subagent-driven-development`, + `mattpocock-skills:code-review`) are extra passes while building, not the approval. +- **Merging** follows the merge tier. Do not merge locally or mark a pull request ready before the + Stop gate passes (`superpowers:finishing-a-development-branch` waits for it). +- **Files of record** for Large changes are `docs/specs/.md` and `.tasks.md`. Drafts other + skills write elsewhere (`docs/superpowers/`, `.scratch/`, an issue) are linked under `Sources:`. +- **Session routing** (`superpowers:using-superpowers`) can stay on; in a project with + `.verify/config.json`, coding requests start from this plugin's `workflow` skill. +- **No check is weakened** for another skill's step: skipping a test or editing `.verify/config.json` + is a guarded change whichever skill asked for it. -The table was written against the commits in `vendor.lock.json` ("routed"). When a pack renames or -removes a skill, the step falls back to this plugin's own instructions; update the table in its own change. +Versions these names were checked against: `vendor.lock.json`, "routed". If a skill is renamed, +use the fallback and update this table in its own change. diff --git a/plugins/dx-workflow/shared/spec.md b/plugins/dx-workflow/shared/spec.md deleted file mode 100644 index b4ec398..0000000 --- a/plugins/dx-workflow/shared/spec.md +++ /dev/null @@ -1,68 +0,0 @@ -# Define: a spec the user agrees before anything is built - -For size L (`skills/flow/SKILL.md`). The spec says what problem this solves, what outcome counts as -success, what it will not do, and the observable criteria that prove it. It is a file in the repo, -`docs/specs/.md`, because tasks, acceptance files, reviews and evidence packs point back to it. - -## 1. Get the answers - -Interview the user until every goal and criterion can be written without guessing: who it is for, -what problem, what success looks like, what must never happen, what is out of scope, which failure -cases matter. One question at a time, each with your recommended answer. Look in the code before -asking what the code can tell you. - -If one of these is installed, use it for the interview (`shared/skill-packs.md`): -`mattpocock-skills:grilling` (or `grill-with-docs` to also build the glossary), -`agent-skills:interview-me` or `agent-skills:spec-driven-development`, `superpowers:brainstorming`. -Whatever it writes, the spec of record is the file below; link theirs under `Sources:`. - -## 2. Write the spec - -```markdown -# Spec: -Status: draft -Owner: -Sources: - -## Problem - - -## Goals -- S1 -- S2 … - -## Non-goals -- - -## Constraints -- - -## Decisions -- D1 · · - -## Open questions -- Q1 · owner: (open: blocks the gate) -- Q2 → D3 (answered: the decision records it) -- Q3 · deferred: - -## Acceptance -- A1 (S1) · proof: -- A2 … (S1, S2) · proof: … -``` - -Criteria follow `shared/acceptance.md` (observable, one behaviour each, with a proof) and cite the -goals they prove. Go through its adverse cases for every lane the work touches; the ones that apply -become criteria here. - -## 3. The gate - -```bash -node /scripts/flow-check.mjs spec docs/specs/.md -``` - -It stays shut until `Status: agreed`, every goal has a criterion, every criterion cites real goals -and names a proof, there are non-goals, and no question is open. Only the user sets `Status: agreed`: -show them the spec, ask, then write it. Commit the spec on its own (`docs(spec): `), before code. - -When the work later shows the spec is wrong, change the spec first, set `Status: draft`, get it -agreed again, then change tasks and code. diff --git a/plugins/dx-workflow/shared/tasks.md b/plugins/dx-workflow/shared/tasks.md deleted file mode 100644 index 85b007b..0000000 --- a/plugins/dx-workflow/shared/tasks.md +++ /dev/null @@ -1,64 +0,0 @@ -# Tasks: split an agreed spec into pull requests - -For size L, after `flow-check.mjs spec` passes. Each task is one pull request: small enough to review -and to revert alone, verified alone, and owning specific acceptance criteria, so its review marks -exactly those. - -## How to split - -- **Vertical slices.** A task delivers something a user or caller can observe (its criteria), across - the layers it needs. Not "all the models", then "all the endpoints", then "all the screens". -- **Contract first when lanes meet.** When the frontend needs a new endpoint, the first task changes - the contract (OpenAPI, schema) and the backend; frontend tasks depend on it. A migration that - must run before code reads it is its own task, expand before contract (`backend/build.md`). -- **S or M only.** About 400 changed lines at most. A larger task hides its risk and its review - stalls; split it again. -- **Risk up front.** Guess each task's merge tier now (1, 2 or 3, with the reason). A tier 3 task - needs the owner's attention: put it early, so a "no" comes before the work that depends on it. -- **Independent where possible.** Tasks without dependencies between them can be built in parallel. - -If one of these is installed, use it to draft the split (`shared/skill-packs.md`): -`agent-skills:planning-and-task-breakdown`, `superpowers:writing-plans`, `mattpocock-skills:to-tickets`. -The task list of record is the file below; their plans and tickets can link to it. - -## The file: `docs/specs/.tasks.md` - -```markdown -# Tasks: - -## T1 Orders API accepts an Idempotency-Key -- lanes: api -- acceptance: A1, A2 -- depends: none -- size: M -- risk: 3 · contract change (openapi.yaml) - -## T2 Checkout sends the key and shows the first order on retry -- lanes: web, app -- acceptance: A3 -- depends: T1 -- size: M -- risk: 2 · shared checkout button -- status: done · PR #123 -``` - -`lanes` are lane names from `.verify/config.json`. - -## The gate - -```bash -node /scripts/flow-check.mjs tasks docs/specs/.tasks.md -``` - -Open when the spec gate is open, every criterion belongs to a task, every task names lanes, -criteria, a size of S or M and a risk tier, its lanes exist, and no dependency is missing or circular. - -## Working through them - -```bash -node /scripts/flow-check.mjs next docs/specs/.tasks.md --done T1 # what can start now -node /scripts/flow-check.mjs acceptance docs/specs/.md T2 --write # its .verify/acceptance.md -``` - -Then the lane's `build.md` and `verify.md` as for any M change. The generated acceptance file names -the spec and the task; the evidence pack and the pull request body carry both. diff --git a/plugins/dx-workflow/shared/verify-ci.yml b/plugins/dx-workflow/shared/verify-ci.yml index 76cf675..8d78c76 100644 --- a/plugins/dx-workflow/shared/verify-ci.yml +++ b/plugins/dx-workflow/shared/verify-ci.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 60 env: # Pin the plugin to a release tag or commit; upgrade it in its own pull request. - DX_WORKFLOW_REF: v0.5.0 + DX_WORKFLOW_REF: v0.7.0 VERIFY_BASE: origin/${{ github.base_ref }} steps: - uses: actions/checkout@v4 diff --git a/plugins/dx-workflow/skills/backend/SKILL.md b/plugins/dx-workflow/skills/backend/SKILL.md index b6a3ca9..f618e28 100644 --- a/plugins/dx-workflow/skills/backend/SKILL.md +++ b/plugins/dx-workflow/skills/backend/SKILL.md @@ -19,9 +19,10 @@ the contract. `` is this skill's folder; `` is two levels up (it | Project state | Read | | --- | --- | -| A new feature, a contract or migration change, or unsure which steps a change needs | the `flow` skill first: it sizes the change and may need a spec and tasks before this skill | +| Any coding request, or unsure which steps a change needs | the `workflow` skill first: it decides size, level and steps; this skill is how to build and verify in this lane | | The same check failed two runs in a row, or the user reports a bug | `/shared/debug.md` before the next fix | -| No `docs/backend.md` or no `backend` lane in `.verify/config.json` | `setup.md`, then come back | +| No `.verify/config.json` | `node /scripts/init.mjs`, then come back | +| No `docs/backend.md`, and the change touches a contract, a migration or an endpoint the checks do not cover | `setup.md` for the parts this change needs; otherwise follow the code's existing patterns | | Any change | `/shared/acceptance.md` first: write `.verify/acceptance.md` | | Building or changing endpoints, jobs, schema | `build.md`, then `verify.md` | | Asked only to review a change | `verify.md` (dispatch), then `code-review.md` | diff --git a/plugins/dx-workflow/skills/backend/setup.md b/plugins/dx-workflow/skills/backend/setup.md index 2847e9f..d4f91a4 100644 --- a/plugins/dx-workflow/skills/backend/setup.md +++ b/plugins/dx-workflow/skills/backend/setup.md @@ -1,5 +1,9 @@ # Setup: a backend contract and checks for this project +This is the full setup, not the first step. A project starts with `node /scripts/init.mjs` +(the existing test, lint and type commands as lanes) and works from there; come here when a change +needs more: the first time a change touches a contract, a migration or an endpoint the checks do not cover, or when the developer asks. Do the parts that change needs. + Do this once per project, or once per service when a repo has several (each gets its own lane, `backend-`, with `"kind": "backend"`). The output is `docs/backend.md`, a contract file, the `backend` lane in `.verify/config.json`, and `ctl`. The user decides policy; you find what exists and write it down. diff --git a/plugins/dx-workflow/skills/backend/verify.md b/plugins/dx-workflow/skills/backend/verify.md index 2dc3a7f..2376a0b 100644 --- a/plugins/dx-workflow/skills/backend/verify.md +++ b/plugins/dx-workflow/skills/backend/verify.md @@ -1,5 +1,9 @@ # Verify: prove the backend change works +What a change needs depends on its level (`node /scripts/level.mjs`): a **light** change is +done when the checks below pass, with no acceptance file, review or evidence pack. **Standard** and +**strict** changes go on to the independent review; the Stop gate makes the evidence pack. + ## Run the checks `node /scripts/run-verify.mjs --lane backend` (or without `--lane` to run every lane) runs the @@ -63,7 +67,7 @@ Then: resume the previous reviewer. 3. Defer a Should-fix only with a reason the user would accept; every deferral is in your final message. Blockers, unmet criteria and broken checklist items are never deferred. -4. After three rounds without `approved`, `review-brief.mjs` refuses a fourth (exit 3): stop, +4. After two rounds without `approved`, `review-brief.mjs` refuses a third (exit 3): stop, reconsider the approach, and give the user the open findings. 5. After an approved review, go through `/shared/ratchet.md` for every Blocker and every finding the reviewer called a class: it turns them into checks so the next change cannot repeat them. @@ -72,7 +76,7 @@ Then: ## Evidence pack and merge tier -After the review, `node /scripts/make-evidence.mjs` (add `--pr` for a pull request body). +After the review the Stop gate writes the evidence pack itself; run `node /scripts/make-evidence.mjs --pr` when you need the pull request body. | Tier | When | Who must look | | --- | --- | --- | diff --git a/plugins/dx-workflow/skills/flow/SKILL.md b/plugins/dx-workflow/skills/flow/SKILL.md deleted file mode 100644 index 1a412af..0000000 --- a/plugins/dx-workflow/skills/flow/SKILL.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -name: flow -description: Use at the start of any feature, fix or change request bigger than a one-line edit, and whenever unsure what comes next. Sizes the change and runs it through define, acceptance, tasks, build, debug, verify and learn, with a gate between each step; routes each step to the frontend or backend skill, or to an installed skill pack (Matt Pocock's skills, superpowers, agent-skills) where one does that step well. ---- - -# Flow: from request to merged, with a gate between every step - -## Overview - -The `frontend` and `backend` skills prove a change is right. This skill decides which steps a change -needs before that, in what order, and what must be true before the next step starts. Each step leaves -a file the next step reads, so a review's marks trace back to the goals the user agreed: - -```text -request → spec (S goals, A criteria) → tasks (T, each owning some A) → .verify/acceptance.md - → tests and code → run-verify → independent review → evidence pack + merge tier → ratchet -``` - -`` is two levels up from this skill (it holds `scripts/` and `shared/`). Other skill packs -may do a step's work; the gates and the files of record stay this plugin's -(`/shared/skill-packs.md`). - -## 1. Size the change - -| Size | When | Steps | -| --- | --- | --- | -| S | copy, a colour, a one-line fix, a config value; no contract, no migration, no auth, no native change | acceptance (1 to 3 criteria) → build → verify | -| M | one feature or fix inside one or two lanes that fits one pull request (about 400 changed lines), no contract change | acceptance with the adverse cases → build → verify | -| L | a new flow; an API, data or design contract change; a migration; auth or payments; a native change; more than one pull request; or the user cannot yet say what done looks like | define → acceptance in the spec → tasks → per task as M → verify each | - -When unsure between two sizes, take the larger. Tell the user the size and the steps in one line -before starting, so they can say "smaller". - -## 2. The steps and their gates - -| Step | Produces | Gate to the next step | How | -| --- | --- | --- | --- | -| Define (L) | `docs/specs/.md`: problem, goals `S1…`, non-goals, constraints, decisions `D1…`, open questions `Q1…` | `node /scripts/flow-check.mjs spec docs/specs/.md` exits 0: the user agreed it, no question is open, every goal has a criterion | `/shared/spec.md` | -| Acceptance | L: the spec's `## Acceptance` (`A1 … (S1) · proof: …`). S and M: `.verify/acceptance.md` | every criterion observable, with a proof; adverse cases decided | `/shared/acceptance.md` | -| Tasks (L) | `docs/specs/.tasks.md`: `T1…`, each with lanes, the criteria it delivers, dependencies, size S or M, a risk tier guess | `flow-check.mjs tasks docs/specs/.tasks.md` exits 0: every criterion in a task, no cycle, nothing larger than M | `/shared/tasks.md` | -| Start a task | `.verify/acceptance.md` for that task, traced to the spec | `flow-check.mjs acceptance docs/specs/.md T --write`, then add the adverse cases for its lanes | below | -| Build | tests first, then code, at the seams `docs/backend.md` and `docs/design.md` name | the new tests fail without the code (the negative check proves it later) | the lane's skill: `frontend` or `backend`, `build.md` | -| Debug | the root cause in `.verify/debug.md`, and a test that reproduces it | `run-verify.mjs` reports the same check failing two runs in a row: stop and diagnose before the next fix | `/shared/debug.md` | -| Verify | `run-verify.mjs` pass, an independent review of the same tree, the evidence pack with a merge tier | the Stop gate; the tier says who must look | the lane's skill, `verify.md` | -| Learn | a check, a checklist item or a contract line for every Blocker, revert and correction | admitted with evidence, in its own change | `/shared/ratchet.md` | -| Ship | the merge, by tier | tier 1: merge; 2: a person looks at what the pack flags; 3: the owner approves | your team's process; this plugin does not deploy | - -A step's gate is a command or a file, not a feeling. If a gate is shut, the next step does not start; -say which gate and why. - -## 3. Several tasks - -- Take the tasks `flow-check.mjs next docs/specs/.tasks.md --done ` lists; independent - ones can run in parallel, each on its own branch and worktree (superpowers `using-git-worktrees` - does this well). Every worktree has its own `.verify/`, so each task is verified alone. -- One task, one pull request, one evidence pack. Mark a task done in the tasks file - (`- status: done · PR #123`) when its pull request merges, not when its code is written. -- When a task shows the spec was wrong, change the spec first (the user agrees again), then the - tasks, then the code. Never let code and spec drift apart silently. - -## 4. Size S and M - -No spec file: write `.verify/acceptance.md` straight from the request with `shared/acceptance.md` -(for M, with the adverse cases), then the lane's `build.md` and `verify.md`. The steps are the same; -the define and tasks steps are empty. - -## 5. When another skill pack is installed - -Use it for the work inside a step, never for the gates. The table of which skill does which step, -and the rules when they disagree with this plugin, is `/shared/skill-packs.md`. Read it -before invoking one of them inside this flow. diff --git a/plugins/dx-workflow/skills/frontend/SKILL.md b/plugins/dx-workflow/skills/frontend/SKILL.md index 909bc9d..1a1bcfb 100644 --- a/plugins/dx-workflow/skills/frontend/SKILL.md +++ b/plugins/dx-workflow/skills/frontend/SKILL.md @@ -17,9 +17,10 @@ Third-party design skills are tools this workflow calls; they never override the | Project state | Read | | --- | --- | -| A new feature, a contract or migration change, or unsure which steps a change needs | the `flow` skill first: it sizes the change and may need a spec and tasks before this skill | +| Any coding request, or unsure which steps a change needs | the `workflow` skill first: it decides size, level and steps; this skill is how to build and verify in this lane | | The same check failed two runs in a row, or the user reports a bug | `/shared/debug.md` before the next fix | -| No `docs/design.md` | `setup.md`, then come back | +| No `.verify/config.json` | `node /scripts/init.mjs`, then come back | +| No `docs/design.md`, and the change adds or restyles screens | `setup.md` for the design contract (ask the developer first: it takes their decisions); for small changes follow the existing components and styles | | The app is React Native or Expo (a lane with `"platform": "react-native"`) | `mobile.md` alongside every file below | | Any change | `/shared/acceptance.md` first: write `.verify/acceptance.md` | | Request: one page/module should look different from `docs/design.md` | "Style change requests" below | diff --git a/plugins/dx-workflow/skills/frontend/setup.md b/plugins/dx-workflow/skills/frontend/setup.md index 0c73397..8b9fe27 100644 --- a/plugins/dx-workflow/skills/frontend/setup.md +++ b/plugins/dx-workflow/skills/frontend/setup.md @@ -1,5 +1,9 @@ # Setup: a design contract for this project +This is the full setup, not the first step. A project starts with `node /scripts/init.mjs` +(the existing test, lint and type commands as lanes) and works from there; come here when a change +needs more: the first time a screen needs design rules or screenshots, or when the developer asks. Do the parts that change needs. + For a React Native or Expo app, follow `mobile.md` "Setup" for the lane, raw styles, screenshots and journeys; the design contract steps below apply as they are. diff --git a/plugins/dx-workflow/skills/frontend/verify.md b/plugins/dx-workflow/skills/frontend/verify.md index 7bde153..b6d5699 100644 --- a/plugins/dx-workflow/skills/frontend/verify.md +++ b/plugins/dx-workflow/skills/frontend/verify.md @@ -1,5 +1,10 @@ # Verify: prove the screen is right +What a change needs depends on its level (`node /scripts/level.mjs`): a **light** change is +done when the lane's checks pass, with no acceptance file, review or evidence pack. **Standard** and +**strict** changes go on to the independent review (with a screenshot review only when something +visual changed); the Stop gate makes the evidence pack. + In a React Native / Expo lane the look check is `rn-look.mjs` (simulators, default, dark and large-text variants) and the journeys are Maestro flows; read `mobile.md` "Verify" for what a phone adds. Use `--lane ` with the lane's name (`app`, `web`, …). @@ -51,7 +56,7 @@ Then: dispatch a new fresh reviewer. Never resume the previous reviewer; it would grade its own advice. 3. Defer a Should-fix only with a reason the user would accept; every deferral appears in your final message. Blockers are never deferred. -4. After three review rounds without `approved`, `review-brief.mjs` refuses a fourth (exit 3): stop +4. After two review rounds without `approved`, `review-brief.mjs` refuses a third (exit 3): stop and give the user the open findings and the screenshots. 5. After an approved review, go through `/shared/ratchet.md` for every Blocker: a visual mistake that a script could catch (a raw colour, a missing state page, a clipped label) becomes a @@ -67,7 +72,7 @@ cannot loop forever; ending that way means your final message must say the UI is ## Evidence pack and merge tier People read evidence instead of code. After the review, run -`node /scripts/make-evidence.mjs` (add `--pr` when you will open a pull request). It writes `/evidence.md`: the merge tier, +The Stop gate runs `node /scripts/make-evidence.mjs` itself after the review (run it with `--pr` when you will open a pull request). It writes `/evidence.md`: the merge tier, the checks, before/after screenshots per page and width, recordings, the verdict, open and deferred findings, what was not checked, and the merge danger (door, blast radius, how to revert). The Stop gate requires it for the tree on disk, written after the review. diff --git a/plugins/dx-workflow/skills/workflow/SKILL.md b/plugins/dx-workflow/skills/workflow/SKILL.md new file mode 100644 index 0000000..8975dcf --- /dev/null +++ b/plugins/dx-workflow/skills/workflow/SKILL.md @@ -0,0 +1,90 @@ +--- +name: workflow +description: The entry for any coding request in a project that uses dx-workflow (a feature, a fix, a refactor, a screen or an endpoint). The developer only describes what they want; this decides the steps (understand, plan, implement, verify, complete), how much planning the change needs, how strictly it is checked, which installed skills to use (superpowers, Matt Pocock's skills), and when to stop and ask a person. Also use when unsure what comes next. +--- + +# Workflow + +The developer describes what they want. You decide the rest, and keep it as light as the change +allows: a small fix should feel like a small fix. Discipline comes from the checks, not from +paperwork. + +```text +Understand → Plan → Implement → Verify → Complete +``` + +`` is two levels up from this skill (it holds `scripts/` and `shared/`). + +## Two things decide the steps + +**Size** (you judge it from the request; say it in one line so the developer can correct you): + +| Size | What it is | Understand | Plan | Files you write | +| --- | --- | --- | --- | --- | +| Small | a fix, copy, a style, a config value, one small function | restate it in a sentence | none | none | +| Medium | one feature or fix, one pull request | 1 to 3 questions if something is unclear, else none | a few bullet steps, only if the change has more than one part | `.verify/acceptance.md` (untracked), with `## Plan` only when needed | +| Large | a new flow, a cross-cutting change, or more than one pull request | brainstorm and interview until goals are clear | spec with a short architecture section, then tasks | `docs/specs/.md` and `.tasks.md` (`large.md`) | + +**Risk** (computed from the diff, not chosen): `node /scripts/level.mjs` says `light`, +`standard` or `strict`, and why. Auth, payments, permissions, migrations, contracts, native app +config, sensitive paths or changes to the checks make a change `strict` however small it is. + +| Level | Verify asks for | +| --- | --- | +| light | the lane's checks pass (`run-verify.mjs`). That is all. | +| standard | acceptance criteria, the checks, one independent review. The evidence pack is made for you. | +| strict | as standard, with a deep review and a security pass; the owner approves the merge (tier 3). | + +A Small change is usually light, but size does not lower risk: a one-line change to a login check +is strict. Run `level.mjs` again after implementing; the Stop gate uses the real diff. + +## The phases + +**1. Understand.** Read the code the request touches before asking anything the code can answer. +Small: restate the request. Medium: ask only what you cannot decide safely (one question at a time, +with your recommendation). Large: use `superpowers:brainstorming` or `mattpocock-skills:grilling` +when installed, else interview the same way; then the spec (`large.md`). + +**2. Plan.** Small: none. Medium: acceptance criteria in `.verify/acceptance.md` +(`/shared/acceptance.md`: observable results, each with its proof; the adverse cases that +apply), plus a `## Plan` of a few bullets only when the change has several parts. Large: the +architecture section and the task list (`large.md`; `superpowers:writing-plans` or +`mattpocock-skills:to-tickets` can draft the split; `mattpocock-skills:codebase-design` can shape the architecture). + +**3. Implement.** Tests first for behaviour (`superpowers:test-driven-development` or +`mattpocock-skills:tdd` when installed). Follow the lane's skill (`frontend` or `backend`, +`build.md`) and the project's contracts (`docs/design.md`, `docs/backend.md`). Independent Large +tasks can run in parallel in worktrees (`superpowers:using-git-worktrees`); otherwise do not start +subagents while building. + +**4. Verify.** `node /scripts/run-verify.mjs`. When it says a check "failed again", stop and +find the cause (`/shared/debug.md`; `superpowers:systematic-debugging` or +`mattpocock-skills:diagnosing-bugs`). Then by level: light is done when the checks pass. Standard and +strict: one independent review, the only subagent this workflow starts by default: +`node /scripts/review-brief.mjs --lane --request ""`, dispatched to a fresh +subagent. The brief picks the reviews the diff needs (code always; UI only when something visual +changed; contract compatibility; security for risky changes). Fix what it finds; at most two rounds, +then hand the open findings to the developer. The Stop gate checks all of this and makes the evidence pack. + +**5. Complete.** Tell the developer in a few lines: what changed, the level and merge tier, anything +not verified and why. For standard and strict, the pull request body comes from +`make-evidence.mjs --pr`. A Blocker the review found, a revert or a correction from the developer goes +through `/shared/ratchet.md` afterwards, so the next change cannot repeat it. + +## Stop and ask a person when + +- the request can be read two ways and the wrong guess is expensive; +- a Large spec is ready (the developer agrees it before tasks or code); +- the change is strict: say why before building, and the owner approves the merge; +- a check still fails after diagnosis, or two review rounds end without approval; +- the right fix needs a contract, migration or native change the request did not mention. + +Otherwise keep going; do not ask permission for each step. + +## Keep it light + +- No file a step does not need: Small writes none; Medium writes the acceptance file only. +- No review, no evidence pack and no subagent for light changes. +- No step for its own sake: if a phase has nothing to do for this change, skip it silently. +- Other skills do the work inside a step; this plugin's files, gates and review decide when it is + done (`/shared/skill-packs.md`). diff --git a/plugins/dx-workflow/skills/workflow/large.md b/plugins/dx-workflow/skills/workflow/large.md new file mode 100644 index 0000000..a1aee2b --- /dev/null +++ b/plugins/dx-workflow/skills/workflow/large.md @@ -0,0 +1,72 @@ +# Large changes: spec, architecture, tasks + +Only for Large (`SKILL.md`). Two files in the repo, because tasks, acceptance files, reviews and the +pull request point back to them. `superpowers:brainstorming`, `mattpocock-skills:grilling`, +`superpowers:writing-plans` or `mattpocock-skills:to-tickets` may do the thinking; these files are the +record (link their drafts under `Sources:`). + +## 1. The spec: `docs/specs/.md` + +```markdown +# Spec: +Status: draft +Owner: +Sources: + +## Problem + + +## Goals +- S1 + +## Non-goals +- + +## Architecture + + +## Decisions +- D1 · · + +## Open questions +- Q1 · owner: (open: blocks) +- Q2 → D1 (answered) +- Q3 · deferred: + +## Acceptance +- A1 (S1) · proof: +``` + +Show it to the developer; only they set `Status: agreed`. Gate: +`node /scripts/flow-check.mjs spec docs/specs/.md` (agreed, every goal has a criterion +with a proof, non-goals, an architecture section, no open question). Commit the spec before code. + +## 2. The tasks: `docs/specs/.tasks.md` + +One task, one pull request: a vertical slice a user or caller can observe, at most Medium (about +400 changed lines). Contract and migration first when lanes meet; risky tasks early so a "no" comes +before work that depends on it. + +```markdown +## T1 Orders API accepts an Idempotency-Key +- lanes: api +- acceptance: A1, A2 +- depends: none +- size: M +- risk: 3 · contract change +``` + +Gate: `flow-check.mjs tasks docs/specs/.tasks.md` (every criterion in a task, lanes exist, +sizes S or M, a risk guess, no cycle). + +## 3. Working through them + +```bash +node /scripts/flow-check.mjs next docs/specs/.tasks.md --done T1 # what can start now +node /scripts/flow-check.mjs acceptance docs/specs/.md T2 --write # its .verify/acceptance.md +``` + +Then each task is a Medium change. Mark it `- status: done · PR #123` when its pull request merges. +When a task shows the spec was wrong, change the spec first (`Status: draft`, agreed again), then the +tasks, then the code. diff --git a/test/flow.test.mjs b/test/flow.test.mjs index befb61c..a9a1c76 100644 --- a/test/flow.test.mjs +++ b/test/flow.test.mjs @@ -25,6 +25,9 @@ Users can only add. ## Non-goals - Multiplication +## Architecture +sub lives next to add in src/math.mjs; no new module. + ## Decisions - D1 Integers only · keeps parsing simple · David @@ -63,7 +66,8 @@ describe("spec gate", () => { const bad = SPEC.replace("Status: agreed", "Status: draft") .replace("- Q1 Decimals? → D1", "- Q1 Decimals? · owner: David") .replace("- A2 sub(3, 5) returns -2 (S1, S2) · proof: test/run.mjs", "- A2 sub(3, 5) returns -2 (S1, S9)") - .replace("- Multiplication\n", ""); + .replace("- Multiplication\n", "") + .replace("sub lives next to add in src/math.mjs; no new module.\n", ""); const p = checkSpec(parseSpec(bad)).join("\n"); assert.match(p, /Status is "draft"/); assert.match(p, /Q1 is open/); @@ -71,6 +75,7 @@ describe("spec gate", () => { assert.match(p, /A2 cites S9, which is not a goal/); assert.match(p, /A2 names no proof/); assert.match(p, /no non-goals/); + assert.match(p, /no architecture/); }); }); diff --git a/test/helpers.mjs b/test/helpers.mjs index c5f455f..2728d8c 100644 --- a/test/helpers.mjs +++ b/test/helpers.mjs @@ -18,6 +18,8 @@ const GIT_ENV = { }; export const CONFIG = { + // Most tests exercise reviews and evidence, so changes count as standard; light changes have their own tests. + risk: { lightMaxLines: 0 }, lanes: { backend: { files: ["src/**", "test/**"], diff --git a/test/init.test.mjs b/test/init.test.mjs new file mode 100644 index 0000000..0d03903 --- /dev/null +++ b/test/init.test.mjs @@ -0,0 +1,84 @@ +import assert from "node:assert/strict"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { after, describe, it } from "node:test"; +import { git, node } from "./helpers.mjs"; + +const dirs = []; +after(() => dirs.forEach((d) => rmSync(d, { recursive: true, force: true }))); + +function repo(files) { + const root = mkdtempSync(join(tmpdir(), "dxinit-")); + dirs.push(root); + git(root, "init", "-q", "-b", "main"); + for (const [p, c] of Object.entries(files)) { + mkdirSync(dirname(join(root, p)), { recursive: true }); + writeFileSync(join(root, p), typeof c === "string" ? c : JSON.stringify(c, null, 2)); + } + return root; +} +const config = (root) => JSON.parse(readFileSync(join(root, ".verify/config.json"), "utf8")); + +describe("init", () => { + it("turns a single Next.js app's scripts into a frontend lane with a negative check", () => { + const root = repo({ + "package.json": { dependencies: { next: "15", react: "19" }, scripts: { lint: "next lint", typecheck: "tsc --noEmit", test: "vitest run" } }, + "pnpm-lock.yaml": "", + "tsconfig.json": "{}", + }); + const r = node("init.mjs", [], { cwd: root }); + assert.equal(r.code, 0, r.stderr); + const { lanes } = config(root); + assert.deepEqual(Object.keys(lanes), ["web"]); + assert.equal(lanes.web.kind, "frontend"); + assert.deepEqual(lanes.web.checks.map((c) => c.run ?? `negative: ${c.negative.test}`), ["pnpm run typecheck", "pnpm run lint", "pnpm run test", "negative: pnpm run test"]); + assert.match(readFileSync(join(root, ".gitignore"), "utf8"), /^\.verify\/\*\n!\.verify\/config\.json\n$/); + assert.equal(node("init.mjs", [], { cwd: root }).code, 2, "does not overwrite without --force"); + }); + + it("finds every app in a monorepo and leaves the workspace root out", () => { + const root = repo({ + "package.json": { private: true, workspaces: ["apps/*", "services/*"], scripts: { test: "turbo test" }, devDependencies: { turbo: "2" } }, + "apps/web/package.json": { dependencies: { react: "19", vite: "6" }, scripts: { test: "vitest run" } }, + "apps/mobile/package.json": { dependencies: { expo: "52", "react-native": "0.76" }, scripts: { test: "jest", lint: "expo lint" } }, + "services/api/package.json": { dependencies: { fastify: "5" }, scripts: { test: "node --test" } }, + "services/ml/pyproject.toml": '[project]\nname = "ml"\n[tool.ruff]\n[project.optional-dependencies]\ndev = ["pytest", "mypy"]\n', + }); + const r = node("init.mjs", [], { cwd: root }); + assert.equal(r.code, 0, r.stderr); + const { lanes } = config(root); + assert.deepEqual(Object.keys(lanes).sort(), ["api", "ml", "mobile", "web"]); + assert.equal(lanes.mobile.platform, "react-native"); + assert.ok(lanes.mobile.native.includes("apps/mobile/app.json")); + assert.equal(lanes.api.kind, "backend"); + assert.deepEqual(lanes.api.checks.find((c) => c.name === "unit"), { name: "unit", run: "npm run test", cwd: "services/api" }); + assert.deepEqual(lanes.api.checks.find((c) => c.name === "negative").negative, { test: "npm run test", cwd: "services/api" }); + assert.deepEqual(lanes.ml.checks.map((c) => c.name), ["lint", "types", "unit", "negative"]); + assert.deepEqual(lanes.ml.files, ["services/ml/**/*.py"]); + assert.match(r.stdout, /4 lane\(s\)/); + }); + + it("handles Go, dry runs, and repos it cannot read", () => { + const go = repo({ "go.mod": "module x\n" }); + const r = node("init.mjs", ["--dry-run"], { cwd: go }); + assert.equal(r.code, 0); + assert.match(r.stdout, /"go test \.\/\.\.\."/); + assert.throws(() => readFileSync(join(go, ".verify/config.json"))); + assert.equal(node("init.mjs", [], { cwd: repo({ "README.md": "hi" }) }).code, 2); + }); + + it("writes a config run-verify can run straight away", () => { + const root = repo({ + "package.json": { type: "module", main: "src/index.js", scripts: { test: "node test.js" } }, + "src/index.js": "export const one = () => 1;\n", + "test.js": 'import { one } from "./src/index.js";\nif (one() !== 1) process.exit(1);\n', + }); + assert.equal(node("init.mjs", [], { cwd: root }).code, 0); + git(root, "add", "-A"); + git(root, "commit", "-q", "-m", "init"); + const r = node("run-verify.mjs", [], { cwd: root }); + assert.equal(r.code, 0, r.stdout); + assert.match(r.stdout, /lane api: pass/); + }); +}); diff --git a/test/level.test.mjs b/test/level.test.mjs new file mode 100644 index 0000000..a97de89 --- /dev/null +++ b/test/level.test.mjs @@ -0,0 +1,116 @@ +import assert from "node:assert/strict"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; +import { after, describe, it } from "node:test"; +import { changeLevel } from "../plugins/dx-workflow/scripts/lib/level.mjs"; +import { loadConfig } from "../plugins/dx-workflow/scripts/lib/verify-config.mjs"; +import { addFeature, CONFIG, cleanup, evidenceText, gate, makeProject, node, read, tierOf, verify, write } from "./helpers.mjs"; + +const DEFAULTS = { lanes: CONFIG.lanes }; // no lightMaxLines override: the real defaults +const roots = []; +const project = (config = DEFAULTS, files = {}) => { + const r = makeProject({ config, files }); + roots.push(r); + return r; +}; +after(() => roots.forEach(cleanup)); +const level = (root) => changeLevel(loadConfig(root)); + +describe("change level", () => { + it("light for a small change with nothing risky", () => { + const root = project(); + addFeature(root); + const l = level(root); + assert.equal(l.level, "light", l.reasons.join("; ")); + assert.ok(l.lines > 0 && l.lines <= 40); + }); + + it("standard when it grows past the light limits", () => { + const root = project(); + write(root, { "src/big.mjs": Array.from({ length: 60 }, (_, i) => `export const v${i} = ${i};`).join("\n") + "\n" }); + assert.equal(level(root).level, "standard"); + assert.match(level(root).reasons.join(), /60 changed lines/); + }); + + it("strict for a one-line change to a risky path or risky code, with no config", () => { + let root = project(); + write(root, { "src/auth/token.mjs": "export const ttl = 60;\n" }); + assert.equal(level(root).level, "strict"); + assert.match(level(root).reasons.join(), /risky path: src\/auth\/token\.mjs/); + + root = project(); + write(root, { "src/math.mjs": read(root, "src/math.mjs") + "export const pay = (s) => s.stripe.charges.create();\n" }); + assert.equal(level(root).level, "strict"); + assert.match(level(root).reasons.join(), /payments in src\/math\.mjs/); + }); + + it("strict for configured sensitive paths; heuristics can be switched off", () => { + let root = project({ lanes: { backend: { ...CONFIG.lanes.backend, sensitive: ["src/math.mjs"] } } }); + addFeature(root); + assert.equal(level(root).level, "strict"); + root = project({ risk: { heuristics: false }, lanes: CONFIG.lanes }); + write(root, { "src/auth/token.mjs": "export const ttl = 60;\n" }); + assert.equal(level(root).level, "light"); + }); + + it("level.mjs prints the level and what it needs", () => { + const root = project(); + write(root, { "src/billing/plan.mjs": "export const plan = 1;\n" }); + const r = node("level.mjs", [], { cwd: root }); + assert.match(r.stdout, /^level: strict/); + assert.match(r.stdout, /owner approves/); + }); +}); + +describe("light changes", () => { + it("end the turn once the checks pass: no acceptance, no review, no evidence pack", () => { + const root = project(); + addFeature(root); + const d = gate(root); + assert.equal(d.decision, "block"); + assert.match(d.reason, /level light/); + assert.match(d.reason, /A light change needs only its checks/); + assert.doesNotMatch(d.reason, /acceptance|review|evidence/i); + assert.equal(node("run-verify.mjs", [], { cwd: root }).code, 0); + assert.equal(gate(root), null); + }); + + it("are merge tier 1 in the evidence pack without a review", () => { + const root = project(); + addFeature(root); + node("run-verify.mjs", [], { cwd: root }); + node("make-evidence.mjs", [], { cwd: root }); + assert.equal(tierOf(root), "1"); + assert.match(evidenceText(root), /Light change \(\d+ line\(s\), nothing risky\)/); + assert.match(evidenceText(root), /^Level: light$/m); + }); +}); + +describe("standard and strict changes", () => { + it("get their evidence pack from the gate when it is the only thing missing", () => { + const root = makeProject(); + roots.push(root); + addFeature(root); + verify(root); + const last = JSON.parse(read(root, ".verify/last-run.json")); + node("run-verify.mjs", [], { cwd: root }); // a new run: new run folder, no pack yet + const run2 = JSON.parse(read(root, ".verify/last-run.json")).runDir; + assert.notEqual(run2, last.runDir); + assert.equal(existsSync(join(run2, "evidence.md")), false); + assert.equal(gate(root), null, "the gate wrote the pack and let the turn end"); + assert.ok(existsSync(join(run2, "evidence.md"))); + }); + + it("strict needs a deep review, and is merge tier 3", () => { + const root = project(); + write(root, { "src/auth/token.mjs": "export const ttl = 60;\n" }); + addFeature(root); + verify(root); + assert.match(gate(root).reason, /the change is strict .* its review must be deep/); + write(root, { ".verify/review-backend.md": read(root, ".verify/review-backend.md").replace("Reviewer: test", "Reviewer: test\nDepth: deep") }); + node("make-evidence.mjs", [], { cwd: root }); + assert.equal(gate(root), null); + assert.equal(tierOf(root), "3"); + assert.match(evidenceText(root), /a risky change \(risky path: src\/auth\/token\.mjs/); + }); +}); diff --git a/test/mobile.test.mjs b/test/mobile.test.mjs index 4f48d45..ecdfa2e 100644 --- a/test/mobile.test.mjs +++ b/test/mobile.test.mjs @@ -253,6 +253,6 @@ describe("react-native lanes", () => { const r = node("review-brief.mjs", ["--lane", "app", "--request", "rename"], { cwd: root }); assert.equal(r.code, 0, r.stderr); assert.match(r.stdout, /## Depth: deep \(native \(needs a store build\): app\.json\)/); - assert.match(r.stdout, /frontend\/design-review\.md for the screenshots/); + assert.match(r.stdout, /## Reviews: code\n/, "app.json is not visual: no screenshot review"); }); }); diff --git a/test/review-brief.test.mjs b/test/review-brief.test.mjs index f2ba8ec..65ca9e8 100644 --- a/test/review-brief.test.mjs +++ b/test/review-brief.test.mjs @@ -74,17 +74,34 @@ describe("review-brief", () => { assert.ok(existsSync(join(root, ".verify/brief-backend.md"))); }); - it("gives a frontend lane both the design review and the frontend code review", () => { - const root = project({ config: { lanes: { web: { kind: "frontend", files: ["src/**", "test/**"], checks: [{ name: "unit", run: "node test/run.mjs" }] } } } }); + it("gives a frontend lane the screenshot review only when something visual changed", () => { + const root = project({ config: { risk: { lightMaxLines: 0 }, lanes: { web: { kind: "frontend", files: ["src/**", "test/**"], checks: [{ name: "unit", run: "node test/run.mjs" }] } } } }); addFeature(root); node("run-verify.mjs", [], { cwd: root }); - const r = node("review-brief.mjs", ["--lane", "web", "--request", "add sub", "--scope", "home at 390"], { cwd: root }); + let r = node("review-brief.mjs", ["--lane", "web", "--request", "add sub"], { cwd: root }); assert.equal(r.code, 0, r.stderr); + assert.match(r.stdout, /## Reviews: code\n/); + assert.match(r.stdout, /frontend\/code-review\.md \(nothing visual changed: no screenshot review\)/); + + write(root, { "src/Total.tsx": 'export const Total = ({ n }) => {n};\n' }); + node("run-verify.mjs", [], { cwd: root }); + r = node("review-brief.mjs", ["--lane", "web", "--request", "add sub", "--scope", "home at 390"], { cwd: root }); + assert.match(r.stdout, /## Reviews: code, UI \(screenshots\)/); assert.match(r.stdout, /skills\/frontend\/design-review\.md for the screenshots, then .*skills\/frontend\/code-review\.md for the code/); assert.match(r.stdout, /docs\/design\.md/); assert.match(r.stdout, /Scope: home at 390/); }); + it("adds a security review for a risky change, found without any config", () => { + const root = project(); + write(root, { "src/session.mjs": "import jwt from 'jsonwebtoken';\nexport const verify = (t) => jwt.verify(t, process.env.KEY);\n" }); + node("run-verify.mjs", [], { cwd: root }); + const r = brief(root); + assert.match(r.stdout, /## Reviews: code, security/); + assert.match(r.stdout, /## Depth: deep \(.*risky path: src\/session\.mjs/); + assert.match(r.stdout, /Write "Depth: deep" under the title/); + }); + it("goes deep on sensitive paths and asks to disprove Blockers", () => { const root = project({ config: { ...CONFIG, lanes: { backend: { ...CONFIG.lanes.backend, sensitive: ["src/math.mjs"] } } } }); addFeature(root); @@ -102,15 +119,15 @@ describe("review-brief", () => { assert.match(brief(root).stdout, /new files not yet in git.*src\/extra\.mjs/); }); - it("gives round 2 the previous findings and only the new diff, and stops after three rounds", () => { + it("gives round 2 the previous findings and only the new diff, and stops after two rounds", () => { const root = project(); addFeature(root); - for (let round = 1; round <= 3; round++) { + for (let round = 1; round <= 2; round++) { write(root, { "src/math.mjs": read(root, "src/math.mjs") + `// round ${round}\n` }); node("run-verify.mjs", [], { cwd: root }); const r = brief(root); assert.equal(r.code, 0, `round ${round}: ${r.stderr}`); - assert.match(r.stdout, new RegExp(`round ${round} of at most 3`)); + assert.match(r.stdout, new RegExp(`round ${round} of at most 2`)); if (round === 2) { assert.match(r.stdout, /## Round 2: what changed since round 1/); assert.match(r.stdout, /git diff [0-9a-f]{40} [0-9a-f]{40}/); @@ -119,11 +136,11 @@ describe("review-brief", () => { const last = JSON.parse(read(root, ".verify/last-run.json")); write(root, { ".verify/review-backend.md": `# Review\nTree: ${last.lanes.backend.tree}\n\n## Findings\n- [ ] Blocker · src/math.mjs:1 · wrong\n\nVerdict: changes required\n` }); } - write(root, { "src/math.mjs": read(root, "src/math.mjs") + "// round 4\n" }); + write(root, { "src/math.mjs": read(root, "src/math.mjs") + "// round 3\n" }); node("run-verify.mjs", [], { cwd: root }); const r4 = brief(root); assert.equal(r4.code, 3); - assert.match(r4.stderr, /3 review rounds of lane backend ended without approval/); + assert.match(r4.stderr, /2 review rounds of lane backend ended without approval/); }); it("restarts the round count for a new change (new acceptance)", () => { diff --git a/vendor.lock.json b/vendor.lock.json index 9868f3d..818f7ec 100644 --- a/vendor.lock.json +++ b/vendor.lock.json @@ -43,12 +43,12 @@ "skills": [ "grilling", "grill-with-docs", - "domain-modeling", + "codebase-design", + "improve-codebase-architecture", "to-tickets", "tdd", "diagnosing-bugs", - "improve-codebase-architecture", - "codebase-design", + "code-review", "retro" ] }, @@ -73,29 +73,6 @@ "finishing-a-development-branch", "using-superpowers" ] - }, - "agent-skills": { - "repo": "https://github.com/addyosmani/agent-skills", - "commit": "39b723ceebf81474d0557c1fecd01eddab585563", - "version": "0.6.16", - "license": "MIT, Copyright (c) 2025 Addy Osmani", - "install": "/plugin marketplace add addyosmani/agent-skills && /plugin install agent-skills@addy-agent-skills", - "skills": [ - "interview-me", - "spec-driven-development", - "planning-and-task-breakdown", - "test-driven-development", - "debugging-and-error-recovery", - "browser-testing-with-devtools", - "code-simplification", - "security-and-hardening", - "performance-optimization" - ], - "overridden": [ - "code-review-and-quality", - "shipping-and-launch", - "using-agent-skills" - ] } }, "adapted": {