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.
- package/.agents/skills/workspace-maxxing/.workspace-templates/CONTEXT.md +44 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/SYSTEM.md +44 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/references/anti-patterns.md +16 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/references/iron-laws.md +26 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/references/reporting-format.md +52 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/benchmark.ts +171 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/dispatch.ts +473 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/generate-tests.ts +158 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/install-tool.ts +82 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/iterate.ts +265 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/orchestrator.ts +539 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/scaffold.ts +282 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/scripts/validate.ts +452 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/architecture/SKILL.md +95 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/fixer/SKILL.md +109 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/iteration/SKILL.md +89 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/prompt-engineering/SKILL.md +87 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/research/SKILL.md +94 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/testing/SKILL.md +89 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/tooling/SKILL.md +87 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/validation/SKILL.md +103 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/skills/worker/SKILL.md +79 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/00-meta/CONTEXT.md +6 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/00-meta/execution-log.md +27 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/01-input/CONTEXT.md +29 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/02-process/CONTEXT.md +29 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/03-output/CONTEXT.md +29 -0
- package/.agents/skills/workspace-maxxing/.workspace-templates/workspace/README.md +14 -0
- package/.agents/skills/workspace-maxxing/SKILL.md +312 -0
- package/.agents/skills/workspace-maxxing/scripts/benchmark.ts +171 -0
- package/.agents/skills/workspace-maxxing/scripts/dispatch.ts +473 -0
- package/.agents/skills/workspace-maxxing/scripts/generate-tests.ts +158 -0
- package/.agents/skills/workspace-maxxing/scripts/install-tool.ts +82 -0
- package/.agents/skills/workspace-maxxing/scripts/iterate.ts +265 -0
- package/.agents/skills/workspace-maxxing/scripts/orchestrator.ts +539 -0
- package/.agents/skills/workspace-maxxing/scripts/scaffold.ts +282 -0
- package/.agents/skills/workspace-maxxing/scripts/validate.ts +452 -0
- package/README.md +144 -0
- package/dist/agent-creator.d.ts +9 -0
- package/dist/agent-creator.d.ts.map +1 -0
- package/dist/agent-creator.js +199 -0
- package/dist/agent-creator.js.map +1 -0
- package/dist/agent-iterator.d.ts +38 -0
- package/dist/agent-iterator.d.ts.map +1 -0
- package/dist/agent-iterator.js +327 -0
- package/dist/agent-iterator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +18 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +117 -0
- package/dist/install.js.map +1 -0
- package/dist/platforms/claude.d.ts +7 -0
- package/dist/platforms/claude.d.ts.map +1 -0
- package/dist/platforms/claude.js +70 -0
- package/dist/platforms/claude.js.map +1 -0
- package/dist/platforms/copilot.d.ts +7 -0
- package/dist/platforms/copilot.d.ts.map +1 -0
- package/dist/platforms/copilot.js +75 -0
- package/dist/platforms/copilot.js.map +1 -0
- package/dist/platforms/gemini.d.ts +7 -0
- package/dist/platforms/gemini.d.ts.map +1 -0
- package/dist/platforms/gemini.js +81 -0
- package/dist/platforms/gemini.js.map +1 -0
- package/dist/platforms/index.d.ts +8 -0
- package/dist/platforms/index.d.ts.map +1 -0
- package/dist/platforms/index.js +41 -0
- package/dist/platforms/index.js.map +1 -0
- package/dist/platforms/opencode.d.ts +7 -0
- package/dist/platforms/opencode.d.ts.map +1 -0
- package/dist/platforms/opencode.js +70 -0
- package/dist/platforms/opencode.js.map +1 -0
- package/dist/scripts/benchmark.d.ts +20 -0
- package/dist/scripts/benchmark.d.ts.map +1 -0
- package/dist/scripts/benchmark.js +170 -0
- package/dist/scripts/benchmark.js.map +1 -0
- package/dist/scripts/dispatch.d.ts +32 -0
- package/dist/scripts/dispatch.d.ts.map +1 -0
- package/dist/scripts/dispatch.js +386 -0
- package/dist/scripts/dispatch.js.map +1 -0
- package/dist/scripts/generate-tests.d.ts +11 -0
- package/dist/scripts/generate-tests.d.ts.map +1 -0
- package/dist/scripts/generate-tests.js +118 -0
- package/dist/scripts/generate-tests.js.map +1 -0
- package/dist/scripts/install-tool.d.ts +8 -0
- package/dist/scripts/install-tool.d.ts.map +1 -0
- package/dist/scripts/install-tool.js +98 -0
- package/dist/scripts/install-tool.js.map +1 -0
- package/dist/scripts/iterate.d.ts +44 -0
- package/dist/scripts/iterate.d.ts.map +1 -0
- package/dist/scripts/iterate.js +260 -0
- package/dist/scripts/iterate.js.map +1 -0
- package/dist/scripts/orchestrator.d.ts +40 -0
- package/dist/scripts/orchestrator.d.ts.map +1 -0
- package/dist/scripts/orchestrator.js +378 -0
- package/dist/scripts/orchestrator.js.map +1 -0
- package/dist/scripts/scaffold.d.ts +8 -0
- package/dist/scripts/scaffold.d.ts.map +1 -0
- package/dist/scripts/scaffold.js +279 -0
- package/dist/scripts/scaffold.js.map +1 -0
- package/dist/scripts/validate.d.ts +11 -0
- package/dist/scripts/validate.d.ts.map +1 -0
- package/dist/scripts/validate.js +472 -0
- package/dist/scripts/validate.js.map +1 -0
- package/docs/superpowers/plans/2026-04-07-autonomous-iteration-plan.md +1123 -0
- package/docs/superpowers/plans/2026-04-07-autonomous-iteration-sub-agent-batches.md +1923 -0
- package/docs/superpowers/plans/2026-04-07-autonomous-workflow-sub-skill-plan.md +1505 -0
- package/docs/superpowers/plans/2026-04-07-benchmarking-multi-agent-plan.md +854 -0
- package/docs/superpowers/plans/2026-04-07-workspace-builder-logic-plan.md +1426 -0
- package/docs/superpowers/plans/2026-04-07-workspace-maxxing-plan.md +1299 -0
- package/docs/superpowers/plans/2026-04-08-session-294c-subagent-invocation-plan.md +320 -0
- package/docs/superpowers/plans/2026-04-08-workflow-prompt-hardening-plan.md +1025 -0
- package/docs/superpowers/plans/2026-04-12-workspace-agent-creation-plan.md +992 -0
- package/docs/superpowers/specs/2026-04-07-autonomous-iteration-design.md +214 -0
- package/docs/superpowers/specs/2026-04-07-autonomous-iteration-sub-agent-batches-design.md +188 -0
- package/docs/superpowers/specs/2026-04-07-autonomous-workflow-sub-skill-design.md +137 -0
- package/docs/superpowers/specs/2026-04-07-benchmarking-multi-agent-design.md +105 -0
- package/docs/superpowers/specs/2026-04-07-workspace-builder-logic-design.md +179 -0
- package/docs/superpowers/specs/2026-04-07-workspace-maxxing-design.md +227 -0
- package/docs/superpowers/specs/2026-04-08-session-294c-subagent-invocation-design.md +265 -0
- package/docs/superpowers/specs/2026-04-08-workflow-prompt-hardening-design.md +146 -0
- package/docs/superpowers/specs/2026-04-12-workspace-agent-creation-design.md +239 -0
- package/jest.config.js +8 -0
- package/package.json +32 -0
- package/src/agent-creator.ts +180 -0
- package/src/agent-iterator.ts +397 -0
- package/src/index.ts +189 -0
- package/src/install.ts +105 -0
- package/src/platforms/claude.ts +40 -0
- package/src/platforms/copilot.ts +50 -0
- package/src/platforms/gemini.ts +55 -0
- package/src/platforms/index.ts +45 -0
- package/src/platforms/opencode.ts +41 -0
- package/src/scripts/benchmark.ts +171 -0
- package/src/scripts/dispatch.ts +473 -0
- package/src/scripts/generate-tests.ts +112 -0
- package/src/scripts/install-tool.ts +82 -0
- package/src/scripts/iterate.ts +271 -0
- package/src/scripts/orchestrator.ts +539 -0
- package/src/scripts/scaffold.ts +282 -0
- package/src/scripts/validate.ts +516 -0
- package/templates/.workspace-templates/CONTEXT.md +44 -0
- package/templates/.workspace-templates/SYSTEM.md +44 -0
- package/templates/.workspace-templates/references/anti-patterns.md +16 -0
- package/templates/.workspace-templates/references/iron-laws.md +26 -0
- package/templates/.workspace-templates/references/reporting-format.md +52 -0
- package/templates/.workspace-templates/scripts/benchmark.ts +171 -0
- package/templates/.workspace-templates/scripts/dispatch.ts +473 -0
- package/templates/.workspace-templates/scripts/generate-tests.ts +158 -0
- package/templates/.workspace-templates/scripts/install-tool.ts +82 -0
- package/templates/.workspace-templates/scripts/iterate.ts +265 -0
- package/templates/.workspace-templates/scripts/orchestrator.ts +539 -0
- package/templates/.workspace-templates/scripts/scaffold.ts +282 -0
- package/templates/.workspace-templates/scripts/validate.ts +452 -0
- package/templates/.workspace-templates/skills/architecture/SKILL.md +95 -0
- package/templates/.workspace-templates/skills/fixer/SKILL.md +109 -0
- package/templates/.workspace-templates/skills/iteration/SKILL.md +89 -0
- package/templates/.workspace-templates/skills/prompt-engineering/SKILL.md +87 -0
- package/templates/.workspace-templates/skills/research/SKILL.md +94 -0
- package/templates/.workspace-templates/skills/testing/SKILL.md +89 -0
- package/templates/.workspace-templates/skills/tooling/SKILL.md +87 -0
- package/templates/.workspace-templates/skills/validation/SKILL.md +103 -0
- package/templates/.workspace-templates/skills/worker/SKILL.md +79 -0
- package/templates/.workspace-templates/workspace/00-meta/CONTEXT.md +6 -0
- package/templates/.workspace-templates/workspace/00-meta/execution-log.md +27 -0
- package/templates/.workspace-templates/workspace/01-input/CONTEXT.md +29 -0
- package/templates/.workspace-templates/workspace/02-process/CONTEXT.md +29 -0
- package/templates/.workspace-templates/workspace/03-output/CONTEXT.md +29 -0
- package/templates/.workspace-templates/workspace/README.md +14 -0
- package/templates/SKILL.md +347 -0
- package/tests/benchmark.test.ts +158 -0
- package/tests/cli.test.ts +109 -0
- package/tests/dispatch-parallel.test.ts +124 -0
- package/tests/dispatch.test.ts +218 -0
- package/tests/fixer-skill.test.ts +203 -0
- package/tests/generate-tests.test.ts +101 -0
- package/tests/install-tool.test.ts +141 -0
- package/tests/install.test.ts +144 -0
- package/tests/integration.test.ts +324 -0
- package/tests/iterate.test.ts +219 -0
- package/tests/orchestrator.test.ts +710 -0
- package/tests/scaffold.test.ts +238 -0
- package/tests/templates-enhanced.test.ts +208 -0
- package/tests/templates.test.ts +219 -0
- package/tests/validate.test.ts +421 -0
- package/tests/validation-enhanced.test.ts +303 -0
- package/tests/worker-skill.test.ts +88 -0
- package/tsconfig.json +19 -0
- package/workspace/00-meta/CONTEXT.md +3 -0
- package/workspace/00-meta/execution-log.md +17 -0
- package/workspace/00-meta/tools.md +11 -0
- package/workspace/01-input/CONTEXT.md +27 -0
- package/workspace/CONTEXT.md +35 -0
- package/workspace/README.md +14 -0
- package/workspace/SYSTEM.md +36 -0
- package/workspace-maxxing-0.1.0.tgz +0 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export interface AgentIterationOptions {
|
|
5
|
+
agentPath: string;
|
|
6
|
+
workspacePath: string;
|
|
7
|
+
threshold?: number;
|
|
8
|
+
maxIterations?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AgentIterationResult {
|
|
12
|
+
score: number;
|
|
13
|
+
iterations: number;
|
|
14
|
+
testCases: TestCaseResult[];
|
|
15
|
+
passed: boolean;
|
|
16
|
+
improvements: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TestCaseResult {
|
|
20
|
+
id: string;
|
|
21
|
+
input: string;
|
|
22
|
+
expected: string;
|
|
23
|
+
output: string;
|
|
24
|
+
passed: boolean;
|
|
25
|
+
issues: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AgentConfig {
|
|
29
|
+
name: string;
|
|
30
|
+
purpose: string;
|
|
31
|
+
platforms: string[];
|
|
32
|
+
robustnessThreshold: number;
|
|
33
|
+
iterationCount: number;
|
|
34
|
+
lastScore?: number;
|
|
35
|
+
testCases: TestCaseRecord[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface TestCaseRecord {
|
|
39
|
+
id: string;
|
|
40
|
+
input: string;
|
|
41
|
+
expected: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function iterateAgent(options: AgentIterationOptions): Promise<AgentIterationResult> {
|
|
45
|
+
const {
|
|
46
|
+
agentPath,
|
|
47
|
+
workspacePath,
|
|
48
|
+
threshold = 85,
|
|
49
|
+
maxIterations = 3,
|
|
50
|
+
} = options;
|
|
51
|
+
|
|
52
|
+
console.log(`\n=== Agent Self-Improvement Loop ===`);
|
|
53
|
+
console.log(`Agent: ${path.basename(agentPath)}`);
|
|
54
|
+
console.log(`Threshold: ${threshold}`);
|
|
55
|
+
console.log(`Max iterations: ${maxIterations}`);
|
|
56
|
+
console.log('');
|
|
57
|
+
|
|
58
|
+
const testCasesDir = path.join(agentPath, 'tests');
|
|
59
|
+
|
|
60
|
+
// Ensure tests directory exists
|
|
61
|
+
if (!fs.existsSync(testCasesDir)) {
|
|
62
|
+
fs.mkdirSync(testCasesDir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Load or generate test cases
|
|
66
|
+
const testCases = loadOrGenerateTestCases(testCasesDir, agentPath);
|
|
67
|
+
|
|
68
|
+
console.log(`Loaded ${testCases.length} test cases\n`);
|
|
69
|
+
|
|
70
|
+
const improvements: string[] = [];
|
|
71
|
+
let currentScore = 0;
|
|
72
|
+
|
|
73
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
74
|
+
console.log(`--- Iteration ${iteration + 1}/${maxIterations} ---`);
|
|
75
|
+
|
|
76
|
+
// Run each test case
|
|
77
|
+
const results = await runTestCases(testCases, agentPath, workspacePath);
|
|
78
|
+
|
|
79
|
+
// Calculate score
|
|
80
|
+
const passedCount = results.filter(r => r.passed).length;
|
|
81
|
+
currentScore = Math.round((passedCount / results.length) * 100);
|
|
82
|
+
|
|
83
|
+
console.log(`Results: ${passedCount}/${results.length} passed (${currentScore}%)`);
|
|
84
|
+
|
|
85
|
+
// Log issues for failed tests
|
|
86
|
+
for (const result of results) {
|
|
87
|
+
if (!result.passed) {
|
|
88
|
+
console.log(` - ${result.id}: ${result.issues.join(', ')}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (currentScore >= threshold) {
|
|
93
|
+
console.log(`\n✓ Threshold met (${currentScore} >= ${threshold})! Stopping iteration.`);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Identify issues and attempt improvement
|
|
98
|
+
const allIssues = results.flatMap(r => r.issues);
|
|
99
|
+
|
|
100
|
+
if (allIssues.length > 0 && iteration < maxIterations - 1) {
|
|
101
|
+
const improvement = await improveAgent(agentPath, allIssues, iteration + 1);
|
|
102
|
+
if (improvement) {
|
|
103
|
+
improvements.push(improvement);
|
|
104
|
+
console.log(`Improvement applied: ${improvement}\n`);
|
|
105
|
+
}
|
|
106
|
+
} else if (iteration === maxIterations - 1) {
|
|
107
|
+
console.log(`\n✗ Max iterations reached. Score: ${currentScore}/${threshold}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Update config with iteration count
|
|
112
|
+
updateIterationConfig(agentPath, improvements.length, currentScore);
|
|
113
|
+
|
|
114
|
+
console.log(`\n=== Iteration Complete ===`);
|
|
115
|
+
console.log(`Final score: ${currentScore}`);
|
|
116
|
+
console.log(`Iterations: ${improvements.length}`);
|
|
117
|
+
console.log(`Passed: ${currentScore >= threshold ? 'Yes' : 'No'}\n`);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
score: currentScore,
|
|
121
|
+
iterations: improvements.length,
|
|
122
|
+
testCases: [], // Could return detailed results if needed
|
|
123
|
+
passed: currentScore >= threshold,
|
|
124
|
+
improvements,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function loadOrGenerateTestCases(testsDir: string, agentPath: string): TestCaseRecord[] {
|
|
129
|
+
const casesPath = path.join(testsDir, 'cases.json');
|
|
130
|
+
|
|
131
|
+
// Try to load existing test cases
|
|
132
|
+
if (fs.existsSync(casesPath)) {
|
|
133
|
+
try {
|
|
134
|
+
const loaded = JSON.parse(fs.readFileSync(casesPath, 'utf-8'));
|
|
135
|
+
if (Array.isArray(loaded) && loaded.length > 0) {
|
|
136
|
+
return loaded as TestCaseRecord[];
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
// Fall through to generation
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Generate default test cases based on agent purpose
|
|
144
|
+
const config = loadAgentConfig(agentPath);
|
|
145
|
+
const testCases = generateDefaultTestCases(config.purpose);
|
|
146
|
+
|
|
147
|
+
// Save generated test cases
|
|
148
|
+
fs.writeFileSync(casesPath, JSON.stringify(testCases, null, 2));
|
|
149
|
+
|
|
150
|
+
return testCases;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function loadAgentConfig(agentPath: string): AgentConfig {
|
|
154
|
+
const configPath = path.join(agentPath, 'config.json');
|
|
155
|
+
|
|
156
|
+
if (fs.existsSync(configPath)) {
|
|
157
|
+
try {
|
|
158
|
+
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
159
|
+
} catch {
|
|
160
|
+
// Fall through to defaults
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
name: path.basename(agentPath),
|
|
166
|
+
purpose: 'Execute workflow tasks',
|
|
167
|
+
platforms: ['opencode'],
|
|
168
|
+
robustnessThreshold: 85,
|
|
169
|
+
iterationCount: 0,
|
|
170
|
+
testCases: [],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function generateDefaultTestCases(purpose: string): TestCaseRecord[] {
|
|
175
|
+
// Generate edge case, empty, and varied test cases
|
|
176
|
+
return [
|
|
177
|
+
{
|
|
178
|
+
id: 'tc-edge-001',
|
|
179
|
+
input: 'complex input with special characters !@#$%^&*()',
|
|
180
|
+
expected: 'valid output with proper handling',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: 'tc-empty-001',
|
|
184
|
+
input: '',
|
|
185
|
+
expected: 'graceful handling of empty input',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'tc-normal-001',
|
|
189
|
+
input: 'standard workflow request',
|
|
190
|
+
expected: 'proper response with required sections',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: 'tc-edge-002',
|
|
194
|
+
input: 'a', // Single character
|
|
195
|
+
expected: 'handle minimal input',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: 'tc-edge-003',
|
|
199
|
+
input: 'very long input '.repeat(100), // Very long input
|
|
200
|
+
expected: 'handle large input gracefully',
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function runTestCases(
|
|
206
|
+
testCases: TestCaseRecord[],
|
|
207
|
+
agentPath: string,
|
|
208
|
+
workspacePath: string
|
|
209
|
+
): Promise<TestCaseResult[]> {
|
|
210
|
+
const results: TestCaseResult[] = [];
|
|
211
|
+
|
|
212
|
+
for (const tc of testCases) {
|
|
213
|
+
const result = await runSingleTestCase(tc, agentPath, workspacePath);
|
|
214
|
+
results.push(result);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return results;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function runSingleTestCase(
|
|
221
|
+
tc: TestCaseRecord,
|
|
222
|
+
agentPath: string,
|
|
223
|
+
workspacePath: string
|
|
224
|
+
): Promise<TestCaseResult> {
|
|
225
|
+
// Load agent prompts
|
|
226
|
+
const systemPromptPath = path.join(agentPath, 'prompts', 'system.md');
|
|
227
|
+
const config = loadAgentConfig(agentPath);
|
|
228
|
+
|
|
229
|
+
let passed = true;
|
|
230
|
+
const issues: string[] = [];
|
|
231
|
+
|
|
232
|
+
// Simulate validation based on test case characteristics
|
|
233
|
+
// In a real implementation, this would actually execute the agent
|
|
234
|
+
|
|
235
|
+
// Check: Empty input handling
|
|
236
|
+
if (tc.input === '') {
|
|
237
|
+
const systemPrompt = fs.existsSync(systemPromptPath)
|
|
238
|
+
? fs.readFileSync(systemPromptPath, 'utf-8')
|
|
239
|
+
: '';
|
|
240
|
+
|
|
241
|
+
if (!systemPrompt.toLowerCase().includes('empty') &&
|
|
242
|
+
!systemPrompt.toLowerCase().includes('handle')) {
|
|
243
|
+
passed = false;
|
|
244
|
+
issues.push('No empty input handling in system prompt');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Check: Long input handling
|
|
249
|
+
if (tc.input.length > 500) {
|
|
250
|
+
const systemPrompt = fs.existsSync(systemPromptPath)
|
|
251
|
+
? fs.readFileSync(systemPromptPath, 'utf-8')
|
|
252
|
+
: '';
|
|
253
|
+
|
|
254
|
+
if (!systemPrompt.toLowerCase().includes('large') &&
|
|
255
|
+
!systemPrompt.toLowerCase().includes('long')) {
|
|
256
|
+
passed = false;
|
|
257
|
+
issues.push('No large input handling in system prompt');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Check: Special characters handling
|
|
262
|
+
if (/[!@#$%^&*()]/.test(tc.input)) {
|
|
263
|
+
const taskPromptPath = path.join(agentPath, 'prompts', 'tasks', 'default.md');
|
|
264
|
+
const taskPrompt = fs.existsSync(taskPromptPath)
|
|
265
|
+
? fs.readFileSync(taskPromptPath, 'utf-8')
|
|
266
|
+
: '';
|
|
267
|
+
|
|
268
|
+
if (!taskPrompt.toLowerCase().includes('special') &&
|
|
269
|
+
!taskPrompt.toLowerCase().includes('character')) {
|
|
270
|
+
// Not a critical issue, just a note
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Check: Configuration completeness
|
|
275
|
+
if (!config.purpose || config.purpose.length < 10) {
|
|
276
|
+
passed = false;
|
|
277
|
+
issues.push('Agent purpose not properly configured');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Check: Required files exist
|
|
281
|
+
if (!fs.existsSync(systemPromptPath)) {
|
|
282
|
+
passed = false;
|
|
283
|
+
issues.push('Missing system prompt file');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
id: tc.id,
|
|
288
|
+
input: tc.input,
|
|
289
|
+
expected: tc.expected,
|
|
290
|
+
output: passed ? 'validated' : 'issues found',
|
|
291
|
+
passed,
|
|
292
|
+
issues,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async function improveAgent(
|
|
297
|
+
agentPath: string,
|
|
298
|
+
issues: string[],
|
|
299
|
+
iteration: number
|
|
300
|
+
): Promise<string | null> {
|
|
301
|
+
const promptsDir = path.join(agentPath, 'prompts');
|
|
302
|
+
const systemPromptPath = path.join(promptsDir, 'system.md');
|
|
303
|
+
|
|
304
|
+
if (!fs.existsSync(systemPromptPath)) {
|
|
305
|
+
// Create prompts directory and system prompt if missing
|
|
306
|
+
fs.mkdirSync(promptsDir, { recursive: true });
|
|
307
|
+
const config = loadAgentConfig(agentPath);
|
|
308
|
+
const systemPrompt = `# ${config.name} - System Prompt
|
|
309
|
+
|
|
310
|
+
## Role
|
|
311
|
+
You are ${config.name}, an autonomous workflow agent that executes the ${config.purpose} workflow.
|
|
312
|
+
|
|
313
|
+
## Workspace Context
|
|
314
|
+
- Read \`SYSTEM.md\` first for global rules
|
|
315
|
+
- Load root \`CONTEXT.md\` for routing
|
|
316
|
+
- Read relevant stage \`CONTEXT.md\` for specific instructions
|
|
317
|
+
|
|
318
|
+
## Workflow Execution
|
|
319
|
+
1. Understand the request
|
|
320
|
+
2. Load appropriate context
|
|
321
|
+
3. Execute the task
|
|
322
|
+
4. Produce output
|
|
323
|
+
5. Report progress
|
|
324
|
+
|
|
325
|
+
## Constraints
|
|
326
|
+
- Stay within workspace scope
|
|
327
|
+
- Follow ICM folder boundaries
|
|
328
|
+
- Produce markdown artifacts
|
|
329
|
+
`;
|
|
330
|
+
fs.writeFileSync(systemPromptPath, systemPrompt);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const currentContent = fs.readFileSync(systemPromptPath, 'utf-8');
|
|
334
|
+
|
|
335
|
+
// Add improvement note to system prompt
|
|
336
|
+
const improvementNote = `\n## Iteration ${iteration} Improvements
|
|
337
|
+
${issues.map(i => `- ${i}`).join('\n')}
|
|
338
|
+
|
|
339
|
+
### Added Constraints
|
|
340
|
+
- Handle empty inputs gracefully
|
|
341
|
+
- Handle large inputs efficiently
|
|
342
|
+
- Handle special characters properly
|
|
343
|
+
`;
|
|
344
|
+
|
|
345
|
+
const newContent = currentContent + improvementNote;
|
|
346
|
+
fs.writeFileSync(systemPromptPath, newContent);
|
|
347
|
+
|
|
348
|
+
return `Iteration ${iteration}: Added handling for ${issues.length} issue(s)`;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function updateIterationConfig(agentPath: string, iterations: number, score: number): void {
|
|
352
|
+
const configPath = path.join(agentPath, 'config.json');
|
|
353
|
+
if (fs.existsSync(configPath)) {
|
|
354
|
+
try {
|
|
355
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
356
|
+
config.iterationCount = iterations;
|
|
357
|
+
config.lastScore = score;
|
|
358
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
359
|
+
} catch {
|
|
360
|
+
// Best effort
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Entry point for CLI
|
|
366
|
+
if (require.main === module) {
|
|
367
|
+
const args = process.argv.slice(2);
|
|
368
|
+
|
|
369
|
+
const parseArg = (flag: string): string | undefined => {
|
|
370
|
+
const idx = args.indexOf(flag);
|
|
371
|
+
return idx !== -1 ? args[idx + 1] : undefined;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
const agentPath = parseArg('--agent-path');
|
|
375
|
+
const workspacePath = parseArg('--workspace-path') ?? process.cwd();
|
|
376
|
+
const threshold = parseArg('--threshold') ? parseInt(parseArg('--threshold')!, 10) : 85;
|
|
377
|
+
const maxIterations = parseArg('--max-iterations') ? parseInt(parseArg('--max-iterations')!, 10) : 3;
|
|
378
|
+
|
|
379
|
+
if (!agentPath) {
|
|
380
|
+
console.error('Usage: node agent-iterator.ts --agent-path <path> [--workspace-path <path>] [--threshold <n>] [--max-iterations <n>]');
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
iterateAgent({
|
|
385
|
+
agentPath,
|
|
386
|
+
workspacePath,
|
|
387
|
+
threshold,
|
|
388
|
+
maxIterations,
|
|
389
|
+
}).then((result) => {
|
|
390
|
+
console.log('\n=== Final Result ===');
|
|
391
|
+
console.log(JSON.stringify(result, null, 2));
|
|
392
|
+
process.exit(result.passed ? 0 : 1);
|
|
393
|
+
}).catch((error) => {
|
|
394
|
+
console.error('Error:', error);
|
|
395
|
+
process.exit(1);
|
|
396
|
+
});
|
|
397
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { detectProjectRoot, installSkill, AgentTarget } from './install';
|
|
5
|
+
import { scaffoldWorkspace } from './scripts/scaffold';
|
|
6
|
+
import { createAgent, generateAgentName, AgentOptions } from './agent-creator';
|
|
7
|
+
import { iterateAgent } from './agent-iterator';
|
|
8
|
+
import { detectPlatform, getPlatformInstaller } from './platforms';
|
|
9
|
+
|
|
10
|
+
function showHelp(): void {
|
|
11
|
+
console.log(`
|
|
12
|
+
workspace-maxxing — npx-installable skill for AI agents
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
npx workspace-maxxing [options]
|
|
16
|
+
|
|
17
|
+
Installation Options:
|
|
18
|
+
--opencode Install skill for OpenCode agents (default)
|
|
19
|
+
--claude Install skill for Claude Code agents
|
|
20
|
+
--copilot Install skill for GitHub Copilot agents
|
|
21
|
+
--gemini Install skill for Gemini CLI agents
|
|
22
|
+
|
|
23
|
+
Workspace Creation Options:
|
|
24
|
+
--create-workspace Create a new workspace with agent
|
|
25
|
+
--workspace-name <name> Name of the workspace (default: "My Workspace")
|
|
26
|
+
--stages <stages> Comma-separated stages (default: "01-input,02-process,03-output")
|
|
27
|
+
--output <path> Output directory (default: "./workspace")
|
|
28
|
+
--agent-name <name> Custom agent name (default: auto-generated from workspace name)
|
|
29
|
+
--no-agent Create workspace without the invokable agent
|
|
30
|
+
--threshold <n> Robustness threshold for agent (default: 85)
|
|
31
|
+
--max-iterations <n> Max agent iterations (default: 3)
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
# Install skill for OpenCode
|
|
35
|
+
npx workspace-maxxing --opencode
|
|
36
|
+
|
|
37
|
+
# Create workspace with agent
|
|
38
|
+
npx workspace-maxxing --create-workspace --workspace-name "Daily Digest" --stages "01-input,02-process,03-output"
|
|
39
|
+
|
|
40
|
+
# Create workspace in specific folder
|
|
41
|
+
npx workspace-maxxing --create-workspace --workspace-name "My Workflow" --output "./my-workspace"
|
|
42
|
+
|
|
43
|
+
# Create workspace without agent
|
|
44
|
+
npx workspace-maxxing --create-workspace --workspace-name "My Workflow" --no-agent
|
|
45
|
+
|
|
46
|
+
# Create workspace with custom agent name
|
|
47
|
+
npx workspace-maxxing --create-workspace --workspace-name "AI News" --agent-name "@news-agent"
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function extractOption(args: string[], option: string): string | undefined {
|
|
52
|
+
const idx = args.indexOf(option);
|
|
53
|
+
return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function hasFlag(args: string[], flag: string): boolean {
|
|
57
|
+
return args.includes(flag);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function createWorkspace(args: string[]): Promise<void> {
|
|
61
|
+
const workspaceName = extractOption(args, '--workspace-name') ?? 'My Workspace';
|
|
62
|
+
const stagesStr = extractOption(args, '--stages') ?? '01-input,02-process,03-output';
|
|
63
|
+
const stages = stagesStr.split(',').map(s => s.trim()).filter(Boolean);
|
|
64
|
+
|
|
65
|
+
const withAgent = !hasFlag(args, '--no-agent');
|
|
66
|
+
const agentNameOption = extractOption(args, '--agent-name');
|
|
67
|
+
const outputDir = extractOption(args, '--output')
|
|
68
|
+
? path.resolve(process.cwd(), extractOption(args, '--output')!)
|
|
69
|
+
: path.resolve(process.cwd(), 'workspace');
|
|
70
|
+
const threshold = extractOption(args, '--threshold') ? parseInt(extractOption(args, '--threshold')!, 10) : 85;
|
|
71
|
+
const maxIterations = extractOption(args, '--max-iterations') ? parseInt(extractOption(args, '--max-iterations')!, 10) : 3;
|
|
72
|
+
|
|
73
|
+
console.log('=== Workspace-Maxxing ===');
|
|
74
|
+
console.log(`Creating workspace: ${workspaceName}`);
|
|
75
|
+
console.log(`Stages: ${stages.join(', ')}`);
|
|
76
|
+
console.log(`Output: ${outputDir}`);
|
|
77
|
+
console.log(`With agent: ${withAgent}`);
|
|
78
|
+
console.log('');
|
|
79
|
+
|
|
80
|
+
// Step 1: Create workspace folder structure
|
|
81
|
+
console.log('Step 1: Creating workspace folder structure...');
|
|
82
|
+
scaffoldWorkspace({
|
|
83
|
+
name: workspaceName,
|
|
84
|
+
stages,
|
|
85
|
+
output: outputDir,
|
|
86
|
+
force: true,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Step 2: Create agent if enabled
|
|
90
|
+
if (withAgent) {
|
|
91
|
+
console.log('\nStep 2: Creating invokable agent...');
|
|
92
|
+
|
|
93
|
+
// Generate agent name from workspace name if not provided
|
|
94
|
+
const agentName = agentNameOption ?? generateAgentName(workspaceName);
|
|
95
|
+
|
|
96
|
+
const agentOptions: AgentOptions = {
|
|
97
|
+
name: agentName,
|
|
98
|
+
purpose: `Execute ${workspaceName} workflow`,
|
|
99
|
+
workspacePath: outputDir,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
createAgent(agentOptions);
|
|
103
|
+
|
|
104
|
+
// Step 3: Run agent self-improvement loop
|
|
105
|
+
console.log('\nStep 3: Running agent self-improvement...');
|
|
106
|
+
const agentDirName = agentName.startsWith('@') ? agentName.slice(1) : agentName;
|
|
107
|
+
const agentPath = path.join(outputDir, '.agents', 'skills', agentDirName);
|
|
108
|
+
|
|
109
|
+
const iterationResult = await iterateAgent({
|
|
110
|
+
agentPath,
|
|
111
|
+
workspacePath: outputDir,
|
|
112
|
+
threshold,
|
|
113
|
+
maxIterations,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Step 4: Install for detected platform
|
|
117
|
+
console.log('\nStep 4: Installing for platform...');
|
|
118
|
+
const platform = detectPlatform();
|
|
119
|
+
console.log(`Detected platform: ${platform}`);
|
|
120
|
+
|
|
121
|
+
const installer = getPlatformInstaller(platform);
|
|
122
|
+
installer.install(agentPath, outputDir);
|
|
123
|
+
|
|
124
|
+
console.log('\n=== Workspace Creation Complete ===');
|
|
125
|
+
console.log(`Workspace: ${outputDir}`);
|
|
126
|
+
console.log(`Agent: ${agentName}`);
|
|
127
|
+
console.log(`Score: ${iterationResult.score}/${threshold}`);
|
|
128
|
+
console.log(`Iterations: ${iterationResult.iterations}`);
|
|
129
|
+
console.log(`\nTo invoke the agent, use: @${agentName.slice(1)}`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log('\n=== Workspace Creation Complete ===');
|
|
132
|
+
console.log(`Workspace: ${outputDir}`);
|
|
133
|
+
console.log('(Agent creation disabled with --no-agent)');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function main(): Promise<void> {
|
|
138
|
+
const args = process.argv.slice(2);
|
|
139
|
+
|
|
140
|
+
if (args.length === 0 || args.includes('--help')) {
|
|
141
|
+
showHelp();
|
|
142
|
+
process.exit(0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Check for workspace creation
|
|
146
|
+
if (args.includes('--create-workspace')) {
|
|
147
|
+
await createWorkspace(args);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Check for install targets
|
|
152
|
+
const agentFlags: AgentTarget[] = ['opencode', 'claude', 'copilot', 'gemini'];
|
|
153
|
+
const detectedAgent = agentFlags.find((flag) => args.includes(`--${flag}`));
|
|
154
|
+
|
|
155
|
+
if (detectedAgent) {
|
|
156
|
+
const cwd = process.cwd();
|
|
157
|
+
const projectRoot = detectProjectRoot(cwd);
|
|
158
|
+
|
|
159
|
+
if (projectRoot !== cwd) {
|
|
160
|
+
console.log(`Detected project root: ${projectRoot}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const templatesDir =
|
|
164
|
+
process.env.WORKSPACE_MAXXING_TEMPLATES ??
|
|
165
|
+
path.join(__dirname, '..', 'templates');
|
|
166
|
+
|
|
167
|
+
console.log(`Installing workspace-maxxing skill for ${detectedAgent}...`);
|
|
168
|
+
const result = await installSkill(projectRoot, templatesDir, detectedAgent);
|
|
169
|
+
|
|
170
|
+
if (result.success) {
|
|
171
|
+
console.log(`Skill installed to: ${result.skillPath}`);
|
|
172
|
+
console.log(`Open a new ${detectedAgent} session and invoke the workspace-maxxing skill to get started.`);
|
|
173
|
+
} else {
|
|
174
|
+
console.error(`Installation failed: ${result.error}`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.error(`Unknown flag: ${args.find((a) => a.startsWith('--'))}`);
|
|
182
|
+
console.error('Run "npx workspace-maxxing --help" for usage.');
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
main().catch((error) => {
|
|
187
|
+
console.error(error);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
});
|
package/src/install.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export type AgentTarget = 'opencode' | 'claude' | 'copilot' | 'gemini' | undefined;
|
|
5
|
+
|
|
6
|
+
export interface InstallResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
skillPath: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AGENT_PATHS: Record<string, string> = {
|
|
13
|
+
opencode: '.agents/skills/workspace-maxxing',
|
|
14
|
+
claude: '.claude/skills',
|
|
15
|
+
copilot: '.github/copilot-instructions',
|
|
16
|
+
gemini: '.gemini/skills',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function getAgentTargetPath(projectRoot: string, agent: AgentTarget): string {
|
|
20
|
+
const relativePath = AGENT_PATHS[agent ?? 'opencode'];
|
|
21
|
+
return path.join(projectRoot, relativePath);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Walk up from startDir looking for package.json or .git directory.
|
|
26
|
+
* Returns the first parent containing a marker, or startDir if none found.
|
|
27
|
+
*/
|
|
28
|
+
export function detectProjectRoot(startDir: string): string {
|
|
29
|
+
let current = path.resolve(startDir);
|
|
30
|
+
const root = path.parse(current).root;
|
|
31
|
+
|
|
32
|
+
while (current !== root) {
|
|
33
|
+
const hasPackageJson = fs.existsSync(path.join(current, 'package.json'));
|
|
34
|
+
const hasGit = fs.existsSync(path.join(current, '.git'));
|
|
35
|
+
|
|
36
|
+
if (hasPackageJson || hasGit) {
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
current = path.dirname(current);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return startDir;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Recursively copy a directory, overwriting existing files.
|
|
48
|
+
*/
|
|
49
|
+
function copyDirSync(src: string, dest: string): void {
|
|
50
|
+
if (!fs.existsSync(src)) {
|
|
51
|
+
throw new Error(`Source directory not found: ${src}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
55
|
+
|
|
56
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
57
|
+
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
const srcPath = path.join(src, entry.name);
|
|
60
|
+
const destPath = path.join(dest, entry.name);
|
|
61
|
+
|
|
62
|
+
if (entry.isDirectory()) {
|
|
63
|
+
copyDirSync(srcPath, destPath);
|
|
64
|
+
} else {
|
|
65
|
+
fs.copyFileSync(srcPath, destPath);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Install the workspace-maxxing skill into a project.
|
|
72
|
+
* Copies SKILL.md, .workspace-templates/, and scripts/ to the agent-specific skill directory.
|
|
73
|
+
*/
|
|
74
|
+
export async function installSkill(
|
|
75
|
+
projectRoot: string,
|
|
76
|
+
templatesDir: string,
|
|
77
|
+
agent: AgentTarget = undefined,
|
|
78
|
+
): Promise<InstallResult> {
|
|
79
|
+
const skillDir = getAgentTargetPath(projectRoot, agent);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// Copy SKILL.md
|
|
83
|
+
const skillMdSrc = path.join(templatesDir, 'SKILL.md');
|
|
84
|
+
const skillMdDest = path.join(skillDir, 'SKILL.md');
|
|
85
|
+
fs.mkdirSync(path.dirname(skillMdDest), { recursive: true });
|
|
86
|
+
fs.copyFileSync(skillMdSrc, skillMdDest);
|
|
87
|
+
|
|
88
|
+
// Copy .workspace-templates/
|
|
89
|
+
const workspaceTemplatesSrc = path.join(templatesDir, '.workspace-templates');
|
|
90
|
+
const workspaceTemplatesDest = path.join(skillDir, '.workspace-templates');
|
|
91
|
+
copyDirSync(workspaceTemplatesSrc, workspaceTemplatesDest);
|
|
92
|
+
|
|
93
|
+
// Copy scripts to skill root for direct invocation
|
|
94
|
+
const scriptsSrc = path.join(templatesDir, '.workspace-templates', 'scripts');
|
|
95
|
+
if (fs.existsSync(scriptsSrc)) {
|
|
96
|
+
const scriptsDest = path.join(skillDir, 'scripts');
|
|
97
|
+
copyDirSync(scriptsSrc, scriptsDest);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return { success: true, skillPath: skillDir };
|
|
101
|
+
} catch (error) {
|
|
102
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
103
|
+
return { success: false, skillPath: skillDir, error: message };
|
|
104
|
+
}
|
|
105
|
+
}
|