claude-everything-workflow 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude-plugin/hooks.json +1 -6
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/AGENTS.md +1 -1
  5. package/README.md +10 -6
  6. package/README.zh-CN.md +11 -7
  7. package/bin/claude-everything-workflow.js +16 -4
  8. package/commands/code-review.md +4 -4
  9. package/docs/plugins.md +21 -2
  10. package/evals/routing-scenarios.json +11 -2
  11. package/hooks/check-code-size.js +4 -126
  12. package/hooks/check-console-log.js +4 -79
  13. package/hooks/check-edited-file.js +139 -0
  14. package/hooks/commit-quality.js +1029 -72
  15. package/hooks/runtime/antigravity-pre-tool.js +116 -0
  16. package/package.json +4 -2
  17. package/rules/02-implementation.md +1 -1
  18. package/rules/common/hooks.md +2 -2
  19. package/scripts/cleanup-retired-skills.js +36 -3
  20. package/scripts/eval-scenarios.js +46 -14
  21. package/scripts/install-antigravity.js +545 -0
  22. package/scripts/install-rules.js +145 -49
  23. package/scripts/install.ps1 +76 -8
  24. package/scripts/install.sh +74 -21
  25. package/scripts/merge-claude-settings.cjs +14 -2
  26. package/scripts/retired-skill-files.json +12 -0
  27. package/scripts/verify/commit-quality.test.js +481 -0
  28. package/scripts/verify/install-rules.test.js +499 -10
  29. package/scripts/verify/metadata-checks.js +27 -1
  30. package/scripts/verify/runtime-checks.js +57 -2
  31. package/scripts/verify/scenario-checks.test.js +39 -10
  32. package/scripts/verify/workflow-checks.js +5 -1
  33. package/settings.json +1 -6
  34. package/skills/README.md +1 -1
  35. package/skills/code-review/SKILL.md +15 -21
  36. package/skills/implement/SKILL.md +2 -2
  37. package/skills/systematic-debugging/SKILL.md +7 -4
  38. package/skills/systematic-debugging/references/diagnostic-scenarios.md +7 -0
  39. package/agents/harness-optimizer.md +0 -93
@@ -6,12 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/runtime/run-with-flags.js\" post:edit:console-log hooks/check-console-log.js standard,strict",
10
- "timeout": 5
11
- },
12
- {
13
- "type": "command",
14
- "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/runtime/run-with-flags.js\" post:edit:code-size hooks/check-code-size.js standard,strict",
9
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/runtime/run-with-flags.js\" post:edit:quality hooks/check-edited-file.js standard,strict",
15
10
  "timeout": 5
16
11
  }
17
12
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-everything-workflow",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Evidence-based engineering workflows: implement, debug, review and verify.",
5
5
  "author": { "name": "xu91102" },
6
6
  "homepage": "https://github.com/xu91102/claude-everything-Workflow",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-everything-workflow",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Evidence-based engineering workflows: implement, debug, review and verify.",
5
5
  "author": { "name": "xu91102" },
6
6
  "homepage": "https://github.com/xu91102/claude-everything-Workflow",
package/AGENTS.md CHANGED
@@ -18,7 +18,7 @@
18
18
  ## 规则加载策略
19
19
 
20
20
  - 规则按需读取,不要默认全量加载 `rules/` 或 `rules/common/`。
21
- - `rules/...` 先查项目根 `rules/`;不存在时,Codex 回退 `~/.codex/rules/`,Claude Code 顶层规则回退 `~/.claude/rules/`,专项 `rules/common/...` 回退 `~/.claude/references/rules/common/...`。升级时保留的个人修改优先于同名分发参考。
21
+ - `rules/...` 先查项目根 `rules/`;不存在时,Antigravity(Gemini)回退 `~/.gemini/config/plugins/claude-everything-workflow/references/rules/`,Codex 回退 `~/.codex/rules/`,Claude Code 顶层规则回退 `~/.claude/rules/`,专项 `rules/common/...` 回退 `~/.claude/references/rules/common/...`。升级时保留的个人修改优先于同名分发参考。
22
22
 
23
23
  ## 规则索引
24
24
 
package/README.md CHANGED
@@ -30,24 +30,25 @@ CEW works with your existing projects and model. It does not provide a model or
30
30
 
