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
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Antigravity PreToolUse Hook 适配器
6
+ *
7
+ * 读取 Antigravity camelCase stdin JSON,将含 git commit 的 run_command 调用
8
+ * 转发给 hooks/commit-quality.js,并输出符合 hooks.json 契约的 JSON 决策。
9
+ */
10
+
11
+ const path = require("node:path");
12
+ const { spawnSync } = require("node:child_process");
13
+ const { isHookEnabled } = require("./hook-flags");
14
+
15
+ const HOOK_ID = "pre:bash:commit-quality";
16
+ const PROFILES = "standard,strict";
17
+
18
+ function isValidDirString(value) {
19
+ return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
20
+ }
21
+
22
+ function resolveWorkDir(payload) {
23
+ const workspacePaths = Array.isArray(payload?.workspacePaths) ? payload.workspacePaths : [];
24
+ const workspaceRoot = workspacePaths.find(isValidDirString);
25
+ const baseCwd = isValidDirString(payload?.cwd)
26
+ ? payload.cwd
27
+ : workspaceRoot || process.cwd();
28
+
29
+ const rawToolCwd = payload?.toolCall?.args?.Cwd;
30
+ if (rawToolCwd !== undefined && rawToolCwd !== null) {
31
+ if (typeof rawToolCwd !== "string" || rawToolCwd.includes("\0")) {
32
+ return { valid: false };
33
+ }
34
+ if (rawToolCwd.trim()) {
35
+ const resolved = path.isAbsolute(rawToolCwd)
36
+ ? rawToolCwd
37
+ : path.resolve(baseCwd, rawToolCwd);
38
+ return { valid: true, cwd: resolved };
39
+ }
40
+ }
41
+
42
+ return { valid: true, cwd: baseCwd };
43
+ }
44
+
45
+ function run(raw) {
46
+ if (!isHookEnabled(HOOK_ID, { profiles: PROFILES })) {
47
+ return { decision: "allow" };
48
+ }
49
+
50
+ let payload;
51
+ try {
52
+ payload = JSON.parse(raw);
53
+ } catch {
54
+ return { decision: "allow" };
55
+ }
56
+
57
+ const toolName = payload?.toolCall?.name;
58
+ const commandLine = payload?.toolCall?.args?.CommandLine;
59
+ if (toolName !== "run_command" || typeof commandLine !== "string" || !commandLine.trim()) {
60
+ return { decision: "allow" };
61
+ }
62
+
63
+ if (!/\bcommit\b/i.test(commandLine)) {
64
+ return { decision: "allow" };
65
+ }
66
+
67
+ const workDir = resolveWorkDir(payload);
68
+ if (!workDir.valid) {
69
+ return { decision: "deny", reason: "Invalid run_command working directory." };
70
+ }
71
+
72
+ const commitQualityPath = path.resolve(__dirname, "..", "commit-quality.js");
73
+ const result = spawnSync(process.execPath, [commitQualityPath], {
74
+ input: JSON.stringify({ tool_input: { command: commandLine } }),
75
+ cwd: workDir.cwd,
76
+ encoding: "utf8",
77
+ timeout: 8000,
78
+ });
79
+
80
+ if (result.error || (result.status !== 0 && result.status !== 2)) {
81
+ return {
82
+ decision: "deny",
83
+ reason: "Could not run the commit check in the requested working directory.",
84
+ };
85
+ }
86
+ const reason = (result.stderr || "").trim();
87
+ if (result.status === 2) {
88
+ return {
89
+ decision: "deny",
90
+ reason: reason || "Commit blocked by cew-commit-quality hook.",
91
+ };
92
+ }
93
+
94
+ return reason ? { decision: "allow", reason } : { decision: "allow" };
95
+ }
96
+
97
+ module.exports = { run };
98
+
99
+ if (require.main === module) {
100
+ let raw = "";
101
+ process.stdin.setEncoding("utf8");
102
+ process.stdin.on("data", (chunk) => {
103
+ raw += chunk;
104
+ });
105
+ process.stdin.on("end", () => {
106
+ try {
107
+ process.stdout.write(`${JSON.stringify(run(raw))}\n`);
108
+ } catch (error) {
109
+ const message = error instanceof Error ? error.message : String(error);
110
+ process.stdout.write(
111
+ `${JSON.stringify({ decision: "allow", reason: `cew-commit-quality hook error: ${message}` })}\n`,
112
+ );
113
+ }
114
+ process.exit(0);
115
+ });
116
+ }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "claude-everything-workflow",
3
- "version": "0.2.10",
4
- "description": "Claude Code and Codex harness with rules, skills, agents, hooks, and verification gates.",
3
+ "version": "0.2.12",
4
+ "description": "Claude Code, Codex, and Antigravity harness with rules, skills, agents, hooks, and verification gates.",
5
5
  "keywords": [
6
6
  "claude-code",
7
7
  "codex",
8
+ "antigravity",
8
9
  "agents",
9
10
  "harness",
10
11
  "skills"
@@ -23,6 +24,7 @@
23
24
  "test:install-rules": "node scripts/verify/install-rules.test.js",
24
25
  "test:learning": "node --test scripts/verify/learning.test.js",
25
26
  "test:plugins": "node --test scripts/verify/plugin-distribution.test.js",
27
+ "test:hooks": "node --test scripts/verify/commit-quality.test.js",
26
28
  "eval:scenarios": "node scripts/eval-scenarios.js",
27
29
  "verify:upstream": "node scripts/verify-upstream-capability-map.js",
28
30
  "pack:dry-run": "npm pack --dry-run"
@@ -23,6 +23,6 @@
23
23
 
24
24
  ## 代码与安全禁止 (CRITICAL)
25
25
 
26
- - 调试残留、类型抑制和耦合问题按目标项目标准检查;不得为掩盖真实错误添加抑制或绕过检查。`hooks/check-console-log.js` 对 `console.log`、`debugger`、`@ts-ignore`、`@ts-nocheck` 和 `any` 的提示属于兼容性警告,需结合真实用途判断。
26
+ - 调试残留、类型抑制和耦合问题按目标项目标准检查;不得为掩盖真实错误添加抑制或绕过检查。`hooks/check-edited-file.js` 对 `console.log`、`debugger`、`@ts-ignore`、`@ts-nocheck` 和 `any` 的提示属于兼容性警告,需结合真实用途判断。
27
27
  - 禁止硬编码密钥、API key、token、secret 或密码(改用环境变量)、SQL 字符串拼接(改用参数化)、未校验外部输入、明文密码(改用 hash)、绕过验证或质量门 Hook,以及提交调试代码。
28
28
  - 危险操作必须在沙箱或等价隔离环境中执行;安全敏感改动提交前按风险检查 SQL 注入、XSS、敏感信息泄露和依赖漏洞。发现违规时立即指出问题、解释原因并提供修复方案。
@@ -10,8 +10,8 @@
10
10
 
11
11
  - 摘要字段以 `rules/common/context-hygiene.md` 为唯一来源;不按轮数机械总结,不保存完整 transcript,不覆盖用户规则和决策;敏感内容只记录风险和证据位置,不持久化原值。
12
12
  - `ECC_HOOK_PROFILE` 支持 `minimal`、默认 `standard` 和 `strict`;`ECC_DISABLED_HOOKS` 禁用指定 Hook ID。
13
- - 会阻止提交的质量门 Hook 默认关闭,只有团队明确需要时启用。
14
- - `check-code-size` 与 `check-console-log` 是兼容性提示,不替代目标项目 lint 或类型规则;项目已有等价检查
13
+ - `standard`、`strict` 默认启用提交检查:疑似密钥命中时阻止提交,提交格式与调试代码仅警告;`minimal` 不启用此 Hook。它不替代目标项目的安全检查与质量门。
14
+ - `check-edited-file`(Hook ID `post:edit:quality`,仍兼容单独禁用 `post:edit:console-log` 与 `post:edit:code-size`)是兼容性提示,不替代目标项目 lint 或类型规则;项目已有等价检查
15
15
  或约定不适用时,可用 `ECC_DISABLED_HOOKS` 关闭相应提示,不能借此绕过项目质量门。
16
16
 
17
17
  ## 权限
@@ -3,6 +3,7 @@
3
3
 
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
+ const { createHash } = require("node:crypto");
6
7
 
7
8
  function writeLine(message) {
8
9
  process.stdout.write(`${message}\n`);
@@ -45,7 +46,15 @@ function validateManifest(manifest) {
45
46
  throw new Error(`Invalid retired skill entry: ${skill}`);
46
47
  }
47
48
  }
48
- return entries;
49
+ const agents = manifest.retired_agent_hashes === undefined ? {} : manifest.retired_agent_hashes;
50
+ if (!agents || typeof agents !== "object" || Array.isArray(agents)) throw new Error("Invalid retired agent manifest");
51
+ for (const [name, hashes] of Object.entries(agents)) {
52
+ if (!/^[a-z0-9-]+\.md$/.test(name) || !Array.isArray(hashes) || hashes.length === 0 ||
53
+ !hashes.every((hash) => typeof hash === "string" && /^[a-f0-9]{64}$/.test(hash))) {
54
+ throw new Error(`Invalid retired agent entry: ${name}`);
55
+ }
56
+ }
57
+ return { skills: entries, agents: Object.entries(agents) };
49
58
  }
