claude-everything-workflow 0.2.7 → 0.2.9

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 (43) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/AGENTS.md +11 -18
  4. package/agents/e2e-runner.md +1 -1
  5. package/commands/pr.md +3 -1
  6. package/evals/routing-scenarios.json +253 -0
  7. package/harness/manifest.json +2 -28
  8. package/hooks/check-console-log.js +2 -2
  9. package/package.json +4 -2
  10. package/rules/01-base.md +2 -2
  11. package/rules/02-implementation.md +7 -6
  12. package/rules/05-git-workflow.md +4 -6
  13. package/rules/common/agent-orchestration.md +1 -1
  14. package/rules/common/pr-automation.md +1 -1
  15. package/rules/common/testing.md +2 -2
  16. package/scripts/eval-scenarios.js +106 -0
  17. package/scripts/install-rules.js +186 -17
  18. package/scripts/install.ps1 +42 -15
  19. package/scripts/install.sh +31 -12
  20. package/scripts/legacy-common-rule-hashes.json +4 -0
  21. package/scripts/retired-skill-files.json +7 -0
  22. package/scripts/verify/install-rules.test.js +80 -24
  23. package/scripts/verify/metadata-checks.js +7 -8
  24. package/scripts/verify/repository-checks.js +44 -368
  25. package/scripts/verify/scenario-checks.js +108 -0
  26. package/scripts/verify/scenario-checks.test.js +84 -0
  27. package/scripts/verify/workflow-checks.js +85 -586
  28. package/scripts/verify-harness.js +2 -0
  29. package/skills/README.md +2 -4
  30. package/skills/feature-acceptance/SKILL.md +8 -8
  31. package/skills/{e2e-testing/SKILL.md → feature-acceptance/references/e2e-testing.md} +3 -9
  32. package/skills/implement/SKILL.md +2 -0
  33. package/skills/{subagent-driven-development/SKILL.md → implement/references/parallel-delivery.md} +7 -9
  34. package/skills/implement/references/ticket-delivery.md +1 -1
  35. package/skills/using-superpowers/SKILL.md +24 -103
  36. package/rules/07-forbidden.md +0 -20
  37. package/rules/08-specialty-rules-index.md +0 -18
  38. package/rules/09-first-principles-adversarial-testing.md +0 -30
  39. package/scripts/verify/continuation-checks.test.js +0 -101
  40. package/scripts/verify/grilling-spec-gate-checks.js +0 -297
  41. package/scripts/verify/workflow-ownership-fixtures.js +0 -371
  42. package/scripts/verify/workflow-ownership.js +0 -780
  43. /package/skills/{e2e-testing → feature-acceptance}/references/playwright-patterns.md +0 -0
@@ -6,7 +6,7 @@ const os = require("node:os");
6
6
  const path = require("node:path");
7
7
  const crypto = require("node:crypto");
8
8
  const { spawnSync } = require("node:child_process");
9
- const { installRules } = require("../install-rules");
9
+ const { installRules, finalizeBackups, BACKUP_ROOT_NAME } = require("../install-rules");
10
10
 
11
11
  const sourceRoot = path.resolve(__dirname, "../..");
12
12
  const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "cew-rules-"));
@@ -24,8 +24,9 @@ function checkLegacyMigration() {
24
24
  fs.writeFileSync(path.join(fixture, "rules/common/testing.md"), "Current distribution\n");
25
25
  const previous = "Previous distribution\n";
26
26
  const hash = crypto.createHash("sha256").update(previous).digest("hex");
27
+ fs.writeFileSync(path.join(fixture, "rules/02-implementation.md"), "New resident distribution\n");
27
28
  fs.writeFileSync(path.join(fixture, "scripts/legacy-common-rule-hashes.json"),
28
- JSON.stringify({ files: { "common/testing.md": [hash] } }));
29
+ JSON.stringify({ files: { "common/testing.md": [hash], "02-implementation.md": [hash] } }));
29
30
  const target = path.join(tempRoot, "legacy-target");
30
31
  fs.mkdirSync(path.join(target, "rules/common"), { recursive: true });
31
32
  fs.writeFileSync(path.join(target, "rules/common/testing.md"), previous.replace(/\n/g, "\r\n"));
