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.
Files changed (44) 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/README.md +2 -0
  5. package/README.zh-CN.md +2 -0
  6. package/agents/e2e-runner.md +1 -1
  7. package/evals/routing-scenarios.json +252 -0
  8. package/harness/manifest.json +2 -28
  9. package/hooks/check-console-log.js +2 -2
  10. package/package.json +4 -2
  11. package/rules/01-base.md +2 -2
  12. package/rules/02-implementation.md +7 -6
  13. package/rules/05-git-workflow.md +4 -6
  14. package/rules/common/agent-orchestration.md +1 -1
  15. package/rules/common/pr-automation.md +1 -1
  16. package/rules/common/testing.md +2 -2
  17. package/scripts/eval-scenarios.js +108 -0
  18. package/scripts/install-rules.js +266 -19
  19. package/scripts/install.ps1 +42 -15
  20. package/scripts/install.sh +31 -12
  21. package/scripts/legacy-common-rule-hashes.json +6 -1
  22. package/scripts/retired-skill-files.json +7 -0
  23. package/scripts/verify/install-rules.test.js +158 -24
  24. package/scripts/verify/metadata-checks.js +7 -8
  25. package/scripts/verify/repository-checks.js +44 -368
  26. package/scripts/verify/scenario-checks.js +108 -0
  27. package/scripts/verify/scenario-checks.test.js +97 -0
  28. package/scripts/verify/workflow-checks.js +85 -586
  29. package/scripts/verify-harness.js +2 -0
  30. package/skills/README.md +2 -4
  31. package/skills/feature-acceptance/SKILL.md +8 -8
  32. package/skills/{e2e-testing/SKILL.md → feature-acceptance/references/e2e-testing.md} +3 -9
  33. package/skills/implement/SKILL.md +2 -0
  34. package/skills/{subagent-driven-development/SKILL.md → implement/references/parallel-delivery.md} +7 -9
  35. package/skills/implement/references/ticket-delivery.md +1 -1
  36. package/skills/using-superpowers/SKILL.md +24 -103
  37. package/rules/07-forbidden.md +0 -20
  38. package/rules/08-specialty-rules-index.md +0 -18
  39. package/rules/09-first-principles-adversarial-testing.md +0 -30
  40. package/scripts/verify/continuation-checks.test.js +0 -101
  41. package/scripts/verify/grilling-spec-gate-checks.js +0 -297
  42. package/scripts/verify/workflow-ownership-fixtures.js +0 -371
  43. package/scripts/verify/workflow-ownership.js +0 -780
  44. /package/skills/{e2e-testing → feature-acceptance}/references/playwright-patterns.md +0 -0