50
59
 
51
60
  function lstatIfExists(target) {
@@ -168,6 +177,29 @@ function cleanupSkill({ installRoot, skill, knownFiles, dryRun }) {
168
177
  }
169
178
  }
170
179
 
180
+ function cleanupRetiredAgents(installRoot, agents, dryRun) {
181
+ const directory = path.join(installRoot, "agents");
182
+ if (lstatIfExists(installRoot)?.isSymbolicLink() || !lstatIfExists(directory)?.isDirectory()) return;
183
+ for (const [name, hashes] of agents) {
184
+ const target = path.join(directory, name);
185
+ const stat = lstatIfExists(target);
186
+ if (!stat) continue;
187
+ if (stat.isSymbolicLink()) {
188
+ writeLine(`Preserving symlinked retired agent: ${target}`);
189
+ continue;
190
+ }
191
+ if (!stat.isFile()) continue;
192
+ // SHA-256 of LF text, including the distinct files generated for Antigravity.
193
+ const text = fs.readFileSync(target, "utf8").replace(/\r\n/g, "\n");
194
+ if (!hashes.includes(createHash("sha256").update(text).digest("hex"))) {
195
+ writeLine(`Preserving customized retired agent: ${target}`);
196
+ continue;
197
+ }
198
+ writeLine(`${dryRun ? "[dry-run] " : ""}Remove retired agent: ${target}`);
199
+ if (!dryRun) fs.rmSync(target, { force: true });
200
+ }
201
+ }
202
+
171
203
  function main(argv = process.argv.slice(2)) {
172
204
  const dryRun = argv.includes("--dry-run");
173
205
  const validateOnly = argv.includes("--validate");
@@ -184,10 +216,11 @@ function main(argv = process.argv.slice(2)) {
184
216
 
185
217
  const manifestPath = path.join(__dirname, "retired-skill-files.json");
186
218
  const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
187
- const retiredSkills = validateManifest(manifest);
219
+ const retired = validateManifest(manifest);
188
220
  if (validateOnly) return 0;
189
221
 
190
222
  const installRoot = path.resolve(positional[0]);
223
+ cleanupRetiredAgents(installRoot, retired.agents, dryRun);
191
224
  const skillsRoot = path.join(installRoot, "skills");
192
225
  const skillsRootStat = lstatIfExists(skillsRoot);
193
226
  if (skillsRootStat?.isSymbolicLink()) {
@@ -198,7 +231,7 @@ function main(argv = process.argv.slice(2)) {
198
231
  throw new Error(`Expected skills directory: ${skillsRoot}`);
199
232
  }
200
233
 
201
- for (const [skill, knownFiles] of retiredSkills) {
234
+ for (const [skill, knownFiles] of retired.skills) {
202
235
  cleanupSkill({ installRoot, skill, knownFiles, dryRun });
203
236
  }
204
237
  return 0;
@@ -5,7 +5,9 @@
5
5
  * 可选真实模型路由场景评测脚本(不进入 CI,需本地已登录 claude 或 codex CLI)。
6
6
  * 用法:
7
7
  * node scripts/eval-scenarios.js --host claude --limit 5
8
- * node scripts/eval-scenarios.js --host codex --id bug-diagnosis
8
+ * node scripts/eval-scenarios.js --host codex --id bug-diagnosis --repeat 3
9
+ *
10
+ * --repeat N 对每个场景采样 N 次;全部命中为 PASS;全部有效但选路不一致为 UNSTABLE;宿主或回答格式异常为 FAIL。
9
11
  */
10
12
 
11
13
  const fs = require("node:fs");
@@ -17,15 +19,24 @@ const root = path.resolve(__dirname, "..");
17
19
  const scenariosPath = path.join(root, "evals/routing-scenarios.json");
18
20
 
19
21
  function parseArgs(argv) {
20
- const opts = { host: "claude", limit: Infinity, id: null, dryRun: false };
22
+ const opts = { host: "claude", limit: Infinity, id: null, repeat: 1, dryRun: false };
21
23
  for (let i = 0; i < argv.length; i += 1) {
22
24
  const arg = argv[i];
23
25
  if (arg === "--host") opts.host = argv[++i];
24
26
  else if (arg === "--limit") opts.limit = Number(argv[++i]);
25
27
  else if (arg === "--id") opts.id = argv[++i];
26
- else if (arg === "--dry-run") opts.dryRun = true;
28
+ else if (arg === "--repeat") {
29
+ const value = Number(argv[++i]);
30
+ if (!Number.isInteger(value) || value < 1) {
31
+ throw new Error("--repeat must be a positive integer");
32
+ }
33
+ opts.repeat = value;
34
+ } else if (arg === "--dry-run") opts.dryRun = true;
27
35
  else if (arg === "-h" || arg === "--help") {
28
- console.log("Usage: node scripts/eval-scenarios.js [--host claude|codex] [--limit N] [--id <id>] [--dry-run]");
36
+ console.log(
37
+ "Usage: node scripts/eval-scenarios.js " +
38
+ "[--host claude|codex] [--limit N] [--id <id>] [--repeat N] [--dry-run]",
39
+ );
29
40
  process.exit(0);
30
41
  } else {
31
42
  throw new Error(`Unknown option: ${arg}`);
@@ -42,7 +53,8 @@ function buildEvalPrompt(scenario) {
42
53
  "这是一个只读工作流路由测试:只做选路,不执行下方用户请求,不修改任何文件。",
43
54
  "根据本仓库的 AGENTS.md、工作流路由、Skill 说明和它们引用的规则,判断分发后由哪个文件直接负责用户当前要做的事。只查工作流文档,不查场景题库、测试、评测脚本或提交记录。",
44
55
  "通用路由器只负责转交时,沿分发继续判断;路由器自己完成请求时,可以是答案。多阶段任务按当前要解决的具体问题选负责方。配套参考资料和后续步骤不作为本次目标。",
45
- "只输出一个 JSON 对象,target 填该 Skill 或规则的完整仓库相对文件路径(包含文件名);无需进入工程流程时填字符串 NONE。不要加 Markdown 围栏。",
56
+ "只输出一个 JSON 对象,target 填该 Skill 或规则的完整仓库相对文件路径;目标必须是 Skill 入口(`.../SKILL.md`)或规则文件," +
57
+ "不要填 Skill 内部的 `references/` 文档。无需进入工程流程时填字符串 NONE。不要加 Markdown 围栏。",
46
58
  "",
47
59
  `用户请求:${scenario.prompt}`,
48
60
  ].join("\n");
@@ -66,9 +78,11 @@ function runHost(host, prompt) {
66
78
  }
67
79
 
68
80
  function selectedTarget(answer) {
81
+ const text = String(answer || "").trim();
82
+ const fenced = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]*```$/i.exec(text);
69
83
  try {
70
- const value = JSON.parse(answer);
71
- return typeof value?.target === "string" ? value.target : null;
84
+ const value = JSON.parse(fenced ? fenced[1] : text);
85
+ return typeof value?.target === "string" && value.target.trim() ? value.target : null;
72
86
  } catch (error) {
73
87
  if (error instanceof SyntaxError) return null;
74
88
  throw error;
@@ -90,15 +104,33 @@ function main() {
90
104
  passed += 1;
91
105
  continue;
92
106
  }
93
- const { result, answer } = runHost(opts.host, evalPrompt);
94
107
  const expected = scenario.expectedTarget ?? "NONE";
95
- const selected = selectedTarget(answer);
96
- const ok = result.status === 0 && selected === expected;
108
+ const samples = [];
109
+ for (let i = 0; i < opts.repeat; i += 1) {
110
+ const { result, answer } = runHost(opts.host, evalPrompt);
111
+ const hostFailed = result.status !== 0 || Boolean(result.error);
112
+ samples.push({
113
+ status: result.status,
114
+ hostFailed,
115
+ target: hostFailed ? null : selectedTarget(answer),
116
+ diagnostic: (result.error?.message || result.stderr || "").trim().slice(0, 200),
117
+ });
118
+ }
119
+ const targets = samples.map((sample) => sample.target);
120
+ const ok = targets.every((target) => target === expected);
121
+ const unstable = !targets.includes(null) && new Set(targets).size > 1;
97
122
  if (ok) passed += 1;
98
- console.log(`${ok ? "PASS" : "FAIL"} ${scenario.id} (expected: ${scenario.expectedTarget || "NONE"})`);
99
- if (!ok) {
100
- const diagnostic = result.error?.message || result.stderr || "";
101
- console.log(` exit=${result.status} target=${JSON.stringify(selected)} ${diagnostic.trim().slice(0, 200)}`);
123
+ console.log(
124
+ `${ok ? "PASS" : unstable ? "UNSTABLE" : "FAIL"} ${scenario.id} ` +
125
+ `(expected: ${expected}) samples=${JSON.stringify(targets)}`,
126
+ );
127
+ for (const sample of samples) {
128
+ if (sample.target === expected) continue;
129
+ const reason = sample.hostFailed ? "host-error" : sample.target === null ? "invalid-answer" : "wrong-target";
130
+ console.log(
131
+ ` exit=${sample.status} target=${JSON.stringify(sample.target)} ` +
132
+ `reason=${reason} ${sample.diagnostic}`,
133
+ );
102
134
  }
103
135
  }
104
136
  console.log(`\nSummary: ${passed}/${list.length} passed.`);