@@ -37,11 +38,70 @@ function checkLegacyMigration() {
37
38
  assert.equal(fs.existsSync(path.join(target, "rules/common/testing.md")), false);
38
39
  assert.equal(read(path.join(target, "references/rules/common/testing.md")), "Current distribution\n");
39
40
 
41
+ const previousReference = path.join(target, "references/rules/02-implementation.md");
42
+ fs.writeFileSync(previousReference, previous.replace(/\n/g, "\r\n"));
43
+ fs.unlinkSync(path.join(target, "rules/02-implementation.md"));
40
44
  const cold = path.join(target, "references/rules/common/testing.md");
41
45
  fs.writeFileSync(cold, previous);
42
- installRules(options);
46
+ installRules({ ...options, backupId: "20261125100000" });
43
47
  assert.equal(read(cold), "Current distribution\n");
44
- assert.equal(read(cold + ".bak." + hash), previous);
48
+ assert.equal(read(path.join(target, "rules/02-implementation.md")), "New resident distribution\n");
49
+ assert.equal(fs.existsSync(previousReference), false);
50
+ assert.equal(
51
+ read(path.join(target, BACKUP_ROOT_NAME, "20261125100000/references/rules/common/testing.md")),
52
+ previous,
53
+ );
54
+ assert.equal(fs.existsSync(cold + ".bak." + hash), false);
55
+
56
+ // Legacy inline .bak.* files and older backup directories are cleaned on finalizeBackups.
57
+ fs.writeFileSync(path.join(target, "AGENTS.md.bak.20260101000000"), "old top backup\n");
58
+ fs.writeFileSync(path.join(target, "rules/01-base.md.bak.deadbeef"), "old rule backup\n");
59
+ fs.writeFileSync(cold + ".bak." + hash, previous);
60
+ const olderSnapshot = path.join(target, BACKUP_ROOT_NAME, "20261124000000");
61
+ fs.mkdirSync(path.join(olderSnapshot, "references/rules/common"), { recursive: true });
62
+ fs.writeFileSync(path.join(olderSnapshot, "references/rules/common/testing.md"), "Superseded backup\n");
63
+ fs.writeFileSync(path.join(target, BACKUP_ROOT_NAME, "20261124000000/AGENTS.md"), "older\n");
64
+ finalizeBackups({ installRoot: target, dryRun: true, log: () => {} });
65
+ assert.equal(read(path.join(olderSnapshot, "references/rules/common/testing.md")), "Superseded backup\n");
66
+ finalizeBackups({ installRoot: target, log: () => {} });
67
+ assert.equal(fs.existsSync(path.join(olderSnapshot, "references")), false);
68
+ assert.equal(read(path.join(target, BACKUP_ROOT_NAME, "20261125100000/references/rules/common/testing.md")), previous);
69
+ assert.equal(fs.existsSync(path.join(target, "AGENTS.md.bak.20260101000000")), false);
70
+ assert.equal(fs.existsSync(path.join(target, "rules/01-base.md.bak.deadbeef")), false);
71
+ assert.equal(fs.existsSync(cold + ".bak." + hash), false);
72
+ const backups = path.join(target, BACKUP_ROOT_NAME);
73
+ assert.equal(read(path.join(backups, "legacy/AGENTS.md.bak.20260101000000")), "old top backup\n");
74
+ assert.equal(read(path.join(backups, "legacy/rules/01-base.md.bak.deadbeef")), "old rule backup\n");
75
+ assert.equal(read(path.join(backups, "20261124000000/AGENTS.md")), "older\n",
76
+ "a later partial backup must preserve the only copy of each unchanged file");
77
+ }
78
+
79
+ function checkPromotedImplementationRule() {
80
+ const filename = "02-implementation.md";
81
+ const target = path.join(tempRoot, "promoted");
82
+ const cold = path.join(target, "references/rules", filename);
83
+ const resident = path.join(target, "rules", filename);
84
+ const custom = "My implementation policy\r\n";
85
+ fs.mkdirSync(path.dirname(cold), { recursive: true });
86
+ fs.writeFileSync(cold, custom);
87
+ install("promoted", "claude-code", true);
88
+ assert.equal(fs.existsSync(resident), false);
89
+ assert.equal(fs.readFileSync(cold, "utf8"), custom);
90
+ install("promoted");
91
+ assert.equal(fs.readFileSync(resident, "utf8"), custom, "promote personal rules byte-for-byte");
92
+ install("promoted");
93
+ assert.equal(fs.readFileSync(resident, "utf8"), custom, "preserve promoted rules on reinstall");
94
+ assert.equal(fs.existsSync(cold), false);
95
+
96
+ fs.writeFileSync(cold, "Separate personal reference\n");
97
+ install("promoted");
98
+ assert.equal(fs.readFileSync(resident, "utf8"), custom, "existing personal resident rules take priority");
99
+ assert.equal(read(cold), "Separate personal reference\n", "preserve conflicting personal copies");
100
+
101
+ fs.copyFileSync(path.join(sourceRoot, "rules", filename), resident);
102
+ install("promoted");
103
+ assert.equal(read(resident), "Separate personal reference\n", "repair a previously shadowed policy");
104
+ assert.equal(fs.existsSync(cold), false);
45
105
  }
