claude-everything-workflow 0.1.9 → 0.2.3

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 (152) hide show
  1. package/AGENTS.md +20 -20
  2. package/CLAUDE.md +1 -5
  3. package/README.md +151 -113
  4. package/agents/e2e-runner.md +8 -141
  5. package/agents/harness-optimizer.md +3 -2
  6. package/commands/code-review.md +10 -15
  7. package/commands/learn.md +97 -0
  8. package/commands/pr.md +5 -6
  9. package/commands/to-spec.md +11 -0
  10. package/commands/verify.md +7 -11
  11. package/harness/manifest.json +346 -0
  12. package/hooks/check-code-size.js +33 -12
  13. package/hooks/check-console-log.js +72 -24
  14. package/package.json +10 -2
  15. package/rules/01-base.md +9 -49
  16. package/rules/02-code-size.md +5 -20
  17. package/rules/03-architecture.md +9 -61
  18. package/rules/04-error-handling.md +4 -26
  19. package/rules/05-git-workflow.md +12 -39
  20. package/rules/06-comments.md +3 -43
  21. package/rules/07-forbidden.md +8 -31
  22. package/rules/08-specialty-rules-index.md +18 -0
  23. package/rules/09-first-principles-adversarial-testing.md +6 -18
  24. package/rules/common/agent-orchestration.md +8 -47
  25. package/rules/common/context-hygiene.md +9 -72
  26. package/rules/common/harness-engineering.md +11 -38
  27. package/rules/common/hooks.md +13 -82
  28. package/rules/common/performance.md +8 -71
  29. package/rules/common/pr-automation.md +7 -68
  30. package/rules/common/skills-learning.md +12 -36
  31. package/rules/common/testing.md +16 -59
  32. package/scripts/cleanup-retired-skills.js +214 -0
  33. package/scripts/install-rules.js +100 -0
  34. package/scripts/install.ps1 +99 -87
  35. package/scripts/install.sh +77 -78
  36. package/scripts/learning/review-confidence.js +1 -4
  37. package/scripts/legacy-common-rule-hashes.json +78 -0
  38. package/scripts/merge-claude-settings.cjs +75 -0
  39. package/scripts/retired-skill-files.json +54 -0
  40. package/scripts/upstream-capability-baseline.json +27 -0
  41. package/scripts/upstream-capability-map.json +155 -0
  42. package/scripts/verify/core.js +91 -0
  43. package/scripts/verify/grilling-spec-gate-checks.js +266 -0
  44. package/scripts/verify/install-rules.test.js +156 -0
  45. package/scripts/verify/metadata-checks.js +747 -0
  46. package/scripts/verify/repository-checks.js +409 -0
  47. package/scripts/verify/runtime-checks.js +593 -0
  48. package/scripts/verify/skill-invocation.test.js +86 -0
  49. package/scripts/verify/skill-manifest-checks.js +197 -0
  50. package/scripts/verify/skill-manifest-checks.test.js +123 -0
  51. package/scripts/verify/workflow-checks.js +685 -0
  52. package/scripts/verify/workflow-ownership-fixtures.js +371 -0
  53. package/scripts/verify/workflow-ownership.js +780 -0
  54. package/scripts/verify-harness.js +18 -1075
  55. package/scripts/verify-upstream-capability-map.js +118 -0
  56. package/skills/README.md +28 -16
  57. package/skills/code-review/SKILL.md +63 -0
  58. package/skills/code-review/references/spec-reviewer-prompt.md +24 -0
  59. package/skills/code-review/references/standards-reviewer-prompt.md +35 -0
  60. package/skills/codebase-design/SKILL.md +63 -0
  61. package/skills/codebase-design/references/deepening.md +27 -0
  62. package/skills/codebase-design/references/design-it-twice.md +17 -0
  63. package/skills/continuous-learning-v2/SKILL.md +8 -8
  64. package/skills/continuous-learning-v2/config.json +0 -4
  65. package/skills/domain-modeling/SKILL.md +101 -0
  66. package/skills/e2e-testing/SKILL.md +20 -310
  67. package/skills/e2e-testing/references/playwright-patterns.md +324 -0
  68. package/skills/feature-acceptance/SKILL.md +89 -0
  69. package/skills/grilling/SKILL.md +83 -0
  70. package/skills/handoff/SKILL.md +55 -0
  71. package/skills/handoff/agents/openai.yaml +2 -0
  72. package/skills/implement/SKILL.md +48 -0
  73. package/skills/implement/references/ticket-delivery.md +43 -0
  74. package/skills/improve-codebase-architecture/SKILL.md +47 -0
  75. package/skills/improve-codebase-architecture/agents/openai.yaml +2 -0
  76. package/skills/iterative-retrieval/SKILL.md +10 -1
  77. package/skills/learn/README.md +2 -2
  78. package/skills/prototype/SKILL.md +50 -0
  79. package/skills/prototype/references/logic.md +28 -0
  80. package/skills/prototype/references/ui.md +30 -0
  81. package/skills/resolving-merge-conflicts/SKILL.md +27 -0
  82. package/skills/spec-gate/SKILL.md +149 -0
  83. package/skills/spec-gate/agents/openai.yaml +4 -0
  84. package/skills/spec-gate/references/spec-document-reviewer-prompt.md +31 -0
  85. package/skills/subagent-driven-development/SKILL.md +95 -414
  86. package/skills/systematic-debugging/SKILL.md +11 -49
  87. package/skills/systematic-debugging/references/diagnosing-bugs.upstream.md +129 -0
  88. package/skills/systematic-debugging/scripts/hitl-loop.template.js +75 -0
  89. package/skills/systematic-debugging/scripts/hitl-loop.template.sh +41 -0
  90. package/skills/test-driven-development/SKILL.md +24 -4
  91. package/skills/to-tickets/SKILL.md +96 -0
  92. package/skills/triage/SKILL.md +53 -0
  93. package/skills/triage/agents/openai.yaml +2 -0
  94. package/skills/triage/references/agent-brief.md +32 -0
  95. package/skills/triage/references/out-of-scope.md +14 -0
  96. package/skills/using-git-worktrees/SKILL.md +8 -5
  97. package/skills/using-superpowers/SKILL.md +76 -43
  98. package/skills/using-superpowers/references/process-outcomes.md +41 -0
  99. package/skills/verification-before-completion/SKILL.md +5 -4
  100. package/skills/visual-companion/SKILL.md +62 -0
  101. package/skills/visual-companion/agents/openai.yaml +4 -0
  102. package/skills/{brainstorming/visual-companion.md → visual-companion/references/guide.md} +1 -1
  103. package/skills/{brainstorming → visual-companion}/scripts/frame-template.html +42 -12
  104. package/skills/visual-companion/scripts/pages.cjs +28 -0
  105. package/skills/visual-companion/scripts/server-utils.cjs +82 -0
  106. package/skills/{brainstorming → visual-companion}/scripts/server.cjs +108 -248
  107. package/skills/{brainstorming → visual-companion}/scripts/start-server.sh +18 -4
  108. package/skills/visual-companion/scripts/websocket.cjs +86 -0
  109. package/agents/architect.md +0 -59
  110. package/agents/code-reviewer.md +0 -57
  111. package/agents/planner.md +0 -124
  112. package/agents/tdd-guide.md +0 -101
  113. package/commands/e2e.md +0 -28
  114. package/commands/evolve.md +0 -42
  115. package/commands/harness-audit.md +0 -27
  116. package/commands/instinct-status.md +0 -38
  117. package/commands/learn-eval.md +0 -91
  118. package/commands/projects.md +0 -27
  119. package/commands/promote.md +0 -29
  120. package/commands/prune.md +0 -46
  121. package/commands/tdd.md +0 -27
  122. package/homunculus/instincts/personal/always-test-first.md +0 -28
  123. package/homunculus/instincts/personal/pr-ci-quality-gate.md +0 -30
  124. package/rules/08-ecc-integration.md +0 -46
  125. package/rules/common/implementation.md +0 -25
  126. package/rules/common/security.md +0 -19
  127. package/skills/brainstorming/SKILL.md +0 -185
  128. package/skills/brainstorming/agents/openai.yaml +0 -3
  129. package/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  130. package/skills/context-budget/SKILL.md +0 -59
  131. package/skills/discover-unknowns-zh/SKILL.md +0 -112
  132. package/skills/discover-unknowns-zh/agents/openai.yaml +0 -4
  133. package/skills/discover-unknowns-zh/references/prompt-patterns.md +0 -144
  134. package/skills/documentation-lookup/SKILL.md +0 -90
  135. package/skills/executing-plans/SKILL.md +0 -66
  136. package/skills/find-skills/SKILL.md +0 -142
  137. package/skills/skill-creator/LICENSE.txt +0 -202
  138. package/skills/skill-creator/SKILL.md +0 -356
  139. package/skills/skill-creator/references/output-patterns.md +0 -82
  140. package/skills/skill-creator/references/workflows.md +0 -28
  141. package/skills/skill-creator/scripts/init_skill.py +0 -303
  142. package/skills/skill-creator/scripts/package_skill.py +0 -110
  143. package/skills/skill-creator/scripts/quick_validate.py +0 -95
  144. package/skills/subagent-driven-development/implementer-prompt.md +0 -139
  145. package/skills/subagent-driven-development/scripts/review-package +0 -44
  146. package/skills/subagent-driven-development/scripts/sdd-workspace +0 -22
  147. package/skills/subagent-driven-development/scripts/task-brief +0 -40
  148. package/skills/subagent-driven-development/task-reviewer-prompt.md +0 -188
  149. package/skills/writing-plans/SKILL.md +0 -206
  150. package/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
  151. /package/skills/{brainstorming → visual-companion}/scripts/helper.js +0 -0
  152. /package/skills/{brainstorming → visual-companion}/scripts/stop-server.sh +0 -0
