workspace-maxxing 0.1.0

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 (198) hide show
  1. package/.agents/skills/workspace-maxxing/.workspace-templates/CONTEXT.md +44 -0
  2. package/.agents/skills/workspace-maxxing/.workspace-templates/SYSTEM.md +44 -0
  3. package/.agents/skills/workspace-maxxing/.workspace-templates/references/anti-patterns.md +16 -0
  4. package/.agents/skills/workspace-maxxing/.workspace-templates/references/iron-laws.md +26 -0
  5. package/.agents/skills/workspace-maxxing/.workspace-templates/references/reporting-format.md +52 -0
  6. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/benchmark.ts +171 -0
  7. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/dispatch.ts +473 -0
  8. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/generate-tests.ts +158 -0
  9. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/install-tool.ts +82 -0
  10. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/iterate.ts +265 -0
  11. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/orchestrator.ts +539 -0
  12. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/scaffold.ts +282 -0
  13. package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/validate.ts +452 -0
  14. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/architecture/SKILL.md +95 -0
  15. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/fixer/SKILL.md +109 -0
  16. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/iteration/SKILL.md +89 -0
  17. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/prompt-engineering/SKILL.md +87 -0
  18. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/research/SKILL.md +94 -0
  19. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/testing/SKILL.md +89 -0
  20. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/tooling/SKILL.md +87 -0
  21. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/validation/SKILL.md +103 -0
  22. package/.agents/skills/workspace-maxxing/.workspace-templates/skills/worker/SKILL.md +79 -0
  23. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/00-meta/CONTEXT.md +6 -0
  24. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/00-meta/execution-log.md +27 -0
  25. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/01-input/CONTEXT.md +29 -0
  26. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/02-process/CONTEXT.md +29 -0
  27. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/03-output/CONTEXT.md +29 -0
  28. package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/README.md +14 -0
  29. package/.agents/skills/workspace-maxxing/SKILL.md +312 -0
  30. package/.agents/skills/workspace-maxxing/scripts/benchmark.ts +171 -0
  31. package/.agents/skills/workspace-maxxing/scripts/dispatch.ts +473 -0
  32. package/.agents/skills/workspace-maxxing/scripts/generate-tests.ts +158 -0
  33. package/.agents/skills/workspace-maxxing/scripts/install-tool.ts +82 -0
  34. package/.agents/skills/workspace-maxxing/scripts/iterate.ts +265 -0
  35. package/.agents/skills/workspace-maxxing/scripts/orchestrator.ts +539 -0
  36. package/.agents/skills/workspace-maxxing/scripts/scaffold.ts +282 -0
  37. package/.agents/skills/workspace-maxxing/scripts/validate.ts +452 -0
  38. package/README.md +144 -0
  39. package/dist/agent-creator.d.ts +9 -0
  40. package/dist/agent-creator.d.ts.map +1 -0
  41. package/dist/agent-creator.js +199 -0
  42. package/dist/agent-creator.js.map +1 -0
  43. package/dist/agent-iterator.d.ts +38 -0
  44. package/dist/agent-iterator.d.ts.map +1 -0
  45. package/dist/agent-iterator.js +327 -0
  46. package/dist/agent-iterator.js.map +1 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +197 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/install.d.ts +18 -0
  52. package/dist/install.d.ts.map +1 -0
  53. package/dist/install.js +117 -0
  54. package/dist/install.js.map +1 -0
  55. package/dist/platforms/claude.d.ts +7 -0
  56. package/dist/platforms/claude.d.ts.map +1 -0
  57. package/dist/platforms/claude.js +70 -0
  58. package/dist/platforms/claude.js.map +1 -0
  59. package/dist/platforms/copilot.d.ts +7 -0
  60. package/dist/platforms/copilot.d.ts.map +1 -0
  61. package/dist/platforms/copilot.js +75 -0
  62. package/dist/platforms/copilot.js.map +1 -0
  63. package/dist/platforms/gemini.d.ts +7 -0
  64. package/dist/platforms/gemini.d.ts.map +1 -0
  65. package/dist/platforms/gemini.js +81 -0
  66. package/dist/platforms/gemini.js.map +1 -0
  67. package/dist/platforms/index.d.ts +8 -0
  68. package/dist/platforms/index.d.ts.map +1 -0
  69. package/dist/platforms/index.js +41 -0
  70. package/dist/platforms/index.js.map +1 -0
  71. package/dist/platforms/opencode.d.ts +7 -0
  72. package/dist/platforms/opencode.d.ts.map +1 -0
  73. package/dist/platforms/opencode.js +70 -0
  74. package/dist/platforms/opencode.js.map +1 -0
  75. package/dist/scripts/benchmark.d.ts +20 -0
  76. package/dist/scripts/benchmark.d.ts.map +1 -0
  77. package/dist/scripts/benchmark.js +170 -0
  78. package/dist/scripts/benchmark.js.map +1 -0
  79. package/dist/scripts/dispatch.d.ts +32 -0
  80. package/dist/scripts/dispatch.d.ts.map +1 -0
  81. package/dist/scripts/dispatch.js +386 -0
  82. package/dist/scripts/dispatch.js.map +1 -0
  83. package/dist/scripts/generate-tests.d.ts +11 -0
  84. package/dist/scripts/generate-tests.d.ts.map +1 -0
  85. package/dist/scripts/generate-tests.js +118 -0
  86. package/dist/scripts/generate-tests.js.map +1 -0
  87. package/dist/scripts/install-tool.d.ts +8 -0
  88. package/dist/scripts/install-tool.d.ts.map +1 -0
  89. package/dist/scripts/install-tool.js +98 -0
  90. package/dist/scripts/install-tool.js.map +1 -0
  91. package/dist/scripts/iterate.d.ts +44 -0
  92. package/dist/scripts/iterate.d.ts.map +1 -0
  93. package/dist/scripts/iterate.js +260 -0
  94. package/dist/scripts/iterate.js.map +1 -0
  95. package/dist/scripts/orchestrator.d.ts +40 -0
  96. package/dist/scripts/orchestrator.d.ts.map +1 -0
  97. package/dist/scripts/orchestrator.js +378 -0
  98. package/dist/scripts/orchestrator.js.map +1 -0
  99. package/dist/scripts/scaffold.d.ts +8 -0
  100. package/dist/scripts/scaffold.d.ts.map +1 -0
  101. package/dist/scripts/scaffold.js +279 -0
  102. package/dist/scripts/scaffold.js.map +1 -0
  103. package/dist/scripts/validate.d.ts +11 -0
  104. package/dist/scripts/validate.d.ts.map +1 -0
  105. package/dist/scripts/validate.js +472 -0
  106. package/dist/scripts/validate.js.map +1 -0
  107. package/docs/superpowers/plans/2026-04-07-autonomous-iteration-plan.md +1123 -0
  108. package/docs/superpowers/plans/2026-04-07-autonomous-iteration-sub-agent-batches.md +1923 -0
  109. package/docs/superpowers/plans/2026-04-07-autonomous-workflow-sub-skill-plan.md +1505 -0
  110. package/docs/superpowers/plans/2026-04-07-benchmarking-multi-agent-plan.md +854 -0
  111. package/docs/superpowers/plans/2026-04-07-workspace-builder-logic-plan.md +1426 -0
  112. package/docs/superpowers/plans/2026-04-07-workspace-maxxing-plan.md +1299 -0
  113. package/docs/superpowers/plans/2026-04-08-session-294c-subagent-invocation-plan.md +320 -0
  114. package/docs/superpowers/plans/2026-04-08-workflow-prompt-hardening-plan.md +1025 -0
  115. package/docs/superpowers/plans/2026-04-12-workspace-agent-creation-plan.md +992 -0
  116. package/docs/superpowers/specs/2026-04-07-autonomous-iteration-design.md +214 -0
  117. package/docs/superpowers/specs/2026-04-07-autonomous-iteration-sub-agent-batches-design.md +188 -0
  118. package/docs/superpowers/specs/2026-04-07-autonomous-workflow-sub-skill-design.md +137 -0
  119. package/docs/superpowers/specs/2026-04-07-benchmarking-multi-agent-design.md +105 -0
  120. package/docs/superpowers/specs/2026-04-07-workspace-builder-logic-design.md +179 -0
  121. package/docs/superpowers/specs/2026-04-07-workspace-maxxing-design.md +227 -0
  122. package/docs/superpowers/specs/2026-04-08-session-294c-subagent-invocation-design.md +265 -0
  123. package/docs/superpowers/specs/2026-04-08-workflow-prompt-hardening-design.md +146 -0
  124. package/docs/superpowers/specs/2026-04-12-workspace-agent-creation-design.md +239 -0
  125. package/jest.config.js +8 -0
  126. package/package.json +32 -0
  127. package/src/agent-creator.ts +180 -0
  128. package/src/agent-iterator.ts +397 -0
  129. package/src/index.ts +189 -0
  130. package/src/install.ts +105 -0
  131. package/src/platforms/claude.ts +40 -0
  132. package/src/platforms/copilot.ts +50 -0
  133. package/src/platforms/gemini.ts +55 -0
  134. package/src/platforms/index.ts +45 -0
  135. package/src/platforms/opencode.ts +41 -0
  136. package/src/scripts/benchmark.ts +171 -0
  137. package/src/scripts/dispatch.ts +473 -0
  138. package/src/scripts/generate-tests.ts +112 -0
  139. package/src/scripts/install-tool.ts +82 -0
  140. package/src/scripts/iterate.ts +271 -0
  141. package/src/scripts/orchestrator.ts +539 -0
  142. package/src/scripts/scaffold.ts +282 -0
  143. package/src/scripts/validate.ts +516 -0
  144. package/templates/.workspace-templates/CONTEXT.md +44 -0
  145. package/templates/.workspace-templates/SYSTEM.md +44 -0
  146. package/templates/.workspace-templates/references/anti-patterns.md +16 -0
  147. package/templates/.workspace-templates/references/iron-laws.md +26 -0
  148. package/templates/.workspace-templates/references/reporting-format.md +52 -0
  149. package/templates/.workspace-templates/scripts/benchmark.ts +171 -0
  150. package/templates/.workspace-templates/scripts/dispatch.ts +473 -0
  151. package/templates/.workspace-templates/scripts/generate-tests.ts +158 -0
  152. package/templates/.workspace-templates/scripts/install-tool.ts +82 -0
  153. package/templates/.workspace-templates/scripts/iterate.ts +265 -0
  154. package/templates/.workspace-templates/scripts/orchestrator.ts +539 -0
  155. package/templates/.workspace-templates/scripts/scaffold.ts +282 -0
  156. package/templates/.workspace-templates/scripts/validate.ts +452 -0
  157. package/templates/.workspace-templates/skills/architecture/SKILL.md +95 -0
  158. package/templates/.workspace-templates/skills/fixer/SKILL.md +109 -0
  159. package/templates/.workspace-templates/skills/iteration/SKILL.md +89 -0
  160. package/templates/.workspace-templates/skills/prompt-engineering/SKILL.md +87 -0
  161. package/templates/.workspace-templates/skills/research/SKILL.md +94 -0
  162. package/templates/.workspace-templates/skills/testing/SKILL.md +89 -0
  163. package/templates/.workspace-templates/skills/tooling/SKILL.md +87 -0
  164. package/templates/.workspace-templates/skills/validation/SKILL.md +103 -0
  165. package/templates/.workspace-templates/skills/worker/SKILL.md +79 -0
  166. package/templates/.workspace-templates/workspace/00-meta/CONTEXT.md +6 -0
  167. package/templates/.workspace-templates/workspace/00-meta/execution-log.md +27 -0
  168. package/templates/.workspace-templates/workspace/01-input/CONTEXT.md +29 -0
  169. package/templates/.workspace-templates/workspace/02-process/CONTEXT.md +29 -0
  170. package/templates/.workspace-templates/workspace/03-output/CONTEXT.md +29 -0
  171. package/templates/.workspace-templates/workspace/README.md +14 -0
  172. package/templates/SKILL.md +347 -0
  173. package/tests/benchmark.test.ts +158 -0
  174. package/tests/cli.test.ts +109 -0
  175. package/tests/dispatch-parallel.test.ts +124 -0
  176. package/tests/dispatch.test.ts +218 -0
  177. package/tests/fixer-skill.test.ts +203 -0
  178. package/tests/generate-tests.test.ts +101 -0
  179. package/tests/install-tool.test.ts +141 -0
  180. package/tests/install.test.ts +144 -0
  181. package/tests/integration.test.ts +324 -0
  182. package/tests/iterate.test.ts +219 -0
  183. package/tests/orchestrator.test.ts +710 -0
  184. package/tests/scaffold.test.ts +238 -0
  185. package/tests/templates-enhanced.test.ts +208 -0
  186. package/tests/templates.test.ts +219 -0
  187. package/tests/validate.test.ts +421 -0
  188. package/tests/validation-enhanced.test.ts +303 -0
  189. package/tests/worker-skill.test.ts +88 -0
  190. package/tsconfig.json +19 -0
  191. package/workspace/00-meta/CONTEXT.md +3 -0
  192. package/workspace/00-meta/execution-log.md +17 -0
  193. package/workspace/00-meta/tools.md +11 -0
  194. package/workspace/01-input/CONTEXT.md +27 -0
  195. package/workspace/CONTEXT.md +35 -0
  196. package/workspace/README.md +14 -0
  197. package/workspace/SYSTEM.md +36 -0
  198. package/workspace-maxxing-0.1.0.tgz +0 -0