31
31
  ### Requirements
32
32
 
33
- - Claude Code and/or Codex, already installed and configured.
33
+ - Claude Code, Codex, and/or Antigravity, already installed and configured.
34
34
  - Node.js **18+** and npm/npx.
35
- - macOS/Linux: Bash and `rsync`. Windows: PowerShell; Git Bash/WSL can use the shell installer if Bash and `rsync` are available.
35
+ - macOS/Linux: Bash and `rsync` (`rsync` is required for Claude Code / Codex installs). Windows: PowerShell; Git Bash/WSL can use the shell installer if Bash and `rsync` are available.
36
36
 
37
37
  ### Install from npm
38
38
 
39
- Preview the changes, then install to both hosts:
39
+ Preview the changes, then install (Claude Code + Codex, and auto-syncs Antigravity if `~/.gemini` already exists):
40
40
 
41
41
  ```sh
42
42
  npx claude-everything-workflow install --dry-run
43
43
  npx claude-everything-workflow install
44
44
  ```
45
45
 
46
- To install for only one host:
46
+ To install for only one host (use `--antigravity-only` when installing Antigravity on a machine without `~/.gemini`):
47
47
 
48
48
  ```sh
49
49
  npx claude-everything-workflow install --claude-only
50
50
  npx claude-everything-workflow install --codex-only
51
+ npx claude-everything-workflow install --antigravity-only
51
52
  ```
52
53
 
53
54
  ### Install from source
@@ -60,7 +61,7 @@ node bin/claude-everything-workflow.js install --dry-run
60
61
  node bin/claude-everything-workflow.js install
61
62
  ```
62
63
 
63
- The CLI selects the shell or PowerShell installer for your platform. The same `--claude-only` and `--codex-only` options apply. The npm command uses the published package; the source command uses your checkout.
64
+ The CLI selects the shell or PowerShell installer for your platform. The same `--claude-only`, `--codex-only`, and `--antigravity-only` options apply. The npm command uses the published package; the source command uses your checkout.
64
65
 
65
66
  ### What changes on your machine
66
67
 
@@ -68,10 +69,13 @@ The CLI selects the shell or PowerShell installer for your platform. The same `-
68
69
  | --- | --- | --- |
69
70
  | Claude Code | `~/.claude/` | Shared workflow files, `CLAUDE.md` bootstrap, rules, and merged hook settings. |
70
71
  | Codex | `~/.codex/` | Shared workflow files and `AGENTS.md`; Claude Code hooks are not automatically enabled. |
72
+ | Antigravity (Gemini) | `~/.gemini/config/plugins/claude-everything-workflow/` | Native plugin (`plugin.json`, `hooks.json` & `hooks/`, `rules/AGENTS.md`, on-demand `references/rules/`, converted `skills/` and `agents/`, `scripts/learning/`). |
71
73
 
72
74
  Installation updates user-level files and can affect multiple projects. Changed top-level configuration files are backed up; matching files inside shared directories are synchronized from the repository. Unknown files are generally retained, while known retired files are removed by an explicit cleanup list. Back up any personal edits to shared files before upgrading. Use the installer instead of copying the entire `rules/` directory: it handles the different rule locations used by each host.
73
75
 
74
- The Codex installer preserves edits to `~/.codex/rules/02-implementation.md`. On the first upgrade it records the packaged rule as a baseline. Later upgrades use Git to merge independent changes. If a merge conflicts or Git is unavailable, the personal rule stays active and the installer prints the incoming copy’s location and manual merge instructions.
76
+ The Codex installer preserves edits to `~/.codex/rules/02-implementation.md`, and the Antigravity installer uses the same three-way Git merge mechanism for `~/.gemini/config/plugins/claude-everything-workflow/references/rules/02-implementation.md`. On the first upgrade it records the packaged rule as a baseline. Later upgrades use Git to merge independent changes. If a merge conflicts or Git is unavailable, the personal rule stays active and the installer prints the incoming copy’s location and manual merge instructions.
77
+
78
+ For Antigravity, only `rules/AGENTS.md` stays in the auto-loaded plugin `rules/` folder while all detailed rules live under `references/rules/` for on-demand loading. Default `install` syncs Antigravity only when a non-symlink `~/.gemini` directory already exists; pass `--antigravity-only` to install it explicitly. If a legacy `~/.gemini/AGENTS.md` exists, the installer leaves it untouched and prints a notice so you can review or remove it manually.
75
79
 
