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,1299 @@
1
+ # Workspace-Maxxing Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Goal:** Build an npx-installable CLI that copies a workspace-builder skill into `.agents/skills/` for OpenCode agents.
6
+
7
+ **Architecture:** A zero-dependency TypeScript CLI with two modules: `index.ts` (argument parsing + entry point) and `install.ts` (recursive file copying). Templates are bundled in the package and copied verbatim to the target project.
8
+
9
+ **Tech Stack:** TypeScript, Node.js builtins only (`fs`, `path`, `process`), Jest for testing.
10
+
11
+ ---
12
+
13
+ ## File Structure
14
+
15
+ ```
16
+ workspace-maxxing/
17
+ ├── package.json # Package config, bin entry, scripts
18
+ ├── tsconfig.json # TypeScript compiler options
19
+ ├── src/
20
+ │ ├── index.ts # CLI: parse args, call installer
21
+ │ └── install.ts # Installer: detect root, copy files
22
+ ├── templates/
23
+ │ ├── SKILL.md # Agent instructions (installed as skill)
24
+ │ └── .workspace-templates/
25
+ │ ├── SYSTEM.md # Layer 0: always-loaded system prompt
26
+ │ ├── CONTEXT.md # Layer 1: task-to-workspace routing
27
+ │ └── workspace/
28
+ │ ├── 00-meta/CONTEXT.md # Workspace-level routing
29
+ │ ├── 01-input/CONTEXT.md # Input stage routing
30
+ │ ├── 02-process/CONTEXT.md # Process stage routing
31
+ │ ├── 03-output/CONTEXT.md # Output stage routing
32
+ │ └── README.md # Usage guide
33
+ ├── tests/
34
+ │ ├── install.test.ts # Installer unit tests
35
+ │ ├── cli.test.ts # CLI argument parsing tests
36
+ │ └── templates.test.ts # Template validation tests
37
+ └── docs/
38
+ └── superpowers/
39
+ ├── specs/2026-04-07-workspace-maxxing-design.md
40
+ └── plans/2026-04-07-workspace-maxxing-plan.md
41
+ ```
42
+
43
+ ---
44
+
45
+ ### Task 1: Project Scaffold
46
+
47
+ **Files:**
48
+ - Create: `package.json`
49
+ - Create: `tsconfig.json`
50
+ - Test: N/A
51
+
52
+ - [ ] **Step 1: Create package.json**
53
+
54
+ ```json
55
+ {
56
+ "name": "workspace-maxxing",
57
+ "version": "0.1.0",
58
+ "description": "npx-installable skill for AI agents to create structured workspaces using ICM methodology",
59
+ "bin": {
60
+ "workspace-maxxing": "dist/index.js"
61
+ },
62
+ "main": "dist/index.js",
63
+ "scripts": {
64
+ "build": "tsc",
65
+ "test": "jest --config jest.config.js",
66
+ "test:watch": "jest --watch",
67
+ "prepublishOnly": "npm run build"
68
+ },
69
+ "keywords": ["ai-agent", "workspace", "skill", "opencode", "icm"],
70
+ "license": "MIT",
71
+ "devDependencies": {
72
+ "@types/jest": "^29.5.12",
73
+ "@types/node": "^20.11.0",
74
+ "jest": "^29.7.0",
75
+ "ts-jest": "^29.1.2",
76
+ "typescript": "^5.3.3"
77
+ },
78
+ "engines": {
79
+ "node": ">=18.0.0"
80
+ }
81
+ }
82
+ ```
83
+
84
+ - [ ] **Step 2: Create tsconfig.json**
85
+
86
+ ```json
87
+ {
88
+ "compilerOptions": {
89
+ "target": "ES2020",
90
+ "module": "commonjs",
91
+ "lib": ["ES2020"],
92
+ "outDir": "./dist",
93
+ "rootDir": "./src",
94
+ "strict": true,
95
+ "esModuleInterop": true,
96
+ "skipLibCheck": true,
97
+ "forceConsistentCasingInFileNames": true,
98
+ "resolveJsonModule": true,
99
+ "declaration": true,
100
+ "declarationMap": true,
101
+ "sourceMap": true
102
+ },
103
+ "include": ["src/**/*"],
104
+ "exclude": ["node_modules", "dist", "tests"]
105
+ }
106
+ ```
107
+
108
+ - [ ] **Step 3: Create jest.config.js**
109
+
110
+ ```js
111
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
112
+ module.exports = {
113
+ preset: 'ts-jest',
114
+ testEnvironment: 'node',
115
+ roots: ['<rootDir>/tests'],
116
+ testMatch: ['**/*.test.ts'],
117
+ moduleFileExtensions: ['ts', 'js', 'json'],
118
+ };
119
+ ```
120
+
121
+ - [ ] **Step 4: Install dependencies and verify build**
122
+
123
+ ```bash
124
+ npm install
125
+ ```
126
+ Expected: `node_modules/` created, no errors.
127
+
128
+ ```bash
129
+ npm run build
130
+ ```
131
+ Expected: `dist/` created with compiled JS (will be empty until source files exist, but no errors).
132
+
133
+ - [ ] **Step 5: Commit**
134
+
135
+ ```bash
136
+ git add package.json tsconfig.json jest.config.js
137
+ git commit -m "chore: scaffold workspace-maxxing project"
138
+ ```
139
+
140
+ ---
141
+
142
+ ### Task 2: Installer Module
143
+
144
+ **Files:**
145
+ - Create: `src/install.ts`
146
+ - Test: `tests/install.test.ts`
147
+
148
+ - [ ] **Step 1: Write the failing test**
149
+
150
+ Create `tests/install.test.ts`:
151
+
152
+ ```typescript
153
+ import * as fs from 'fs';
154
+ import * as path from 'path';
155
+ import * as os from 'os';
156
+ import { installSkill, detectProjectRoot } from '../src/install';
157
+
158
+ describe('install', () => {
159
+ let tempDir: string;
160
+
161
+ beforeEach(() => {
162
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'workspace-maxxing-test-'));
163
+ });
164
+
165
+ afterEach(() => {
166
+ fs.rmSync(tempDir, { recursive: true, force: true });
167
+ });
168
+
169
+ describe('detectProjectRoot', () => {
170
+ it('returns the directory containing package.json', () => {
171
+ const projectDir = path.join(tempDir, 'my-project');
172
+ fs.mkdirSync(projectDir, { recursive: true });
173
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
174
+
175
+ const result = detectProjectRoot(projectDir);
176
+ expect(result).toBe(projectDir);
177
+ });
178
+
179
+ it('returns the directory containing .git', () => {
180
+ const projectDir = path.join(tempDir, 'my-project');
181
+ fs.mkdirSync(path.join(projectDir, '.git'), { recursive: true });
182
+
183
+ const result = detectProjectRoot(projectDir);
184
+ expect(result).toBe(projectDir);
185
+ });
186
+
187
+ it('returns current directory if no marker found', () => {
188
+ const result = detectProjectRoot(tempDir);
189
+ expect(result).toBe(tempDir);
190
+ });
191
+
192
+ it('walks up parent directories to find marker', () => {
193
+ const projectDir = path.join(tempDir, 'my-project');
194
+ const nestedDir = path.join(projectDir, 'src', 'utils');
195
+ fs.mkdirSync(nestedDir, { recursive: true });
196
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
197
+
198
+ const result = detectProjectRoot(nestedDir);
199
+ expect(result).toBe(projectDir);
200
+ });
201
+ });
202
+
203
+ describe('installSkill', () => {
204
+ it('creates the skill directory structure', async () => {
205
+ const projectDir = path.join(tempDir, 'my-project');
206
+ fs.mkdirSync(projectDir, { recursive: true });
207
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
208
+
209
+ const templatesDir = path.join(__dirname, '..', 'templates');
210
+ const result = await installSkill(projectDir, templatesDir);
211
+
212
+ expect(result.success).toBe(true);
213
+ expect(fs.existsSync(path.join(projectDir, '.agents', 'skills', 'workspace-maxxing'))).toBe(true);
214
+ });
215
+
216
+ it('copies SKILL.md to the skill directory', async () => {
217
+ const projectDir = path.join(tempDir, 'my-project');
218
+ fs.mkdirSync(projectDir, { recursive: true });
219
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
220
+
221
+ const templatesDir = path.join(__dirname, '..', 'templates');
222
+ await installSkill(projectDir, templatesDir);
223
+
224
+ const skillPath = path.join(projectDir, '.agents', 'skills', 'workspace-maxxing', 'SKILL.md');
225
+ expect(fs.existsSync(skillPath)).toBe(true);
226
+ });
227
+
228
+ it('copies workspace templates', async () => {
229
+ const projectDir = path.join(tempDir, 'my-project');
230
+ fs.mkdirSync(projectDir, { recursive: true });
231
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
232
+
233
+ const templatesDir = path.join(__dirname, '..', 'templates');
234
+ await installSkill(projectDir, templatesDir);
235
+
236
+ const systemMd = path.join(projectDir, '.agents', 'skills', 'workspace-maxxing', '.workspace-templates', 'SYSTEM.md');
237
+ const contextMd = path.join(projectDir, '.agents', 'skills', 'workspace-maxxing', '.workspace-templates', 'CONTEXT.md');
238
+ expect(fs.existsSync(systemMd)).toBe(true);
239
+ expect(fs.existsSync(contextMd)).toBe(true);
240
+ });
241
+
242
+ it('is idempotent — running twice produces same result', async () => {
243
+ const projectDir = path.join(tempDir, 'my-project');
244
+ fs.mkdirSync(projectDir, { recursive: true });
245
+ fs.writeFileSync(path.join(projectDir, 'package.json'), '{}');
246
+
247
+ const templatesDir = path.join(__dirname, '..', 'templates');
248
+ await installSkill(projectDir, templatesDir);
249
+ const result2 = await installSkill(projectDir, templatesDir);
250
+
251
+ expect(result2.success).toBe(true);
252
+ const skillPath = path.join(projectDir, '.agents', 'skills', 'workspace-maxxing', 'SKILL.md');
253
+ expect(fs.existsSync(skillPath)).toBe(true);
254
+ });
255
+ });
256
+ });
257
+ ```
258
+
259
+ - [ ] **Step 2: Run test to verify it fails**
260
+
261
+ ```bash
262
+ npx jest tests/install.test.ts --no-coverage 2>&1 | head -20
263
+ ```
264
+ Expected: FAIL with "Cannot find module '../src/install'"
265
+
266
+ - [ ] **Step 3: Write minimal implementation**
267
+
268
+ Create `src/install.ts`:
269
+
270
+ ```typescript
271
+ import * as fs from 'fs';
272
+ import * as path from 'path';
273
+
274
+ export interface InstallResult {
275
+ success: boolean;
276
+ skillPath: string;
277
+ error?: string;
278
+ }
279
+
280
+ /**
281
+ * Walk up from startDir looking for package.json or .git directory.
282
+ * Returns the first parent containing a marker, or startDir if none found.
283
+ */
284
+ export function detectProjectRoot(startDir: string): string {
285
+ let current = path.resolve(startDir);
286
+ const root = path.parse(current).root;
287
+
288
+ while (current !== root) {
289
+ const hasPackageJson = fs.existsSync(path.join(current, 'package.json'));
290
+ const hasGit = fs.existsSync(path.join(current, '.git'));
291
+
292
+ if (hasPackageJson || hasGit) {
293
+ return current;
294
+ }
295
+
296
+ current = path.dirname(current);
297
+ }
298
+
299
+ return startDir;
300
+ }
301
+
302
+ /**
303
+ * Recursively copy a directory, overwriting existing files.
304
+ */
305
+ function copyDirSync(src: string, dest: string): void {
306
+ if (!fs.existsSync(src)) {
307
+ throw new Error(`Source directory not found: ${src}`);
308
+ }
309
+
310
+ fs.mkdirSync(dest, { recursive: true });
311
+
312
+ const entries = fs.readdirSync(src, { withFileTypes: true });
313
+
314
+ for (const entry of entries) {
315
+ const srcPath = path.join(src, entry.name);
316
+ const destPath = path.join(dest, entry.name);
317
+
318
+ if (entry.isDirectory()) {
319
+ copyDirSync(srcPath, destPath);
320
+ } else {
321
+ fs.copyFileSync(srcPath, destPath);
322
+ }
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Install the workspace-maxxing skill into a project.
328
+ * Copies SKILL.md and .workspace-templates/ to .agents/skills/workspace-maxxing/
329
+ */
330
+ export async function installSkill(
331
+ projectRoot: string,
332
+ templatesDir: string,
333
+ ): Promise<InstallResult> {
334
+ const skillDir = path.join(projectRoot, '.agents', 'skills', 'workspace-maxxing');
335
+
336
+ try {
337
+ // Copy SKILL.md
338
+ const skillMdSrc = path.join(templatesDir, 'SKILL.md');
339
+ const skillMdDest = path.join(skillDir, 'SKILL.md');
340
+ fs.mkdirSync(path.dirname(skillMdDest), { recursive: true });
341
+ fs.copyFileSync(skillMdSrc, skillMdDest);
342
+
343
+ // Copy .workspace-templates/
344
+ const workspaceTemplatesSrc = path.join(templatesDir, '.workspace-templates');
345
+ const workspaceTemplatesDest = path.join(skillDir, '.workspace-templates');
346
+ copyDirSync(workspaceTemplatesSrc, workspaceTemplatesDest);
347
+
348
+ return { success: true, skillPath: skillDir };
349
+ } catch (error) {
350
+ const message = error instanceof Error ? error.message : String(error);
351
+ return { success: false, skillPath: skillDir, error: message };
352
+ }
353
+ }
354
+ ```
355
+
356
+ - [ ] **Step 4: Run test to verify it passes**
357
+
358
+ ```bash
359
+ npx jest tests/install.test.ts --no-coverage
360
+ ```
361
+ Expected: All tests PASS
362
+
363
+ - [ ] **Step 5: Commit**
364
+
365
+ ```bash
366
+ git add src/install.ts tests/install.test.ts
367
+ git commit -m "feat: implement installer with project root detection and file copying"
368
+ ```
369
+
370
+ ---
371
+
372
+ ### Task 3: CLI Entry Point
373
+
374
+ **Files:**
375
+ - Create: `src/index.ts`
376
+ - Test: `tests/cli.test.ts`
377
+
378
+ - [ ] **Step 1: Write the failing test**
379
+
380
+ Create `tests/cli.test.ts`:
381
+
382
+ ```typescript
383
+ import * as fs from 'fs';
384
+ import * as path from 'path';
385
+ import * as os from 'os';
386
+ import { execSync } from 'child_process';
387
+
388
+ describe('CLI', () => {
389
+ let tempDir: string;
390
+
391
+ beforeEach(() => {
392
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'workspace-maxxing-cli-'));
393
+ fs.writeFileSync(path.join(tempDir, 'package.json'), '{}');
394
+ });
395
+
396
+ afterEach(() => {
397
+ fs.rmSync(tempDir, { recursive: true, force: true });
398
+ });
399
+
400
+ it('shows help when no args provided', () => {
401
+ const output = execSync('node dist/index.js', {
402
+ cwd: path.join(__dirname, '..'),
403
+ encoding: 'utf-8',
404
+ });
405
+
406
+ expect(output).toContain('workspace-maxxing');
407
+ expect(output).toContain('--opencode');
408
+ });
409
+
410
+ it('shows help when --help flag is provided', () => {
411
+ const output = execSync('node dist/index.js --help', {
412
+ cwd: path.join(__dirname, '..'),
413
+ encoding: 'utf-8',
414
+ });
415
+
416
+ expect(output).toContain('workspace-maxxing');
417
+ expect(output).toContain('--opencode');
418
+ });
419
+
420
+ it('installs skill when --opencode flag is provided', () => {
421
+ const output = execSync(`node dist/index.js --opencode`, {
422
+ cwd: tempDir,
423
+ encoding: 'utf-8',
424
+ env: { ...process.env, WORKSPACE_MAXXING_TEMPLATES: path.join(__dirname, '..', 'templates') },
425
+ });
426
+
427
+ expect(output).toContain('installed');
428
+ expect(
429
+ fs.existsSync(path.join(tempDir, '.agents', 'skills', 'workspace-maxxing', 'SKILL.md')),
430
+ ).toBe(true);
431
+ });
432
+
433
+ it('errors on unsupported flag', () => {
434
+ try {
435
+ execSync('node dist/index.js --claude', {
436
+ cwd: path.join(__dirname, '..'),
437
+ encoding: 'utf-8',
438
+ stdio: ['pipe', 'pipe', 'pipe'],
439
+ });
440
+ fail('Should have thrown');
441
+ } catch (error) {
442
+ // Expected — --claude not yet supported
443
+ expect(true).toBe(true);
444
+ }
445
+ });
446
+ });
447
+ ```
448
+
449
+ - [ ] **Step 2: Run test to verify it fails**
450
+
451
+ ```bash
452
+ npx jest tests/cli.test.ts --no-coverage 2>&1 | head -20
453
+ ```
454
+ Expected: FAIL with "Cannot find module '../dist/index.js'" or similar
455
+
456
+ - [ ] **Step 3: Write minimal implementation**
457
+
458
+ Create `src/index.ts`:
459
+
460
+ ```typescript
461
+ #!/usr/bin/env node
462
+
463
+ import * as path from 'path';
464
+ import { detectProjectRoot, installSkill } from './install';
465
+
466
+ function showHelp(): void {
467
+ console.log(`
468
+ workspace-maxxing — npx-installable skill for AI agents
469
+
470
+ Usage:
471
+ npx workspace-maxxing [options]
472
+
473
+ Options:
474
+ --opencode Install skill for OpenCode agents
475
+ --help Show this help message
476
+
477
+ Examples:
478
+ npx workspace-maxxing --opencode
479
+ `);
480
+ }
481
+
482
+ async function main(): Promise<void> {
483
+ const args = process.argv.slice(2);
484
+
485
+ if (args.length === 0 || args.includes('--help')) {
486
+ showHelp();
487
+ process.exit(0);
488
+ }
489
+
490
+ if (args.includes('--opencode')) {
491
+ const cwd = process.cwd();
492
+ const projectRoot = detectProjectRoot(cwd);
493
+
494
+ if (projectRoot !== cwd) {
495
+ console.log(`Detected project root: ${projectRoot}`);
496
+ }
497
+
498
+ // Allow overriding templates path for testing; default to bundled templates
499
+ const templatesDir =
500
+ process.env.WORKSPACE_MAXXING_TEMPLATES ??
501
+ path.join(__dirname, '..', 'templates');
502
+
503
+ console.log('Installing workspace-maxxing skill...');
504
+ const result = await installSkill(projectRoot, templatesDir);
505
+
506
+ if (result.success) {
507
+ console.log(`Skill installed to: ${result.skillPath}`);
508
+ console.log('Open a new OpenCode session and invoke the workspace-maxxing skill to get started.');
509
+ } else {
510
+ console.error(`Installation failed: ${result.error}`);
511
+ process.exit(1);
512
+ }
513
+
514
+ return;
515
+ }
516
+
517
+ console.error(`Unknown flag: ${args.find((a) => a.startsWith('--'))}`);
518
+ console.error('Run "npx workspace-maxxing --help" for usage.');
519
+ process.exit(1);
520
+ }
521
+
522
+ main().catch((error) => {
523
+ console.error(error);
524
+ process.exit(1);
525
+ });
526
+ ```
527
+
528
+ - [ ] **Step 4: Build the project**
529
+
530
+ ```bash
531
+ npm run build
532
+ ```
533
+ Expected: `dist/` created with `index.js` and `install.js`
534
+
535
+ - [ ] **Step 5: Run test to verify it passes**
536
+
537
+ ```bash
538
+ npx jest tests/cli.test.ts --no-coverage
539
+ ```
540
+ Expected: All tests PASS
541
+
542
+ - [ ] **Step 6: Commit**
543
+
544
+ ```bash
545
+ git add src/index.ts tests/cli.test.ts
546
+ git commit -m "feat: add CLI entry point with --opencode flag and help output"
547
+ ```
548
+
549
+ ---
550
+
551
+ ### Task 4: Template Validation Tests
552
+
553
+ **Files:**
554
+ - Test: `tests/templates.test.ts`
555
+ - Modify: `templates/SKILL.md` (created in Task 5, but tests reference it)
556
+
557
+ Note: These tests will fail until Task 5 creates the template files. That's intentional — we write tests first.
558
+
559
+ - [ ] **Step 1: Write the failing test**
560
+
561
+ Create `tests/templates.test.ts`:
562
+
563
+ ```typescript
564
+ import * as fs from 'fs';
565
+ import * as path from 'path';
566
+
567
+ const templatesDir = path.join(__dirname, '..', 'templates');
568
+
569
+ describe('Template files', () => {
570
+ const requiredFiles = [
571
+ 'SKILL.md',
572
+ '.workspace-templates/SYSTEM.md',
573
+ '.workspace-templates/CONTEXT.md',
574
+ '.workspace-templates/workspace/00-meta/CONTEXT.md',
575
+ '.workspace-templates/workspace/01-input/CONTEXT.md',
576
+ '.workspace-templates/workspace/02-process/CONTEXT.md',
577
+ '.workspace-templates/workspace/03-output/CONTEXT.md',
578
+ '.workspace-templates/workspace/README.md',
579
+ ];
580
+
581
+ describe.each(requiredFiles)('%s', (filePath) => {
582
+ it('exists', () => {
583
+ const fullPath = path.join(templatesDir, filePath);
584
+ expect(fs.existsSync(fullPath)).toBe(true);
585
+ });
586
+
587
+ it('is not empty', () => {
588
+ const fullPath = path.join(templatesDir, filePath);
589
+ if (!fs.existsSync(fullPath)) {
590
+ fail(`File does not exist: ${fullPath}`);
591
+ return;
592
+ }
593
+ const content = fs.readFileSync(fullPath, 'utf-8');
594
+ expect(content.trim().length).toBeGreaterThan(0);
595
+ });
596
+ });
597
+
598
+ it('SKILL.md contains required sections', () => {
599
+ const skillPath = path.join(templatesDir, 'SKILL.md');
600
+ if (!fs.existsSync(skillPath)) {
601
+ fail('SKILL.md does not exist');
602
+ return;
603
+ }
604
+ const content = fs.readFileSync(skillPath, 'utf-8');
605
+
606
+ expect(content).toContain('# Workspace-Maxxing');
607
+ expect(content).toContain('## Role');
608
+ expect(content).toContain('## Process');
609
+ expect(content).toContain('## ICM Rules');
610
+ expect(content).toContain('## Output Format');
611
+ });
612
+
613
+ it('SYSTEM.md contains Layer 0 content', () => {
614
+ const systemPath = path.join(templatesDir, '.workspace-templates', 'SYSTEM.md');
615
+ if (!fs.existsSync(systemPath)) {
616
+ fail('SYSTEM.md does not exist');
617
+ return;
618
+ }
619
+ const content = fs.readFileSync(systemPath, 'utf-8');
620
+
621
+ expect(content).toContain('folder map');
622
+ expect(content).toContain('workspace');
623
+ });
624
+
625
+ it('CONTEXT.md contains routing table structure', () => {
626
+ const contextPath = path.join(templatesDir, '.workspace-templates', 'CONTEXT.md');
627
+ if (!fs.existsSync(contextPath)) {
628
+ fail('CONTEXT.md does not exist');
629
+ return;
630
+ }
631
+ const content = fs.readFileSync(contextPath, 'utf-8');
632
+
633
+ expect(content).toContain('routing');
634
+ expect(content).toContain('workspace');
635
+ });
636
+ });
637
+ ```
638
+
639
+ - [ ] **Step 2: Run test to verify it fails**
640
+
641
+ ```bash
642
+ npx jest tests/templates.test.ts --no-coverage 2>&1 | head -30
643
+ ```
644
+ Expected: FAIL — template files don't exist yet
645
+
646
+ - [ ] **Step 3: Commit the tests only**
647
+
648
+ ```bash
649
+ git add tests/templates.test.ts
650
+ git commit -m "test: add template validation tests"
651
+ ```
652
+
653
+ ---
654
+
655
+ ### Task 5: SKILL.md Template
656
+
657
+ **Files:**
658
+ - Create: `templates/SKILL.md`
659
+ - Test: `tests/templates.test.ts` (from Task 4)
660
+
661
+ - [ ] **Step 1: Write the SKILL.md**
662
+
663
+ Create `templates/SKILL.md`:
664
+
665
+ ```markdown
666
+ # Workspace-Maxxing
667
+
668
+ ## Role
669
+
670
+ You are a workspace architect. You create structured, ICM-compliant workspaces that serve as both agent instructions and reusable skill packages.
671
+
672
+ ## Process
673
+
674
+ ### 1. CAPTURE INTENT
675
+
676
+ Ask the user: "What workflow do you want to automate?"
677
+
678
+ Understand:
679
+ - What is the end goal? (e.g., research report, PDF output, content pipeline)
680
+ - What are the input sources? (web, files, APIs, databases)
681
+ - What is the expected output format?
682
+ - Are there any constraints or preferences?
683
+
684
+ ### 2. PROPOSE STRUCTURE
685
+
686
+ Design a workspace using the Interpretable Context Methodology (ICM):
687
+
688
+ - **Numbered folders** for workflow stages (01-research, 02-draft, 03-review, 04-output)
689
+ - **SYSTEM.md** (Layer 0) — always-loaded system prompt with folder map and core rules
690
+ - **CONTEXT.md** (Layer 1) — routing table mapping tasks to workspaces
691
+ - **Per-folder CONTEXT.md** (Layer 2) — what to load, in order, for each stage
692
+ - **Content files** (Layer 3) — reference material, loaded selectively
693
+
694
+ Present the plan to the user as a file tree with brief descriptions.
695
+
696
+ ### 3. GET APPROVAL
697
+
698
+ Show the proposed structure. Wait for approval. **Do not build until the user approves.**
699
+
700
+ If the user requests changes, update the proposal and show it again.
701
+
702
+ ### 4. BUILD WORKSPACE
703
+
704
+ Create the approved structure:
705
+ 1. Create numbered folders for each stage
706
+ 2. Write SYSTEM.md with the folder map and agent rules
707
+ 3. Write CONTEXT.md files with routing instructions
708
+ 4. Write content files with reference material
709
+ 5. Write a README.md explaining how to use the workspace
710
+
711
+ ### 5. ASSESS TOOLS
712
+
713
+ Scan the environment for available tools:
714
+ - Check installed packages (`npm list`, `pip list`, etc.)
715
+ - Check available CLI tools in PATH
716
+ - Check what the agent harness can access
717
+
718
+ List available tools. Propose any missing tools the workspace needs. **Get user approval before installing anything.**
719
+
720
+ ### 6. INSTALL TOOLS
721
+
722
+ After user approval, install proposed tools. Log what was installed.
723
+
724
+ ### 7. TEST AUTONOMOUSLY
725
+
726
+ Spawn sub-agents with diverse test cases relevant to the workspace:
727
+ - Give each sub-agent a realistic task
728
+ - Evaluate the output against expected criteria
729
+ - Record what worked and what didn't
730
+
731
+ Only involve the human if confidence is low or results are inconsistent.
732
+
733
+ ### 8. ITERATE
734
+
735
+ Based on test results:
736
+ - Update SYSTEM.md if agent behavior was wrong
737
+ - Update CONTEXT.md if routing was unclear
738
+ - Update content files if reference material was insufficient
739
+ - Re-test if significant changes were made
740
+
741
+ ### 9. DELIVER
742
+
743
+ Output three artifacts:
744
+ 1. **workspace/** — the built workspace folder
745
+ 2. **.agents/skills/<workspace-name>/** — installable skill package
746
+ 3. **USAGE.md** — how to use this workspace in future sessions
747
+
748
+ ## ICM Rules
749
+
750
+ Follow these rules strictly:
751
+
752
+ 1. **Canonical Sources** — Each fact lives in exactly one file. Other files reference it, never duplicate it.
753
+ 2. **One-Way Dependencies** — A → B is fine. B → A means you need a third file C that both reference.
754
+ 3. **Selective Loading** — Route to specific sections of files, not entire files. Load only what the task needs.
755
+ 4. **Numbered Folders** — Use numbered folders for workflow stages: `01-`, `02-`, `03-`, etc.
756
+ 5. **Routing ≠ Content** — CONTEXT.md files tell agents what to load. They do not contain the knowledge itself.
757
+
758
+ ## Output Format
759
+
760
+ When delivering the final workspace:
761
+
762
+ ```
763
+ workspace/
764
+ ├── SYSTEM.md # Layer 0: always loaded
765
+ ├── CONTEXT.md # Layer 1: routing table
766
+ ├── 01-<stage>/
767
+ │ └── CONTEXT.md # Layer 2: stage-specific routing
768
+ ├── 02-<stage>/
769
+ │ └── CONTEXT.md
770
+ ├── ...
771
+ └── README.md # Usage guide
772
+
773
+ .agents/skills/<workspace-name>/
774
+ └── SKILL.md # Installable skill
775
+
776
+ USAGE.md # How to use in future sessions
777
+ ```
778
+ ```
779
+
780
+ - [ ] **Step 2: Run template tests to verify they pass**
781
+
782
+ ```bash
783
+ npx jest tests/templates.test.ts --no-coverage
784
+ ```
785
+ Expected: SKILL.md-related tests PASS, other template tests still FAIL (files not yet created)
786
+
787
+ - [ ] **Step 3: Commit**
788
+
789
+ ```bash
790
+ git add templates/SKILL.md
791
+ git commit -m "feat: add SKILL.md with complete agent instructions for workspace creation"
792
+ ```
793
+
794
+ ---
795
+
796
+ ### Task 6: Workspace Templates
797
+
798
+ **Files:**
799
+ - Create: `templates/.workspace-templates/SYSTEM.md`
800
+ - Create: `templates/.workspace-templates/CONTEXT.md`
801
+ - Create: `templates/.workspace-templates/workspace/00-meta/CONTEXT.md`
802
+ - Create: `templates/.workspace-templates/workspace/01-input/CONTEXT.md`
803
+ - Create: `templates/.workspace-templates/workspace/02-process/CONTEXT.md`
804
+ - Create: `templates/.workspace-templates/workspace/03-output/CONTEXT.md`
805
+ - Create: `templates/.workspace-templates/workspace/README.md`
806
+ - Test: `tests/templates.test.ts` (from Task 4)
807
+
808
+ - [ ] **Step 1: Create SYSTEM.md (Layer 0 template)**
809
+
810
+ Create `templates/.workspace-templates/SYSTEM.md`:
811
+
812
+ ```markdown
813
+ # System — Workspace Root
814
+
815
+ ## Folder Map
816
+
817
+ | Folder | Purpose |
818
+ |--------|---------|
819
+ | 00-meta/ | Workspace configuration, tool inventory, session notes |
820
+ | 01-input/ | Source materials, research data, raw inputs |
821
+ | 02-process/ | Working documents, analysis, drafts |
822
+ | 03-output/ | Final deliverables, exports, published content |
823
+
824
+ ## Rules
825
+
826
+ 1. Read this file first every session
827
+ 2. Check CONTEXT.md for task routing before loading any other files
828
+ 3. Load only the files and sections your task requires
829
+ 4. Never duplicate information — reference canonical sources instead
830
+ 5. One-way dependencies only: downstream folders may reference upstream, never the reverse
831
+
832
+ ## Tool Inventory
833
+
834
+ Tools available in this workspace are tracked in `00-meta/tools.md`.
835
+ Check this file before proposing new tool installations.
836
+ ```
837
+
838
+ - [ ] **Step 2: Create CONTEXT.md (Layer 1 routing template)**
839
+
840
+ Create `templates/.workspace-templates/CONTEXT.md`:
841
+
842
+ ```markdown
843
+ # Routing Table
844
+
845
+ ## How to Use This File
846
+
847
+ This file maps tasks to workspaces. Read the task description, find the matching entry, and load only the files listed.
848
+
849
+ ## Task Routing
850
+
851
+ | When you need to... | Go to | Load |
852
+ |---------------------|-------|------|
853
+ | Understand workspace structure | SYSTEM.md | Always loaded |
854
+ | Gather inputs or research | 01-input/CONTEXT.md | Stage-specific routing |
855
+ | Process, analyze, or draft | 02-process/CONTEXT.md | Stage-specific routing |
856
+ | Produce final output | 03-output/CONTEXT.md | Stage-specific routing |
857
+ | Check available tools | 00-meta/tools.md | Tool inventory |
858
+
859
+ ## Loading Order
860
+
861
+ 1. SYSTEM.md (always)
862
+ 2. This file (once per session)
863
+ 3. The relevant workspace CONTEXT.md
864
+ 4. Only the content files your task needs
865
+ ```
866
+
867
+ - [ ] **Step 3: Create workspace folder CONTEXT.md files**
868
+
869
+ Create `templates/.workspace-templates/workspace/00-meta/CONTEXT.md`:
870
+
871
+ ```markdown
872
+ # 00-meta — Workspace Configuration
873
+
874
+ ## Purpose
875
+
876
+ Workspace-level configuration, tool inventory, and session notes.
877
+
878
+ ## Files in This Folder
879
+
880
+ | File | Purpose |
881
+ |------|---------|
882
+ | tools.md | Inventory of available tools and their versions |
883
+ | session-log.md | Log of workspace sessions |
884
+
885
+ ## Routing
886
+
887
+ - To check available tools: read `tools.md`
888
+ - To propose new tools: update `tools.md` after user approval
889
+ ```
890
+
891
+ Create `templates/.workspace-templates/workspace/01-input/CONTEXT.md`:
892
+
893
+ ```markdown
894
+ # 01-input — Input Stage
895
+
896
+ ## Purpose
897
+
898
+ Source materials, research data, and raw inputs.
899
+
900
+ ## Files in This Folder
901
+
902
+ | File | Purpose |
903
+ |------|---------|
904
+ | sources.md | List of input sources and access methods |
905
+ | research/ | Raw research notes and findings |
906
+
907
+ ## Routing
908
+
909
+ - To gather information: check `sources.md` for available inputs
910
+ - To add research: create files in `research/` with date-prefixed names
911
+ ```
912
+
913
+ Create `templates/.workspace-templates/workspace/02-process/CONTEXT.md`:
914
+
915
+ ```markdown
916
+ # 02-process — Process Stage
917
+
918
+ ## Purpose
919
+
920
+ Working documents, analysis, and drafts.
921
+
922
+ ## Files in This Folder
923
+
924
+ | File | Purpose |
925
+ |------|---------|
926
+ | analysis/ | Working analysis and notes |
927
+ | drafts/ | Draft documents under iteration |
928
+
929
+ ## Routing
930
+
931
+ - To analyze inputs: create files in `analysis/` referencing sources from 01-input/
932
+ - To draft content: create files in `drafts/`
933
+ - Reference upstream files (01-input/), never duplicate their content
934
+ ```
935
+
936
+ Create `templates/.workspace-templates/workspace/03-output/CONTEXT.md`:
937
+
938
+ ```markdown
939
+ # 03-output — Output Stage
940
+
941
+ ## Purpose
942
+
943
+ Final deliverables, exports, and published content.
944
+
945
+ ## Files in This Folder
946
+
947
+ | File | Purpose |
948
+ |------|---------|
949
+ | deliverables/ | Final output documents |
950
+ | exports/ | Exported files in various formats |
951
+
952
+ ## Routing
953
+
954
+ - To produce output: create files in `deliverables/`
955
+ - To export: create files in `exports/`
956
+ - Reference processed content from 02-process/, never duplicate it
957
+ ```
958
+
959
+ - [ ] **Step 4: Create workspace README.md**
960
+
961
+ Create `templates/.workspace-templates/workspace/README.md`:
962
+
963
+ ```markdown
964
+ # Workspace
965
+
966
+ This workspace follows the Interpretable Context Methodology (ICM).
967
+
968
+ ## Structure
969
+
970
+ - **SYSTEM.md** — Always loaded. Contains the folder map and core rules.
971
+ - **CONTEXT.md** — Routing table. Maps tasks to workspaces.
972
+ - **Numbered folders** — Workflow stages (01-input → 02-process → 03-output).
973
+ - **Per-folder CONTEXT.md** — Stage-specific routing instructions.
974
+
975
+ ## How to Use
976
+
977
+ 1. Start a new session by reading SYSTEM.md
978
+ 2. Check CONTEXT.md to find the right workspace for your task
979
+ 3. Load only the files you need — not everything
980
+ 4. Follow ICM rules: canonical sources, one-way dependencies, selective loading
981
+
982
+ ## ICM Rules
983
+
984
+ - Each fact lives in exactly one file
985
+ - One-way dependencies only (downstream references upstream)
986
+ - Route to sections, not whole files
987
+ - Numbered folders for workflow stages
988
+ ```
989
+
990
+ - [ ] **Step 5: Create 00-meta/tools.md template**
991
+
992
+ Create `templates/.workspace-templates/workspace/00-meta/tools.md`:
993
+
994
+ ```markdown
995
+ # Tool Inventory
996
+
997
+ ## Available Tools
998
+
999
+ _List tools available in this workspace. Update after each installation._
1000
+
1001
+ | Tool | Version | Purpose | Installed |
1002
+ |------|---------|---------|-----------|
1003
+ | | | | |
1004
+
1005
+ ## Proposed Tools
1006
+
1007
+ _Tools proposed but not yet installed. Remove after user approval and installation._
1008
+
1009
+ | Tool | Purpose | Status |
1010
+ |------|---------|--------|
1011
+ | | | |
1012
+ ```
1013
+
1014
+ - [ ] **Step 6: Run all template tests**
1015
+
1016
+ ```bash
1017
+ npx jest tests/templates.test.ts --no-coverage
1018
+ ```
1019
+ Expected: ALL tests PASS
1020
+
1021
+ - [ ] **Step 7: Run full test suite**
1022
+
1023
+ ```bash
1024
+ npm test
1025
+ ```
1026
+ Expected: ALL tests PASS (install, CLI, templates)
1027
+
1028
+ - [ ] **Step 8: Commit**
1029
+
1030
+ ```bash
1031
+ git add templates/.workspace-templates/
1032
+ git commit -m "feat: add workspace templates with ICM structure"
1033
+ ```
1034
+
1035
+ ---
1036
+
1037
+ ### Task 7: Integration Test
1038
+
1039
+ **Files:**
1040
+ - Create: `tests/integration.test.ts`
1041
+
1042
+ - [ ] **Step 1: Write the integration test**
1043
+
1044
+ Create `tests/integration.test.ts`:
1045
+
1046
+ ```typescript
1047
+ import * as fs from 'fs';
1048
+ import * as path from 'path';
1049
+ import * as os from 'os';
1050
+ import { execSync } from 'child_process';
1051
+
1052
+ describe('Integration', () => {
1053
+ let tempDir: string;
1054
+
1055
+ beforeEach(() => {
1056
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'workspace-maxxing-integration-'));
1057
+ fs.writeFileSync(path.join(tempDir, 'package.json'), '{}');
1058
+ });
1059
+
1060
+ afterEach(() => {
1061
+ fs.rmSync(tempDir, { recursive: true, force: true });
1062
+ });
1063
+
1064
+ it('end-to-end: install and verify complete structure', () => {
1065
+ // Build first
1066
+ execSync('npm run build', {
1067
+ cwd: path.join(__dirname, '..'),
1068
+ stdio: 'pipe',
1069
+ });
1070
+
1071
+ // Run installer
1072
+ const output = execSync('node dist/index.js --opencode', {
1073
+ cwd: tempDir,
1074
+ encoding: 'utf-8',
1075
+ env: {
1076
+ ...process.env,
1077
+ WORKSPACE_MAXXING_TEMPLATES: path.join(__dirname, '..', 'templates'),
1078
+ },
1079
+ });
1080
+
1081
+ expect(output).toContain('installed');
1082
+
1083
+ // Verify skill directory
1084
+ const skillDir = path.join(tempDir, '.agents', 'skills', 'workspace-maxxing');
1085
+ expect(fs.existsSync(skillDir)).toBe(true);
1086
+
1087
+ // Verify all expected files exist
1088
+ const expectedFiles = [
1089
+ 'SKILL.md',
1090
+ '.workspace-templates/SYSTEM.md',
1091
+ '.workspace-templates/CONTEXT.md',
1092
+ '.workspace-templates/workspace/00-meta/CONTEXT.md',
1093
+ '.workspace-templates/workspace/01-input/CONTEXT.md',
1094
+ '.workspace-templates/workspace/02-process/CONTEXT.md',
1095
+ '.workspace-templates/workspace/03-output/CONTEXT.md',
1096
+ '.workspace-templates/workspace/README.md',
1097
+ ];
1098
+
1099
+ for (const file of expectedFiles) {
1100
+ const filePath = path.join(skillDir, file);
1101
+ expect(fs.existsSync(filePath)).toBe(true);
1102
+ const content = fs.readFileSync(filePath, 'utf-8');
1103
+ expect(content.trim().length).toBeGreaterThan(0);
1104
+ }
1105
+
1106
+ // Verify SKILL.md has required sections
1107
+ const skillContent = fs.readFileSync(path.join(skillDir, 'SKILL.md'), 'utf-8');
1108
+ expect(skillContent).toContain('## Role');
1109
+ expect(skillContent).toContain('## Process');
1110
+ expect(skillContent).toContain('## ICM Rules');
1111
+ expect(skillContent).toContain('## Output Format');
1112
+
1113
+ // Verify SYSTEM.md has Layer 0 content
1114
+ const systemContent = fs.readFileSync(path.join(skillDir, '.workspace-templates', 'SYSTEM.md'), 'utf-8');
1115
+ expect(systemContent).toContain('folder map');
1116
+ });
1117
+
1118
+ it('idempotency: running install twice produces valid result', () => {
1119
+ execSync('npm run build', {
1120
+ cwd: path.join(__dirname, '..'),
1121
+ stdio: 'pipe',
1122
+ });
1123
+
1124
+ // Run twice
1125
+ execSync('node dist/index.js --opencode', {
1126
+ cwd: tempDir,
1127
+ encoding: 'utf-8',
1128
+ env: {
1129
+ ...process.env,
1130
+ WORKSPACE_MAXXING_TEMPLATES: path.join(__dirname, '..', 'templates'),
1131
+ },
1132
+ });
1133
+
1134
+ execSync('node dist/index.js --opencode', {
1135
+ cwd: tempDir,
1136
+ encoding: 'utf-8',
1137
+ env: {
1138
+ ...process.env,
1139
+ WORKSPACE_MAXXING_TEMPLATES: path.join(__dirname, '..', 'templates'),
1140
+ },
1141
+ });
1142
+
1143
+ // Still valid
1144
+ const skillDir = path.join(tempDir, '.agents', 'skills', 'workspace-maxxing');
1145
+ expect(fs.existsSync(path.join(skillDir, 'SKILL.md'))).toBe(true);
1146
+ });
1147
+ });
1148
+ ```
1149
+
1150
+ - [ ] **Step 2: Run integration tests**
1151
+
1152
+ ```bash
1153
+ npx jest tests/integration.test.ts --no-coverage
1154
+ ```
1155
+ Expected: ALL tests PASS
1156
+
1157
+ - [ ] **Step 3: Run full test suite**
1158
+
1159
+ ```bash
1160
+ npm test
1161
+ ```
1162
+ Expected: ALL tests PASS
1163
+
1164
+ - [ ] **Step 4: Commit**
1165
+
1166
+ ```bash
1167
+ git add tests/integration.test.ts
1168
+ git commit -m "test: add end-to-end integration test for full install flow"
1169
+ ```
1170
+
1171
+ ---
1172
+
1173
+ ### Task 8: Final Polish
1174
+
1175
+ **Files:**
1176
+ - Modify: `package.json` (add repository, homepage)
1177
+ - Create: `.gitignore`
1178
+ - Create: `README.md` (project readme, not workspace template)
1179
+
1180
+ - [ ] **Step 1: Update package.json with metadata**
1181
+
1182
+ ```json
1183
+ {
1184
+ "name": "workspace-maxxing",
1185
+ "version": "0.1.0",
1186
+ "description": "npx-installable skill for AI agents to create structured workspaces using ICM methodology",
1187
+ "bin": {
1188
+ "workspace-maxxing": "dist/index.js"
1189
+ },
1190
+ "main": "dist/index.js",
1191
+ "scripts": {
1192
+ "build": "tsc",
1193
+ "test": "jest --config jest.config.js",
1194
+ "test:watch": "jest --watch",
1195
+ "prepublishOnly": "npm run build"
1196
+ },
1197
+ "keywords": ["ai-agent", "workspace", "skill", "opencode", "icm"],
1198
+ "author": "",
1199
+ "license": "MIT",
1200
+ "repository": {
1201
+ "type": "git",
1202
+ "url": "https://github.com/YOUR_USERNAME/workspace-maxxing"
1203
+ },
1204
+ "devDependencies": {
1205
+ "@types/jest": "^29.5.12",
1206
+ "@types/node": "^20.11.0",
1207
+ "jest": "^29.7.0",
1208
+ "ts-jest": "^29.1.2",
1209
+ "typescript": "^5.3.3"
1210
+ },
1211
+ "engines": {
1212
+ "node": ">=18.0.0"
1213
+ }
1214
+ }
1215
+ ```
1216
+
1217
+ - [ ] **Step 2: Create .gitignore**
1218
+
1219
+ ```
1220
+ node_modules/
1221
+ dist/
1222
+ coverage/
1223
+ *.tsbuildinfo
1224
+ .env
1225
+ ```
1226
+
1227
+ - [ ] **Step 3: Create project README.md**
1228
+
1229
+ Create `README.md` (at project root, not in templates):
1230
+
1231
+ ```markdown
1232
+ # workspace-maxxing
1233
+
1234
+ > npx-installable skill for AI agents to create structured workspaces using the Interpretable Context Methodology (ICM).
1235
+
1236
+ ## Quick Start
1237
+
1238
+ ```bash
1239
+ npx workspace-maxxing --opencode
1240
+ ```
1241
+
1242
+ This installs the workspace-maxxing skill into `.agents/skills/workspace-maxxing/` in your project.
1243
+
1244
+ ## What It Does
1245
+
1246
+ After installation, open a new OpenCode session and invoke the workspace-maxxing skill. The agent will:
1247
+
1248
+ 1. Ask what workflow you want to automate
1249
+ 2. Propose a workspace structure using ICM methodology
1250
+ 3. Wait for your approval
1251
+ 4. Build the workspace with numbered folders, routing tables, and reference files
1252
+ 5. Assess available tools and propose any missing ones
1253
+ 6. Test the workspace autonomously with sub-agents
1254
+ 7. Deliver a complete workspace + skill package + usage guide
1255
+
1256
+ ## ICM Methodology
1257
+
1258
+ Based on [Interpretable Context Methodology](https://arxiv.org/abs/2603.16021) by Jake Van Clief & David McDermott:
1259
+
1260
+ - **Layer 0** — SYSTEM.md: always-loaded system prompt
1261
+ - **Layer 1** — CONTEXT.md: task-to-workspace routing
1262
+ - **Layer 2** — Per-folder CONTEXT.md: stage-specific instructions
1263
+ - **Layer 3** — Content files: selectively loaded reference material
1264
+
1265
+ ## Development
1266
+
1267
+ ```bash
1268
+ npm install
1269
+ npm run build
1270
+ npm test
1271
+ ```
1272
+
1273
+ ## License
1274
+
1275
+ MIT
1276
+ ```
1277
+
1278
+ - [ ] **Step 4: Run full test suite one final time**
1279
+
1280
+ ```bash
1281
+ npm test
1282
+ ```
1283
+ Expected: ALL tests PASS
1284
+
1285
+ - [ ] **Step 5: Verify build**
1286
+
1287
+ ```bash
1288
+ npm run build
1289
+ ```
1290
+ Expected: Clean build, no errors
1291
+
1292
+ - [ ] **Step 6: Final commit**
1293
+
1294
+ ```bash
1295
+ git add package.json .gitignore README.md
1296
+ git commit -m "chore: add project metadata, gitignore, and readme"
1297
+ ```
1298
+
1299
+ ---