@@ -1,297 +0,0 @@
1
- "use strict";
2
-
3
- const ACTIVE_BRAINSTORMING_REFERENCE = "skills/brainstorming/SKILL.md";
4
- const PROCESS_OUTCOMES = "skills/using-superpowers/references/process-outcomes.md";
5
- const BRAINSTORMING_REFERENCE_ALLOWLIST = new Set([
6
- "README.md",
7
- "skills/using-superpowers/SKILL.md",
8
- "scripts/install.sh",
9
- "scripts/install.ps1",
10
- ]);
11
-
12
- const ROUTING_SCENARIOS = [
13
- {
14
- name: "clear low-risk task",
15
- checks: [{ file: "skills/using-superpowers/SKILL.md", tokens: ["direct", "clear low-risk task"] }],
16
- },
17
- {
18
- name: "ordinary task with one user decision",
19
- checks: [{
20
- file: "skills/using-superpowers/SKILL.md",
21
- tokens: ["grilling inline", "unresolved user-owned decision"],
22
- }],
23
- },
24
- {
25
- name: "explicit grilling request",
26
- checks: [{ file: "skills/using-superpowers/SKILL.md", tokens: ["explicit grilling request", "grilling explicit"] }],
27
- },
28
- {
29
- name: "clear breaking public API migration",
30
- checks: [{ file: "skills/spec-gate/SKILL.md", tokens: ["clear breaking public API migration", "Spec drafting"] }],
31
- },
32
- {
33
- name: "public API migration with unresolved compatibility",
34
- checks: [{
35
- file: "skills/using-superpowers/SKILL.md",
36
- tokens: ["unresolved user-owned decision", "resume_target: spec-gate"],
37
- }],
38
- },
39
- {
40
- name: "Spec Gate discovers an unresolved public contract",
41
- checks: [{
42
- file: PROCESS_OUTCOMES,
43
- tokens: ["BLOCKED_BY_UNRESOLVED_DECISION", "decision map"],
44
- }],
45
- },
46
- {
47
- name: "authorized task continues after focused clarification",
48
- checks: [{
49
- file: PROCESS_OUTCOMES,
50
- tokens: ["grilling inline", "Wait for the user's answer", "new Spec Gate", "do not resume the old call stack"],
51
- }],
52
- },
53
- {
54
- name: "unchanged confirmed decision blocks again",
55
- checks: [{ file: PROCESS_OUTCOMES, tokens: ["Spec Gate contract conflict"] }],
56
- },
57
- {
58
- name: "task only consumes established domain vocabulary",
59
- checks: [{
60
- file: "skills/domain-modeling/SKILL.md",
61
- tokens: ["established `CONTEXT.md` vocabulary", "does not trigger it"],
62
- }],
63
- },
64
- {
65
- name: "new domain entity and lifecycle without a user decision",
66
- checks: [{ file: "skills/domain-modeling/SKILL.md", tokens: ["subscription entity", "lifecycle states"] }],
67
- },
68
- {
69
- name: "domain boundary remains a user decision",
70
- checks: [
71
- { file: "skills/domain-modeling/SKILL.md", tokens: ["Unresolved consequential decisions"] },
72
- { file: "skills/using-superpowers/SKILL.md", tokens: ["unresolved user-owned decision"] },
73
- ],
74
- },
75
- {
76
- name: "explicit /to-spec with sufficient context",
77
- checks: [{ file: "commands/to-spec.md", tokens: ["skills/spec-gate/SKILL.md"] }],
78
- },
79
- {
80
- name: "old brainstorming name compatibility",
81
- checks: [{
82
- file: "skills/using-superpowers/SKILL.md",
83
- tokens: ["Compatibility Alias", "old name `brainstorming`", "/to-spec"],
84
- }],
85
- },
86
- {
87
- name: "consented visual comparison",
88
- checks: [{ file: "skills/visual-companion/SKILL.md", tokens: ["user consent", "visual comparisons"] }],
89
- },
90
- ];
91
-
92
- function checkRequiredPaths({ exists, fail }) {
93
- for (const file of [
94
- "skills/spec-gate/SKILL.md",
95
- "skills/spec-gate/references/spec-document-reviewer-prompt.md",
96
- "skills/spec-gate/agents/openai.yaml",
97
- "skills/domain-modeling/SKILL.md",
98
- "skills/visual-companion/SKILL.md",
99
- "skills/visual-companion/references/guide.md",
100
- "commands/to-spec.md",
101
- ]) {
102
- if (!exists(file)) fail(`${file} is missing from the new workflow`);
103
- }
104
- }
105
-
106
- function checkSpecGateContract({ exists, read, fail, requireTokens }) {
107
- const file = "skills/spec-gate/SKILL.md";
108
- requireTokens(file, [
109
- "zero interview",
110
- "READY_FOR_USER_REVIEW",
111
- "BLOCKED_BY_UNRESOLVED_DECISION",
112
- "NOT_APPLICABLE",
113
- "decision_id",
114
- "blocking_reason",
115
- "known_constraints",
116
- "evidence",
117
- "Local-only artifact policy",
118
- "Do not stage or commit it.",
119
- "Spec Gate contract conflict",
120
- "the user has explicitly approved it",
121
- ]);
122
- if (!exists(file)) return;
123
-
124
- const body = read(file);
125
- const blockedSection = body.match(
126
- /## Outcomes[\s\S]*?BLOCKED_BY_UNRESOLVED_DECISION([\s\S]*?)(?=NOT_APPLICABLE)/,
127
- );
128
- if (blockedSection && /^- resume_target\s*$/m.test(blockedSection[1])) {
129
- fail("Spec Gate blocked outcome must not include resume_target");
130
- }
131
- if (/spec-gate\s*->\s*grilling/i.test(body)) {
132
- fail("Spec Gate must not define an automatic spec-gate -> grilling edge");
133
- }
134
- }
135
-
136
- function checkRouterContract({ exists, read, fail, requireTokens }) {
137
- const file = "skills/using-superpowers/SKILL.md";
138
- requireTokens(file, [
139
- "three lanes",
140
- "[references/process-outcomes.md](references/process-outcomes.md)",
141
- "Ordinary direct delivery does not load this reference",
142
- "spec-gate",
143
- ]);
144
- requireTokens(PROCESS_OUTCOMES, [
145
- "BLOCKED_BY_UNRESOLVED_DECISION",
146
- "decision map",
147
- "grilling inline",
148
- "do not ask whether to continue clarification",
149
- "Wait for the user's answer",
150
- "Silence is not a decision or approval.",
151
- "If the user pauses or ends the task, stop.",
152
- "A new scope or external action still requires its own",
153
- "authorization; clarification does not expand the original request.",
154
- "new Spec Gate",
155
- "do not resume the old call stack",
156
- "spec-gate",
157
- ]);
158
- if (!exists(file) || !exists(PROCESS_OUTCOMES)) return;
159
-
160
- const body = read(PROCESS_OUTCOMES);
161
- for (const staleGate of [
162
- "Only an explicit choice to continue",
163
- "Let the user choose to continue clarification",
164
- "Stop without drafting, guessing, or invoking another Skill.",
165
- "is terminal for the current call chain",
166
- ]) {
167
- if (body.includes(staleGate)) {
168
- fail("Router must ask the missing decision within the authorized task, not request permission to clarify");
169
- }
170
- }
171
- for (const scenario of ROUTING_SCENARIOS) {
172
- for (const check of scenario.checks) requireTokens(check.file, check.tokens);
173
- }
174
- }
175
-
176
- function checkSupportingSkills({ exists, read, fail, requireTokens }) {
177
- requireTokens("skills/grilling/SKILL.md", [
178
- "Route context:",
179
- "Risk classification:",
180
- "Resume target:",
181
- "resume_target: spec-gate",
182
- "return to `skills/using-superpowers/SKILL.md`",
183
- ]);
184
- requireTokens("skills/domain-modeling/SKILL.md", [
185
- "bounded context",
186
- "lifecycle",
187
- "CONTEXT.md",
188
- "approved Spec",
189
- "Reuse existing maintenance authorization",
190
- "within the approved paths and scope",
191
- "If maintenance is not yet authorized, obtain approval before writing",
192
- "New paths or scope",
193
- ]);
194
- const domain = "skills/domain-modeling/SKILL.md";
195
- if (exists(domain)) {
196
- const body = read(domain).replace(/\s+/g, " ");
197
- if (body.includes("When a term becomes stable, show the exact glossary change and obtain write approval before")) {
198
- fail("Domain documentation must reuse in-scope maintenance authorization, not require per-term approval");
199
- }
200
- for (const constraint of [
201
- "changes to confirmed decisions",
202
- "unresolved consequential decisions require approval before the affected edit.",
203
- ]) {
204
- if (!body.includes(constraint)) fail(`${domain} should include ${constraint}`);
205
- }
206
- }
207
- requireTokens("skills/visual-companion/SKILL.md", [
208
- "user consent",
209
- "grilling owns the decision loop",
210
- "does not own continuation",
211
- ]);
212
- requireTokens("commands/to-spec.md", ["skills/spec-gate/SKILL.md"]);
213
- }
214
-
215
- function checkRemovedBrainstormingReferences(context) {
216
- const { exists, read, managedFiles, fail, isVerifierImplementation } = context;
217
- for (const agent of ["agents/harness-optimizer.md"]) {
218
- if (exists(agent) && read(agent).includes("brainstorming")) {
219
- fail(`${agent} must not reference brainstorming after the migration`);
220
- }
221
- }
222
-
223
- for (const file of managedFiles()) {
224
- if (isVerifierImplementation(file) || BRAINSTORMING_REFERENCE_ALLOWLIST.has(file)) continue;
225
- if (read(file).includes(ACTIVE_BRAINSTORMING_REFERENCE)) {
226
- fail(`${file} contains active reference to ${ACTIVE_BRAINSTORMING_REFERENCE}`);
227
- }
228
- }
229
-
230
- if (exists("skills/brainstorming/SKILL.md")) {
231
- fail("skills/brainstorming/SKILL.md must be removed");
232
- }
233
- }
234
-
235
- function checkVisualCompanionSecurity({ requireTokens }) {
236
- requireTokens("skills/visual-companion/references/guide.md", [
237
- "session key",
238
- "?key=",
239
- "4 hours idle",
240
- "--idle-timeout-minutes",
241
- "same port",
242
- ]);
243
- requireTokens("skills/visual-companion/scripts/server.cjs", [
244
- "BRAINSTORM_TOKEN",
245
- "BRAINSTORM_TOKEN_FILE",
246
- "Default 4 hours",
247
- ]);
248
- requireTokens("skills/visual-companion/scripts/server-utils.cjs", [
249
- "timingSafeEqualStr",
250
- "Cache-Control",
251
- "X-Frame-Options",
252
- ]);
253
- }
254
-
255
- function checkInstallerCleanupContract({ requireTokens }) {
256
- requireTokens("scripts/install.sh", [
257
- "cleanup_retired_skills",
258
- "cleanup-retired-skills.js",
259
- "validate_retired_skill_manifest",
260
- "--dry-run",
261
- "rules/08-ecc-integration.md",
262
- "skills/subagent-driven-development/implementer-prompt.md",
263
- ]);
264
- requireTokens("scripts/install.ps1", [
265
- "Remove-RetiredSkills",
266
- "cleanup-retired-skills.js",
267
- "Test-RetiredSkillManifest",
268
- "--dry-run",
269
- "rules\\08-ecc-integration.md",
270
- "skills\\subagent-driven-development\\implementer-prompt.md",
271
- ]);
272
- requireTokens("scripts/retired-skill-files.json", [
273
- "brainstorming",
274
- "SKILL.md",
275
- "scripts/server.cjs",
276
- "agents/openai.yaml",
277
- "writing-plans",
278
- "executing-plans",
279
- ]);
280
- requireTokens("scripts/cleanup-retired-skills.js", [
281
- "Preserving unknown files in retired skill",
282
- "Preserving symlinked retired skill",
283
- "Preserving retired path through symlink",
284
- ]);
285
- }
286
-
287
- function runGrillingSpecGateChecks(context) {
288
- checkRequiredPaths(context);
289
- checkSpecGateContract(context);
290
- checkRouterContract(context);
291
- checkSupportingSkills(context);
292
- checkRemovedBrainstormingReferences(context);
293
- checkVisualCompanionSecurity(context);
294
- checkInstallerCleanupContract(context);
295
- }
296
-
297
- module.exports = { runGrillingSpecGateChecks };
@@ -1,371 +0,0 @@
1
- "use strict";
2
-
3
- function encodeFirstSpace(tokens, entity) {
4
- return tokens.map((token) => token.replace(" ", entity)).join(" -> ");
5
- }
6
-
7
- function repositoryScopeFixture(definition) {
8
- const [first, second, third] = definition.signatureTokens;
9
- return `## 替代标题\n1. ${first}\n2. ${second}\n3. ${third}`;
10
- }
11
-
12
- function fixtureAuthorityPath(definition, token) {
13
- return definition.tokenAuthorityPaths?.[token]?.[0] ?? definition.authorityPath;
14
- }
15
-
16
- function fixtureWrongAuthorityPath(definition, token) {
17
- const allowedPaths = new Set([
18
- definition.authorityPath,
19
- ...(definition.tokenAuthorityPaths?.[token] ?? []),
20
- ]);
21
- const allPaths = new Set([definition.authorityPath]);
22
- for (const tokenPaths of Object.values(definition.tokenAuthorityPaths ?? {})) {
23
- for (const path of tokenPaths) allPaths.add(path);
24
- }
25
- return (
26
- [...allPaths].find((path) => !allowedPaths.has(path)) ??
27
- "skills/unrelated/SKILL.md"
28
- );
29
- }
30
-
31
- function allowedReferenceFixtures(definition) {
32
- const [first, second, third] = definition.signatureTokens;
33
- const directList = [first, second, third]
34
- .map((token) => `- ${token} 见 \`${definition.authorityPath}\`。`)
35
- .join("\n");
36
- const distributedList = definition.signatureTokens
37
- .map((token) => `- ${token} 见 \`${fixtureAuthorityPath(definition, token)}\`。`)
38
- .join("\n");
39
- const aggregate =
40
- `${definition.signatureTokens.join("、")},` +
41
- `均以 \`${definition.authorityPath}\` 为准。`;
42
- const distributed =
43
- `${definition.signatureTokens.join("、")},分别见 ` +
44
- definition.signatureTokens
45
- .map((token) => `\`${fixtureAuthorityPath(definition, token)}\``)
46
- .join("、");
47
- const possessiveList = definition.signatureTokens
48
- .map((token) =>
49
- `- ${token} 的权威定义见 \`${fixtureAuthorityPath(definition, token)}\`。`,
50
- )
51
- .join("\n");
52
- const englishList = definition.signatureTokens
53
- .map((token) =>
54
- `- ${token}: see \`${fixtureAuthorityPath(definition, token)}\`.`,
55
- )
56
- .join("\n");
57
- const englishPossessiveList = definition.signatureTokens
58
- .map((token) =>
59
- `- ${token}'s authority is ` +
60
- `\`${fixtureAuthorityPath(definition, token)}\`.`,
61
- )
62
- .join("\n");
63
- const englishAggregate =
64
- `${definition.signatureTokens.join(", ")} are all defined by ` +
65
- `\`${definition.authorityPath}\`.`;
66
- const contextWithHeading = [
67
- `流程定义以 \`${definition.authorityPath}\` 为准。`,
68
- "",
69
- `- ${first}`,
70
- "",
71
- ` ### ${second}`,
72
- `- ${third}`,
73
- ].join("\n");
74
- const nestedContext = [
75
- `- 流程定义以 \`${definition.authorityPath}\` 为准:`,
76
- ` - ${first}`,
77
- ` - ${second}`,
78
- ` - ${third}`,
79
- ].join("\n");
80
- const commentSeparatedContext = [
81
- `流程定义以 \`${definition.authorityPath}\` 为准。`,
82
- "<!-- reference separator -->",
83
- `- ${first}`,
84
- `- ${second}`,
85
- `- ${third}`,
86
- ].join("\n");
87
- return [
88
- `## 引用\n${definition.label} 见 \`${definition.authorityPath}\`。`,
89
- `- ${definition.label} 见 \`${definition.authorityPath}\`。`,
90
- `- ${first} 见 \`${definition.authorityPath}\`。`,
91
- [first, second, third]
92
- .map((token) => `${token} 见 \`${definition.authorityPath}\`。`)
93
- .join("\n\n"),
94
- directList,
95
- distributedList,
96
- aggregate,
97
- distributed,
98
- possessiveList,
99
- englishList,
100
- englishPossessiveList,
101
- englishAggregate,
102
- `流程定义以 \`${definition.authorityPath}\` 为准。\n\n- ${first}\n- ${second}\n- ${third}`,
103
- contextWithHeading,
104
- nestedContext,
105
- commentSeparatedContext,
106
- ];
107
- }
108
-
109
- function allowedHiddenFixtures(definition) {
110
- const [first, second, third] = definition.signatureTokens;
111
- const heading = definition.headings[0];
112
- const nestedTemplate = [
113
- "<template>",
114
- "<template>inner</template>",
115
- `<div>${first} -> ${second} -> ${third}</div>`,
116
- "</template>",
117
- ].join("\n");
118
- return [
119
- `- ${heading}\n---`,
120
- `- ${heading}\n- ---`,
121
- `\`\`\`markdown\n## ${heading}\n1. ${first}\n2. ${second}\n3. ${third}\n\`\`\``,
122
- `- \`\`\`markdown\n ## ${heading}\n 1. ${first}\n 2. ${second}\n 3. ${third}\n \`\`\``,
123
- `- 示例\n \t\`\`\`markdown\n \t## ${heading}\n \t1. ${first}\n \t2. ${second}\n \t3. ${third}\n \t\`\`\``,
124
- `> \`\`\`markdown\n>> \`\`\`\n> ## ${heading}\n> \`\`\`\``,
125
- `> - \`\`\`markdown\n> 示例\n ## ${heading}`,
126
- ` ~~~markdown\n ## ${heading}\n 1. ${first}\n 2. ${second}\n 3. ${third}\n ~~~`,
127
- `\`\`\`markdown\n\`\`\`not-close\n## ${heading}\n1. ${first}\n2. ${second}\n3. ${third}\n\`\`\``,
128
- ` ## ${heading}\n 1. ${first}\n 2. ${second}\n 3. ${third}`,
129
- `<!-- ## ${heading} -->`,
130
- `<!-- ## ${heading}\n1. ${first}\n2. ${second}\n3. ${third}`,
131
- `<!-- <div>${first} -> ${second} -> ${third}</div> -->`,
132
- `<!-- <h2>${heading}</h2> -->`,
133
- `<script>${first} -> ${second} -> ${third}</script>`,
134
- `<script><h2>${heading}</h2></script>`,
135
- `<style>${first} -> ${second} -> ${third}</style>`,
136
- `<template>${first} -> ${second} -> ${third}</template>`,
137
- `<pre><code>${first} -> ${second} -> ${third}</code></pre>`,
138
- nestedTemplate,
139
- `说明 <script>${first} -> ${second} -> ${third}</script>`,
140
- `<div data-flow="${first} -> ${second} -> ${third}">引用说明</div>`,
141
- ];
142
- }
143
-
144
- function allowedFixtures(definition) {
145
- const fixtures = [
146
- ...allowedReferenceFixtures(definition),
147
- ...allowedHiddenFixtures(definition),
148
- ];
149
- if (!definition.signatureTokens.some((token) => token.includes("->"))) {
150
- const [first, second, third] = definition.signatureTokens;
151
- fixtures.push(
152
- `- ${first}、${second}、${third},见 \`${definition.authorityPath}\`。`,
153
- );
154
- }
155
- return fixtures;
156
- }
157
-
158
- function rejectedReferenceFixtures(definition, first, second, third) {
159
- const directReferenceWithLocalStep = [
160
- `- ${first} 见 \`${definition.authorityPath}\`。`,
161
- `- ${second} 见 \`${definition.authorityPath}\`。`,
162
- `- ${third} 见 \`${definition.authorityPath}\`。`,
163
- "- 按顺序执行上述步骤,并在最后自动发布。",
164
- ].join("\n");
165
- const contextReferenceWithNestedHeading = [
166
- `流程定义以 \`${definition.authorityPath}\` 为准。`,
167
- "",
168
- `- ${first}`,
169
- "",
170
- " ### 按顺序执行并自动发布",
171
- `- ${second}`,
172
- `- ${third}`,
173
- ].join("\n");
174
- const nestedDirectReferenceWithOuterHeading = [
175
- "- 引用容器",
176
- ` - ${first} 见 \`${definition.authorityPath}\`。`,
177
- ` - ${second} 见 \`${definition.authorityPath}\`。`,
178
- ` - ${third} 见 \`${definition.authorityPath}\`。`,
179
- "",
180
- " ### 按顺序执行上述步骤并自动发布",
181
- ].join("\n");
182
- const nestedContextReferenceWithOuterHeading = [
183
- `- 流程定义以 \`${definition.authorityPath}\` 为准:`,
184
- ` - ${first}`,
185
- ` - ${second}`,
186
- ` - ${third}`,
187
- "",
188
- " ### 按顺序执行上述步骤并自动发布",
189
- ].join("\n");
190
- return [
191
- directReferenceWithLocalStep,
192
- contextReferenceWithNestedHeading,
193
- nestedDirectReferenceWithOuterHeading,
194
- nestedContextReferenceWithOuterHeading,
195
- ];
196
- }
197
-
198
- function adjacentReferenceFixtures(definition, first, second, third) {
199
- const direct = [first, second, third]
200
- .map((token) => `- ${token} 见 \`${definition.authorityPath}\``)
201
- .join("\n");
202
- const independent = [first, second, third]
203
- .map((token) => `${token} 见 \`${definition.authorityPath}\``)
204
- .join("\n\n");
205
- const context = [
206
- `流程定义以 \`${definition.authorityPath}\` 为准。`,
207
- `- ${first}`,
208
- `- ${second}`,
209
- `- ${third}`,
210
- ].join("\n");
211
- const directiveTexts = [
212
- "按顺序执行上述步骤,并在最后自动发布",
213
- "遵循上述步骤",
214
- "先完成上述步骤,再发布",
215
- "上述步骤必须执行",
216
- "按上述步骤执行",
217
- "以上流程需要完成",
218
- "前述门禁必须遵循",
219
- "随后执行上述步骤",
220
- "上述步骤完成后发布",
221
- "遵照以上流程",
222
- "Follow the steps above",
223
- "The above steps must be completed",
224
- "The steps above must be completed",
225
- "The workflow above will be automatically deployed",
226
- "The workflow will automatically be deployed",
227
- "The changes will automatically be committed",
228
- "The branch will automatically be merged",
229
- "The workflow automatically publishes",
230
- "The workflow merges automatically",
231
- "The workflow is auto-merged",
232
- "Then execute the previous workflow",
233
- "Execute the following steps",
234
- "Complete the steps below",
235
- ];
236
- const directives = directiveTexts.flatMap((text) => [
237
- `${text}。`,
238
- `### ${text}`,
239
- `<h3>${text}</h3>`,
240
- ]);
241
- const authorityIntro = `权威来源见 \`${definition.authorityPath}\`。`;
242
- const masked = [
243
- `${directives[0]}\n\n${authorityIntro}\n\n${direct}`,
244
- `${directives[0]}\n\n${authorityIntro}\n\n${independent}`,
245
- `${direct}\n\n${authorityIntro}\n\n${directives[0]}`,
246
- `${independent}\n\n${authorityIntro}\n\n${directives[0]}`,
247
- ];
248
- return [
249
- ...masked,
250
- ...directives.flatMap((adjacent) => [
251
- `${direct}\n\n${adjacent}`,
252
- `${context}\n\n${adjacent}`,
253
- `${independent}\n\n${adjacent}`,
254
- `${adjacent}\n\n${direct}`,
255
- `${adjacent}\n\n${context}`,
256
- `${adjacent}\n\n${independent}`,
257
- ]),
258
- ];
259
- }
260
-
261
- function rejectedOwnerFixtures(definition) {
262
- const [first, second, third] = definition.signatureTokens;
263
- const independentWithWrongOwner = [
264
- `${first} 见 \`${fixtureAuthorityPath(definition, first)}\`。`,
265
- `${second} 见 \`${fixtureWrongAuthorityPath(definition, second)}\`。`,
266
- `${third} 见 \`${fixtureAuthorityPath(definition, third)}\`。`,
267
- ].join("\n\n");
268
- const tokens = definition.signatureTokens;
269
- const paths = tokens.map((token) => fixtureAuthorityPath(definition, token));
270
- const distinctIndex = paths.findIndex((path) => path !== paths[0]);
271
- if (distinctIndex < 0) {
272
- paths[0] = fixtureWrongAuthorityPath(definition, tokens[0]);
273
- } else {
274
- [paths[0], paths[distinctIndex]] = [paths[distinctIndex], paths[0]];
275
- }
276
- const swappedAggregateOwners =
277
- `${tokens.join("、")},分别见 ` + paths.map((path) => `\`${path}\``).join("、");
278
- const contextWithExplicitWrongOwner = [
279
- `权威来源见 \`${definition.authorityPath}\`。`,
280
- "",
281
- `- ${first} 见 \`${fixtureWrongAuthorityPath(definition, first)}\`。`,
282
- `- ${second}`,
283
- `- ${third}`,
284
- ].join("\n");
285
- return [
286
- independentWithWrongOwner,
287
- swappedAggregateOwners,
288
- contextWithExplicitWrongOwner,
289
- ];
290
- }
291
-
292
- function rejectedFixtures(definition) {
293
- const [first, second, third] = definition.signatureTokens;
294
- const heading = definition.headings[0];
295
- const encodedTokens = encodeFirstSpace([first, second, third], "&#32;");
296
- const unterminatedEncodedTokens = encodeFirstSpace(
297
- [first, second, third],
298
- "&#32",
299
- );
300
- const fixtures = [
301
- `## **${heading}** ##\n流程在本规则定义。`,
302
- `## [${heading}](#workflow)`,
303
- `### ${first}\n### ${second}\n### ${third}`,
304
- `${heading}\n---`,
305
- `## 替代标题\n1. ${first}\n2. ${second}\n3. ${third}`,
306
- `## 替代标题\n- ${first}\n- ${second}\n- ${third}`,
307
- `- 嵌套流程\n 1. ${first}\n 2. ${second}\n 3. ${third}`,
308
- ` \`\`\`markdown\n## ${heading}\n1. ${first}\n2. ${second}\n3. ${third}`,
309
- `说明 \`<!--\` 不是注释\n## ${heading}\n流程在本规则定义。`,
310
- `## 替代标题\n1. **${first}**,见 \`${definition.authorityPath}\`\n2. ${second}\n3. ${third}`,
311
- `${first} -> ${second} -> ${third},详见 \`${definition.authorityPath}\`。`,
312
- `先执行 ${first},再完成 ${second},最后进入 ${third};详见 \`${definition.authorityPath}\`。`,
313
- `- 先执行 ${first},再完成 ${second},最后进入 ${third};详见 \`${definition.authorityPath}\`。`,
314
- `流程定义以 \`${definition.authorityPath}\` 为准。\n\n- ${first}\n- ${second}\n- 本地执行 ${third}`,
315
- `流程定义以 \`${definition.authorityPath}\` 为准。\n\n` +
316
- `- ${first}\n- ${second}\n- ${third}\n` +
317
- "- 按顺序执行上述步骤,并在最后自动发布",
318
- ...rejectedReferenceFixtures(definition, first, second, third),
319
- ...adjacentReferenceFixtures(definition, first, second, third),
320
- ...rejectedOwnerFixtures(definition),
321
- `<div>${first} -> ${second} -> ${third}</div>`,
322
- `<div>${first} < ${second} > ${third}</div>`,
323
- `<div>${encodedTokens}</div>`,
324
- `<div>${unterminatedEncodedTokens}</div>`,
325
- `<h2>${heading}</h2>`,
326
- `前言 <h2>${heading}</h2>`,
327
- `流程:<span>${first} -> ${second} -> ${third}</span>`,
328
- `流程如下:\n ${first} -> ${second} -> ${third}`,
329
- `- 流程如下:\n ${first} -> ${second} -> ${third}`,
330
- `<!--\n\`\`\`markdown\n-->\n## ${heading}`,
331
- `<!--\n~~~markdown\n-->\n## ${heading}`,
332
- ` <!--\n## ${heading}`,
333
- `-\n \`\`\`markdown\n 示例\n \`\`\`\n## ${heading}`,
334
- `-\n ~~~markdown\n 示例\n ~~~\n## ${heading}`,
335
- `> \`\`\`markdown\n> 示例\n## ${heading}`,
336
- `> <!--\n> 示例\n## ${heading}`,
337
- `> \`\`\`markdown\n\n> ## ${heading}`,
338
- `> <!--\n\n> ## ${heading}`,
339
- `- \`\`\`markdown\n 示例\n## ${heading}`,
340
- `-\t\`\`\`markdown\n ## ${heading}`,
341
- `\`\`\`markdown\`invalid\n## ${heading}`,
342
- ];
343
- if (definition.detectionTokens) {
344
- fixtures.push(
345
- definition.detectionTokens
346
- .map((token, index) => `${index + 1}. ${token}`)
347
- .join("\n"),
348
- definition.detectionTokens.join(",然后"),
349
- );
350
- }
351
- if (definition.signatureTokens.some((token) => token.includes("->"))) {
352
- fixtures.push(
353
- `## 替代标题\n${definition.signatureTokens
354
- .slice(0, 3)
355
- .map((token) => token.replaceAll("->", "→"))
356
- .join(" → ")}`,
357
- definition.signatureTokens
358
- .slice(0, 3)
359
- // Remove optional ASCII-arrow spacing to exercise compact Unicode-arrow normalization.
360
- .map((token) => token.replace(/\s*->\s*/g, "→"))
361
- .join("→"),
362
- );
363
- }
364
- return fixtures;
365
- }
366
-
367
- module.exports = {
368
- allowedFixtures,
369
- rejectedFixtures,
370
- repositoryScopeFixture,
371
- };