46
106
 
47
107
  function checkInstallerCliOptions() {
@@ -257,13 +317,20 @@ function checkInstallerEntrypoint() {
257
317
  SessionStart: [{ ...unrelatedHook, hooks: [...unrelatedHook.hooks, retiredSession] }],
258
318
  },
259
319
  }));
320
+ fs.writeFileSync(path.join(profile, ".claude/AGENTS.md"), "My original instructions\n");
260
321
  run();
322
+ // Give the first snapshot a distinct, earlier timestamp even on fast machines.
323
+ const backups = path.join(profile, ".claude", BACKUP_ROOT_NAME);
324
+ const [firstSnapshot] = fs.readdirSync(backups);
325
+ const earlier = "20000101000000";
326
+ fs.renameSync(path.join(backups, firstSnapshot), path.join(backups, earlier));
261
327
  const installedSettings = JSON.parse(read(settingsPath).replace(/^\uFEFF/, ""));
262
328
  assert.deepEqual(installedSettings.hooks.PostToolUse[0], userHookGroup);
263
329
  assert.deepEqual(installedSettings.hooks.SessionStart, [unrelatedHook]);
264
330
  assert.equal(installedSettings.hooks.PostToolUse.flatMap(({ hooks }) => hooks)
265
331
  .filter(({ command }) => command?.includes("hooks/check-console-log.js")).length, 1);
266
332
  run();
333
+ assert.equal(read(path.join(backups, earlier, "AGENTS.md")), "My original instructions\n");
267
334
  assert.deepEqual(JSON.parse(read(settingsPath).replace(/^\uFEFF/, "")), installedSettings,
268
335
  "reinstallation must preserve user hooks and add each managed hook only once");
269
336
  assert.equal(read(path.join(profile, ".claude/references/rules/common/testing.md")),
@@ -286,8 +353,10 @@ function checkInstallerEntrypoint() {
286
353
  }
287
354
  assert.equal(fs.existsSync(path.join(profile, host, "skills/wayfinder/agents")), false);
288
355
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/install-rules.js")), false);
289
- assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/continuation-checks.test.js")), false,
290
- "安装不应保留仅供包内验证的续接测试");
356
+ assert.equal(fs.existsSync(path.join(profile, host, "scripts/eval-scenarios.js")), false,
357
+ "安装不应保留仅供包内评测的场景脚本");
358
+ assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/scenario-checks.test.js")), false,
359
+ "安装不应保留仅供包内验证的场景测试");
291
360
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/plugin-distribution.test.js")), false,
292
361
  "安装不应保留仅供包内验证的插件分发测试");
