claude-everything-workflow 0.1.8 → 0.2.2

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 (132) hide show
  1. package/AGENTS.md +19 -20
  2. package/README.md +112 -104
  3. package/agents/code-reviewer.md +15 -44
  4. package/agents/harness-optimizer.md +3 -2
  5. package/agents/planner.md +23 -107
  6. package/commands/code-review.md +25 -9
  7. package/commands/learn.md +97 -0
  8. package/commands/pr.md +4 -0
  9. package/commands/to-spec.md +11 -0
  10. package/hooks/check-code-size.js +33 -12
  11. package/hooks/check-console-log.js +72 -24
  12. package/package.json +5 -2
  13. package/rules/01-base.md +19 -42
  14. package/rules/02-code-size.md +6 -17
  15. package/rules/03-architecture.md +16 -54
  16. package/rules/04-error-handling.md +4 -25
  17. package/rules/05-git-workflow.md +9 -37
  18. package/rules/06-comments.md +3 -37
  19. package/rules/07-forbidden.md +6 -30
  20. package/rules/08-specialty-rules-index.md +18 -0
  21. package/rules/09-first-principles-adversarial-testing.md +6 -18
  22. package/rules/common/agent-orchestration.md +10 -47
  23. package/rules/common/context-hygiene.md +9 -72
  24. package/rules/common/harness-engineering.md +11 -38
  25. package/rules/common/hooks.md +11 -82
  26. package/rules/common/performance.md +8 -71
  27. package/rules/common/pr-automation.md +7 -68
  28. package/rules/common/skills-learning.md +12 -36
  29. package/rules/common/testing.md +15 -59
  30. package/scripts/cleanup-retired-skills.js +214 -0
  31. package/scripts/install.ps1 +73 -85
  32. package/scripts/install.sh +54 -77
  33. package/scripts/learning/review-confidence.js +1 -4
  34. package/scripts/merge-claude-settings.cjs +75 -0
  35. package/scripts/retired-skill-files.json +37 -0
  36. package/scripts/upstream-capability-baseline.json +27 -0
  37. package/scripts/upstream-capability-map.json +150 -0
  38. package/scripts/verify/core.js +91 -0
  39. package/scripts/verify/grilling-spec-gate-checks.js +260 -0
  40. package/scripts/verify/metadata-checks.js +724 -0
  41. package/scripts/verify/repository-checks.js +435 -0
  42. package/scripts/verify/runtime-checks.js +593 -0
  43. package/scripts/verify/workflow-checks.js +741 -0
  44. package/scripts/verify/workflow-ownership-fixtures.js +371 -0
  45. package/scripts/verify/workflow-ownership.js +780 -0
  46. package/scripts/verify-harness.js +16 -1075
  47. package/scripts/verify-upstream-capability-map.js +117 -0
  48. package/skills/README.md +24 -10
  49. package/skills/code-review/SKILL.md +50 -0
  50. package/skills/code-review/references/spec-reviewer-prompt.md +24 -0
  51. package/skills/code-review/references/standards-reviewer-prompt.md +35 -0
  52. package/skills/codebase-design/SKILL.md +63 -0
  53. package/skills/codebase-design/references/deepening.md +27 -0
  54. package/skills/codebase-design/references/design-it-twice.md +17 -0
  55. package/skills/continuous-learning-v2/SKILL.md +7 -7
  56. package/skills/continuous-learning-v2/config.json +0 -4
  57. package/skills/domain-modeling/SKILL.md +100 -0
  58. package/skills/feature-acceptance/SKILL.md +89 -0
  59. package/skills/grilling/SKILL.md +83 -0
  60. package/skills/handoff/SKILL.md +56 -0
  61. package/skills/implement/SKILL.md +97 -0
  62. package/skills/improve-codebase-architecture/SKILL.md +48 -0
  63. package/skills/iterative-retrieval/SKILL.md +10 -1
  64. package/skills/learn/README.md +2 -2
  65. package/skills/project-context/SKILL.md +94 -0
  66. package/skills/project-context/agents/openai.yaml +6 -0
  67. package/skills/project-context/references/project-context-template.md +61 -0
  68. package/skills/prototype/SKILL.md +50 -0
  69. package/skills/prototype/references/logic.md +28 -0
  70. package/skills/prototype/references/ui.md +30 -0
  71. package/skills/research/SKILL.md +48 -0
  72. package/skills/resolving-merge-conflicts/SKILL.md +27 -0
  73. package/skills/spec-gate/SKILL.md +149 -0
  74. package/skills/spec-gate/agents/openai.yaml +4 -0
  75. package/skills/spec-gate/references/spec-document-reviewer-prompt.md +31 -0
  76. package/skills/subagent-driven-development/SKILL.md +95 -414
  77. package/skills/systematic-debugging/SKILL.md +7 -51
  78. package/skills/systematic-debugging/references/diagnosing-bugs.upstream.md +129 -0
  79. package/skills/systematic-debugging/scripts/hitl-loop.template.js +75 -0
  80. package/skills/systematic-debugging/scripts/hitl-loop.template.sh +41 -0
  81. package/skills/test-driven-development/SKILL.md +18 -2
  82. package/skills/to-tickets/SKILL.md +94 -0
  83. package/skills/triage/SKILL.md +53 -0
  84. package/skills/triage/references/agent-brief.md +32 -0
  85. package/skills/triage/references/out-of-scope.md +14 -0
  86. package/skills/using-superpowers/SKILL.md +140 -40
  87. package/skills/visual-companion/SKILL.md +62 -0
  88. package/skills/visual-companion/agents/openai.yaml +4 -0
  89. package/skills/{brainstorming/visual-companion.md → visual-companion/references/guide.md} +1 -1
  90. package/skills/{brainstorming → visual-companion}/scripts/frame-template.html +42 -12
  91. package/skills/visual-companion/scripts/pages.cjs +28 -0
  92. package/skills/visual-companion/scripts/server-utils.cjs +82 -0
  93. package/skills/{brainstorming → visual-companion}/scripts/server.cjs +108 -248
  94. package/skills/{brainstorming → visual-companion}/scripts/start-server.sh +18 -4
  95. package/skills/visual-companion/scripts/websocket.cjs +86 -0
  96. package/skills/wayfinder/SKILL.md +57 -0
  97. package/commands/e2e.md +0 -28
  98. package/commands/evolve.md +0 -42
  99. package/commands/harness-audit.md +0 -27
  100. package/commands/instinct-status.md +0 -38
  101. package/commands/learn-eval.md +0 -91
  102. package/commands/projects.md +0 -27
  103. package/commands/promote.md +0 -29
  104. package/commands/prune.md +0 -46
  105. package/commands/tdd.md +0 -27
  106. package/homunculus/instincts/personal/always-test-first.md +0 -28
  107. package/homunculus/instincts/personal/pr-ci-quality-gate.md +0 -30
  108. package/rules/08-ecc-integration.md +0 -46
  109. package/rules/common/implementation.md +0 -25
  110. package/rules/common/security.md +0 -19
  111. package/skills/brainstorming/SKILL.md +0 -185
  112. package/skills/brainstorming/agents/openai.yaml +0 -3
  113. package/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  114. package/skills/context-budget/SKILL.md +0 -59
  115. package/skills/documentation-lookup/SKILL.md +0 -90
  116. package/skills/executing-plans/SKILL.md +0 -66
  117. package/skills/skill-creator/LICENSE.txt +0 -202
  118. package/skills/skill-creator/SKILL.md +0 -356
  119. package/skills/skill-creator/references/output-patterns.md +0 -82
  120. package/skills/skill-creator/references/workflows.md +0 -28
  121. package/skills/skill-creator/scripts/init_skill.py +0 -303
  122. package/skills/skill-creator/scripts/package_skill.py +0 -110
  123. package/skills/skill-creator/scripts/quick_validate.py +0 -95
  124. package/skills/subagent-driven-development/implementer-prompt.md +0 -139
  125. package/skills/subagent-driven-development/scripts/review-package +0 -44
  126. package/skills/subagent-driven-development/scripts/sdd-workspace +0 -22
  127. package/skills/subagent-driven-development/scripts/task-brief +0 -40
  128. package/skills/subagent-driven-development/task-reviewer-prompt.md +0 -188
  129. package/skills/writing-plans/SKILL.md +0 -206
  130. package/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
  131. /package/skills/{brainstorming → visual-companion}/scripts/helper.js +0 -0
  132. /package/skills/{brainstorming → visual-companion}/scripts/stop-server.sh +0 -0