@@ -0,0 +1,452 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+
4
+ export interface CheckResult {
5
+ name: string;
6
+ passed: boolean;
7
+ message: string;
8
+ }
9
+
10
+ export interface ValidationResult {
11
+ passed: boolean;
12
+ checks: CheckResult[];
13
+ }
14
+
15
+ const REQUIRED_SYSTEM_HEADINGS = [
16
+ '## Role',
17
+ '## Folder Map',
18
+ '## Workflow Rules',
19
+ '## Scope Guardrails',
20
+ '## Sequential Execution Protocol',
21
+ '## Stage Boundaries',
22
+ '## Tooling Policy',
23
+ ];
24
+
25
+ const REQUIRED_ROOT_CONTEXT_HEADINGS = [
26
+ '## How to Use This File',
27
+ '## Task Routing',
28
+ '## Loading Order',
29
+ '## Scope Guardrails',
30
+ '## Sequential Routing Contract',
31
+ '## Stage Handoff Routing',
32
+ '## Escalation',
33
+ ];
34
+
35
+ const REQUIRED_STAGE_CONTEXT_HEADINGS = [
36
+ '## Purpose',
37
+ '## Inputs',
38
+ '## Outputs',
39
+ '## Dependencies',
40
+ '## Required Evidence',
41
+ '## Completion Criteria',
42
+ '## Handoff',
43
+ ];
44
+
45
+ const DISALLOWED_STAGE_SOURCE_EXTENSIONS = new Set([
46
+ '.ts',
47
+ '.tsx',
48
+ '.js',
49
+ '.jsx',
50
+ '.py',
51
+ '.java',
52
+ '.go',
53
+ '.rs',
54
+ '.cs',
55
+ '.cpp',
56
+ '.c',
57
+ '.rb',
58
+ '.php',
59
+ '.swift',
60
+ '.kt',
61
+ '.scala',
62
+ ]);
63
+
64
+ export function validateWorkspace(workspacePath: string): ValidationResult {
65
+ const ws = path.resolve(workspacePath);
66
+ const checks: CheckResult[] = [];
67
+ const numberedFolders = getNumberedStageFolders(ws);
68
+
69
+ const systemMdPath = path.join(ws, 'SYSTEM.md');
70
+ const systemExists = fs.existsSync(systemMdPath);
71
+ checks.push({
72
+ name: 'SYSTEM.md exists',
73
+ passed: systemExists,
74
+ message: systemExists ? 'Found' : 'Missing',
75
+ });
76
+
77
+ if (systemExists) {
78
+ const systemContent = fs.readFileSync(systemMdPath, 'utf-8');
79
+ const hasFolderMap = systemContent.toLowerCase().includes('folder map');
80
+ checks.push({
81
+ name: 'SYSTEM.md contains folder map',
82
+ passed: hasFolderMap,
83
+ message: hasFolderMap ? 'Found' : 'Missing "folder map" reference',
84
+ });
85
+
86
+ addRequiredHeadingChecks('SYSTEM.md', systemContent, REQUIRED_SYSTEM_HEADINGS, checks);
87
+ } else {
88
+ checks.push({
89
+ name: 'SYSTEM.md contains folder map',
90
+ passed: false,
91
+ message: 'Cannot check — SYSTEM.md missing',
92
+ });
93
+
94
+ for (const heading of REQUIRED_SYSTEM_HEADINGS) {
95
+ checks.push({
96
+ name: `SYSTEM.md contains ${heading}`,
97
+ passed: false,
98
+ message: `Cannot check - SYSTEM.md missing`,
99
+ });
100
+ }
101
+ }
102
+
103
+ const contextMdPath = path.join(ws, 'CONTEXT.md');
104
+ const contextExists = fs.existsSync(contextMdPath);
105
+ checks.push({
106
+ name: 'CONTEXT.md exists at root',
107
+ passed: contextExists,
108
+ message: contextExists ? 'Found' : 'Missing',
109
+ });
110
+
111
+ if (contextExists) {
112
+ const contextContent = fs.readFileSync(contextMdPath, 'utf-8');
113
+ addRequiredHeadingChecks('CONTEXT.md', contextContent, REQUIRED_ROOT_CONTEXT_HEADINGS, checks);
114
+
115
+ const allReferenced = numberedFolders.every((folder) => contextContent.includes(`${folder}/CONTEXT.md`));
116
+ checks.push({
117
+ name: 'Root routing references all numbered stages',
118
+ passed: allReferenced,
119
+ message: allReferenced ? 'All numbered stages are routed' : 'Missing one or more numbered stage routes',
120
+ });
121
+
122
+ const enforcesSelectiveLoading =
123
+ /## Loading Order/i.test(contextContent)
124
+ && /SYSTEM\.md/i.test(contextContent)
125
+ && /Only the task files needed/i.test(contextContent);
126
+
127
+ checks.push({
128
+ name: 'Root loading order enforces selective loading',
129
+ passed: enforcesSelectiveLoading,
130
+ message: enforcesSelectiveLoading
131
+ ? 'Selective loading guidance found'
132
+ : 'Loading order lacks selective-loading guidance',
133
+ });
134
+ } else {
135
+ for (const heading of REQUIRED_ROOT_CONTEXT_HEADINGS) {
136
+ checks.push({
137
+ name: `CONTEXT.md contains ${heading}`,
138
+ passed: false,
139
+ message: 'Cannot check - CONTEXT.md missing',
140
+ });
141
+ }
142
+
143
+ checks.push({
144
+ name: 'Root routing references all numbered stages',
145
+ passed: false,
146
+ message: 'Cannot check - CONTEXT.md missing',
147
+ });
148
+ checks.push({
149
+ name: 'Root loading order enforces selective loading',
150
+ passed: false,
151
+ message: 'Cannot check - CONTEXT.md missing',
152
+ });
153
+ }
154
+
155
+ const executionLogPath = path.join(ws, '00-meta', 'execution-log.md');
156
+ const executionLogExists = fs.existsSync(executionLogPath);
157
+ checks.push({
158
+ name: '00-meta/execution-log.md exists',
159
+ passed: executionLogExists,
160
+ message: executionLogExists ? 'Found' : 'Missing',
161
+ });
162
+
163
+ if (executionLogExists) {
164
+ const executionLogContent = fs.readFileSync(executionLogPath, 'utf-8');
165
+ const hasStageChecklistHeading = /## Stage Checklist/i.test(executionLogContent);
166
+ checks.push({
167
+ name: 'Execution log contains stage checklist heading',
168
+ passed: hasStageChecklistHeading,
169
+ message: hasStageChecklistHeading ? 'Found' : 'Missing "## Stage Checklist" heading',
170
+ });
171
+
172
+ const hasAllStageChecklistEntries = numberedFolders.every((folder) => {
173
+ const pattern = new RegExp(`^\\s*-\\s*\\[[ xX]\\]\\s+${escapeRegExp(folder)}\\s*$`, 'm');
174
+ return pattern.test(executionLogContent);
175
+ });
176
+ checks.push({
177
+ name: 'Execution log references all numbered stages',
178
+ passed: hasAllStageChecklistEntries,
179
+ message: hasAllStageChecklistEntries
180
+ ? 'All numbered stages are present in checklist'
181
+ : 'Missing one or more numbered stage checklist entries',
182
+ });
183
+
184
+ const sequentialOrderValid = hasAllStageChecklistEntries
185
+ ? isExecutionChecklistSequential(executionLogContent, numberedFolders)
186
+ : false;
187
+ checks.push({
188
+ name: 'Execution log stage completion order is sequential',
189
+ passed: sequentialOrderValid,
190
+ message: sequentialOrderValid
191
+ ? 'Stage completion order is sequential'
192
+ : 'Found later stage marked complete before earlier stage',
193
+ });
194
+ } else {
195
+ checks.push({
196
+ name: 'Execution log contains stage checklist heading',
197
+ passed: false,
198
+ message: 'Cannot check - execution log missing',
199
+ });
200
+ checks.push({
201
+ name: 'Execution log references all numbered stages',
202
+ passed: false,
203
+ message: 'Cannot check - execution log missing',
204
+ });
205
+ checks.push({
206
+ name: 'Execution log stage completion order is sequential',
207
+ passed: false,
208
+ message: 'Cannot check - execution log missing',
209
+ });
210
+ }
211
+
212
+ for (const folder of numberedFolders) {
213
+ const contextPath = path.join(ws, folder, 'CONTEXT.md');
214
+ const exists = fs.existsSync(contextPath);
215
+ checks.push({
216
+ name: `${folder}/CONTEXT.md exists`,
217
+ passed: exists,
218
+ message: exists ? 'Found' : 'Missing',
219
+ });
220
+
221
+ if (exists) {
222
+ const content = fs.readFileSync(contextPath, 'utf-8');
223
+ const notEmpty = content.trim().length > 0;
224
+ checks.push({
225
+ name: `${folder}/CONTEXT.md is not empty`,
226
+ passed: notEmpty,
227
+ message: notEmpty ? `${content.trim().length} chars` : 'File is empty',
228
+ });
229
+
230
+ addRequiredHeadingChecks(`${folder}/CONTEXT.md`, content, REQUIRED_STAGE_CONTEXT_HEADINGS, checks);
231
+
232
+ const deps = extractStageRefs(extractDependenciesSection(content));
233
+ const currentNum = parseInt(folder.slice(0, 2), 10);
234
+ const pointsToLaterStage = deps.some((dep) => parseInt(dep.slice(0, 2), 10) > currentNum);
235
+
236
+ checks.push({
237
+ name: `${folder} dependencies do not point to later stages`,
238
+ passed: !pointsToLaterStage,
239
+ message: !pointsToLaterStage ? 'Dependency direction valid' : 'Found dependency on later-numbered stage',
240
+ });
241
+ } else {
242
+ for (const heading of REQUIRED_STAGE_CONTEXT_HEADINGS) {
243
+ checks.push({
244
+ name: `${folder}/CONTEXT.md contains ${heading}`,
245
+ passed: false,
246
+ message: 'Cannot check - CONTEXT.md missing',
247
+ });
248
+ }
249
+
250
+ checks.push({
251
+ name: `${folder} dependencies do not point to later stages`,
252
+ passed: false,
253
+ message: 'Cannot check - CONTEXT.md missing',
254
+ });
255
+ }
256
+
257
+ const disallowedFiles = findDisallowedStageSourceFiles(path.join(ws, folder));
258
+ checks.push({
259
+ name: `${folder} contains no product source code files`,
260
+ passed: disallowedFiles.length === 0,
261
+ message: disallowedFiles.length === 0
262
+ ? 'Only workflow documentation artifacts found'
263
+ : `Found source files: ${disallowedFiles.join(', ')}`,
264
+ });
265
+ }
266
+
267
+ const allFiles = getAllMarkdownFiles(ws);
268
+ const duplicateCheck = checkDuplicateContent(allFiles);
269
+ checks.push(duplicateCheck);
270
+
271
+ const passed = checks.every((c) => c.passed);
272
+
273
+ console.log(`\nValidation: ${ws}`);
274
+ console.log('='.repeat(50));
275
+ for (const check of checks) {
276
+ const icon = check.passed ? '✓' : '✗';
277
+ console.log(` ${icon} ${check.name}: ${check.message}`);
278
+ }
279
+ console.log('='.repeat(50));
280
+ console.log(passed ? '✓ All checks passed' : '✗ Some checks failed');
281
+
282
+ return { passed, checks };
283
+ }
284
+
285
+ function getAllMarkdownFiles(dir: string): string[] {
286
+ const results: string[] = [];
287
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
288
+
289
+ for (const entry of entries) {
290
+ const fullPath = path.join(dir, entry.name);
291
+ if (entry.isDirectory()) {
292
+ results.push(...getAllMarkdownFiles(fullPath));
293
+ } else if (entry.name.endsWith('.md')) {
294
+ results.push(fullPath);
295
+ }
296
+ }
297
+
298
+ return results;
299
+ }
300
+
301
+ function escapeRegExp(value: string): string {
302
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
303
+ }
304
+
305
+ function hasHeading(content: string, heading: string): boolean {
306
+ return new RegExp(`^${escapeRegExp(heading)}\\s*$`, 'im').test(content);
307
+ }
308
+
309
+ function addRequiredHeadingChecks(
310
+ fileLabel: string,
311
+ content: string,
312
+ headings: string[],
313
+ checks: CheckResult[],
314
+ ): void {
315
+ for (const heading of headings) {
316
+ const found = hasHeading(content, heading);
317
+ checks.push({
318
+ name: `${fileLabel} contains ${heading}`,
319
+ passed: found,
320
+ message: found ? 'Found' : `Missing ${heading}`,
321
+ });
322
+ }
323
+ }
324
+
325
+ function checkDuplicateContent(files: string[]): CheckResult {
326
+ const MIN_DUPLICATE_LENGTH = 50;
327
+ const duplicates: string[] = [];
328
+
329
+ for (let i = 0; i < files.length; i++) {
330
+ for (let j = i + 1; j < files.length; j++) {
331
+ const contentA = fs.readFileSync(files[i], 'utf-8');
332
+ const contentB = fs.readFileSync(files[j], 'utf-8');
333
+
334
+ const linesA = contentA.split('\n');
335
+ const linesB = contentB.split('\n');
336
+
337
+ for (const lineA of linesA) {
338
+ const trimmed = lineA.trim();
339
+ if (trimmed.length > MIN_DUPLICATE_LENGTH) {
340
+ for (const lineB of linesB) {
341
+ if (lineB.trim() === trimmed) {
342
+ duplicates.push(trimmed.substring(0, 60) + '...');
343
+ break;
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+
351
+ if (duplicates.length > 0) {
352
+ return {
353
+ name: 'No duplicate content across files',
354
+ passed: false,
355
+ message: `Found ${duplicates.length} duplicate text block(s)`,
356
+ };
357
+ }
358
+
359
+ return {
360
+ name: 'No duplicate content across files',
361
+ passed: true,
362
+ message: 'No duplicates found',
363
+ };
364
+ }
365
+
366
+ function getNumberedStageFolders(workspacePath: string): string[] {
367
+ const entries = fs.readdirSync(workspacePath, { withFileTypes: true });
368
+ return entries
369
+ .filter((entry) => entry.isDirectory() && /^\d{2}-/.test(entry.name) && entry.name !== '00-meta')
370
+ .map((entry) => entry.name);
371
+ }
372
+
373
+ function extractDependenciesSection(content: string): string {
374
+ const match = content.match(/## Dependencies\s*([\s\S]*?)(?=\n##\s|$)/i);
375
+ return match ? match[1] : '';
376
+ }
377
+
378
+ function extractStageRefs(content: string): string[] {
379
+ const refs = new Set<string>();
380
+ const regex = /(\d{2}-[A-Za-z0-9-_]+)/g;
381
+ let match: RegExpExecArray | null;
382
+
383
+ while ((match = regex.exec(content)) !== null) {
384
+ refs.add(match[1]);
385
+ }
386
+
387
+ return Array.from(refs);
388
+ }
389
+
390
+ function isExecutionChecklistSequential(content: string, stages: string[]): boolean {
391
+ let foundUncheckedStage = false;
392
+
393
+ for (const stage of stages) {
394
+ const pattern = new RegExp(`^\\s*-\\s*\\[([ xX])\\]\\s+${escapeRegExp(stage)}\\s*$`, 'm');
395
+ const match = content.match(pattern);
396
+ if (!match) {
397
+ return false;
398
+ }
399
+
400
+ const isChecked = match[1].toLowerCase() === 'x';
401
+ if (!isChecked) {
402
+ foundUncheckedStage = true;
403
+ continue;
404
+ }
405
+
406
+ if (foundUncheckedStage) {
407
+ return false;
408
+ }
409
+ }
410
+
411
+ return true;
412
+ }
413
+
414
+ function findDisallowedStageSourceFiles(stageDir: string): string[] {
415
+ const disallowed: string[] = [];
416
+
417
+ const walk = (currentDir: string): void => {
418
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
419
+
420
+ for (const entry of entries) {
421
+ const fullPath = path.join(currentDir, entry.name);
422
+
423
+ if (entry.isDirectory()) {
424
+ walk(fullPath);
425
+ continue;
426
+ }
427
+
428
+ const ext = path.extname(entry.name).toLowerCase();
429
+ if (DISALLOWED_STAGE_SOURCE_EXTENSIONS.has(ext)) {
430
+ disallowed.push(path.relative(stageDir, fullPath).replace(/\\/g, '/'));
431
+ }
432
+ }
433
+ };
434
+
435
+ walk(stageDir);
436
+
437
+ return disallowed;
438
+ }
439
+
440
+ if (require.main === module) {
441
+ const args = process.argv.slice(2);
442
+ const workspaceIdx = args.indexOf('--workspace');
443
+ const workspace = workspaceIdx !== -1 ? args[workspaceIdx + 1] : undefined;
444
+
445
+ if (!workspace) {
446
+ console.error('Usage: node validate.ts --workspace <path>');
447
+ process.exit(1);
448
+ }
449
+
450
+ const result = validateWorkspace(workspace);
451
+ process.exit(result.passed ? 0 : 1);
452
+ }
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: architecture
3
+ description: "Designs workspace structure, plans folder layout, and creates the build plan. Use when planning workspace structure, designing folder hierarchy, or after research phase."
4
+ triggers: ["design workspace", "plan structure", "folder layout", "build plan"]
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Design the workspace structure based on research findings. Architecture translates research into a concrete, buildable plan.
10
+
11
+ ## When to Use
12
+
13
+ - Phase 2 of the hybrid flow (after research)
14
+ - When research is complete and building is next
15
+ - When restructuring an existing workspace
16
+
17
+ ## When Not to Use
18
+
19
+ - Before research is complete (use research sub-skill)
20
+ - During building itself (use scaffold.ts directly)
21
+ - For minor structural tweaks (use direct file operations)
22
+
23
+ ## The Iron Law
24
+
25
+ NO ARCHITECTURE WITHOUT RESEARCH
26
+ NO BUILDING WITHOUT APPROVED PLAN
27
+ NO SKIPPING USER APPROVAL
28
+ NO AMBIGUOUS STAGE DEFINITIONS
29
+
30
+ ## Scope Guardrails
31
+
32
+ - Design only the ICM workspace architecture (folders, routing, context contracts).
33
+ - Plan markdown workflow artifacts per stage; do not design application runtime components.
34
+ - Keep architecture outputs directly consumable by scaffold.ts for file-structured markdown folders.
35
+ - Treat product implementation asks as workflow requirements captured in stage docs.
36
+
37
+ ## The Process
38
+
39
+ 1. **Review research findings** - Read the research sub-skill report.
40
+ 2. **Define stage folders** - Determine numbered folder structure (01-xxx, 02-xxx, and so on) for workflow execution.
41
+ 3. **Design routing table** - Plan CONTEXT.md routing for each stage.
42
+ 4. **Define SYSTEM.md** - Plan the folder map, rules, and tool inventory.
43
+ 5. **Plan CONTEXT.md content** - Define what each stage CONTEXT.md must contain and which markdown artifacts it must produce.
44
+ 6. **Create build plan** - Document the scaffold.ts command with all parameters.
45
+ 7. **Get approval** - Present the plan to the user before building.
46
+
47
+ ## Red Flags
48
+
49
+ - Stage folders do not follow sequential numbering
50
+ - Routing table does not reference all stages
51
+ - SYSTEM.md plan is missing or incomplete
52
+ - Build plan is missing scaffold.ts parameters
53
+ - User approval is skipped before build
54
+ - Plan includes backend/frontend/database implementation details instead of workspace structure
55
+
56
+ ## Anti-Rationalization Table
57
+
58
+ | Thought | Reality |
59
+ |---------|---------|
60
+ | "I will adjust the structure while building" | Structure changes mid-build are expensive. Plan first. |
61
+ | "This stage name is good enough" | Stage names affect routing. Be precise. |
62
+ | "The user will understand without approval" | Unapproved plans produce unwanted results. Always present the plan. |
63
+
64
+ ## Sub-Skill Dispatch
65
+
66
+ - `status = passed` (plan approved) -> `nextSkill = none` and main workflow runs scaffold.ts.
67
+ - `status = failed` (plan incomplete or not approved) -> `nextSkill = none`.
68
+ - `status = escalated` (blocking uncertainty) -> `nextSkill = none`.
69
+
70
+ ## Report Format
71
+
72
+ ```json
73
+ {
74
+ "skill": "architecture",
75
+ "status": "passed",
76
+ "timestamp": "2026-04-08T00:00:00Z",
77
+ "findings": ["Defined four sequential stages with explicit routing"],
78
+ "recommendations": ["Run scaffold.ts using the approved stage list"],
79
+ "metrics": {
80
+ "stagesPlanned": 4,
81
+ "toolsIdentified": 2
82
+ },
83
+ "nextSkill": "none"
84
+ }
85
+ ```
86
+
87
+ Allowed `status` values: `passed`, `failed`, `escalated`.
88
+
89
+ Allowed `nextSkill` values: `none`.
90
+
91
+ ## Integration
92
+
93
+ - Uses research output as architecture input.
94
+ - Produces the approved plan consumed by scaffold.ts.
95
+
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: fixer
3
+ description: "Applies targeted fixes to failing test case outputs. Use when fixing failed worker outputs, improving low-scoring results, or addressing validator findings."
4
+ triggers: ["fix failing test", "improve output", "address validation failure", "apply targeted fix"]
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Read validator findings and original worker output, identify the root cause of failure, apply the minimal fix needed, and prepare the case for re-validation. Each fixer runs with fresh context.
10
+
11
+ ## When to Use
12
+
13
+ - Dispatched by orchestrator in a fix loop
14
+ - Validator identifies specific failures for a test case
15
+ - Worker output is incomplete, incorrect, or misaligned with expectations
16
+
17
+ ## When Not to Use
18
+
19
+ - Generating new output from scratch (use worker sub-skill)
20
+ - Validating outputs (use validation sub-skill)
21
+ - Redesigning workspace structure (use architecture sub-skill)
22
+
23
+ ## The Iron Law
24
+
25
+ NO BLIND RETRIES
26
+ NO COSMETIC FIXES
27
+ NO FIXING WHAT IS NOT BROKEN
28
+ NO CLAIMING FIX WITHOUT RE-VALIDATION
29
+
30
+ ## The Process
31
+
32
+ 1. **Read validator findings** - Load `batch-report.json` from the batch directory
33
+ 2. **Read original output** - Load `output.md` and `report.json` from `.agents/iteration/batch-<N>/<testCaseId>/`
34
+ 3. **Identify root cause** - Map each finding to a specific defect in the output
35
+ 4. **Apply minimal fix** - Change only what is needed to resolve each finding
36
+ 5. **Update output.md** - Write the fixed output for the same test case
37
+ 6. **Write report.json** - Structured JSON with `{skill, status, timestamp, testCaseId, batchId, findings, fixesApplied, recommendations, metrics, nextSkill}`
38
+ 7. **Dispatch validation** - Signal that the fix is ready for re-validation
39
+
40
+ ## External Runner Contract
41
+
42
+ - Fixer execution in autonomous iteration is orchestrated via `--subagent-runner`.
43
+ - Direct fixer dispatch must provide `--runner-command` with placeholders `{skill}`, `{workspace}`, `{batchId}`, `{testCaseId}`.
44
+ - Runner output must be JSON and include `report.json` compatible fields:
45
+ - `skill`, `status`, `timestamp`, `findings`, `recommendations`, `metrics`, `nextSkill`
46
+ - Missing/invalid runner output is a failure, not a simulated success path.
47
+ - Use `.agents/iteration/runs/*.json` telemetry to debug command rendering and runner payload issues.
48
+
49
+ ## Agent-Driven Test-Case Generation (Required)
50
+
51
+ - **Agent ownership:** Test-cases MUST be discovered and authored by an agent using the workspace context. Do not rely on hardcoded script-generated test cases.
52
+ - **Where to write:** The agent must write the test-case bundle to `.agents/iteration/test-cases.json` inside the workspace before the orchestrator or validator dispatches workers. Validators and orchestrator flows will treat this file as the authoritative source of inputs for the iteration.
53
+ - **Discovery guidance:** Agents should inspect repo files (SYSTEM.md, CONTEXT.md, stage CONTEXTs, user prompts, examples, and any domain files) to infer realistic inputs, edge cases, and acceptance criteria. Test-cases should reflect actual workspace intent and cover positive, negative, and boundary cases.
54
+ - **Schema (minimal):** The file must be valid JSON and an array of objects with the following fields:
55
+
56
+ ```json
57
+ [
58
+ {
59
+ "id": "tc-001",
60
+ "title": "Short descriptive title",
61
+ "input": {"type": "text", "payload": "..."},
62
+ "expected": {"criteria": ["..."], "matcher": "contains|equals|schema"},
63
+ "metadata": {"priority": "high|medium|low", "sourceHints": ["SYSTEM.md"]}
64
+ }
65
+ ]
66
+ ```
67
+
68
+ - **Idempotence:** Agents may re-generate or refine the file across iterations, but each write must be complete (no partial artifacts) and timestamped inside the JSON if updated.
69
+ - **Signal readiness:** After creating `.agents/iteration/test-cases.json` the agent should also write a single-line marker file `.agents/iteration/.test-cases-ready` to avoid race conditions with orchestrators reading stdout.
70
+
71
+ ## Enforcement Notes
72
+
73
+ - **Validator contract:** The validation step is expected to check for `.agents/iteration/test-cases.json` when running in agent-driven mode and fail fast if missing or malformed. This ensures the orchestrator cannot fall back to hardcoded script cases.
74
+ - **Orchestrator behavior:** When agent-driven mode is enabled, the orchestrator must prefer `.agents/iteration/test-cases.json` and should not call or rely on any built-in `generate-tests` script to produce authoritative inputs.
75
+ - **Audit trail:** Agents should include a `generatedBy` and `timestamp` field in the test-cases file to aid debugging and reproducibility.
76
+
77
+ ## Anti-Rationalization Table
78
+
79
+ | Thought | Reality |
80
+ |---------|---------|
81
+ | "I will just re-run the worker logic" | Blind retries do not fix root causes. Address the findings directly. |
82
+ | "This looks better now" | Better is subjective. The fix must satisfy the validator criteria. |
83
+ | "I will fix other things while I am here" | Scope creep adds risk. Fix only what was flagged. |
84
+ | "The fix is obvious" | Obvious assumptions cause regressions. Tie every change to a finding. |
85
+ | "I do not need to re-validate" | Unvalidated fixes are guesses. Always dispatch validation. |
86
+
87
+ ## Sub-Skill Dispatch
88
+
89
+ - After fix applied -> validation sub-skill
90
+
91
+ ## Report Format
92
+
93
+ ```json
94
+ {
95
+ "skill": "fixer",
96
+ "status": "passed|failed|escalated",
97
+ "timestamp": "2026-04-08T00:00:00Z",
98
+ "testCaseId": "tc-001",
99
+ "batchId": 1,
100
+ "findings": ["Missing expected acceptance criteria section"],
101
+ "fixesApplied": ["Added acceptance criteria section from validator recommendation"],
102
+ "recommendations": ["Run validation to confirm all findings are cleared"],
103
+ "metrics": {
104
+ "findingsAddressed": 1,
105
+ "fixesApplied": 1
106
+ },
107
+ "nextSkill": "validation"
108
+ }
109
+ ```