@@ -0,0 +1,593 @@
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 managedFiles;
13
+ let fail;
14
+ let warn;
15
+ let requireTokens;
16
+ let isVerifierImplementation;
17
+
18
+ function bindContext(context) {
19
+ ({
20
+ root,
21
+ rel,
22
+ exists,
23
+ read,
24
+ managedFiles,
25
+ fail,
26
+ warn,
27
+ requireTokens,
28
+ isVerifierImplementation,
29
+ } = context);
30
+ }
31
+
32
+ function checkScriptLayout() {
33
+ for (const legacyPath of [
34
+ "scripts/hooks/run-with-flags.js",
35
+ "scripts/hooks/commit-quality.js",
36
+ "scripts/hooks/session-start.js",
37
+ "scripts/hooks/session-end.js",
38
+ "scripts/lib/hook-flags.js",
39
+ "scripts/lib/utils.js",
40
+ "scripts/learning/utils.js",
41
+ "hooks/review-confidence.js",
42
+ "hooks/session-start.js",
43
+ "hooks/session-end.js",
44
+ "hooks/evaluate-session.js",
45
+ "hooks/pre-compact.js",
46
+ "hooks/runtime/session-utils.js",
47
+ ]) {
48
+ if (exists(legacyPath)) {
49
+ fail(`${legacyPath} should not exist after script layout cleanup`);
50
+ }
51
+ }
52
+
53
+ for (const requiredPath of [
54
+ "hooks/runtime/run-with-flags.js",
55
+ "hooks/runtime/hook-flags.js",
56
+ "hooks/commit-quality.js",
57
+ "hooks/check-console-log.js",
58
+ "hooks/check-code-size.js",
59
+ "scripts/learning/review-confidence.js",
60
+ "scripts/learning/project-utils.js",
61
+ "scripts/learning/projects.js",
62
+ "scripts/learning/promote.js",
63
+ "scripts/learning/migrate-homunculus.js",
64
+ "scripts/merge-claude-settings.cjs",
65
+ ]) {
66
+ if (!exists(requiredPath)) {
67
+ fail(`${requiredPath} is missing after script layout cleanup`);
68
+ }
69
+ }
70
+
71
+ requireTokens("settings.json", [
72
+ "hooks/runtime/run-with-flags.js",
73
+ "hooks/check-console-log.js",
74
+ "hooks/check-code-size.js",
75
+ "hooks/commit-quality.js",
76
+ "skills/continuous-learning-v2/hooks/observe-v2.js",
77
+ ]);
78
+
79
+ requireTokens("scripts/install.ps1", [
80
+ "Remove-ObsoleteWorkflowPaths",
81
+ "Remove-RetiredSkills",
82
+ "Test-RetiredSkillManifest",
83
+ "scripts\\hooks\\run-with-flags.js",
84
+ "hooks\\review-confidence.js",
85
+ "rules\\08-ecc-integration.md",
86
+ ]);
87
+
88
+ requireTokens("scripts/install.sh", [
89
+ "remove_obsolete_workflow_paths",
90
+ "cleanup_retired_skills",
91
+ "validate_retired_skill_manifest",
92
+ "scripts/hooks/run-with-flags.js",
93
+ "hooks/review-confidence.js",
94
+ "rules/08-ecc-integration.md",
95
+ ]);
96
+
97
+ checkLegacyScriptReferences();
98
+ }
99
+
100
+ function checkLegacyScriptReferences() {
101
+ for (const file of managedFiles()) {
102
+ if (
103
+ isVerifierImplementation(file) ||
104
+ [
105
+ "scripts/install.ps1",
106
+ "scripts/install.sh",
107
+ "scripts/merge-claude-settings.cjs",
108
+ ].includes(file)
109
+ ) continue;
110
+ if (!/\.(md|json|js|ps1|sh)$/.test(file)) continue;
111
+
112
+ const body = read(file);
113
+ for (const forbidden of [
114
+ "scripts/hooks/run-with-flags.js",
115
+ "scripts/lib/hook-flags.js",
116
+ "hooks/review-confidence.js",
117
+ "hooks/session-start.js",
118
+ "hooks/session-end.js",
119
+ "hooks/evaluate-session.js",
120
+ "hooks/pre-compact.js",
121
+ "hooks/runtime/session-utils.js",
122
+ ]) {
123
+ if (body.includes(forbidden)) {
124
+ fail(`${file} references legacy path ${forbidden}`);
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+ function checkContinuousLearningV21() {
131
+ requireTokens("skills/continuous-learning-v2/config.json", [
132
+ '"version": "2.1"',
133
+ '"data_root": "~/.local/share/ecc-homunculus"',
134
+ '"project_scoped": true',
135
+ '"promotion_min_confidence": 0.7',
136
+ ]);
137
+
138
+ requireTokens("skills/continuous-learning-v2/SKILL.md", [
139
+ "Continuous Learning v2.1",
140
+ "projects/<project-id>/",
141
+ "observations.jsonl",
142
+ "/learn projects",
143
+ "/learn promote --dry-run",
144
+ "migrate-homunculus.js --dry-run",
145
+ "observer.enabled",
146
+ ]);
147
+
148
+ requireTokens("skills/continuous-learning-v2/hooks/observe-v2.js", [
149
+ "registerProject",
150
+ "projects",
151
+ "observations.jsonl",
152
+ ]);
153
+
154
+ requireTokens("scripts/learning/review-confidence.js", [
155
+ "--scope <范围>",
156
+ "project",
157
+ "global",
158
+ "legacy",
159
+ ]);
160
+
161
+ requireTokens("commands/learn.md", [
162
+ "/learn projects",
163
+ "scripts/learning/projects.js",
164
+ "--register-current",
165
+ "/learn promote",
166
+ "scripts/learning/promote.js",
167
+ "--dry-run",
168
+ "--apply",
169
+ ]);
170
+ }
171
+
172
+ function checkObserveV2() {
173
+ const hook = rel("skills/continuous-learning-v2/hooks/observe-v2.js");
174
+ const config = rel("skills/continuous-learning-v2/config.json");
175
+ if (fs.existsSync(rel("hooks/observe.js"))) {
176
+ fail("legacy hooks/observe.js should not exist; use observe-v2 only");
177
+ }
178
+ if (!fs.existsSync(hook)) return fail("observe-v2.js is missing");
179
+ if (!fs.existsSync(config))
180
+ return fail("continuous-learning-v2 config is missing");
181
+
182
+ const tempHome = rel(".tmp-verify-harness");
183
+ const tempConfigDir = path.join(
184
+ tempHome,
185
+ ".claude",
186
+ "skills",
187
+ "continuous-learning-v2",
188
+ );
189
+ const observationsPath = path.join(
190
+ tempHome,
191
+ ".claude",
192
+ "homunculus",
193
+ "observations.jsonl",
194
+ );
195
+
196
+ fs.rmSync(tempHome, { recursive: true, force: true });
197
+ fs.mkdirSync(tempConfigDir, { recursive: true });
198
+
199
+ const cfg = JSON.parse(fs.readFileSync(config, "utf8"));
200
+ cfg.observation = cfg.observation || {};
201
+ cfg.observation.enabled = true;
202
+ cfg.observation.store_path = observationsPath;
203
+ fs.writeFileSync(
204
+ path.join(tempConfigDir, "config.json"),
205
+ JSON.stringify(cfg, null, 2),
206
+ );
207
+
208
+ const input = JSON.stringify({
209
+ tool: "Edit",
210
+ cwd: root,
211
+ tool_input: { file_path: "README.md" },
212
+ session_id: "verify-harness",
213
+ });
214
+
215
+ const result = spawnSync(process.execPath, [hook, "post"], {
216
+ cwd: root,
217
+ input,
218
+ encoding: "utf8",
219
+ env: {
220
+ ...process.env,
221
+ HOME: tempHome,
222
+ USERPROFILE: tempHome,
223
+ },
224
+ timeout: 10000,
225
+ });
226
+
227
+ if (result.error)
228
+ fail(`observe-v2 smoke test failed: ${result.error.message}`);
229
+ if (result.status !== 0)
230
+ fail(`observe-v2 exited ${result.status}: ${result.stderr}`);
231
+ if (!fs.existsSync(observationsPath)) {
232
+ fail("observe-v2 did not write observations.jsonl");
233
+ } else {
234
+ const firstLine = fs
235
+ .readFileSync(observationsPath, "utf8")
236
+ .split(/\r?\n/)[0];
237
+ try {
238
+ const event = JSON.parse(firstLine);
239
+ if (event.tool !== "Edit" || event.event !== "tool_complete") {
240
+ fail("observe-v2 wrote unexpected observation payload");
241
+ }
242
+ } catch (err) {
243
+ fail(`observe-v2 wrote invalid JSON: ${err.message}`);
244
+ }
245
+ }
246
+
247
+ fs.rmSync(tempHome, { recursive: true, force: true });
248
+ }
249
+
250
+ function runCodexInstall(tempHome) {
251
+ fs.mkdirSync(tempHome, { recursive: true });
252
+ const result = spawnSync(
253
+ "bash",
254
+ [rel("scripts/install.sh"), "--codex-only"],
255
+ {
256
+ cwd: root,
257
+ encoding: "utf8",
258
+ env: { ...process.env, HOME: tempHome, USERPROFILE: tempHome },
259
+ timeout: 30000,
260
+ },
261
+ );
262
+ if (result.error) {
263
+ fail(`Codex install smoke test failed: ${result.error.message}`);
264
+ return false;
265
+ }
266
+ if (result.status !== 0) {
267
+ fail(`Codex install smoke test exited ${result.status}: ${result.stderr}`);
268
+ return false;
269
+ }
270
+ return true;
271
+ }
272
+
273
+ function installedRuntimeSources(directory) {
274
+ if (!fs.existsSync(directory)) return [];
275
+ const sources = [];
276
+ const pending = [directory];
277
+ while (pending.length > 0) {
278
+ const current = pending.pop();
279
+ for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
280
+ const target = path.join(current, entry.name);
281
+ if (entry.isDirectory()) pending.push(target);
282
+ // Installed Node runtimes may use .js, .cjs, or .mjs module conventions.
283
+ if (entry.isFile() && /\.(?:c|m)?js$/.test(entry.name)) sources.push(target);
284
+ }
285
+ }
286
+ return sources;
287
+ }
288
+
289
+ function checkInstalledCommonmarkIsolation(codexHome) {
290
+ // Match CommonJS, dynamic/side-effect imports, package subpaths, and static `from` imports.
291
+ const commonmarkImport =
292
+ /(?:require|import)\s*(?:\(\s*)?["']commonmark(?:\/[^"']*)?["']|\bfrom\s*["']commonmark(?:\/[^"']*)?["']/;
293
+ for (const source of installedRuntimeSources(codexHome)) {
294
+ if (commonmarkImport.test(fs.readFileSync(source, "utf8"))) {
295
+ fail(`${source} must not import package-only commonmark`);
296
+ }
297
+ }
298
+ }
299
+
300
+ function checkInstalledPackageOnlyPaths() {
301
+ if (process.platform === "win32") return;
302
+
303
+ const tempRoot = fs.mkdtempSync(
304
+ path.join(os.tmpdir(), "cew-install-package-only-"),
305
+ );
306
+ try {
307
+ const cleanHome = path.join(tempRoot, "clean");
308
+ if (!runCodexInstall(cleanHome)) return;
309
+ const cleanScripts = path.join(cleanHome, ".codex", "scripts");
310
+ for (const relative of ["verify-harness.js", "verify"]) {
311
+ if (fs.existsSync(path.join(cleanScripts, relative))) {
312
+ fail(`Codex install must omit package-only scripts/${relative}`);
313
+ }
314
+ }
315
+ checkInstalledCommonmarkIsolation(path.join(cleanHome, ".codex"));
316
+
317
+ const preserveHome = path.join(tempRoot, "preserve");
318
+ const userFile = path.join(
319
+ preserveHome,
320
+ ".codex",
321
+ "scripts",
322
+ "verify",
323
+ "user-notes.js",
324
+ );
325
+ fs.mkdirSync(path.dirname(userFile), { recursive: true });
326
+ fs.writeFileSync(userFile, "// user-owned fixture\n");
327
+ if (!runCodexInstall(preserveHome)) return;
328
+ if (!fs.existsSync(userFile)) {
329
+ fail("Codex install removed an unknown user-owned verifier file");
330
+ }
331
+ checkInstalledCommonmarkIsolation(path.join(preserveHome, ".codex"));
332
+ } finally {
333
+ fs.rmSync(tempRoot, { recursive: true, force: true });
334
+ }
335
+ }
336
+
337
+ function createRetiredSkillFixture() {
338
+ const tempRoot = fs.mkdtempSync(
339
+ path.join(os.tmpdir(), "cew-retired-skill-cleanup-"),
340
+ );
341
+ const at = (...parts) => path.join(tempRoot, ...parts);
342
+ const fixture = {
343
+ tempRoot,
344
+ known: at("skills", "brainstorming", "SKILL.md"),
345
+ unknown: at("skills", "brainstorming", "user-notes.md"),
346
+ dryRunKnown: at("skills", "discover-unknowns-zh", "SKILL.md"),
347
+ creatorKnown: at("skills", "skill-creator", "scripts", "quick_validate.py"),
348
+ creatorUnknown: at("skills", "skill-creator", "user-template.md"),
349
+ nestedSymlink: at("skills", "brainstorming", "scripts"),
350
+ nestedExternalKnown: at("outside-nested-directory", "helper.js"),
351
+ rootSymlinkInstall: at("root-symlink-install"),
352
+ rootSymlink: at(
353
+ "root-symlink-install",
354
+ "skills",
355
+ "discover-unknowns-zh",
356
+ ),
357
+ rootExternalKnown: at("outside-retired-skill", "SKILL.md"),
358
+ leafSymlinkInstall: at("leaf-symlink-install"),
359
+ leafSymlink: at(
360
+ "leaf-symlink-install",
361
+ "skills",
362
+ "discover-unknowns-zh",
363
+ "SKILL.md",
364
+ ),
365
+ leafExternalKnown: at("outside-leaf-symlink", "SKILL.md"),
366
+ permissionInstall: at("permission-install"),
367
+ permissionSkillsRoot: at("permission-install", "skills"),
368
+ testLeafSymlink: process.platform !== "win32",
369
+ };
370
+
371
+ for (const file of [
372
+ fixture.known,
373
+ fixture.unknown,
374
+ fixture.dryRunKnown,
375
+ fixture.creatorKnown,
376
+ fixture.creatorUnknown,
377
+ ]) {
378
+ fs.mkdirSync(path.dirname(file), { recursive: true });
379
+ fs.writeFileSync(file, "fixture");
380
+ }
381
+ fs.mkdirSync(path.dirname(fixture.rootExternalKnown), { recursive: true });
382
+ fs.writeFileSync(fixture.rootExternalKnown, "must stay");
383
+ fs.mkdirSync(path.dirname(fixture.rootSymlink), { recursive: true });
384
+ fs.symlinkSync(
385
+ path.dirname(fixture.rootExternalKnown),
386
+ fixture.rootSymlink,
387
+ process.platform === "win32" ? "junction" : "dir",
388
+ );
389
+ fs.mkdirSync(path.dirname(fixture.nestedSymlink), { recursive: true });
390
+ fs.mkdirSync(path.dirname(fixture.nestedExternalKnown), { recursive: true });
391
+ fs.writeFileSync(fixture.nestedExternalKnown, "must also stay");
392
+ fs.symlinkSync(
393
+ path.dirname(fixture.nestedExternalKnown),
394
+ fixture.nestedSymlink,
395
+ process.platform === "win32" ? "junction" : "dir",
396
+ );
397
+ if (fixture.testLeafSymlink) {
398
+ fs.mkdirSync(path.dirname(fixture.leafSymlink), { recursive: true });
399
+ fs.mkdirSync(path.dirname(fixture.leafExternalKnown), { recursive: true });
400
+ fs.writeFileSync(fixture.leafExternalKnown, "must stay linked");
401
+ fs.symlinkSync(fixture.leafExternalKnown, fixture.leafSymlink, "file");
402
+ }
403
+ fs.mkdirSync(fixture.permissionSkillsRoot, { recursive: true });
404
+ return fixture;
405
+ }
406
+
407
+ function runRetiredSkillCleanup(cleanup, args) {
408
+ return spawnSync(process.execPath, [cleanup, ...args], {
409
+ cwd: root,
410
+ encoding: "utf8",
411
+ timeout: 10000,
412
+ });
413
+ }
414
+
415
+ function isSymlink(file) {
416
+ try {
417
+ return fs.lstatSync(file).isSymbolicLink();
418
+ } catch (error) {
419
+ if (error.code === "ENOENT") return false;
420
+ throw error;
421
+ }
422
+ }
423
+
424
+ function assertRetiredSkillCleanup(fixture) {
425
+ if (
426
+ fs.existsSync(fixture.known) ||
427
+ fs.existsSync(fixture.dryRunKnown) ||
428
+ fs.existsSync(fixture.creatorKnown)
429
+ ) {
430
+ fail("retired skill cleanup did not remove known files");
431
+ }
432
+ if (
433
+ !fs.existsSync(fixture.unknown) ||
434
+ !fs.existsSync(fixture.creatorUnknown)
435
+ ) {
436
+ fail("retired skill cleanup removed an unknown user file");
437
+ }
438
+ if (
439
+ !fs.existsSync(fixture.rootExternalKnown) ||
440
+ !isSymlink(fixture.rootSymlink)
441
+ ) {
442
+ fail("retired skill cleanup followed a symlinked skill directory");
443
+ }
444
+ if (
445
+ !fs.existsSync(fixture.nestedExternalKnown) ||
446
+ !isSymlink(fixture.nestedSymlink)
447
+ ) {
448
+ fail("retired skill cleanup followed a nested directory symlink");
449
+ }
450
+ const leafSymlinkPreserved =
451
+ !fixture.testLeafSymlink ||
452
+ (
453
+ fs.existsSync(fixture.leafExternalKnown) &&
454
+ isSymlink(fixture.leafSymlink)
455
+ );
456
+ if (!leafSymlinkPreserved) {
457
+ fail("retired skill cleanup removed a leaf symlink");
458
+ }
459
+ }
460
+
461
+ function checkPermissionFailure(cleanup, fixture) {
462
+ if (process.platform === "win32") return;
463
+
464
+ fs.chmodSync(fixture.permissionInstall, 0o000);
465
+ try {
466
+ const result = runRetiredSkillCleanup(cleanup, [
467
+ fixture.permissionInstall,
468
+ ]);
469
+ if (result.status === 0) {
470
+ fail("retired skill cleanup ignored an inaccessible install root");
471
+ }
472
+ } finally {
473
+ fs.chmodSync(fixture.permissionInstall, 0o700);
474
+ }
475
+ }
476
+
477
+ function checkRetiredSkillCleanup() {
478
+ const cleanup = rel("scripts/cleanup-retired-skills.js");
479
+ const manifest = rel("scripts/retired-skill-files.json");
480
+ if (!fs.existsSync(cleanup)) return fail("retired skill cleanup script is missing");
481
+ if (!fs.existsSync(manifest)) return fail("retired skill manifest is missing");
482
+
483
+ const fixture = createRetiredSkillFixture();
484
+ try {
485
+ const validation = runRetiredSkillCleanup(cleanup, ["--validate"]);
486
+ if (validation.status !== 0) {
487
+ fail(`retired skill manifest validation failed: ${validation.stderr}`);
488
+ }
489
+
490
+ const dryRun = runRetiredSkillCleanup(cleanup, [
491
+ fixture.tempRoot,
492
+ "--dry-run",
493
+ ]);
494
+ if (dryRun.status !== 0) {
495
+ fail(`retired skill cleanup dry-run failed: ${dryRun.stderr}`);
496
+ }
497
+ if (!dryRun.stdout.includes("Preserve unknown retired skill path")) {
498
+ fail("retired skill cleanup dry-run did not report preserved unknown files");
499
+ }
500
+ if (
501
+ !fs.existsSync(fixture.known) ||
502
+ !fs.existsSync(fixture.dryRunKnown) ||
503
+ !fs.existsSync(fixture.creatorKnown)
504
+ ) {
505
+ fail("retired skill cleanup dry-run modified files");
506
+ }
507
+
508
+ for (let attempt = 1; attempt <= 2; attempt += 1) {
509
+ const result = runRetiredSkillCleanup(cleanup, [fixture.tempRoot]);
510
+ if (result.status !== 0) {
511
+ fail(`retired skill cleanup attempt ${attempt} failed: ${result.stderr}`);
512
+ }
513
+ }
514
+ const rootSymlink = runRetiredSkillCleanup(cleanup, [
515
+ fixture.rootSymlinkInstall,
516
+ ]);
517
+ if (rootSymlink.status !== 0) {
518
+ fail(`retired skill root symlink cleanup failed: ${rootSymlink.stderr}`);
519
+ }
520
+ if (fixture.testLeafSymlink) {
521
+ const leafSymlink = runRetiredSkillCleanup(cleanup, [
522
+ fixture.leafSymlinkInstall,
523
+ ]);
524
+ if (leafSymlink.status !== 0) {
525
+ fail(`retired skill leaf symlink cleanup failed: ${leafSymlink.stderr}`);
526
+ }
527
+ }
528
+ checkPermissionFailure(cleanup, fixture);
529
+ assertRetiredSkillCleanup(fixture);
530
+ } finally {
531
+ fs.rmSync(fixture.tempRoot, { recursive: true, force: true });
532
+ }
533
+ }
534
+
535
+ function checkUpstreamCapabilityVerifier() {
536
+ const verifier = rel("scripts/verify-upstream-capability-map.js");
537
+ const baseline = rel("scripts/upstream-capability-baseline.json");
538
+ if (!fs.existsSync(verifier)) {
539
+ fail("upstream capability verifier is missing");
540
+ return;
541
+ }
542
+ if (!fs.existsSync(baseline)) {
543
+ fail("upstream capability baseline is missing");
544
+ return;
545
+ }
546
+ const result = spawnSync(process.execPath, [verifier], {
547
+ cwd: root,
548
+ encoding: "utf8",
549
+ timeout: 10000,
550
+ });
551
+ if (result.error) {
552
+ fail(`upstream capability verifier failed: ${result.error.message}`);
553
+ } else if (result.status !== 0) {
554
+ fail(`upstream capability verifier exited ${result.status}: ${result.stderr}`);
555
+ }
556
+ }
557
+
558
+ function checkGitDiffWhitespace() {
559
+ const isRepo = spawnSync("git", ["rev-parse", "--is-inside-work-tree"], {
560
+ cwd: root,
561
+ encoding: "utf8",
562
+ timeout: 30000,
563
+ });
564
+
565
+ if (isRepo.status !== 0) {
566
+ return;
567
+ }
568
+
569
+ const result = spawnSync("git", ["diff", "--check"], {
570
+ cwd: root,
571
+ encoding: "utf8",
572
+ timeout: 30000,
573
+ });
574
+
575
+ if (result.status !== 0) {
576
+ fail(`git diff --check failed:\n${result.stdout}${result.stderr}`);
577
+ } else if (result.stderr.trim()) {
578
+ warn(result.stderr.trim());
579
+ }
580
+ }
581
+
582
+ function runRuntimeChecks(context) {
583
+ bindContext(context);
584
+ checkScriptLayout();
585
+ checkContinuousLearningV21();
586
+ checkObserveV2();
587
+ checkInstalledPackageOnlyPaths();
588
+ checkRetiredSkillCleanup();
589
+ checkUpstreamCapabilityVerifier();
590
+ checkGitDiffWhitespace();
591
+ }
592
+
593
+ module.exports = { runRuntimeChecks };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ const assert = require("node:assert/strict");
4
+ const { validateManifest, validateNativeRoutes } = require("./skill-manifest-checks");
5
+
6
+ function validate(compatibility, invocation, claudeFlag, policy) {
7
+ const skillPath = "skills/demo/SKILL.md";
8
+ const policyPath = "skills/demo/agents/openai.yaml";
9
+ const body = "---\nname: demo\ndescription: Invocation fixture\n" +
10
+ (typeof claudeFlag === "string" ? claudeFlag : claudeFlag ? "disable-model-invocation: true\n" : "") + "---\n";
11
+ return validateManifest({
12
+ schemaVersion: 1,
13
+ skills: [{ name: "demo", path: skillPath, owner: skillPath, version: "0.1.0",
14
+ compatibility, allowedTools: null, invocation }],
15
+ ownership: [],
16
+ }, {
17
+ exists: (file) => file === skillPath || (file === policyPath && policy !== undefined),
18
+ read: (file) => file === skillPath ? body : policy,
19
+ skillPaths: [skillPath],
20
+ }).join("\n");
21
+ }
22
+
23
+ const both = ["claude-code", "codex"];
24
+ const disabledPolicy = "policy:\n allow_implicit_invocation: false\n";
25
+ assert.match(validate(both, "explicit-only", true), /codex.*disable implicit invocation/i);
26
+ assert.match(validate(both, "explicit-only", false, disabledPolicy), /claude-code.*disable implicit invocation/i);
27
+ assert.equal(validate(both, "explicit-only", true, disabledPolicy), "");
28
+ assert.equal(validate(["claude-code"], "explicit-only", true), "");
29
+ assert.equal(validate(["codex"], "explicit-only", false, disabledPolicy), "");
30
+ assert.match(validate(["codex"], "explicit-only", false,
31
+ "interface:\n allow_implicit_invocation: false\n"), /codex.*disable implicit invocation/i);
32
+ assert.match(validate(both, "implicit", true), /conflicts with frontmatter/);
33
+ assert.match(validate(both, "implicit", false, disabledPolicy), /conflicts with policy/);
34
+ assert.equal(validate(both, "implicit", false), "");
35
+ assert.equal(validate(both, "explicit-only", true, disabledPolicy.replace(/\n/g, "\r\n")), "");
36
+ for (const policy of [
37
+ "policy: # native invocation policy\n allow_implicit_invocation: false\n",
38
+ "policy:\n allow_implicit_invocation: false\n",
39
+ "policy:\n\n # invocation gate\n allow_implicit_invocation: false\n",
40
+ "policy: { allow_implicit_invocation: false }\n",
41
+ "'policy':\n 'allow_implicit_invocation': false\n",
42
+ ]) {
43
+ assert.match(validate(both, "implicit", false, policy), /conflicts with policy/);
44
+ assert.equal(validate(both, "explicit-only", true, policy), "");
45
+ }
46
+ for (const policy of [
47
+ "policy:\n allow_implicit_invocation: 'false'\n",
48
+ "policy:\n allow_implicit_invocation: false\n allow_implicit_invocation: true\n",
49
+ "policy: [\n",
50
+ ]) {
51
+ assert.match(validate(both, "implicit", false, policy), /invalid.*yaml|must be.*boolean/i);
52
+ }
53
+ assert.equal(validate(both, "implicit", false,
54
+ "policy:\n nested:\n allow_implicit_invocation: false\n"), "");
55
+ for (const flag of [
56
+ "disable-model-invocation: true # user-only\n",
57
+ "'disable-model-invocation': true\n",
58
+ ]) {
59
+ assert.match(validate(both, "implicit", flag), /conflicts with frontmatter/);
60
+ assert.equal(validate(both, "explicit-only", flag, disabledPolicy), "");
61
+ }
62
+ assert.match(validate(both, "implicit", "disable-model-invocation: 'true'\n"), /must be.*boolean/);
63
+ const routes = { skills: [{ name: "handoff", path: "skills/handoff/SKILL.md", invocation: "explicit-only" }] };
64
+ assert.match(validateNativeRoutes(routes, " -> fresh session? -> skills/handoff/SKILL.md\n").join("\n"), /native-entry/);
65
+ assert.match(validateNativeRoutes(routes, " -> fresh session? -> handoff\n").join("\n"), /native-entry/);
66
+ assert.deepEqual(validateNativeRoutes(routes, " -> fresh session? -> native-entry skills/handoff/SKILL.md\n"), []);
67
+ assert.deepEqual(validateNativeRoutes(routes, " -> delivery -> skills/implement/SKILL.md\n"), []);
68
+ // Natural-language requests must remain selectable on both hosts after an upgrade.
69
+ const fs = require("node:fs");
70
+ const path = require("node:path");
71
+ const YAML = require("yaml");
72
+ const root = path.resolve(__dirname, "../..");
73
+ const manifest = require("../../harness/manifest.json");
74
+ for (const name of ["handoff", "improve-codebase-architecture", "triage"]) {
75
+ const entry = manifest.skills.find((skill) => skill.name === name);
76
+ assert.equal(entry?.invocation, "implicit", name);
77
+ const body = fs.readFileSync(path.join(root, entry.path), "utf8");
78
+ const frontmatter = YAML.parse(body.match(/^---\r?\n([\s\S]*?)\r?\n---/)[1]);
79
+ assert.notEqual(frontmatter["disable-model-invocation"], true, name);
80
+ const policy = YAML.parse(fs.readFileSync(path.join(root, "skills", name, "agents/openai.yaml"), "utf8"));
81
+ assert.equal(policy.policy.allow_implicit_invocation, true, name);
82
+ }
83
+ for (const name of ["research", "wayfinder", "find-skills", "project-context"]) {
84
+ assert.equal(manifest.skills.some((skill) => skill.name === name), false);
85
+ }
86
+ console.log("Skill invocation tests passed (33 host-gate scenarios, three natural-language entries, four retired skills).");