@@ -0,0 +1,741 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { spawnSync } = require("child_process");
5
+ const { runGrillingSpecGateChecks } = require("./grilling-spec-gate-checks");
6
+ const { runWorkflowOwnershipChecks } = require("./workflow-ownership");
7
+
8
+ let root;
9
+ let exists;
10
+ let read;
11
+ let managedFiles;
12
+ let fail;
13
+ let requireTokens;
14
+ let isVerifierImplementation;
15
+
16
+ function bindContext(context) {
17
+ ({
18
+ root,
19
+ exists,
20
+ read,
21
+ managedFiles,
22
+ fail,
23
+ requireTokens,
24
+ isVerifierImplementation,
25
+ } = context);
26
+ }
27
+
28
+ function checkReadmeWorkflowContract() {
29
+ requireTokens("README.md", [
30
+ "Ticket-first 工程交付闭环",
31
+ "using-superpowers",
32
+ "?key=",
33
+ "4 小时",
34
+ "using-git-worktrees",
35
+ "iterative-retrieval",
36
+ "to-tickets",
37
+ "implement",
38
+ "subagent-driven-development",
39
+ "verification-before-completion",
40
+ "完整流程适用时",
41
+ "没有批准的必需 Spec 不进入 ticket 或 implement",
42
+ "没有用户审核不进入实现",
43
+ "没有 failing test,不写行为代码",
44
+ "没有 review 不标记任务完成",
45
+ "没有新鲜验证证据,不声明完成、通过、已修复或 ready",
46
+ "没有 verify,不进入 PR",
47
+ "`/learn eval --preview` 是非阻塞学习建议门",
48
+ ]);
49
+ }
50
+
51
+ function checkSuperpowersDevLoop() {
52
+ checkReadmeWorkflowContract();
53
+
54
+ requireTokens("rules/01-base.md", [
55
+ "## 最小且正确的实现",
56
+ "先理解真实调用链",
57
+ "必要性",
58
+ "复用现有实现",
59
+ "标准库或平台原生能力",
60
+ "已安装依赖",
61
+ "最小新增代码",
62
+ "skills/using-superpowers/SKILL.md",
63
+ ]);
64
+
65
+ requireTokens("rules/common/skills-learning.md", [
66
+ "skills/using-superpowers/SKILL.md",
67
+ "路由权威来源",
68
+ "rules/01-base.md",
69
+ "rules/common/agent-orchestration.md",
70
+ "不凭记忆执行 skill",
71
+ ]);
72
+
73
+ requireTokens("skills/spec-gate/SKILL.md", [
74
+ "# Spec Gate",
75
+ "READY_FOR_USER_REVIEW",
76
+ "User Review Gate",
77
+ ]);
78
+
79
+ requireTokens("skills/to-tickets/SKILL.md", [
80
+ "tracer bullet",
81
+ "blocking edges",
82
+ "fresh context",
83
+ "file paths",
84
+ "code snippets",
85
+ ]);
86
+
87
+ requireTokens("skills/implement/SKILL.md", [
88
+ "一个 fresh context",
89
+ "test-driven-development",
90
+ "ticket as the Spec source",
91
+ ]);
92
+
93
+ requireTokens("skills/subagent-driven-development/SKILL.md", [
94
+ "frontier ticket",
95
+ "fresh subagent",
96
+ "one ticket",
97
+ "Do not generate a detailed implementation plan",
98
+ "controller-owned integration worktree",
99
+ "integrate-and-verify gate",
100
+ "task-owned untracked files",
101
+ "every selected ticket body as the combined Spec source",
102
+ ]);
103
+
104
+ requireTokens("skills/test-driven-development/SKILL.md", [
105
+ "## Red Test Gate",
106
+ "失败测试",
107
+ "替代验证",
108
+ ]);
109
+
110
+ requireTokens("commands/verify.md", [
111
+ "Verify Gate",
112
+ "已运行检查",
113
+ "未运行检查",
114
+ "是否可以进入 `/pr`",
115
+ ]);
116
+
117
+ requireTokens("commands/pr.md", [
118
+ "PR Gate",
119
+ "`/verify` 或等价验证结果",
120
+ "先回到验证和修复阶段",
121
+ ]);
122
+ }
123
+
124
+ function checkSpecVisualContracts() {
125
+ requireTokens("skills/spec-gate/SKILL.md", [
126
+ "docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md",
127
+ "Self-Review",
128
+ ]);
129
+
130
+ requireTokens("skills/visual-companion/references/guide.md", [
131
+ "session key",
132
+ "?key=",
133
+ "4 hours idle",
134
+ "--idle-timeout-minutes",
135
+ "same port",
136
+ ]);
137
+
138
+ requireTokens("skills/visual-companion/scripts/server.cjs", [
139
+ "BRAINSTORM_TOKEN",
140
+ "BRAINSTORM_TOKEN_FILE",
141
+ "Default 4 hours",
142
+ ]);
143
+
144
+ requireTokens("skills/visual-companion/scripts/server-utils.cjs", [
145
+ "timingSafeEqualStr",
146
+ "Cache-Control",
147
+ "X-Frame-Options",
148
+ ]);
149
+
150
+ requireTokens("skills/visual-companion/scripts/start-server.sh", [
151
+ "--idle-timeout-minutes",
152
+ "BRAINSTORM_TOKEN_FILE",
153
+ "umask 077",
154
+ ".last-token",
155
+ ]);
156
+ }
157
+
158
+ function checkSuperpowersArtifactPolicy() {
159
+ requireTokens("rules/05-git-workflow.md", [
160
+ "## Superpowers 本地工件",
161
+ "Superpowers 生成的 Spec 和本地 tickets 仅用于本地工作流",
162
+ "无论保存位置都不得暂存或提交",
163
+ ]);
164
+ requireTokens("skills/spec-gate/SKILL.md", [
165
+ "Local-only artifact policy",
166
+ "Treat every generated design Spec as a local workflow artifact",
167
+ "Do not stage or commit it.",
168
+ ]);
169
+ requireTokens("skills/to-tickets/SKILL.md", ["Local tracker", "one file per ticket"]);
170
+
171
+ const repoRoot = spawnSync("git", ["rev-parse", "--show-toplevel"], {
172
+ cwd: root,
173
+ encoding: "utf8",
174
+ timeout: 30000,
175
+ });
176
+
177
+ if (
178
+ repoRoot.status !== 0 ||
179
+ path.resolve(repoRoot.stdout.trim()) !== path.resolve(root)
180
+ ) {
181
+ return;
182
+ }
183
+
184
+ requireTokens(".gitignore", ["/docs/superpowers/"]);
185
+
186
+ const tracked = spawnSync("git", ["ls-files", "docs/superpowers"], {
187
+ cwd: root,
188
+ encoding: "utf8",
189
+ timeout: 30000,
190
+ });
191
+
192
+ if (tracked.status !== 0) {
193
+ fail(`unable to inspect tracked Superpowers artifacts: ${tracked.stderr}`);
194
+ } else if (tracked.stdout.trim()) {
195
+ fail(
196
+ `docs/superpowers artifacts must not be tracked:\n${tracked.stdout.trim()}`,
197
+ );
198
+ }
199
+ }
200
+
201
+ function checkGrillingCoreContracts() {
202
+ requireTokens("skills/grilling/SKILL.md", [
203
+ "one question per turn",
204
+ "recommended answer",
205
+ "reversal evidence",
206
+ "shared understanding",
207
+ "Do not ask for discoverable facts",
208
+ "Inline uncertainty mode",
209
+ "Explicit grilling session",
210
+ "Route context:",
211
+ "Risk classification:",
212
+ "Resume target:",
213
+ "Reversal evidence:",
214
+ "return to `skills/using-superpowers/SKILL.md` for routing",
215
+ "Existing Confirmed Handoff",
216
+ "Do not re-ask them",
217
+ "recorded reversal evidence appears",
218
+ ]);
219
+ requireTokens("skills/using-superpowers/SKILL.md", [
220
+ "discoverable fact",
221
+ "user-owned decision",
222
+ "skills/grilling/SKILL.md",
223
+ "shortest applicable path",
224
+ "explicit formal Spec",
225
+ "high-risk boundary",
226
+ ]);
227
+ }
228
+
229
+ function checkRouteOrdering() {
230
+ const router = read("skills/using-superpowers/SKILL.md");
231
+ const inlineRoute = router.indexOf("unresolved user-owned decision?");
232
+ const specRoute = router.indexOf("explicit formal Spec or high-risk boundary?");
233
+ if (
234
+ inlineRoute === -1 ||
235
+ specRoute === -1 ||
236
+ inlineRoute > specRoute
237
+ ) {
238
+ fail(
239
+ "router should resolve a real user decision before entering formal Spec Gate",
240
+ );
241
+ }
242
+
243
+ const grillingContract = read("skills/grilling/SKILL.md");
244
+ if (
245
+ /^\s*(?:recommended )?next skill:/im.test(grillingContract) ||
246
+ /^\s*推荐下一 skill:/m.test(grillingContract)
247
+ ) {
248
+ fail(
249
+ "skills/grilling/SKILL.md should return routing responsibility instead of recommending the next skill",
250
+ );
251
+ }
252
+ }
253
+
254
+ function checkWorkflowDocuments() {
255
+ runWorkflowOwnershipChecks({ read, fail, managedFiles });
256
+ requireTokens("skills/iterative-retrieval/SKILL.md", [
257
+ "事实、证据和盲点缺口",
258
+ "低成本",
259
+ "复杂、高风险、多文件或长周期",
260
+ "skills/grilling/SKILL.md",
261
+ "skills/spec-gate/SKILL.md",
262
+ "返回 `skills/using-superpowers/SKILL.md`",
263
+ ]);
264
+ requireTokens("rules/01-base.md", [
265
+ "默认走最短适用闭环",
266
+ "多文件、新功能、普通行为变化和复杂度本身都不是完整流程触发条件",
267
+ "高风险边界",
268
+ "rules/common/testing.md",
269
+ "skills/using-superpowers/SKILL.md",
270
+ ]);
271
+ requireTokens("rules/common/testing.md", [
272
+ "隔离端口和环境变量",
273
+ "等待 Web/API ready",
274
+ ]);
275
+ requireTokens("rules/common/context-hygiene.md", [
276
+ "任何外部 mutation",
277
+ "发送消息",
278
+ "写入云文档",
279
+ ]);
280
+ requireTokens("rules/common/hooks.md", [
281
+ "敏感内容只记录风险和证据位置",
282
+ ]);
283
+ requireTokens("rules/common/pr-automation.md", [
284
+ "失败检查不得跳过",
285
+ "Git/PR 操作按 `rules/05-git-workflow.md` 的授权边界执行",
286
+ ]);
287
+ for (const file of [
288
+ "rules/common/context-hygiene.md",
289
+ "rules/common/harness-engineering.md",
290
+ "rules/common/performance.md",
291
+ ]) {
292
+ requireTokens(file, ["rules/common/agent-orchestration.md"]);
293
+ }
294
+ requireTokens("rules/common/skills-learning.md", [
295
+ "路由权威来源",
296
+ "不要因为多文件或普通复杂度加载完整 process skill 链",
297
+ "rules/01-base.md",
298
+ "rules/common/agent-orchestration.md",
299
+ ]);
300
+ requireTokens("agents/planner.md", ["to-tickets", "不写文件路径"]);
301
+ }
302
+
303
+ function checkComplexityRules() {
304
+ const baseRules = read("rules/01-base.md");
305
+ if (
306
+ baseRules.includes(
307
+ "复杂任务包括新功能、架构调整、多文件行为变化",
308
+ )
309
+ ) {
310
+ fail(
311
+ "rules/01-base.md should not classify new or multi-file behavior work as full-flow by default",
312
+ );
313
+ }
314
+ requireTokens("README.md", [
315
+ "直接提出 grilling 请求",
316
+ "`/to-spec`",
317
+ "`grilling` 是唯一需求澄清引擎",
318
+ "默认最短闭环",
319
+ "按风险逐级升级",
320
+ "完整流程适用时",
321
+ "明确低风险且无未决决策",
322
+ ]);
323
+ }
324
+
325
+ function checkGrillingWorkflow() {
326
+ checkGrillingCoreContracts();
327
+ checkRouteOrdering();
328
+ checkWorkflowDocuments();
329
+ checkComplexityRules();
330
+ }
331
+
332
+ function checkSuperpowersRoutingConsistency() {
333
+ requireTokens("skills/iterative-retrieval/SKILL.md", [
334
+ "返回 `skills/using-superpowers/SKILL.md` 重新路由",
335
+ "不要自行枚举或调用下一 skill",
336
+ ]);
337
+ requireTokens("skills/using-superpowers/SKILL.md", [
338
+ "explicit formal Spec",
339
+ "high-risk boundary",
340
+ "unresolved user-owned decision?",
341
+ "skills/grilling/SKILL.md",
342
+ ]);
343
+ requireTokens("skills/spec-gate/SKILL.md", [
344
+ "zero interview",
345
+ "BLOCKED_BY_UNRESOLVED_DECISION",
346
+ "Spec Gate contract conflict",
347
+ ]);
348
+
349
+ const retrieval = read("skills/iterative-retrieval/SKILL.md");
350
+ for (const staleRoute of [
351
+ "交接到 `brainstorming`、`test-driven-development` 或 `executing-plans` skill",
352
+ "再进入 `brainstorming`、`test-driven-development` 或 `executing-plans`",
353
+ ]) {
354
+ if (retrieval.includes(staleRoute)) {
355
+ fail(
356
+ "skills/iterative-retrieval/SKILL.md should return to the router " +
357
+ `instead of enumerating follow-up skills: ${staleRoute}`,
358
+ );
359
+ }
360
+ }
361
+
362
+ }
363
+
364
+ function readCapabilityManifest(manifestPath) {
365
+ if (!exists(manifestPath)) {
366
+ fail(`${manifestPath} is missing`);
367
+ return null;
368
+ }
369
+ try {
370
+ return JSON.parse(read(manifestPath));
371
+ } catch (error) {
372
+ fail(`${manifestPath} is not valid JSON: ${error.message}`);
373
+ return null;
374
+ }
375
+ }
376
+
377
+ function checkCapabilityManifestHeader(manifest, manifestPath) {
378
+ const valid =
379
+ manifest.schema_version === 1 &&
380
+ manifest.upstream?.repository === "https://github.com/mattpocock/skills" &&
381
+ /^[0-9a-f]{40}$/.test(manifest.upstream?.commit || "") &&
382
+ manifest.upstream?.baseline === "promoted-engineering";
383
+ if (!valid) fail(`${manifestPath} has an invalid upstream contract`);
384
+ }
385
+
386
+ function checkCapabilityEntries(manifest, manifestPath) {
387
+ const expected = [
388
+ "ask-matt", "code-review", "codebase-design", "diagnosing-bugs",
389
+ "domain-modeling", "grill-with-docs", "implement",
390
+ "improve-codebase-architecture", "prototype", "research",
391
+ "resolving-merge-conflicts", "setup-matt-pocock-skills", "tdd",
392
+ "to-spec", "to-tickets", "triage", "wayfinder",
393
+ ].sort();
394
+ const capabilities = Array.isArray(manifest.capabilities)
395
+ ? manifest.capabilities
396
+ : [];
397
+ const actual = capabilities.map((entry) => entry.upstream).sort();
398
+ if (JSON.stringify(actual) !== JSON.stringify(expected)) {
399
+ fail(`${manifestPath} must map all 17 promoted engineering capabilities`);
400
+ }
401
+ for (const entry of capabilities) {
402
+ if (!["covered", "adapted"].includes(entry.status)) {
403
+ fail(`${entry.upstream} is not capability-equivalent: ${entry.status}`);
404
+ }
405
+ if (!Array.isArray(entry.evidence) || entry.evidence.length === 0) {
406
+ fail(`${entry.upstream} has no local evidence files`);
407
+ continue;
408
+ }
409
+ for (const file of entry.evidence) {
410
+ if (!exists(file)) fail(`${entry.upstream} evidence is missing: ${file}`);
411
+ }
412
+ }
413
+ }
414
+
415
+ function checkCapabilitySupportDependencies(manifest, manifestPath) {
416
+ const dependencies = Array.isArray(manifest.support_dependencies)
417
+ ? manifest.support_dependencies
418
+ : [];
419
+ const handoff = dependencies.find((entry) => entry.upstream === "handoff");
420
+ const valid =
421
+ handoff?.source_group === "productivity" &&
422
+ ["covered", "adapted"].includes(handoff.status) &&
423
+ handoff.evidence?.includes("skills/handoff/SKILL.md") &&
424
+ !handoff.evidence?.includes("commands/handoff.md");
425
+ if (!valid) {
426
+ fail(`${manifestPath} must map the engineering flow's handoff dependency`);
427
+ }
428
+ }
429
+
430
+ function checkCapabilityRouting() {
431
+ requireTokens("skills/using-superpowers/SKILL.md", [
432
+ "explicit workflow advice?",
433
+ "workflow advice mode",
434
+ "explicit TDD request?",
435
+ "agents/tdd-guide.md",
436
+ "explicit E2E or Playwright request?",
437
+ "skills/e2e-testing/SKILL.md",
438
+ "agents/e2e-runner.md",
439
+ "explicit harness audit?",
440
+ "agents/harness-optimizer.md",
441
+ "Agent-selected Delivery Topology",
442
+ "delivery request in defined scope?",
443
+ "independent frontier tickets with no overlapping write surface?",
444
+ "skills/implement/SKILL.md",
445
+ "skills/subagent-driven-development/SKILL.md",
446
+ "explicit prototype or runnable design question?",
447
+ "skills/prototype/SKILL.md",
448
+ "primary-source research or cited research artifact?",
449
+ "skills/research/SKILL.md",
450
+ "huge effort beyond one session?",
451
+ "skills/wayfinder/SKILL.md",
452
+ "skills/to-tickets/SKILL.md",
453
+ "merge or rebase conflict?",
454
+ "skills/resolving-merge-conflicts/SKILL.md",
455
+ "fresh session or prototype branch?",
456
+ "skills/handoff/SKILL.md",
457
+ ]);
458
+
459
+ const router = read("skills/using-superpowers/SKILL.md");
460
+ for (const staleGate of [
461
+ "User-invoked Delivery Gates",
462
+ "recommend `to-tickets`; wait for explicit invocation",
463
+ "recommend `implement`; wait for explicit invocation",
464
+ ]) {
465
+ if (router.includes(staleGate)) {
466
+ fail(`router must not retain the obsolete user-invoked delivery gate: ${staleGate}`);
467
+ }
468
+ }
469
+
470
+ for (const deliverySkill of [
471
+ "skills/to-tickets/SKILL.md",
472
+ "skills/implement/SKILL.md",
473
+ "skills/subagent-driven-development/SKILL.md",
474
+ ]) {
475
+ if (read(deliverySkill).includes("disable-model-invocation: true")) {
476
+ fail(`${deliverySkill} must remain router-selectable for delivery topology`);
477
+ }
478
+ }
479
+ }
480
+
481
+ function checkCapabilityFiles() {
482
+ for (const file of [
483
+ "skills/codebase-design/SKILL.md",
484
+ "skills/handoff/SKILL.md",
485
+ "skills/implement/SKILL.md",
486
+ "skills/improve-codebase-architecture/SKILL.md",
487
+ "skills/prototype/SKILL.md",
488
+ "skills/research/SKILL.md",
489
+ "skills/resolving-merge-conflicts/SKILL.md",
490
+ "skills/to-tickets/SKILL.md",
491
+ "skills/triage/SKILL.md",
492
+ "skills/wayfinder/SKILL.md",
493
+ ]) {
494
+ if (!exists(file)) fail(`${file} is missing`);
495
+ }
496
+
497
+ for (const file of [
498
+ "commands/ask-workflow.md",
499
+ "commands/e2e.md",
500
+ "commands/evolve.md",
501
+ "commands/grill.md",
502
+ "commands/grill-with-docs.md",
503
+ "commands/handoff.md",
504
+ "commands/harness-audit.md",
505
+ "commands/implement.md",
506
+ "commands/improve-codebase-architecture.md",
507
+ "commands/instinct-status.md",
508
+ "commands/learn-eval.md",
509
+ "commands/projects.md",
510
+ "commands/promote.md",
511
+ "commands/prune.md",
512
+ "commands/setup-workflow.md",
513
+ "commands/tdd.md",
514
+ "commands/to-tickets.md",
515
+ "commands/triage.md",
516
+ "commands/wayfinder.md",
517
+ ]) {
518
+ if (exists(file)) fail(`${file} is a redundant Skill wrapper`);
519
+ }
520
+ }
521
+
522
+ function checkDesignCapabilityContracts() {
523
+ requireTokens("skills/codebase-design/SKILL.md", [
524
+ "Module",
525
+ "Interface",
526
+ "Seam",
527
+ "Adapter",
528
+ "Leverage",
529
+ "Locality",
530
+ "deletion test",
531
+ "interface as the test surface",
532
+ ]);
533
+ requireTokens("skills/improve-codebase-architecture/SKILL.md", [
534
+ "disable-model-invocation: true",
535
+ "deepening opportunities",
536
+ "skills/codebase-design/SKILL.md",
537
+ "skills/visual-companion/SKILL.md",
538
+ "explicit consent",
539
+ "skills/grilling/SKILL.md",
540
+ ]);
541
+ requireTokens("skills/prototype/SKILL.md", [
542
+ "Logic",
543
+ "Visual",
544
+ "throwaway",
545
+ "one command to run",
546
+ "Do not silently continue into production code",
547
+ ]);
548
+ requireTokens("skills/prototype/references/ui.md", [
549
+ "runnable in-project UI prototype",
550
+ "?variant=",
551
+ "real read-only data",
552
+ "production builds",
553
+ "exact URLs",
554
+ ]);
555
+ }
556
+
557
+ function checkDeliveryCapabilityContracts() {
558
+ requireTokens("skills/research/SKILL.md", [
559
+ "background subagent",
560
+ "primary sources",
561
+ "citing each claim",
562
+ "Markdown report",
563
+ ".unknowns/",
564
+ ]);
565
+ requireTokens("skills/resolving-merge-conflicts/SKILL.md", [
566
+ "primary sources",
567
+ "one hunk at a time",
568
+ "Do not abort",
569
+ "Git authorization",
570
+ ]);
571
+ requireTokens("skills/to-tickets/SKILL.md", [
572
+ "tracer bullet",
573
+ "blocking edges",
574
+ "vertical",
575
+ "Do not publish before approval",
576
+ "ready-for-agent",
577
+ ]);
578
+ requireTokens("skills/triage/SKILL.md", [
579
+ "disable-model-invocation: true",
580
+ "needs-triage",
581
+ "needs-info",
582
+ "ready-for-agent",
583
+ "ready-for-human",
584
+ "wontfix",
585
+ "generated by AI during triage",
586
+ "obtain confirmation",
587
+ ]);
588
+ requireTokens("skills/wayfinder/SKILL.md", [
589
+ "disable-model-invocation: true",
590
+ "Destination",
591
+ "Decisions so far",
592
+ "Not yet specified",
593
+ "frontier",
594
+ "one ticket per session",
595
+ "WAY_CLEAR",
596
+ "to-tickets",
597
+ ]);
598
+ requireTokens("skills/test-driven-development/SKILL.md", [
599
+ "Public Seam",
600
+ "测试和调用方应穿过同一个 seam",
601
+ "固定事实",
602
+ "真实系统边界",
603
+ "tracer bullet",
604
+ ]);
605
+ requireTokens("skills/handoff/SKILL.md", [
606
+ "disable-model-invocation: true",
607
+ "temporary directory",
608
+ "private subdirectory",
609
+ "0700",
610
+ "exclusive creation",
611
+ "0600",
612
+ "delete the handoff after consumption",
613
+ "fresh session",
614
+ "Suggested skills",
615
+ "Do not duplicate",
616
+ "Redact",
617
+ "exact path",
618
+ ]);
619
+ }
620
+
621
+ function checkUpstreamCapabilityParity() {
622
+ const manifestPath = "scripts/upstream-capability-map.json";
623
+ const manifest = readCapabilityManifest(manifestPath);
624
+ if (!manifest) return;
625
+ checkCapabilityManifestHeader(manifest, manifestPath);
626
+ checkCapabilityEntries(manifest, manifestPath);
627
+ checkCapabilitySupportDependencies(manifest, manifestPath);
628
+ checkCapabilityRouting();
629
+ checkCapabilityFiles();
630
+ checkDesignCapabilityContracts();
631
+ checkDeliveryCapabilityContracts();
632
+ }
633
+
634
+ function checkRemovedSkillReferences() {
635
+ for (const skill of ["context-budget", "documentation-lookup"]) {
636
+ for (const file of managedFiles()) {
637
+ if (isVerifierImplementation(file)) continue;
638
+ if (read(file).includes(skill)) {
639
+ fail(`${file} still references removed skill ${skill}`);
640
+ }
641
+ }
642
+ }
643
+
644
+ const retiredSkills = [
645
+ "discover-unknowns-zh",
646
+ "skill-creator",
647
+ "writing-plans",
648
+ "executing-plans",
649
+ ];
650
+ const allowedRetirementFiles = new Set([
651
+ "README.md",
652
+ "scripts/retired-skill-files.json",
653
+ ]);
654
+
655
+ for (const skill of retiredSkills) {
656
+ if (exists(`skills/${skill}/SKILL.md`)) {
657
+ fail(`skills/${skill} should be retired`);
658
+ }
659
+ for (const file of managedFiles()) {
660
+ if (
661
+ isVerifierImplementation(file) ||
662
+ allowedRetirementFiles.has(file)
663
+ ) {
664
+ continue;
665
+ }
666
+ if (read(file).includes(skill)) {
667
+ fail(`${file} still references retired skill ${skill}`);
668
+ }
669
+ }
670
+ }
671
+
672
+ requireTokens("README.md", [
673
+ "Skill 迁移说明",
674
+ "`discover-unknowns-zh` 已退休",
675
+ "`iterative-retrieval`",
676
+ "`research`",
677
+ "`prototype`",
678
+ "`to-tickets`",
679
+ "`implementation-notes`、`explainer` 和 `quiz` 工件链不再属于",
680
+ "`skill-creator` 已退休",
681
+ "`rules/common/skills-learning.md`",
682
+ "scripts/upstream-capability-map.json",
683
+ ]);
684
+ requireTokens("scripts/retired-skill-files.json", retiredSkills);
685
+ requireTokens("skills/find-skills/SKILL.md", [
686
+ "name: find-skills",
687
+ "npx skills find",
688
+ "Verify Quality Before Recommending",
689
+ ]);
690
+ requireTokens("rules/common/skills-learning.md", [
691
+ "Skill 创建和更新遵循本规则",
692
+ "开放生态中的 skill 查找和安装由 `find-skills` 处理",
693
+ ]);
694
+ }
695
+
696
+ function checkForbiddenCommandDrift() {
697
+ const patterns = [
698
+ [/\/docs\b/, "removed /docs command reference"],
699
+ [/\/instinct-export\b/, "removed /instinct-export command reference"],
700
+ [/\/instinct-import\b/, "removed /instinct-import command reference"],
701
+ [/--decay\b/, "deprecated decay flag"],
702
+ [/decay-confidence/, "deprecated decay-confidence script"],
703
+ [/置信度降低 0\.02/, "automatic confidence decay"],
704
+ [/超过.*天.*删除/, "time-based instinct deletion"],
705
+ [/--max-age\b/, "time-based prune flag"],
706
+ [/清理过期/, "expired-instinct cleanup wording"],
707
+ ];
708
+
709
+ for (const file of managedFiles()) {
710
+ if (
711
+ isVerifierImplementation(file) ||
712
+ ["scripts/install.ps1", "scripts/install.sh"].includes(file)
713
+ ) continue;
714
+ if (!/\.(md|json|js|ps1|sh)$/.test(file)) continue;
715
+
716
+ const body = read(file);
717
+ const lines = body.split(/\r?\n/);
718
+ for (const [pattern, label] of patterns) {
719
+ lines.forEach((line, index) => {
720
+ if (pattern.test(line)) {
721
+ fail(`${file}:${index + 1} contains ${label}: ${line.trim()}`);
722
+ }
723
+ });
724
+ }
725
+ }
726
+ }
727
+
728
+ function runWorkflowChecks(context) {
729
+ bindContext(context);
730
+ checkSuperpowersDevLoop();
731
+ checkSpecVisualContracts();
732
+ checkSuperpowersArtifactPolicy();
733
+ checkGrillingWorkflow();
734
+ checkSuperpowersRoutingConsistency();
735
+ checkUpstreamCapabilityParity();
736
+ runGrillingSpecGateChecks(context);
737
+ checkRemovedSkillReferences();
738
+ checkForbiddenCommandDrift();
739
+ }
740
+
741
+ module.exports = { runWorkflowChecks };