76
80
  A fresh Claude Code installation puts CEW’s base, Git and security rules in `~/.claude/rules/`. Other CEW rules are available on demand under `~/.claude/references/rules/`. On upgrade, personally edited copies of the three newly migrated rules stay active. Obsolete rules left by older releases can also still load.
77
81
 
package/README.zh-CN.md CHANGED
@@ -30,24 +30,25 @@ CEW 使用你已有的项目和模型,不提供模型,也不替代 Claude Co
30
30
 
31
31
  ### 环境要求
32
32
 
33
- - 已安装并配置 Claude Code 和/或 Codex。
33
+ - 已安装并配置 Claude Code、Codex 和/或 Antigravity。
34
34
  - Node.js **18+**,以及 npm/npx。
35
- - macOS/Linux:Bash 和 `rsync`。Windows:PowerShell;Git Bash/WSL 配有 Bash 和 `rsync` 时也可使用 shell 安装器。
35
+ - macOS/Linux:Bash 和 `rsync`(安装 Claude Code / Codex 时需要 `rsync`)。Windows:PowerShell;Git Bash/WSL 配有 Bash 和 `rsync` 时也可使用 shell 安装器。
36
36
 
37
37
  ### 从 npm 安装
38
38
 
39
- 先预览,再安装到两个宿主:
39
+ 先预览,再执行安装(默认安装 Claude Code 和 Codex;若本机已存在非软链 `~/.gemini` 会一并自动同步 Antigravity):
40
40
 
41
41
  ```sh
42
42
  npx claude-everything-workflow install --dry-run
43
43
  npx claude-everything-workflow install
44
44
  ```
45
45
 
46
- 只安装到其中一个:
46
+ 只安装到其中一个(若本机尚未有 `~/.gemini`,请使用 `--antigravity-only` 显式安装):
47
47
 
48
48
  ```sh
49
49
  npx claude-everything-workflow install --claude-only
50
50
  npx claude-everything-workflow install --codex-only
51
+ npx claude-everything-workflow install --antigravity-only
51
52
  ```
52
53
 
53
54
  ### 从源码安装
@@ -60,7 +61,7 @@ node bin/claude-everything-workflow.js install --dry-run
60
61
  node bin/claude-everything-workflow.js install
