claude-everything-workflow 0.2.8 → 0.2.10
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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +11 -18
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/agents/e2e-runner.md +1 -1
- package/evals/routing-scenarios.json +252 -0
- package/harness/manifest.json +2 -28
- package/hooks/check-console-log.js +2 -2
- package/package.json +4 -2
- package/rules/01-base.md +2 -2
- package/rules/02-implementation.md +7 -6
- package/rules/05-git-workflow.md +4 -6
- package/rules/common/agent-orchestration.md +1 -1
- package/rules/common/pr-automation.md +1 -1
- package/rules/common/testing.md +2 -2
- package/scripts/eval-scenarios.js +108 -0
- package/scripts/install-rules.js +266 -19
- package/scripts/install.ps1 +42 -15
- package/scripts/install.sh +31 -12
- package/scripts/legacy-common-rule-hashes.json +6 -1
- package/scripts/retired-skill-files.json +7 -0
- package/scripts/verify/install-rules.test.js +158 -24
- package/scripts/verify/metadata-checks.js +7 -8
- package/scripts/verify/repository-checks.js +44 -368
- package/scripts/verify/scenario-checks.js +108 -0
- package/scripts/verify/scenario-checks.test.js +97 -0
- package/scripts/verify/workflow-checks.js +85 -586
- package/scripts/verify-harness.js +2 -0
- package/skills/README.md +2 -4
- package/skills/feature-acceptance/SKILL.md +8 -8
- package/skills/{e2e-testing/SKILL.md → feature-acceptance/references/e2e-testing.md} +3 -9
- package/skills/implement/SKILL.md +2 -0
- package/skills/{subagent-driven-development/SKILL.md → implement/references/parallel-delivery.md} +7 -9
- package/skills/implement/references/ticket-delivery.md +1 -1
- package/skills/using-superpowers/SKILL.md +24 -103
- package/rules/07-forbidden.md +0 -20
- package/rules/08-specialty-rules-index.md +0 -18
- package/rules/09-first-principles-adversarial-testing.md +0 -30
- package/scripts/verify/continuation-checks.test.js +0 -101
- package/scripts/verify/grilling-spec-gate-checks.js +0 -297
- package/scripts/verify/workflow-ownership-fixtures.js +0 -371
- package/scripts/verify/workflow-ownership.js +0 -780
- /package/skills/{e2e-testing → feature-acceptance}/references/playwright-patterns.md +0 -0
|
@@ -1,394 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
49
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
|
|
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
|
|
179
|
-
requireTokens("
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
"
|
|
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
|
-
|
|
217
|
-
"
|
|
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
|
-
|
|
390
|
-
|
|
391
|
-
checkRuleLoadingPolicy();
|
|
66
|
+
checkPathReferences(context);
|
|
67
|
+
checkRuleLoadingPolicy(context);
|
|
392
68
|
}
|
|
393
69
|
|
|
394
70
|
module.exports = { runRepositoryChecks };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { parseFrontmatter } = require("./skill-manifest-checks");
|
|
4
|
+
|
|
5
|
+
const SCENARIOS_PATH = "evals/routing-scenarios.json";
|
|
6
|
+
const MIN_SCENARIO_COUNT = 25;
|
|
7
|
+
|
|
8
|
+
function validateScenarios(data, { exists, read, manifest }) {
|
|
9
|
+
const errors = [];
|
|
10
|
+
if (!data || data.schemaVersion !== 1 || !Array.isArray(data.scenarios)) {
|
|
11
|
+
return [`${SCENARIOS_PATH} must have schemaVersion 1 and a scenarios array`];
|
|
12
|
+
}
|
|
13
|
+
if (data.scenarios.length < MIN_SCENARIO_COUNT) {
|
|
14
|
+
errors.push(`${SCENARIOS_PATH} must include at least ${MIN_SCENARIO_COUNT} scenarios (found ${data.scenarios.length})`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const registeredSkills = new Set((manifest?.skills || []).map((entry) => entry.path));
|
|
18
|
+
const routerBody = exists("skills/using-superpowers/SKILL.md") ? read("skills/using-superpowers/SKILL.md") : "";
|
|
19
|
+
const seenIds = new Set();
|
|
20
|
+
|
|
21
|
+
for (const scenario of data.scenarios) {
|
|
22
|
+
if (!scenario || typeof scenario !== "object") {
|
|
23
|
+
errors.push("scenario entry must be an object");
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const { id, prompt, expectedTarget, expectedReference, expectedLane, requiredSignals } = scenario;
|
|
27
|
+
if (!id || typeof id !== "string") {
|
|
28
|
+
errors.push("scenario is missing string id");
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (seenIds.has(id)) errors.push(`duplicate scenario id: ${id}`);
|
|
32
|
+
seenIds.add(id);
|
|
33
|
+
|
|
34
|
+
if (!prompt || typeof prompt !== "string" || prompt.trim().length < 6) {
|
|
35
|
+
errors.push(`scenario ${id} must have a non-empty prompt`);
|
|
36
|
+
}
|
|
37
|
+
if (!expectedLane || typeof expectedLane !== "string") {
|
|
38
|
+
errors.push(`scenario ${id} must declare expectedLane`);
|
|
39
|
+
}
|
|
40
|
+
if (!Array.isArray(requiredSignals) || requiredSignals.length === 0) {
|
|
41
|
+
errors.push(`scenario ${id} must declare non-empty requiredSignals`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (expectedTarget === null) {
|
|
45
|
+
for (const signal of requiredSignals || []) {
|
|
46
|
+
if (!routerBody.toLowerCase().includes(signal.toLowerCase())) {
|
|
47
|
+
errors.push(`scenario ${id}: router should cover exclusion signal "${signal}"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof expectedTarget !== "string" || !exists(expectedTarget)) {
|
|
54
|
+
errors.push(`scenario ${id}: expectedTarget does not exist: ${expectedTarget}`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (expectedTarget.startsWith("skills/") && expectedTarget.endsWith("/SKILL.md") && !registeredSkills.has(expectedTarget)) {
|
|
58
|
+
errors.push(`scenario ${id}: expectedTarget skill is not registered in harness/manifest.json: ${expectedTarget}`);
|
|
59
|
+
}
|
|
60
|
+
if (expectedReference && !exists(expectedReference)) {
|
|
61
|
+
errors.push(`scenario ${id}: expectedReference does not exist: ${expectedReference}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const targetBody = read(expectedTarget);
|
|
65
|
+
const refBody = expectedReference && exists(expectedReference) ? read(expectedReference) : "";
|
|
66
|
+
let description = "";
|
|
67
|
+
if (expectedTarget.endsWith("/SKILL.md")) {
|
|
68
|
+
const fm = parseFrontmatter(targetBody);
|
|
69
|
+
description = String(fm?.description || "");
|
|
70
|
+
}
|
|
71
|
+
const searchable = `${routerBody}\n${description}\n${targetBody}\n${refBody}`.toLowerCase();
|
|
72
|
+
for (const signal of requiredSignals || []) {
|
|
73
|
+
if (!searchable.includes(signal.toLowerCase())) {
|
|
74
|
+
errors.push(`scenario ${id}: expected route surface for ${expectedTarget} does not cover signal "${signal}"`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return errors;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function runScenarioChecks(context) {
|
|
83
|
+
const { exists, read, fail } = context;
|
|
84
|
+
if (!exists(SCENARIOS_PATH)) {
|
|
85
|
+
fail(`${SCENARIOS_PATH} is missing`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let data;
|
|
89
|
+
try {
|
|
90
|
+
data = JSON.parse(read(SCENARIOS_PATH));
|
|
91
|
+
} catch (error) {
|
|
92
|
+
fail(`${SCENARIOS_PATH} is invalid JSON: ${error.message}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let manifest = { skills: [] };
|
|
96
|
+
if (exists("harness/manifest.json")) {
|
|
97
|
+
try {
|
|
98
|
+
manifest = JSON.parse(read("harness/manifest.json"));
|
|
99
|
+
} catch {
|
|
100
|
+
// manifest syntax errors are reported by skill-manifest-checks
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
for (const error of validateScenarios(data, { exists, read, manifest })) {
|
|
104
|
+
fail(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = { SCENARIOS_PATH, MIN_SCENARIO_COUNT, validateScenarios, runScenarioChecks };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const assert = require("node:assert/strict");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const os = require("node:os");
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const { createHarnessContext } = require("./core");
|
|
9
|
+
const { SCENARIOS_PATH, validateScenarios, runScenarioChecks } = require("./scenario-checks");
|
|
10
|
+
|
|
11
|
+
const root = path.resolve(__dirname, "../..");
|
|
12
|
+
const context = createHarnessContext(root);
|
|
13
|
+
runScenarioChecks(context);
|
|
14
|
+
assert.deepEqual(context.errors, [], `scenario checks failed:\n${context.errors.join("\n")}`);
|
|
15
|
+
|
|
16
|
+
const data = JSON.parse(fs.readFileSync(path.join(root, SCENARIOS_PATH), "utf8"));
|
|
17
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(root, "harness/manifest.json"), "utf8"));
|
|
18
|
+
|
|
19
|
+
// Negative test: missing target file must fail
|
|
20
|
+
const badTargetErrors = validateScenarios(
|
|
21
|
+
{
|
|
22
|
+
schemaVersion: 1,
|
|
23
|
+
scenarios: Array.from({ length: 25 }, (_, i) =>
|
|
24
|
+
i === 0
|
|
25
|
+
? { id: "bad-target", prompt: "test missing target skill", expectedTarget: "skills/nonexistent/SKILL.md", expectedLane: "direct", requiredSignals: ["x"] }
|
|
26
|
+
: data.scenarios[i % data.scenarios.length],
|
|
27
|
+
).map((s, i) => ({ ...s, id: `${s.id}-${i}` })),
|
|
28
|
+
},
|
|
29
|
+
{ exists: context.exists, read: context.read, manifest },
|
|
30
|
+
);
|
|
31
|
+
assert.ok(badTargetErrors.some((e) => e.includes("does not exist")), "missing target must fail");
|
|
32
|
+
|
|
33
|
+
// Negative test: too few scenarios must fail
|
|
34
|
+
const tooFewErrors = validateScenarios(
|
|
35
|
+
{ schemaVersion: 1, scenarios: data.scenarios.slice(0, 5) },
|
|
36
|
+
{ exists: context.exists, read: context.read, manifest },
|
|
37
|
+
);
|
|
38
|
+
assert.ok(tooFewErrors.some((e) => e.includes("at least")), "too few scenarios must fail");
|
|
39
|
+
|
|
40
|
+
// Exercise the evaluator CLI with a stand-in executable at the external host boundary.
|
|
41
|
+
function checkEvalCli() {
|
|
42
|
+
const bin = fs.mkdtempSync(path.join(os.tmpdir(), "cew-eval-test-"));
|
|
43
|
+
const stub = `#!/usr/bin/env node
|
|
44
|
+
const fs = require("node:fs");
|
|
45
|
+
fs.writeFileSync(process.env.PROMPT_FILE, process.argv.at(-1));
|
|
46
|
+
const output = process.argv.indexOf("--output-last-message");
|
|
47
|
+
if (output >= 0) fs.writeFileSync(process.argv[output + 1], process.env.FINAL);
|
|
48
|
+
process.stdout.write(process.env.STDOUT);
|
|
49
|
+
process.stderr.write(process.env.STDERR);
|
|
50
|
+
process.exitCode = Number(process.env.HOST_STATUS);
|
|
51
|
+
`;
|
|
52
|
+
const promptFile = path.join(bin, "prompt.txt");
|
|
53
|
+
try {
|
|
54
|
+
for (const host of ["claude", "codex"]) {
|
|
55
|
+
fs.writeFileSync(path.join(bin, host), stub, { mode: 0o755 });
|
|
56
|
+
}
|
|
57
|
+
const target = "skills/implement/SKILL.md";
|
|
58
|
+
const correct = JSON.stringify({ target });
|
|
59
|
+
const excluded = JSON.stringify({ target: "NONE", reason: `Do not choose ${target}` });
|
|
60
|
+
const run = (host, id, final, expectedStatus, diagnostics = "", hostStatus = 0) => {
|
|
61
|
+
const result = spawnSync(process.execPath, ["scripts/eval-scenarios.js", "--host", host, "--id", id], {
|
|
62
|
+
cwd: root, encoding: "utf8",
|
|
63
|
+
env: { ...process.env, PATH: bin + path.delimiter + process.env.PATH, FINAL: final, PROMPT_FILE: promptFile,
|
|
64
|
+
STDOUT: host === "codex" ? correct : final, STDERR: diagnostics, HOST_STATUS: String(hostStatus) },
|
|
65
|
+
});
|
|
66
|
+
assert.ifError(result.error);
|
|
67
|
+
assert.equal(result.status, expectedStatus, `${host} ${id}: ${result.stdout} ${result.stderr}`);
|
|
68
|
+
assert.match(result.stdout, expectedStatus === 0 ? /^PASS /m : /^FAIL /m);
|
|
69
|
+
};
|
|
70
|
+
for (const host of ["claude", "codex"]) {
|
|
71
|
+
run(host, "direct-small-change", excluded, 1, correct);
|
|
72
|
+
run(host, "direct-small-change", "NONE. Do not choose implement.", 1);
|
|
73
|
+
run(host, "direct-small-change", "{}", 1, correct);
|
|
74
|
+
run(host, "direct-small-change", correct, 0);
|
|
75
|
+
const prompt = fs.readFileSync(promptFile, "utf8");
|
|
76
|
+
assert.ok(!prompt.includes("第一个 Skill 或规则"), "the host question must not ask for the first routing hop");
|
|
77
|
+
assert.ok(!prompt.includes(target), "keep the expected answer out of the host prompt");
|
|
78
|
+
const router = JSON.stringify({ target: "skills/using-superpowers/SKILL.md" });
|
|
79
|
+
run(host, "direct-small-change", router, 1);
|
|
80
|
+
run(host, "workflow-advice", router, 0);
|
|
81
|
+
run(host, "direct-small-change", correct, 1, "", 1);
|
|
82
|
+
run(host, "non-eng-translate", JSON.stringify({ target: "NONE" }), 0);
|
|
83
|
+
const debug = JSON.stringify({ target: "skills/systematic-debugging/SKILL.md" });
|
|
84
|
+
const acceptance = JSON.stringify({ target: "skills/feature-acceptance/SKILL.md" });
|
|
85
|
+
run(host, "e2e-flaky-fix", debug, 0);
|
|
86
|
+
run(host, "e2e-flaky-fix", acceptance, 1);
|
|
87
|
+
run(host, "e2e-playwright-tests", acceptance, 0);
|
|
88
|
+
}
|
|
89
|
+
} finally {
|
|
90
|
+
fs.rmSync(bin, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// These executable shims use POSIX shebangs, as do the Linux and macOS CI jobs.
|
|
95
|
+
if (process.platform !== "win32") checkEvalCli();
|
|
96
|
+
|
|
97
|
+
console.log(`Scenario checks tests passed (${data.scenarios.length} routing scenarios verified).`);
|