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.
- package/AGENTS.md +19 -20
- package/README.md +112 -104
- package/agents/code-reviewer.md +15 -44
- package/agents/harness-optimizer.md +3 -2
- package/agents/planner.md +23 -107
- package/commands/code-review.md +25 -9
- package/commands/learn.md +97 -0
- package/commands/pr.md +4 -0
- package/commands/to-spec.md +11 -0
- package/hooks/check-code-size.js +33 -12
- package/hooks/check-console-log.js +72 -24
- package/package.json +5 -2
- package/rules/01-base.md +19 -42
- package/rules/02-code-size.md +6 -17
- package/rules/03-architecture.md +16 -54
- package/rules/04-error-handling.md +4 -25
- package/rules/05-git-workflow.md +9 -37
- package/rules/06-comments.md +3 -37
- package/rules/07-forbidden.md +6 -30
- package/rules/08-specialty-rules-index.md +18 -0
- package/rules/09-first-principles-adversarial-testing.md +6 -18
- package/rules/common/agent-orchestration.md +10 -47
- package/rules/common/context-hygiene.md +9 -72
- package/rules/common/harness-engineering.md +11 -38
- package/rules/common/hooks.md +11 -82
- package/rules/common/performance.md +8 -71
- package/rules/common/pr-automation.md +7 -68
- package/rules/common/skills-learning.md +12 -36
- package/rules/common/testing.md +15 -59
- package/scripts/cleanup-retired-skills.js +214 -0
- package/scripts/install.ps1 +73 -85
- package/scripts/install.sh +54 -77
- package/scripts/learning/review-confidence.js +1 -4
- package/scripts/merge-claude-settings.cjs +75 -0
- package/scripts/retired-skill-files.json +37 -0
- package/scripts/upstream-capability-baseline.json +27 -0
- package/scripts/upstream-capability-map.json +150 -0
- package/scripts/verify/core.js +91 -0
- package/scripts/verify/grilling-spec-gate-checks.js +260 -0
- package/scripts/verify/metadata-checks.js +724 -0
- package/scripts/verify/repository-checks.js +435 -0
- package/scripts/verify/runtime-checks.js +593 -0
- package/scripts/verify/workflow-checks.js +741 -0
- package/scripts/verify/workflow-ownership-fixtures.js +371 -0
- package/scripts/verify/workflow-ownership.js +780 -0
- package/scripts/verify-harness.js +16 -1075
- package/scripts/verify-upstream-capability-map.js +117 -0
- package/skills/README.md +24 -10
- package/skills/code-review/SKILL.md +50 -0
- package/skills/code-review/references/spec-reviewer-prompt.md +24 -0
- package/skills/code-review/references/standards-reviewer-prompt.md +35 -0
- package/skills/codebase-design/SKILL.md +63 -0
- package/skills/codebase-design/references/deepening.md +27 -0
- package/skills/codebase-design/references/design-it-twice.md +17 -0
- package/skills/continuous-learning-v2/SKILL.md +7 -7
- package/skills/continuous-learning-v2/config.json +0 -4
- package/skills/domain-modeling/SKILL.md +100 -0
- package/skills/feature-acceptance/SKILL.md +89 -0
- package/skills/grilling/SKILL.md +83 -0
- package/skills/handoff/SKILL.md +56 -0
- package/skills/implement/SKILL.md +97 -0
- package/skills/improve-codebase-architecture/SKILL.md +48 -0
- package/skills/iterative-retrieval/SKILL.md +10 -1
- package/skills/learn/README.md +2 -2
- package/skills/project-context/SKILL.md +94 -0
- package/skills/project-context/agents/openai.yaml +6 -0
- package/skills/project-context/references/project-context-template.md +61 -0
- package/skills/prototype/SKILL.md +50 -0
- package/skills/prototype/references/logic.md +28 -0
- package/skills/prototype/references/ui.md +30 -0
- package/skills/research/SKILL.md +48 -0
- package/skills/resolving-merge-conflicts/SKILL.md +27 -0
- package/skills/spec-gate/SKILL.md +149 -0
- package/skills/spec-gate/agents/openai.yaml +4 -0
- package/skills/spec-gate/references/spec-document-reviewer-prompt.md +31 -0
- package/skills/subagent-driven-development/SKILL.md +95 -414
- package/skills/systematic-debugging/SKILL.md +7 -51
- package/skills/systematic-debugging/references/diagnosing-bugs.upstream.md +129 -0
- package/skills/systematic-debugging/scripts/hitl-loop.template.js +75 -0
- package/skills/systematic-debugging/scripts/hitl-loop.template.sh +41 -0
- package/skills/test-driven-development/SKILL.md +18 -2
- package/skills/to-tickets/SKILL.md +94 -0
- package/skills/triage/SKILL.md +53 -0
- package/skills/triage/references/agent-brief.md +32 -0
- package/skills/triage/references/out-of-scope.md +14 -0
- package/skills/using-superpowers/SKILL.md +140 -40
- package/skills/visual-companion/SKILL.md +62 -0
- package/skills/visual-companion/agents/openai.yaml +4 -0
- package/skills/{brainstorming/visual-companion.md → visual-companion/references/guide.md} +1 -1
- package/skills/{brainstorming → visual-companion}/scripts/frame-template.html +42 -12
- package/skills/visual-companion/scripts/pages.cjs +28 -0
- package/skills/visual-companion/scripts/server-utils.cjs +82 -0
- package/skills/{brainstorming → visual-companion}/scripts/server.cjs +108 -248
- package/skills/{brainstorming → visual-companion}/scripts/start-server.sh +18 -4
- package/skills/visual-companion/scripts/websocket.cjs +86 -0
- package/skills/wayfinder/SKILL.md +57 -0
- package/commands/e2e.md +0 -28
- package/commands/evolve.md +0 -42
- package/commands/harness-audit.md +0 -27
- package/commands/instinct-status.md +0 -38
- package/commands/learn-eval.md +0 -91
- package/commands/projects.md +0 -27
- package/commands/promote.md +0 -29
- package/commands/prune.md +0 -46
- package/commands/tdd.md +0 -27
- package/homunculus/instincts/personal/always-test-first.md +0 -28
- package/homunculus/instincts/personal/pr-ci-quality-gate.md +0 -30
- package/rules/08-ecc-integration.md +0 -46
- package/rules/common/implementation.md +0 -25
- package/rules/common/security.md +0 -19
- package/skills/brainstorming/SKILL.md +0 -185
- package/skills/brainstorming/agents/openai.yaml +0 -3
- package/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
- package/skills/context-budget/SKILL.md +0 -59
- package/skills/documentation-lookup/SKILL.md +0 -90
- package/skills/executing-plans/SKILL.md +0 -66
- package/skills/skill-creator/LICENSE.txt +0 -202
- package/skills/skill-creator/SKILL.md +0 -356
- package/skills/skill-creator/references/output-patterns.md +0 -82
- package/skills/skill-creator/references/workflows.md +0 -28
- package/skills/skill-creator/scripts/init_skill.py +0 -303
- package/skills/skill-creator/scripts/package_skill.py +0 -110
- package/skills/skill-creator/scripts/quick_validate.py +0 -95
- package/skills/subagent-driven-development/implementer-prompt.md +0 -139
- package/skills/subagent-driven-development/scripts/review-package +0 -44
- package/skills/subagent-driven-development/scripts/sdd-workspace +0 -22
- package/skills/subagent-driven-development/scripts/task-brief +0 -40
- package/skills/subagent-driven-development/task-reviewer-prompt.md +0 -188
- package/skills/writing-plans/SKILL.md +0 -206
- package/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
- /package/skills/{brainstorming → visual-companion}/scripts/helper.js +0 -0
- /package/skills/{brainstorming → visual-companion}/scripts/stop-server.sh +0 -0
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { spawnSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
let root;
|
|
9
|
+
let rel;
|
|
10
|
+
let exists;
|
|
11
|
+
let read;
|
|
12
|
+
let fail;
|
|
13
|
+
let requireTokens;
|
|
14
|
+
|
|
15
|
+
const PACKAGE_ONLY_PATHS = [
|
|
16
|
+
"scripts/install.sh",
|
|
17
|
+
"scripts/install.ps1",
|
|
18
|
+
"scripts/verify-harness.js",
|
|
19
|
+
"scripts/verify/core.js",
|
|
20
|
+
"scripts/verify/grilling-spec-gate-checks.js",
|
|
21
|
+
"scripts/verify/metadata-checks.js",
|
|
22
|
+
"scripts/verify/repository-checks.js",
|
|
23
|
+
"scripts/verify/runtime-checks.js",
|
|
24
|
+
"scripts/verify/workflow-checks.js",
|
|
25
|
+
"scripts/verify/workflow-ownership-fixtures.js",
|
|
26
|
+
"scripts/verify/workflow-ownership.js",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function bindContext(context) {
|
|
30
|
+
({ root, rel, exists, read, fail, requireTokens } = context);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function checkCommands() {
|
|
34
|
+
const commandsDir = rel("commands");
|
|
35
|
+
const commands = fs.existsSync(commandsDir)
|
|
36
|
+
? fs
|
|
37
|
+
.readdirSync(commandsDir)
|
|
38
|
+
.filter((file) => file.endsWith(".md"))
|
|
39
|
+
.sort()
|
|
40
|
+
: [];
|
|
41
|
+
const expectedCommands = [
|
|
42
|
+
"code-review.md",
|
|
43
|
+
"learn.md",
|
|
44
|
+
"pr.md",
|
|
45
|
+
"to-spec.md",
|
|
46
|
+
"verify.md",
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
if (JSON.stringify(commands) !== JSON.stringify(expectedCommands)) {
|
|
50
|
+
fail(
|
|
51
|
+
`commands must expose exactly: ${expectedCommands.join(", ")}; found: ${commands.join(", ")}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!exists("README.md")) {
|
|
56
|
+
fail("README.md is missing");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const listed = Array.from(read("README.md").matchAll(/`\/([^`\s]+)`/g))
|
|
61
|
+
.map((match) => `${match[1]}.md`)
|
|
62
|
+
.filter((value, index, array) => array.indexOf(value) === index)
|
|
63
|
+
.sort();
|
|
64
|
+
|
|
65
|
+
for (const file of listed) {
|
|
66
|
+
if (!commands.includes(file)) {
|
|
67
|
+
fail(
|
|
68
|
+
`README lists /${file.replace(/\.md$/, "")} but commands/${file} is missing`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const file of commands) {
|
|
74
|
+
if (!listed.includes(file)) {
|
|
75
|
+
fail(
|
|
76
|
+
`commands/${file} exists but README does not list /${file.replace(/\.md$/, "")}`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
requireTokens("commands/learn.md", [
|
|
82
|
+
"/learn eval",
|
|
83
|
+
"/learn status",
|
|
84
|
+
"/learn projects",
|
|
85
|
+
"/learn promote",
|
|
86
|
+
"/learn prune",
|
|
87
|
+
"/learn evolve",
|
|
88
|
+
"scripts/learning/review-confidence.js",
|
|
89
|
+
"scripts/learning/projects.js",
|
|
90
|
+
"scripts/learning/promote.js",
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function checkReadmeTreePaths() {
|
|
95
|
+
if (!exists("README.md")) return;
|
|
96
|
+
|
|
97
|
+
const body = read("README.md");
|
|
98
|
+
const treeMatch = body.match(/## 目录结构[\s\S]*?```([\s\S]*?)```/);
|
|
99
|
+
if (!treeMatch) {
|
|
100
|
+
fail("README.md should include a directory tree under ## 目录结构");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const ignored = new Set([
|
|
105
|
+
"claude-everything-Workflow",
|
|
106
|
+
"agents/...",
|
|
107
|
+
]);
|
|
108
|
+
const stack = [];
|
|
109
|
+
|
|
110
|
+
for (const rawLine of treeMatch[1].split(/\r?\n/)) {
|
|
111
|
+
const markerIndex = rawLine.search(/[├└]──/);
|
|
112
|
+
if (markerIndex < 0) continue;
|
|
113
|
+
|
|
114
|
+
const match = rawLine.match(/[├└]──\s+([^#\s]+)/);
|
|
115
|
+
if (!match) continue;
|
|
116
|
+
|
|
117
|
+
const normalized = match[1].replace(/\/$/, "");
|
|
118
|
+
if (!normalized || ignored.has(normalized)) continue;
|
|
119
|
+
|
|
120
|
+
const depth = Math.floor(markerIndex / 4);
|
|
121
|
+
stack[depth] = normalized;
|
|
122
|
+
stack.length = depth + 1;
|
|
123
|
+
|
|
124
|
+
const pathInTree = stack.join("/").replace(/\\/g, "/");
|
|
125
|
+
if (ignored.has(pathInTree)) continue;
|
|
126
|
+
|
|
127
|
+
if (!exists(pathInTree)) {
|
|
128
|
+
fail(`README directory tree lists missing path: ${pathInTree}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function quotedPackageOnlyPaths(source, bodyPattern) {
|
|
134
|
+
const body = source.match(bodyPattern)?.[1] ?? "";
|
|
135
|
+
return [...body.matchAll(/"([^"]+)"/g)].map((match) =>
|
|
136
|
+
match[1].replaceAll("\\", "/"),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function checkPackageOnlyLists(ps, sh) {
|
|
141
|
+
const psPaths = quotedPackageOnlyPaths(
|
|
142
|
+
ps,
|
|
143
|
+
/\$packageOnlyFiles = @\(([\s\S]*?)\r?\n\s*\)/,
|
|
144
|
+
);
|
|
145
|
+
const shPaths = quotedPackageOnlyPaths(
|
|
146
|
+
sh,
|
|
147
|
+
/remove_package_only_paths\(\) \{[\s\S]*?for file in \\\r?\n([\s\S]*?)\r?\n\s*do/,
|
|
148
|
+
);
|
|
149
|
+
const expected = JSON.stringify(PACKAGE_ONLY_PATHS);
|
|
150
|
+
if (JSON.stringify(psPaths) !== expected) {
|
|
151
|
+
fail(`scripts/install.ps1 package-only list mismatch: ${psPaths.join(", ")}`);
|
|
152
|
+
}
|
|
153
|
+
if (JSON.stringify(shPaths) !== expected) {
|
|
154
|
+
fail(`scripts/install.sh package-only list mismatch: ${shPaths.join(", ")}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function checkInstallerSurface(ps, sh) {
|
|
159
|
+
const sharedDirs = [
|
|
160
|
+
"rules",
|
|
161
|
+
"agents",
|
|
162
|
+
"commands",
|
|
163
|
+
"scripts",
|
|
164
|
+
"hooks",
|
|
165
|
+
"skills",
|
|
166
|
+
"references",
|
|
167
|
+
];
|
|
168
|
+
for (const dir of sharedDirs) {
|
|
169
|
+
if (!ps.includes(`"${dir}"`)) {
|
|
170
|
+
fail(`scripts/install.ps1 shared dirs should include ${dir}`);
|
|
171
|
+
}
|
|
172
|
+
if (!sh.includes(`copy_dir ${dir} "$dest"`)) {
|
|
173
|
+
fail(`scripts/install.sh shared dirs should include ${dir}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (ps.includes('"homunculus"')) {
|
|
177
|
+
fail("scripts/install.ps1 should not install removed homunculus directory");
|
|
178
|
+
}
|
|
179
|
+
if (sh.includes('copy_dir homunculus "$dest"')) {
|
|
180
|
+
fail("scripts/install.sh should not install removed homunculus directory");
|
|
181
|
+
}
|
|
182
|
+
const retiredCommands = [
|
|
183
|
+
"e2e.md", "evolve.md", "grill.md", "harness-audit.md", "instinct-status.md",
|
|
184
|
+
"learn-eval.md", "projects.md", "promote.md", "prune.md", "setup-workflow.md",
|
|
185
|
+
"tdd.md",
|
|
186
|
+
];
|
|
187
|
+
for (const command of retiredCommands) {
|
|
188
|
+
if (!sh.includes(`commands/${command}`)) {
|
|
189
|
+
fail(`scripts/install.sh should remove retired commands/${command}`);
|
|
190
|
+
}
|
|
191
|
+
if (!ps.includes(`commands\\${command}`)) {
|
|
192
|
+
fail(`scripts/install.ps1 should remove retired commands/${command}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const psCodexBody = ps.match(/function Install-CodexWorkflow \{[\s\S]*?\n\}/);
|
|
196
|
+
if (psCodexBody && psCodexBody[0].includes("settings.json")) {
|
|
197
|
+
fail("Install-CodexWorkflow should not install Claude Code settings.json");
|
|
198
|
+
}
|
|
199
|
+
const shCodexBody = sh.match(/install_codex\(\) \{[\s\S]*?\n\}/);
|
|
200
|
+
if (shCodexBody && shCodexBody[0].includes("settings.json")) {
|
|
201
|
+
fail("install_codex should not install Claude Code settings.json");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function checkInstallRuntimePolicy() {
|
|
206
|
+
requireTokens("README.md", [
|
|
207
|
+
"Codex 安装共享 Workflow 材料,不默认消费 Claude Code `settings.json`",
|
|
208
|
+
"Codex 安装同一套 `hooks/` 脚本材料,但不会因为安装本仓文件而自动启用 Claude Code hooks",
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
requireTokens("scripts/install.ps1", [
|
|
212
|
+
"Copy-ClaudeSettings",
|
|
213
|
+
"Install-CodexWorkflow",
|
|
214
|
+
"Copy-ConfigFile -Source (Join-Path $RootDir \"AGENTS.md\")",
|
|
215
|
+
"Remove-PackageOnlyPaths",
|
|
216
|
+
"scripts\\install.ps1",
|
|
217
|
+
"scripts\\verify-harness.js",
|
|
218
|
+
"scripts\\verify",
|
|
219
|
+
"scripts\\verify\\workflow-ownership-fixtures.js",
|
|
220
|
+
"scripts\\verify\\workflow-ownership.js",
|
|
221
|
+
]);
|
|
222
|
+
requireTokens("scripts/install.sh", [
|
|
223
|
+
"copy_claude_settings",
|
|
224
|
+
"install_codex()",
|
|
225
|
+
"copy_file \"$ROOT_DIR/AGENTS.md\" \"$dest/AGENTS.md\"",
|
|
226
|
+
"remove_package_only_paths",
|
|
227
|
+
"scripts/install.sh",
|
|
228
|
+
"scripts/verify-harness.js",
|
|
229
|
+
"scripts/verify",
|
|
230
|
+
"scripts/verify/workflow-ownership-fixtures.js",
|
|
231
|
+
"scripts/verify/workflow-ownership.js",
|
|
232
|
+
]);
|
|
233
|
+
|
|
234
|
+
const ps = read("scripts/install.ps1");
|
|
235
|
+
const sh = read("scripts/install.sh");
|
|
236
|
+
checkPackageOnlyLists(ps, sh);
|
|
237
|
+
checkInstallerSurface(ps, sh);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function checkHookConfigReferences() {
|
|
241
|
+
if (!exists("settings.json")) {
|
|
242
|
+
fail("settings.json is missing");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const settings = JSON.parse(read("settings.json"));
|
|
247
|
+
const commands = [];
|
|
248
|
+
|
|
249
|
+
function collect(value) {
|
|
250
|
+
if (!value) return;
|
|
251
|
+
if (Array.isArray(value)) {
|
|
252
|
+
value.forEach(collect);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (typeof value !== "object") return;
|
|
256
|
+
if (typeof value.command === "string") {
|
|
257
|
+
commands.push(value.command);
|
|
258
|
+
}
|
|
259
|
+
Object.values(value).forEach(collect);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
collect(settings.hooks);
|
|
263
|
+
|
|
264
|
+
const LEGACY_HOOK_PATTERNS = [
|
|
265
|
+
"scripts/hooks/run-with-flags.js",
|
|
266
|
+
"scripts/hooks/commit-quality.js",
|
|
267
|
+
"scripts/hooks/session-start.js",
|
|
268
|
+
"scripts/hooks/session-end.js",
|
|
269
|
+
"scripts/lib/hook-flags.js",
|
|
270
|
+
"hooks/observe.js",
|
|
271
|
+
"hooks/review-confidence.js",
|
|
272
|
+
"hooks/session-start.js",
|
|
273
|
+
"hooks/session-end.js",
|
|
274
|
+
"hooks/evaluate-session.js",
|
|
275
|
+
"hooks/pre-compact.js",
|
|
276
|
+
"hooks/runtime/session-utils.js",
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
for (const command of commands) {
|
|
280
|
+
if (command.includes("$HOME/.codex")) {
|
|
281
|
+
fail("settings.json should not point hooks at ~/.codex");
|
|
282
|
+
}
|
|
283
|
+
for (const legacy of LEGACY_HOOK_PATTERNS) {
|
|
284
|
+
if (command.includes(legacy)) {
|
|
285
|
+
fail(`settings.json contains legacy hook path: ${legacy}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const matches = [...command.matchAll(/\$HOME\/\.claude\/([^" ]+)/g)];
|
|
289
|
+
for (const match of matches) {
|
|
290
|
+
const referenced = match[1];
|
|
291
|
+
if (!exists(referenced)) {
|
|
292
|
+
fail(`settings.json references missing hook path: ${referenced}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
requireTokens("scripts/merge-claude-settings.cjs", [
|
|
298
|
+
"LEGACY_HOOK_PATTERNS",
|
|
299
|
+
"cleanHooks",
|
|
300
|
+
"mergeSettings",
|
|
301
|
+
]);
|
|
302
|
+
|
|
303
|
+
for (const installer of ["scripts/install.sh", "scripts/install.ps1"]) {
|
|
304
|
+
if (!exists(installer)) continue;
|
|
305
|
+
const body = read(installer);
|
|
306
|
+
if (!body.includes("merge-claude-settings.cjs")) {
|
|
307
|
+
fail(`${installer} should invoke the shared Claude settings merger`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function runCommand(command, args, { allowFailure = false, ...options } = {}) {
|
|
313
|
+
const result = spawnSync(command, args, {
|
|
314
|
+
encoding: "utf8",
|
|
315
|
+
timeout: 30000,
|
|
316
|
+
...options,
|
|
317
|
+
});
|
|
318
|
+
if (result.error) throw result.error;
|
|
319
|
+
if (!allowFailure && result.status !== 0) {
|
|
320
|
+
throw new Error(
|
|
321
|
+
`${command} ${args.join(" ")} failed:\n${result.stdout}${result.stderr}`,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function releaseScenario({ exactPublished = false, publishFails = false, tagAt }) {
|
|
328
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "cew-release-"));
|
|
329
|
+
const repository = path.join(tempRoot, "repository");
|
|
330
|
+
const remote = path.join(tempRoot, "remote.git");
|
|
331
|
+
const npmLog = path.join(tempRoot, "npm-calls.jsonl");
|
|
332
|
+
const isolatedGitEnvironment = {
|
|
333
|
+
...process.env,
|
|
334
|
+
GIT_CONFIG_GLOBAL: os.devNull,
|
|
335
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
336
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
337
|
+
XDG_CONFIG_HOME: path.join(tempRoot, "xdg-config"),
|
|
338
|
+
};
|
|
339
|
+
const git = (args, options = {}) => runCommand("git", args, {
|
|
340
|
+
env: isolatedGitEnvironment,
|
|
341
|
+
...options,
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
fs.mkdirSync(repository);
|
|
346
|
+
git(["init", "--bare", remote]);
|
|
347
|
+
git(["init", repository]);
|
|
348
|
+
git(["-C", repository, "config", "user.name", "Release Test"]);
|
|
349
|
+
git(["-C", repository, "config", "user.email", "release@example.com"]);
|
|
350
|
+
fs.writeFileSync(
|
|
351
|
+
path.join(repository, "package.json"),
|
|
352
|
+
JSON.stringify({ name: "claude-everything-workflow", version: "0.2.2" }),
|
|
353
|
+
);
|
|
354
|
+
git(["-C", repository, "add", "package.json"]);
|
|
355
|
+
git(["-C", repository, "commit", "-m", "initial"]);
|
|
356
|
+
const firstCommit = git(["-C", repository, "rev-parse", "HEAD"]).stdout.trim();
|
|
357
|
+
fs.writeFileSync(path.join(repository, "release.txt"), "current\n");
|
|
358
|
+
git(["-C", repository, "add", "release.txt"]);
|
|
359
|
+
git(["-C", repository, "commit", "-m", "current"]);
|
|
360
|
+
const currentCommit = git(["-C", repository, "rev-parse", "HEAD"]).stdout.trim();
|
|
361
|
+
git(["-C", repository, "remote", "add", "origin", remote]);
|
|
362
|
+
|
|
363
|
+
if (tagAt) {
|
|
364
|
+
const target = tagAt === "current" ? currentCommit : firstCommit;
|
|
365
|
+
git(["-C", repository, "tag", "-a", "v0.2.2", target, "-m", "test tag"]);
|
|
366
|
+
git(["-C", repository, "push", "origin", "v0.2.2"]);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const npmStub = path.join(tempRoot, "npm-stub.js");
|
|
370
|
+
fs.writeFileSync(
|
|
371
|
+
npmStub,
|
|
372
|
+
`const fs = require("fs");
|
|
373
|
+
const args = process.argv.slice(2);
|
|
374
|
+
fs.appendFileSync(process.env.NPM_CALL_LOG, JSON.stringify(args) + "\\n");
|
|
375
|
+
if (args[0] === "view" && args[1].includes("@0.2.2")) {
|
|
376
|
+
if (process.env.EXACT_PUBLISHED === "true") {
|
|
377
|
+
process.stdout.write("0.2.2\\n");
|
|
378
|
+
process.exit(0);
|
|
379
|
+
}
|
|
380
|
+
process.stderr.write("npm error code E404\\n");
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
if (args[0] === "view") {
|
|
384
|
+
process.stdout.write("0.1.9\\n");
|
|
385
|
+
process.exit(0);
|
|
386
|
+
}
|
|
387
|
+
if (args[0] === "publish") {
|
|
388
|
+
if (process.env.PUBLISH_FAILS === "true") {
|
|
389
|
+
process.stderr.write("publish failed\\n");
|
|
390
|
+
process.exit(1);
|
|
391
|
+
}
|
|
392
|
+
process.exit(0);
|
|
393
|
+
}
|
|
394
|
+
process.stderr.write("unexpected npm invocation: " + args.join(" ") + "\\n");
|
|
395
|
+
process.exit(2);
|
|
396
|
+
`,
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
const result = runCommand(
|
|
400
|
+
process.execPath,
|
|
401
|
+
[path.join(root, ".github/scripts/publish-release.js")],
|
|
402
|
+
{
|
|
403
|
+
allowFailure: true,
|
|
404
|
+
cwd: repository,
|
|
405
|
+
env: {
|
|
406
|
+
...isolatedGitEnvironment,
|
|
407
|
+
CEW_NPM_CLI: npmStub,
|
|
408
|
+
EXACT_PUBLISHED: String(exactPublished),
|
|
409
|
+
GITHUB_SHA: currentCommit,
|
|
410
|
+
NPM_CALL_LOG: npmLog,
|
|
411
|
+
PUBLISH_FAILS: String(publishFails),
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
);
|
|
415
|
+
const calls = fs.existsSync(npmLog)
|
|
416
|
+
? fs.readFileSync(npmLog, "utf8").trim().split("\n").filter(Boolean).map(JSON.parse)
|
|
417
|
+
: [];
|
|
418
|
+
const localTag = git(
|
|
419
|
+
["-C", repository, "rev-list", "-n", "1", "v0.2.2"],
|
|
420
|
+
{ allowFailure: true },
|
|
421
|
+
);
|
|
422
|
+
const remoteTag = git(
|
|
423
|
+
["--git-dir", remote, "rev-list", "-n", "1", "v0.2.2"],
|
|
424
|
+
{ allowFailure: true },
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
calls,
|
|
429
|
+
currentCommit,
|
|
430
|
+
firstCommit,
|
|
431
|
+
localTag: localTag.status === 0 ? localTag.stdout.trim() : "",
|
|
432
|
+
remoteTag: remoteTag.status === 0 ? remoteTag.stdout.trim() : "",
|
|
433
|
+
result,
|
|
434
|
+
};
|
|
435
|
+
} finally {
|
|
436
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function checkReleaseRecoveryBehavior() {
|
|
441
|
+
if (!exists(".github/scripts/publish-release.js")) {
|
|
442
|
+
fail("release workflow must use an executable publish-release script");
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const firstPublish = releaseScenario({});
|
|
447
|
+
if (
|
|
448
|
+
firstPublish.result.status !== 0 ||
|
|
449
|
+
!firstPublish.calls.some(([command]) => command === "publish") ||
|
|
450
|
+
firstPublish.remoteTag !== firstPublish.currentCommit
|
|
451
|
+
) {
|
|
452
|
+
fail("release script must publish an absent version before creating its tag");
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const failedPublish = releaseScenario({ publishFails: true });
|
|
456
|
+
if (
|
|
457
|
+
failedPublish.result.status === 0 ||
|
|
458
|
+
failedPublish.localTag ||
|
|
459
|
+
failedPublish.remoteTag
|
|
460
|
+
) {
|
|
461
|
+
fail("release script must not create a tag when npm publish fails");
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const publishedWithoutTag = releaseScenario({ exactPublished: true });
|
|
465
|
+
if (
|
|
466
|
+
publishedWithoutTag.result.status !== 0 ||
|
|
467
|
+
publishedWithoutTag.calls.some(([command]) => command === "publish") ||
|
|
468
|
+
publishedWithoutTag.remoteTag !== publishedWithoutTag.currentCommit
|
|
469
|
+
) {
|
|
470
|
+
fail("release script must recreate a missing tag for an already published version");
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const taggedWithoutPublish = releaseScenario({ tagAt: "current" });
|
|
474
|
+
if (
|
|
475
|
+
taggedWithoutPublish.result.status !== 0 ||
|
|
476
|
+
!taggedWithoutPublish.calls.some(([command]) => command === "publish") ||
|
|
477
|
+
taggedWithoutPublish.remoteTag !== taggedWithoutPublish.currentCommit
|
|
478
|
+
) {
|
|
479
|
+
fail("release script must publish when the correct tag already exists");
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const mismatchedTag = releaseScenario({ tagAt: "previous" });
|
|
483
|
+
if (
|
|
484
|
+
mismatchedTag.result.status === 0 ||
|
|
485
|
+
mismatchedTag.calls.some(([command]) => command === "publish") ||
|
|
486
|
+
mismatchedTag.remoteTag !== mismatchedTag.firstCommit
|
|
487
|
+
) {
|
|
488
|
+
fail("release script must reject a tag that points to another commit");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function checkGitHubWorkflows() {
|
|
493
|
+
const ci = read(".github/workflows/ci.yml");
|
|
494
|
+
|
|
495
|
+
requireTokens(".github/workflows/ci.yml", [
|
|
496
|
+
"pull_request",
|
|
497
|
+
"workflow_dispatch:",
|
|
498
|
+
"npm run verify",
|
|
499
|
+
"npm run pack:dry-run",
|
|
500
|
+
"publish:",
|
|
501
|
+
"needs: verify",
|
|
502
|
+
"id-token: write",
|
|
503
|
+
"node-version: 22.14.0",
|
|
504
|
+
"package-manager-cache: false",
|
|
505
|
+
"npm install -g npm@11.5.1",
|
|
506
|
+
"git config user.name \"github-actions[bot]\"",
|
|
507
|
+
"node .github/scripts/publish-release.js",
|
|
508
|
+
]);
|
|
509
|
+
|
|
510
|
+
requireTokens(".github/scripts/publish-release.js", [
|
|
511
|
+
'["publish"]',
|
|
512
|
+
'["push", "origin", tag]',
|
|
513
|
+
"exactVersionIsPublished",
|
|
514
|
+
"existingTagCommit",
|
|
515
|
+
"CEW_NPM_CLI",
|
|
516
|
+
]);
|
|
517
|
+
|
|
518
|
+
if (ci.includes("npm version \"$VERSION\"") || ci.includes("HEAD:main")) {
|
|
519
|
+
fail("ci.yml must not rewrite or push main during publish");
|
|
520
|
+
}
|
|
521
|
+
if (ci.includes("npm publish") || ci.includes("git push origin")) {
|
|
522
|
+
fail("ci.yml must delegate the release transaction to publish-release.js");
|
|
523
|
+
}
|
|
524
|
+
if (exists(".github/workflows/npm-publish.yml")) {
|
|
525
|
+
fail("legacy npm-publish workflow must be removed");
|
|
526
|
+
}
|
|
527
|
+
checkReleaseRecoveryBehavior();
|
|
528
|
+
|
|
529
|
+
requireTokens("README.md", [
|
|
530
|
+
"npm 发布",
|
|
531
|
+
"版本号通过 PR",
|
|
532
|
+
"ci.yml",
|
|
533
|
+
"受信任的发布商",
|
|
534
|
+
"npm 发布成功后才创建",
|
|
535
|
+
]);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function checkLearningPathPolicy() {
|
|
539
|
+
if (exists("homunculus")) {
|
|
540
|
+
fail("repository should not contain removed homunculus directory");
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const reviewScript = read("scripts/learning/review-confidence.js");
|
|
544
|
+
const repositoryInstinctsLookup =
|
|
545
|
+
/process\.cwd\(\)[\s\S]{0,120}["']homunculus["'][\s\S]{0,80}["']instincts["']/;
|
|
546
|
+
if (repositoryInstinctsLookup.test(reviewScript)) {
|
|
547
|
+
fail("review-confidence should not scan repository homunculus/instincts");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
for (const dir of [
|
|
551
|
+
"skills/learn",
|
|
552
|
+
"skills/learn/pr",
|
|
553
|
+
"skills/learn/testing",
|
|
554
|
+
"skills/learn/debugging",
|
|
555
|
+
]) {
|
|
556
|
+
if (!exists(dir)) {
|
|
557
|
+
fail(`${dir} is missing`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (exists("skills/learn")) {
|
|
562
|
+
const rootEntries = fs.readdirSync(rel("skills/learn"), {
|
|
563
|
+
withFileTypes: true,
|
|
564
|
+
});
|
|
565
|
+
for (const entry of rootEntries) {
|
|
566
|
+
if (entry.isFile() && ![".gitkeep", "README.md"].includes(entry.name)) {
|
|
567
|
+
fail(
|
|
568
|
+
`skills/learn root should not contain ${entry.name}; use a category directory`,
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
requireTokens("README.md", [
|
|
575
|
+
"skills/learn/<category>/",
|
|
576
|
+
"观察、候选和迁移来源",
|
|
577
|
+
]);
|
|
578
|
+
requireTokens("commands/learn.md", [
|
|
579
|
+
"/learn eval",
|
|
580
|
+
"/learn evolve",
|
|
581
|
+
"skills/learn/<category>/",
|
|
582
|
+
"候选证据来源",
|
|
583
|
+
"权威学习产物",
|
|
584
|
+
]);
|
|
585
|
+
requireTokens("rules/common/skills-learning.md", [
|
|
586
|
+
"skills/learn/<category>/",
|
|
587
|
+
"最终可复用学习产物",
|
|
588
|
+
]);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function checkSkillCategoryIndex() {
|
|
592
|
+
requireTokens("skills/README.md", [
|
|
593
|
+
"正式 skill 保持 `skills/<skill-name>/SKILL.md` 平铺结构",
|
|
594
|
+
"Process / 门禁",
|
|
595
|
+
"Engineering / 开发实践",
|
|
596
|
+
"Harness / 上下文与编排",
|
|
597
|
+
"Meta / Skill 管理",
|
|
598
|
+
"Learn / 学习沉淀",
|
|
599
|
+
]);
|
|
600
|
+
|
|
601
|
+
const indexed = new Set(
|
|
602
|
+
[...read("skills/README.md").matchAll(/^- `([^`]+)`:/gm)].map(
|
|
603
|
+
(match) => match[1],
|
|
604
|
+
),
|
|
605
|
+
);
|
|
606
|
+
const skillsDir = rel("skills");
|
|
607
|
+
const actual = fs
|
|
608
|
+
.readdirSync(skillsDir, { withFileTypes: true })
|
|
609
|
+
.filter((entry) => entry.isDirectory())
|
|
610
|
+
.map((entry) => entry.name)
|
|
611
|
+
.filter((name) => name !== "learn")
|
|
612
|
+
.filter((name) => exists(path.join("skills", name, "SKILL.md")))
|
|
613
|
+
.sort();
|
|
614
|
+
|
|
615
|
+
for (const name of actual) {
|
|
616
|
+
if (!indexed.has(name)) {
|
|
617
|
+
fail(`skills/README.md should categorize skill ${name}`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
for (const name of indexed) {
|
|
622
|
+
if (name === "learn") continue;
|
|
623
|
+
if (!exists(path.join("skills", name, "SKILL.md"))) {
|
|
624
|
+
fail(`skills/README.md lists missing skill ${name}`);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
requireTokens("README.md", [
|
|
629
|
+
"Skill 分类索引",
|
|
630
|
+
"物理目录保持平铺以兼容发现",
|
|
631
|
+
"只有学习产物使用物理分类目录 `skills/learn/<category>/`",
|
|
632
|
+
]);
|
|
633
|
+
|
|
634
|
+
requireTokens("rules/common/skills-learning.md", [
|
|
635
|
+
"正式 skill 目录保持 `skills/<skill-name>/SKILL.md` 平铺结构",
|
|
636
|
+
"分类维护在 `skills/README.md`",
|
|
637
|
+
]);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function checkRouterTargets() {
|
|
641
|
+
const expected = [
|
|
642
|
+
["commands/code-review.md", ["skills/code-review/SKILL.md"]],
|
|
643
|
+
["commands/learn.md", ["skills/continuous-learning-v2/SKILL.md"]],
|
|
644
|
+
["commands/to-spec.md", ["skills/spec-gate/SKILL.md"]],
|
|
645
|
+
];
|
|
646
|
+
|
|
647
|
+
for (const [command, targets] of expected) {
|
|
648
|
+
if (!exists(command)) {
|
|
649
|
+
fail(`${command} is missing`);
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
const body = read(command);
|
|
654
|
+
for (const target of targets) {
|
|
655
|
+
if (!exists(target)) {
|
|
656
|
+
fail(`${command} references missing ${target}`);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const token = target
|
|
660
|
+
.replace(/^agents\//, "")
|
|
661
|
+
.replace(/^skills\//, "skills/")
|
|
662
|
+
.replace(/\.md$/, "")
|
|
663
|
+
.replace(/\/SKILL$/, "");
|
|
664
|
+
|
|
665
|
+
if (!body.includes(token) && !body.includes(target)) {
|
|
666
|
+
fail(`${command} should mention ${target}`);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function checkNpmPackageSurface() {
|
|
673
|
+
requireTokens("package.json", [
|
|
674
|
+
'"name": "claude-everything-workflow"',
|
|
675
|
+
'"bin"',
|
|
676
|
+
'"claude-everything-workflow": "bin/claude-everything-workflow.js"',
|
|
677
|
+
'"cew": "bin/claude-everything-workflow.js"',
|
|
678
|
+
'"scripts/"',
|
|
679
|
+
]);
|
|
680
|
+
|
|
681
|
+
requireTokens("bin/claude-everything-workflow.js", [
|
|
682
|
+
"cew install",
|
|
683
|
+
"cew verify",
|
|
684
|
+
]);
|
|
685
|
+
|
|
686
|
+
const packageFiles = JSON.parse(read("package.json")).files ?? [];
|
|
687
|
+
const publishesHomunculus = packageFiles.some((file) => {
|
|
688
|
+
const normalized = file.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
689
|
+
return normalized === "homunculus" || normalized.startsWith("homunculus/");
|
|
690
|
+
});
|
|
691
|
+
if (publishesHomunculus) {
|
|
692
|
+
fail("package.json should not publish removed homunculus directory");
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const cliHelp = spawnSync(
|
|
696
|
+
process.execPath,
|
|
697
|
+
["bin/claude-everything-workflow.js", "--help"],
|
|
698
|
+
{
|
|
699
|
+
cwd: root,
|
|
700
|
+
encoding: "utf8",
|
|
701
|
+
timeout: 10000,
|
|
702
|
+
},
|
|
703
|
+
);
|
|
704
|
+
if (cliHelp.status !== 0 || !cliHelp.stdout.includes("cew install")) {
|
|
705
|
+
fail(
|
|
706
|
+
`npm CLI help failed:\n${cliHelp.stdout}${cliHelp.stderr}`,
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function runMetadataChecks(context) {
|
|
712
|
+
bindContext(context);
|
|
713
|
+
checkCommands();
|
|
714
|
+
checkReadmeTreePaths();
|
|
715
|
+
checkInstallRuntimePolicy();
|
|
716
|
+
checkHookConfigReferences();
|
|
717
|
+
checkGitHubWorkflows();
|
|
718
|
+
checkLearningPathPolicy();
|
|
719
|
+
checkSkillCategoryIndex();
|
|
720
|
+
checkRouterTargets();
|
|
721
|
+
checkNpmPackageSurface();
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
module.exports = { runMetadataChecks };
|