61
62
  ```
62
63
 
63
- 命令行入口会按系统选择 shell 或 PowerShell 安装器,同样支持 `--claude-only` 和 `--codex-only`。npm 命令安装已发布版本;源码命令安装当前 checkout 中的内容。
64
+ 命令行入口会按系统选择 shell 或 PowerShell 安装器,同样支持 `--claude-only`、`--codex-only` 和 `--antigravity-only`。npm 命令安装已发布版本;源码命令安装当前 checkout 中的内容。
64
65
 
65
66
  ### 安装会修改什么
66
67
 
@@ -68,10 +69,13 @@ node bin/claude-everything-workflow.js install
68
69
  | --- | --- | --- |
69
70
  | Claude Code | `~/.claude/` | 共享工作流文件、`CLAUDE.md` 入口、规则,以及合并后的 hooks 配置。 |
70
71
  | Codex | `~/.codex/` | 共享工作流文件和 `AGENTS.md`;不会自动启用 Claude Code hooks。 |
72
+ | Antigravity (Gemini) | `~/.gemini/config/plugins/claude-everything-workflow/` | 原生插件(`plugin.json`、`hooks.json` 与 `hooks/`、`rules/AGENTS.md`、按需加载的 `references/rules/`、转换后的 `skills/` 与 `agents/`、`scripts/learning/`)。 |
71
73
 
72
- 安装修改的是用户级目录,可能影响多个项目。顶层配置内容不同时会先备份;共享目录中的同名文件按仓库版本同步。未知文件通常保留,已登记的退役文件按明确清单清理。升级前请备份对共享文件的个人修改。不要直接复制整个 `rules/` 目录,安装器会处理两个宿主不同的规则加载位置。
74
+ 安装修改的是用户级目录,可能影响多个项目。顶层配置内容不同时会先备份;共享目录中的同名文件按仓库版本同步。未知文件通常保留,已登记的退役文件按明确清单清理。升级前请备份对共享文件的个人修改。不要直接复制整个 `rules/` 目录,安装器会处理不同宿主各自的规则加载位置。
73
75
 
74
- Codex 安装器会保留 `~/.codex/rules/02-implementation.md` 中的个人修改。首次升级会记录本次分发的规则,供后续版本比较。此后上游规则变化时,安装器用 Git 自动合并互不冲突的改动。遇到冲突或 Git 不可用时,个人规则继续生效,安装日志会给出新版规则副本和手动合并方法。
76
+ Codex 安装器会保留 `~/.codex/rules/02-implementation.md` 中的个人修改;Antigravity 安装器也对 `~/.gemini/config/plugins/claude-everything-workflow/references/rules/02-implementation.md` 采用相同的 Git 三方合并机制。首次升级会记录本次分发的规则,供后续版本比较。此后上游规则变化时,安装器用 Git 自动合并互不冲突的改动。遇到冲突或 Git 不可用时,个人规则继续生效,安装日志会给出新版规则副本和手动合并方法。
77
+
78
+ Antigravity 插件只把入口 `rules/AGENTS.md` 放入自动加载目录 `rules/`,其余详细规则放在 `references/rules/` 按需读取。默认 `install` 仅在存在非符号链接的 `~/.gemini` 目录时自动同步 Antigravity,不存在则跳过;需要首次显式安装时使用 `--antigravity-only`。若存在旧版 `~/.gemini/AGENTS.md`,安装器不会擅自删除,只打印提示供你手动备份或移除。
75
79
 
76
80
  全新安装时,CEW 将执行原则、Git 和安全规则放入 Claude Code 自动读取的 `~/.claude/rules/`,其余规则从 `~/.claude/references/rules/` 按需读取。升级时,本次迁移的三份规则如有个人修改,仍在原处生效。更早版本遗留的退役规则也可能继续加载。
77
81
 
@@ -30,14 +30,24 @@ function main() {
30
30
  }
31
31
 
32
32
  function runInstall(args) {
33
- const supported = new Set(["--claude-only", "--codex-only", "--dry-run", "--help", "-h"]);
33
+ const supported = new Set([
34
+ "--claude-only",
35
+ "--codex-only",
36
+ "--antigravity-only",
37
+ "--dry-run",
38
+ "--help",
39
+ "-h",
40
+ ]);
34
41
  const unknown = args.find((arg) => !supported.has(arg));
35
42
  if (unknown) {
36
43
  process.stderr.write(`Unknown option: ${unknown}\n`);
37
44
  process.exit(1);
38
45
  }
39
- if (args.includes("--claude-only") && args.includes("--codex-only")) {
40
- process.stderr.write("--claude-only and --codex-only cannot be used together\n");
46
+ const onlyFlags = ["--claude-only", "--codex-only", "--antigravity-only"].filter(
47
+ (flag) => args.includes(flag),
48
+ );
49
+ if (onlyFlags.length > 1) {
50
+ process.stderr.write(`${onlyFlags.join(" and ")} cannot be used together\n`);
41
51
  process.exit(1);
42
52
  }
43
53
  if (args.includes("--help") || args.includes("-h")) {
@@ -84,6 +94,7 @@ function toPowerShellArgs(args) {
84
94
  return args.map((arg) => {
85
95
  if (arg === "--claude-only") return "-ClaudeOnly";
86
96
  if (arg === "--codex-only") return "-CodexOnly";
97
+ if (arg === "--antigravity-only") return "-AntigravityOnly";
87
98
  if (arg === "--dry-run") return "-DryRun";
88
99
  return arg;
89
100
  });
@@ -93,12 +104,13 @@ function printHelp() {
93
104
  process.stdout.write(`claude-everything-workflow
94
105
 
95
106
  Usage:
96
- cew install [--claude-only|--codex-only] [--dry-run]
107
+ cew install [--claude-only|--codex-only|--antigravity-only] [--dry-run]
97
108
  cew verify
98
109
 
99
110
  Examples:
100
111
  npx claude-everything-workflow install
101
112
  npx claude-everything-workflow install --codex-only
113
+ npx claude-everything-workflow install --antigravity-only
102
114
  npx claude-everything-workflow verify