293
362
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/learning.test.js")), false,
@@ -302,13 +371,10 @@ try {
302
371
  const fresh = path.join(tempRoot, "fresh");
303
372
  const common = fs.readdirSync(path.join(sourceRoot, "rules/common"));
304
373
  assert.equal(common.length, 8);
305
- const resident = ["01-base.md", "05-git-workflow.md", "07-forbidden.md"];
306
- const onDemand = [
307
- "02-implementation.md", "08-specialty-rules-index.md", "09-first-principles-adversarial-testing.md",
308
- ];
374
+ const resident = ["01-base.md", "02-implementation.md", "05-git-workflow.md"];
309
375
  assert.deepEqual(fs.readdirSync(path.join(fresh, "rules")).sort(), resident);
310
376
  install("codex", "codex");
311
- for (const file of [...resident, ...onDemand, ...common.map((name) => `common/${name}`)]) {
377
+ for (const file of [...resident, ...common.map((name) => `common/${name}`)]) {
312
378
  const source = read(path.join(sourceRoot, "rules", file));
313
379
  const claudeDir = resident.includes(file) ? "rules" : "references/rules";
314
380
  assert.equal(read(path.join(fresh, claudeDir, file)), source);
@@ -323,29 +389,18 @@ try {
323
389
  path.join(upgrade, "rules/common/testing.md"));
324
390
  fs.writeFileSync(path.join(upgrade, "rules/common/hooks.md"), "Personal hook policy\n");
325
391
  fs.writeFileSync(path.join(upgrade, "rules/common/personal.md"), "Keep my rules\n");
326
- for (const file of onDemand) {
327
- fs.copyFileSync(path.join(sourceRoot, "rules", file), path.join(upgrade, "rules", file));
328
- }
329
- const customRule = "02-implementation.md";
330
- const personal = path.join(upgrade, "rules", customRule);
331
- fs.writeFileSync(personal, "Personal implementation rules\n");
392
+ fs.writeFileSync(path.join(upgrade, "rules/08-specialty-rules-index.md"), "Personal index\n");
332
393
  install("upgrade", "claude-code", true);
333
394
  assert.equal(fs.existsSync(path.join(upgrade, "references")), false);
334
- for (const file of onDemand) assert.ok(fs.existsSync(path.join(upgrade, "rules", file)));
335
395
  install("upgrade");
336
396
  assert.equal(fs.existsSync(path.join(upgrade, "rules/common/testing.md")), false);
337
397
  assert.equal(read(path.join(upgrade, "rules/common/hooks.md")), "Personal hook policy\n");
338
398
  assert.equal(read(path.join(upgrade, "rules/common/personal.md")), "Keep my rules\n");
399
+ assert.equal(read(path.join(upgrade, "rules/08-specialty-rules-index.md")), "Personal index\n");
339
400
  assert.ok(messages.some((message) => /保留.*hooks\.md/.test(message)));
340
401
  install("upgrade");
341
402
  assert.equal(read(path.join(upgrade, "rules/common/hooks.md")), "Personal hook policy\n");
342
403
 
343
- assert.equal(read(personal), "Personal implementation rules\n");
344
- for (const file of onDemand) {
345
- assert.equal(fs.existsSync(path.join(upgrade, "rules", file)), file === customRule);
346
- assert.equal(read(path.join(upgrade, "references/rules", file)), read(path.join(sourceRoot, "rules", file)));
347
- }
348
-
349
404
  const outside = path.join(tempRoot, "outside");
350
405
  fs.mkdirSync(outside);
351
406
  const linked = path.join(tempRoot, "linked");
@@ -355,6 +410,7 @@ try {
355
410
  assert.deepEqual(fs.readdirSync(outside), []);
356
411
  assert.throws(() => install("invalid", "unknown"), /host/i);
357
412
  checkLegacyMigration();
413
+ checkPromotedImplementationRule();
358
414
  checkInstallerCliOptions();
359
415
  checkBashHelpOptions();
360
416
  checkInstallerLinkedRoots();
@@ -17,19 +17,18 @@ const PACKAGE_ONLY_PATHS = [
17
17
  "scripts/install.ps1",
18
18
  "scripts/install-rules.js",
19
19
  "scripts/legacy-common-rule-hashes.json",
20
+ "scripts/eval-scenarios.js",
20
21
  "scripts/verify-harness.js",
21
22
  "scripts/verify/core.js",
22
- "scripts/verify/grilling-spec-gate-checks.js",
23
23
  "scripts/verify/metadata-checks.js",
24
24
  "scripts/verify/repository-checks.js",
25
25
  "scripts/verify/runtime-checks.js",
26
26
  "scripts/verify/workflow-checks.js",
27
- "scripts/verify/workflow-ownership-fixtures.js",
28
- "scripts/verify/workflow-ownership.js",
27
+ "scripts/verify/scenario-checks.js",
28
+ "scripts/verify/scenario-checks.test.js",
29
29
  "scripts/verify/skill-manifest-checks.js",
30
30
  "scripts/verify/skill-manifest-checks.test.js",
31
31
  "scripts/verify/skill-invocation.test.js",
32
- "scripts/verify/continuation-checks.test.js",
33
32
  "scripts/verify/install-rules.test.js",
34
33
  "scripts/verify/learning.test.js",
35
34
  "scripts/verify/plugin-distribution.test.js",
@@ -232,8 +231,8 @@ function checkInstallRuntimePolicy() {
232
231
  "scripts\\install.ps1",
233
232
  "scripts\\verify-harness.js",
234
233
  "scripts\\verify",
235
- "scripts\\verify\\workflow-ownership-fixtures.js",
236
- "scripts\\verify\\workflow-ownership.js",
234
+ "scripts\\verify\\scenario-checks.js",
235
+ "scripts\\verify\\scenario-checks.test.js",
237
236
  ]);
238
237
  requireTokens("scripts/install.sh", [
239
238
  "copy_claude_settings",
@@ -243,8 +242,8 @@ function checkInstallRuntimePolicy() {
243
242
  "scripts/install.sh",
244
243
  "scripts/verify-harness.js",
245
244
  "scripts/verify",
246
- "scripts/verify/workflow-ownership-fixtures.js",
247
- "scripts/verify/workflow-ownership.js",
245
+ "scripts/verify/scenario-checks.js",
246
+ "scripts/verify/scenario-checks.test.js",
248
247
  ]);
249
248
 
250
249
  const ps = read("scripts/install.ps1");
@@ -1,394 +1,70 @@
1
1
  "use strict";
2
2
 
3
- let exists;
4
- let read;
5
- let fail;
6
- let requireTokens;
7
-
8
- function bindContext(context) {
9
- ({ exists, read, fail, requireTokens } = context);
10
- }
11
-
12
- function checkRouterAndAgentLinks() {
13
- requireTokens("skills/using-superpowers/SKILL.md", [
14
- "Skill Invocation Rule",
15
- "Task arrives",
16
- "Agent-selected Delivery Topology",
17
- "delivery request in defined scope?",
18
- "independent frontier tickets with no overlapping write surface?",
19
- "skills/subagent-driven-development/SKILL.md",
20
- "skill discovery or install request?",
21
- "external skill learning or edit?",
22
- "process skills before implementation skills",
23
- "skills/grilling/SKILL.md",
24
- "spec-gate",
25
- "skills/systematic-debugging/SKILL.md",
26
- "rules/common/testing.md",
27
- "User instructions",
28
- ]);
29
-
30
- const expected = [
31
- ["agents/e2e-runner.md", "skills/e2e-testing/SKILL.md"],
32
- ];
33
-
34
- for (const [agent, skill] of expected) {
35
- if (!exists(agent)) fail(`${agent} is missing`);
36
- if (!exists(skill)) fail(`${skill} is missing`);
37
- if (exists(agent) && !read(agent).includes(skill)) {
38
- fail(`${agent} should reference ${skill}`);
39
- }
40
- }
41
-
42
- for (const agent of ["agents/harness-optimizer.md"]) {
43
- if (!exists(agent)) {
44
- fail(`${agent} is missing`);
3
+ const path = require("path");
4
+
5
+ const PATH_REF_PATTERN = /`((?:skills|rules|agents|commands)\/[A-Za-z0-9_./-]+\.(?:md|json|yaml|yml|js|cjs|sh|ps1))`/g;
6
+ const LOCAL_REF_PATTERN = /`(references\/[A-Za-z0-9_./-]+\.(?:md|json|yaml|yml|js|cjs|sh|ps1))`/g;
7
+ const MD_LINK_PATTERN = /\]\(([^)#\s]+\.(?:md|json|yaml|yml|js|cjs|sh|ps1))\)/g;
8
+
9
+ function checkPathReferences({ managedFiles, isVerifierImplementation, exists, read, fail }) {
10
+ const rootsToCheck = ["AGENTS.md", "CLAUDE.md"];
11
+ for (const file of managedFiles()) {
12
+ if (isVerifierImplementation(file)) continue;
13
+ if (
14
+ !rootsToCheck.includes(file) &&
15
+ !/^(?:rules|skills|agents|commands)\//.test(file)
16
+ ) {
45
17
  continue;
46
18
  }
19
+ if (!file.endsWith(".md")) continue;
47
20
 
48
- const body = read(agent);
49
- if (body.includes("brainstorming")) {
50
- fail(`${agent} must not reference the removed brainstorming skill`);
51
- }
52
- if (!body.includes("grilling") || !body.includes("spec-gate")) {
53
- fail(`${agent} should reference grilling and spec-gate`);
54
- }
55
- }
56
- }
21
+ const body = read(file);
22
+ const dir = path.posix.dirname(file);
57
23
 
58
- function checkTicketFirstDelivery() {
59
- for (const skill of ["writing-plans", "executing-plans"]) {
60
- if (exists(`skills/${skill}/SKILL.md`)) {
61
- fail(`skills/${skill}/SKILL.md must be retired for the ticket-first flow`);
62
- }
63
- }
64
-
65
- requireTokens("skills/to-tickets/SKILL.md", [
66
- "tracer bullet",
67
- "blocking edges",
68
- "fresh context",
69
- "file paths",
70
- "code snippets",
71
- "Do not publish before approval",
72
- ]);
73
- requireTokens("skills/implement/SKILL.md", [
74
- "test-driven-development",
75
- "direct-scope contract",
76
- "无 ticket 范围不得 claim 或写入任何 tracker",
77
- "[references/ticket-delivery.md](references/ticket-delivery.md)",
78
- ]);
79
- requireTokens("skills/implement/references/ticket-delivery.md", [
80
- "一个 fresh context",
81
- "ticket as the Spec source",
82
- "`/code-review --worktree <pre-ticket-base> --spec <ticket>`",
83
- ]);
84
- requireTokens("skills/subagent-driven-development/SKILL.md", [
85
- "frontier ticket",
86
- "fresh subagent",
87
- "one ticket",
88
- "router is executing a user-authorized delivery scope",
89
- "separate worktree",
90
- "controller-owned integration worktree",
91
- "integrate-and-verify gate",
92
- "task-owned untracked files",
93
- "every selected ticket body as the combined Spec source",
94
- "Do not generate a detailed implementation plan",
95
- ]);
96
- }
97
-
98
- function checkDebuggingSkill() {
99
- if (!exists("skills/systematic-debugging/SKILL.md")) {
100
- fail("skills/systematic-debugging/SKILL.md is missing");
101
- } else {
102
- const debugging = read("skills/systematic-debugging/SKILL.md");
103
- for (const token of [
104
- "references/diagnosing-bugs.upstream.md",
105
- "唯一运行入口",
106
- "上游原始 Bash 模板留档",
107
- "scripts/hitl-loop.template.js",
108
- ]) {
109
- if (!debugging.includes(token)) {
110
- fail(`skills/systematic-debugging/SKILL.md should include ${token}`);
24
+ for (const [, target] of body.matchAll(PATH_REF_PATTERN)) {
25
+ if (target.includes("<") || target.includes("*")) continue;
26
+ if (!exists(target)) {
27
+ fail(`${file} references missing path: ${target}`);
111
28
  }
112
29
  }
113
30
 
114
- const upstreamPath =
115
- "skills/systematic-debugging/references/diagnosing-bugs.upstream.md";
116
- if (!exists(upstreamPath)) {
117
- fail(`${upstreamPath} is missing`);
118
- } else {
119
- const upstreamDebugging = read(upstreamPath);
120
- for (const token of [
121
- "# Diagnosing Bugs",
122
- "## Phase 1 — Build a feedback loop",
123
- "one command",
124
- "Red-capable",
125
- "Deterministic",
126
- "Fast",
127
- "Agent-runnable",
128
- "3–5 ranked hypotheses",
129
- "higher reproduction rate",
130
- "## Phase 2 — Reproduce + minimise",
131
- "## Phase 3 — Hypothesise",
132
- "## Phase 4 — Instrument",
133
- "## Phase 5 — Fix + regression test",
134
- "## Phase 6 — Cleanup + post-mortem",
135
- "scripts/hitl-loop.template.sh",
136
- "Show the ranked list to the user before testing",
137
- "Tag every debug log",
138
- "what would have prevented this bug?",
139
- "/improve-codebase-architecture",
140
- ]) {
141
- if (!upstreamDebugging.includes(token)) {
142
- fail(`${upstreamPath} should include ${token}`);
31
+ if (/^skills\/[^/]+\/SKILL\.md$/.test(file)) {
32
+ for (const [, target] of body.matchAll(LOCAL_REF_PATTERN)) {
33
+ if (target.includes("<") || target.includes("*")) continue;
34
+ const skillLocal = path.posix.join(dir, target);
35
+ if (!exists(skillLocal) && !exists(target)) {
36
+ fail(`${file} references missing path: ${target}`);
143
37
  }
144
38
  }
145
39
  }
146
40
 
147
- requireTokens("skills/systematic-debugging/scripts/hitl-loop.template.sh", [
148
- "Human-in-the-loop reproduction loop.",
149
- "step()",
150
- "capture()",
151
- "ERRORED",
152
- "ERROR_MSG",
153
- ]);
154
-
155
- requireTokens("skills/systematic-debugging/scripts/hitl-loop.template.js", [
156
- "Human-in-the-loop reproduction loop.",
157
- "async function step",
158
- "async function capture",
159
- "完成后按 Enter",
160
- "输入已结束",
161
- "ERRORED",
162
- "ERROR_MSG",
163
- ]);
164
-
165
- const hitlNode = read(
166
- "skills/systematic-debugging/scripts/hitl-loop.template.js",
167
- );
168
- for (const token of ["(y/n)", "none", "--- Captured ---"]) {
169
- if (hitlNode.includes(token)) {
170
- fail(
171
- `skills/systematic-debugging/scripts/hitl-loop.template.js should not expose English prompt token ${token}`,
172
- );
41
+ for (const [, link] of body.matchAll(MD_LINK_PATTERN)) {
42
+ if (/^(?:https?:|mailto:|\/)/.test(link) || link.includes("<") || link.includes("*")) continue;
43
+ const resolved = path.posix.normalize(dir === "." ? link : path.posix.join(dir, link));
44
+ if (!exists(resolved)) {
45
+ fail(`${file} links to missing path: ${link} (resolved: ${resolved})`);
173
46
  }
174
47
  }
175
48
  }
176
49
  }
177
50
 
178
- function checkCodeReviewContracts() {
179
- requireTokens("commands/code-review.md", [
180
- "固定基点",
181
- "`git diff <base>...HEAD`",
182
- "`git diff <base>`",
183
- "--worktree",
184
- "--spec <path>",
185
- "Spec 轴",
186
- "skills/code-review/SKILL.md",
187
- "并行",
188
- ]);
189
-
190
- requireTokens("skills/code-review/SKILL.md", [
191
- "two parallel subagents",
192
- "tracked staged and unstaged",
193
- "untracked",
194
- "git diff <base>",
195
- "standards-reviewer-prompt.md",
196
- "spec-reviewer-prompt.md",
197
- "Do not merge or rerank",
198
- ]);
199
-
200
- requireTokens("skills/code-review/references/standards-reviewer-prompt.md", [
201
- "Mysterious Name",
202
- "Duplicated Code",
203
- "Feature Envy",
204
- "Data Clumps",
205
- "Primitive Obsession",
206
- "Repeated Switches",
207
- "Shotgun Surgery",
208
- "Divergent Change",
209
- "Speculative Generality",
210
- "Message Chains",
211
- "Middle Man",
212
- "Refused Bequest",
213
- "judgement call",
51
+ function checkRuleLoadingPolicy({ requireTokens }) {
52
+ requireTokens("AGENTS.md", [
53
+ "rules/common/",
54
+ "01-base.md",
55
+ "02-implementation.md",
56
+ "05-git-workflow.md",
57
+ "using-superpowers",
214
58
  ]);
215
-
216
- requireTokens("skills/code-review/references/spec-reviewer-prompt.md", [
217
- "missing or partial",
218
- "scope creep",
219
- "looks implemented but is wrong",
220
- "NOT RUN",
221
- ]);
222
-
223
- requireTokens("skills/implement/references/ticket-delivery.md", [
224
- "pre-ticket base",
225
- "ticket as the Spec source",
59
+ requireTokens("CLAUDE.md", [
60
+ "@AGENTS.md",
61
+ "~/.claude/references/rules/",
226
62
  ]);
227
63
  }
228
64
 
229
- function checkProjectContextContracts() {
230
- for (const name of ["find-skills", "project-context"]) {
231
- if (exists(`skills/${name}/SKILL.md`)) fail(`${name} Skill must be retired`);
232
- }
233
- for (const file of ["skills/to-tickets/SKILL.md", "skills/triage/SKILL.md", "skills/domain-modeling/SKILL.md"]) {
234
- requireTokens(file, ["docs/agent-workflow/project-context.md"]);
235
- }
236
- requireTokens("skills/to-tickets/SKILL.md", ["does not block drafting", "Before publication"]);
237
- requireTokens("skills/triage/SKILL.md", ["does not block read-only assessment", "before external changes"]);
238
- }
239
-
240
- function checkTrackerDeliveryLifecycle() {
241
- const deliveryLifecycle =
242
- "PRECONDITION → ISOLATE → [CLAIM] → EXECUTE → REVIEW → VERIFY → " +
243
- "[RESOLVE → REFRESH_FRONTIER] → FINISH_DELIVERY";
244
-
245
- requireTokens("skills/implement/SKILL.md", [
246
- "rules/05-git-workflow.md",
247
- "clean baseline",
248
- "pre-delivery base",
249
- "不覆盖 commit、push 或创建 PR",
250
- "无 ticket 范围不得 claim 或写入任何 tracker",
251
- ]);
252
- requireTokens("rules/05-git-workflow.md", [
253
- "开发新功能必须使用独立 `git worktree` 和任务分支",
254
- "单文件新功能也不例外",
255
- ]);
256
- requireTokens("skills/implement/references/ticket-delivery.md", [
257
- "## State Machine",
258
- deliveryLifecycle,
259
- "docs/agent-workflow/project-context.md",
260
- "clean baseline",
261
- "pre-ticket base",
262
- "一个 fresh context",
263
- "ticket as the Spec source",
264
- "`/code-review --worktree <pre-ticket-base> --spec <ticket>`",
265
- "frontier",
266
- "claim",
267
- "in-progress",
268
- "resolve",
269
- "unlocked",
270
- "explicit confirmation",
271
- "frontier 为空",
272
- "frontier 为空但仍有 open tickets",
273
- "BLOCKED_GRAPH",
274
- "open ticket count = 0",
275
- "全分支相称 review",
276
- "`/verify pre-pr`",
277
- "`/pr` 或 keep",
278
- "可重新选择串行 `implement` 或安全 SDD",
279
- "不得自动关闭外部 Issue",
280
- ]);
281
-
282
- requireTokens("commands/pr.md", [
283
- "ticket reference",
284
- "does not authorize closing",
285
- ]);
286
- }
287
-
288
- function checkExecutionSupportSkills() {
289
- requireTokens("references/git-worktrees.md", [
290
- "git worktree add",
291
- "git worktree remove",
292
- "rules/05-git-workflow.md",
293
- "git status --short",
294
- ]);
295
-
296
- requireTokens("rules/common/testing.md", [
297
- "本轮",
298
- "skills/systematic-debugging/SKILL.md",
299
- "未运行",
300
- "剩余风险",
301
- ]);
302
-
303
- requireTokens("skills/feature-acceptance/SKILL.md", [
304
- "PASS / FAIL / BLOCKED / NOT RUN",
305
- "用例矩阵",
306
- "keyNodes",
307
- "evidenceMedium",
308
- "二次审核",
309
- "skills/e2e-testing/SKILL.md",
310
- "敏感信息",
311
- ]);
312
- }
313
-
314
- function checkSkillLinks() {
315
- checkRouterAndAgentLinks();
316
- checkTicketFirstDelivery();
317
- checkDebuggingSkill();
318
- checkCodeReviewContracts();
319
- checkProjectContextContracts();
320
- checkTrackerDeliveryLifecycle();
321
- checkExecutionSupportSkills();
322
- }
323
-
324
- function checkRuleLoadingPolicy() {
325
- if (!exists("AGENTS.md")) {
326
- fail("AGENTS.md is missing");
327
- return;
328
- }
329
-
330
- const agentsBody = read("AGENTS.md");
331
- if (!agentsBody.includes("规则加载策略")) {
332
- fail("AGENTS.md should include a rule loading policy section");
333
- }
334
-
335
- const forbidsFullRulesLoad =
336
- agentsBody.includes("不要默认全量加载 `rules/`") ||
337
- agentsBody.includes("不要默认全量加载`rules/`") ||
338
- agentsBody.includes("仍然只读取当前任务直接相关的规则文件");
339
-
340
- const forbidsFullCommonLoad =
341
- agentsBody.includes("不要默认全量加载 `rules/common/`") ||
342
- agentsBody.includes("不要默认全量加载`rules/common/`") ||
343
- agentsBody.includes("`rules/common/` 是专项参考区");
344
-
345
- if (!forbidsFullRulesLoad || !forbidsFullCommonLoad) {
346
- fail("AGENTS.md should forbid loading all rules by default");
347
- }
348
- if (!agentsBody.includes("~/.codex/rules/")) {
349
- fail("AGENTS.md should mention Codex user-level rules fallback");
350
- }
351
- if (!agentsBody.includes("~/.claude/rules/")) {
352
- fail("AGENTS.md should mention Claude Code user-level rules fallback");
353
- }
354
- if (!agentsBody.includes("~/.claude/references/rules/common/")) {
355
- fail("AGENTS.md should resolve Claude common rules from the cold reference directory");
356
- }
357
- if (!agentsBody.includes("不能把项目规则目录缺失等同于") || !agentsBody.includes("无规则")) {
358
- fail("AGENTS.md should forbid treating a missing project rules directory as no rules");
359
- }
360
-
361
- if (exists("CLAUDE.md")) {
362
- const claudeBody = read("CLAUDE.md");
363
- if (!claudeBody.includes("AGENTS.md")) {
364
- fail("CLAUDE.md should reference AGENTS.md");
365
- }
366
- }
367
-
368
- if (!exists("rules/08-specialty-rules-index.md")) {
369
- fail("rules/08-specialty-rules-index.md is missing");
370
- return;
371
- }
372
-
373
- const specialtyRules = read("rules/08-specialty-rules-index.md");
374
- if (!specialtyRules.includes("触发矩阵")) {
375
- fail("rules/08-specialty-rules-index.md should include a trigger matrix");
376
- }
377
- if (
378
- !specialtyRules.includes("不得因为") ||
379
- !specialtyRules.includes("可能有用") ||
380
- !specialtyRules.includes("而一次性读取完整")
381
- ) {
382
- fail(
383
- "rules/08-specialty-rules-index.md should forbid full rules loading just because it might be useful",
384
- );
385
- }
386
- }
387
-
388
65
  function runRepositoryChecks(context) {
389
- bindContext(context);
390
- checkSkillLinks();
391
- checkRuleLoadingPolicy();
66
+ checkPathReferences(context);
67
+ checkRuleLoadingPolicy(context);
392
68
  }
393
69
 
394
70
  module.exports = { runRepositoryChecks };