103
115
  `);
104
116
  }
@@ -1,13 +1,13 @@
1
1
  ---
2
- description: 基于固定基点和已确认范围,按风险选择自审、独立或双轴审查
2
+ description: 基于固定基点和已确认范围,按风险选择独立或双轴子代理审查
3
3
  ---
4
4
 
5
5
  # /code-review - 代码审查
6
6
 
7
- 读取 `skills/code-review/SKILL.md`,由它决定审查深度、上下文隔离和降级边界;不在命令中重写流程。
7
+ 读取 `skills/code-review/SKILL.md`,由它决定审查深度、上下文隔离和阻塞边界;不在命令中重写流程。
8
8
 
9
9
  ```text
10
- /code-review <base> [--spec <path>] [--mode auto|self|independent|dual]
10
+ /code-review <base> [--spec <path>] [--mode auto|independent|dual]
11
11
  /code-review --worktree <base> --spec <path>
12
12
  /code-review --staged
13
13
  ```
@@ -16,7 +16,7 @@ description: 基于固定基点和已确认范围,按风险选择自审、独
16
16
  - 分支包用 `git diff <base>...HEAD`;混合工作区用 `git diff <base>`,并加入任务所属 untracked 文件。
17
17
  - `--staged` 使用 `git diff --cached`;不代表整个分支。
18
18
  - `--spec <path>` 或调用方的范围合同都是有效需求来源;已有信息不重复询问。
19
- - 默认由 Skill 按风险和验证证据选择;满足条件的简单任务可自审,双轴可并行或顺序隔离运行。模式参数不能降低必要审查,代理不可用也不能作为自审兜底。
19
+ - 默认由 Skill 按风险选择独立单代理(`independent`)或双轴隔离代理(`dual`,可并行或顺序运行);不提供自审模式,模式参数不能降低必要审查,代理不可用时直接 `BLOCKED`,不得降级。
20
20
  - Standards 与 Spec 轴分别报告;缺少需求证据时说明 `NOT RUN`,不根据 diff 编造需求。
21
21
 
22
22
  `$ARGUMENTS`
package/docs/plugins.md CHANGED
@@ -55,6 +55,25 @@ codex plugin add claude-everything-workflow@cew
55
55
 
56
56
  CLI 命令以宿主版本为准;缺少 `plugin` 子命令时使用支持插件的应用版本或继续使用 npm 安装。
57
57
 
58
+ ## Antigravity (Gemini)
59
+
60
+ Antigravity 支持原生用户级插件(`~/.gemini/config/plugins/claude-everything-workflow/`)。可直接通过 npm 一键安装并在后续像 Codex 一样同步升级:
61
+
62
+ ```sh
63
+ npx claude-everything-workflow install --antigravity-only
64
+ ```
65
+
66
+ 或者运行 `npx claude-everything-workflow install`(当本机已存在非符号链接的 `~/.gemini` 时会自动同步 Antigravity;未存在时跳过,可随时用 `--antigravity-only` 显式安装)。安装器会自动生成或同步:
67
+
68
+ - `plugin.json`:原生插件清单(版本与 `package.json` 保持一致)。
69
+ - `hooks.json` & `hooks/`:注册 Antigravity 原生 `PreToolUse`(`run_command`)提交密钥与质量拦截钩子,沿用 `ECC_HOOK_PROFILE`、`ECC_DISABLED_HOOKS` 控制;不自动启用 Claude Code 专用编辑/观察 hooks。
70
+ - `rules/AGENTS.md`:唯一的常驻入口规则,指引按需读取 `references/rules/` 下的基础规则与 `common/` 专项规则。
71
+ - `skills/`:同步全部工作流技能,并把非重复命令(`pr`、`verify`、`to-spec`、`learn`)转换为原生技能,同时把内部 `commands/` 引用改写为插件内技能路径;自动清理已退役技能。
72
+ - `agents/`:转换工具名称与插件内引用路径为 Antigravity 原生子代理格式。
73
+ - `references/rules/02-implementation.md`:采用与 Codex 相同的 Git 三方合并机制,升级时保留个人修改。
74
+
75
+ 若本机存在旧版 `~/.gemini/AGENTS.md`,安装器不会自动删除,仅在输出中提示手动确认。
76
+
58
77
  ### 浏览器验证 MCP
59
78
 
60
79
  Claude 插件根目录的 `.mcp.json` 会注册 `chrome-devtools` MCP,启用插件后无需手动配置。前置条件、手动添加命令和复用已登录 Chrome 的说明见 README 的“浏览器验证(可选)”。
@@ -63,13 +82,13 @@ Claude 插件根目录的 `.mcp.json` 会注册 `chrome-devtools` MCP,启用
63
82
 
64
83
  | 项目 | 插件安装 | npm 安装 |
65
84
  | --- | --- | --- |
66
- | 文件位置 | 宿主管理的插件目录或缓存 | `~/.claude/`、`~/.codex/` |
85
+ | 文件位置 | 宿主管理的插件目录或缓存 | `~/.claude/`、`~/.codex/`、`~/.gemini/config/plugins/claude-everything-workflow/` |
67
86
  | 全局入口配置 | 不覆盖已有入口和设置 | 安装器备份并同步入口,Claude hooks 合并进设置 |
68
87
  | 工作流 | 宿主发现插件技能,保留原有规则查找方式 | 从用户级目录按需加载 |
69
88
  | Claude hooks | 插件生命周期内启用基础检查 | 原有安装器配置 |
70
89
  | 停用 | 用宿主插件管理功能禁用或卸载 | 按原有全局配置管理 |
71
90
 
72
- 插件不会自动加载随包的 `AGENTS.md` 或注册 `rules/`,也不提供额外的资源路径适配;这些文件被打包不等于其规则已生效。需要全局入口和规则安装时使用 npm 安装器。只使用插件时,跨文件工作流仍需目标项目或用户已有配置提供可解析的规则及参考路径,不能视为与 npm 安装完全等价。
91
+ Claude Code / Codex 市场插件不会自动加载随包的 `AGENTS.md` 或注册 `rules/`,也不提供额外的资源路径适配;这些文件被打包不等于其规则已生效。Antigravity 通过 npm 安装器生成的原生插件会将 `rules/AGENTS.md` 放入插件入口并把详细规则放到 `references/rules/` 按需加载。仅使用 Claude / Codex 市场插件时,跨文件工作流仍需目标项目或用户已有配置提供可解析的规则及参考路径,不能视为与 npm 安装完全等价。
73
92
 
74
93
  同一宿主建议选一种方式,避免同名技能和 Claude hooks 重复。已有 npm 安装不会被插件自动迁移或删除;学习系统仍需显式配置。脚本声明的可选外部工具和依赖也不会因安装插件自动安装。基础检查脚本需要 Node.js 18+;运行仓库校验器需要安装 package.json 中的依赖。
75
94
 
@@ -23,11 +23,11 @@
23
23
  {
24
24
  "id": "direct-small-change",
25
25
  "category": "delivery",
26
- "prompt": "给 parseConfig 加一个默认值 fallback,并补一个单元测试",
26
+ "prompt": "给 parseConfig 加一个默认值 fallback",
27
27
  "expectedTarget": "skills/implement/SKILL.md",
28
28
  "expectedLane": "direct",
29
29
  "requiredSignals": ["direct-scope", "implement"],
30
- "rationale": "明确、低风险的单次交付请求直接走 direct 通道与 implement。"
30
+ "rationale": "明确、低风险的单次交付请求直接走 direct 通道与 implement;测试补写由 implement 内部的 TDD 步骤承接,不单独路由。"
31
31
  },
32
32
  {
33
33
  "id": "workflow-advice",
@@ -121,6 +121,15 @@
121
121
  "requiredSignals": ["flaky", "根因"],
122
122
  "rationale": "先定位间歇性超时的根因。根因确认后,需要维护或稳定浏览器测试时再使用验收 Skill 的 E2E 参考。"
123
123
  },
124
+ {
125
+ "id": "debugging-third-round-recurrence",
126
+ "category": "debugging",
127
+ "prompt": "这个导入路径问题前两轮修复单测都过了,第三轮复审又在重试队列复现,帮我重查原因",
128
+ "expectedTarget": "skills/systematic-debugging/SKILL.md",
129
+ "expectedLane": "debugging",
130
+ "requiredSignals": ["复发", "证据闭环"],
131
+ "rationale": "同类问题在多轮修复或复审中复发应进入 systematic-debugging 证据闭环,重新检验共同假设而不是继续追加局部补丁。"
132
+ },
124
133
  {
125
134
  "id": "grilling-ambiguous-decision",
126
135
  "category": "decision",
@@ -1,132 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Check Code Size Hook
4
- *
5
- * 编辑后只检查本次改动的代码文件:文件行数上限与单行长度。
6
- * 正常静默,避免增加上下文噪音。对应 rules/02-implementation.md。
3
+ * Check Code Size Hook(兼容入口,实现已并入 hooks/check-edited-file.js)
7
4
  */
8
-
9
5
  'use strict'
10
6
 
11
- const fs = require('fs')
12
-
13
- const CODE_TARGET_LINES = 800
14
- const TEST_MAX_LINES = 1000
15
- const MAX_LINE_LENGTH = 120
16
- const CODE_EXTENSIONS = new Set([
17
- '.c',
18
- '.cc',
19
- '.cpp',
20
- '.cs',
21
- '.css',
22
- '.go',
23
- '.h',
24
- '.hpp',
25
- '.html',
26
- '.java',
27
- '.js',
28
- '.jsx',
29
- '.kt',
30
- '.lua',
31
- '.mjs',
32
- '.php',
33
- '.py',
34
- '.rb',
35
- '.rs',
36
- '.sh',
37
- '.swift',
38
- '.ts',
39
- '.tsx',
40
- '.vue'
41
- ])
42
-
43
- function getExtension(filePath) {
44
- const match = filePath.match(/(\.[^.\\/]+)$/)
45
- return match ? match[1].toLowerCase() : ''
46
- }
47
-
48
- function isCodeFile(filePath) {
49
- return CODE_EXTENSIONS.has(getExtension(filePath))
50
- }
51
-
52
- function isTestFile(filePath) {
53
- return /(^|[\\/])__tests__([\\/]|$)/.test(filePath) ||
54
- /\.(test|spec)\.[^.\\/]+$/.test(filePath)
55
- }
56
-
57
- function getLineThreshold(filePath) {
58
- return isTestFile(filePath) ? TEST_MAX_LINES : CODE_TARGET_LINES
59
- }
60
-
61
- function countLines(content) {
62
- if (content.length === 0) return 0
63
- const lines = content.split(/\r?\n/)
64
- return content.endsWith('\n') ? lines.length - 1 : lines.length
65
- }
66
-
67
- function run(raw) {
68
- let input
69
- try {
70
- input = JSON.parse(raw)
71
- } catch {
72
- return { exitCode: 0 }
73
- }
74
-
75
- const filePath = input.tool_input?.file_path
76
- if (!filePath || !isCodeFile(filePath) || !fs.existsSync(filePath)) {
77
- return { exitCode: 0 }
78
- }
79
-
80
- let content
81
- try {
82
- content = fs.readFileSync(filePath, 'utf8')
83
- } catch {
84
- return { exitCode: 0 }
85
- }
86
-
87
- const testFile = isTestFile(filePath)
88
- const lineThreshold = getLineThreshold(filePath)
89
- const lineCount = countLines(content)
90
-
91
- const messages = []
92
- if (lineCount > lineThreshold) {
93
- messages.push(
94
- testFile
95
- ? `测试文件超过 ${lineThreshold} 行上限 (${lineCount} 行),请拆分测试场景。`
96
- : `代码文件超过约 ${lineThreshold} 行的参考值 (${lineCount} 行),请评估是否按职责拆分。`
97
- )
98
- }
99
-
100
- // 最多提示前 3 处超长行
101
- const longLineNumbers = []
102
- content.split(/\r?\n/).forEach((line, index) => {
103
- if (line.length > MAX_LINE_LENGTH && longLineNumbers.length < 3) {
104
- longLineNumbers.push(index + 1)
105
- }
106
- })
107
- if (longLineNumbers.length > 0) {
108
- messages.push(
109
- `存在超过 ${MAX_LINE_LENGTH} 字符的行(如第 ${longLineNumbers.join('、')} 行),请换行或提取。`
110
- )
111
- }
112
-
113
- if (messages.length === 0) {
114
- return { exitCode: 0 }
115
- }
116
-
117
- return { exitCode: 0, stderr: `[Hook] ${filePath}: ${messages.join(' ')}\n` }
118
- }
119
-
7
+ const { checkEditedFile, runCli } = require('./check-edited-file')
8
+ const run = raw => checkEditedFile(raw, false, true)
120
9
  module.exports = { run }
121
-
122
- if (require.main === module) {
123
- let data = ''
124
- process.stdin.setEncoding('utf8')
125
- process.stdin.on('data', chunk => { data += chunk })
126
- process.stdin.on('end', () => {
127
- const result = run(data)
128
- if (result.stderr) process.stderr.write(result.stderr)
129
- if (result.stdout) process.stdout.write(result.stdout)
130
- process.exit(result.exitCode || 0)
131
- })
132
- }
10
+ if (require.main === module) runCli(run)
@@ -1,85 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Check Forbidden Patterns Hook
4
- *
5
- * 在代码编辑后检测静态禁止模式:console.log、debugger,
6
- * 以及 TypeScript 文件中的 @ts-ignore、@ts-nocheck、`: any`、`as any`。
7
- * 对应 rules/02-implementation.md 的代码与安全禁止项;文档文件不受检查。
8
- * 用于 PostToolUse hook,警告不阻塞。
3
+ * Check Forbidden Patterns Hook(兼容入口,实现已并入 hooks/check-edited-file.js)
9
4
  */
10
-
11
5
  'use strict'
12
6
 
13
- const fs = require('fs')
14
-
15
- const TS_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts'])
16
-
17
- function getExtension(filePath) {
18
- const match = filePath.match(/(\.[^.\\/]+)$/)
19
- return match ? match[1].toLowerCase() : ''
20
- }
21
-
22
- const FORBIDDEN_PATTERNS = [
23
- { label: 'console.log 调试残留', pattern: /\bconsole\.log\s*\(/ },
24
- { label: 'debugger 调试残留', pattern: /^\s*debugger\b/m },
25
- { label: '@ts-ignore', pattern: /@ts-ignore/ },
26
- { label: '@ts-nocheck', pattern: /@ts-nocheck/ },
27
- { label: 'any 类型(: any)', pattern: /:\s*any\b/ },
28
- { label: 'any 断言(as any)', pattern: /\bas\s+any\b/ }
29
- ]
30
-
31
- function run(raw) {
32
- let input
33
- try {
34
- input = JSON.parse(raw)
35
- } catch {
36
- return { exitCode: 0 }
37
- }
38
-
39
- const filePath = input.tool_input?.file_path
40
- if (!filePath || !fs.existsSync(filePath)) {
41
- return { exitCode: 0 }
42
- }
43
-
44
- const ext = getExtension(filePath)
45
- const isCode = Boolean(ext) && !/^\.(md|json|txt)$/.test(ext)
46
- const isTs = TS_EXTENSIONS.has(ext)
47
- if (!isCode) {
48
- return { exitCode: 0 }
49
- }
50
-
51
- let content
52
- try {
53
- content = fs.readFileSync(filePath, 'utf8')
54
- } catch {
55
- return { exitCode: 0 }
56
- }
57
-
58
- const hits = []
59
- for (const rule of FORBIDDEN_PATTERNS) {
60
- if (rule.label.includes('any') && !isTs) continue
61
- if (rule.pattern.test(content)) hits.push(rule.label)
62
- }
63
- if (hits.length === 0) {
64
- return { exitCode: 0 }
65
- }
66
-
67
- return {
68
- exitCode: 0,
69
- stderr: `[Hook] 警告: ${filePath} 含禁止模式: ${hits.join('、')},请按 rules/02-implementation.md 处理\n`
70
- }
71
- }
72
-
7
+ const { checkEditedFile, runCli } = require('./check-edited-file')
8
+ const run = raw => checkEditedFile(raw, true, false)
73
9
  module.exports = { run }
74
-
75
- if (require.main === module) {
76
- let data = ''
77
- process.stdin.setEncoding('utf8')
78
- process.stdin.on('data', chunk => { data += chunk })
79
- process.stdin.on('end', () => {
80
- const result = run(data)
81
- if (result.stderr) process.stderr.write(result.stderr)
82
- if (result.stdout) process.stdout.write(result.stdout)
83
- process.exit(result.exitCode || 0)
84
- })
85
- }
10
+ if (require.main === module) runCli(run)