vralphy 0.0.1
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/bin/vralphy.js +3 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +85 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +34 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/plan.d.ts +9 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +85 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/spec.d.ts +9 -0
- package/dist/commands/spec.d.ts.map +1 -0
- package/dist/commands/spec.js +109 -0
- package/dist/commands/spec.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agents.d.ts +32 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/agents.js +94 -0
- package/dist/lib/agents.js.map +1 -0
- package/dist/lib/config.d.ts +38 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +96 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/config.test.d.ts +2 -0
- package/dist/lib/config.test.d.ts.map +1 -0
- package/dist/lib/config.test.js +45 -0
- package/dist/lib/config.test.js.map +1 -0
- package/dist/lib/engines/base.d.ts +57 -0
- package/dist/lib/engines/base.d.ts.map +1 -0
- package/dist/lib/engines/base.js +18 -0
- package/dist/lib/engines/base.js.map +1 -0
- package/dist/lib/engines/base.test.d.ts +2 -0
- package/dist/lib/engines/base.test.d.ts.map +1 -0
- package/dist/lib/engines/base.test.js +28 -0
- package/dist/lib/engines/base.test.js.map +1 -0
- package/dist/lib/engines/claude.d.ts +11 -0
- package/dist/lib/engines/claude.d.ts.map +1 -0
- package/dist/lib/engines/claude.js +124 -0
- package/dist/lib/engines/claude.js.map +1 -0
- package/dist/lib/engines/index.d.ts +18 -0
- package/dist/lib/engines/index.d.ts.map +1 -0
- package/dist/lib/engines/index.js +37 -0
- package/dist/lib/engines/index.js.map +1 -0
- package/dist/lib/engines/opencode.d.ts +10 -0
- package/dist/lib/engines/opencode.d.ts.map +1 -0
- package/dist/lib/engines/opencode.js +71 -0
- package/dist/lib/engines/opencode.js.map +1 -0
- package/dist/lib/init.d.ts +8 -0
- package/dist/lib/init.d.ts.map +1 -0
- package/dist/lib/init.js +254 -0
- package/dist/lib/init.js.map +1 -0
- package/dist/lib/prompts.d.ts +34 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +130 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/skills.d.ts +32 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +119 -0
- package/dist/lib/skills.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Engine, ExecuteOptions, Chunk, EngineFlags } from './base.js';
|
|
2
|
+
export declare class OpenCodeEngine implements Engine {
|
|
3
|
+
readonly name = "opencode";
|
|
4
|
+
execute(prompt: string, options: ExecuteOptions): AsyncIterable<Chunk>;
|
|
5
|
+
isAvailable(): Promise<boolean>;
|
|
6
|
+
getFlags(options: EngineFlags): string[];
|
|
7
|
+
supportsInteractive(): boolean;
|
|
8
|
+
getCommand(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=opencode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../../src/lib/engines/opencode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAgB,MAAM,WAAW,CAAC;AAErF,qBAAa,cAAe,YAAW,MAAM;IAC3C,QAAQ,CAAC,IAAI,cAAc;IAEpB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC;IAuCvE,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAgBrC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE;IAkBxC,mBAAmB,IAAI,OAAO;IAI9B,UAAU,IAAI,MAAM;CAGrB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { resolveModel } from './base.js';
|
|
3
|
+
export class OpenCodeEngine {
|
|
4
|
+
name = 'opencode';
|
|
5
|
+
async *execute(prompt, options) {
|
|
6
|
+
const flags = this.getFlags({
|
|
7
|
+
model: options.model,
|
|
8
|
+
skipPermissions: options.skipPermissions,
|
|
9
|
+
outputFormat: options.outputFormat,
|
|
10
|
+
verbose: options.verbose,
|
|
11
|
+
});
|
|
12
|
+
const args = [...flags];
|
|
13
|
+
const child = spawn('opencode', args, {
|
|
14
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
15
|
+
});
|
|
16
|
+
child.stdin.write(prompt);
|
|
17
|
+
child.stdin.end();
|
|
18
|
+
for await (const data of child.stdout) {
|
|
19
|
+
yield { type: 'text', content: data.toString() };
|
|
20
|
+
}
|
|
21
|
+
let stderrOutput = '';
|
|
22
|
+
for await (const data of child.stderr) {
|
|
23
|
+
stderrOutput += data.toString();
|
|
24
|
+
}
|
|
25
|
+
await new Promise((resolve, reject) => {
|
|
26
|
+
child.on('close', (code) => {
|
|
27
|
+
if (code !== 0 && stderrOutput) {
|
|
28
|
+
reject(new Error(`OpenCode exited with code ${code}: ${stderrOutput}`));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
resolve();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
child.on('error', reject);
|
|
35
|
+
});
|
|
36
|
+
yield { type: 'done' };
|
|
37
|
+
}
|
|
38
|
+
async isAvailable() {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const child = spawn('opencode', ['--version'], {
|
|
41
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
42
|
+
});
|
|
43
|
+
child.on('close', (code) => {
|
|
44
|
+
resolve(code === 0);
|
|
45
|
+
});
|
|
46
|
+
child.on('error', () => {
|
|
47
|
+
resolve(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getFlags(options) {
|
|
52
|
+
const flags = [];
|
|
53
|
+
if (options.model) {
|
|
54
|
+
flags.push('--model', resolveModel(options.model));
|
|
55
|
+
}
|
|
56
|
+
if (options.skipPermissions) {
|
|
57
|
+
flags.push('--yes');
|
|
58
|
+
}
|
|
59
|
+
if (options.verbose) {
|
|
60
|
+
flags.push('--verbose');
|
|
61
|
+
}
|
|
62
|
+
return flags;
|
|
63
|
+
}
|
|
64
|
+
supportsInteractive() {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
getCommand() {
|
|
68
|
+
return 'opencode';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=opencode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../../src/lib/engines/opencode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAA8C,YAAY,EAAE,MAAM,WAAW,CAAC;AAErF,MAAM,OAAO,cAAc;IAChB,IAAI,GAAG,UAAU,CAAC;IAE3B,KAAK,CAAC,CAAC,OAAO,CAAC,MAAc,EAAE,OAAuB;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;QAEH,MAAM,I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E,CAAC,CA2EhH"}
|
package/dist/lib/init.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { DEFAULT_PLAN_PROMPT, DEFAULT_BUILD_PROMPT, DEFAULT_SPEC_PROMPT } from './prompts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Detect project info from package.json
|
|
7
|
+
*/
|
|
8
|
+
async function detectFromPackageJson(dir) {
|
|
9
|
+
const path = join(dir, 'package.json');
|
|
10
|
+
if (!existsSync(path))
|
|
11
|
+
return {};
|
|
12
|
+
try {
|
|
13
|
+
const content = await readFile(path, 'utf-8');
|
|
14
|
+
const pkg = JSON.parse(content);
|
|
15
|
+
const scripts = pkg.scripts ?? {};
|
|
16
|
+
return {
|
|
17
|
+
projectType: 'node',
|
|
18
|
+
buildCommand: scripts.build ? 'npm run build' : undefined,
|
|
19
|
+
testCommand: scripts.test ? 'npm test' : undefined,
|
|
20
|
+
lintCommand: scripts.lint ? 'npm run lint' : undefined,
|
|
21
|
+
typecheckCommand: scripts.typecheck ? 'npm run typecheck' : undefined,
|
|
22
|
+
devCommand: scripts.dev ? 'npm run dev' : undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Detect project info from Cargo.toml
|
|
31
|
+
*/
|
|
32
|
+
async function detectFromCargoToml(dir) {
|
|
33
|
+
const path = join(dir, 'Cargo.toml');
|
|
34
|
+
if (!existsSync(path))
|
|
35
|
+
return {};
|
|
36
|
+
return {
|
|
37
|
+
projectType: 'rust',
|
|
38
|
+
buildCommand: 'cargo build',
|
|
39
|
+
testCommand: 'cargo test',
|
|
40
|
+
lintCommand: 'cargo clippy',
|
|
41
|
+
typecheckCommand: 'cargo check',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Detect project info from go.mod
|
|
46
|
+
*/
|
|
47
|
+
async function detectFromGoMod(dir) {
|
|
48
|
+
const path = join(dir, 'go.mod');
|
|
49
|
+
if (!existsSync(path))
|
|
50
|
+
return {};
|
|
51
|
+
return {
|
|
52
|
+
projectType: 'go',
|
|
53
|
+
buildCommand: 'go build ./...',
|
|
54
|
+
testCommand: 'go test ./...',
|
|
55
|
+
lintCommand: 'golangci-lint run',
|
|
56
|
+
typecheckCommand: 'go vet ./...',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extract patterns from existing documentation
|
|
61
|
+
*/
|
|
62
|
+
async function extractFromDocs(dir) {
|
|
63
|
+
const patterns = [];
|
|
64
|
+
const docFiles = ['CLAUDE.md', 'claude.md', 'AGENTS.md', 'agents.md', 'README.md'];
|
|
65
|
+
for (const file of docFiles) {
|
|
66
|
+
const path = join(dir, file);
|
|
67
|
+
if (!existsSync(path))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const content = await readFile(path, 'utf-8');
|
|
71
|
+
const lines = content.split('\n');
|
|
72
|
+
for (const line of lines) {
|
|
73
|
+
if (line.startsWith('- ') && line.length < 150) {
|
|
74
|
+
const pattern = line.slice(2).trim();
|
|
75
|
+
if (pattern && !patterns.includes(pattern)) {
|
|
76
|
+
patterns.push(pattern);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (patterns.length >= 10)
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return patterns.slice(0, 10);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generate lightweight AGENTS.md (max ~60 lines)
|
|
91
|
+
*/
|
|
92
|
+
function generateAgentsMd(info) {
|
|
93
|
+
const lines = [];
|
|
94
|
+
lines.push('## Build & Run');
|
|
95
|
+
lines.push('');
|
|
96
|
+
if (info.buildCommand) {
|
|
97
|
+
lines.push(`- Build: \`${info.buildCommand}\``);
|
|
98
|
+
}
|
|
99
|
+
if (info.devCommand) {
|
|
100
|
+
lines.push(`- Dev: \`${info.devCommand}\``);
|
|
101
|
+
}
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push('## Validation');
|
|
104
|
+
lines.push('');
|
|
105
|
+
if (info.testCommand) {
|
|
106
|
+
lines.push(`- Tests: \`${info.testCommand}\``);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
lines.push('- Tests: [configure]');
|
|
110
|
+
}
|
|
111
|
+
if (info.typecheckCommand) {
|
|
112
|
+
lines.push(`- Typecheck: \`${info.typecheckCommand}\``);
|
|
113
|
+
}
|
|
114
|
+
if (info.lintCommand) {
|
|
115
|
+
lines.push(`- Lint: \`${info.lintCommand}\``);
|
|
116
|
+
}
|
|
117
|
+
if (info.patterns.length > 0) {
|
|
118
|
+
lines.push('');
|
|
119
|
+
lines.push('## Codebase Patterns');
|
|
120
|
+
lines.push('');
|
|
121
|
+
for (const pattern of info.patterns.slice(0, 5)) {
|
|
122
|
+
lines.push(`- ${pattern}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
lines.push('');
|
|
126
|
+
return lines.join('\n');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generate loop.sh script
|
|
130
|
+
*/
|
|
131
|
+
function generateLoopSh() {
|
|
132
|
+
return `#!/bin/bash
|
|
133
|
+
# Ralph methodology loop - orchestrates planning and building
|
|
134
|
+
|
|
135
|
+
set -e
|
|
136
|
+
|
|
137
|
+
if [ "$1" = "plan" ]; then
|
|
138
|
+
MODE="plan"
|
|
139
|
+
PROMPT_FILE="PROMPT_plan.md"
|
|
140
|
+
MAX_ITERATIONS=\${2:-0}
|
|
141
|
+
elif [[ "$1" =~ ^[0-9]+$ ]]; then
|
|
142
|
+
MODE="build"
|
|
143
|
+
PROMPT_FILE="PROMPT_build.md"
|
|
144
|
+
MAX_ITERATIONS=$1
|
|
145
|
+
else
|
|
146
|
+
MODE="build"
|
|
147
|
+
PROMPT_FILE="PROMPT_build.md"
|
|
148
|
+
MAX_ITERATIONS=0
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
ITERATION=0
|
|
152
|
+
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null || echo "main")
|
|
153
|
+
|
|
154
|
+
echo "Starting Ralph loop in $MODE mode"
|
|
155
|
+
echo "Prompt: $PROMPT_FILE"
|
|
156
|
+
echo "Max iterations: \${MAX_ITERATIONS:-unlimited}"
|
|
157
|
+
|
|
158
|
+
while true; do
|
|
159
|
+
if [ $MAX_ITERATIONS -gt 0 ] && [ $ITERATION -ge $MAX_ITERATIONS ]; then
|
|
160
|
+
echo "Reached max iterations ($MAX_ITERATIONS)"
|
|
161
|
+
break
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
echo "=== Iteration $((ITERATION + 1)) ==="
|
|
165
|
+
|
|
166
|
+
cat "$PROMPT_FILE" | claude -p \\
|
|
167
|
+
--dangerously-skip-permissions \\
|
|
168
|
+
--output-format=stream-json \\
|
|
169
|
+
--model opus \\
|
|
170
|
+
--verbose
|
|
171
|
+
|
|
172
|
+
git push origin "$CURRENT_BRANCH" 2>/dev/null || git push -u origin "$CURRENT_BRANCH" || true
|
|
173
|
+
|
|
174
|
+
ITERATION=$((ITERATION + 1))
|
|
175
|
+
done
|
|
176
|
+
|
|
177
|
+
echo "Loop complete after $ITERATION iterations"
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Initialize a project for vralphy
|
|
182
|
+
*/
|
|
183
|
+
export async function initProject(dir = process.cwd()) {
|
|
184
|
+
const created = [];
|
|
185
|
+
const skipped = [];
|
|
186
|
+
const info = {
|
|
187
|
+
patterns: [],
|
|
188
|
+
};
|
|
189
|
+
const [pkgInfo, cargoInfo, goInfo] = await Promise.all([
|
|
190
|
+
detectFromPackageJson(dir),
|
|
191
|
+
detectFromCargoToml(dir),
|
|
192
|
+
detectFromGoMod(dir),
|
|
193
|
+
]);
|
|
194
|
+
Object.assign(info, pkgInfo, cargoInfo, goInfo);
|
|
195
|
+
info.patterns = await extractFromDocs(dir);
|
|
196
|
+
const specsDir = join(dir, 'specs');
|
|
197
|
+
if (!existsSync(specsDir)) {
|
|
198
|
+
await mkdir(specsDir, { recursive: true });
|
|
199
|
+
created.push('specs/');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
skipped.push('specs/');
|
|
203
|
+
}
|
|
204
|
+
const agentsMd = join(dir, 'AGENTS.md');
|
|
205
|
+
if (!existsSync(agentsMd)) {
|
|
206
|
+
await writeFile(agentsMd, generateAgentsMd(info));
|
|
207
|
+
created.push('AGENTS.md');
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
skipped.push('AGENTS.md');
|
|
211
|
+
}
|
|
212
|
+
const planPrompt = join(dir, 'PROMPT_plan.md');
|
|
213
|
+
if (!existsSync(planPrompt)) {
|
|
214
|
+
await writeFile(planPrompt, DEFAULT_PLAN_PROMPT);
|
|
215
|
+
created.push('PROMPT_plan.md');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
skipped.push('PROMPT_plan.md');
|
|
219
|
+
}
|
|
220
|
+
const buildPrompt = join(dir, 'PROMPT_build.md');
|
|
221
|
+
if (!existsSync(buildPrompt)) {
|
|
222
|
+
await writeFile(buildPrompt, DEFAULT_BUILD_PROMPT);
|
|
223
|
+
created.push('PROMPT_build.md');
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
skipped.push('PROMPT_build.md');
|
|
227
|
+
}
|
|
228
|
+
const specPrompt = join(dir, 'PROMPT_spec.md');
|
|
229
|
+
if (!existsSync(specPrompt)) {
|
|
230
|
+
await writeFile(specPrompt, DEFAULT_SPEC_PROMPT);
|
|
231
|
+
created.push('PROMPT_spec.md');
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
skipped.push('PROMPT_spec.md');
|
|
235
|
+
}
|
|
236
|
+
const loopSh = join(dir, 'loop.sh');
|
|
237
|
+
if (!existsSync(loopSh)) {
|
|
238
|
+
await writeFile(loopSh, generateLoopSh(), { mode: 0o755 });
|
|
239
|
+
created.push('loop.sh');
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
skipped.push('loop.sh');
|
|
243
|
+
}
|
|
244
|
+
const implPlan = join(dir, 'IMPLEMENTATION_PLAN.md');
|
|
245
|
+
if (!existsSync(implPlan)) {
|
|
246
|
+
await writeFile(implPlan, '# Implementation Plan\n\n- [ ] Initial setup\n');
|
|
247
|
+
created.push('IMPLEMENTATION_PLAN.md');
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
skipped.push('IMPLEMENTATION_PLAN.md');
|
|
251
|
+
}
|
|
252
|
+
return { created, skipped };
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/lib/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAY9F;;GAEG;AACH,KAAK,UAAU,qBAAqB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9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AM,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;IACrD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,gDAAgD,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface PromptContext {
|
|
2
|
+
model: string;
|
|
3
|
+
executor: string;
|
|
4
|
+
projectName?: string;
|
|
5
|
+
existingSpecs?: string[];
|
|
6
|
+
skills?: string;
|
|
7
|
+
agents?: string;
|
|
8
|
+
topic?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Load a prompt template from file
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadPromptTemplate(path: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Interpolate variables in prompt template
|
|
16
|
+
*/
|
|
17
|
+
export declare function interpolatePrompt(template: string, context: PromptContext): string;
|
|
18
|
+
/**
|
|
19
|
+
* Load and interpolate prompt
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadPrompt(path: string, context: PromptContext): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Default plan mode prompt
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_PLAN_PROMPT = "0a. Study `specs/*` with up to 250 parallel ${executor} subagents to learn the project specifications.\n0b. Study @IMPLEMENTATION_PLAN.md (if present) to understand the plan so far.\n0c. Study `src/lib/*` with up to 250 parallel ${executor} subagents to understand shared utilities & components.\n0d. For reference, the application source code is in `src/*`.\n\n1. Study @IMPLEMENTATION_PLAN.md (if present; it may be incorrect) and use up to 500 ${executor} subagents to study existing source code in `src/*` and compare it against `specs/*`. Use an ${model} subagent to analyze findings, prioritize tasks, and create/update @IMPLEMENTATION_PLAN.md as a bullet point list sorted in priority of items yet to be implemented. Ultrathink. Consider searching for TODO, minimal implementations, placeholders, skipped/flaky tests, and inconsistent patterns. Study @IMPLEMENTATION_PLAN.md to determine starting point for research and keep it up to date with items considered complete/incomplete using subagents.\n\nIMPORTANT: Plan only. Do NOT implement anything. Do NOT assume functionality is missing; confirm with code search first. Treat `src/lib` as the project's standard library for shared utilities and components. Prefer consolidated, idiomatic implementations there over ad-hoc copies.\n";
|
|
26
|
+
/**
|
|
27
|
+
* Default build mode prompt
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_BUILD_PROMPT = "0a. Study `specs/*` with up to 500 parallel ${executor} subagents to learn the project specifications.\n0b. Study @IMPLEMENTATION_PLAN.md.\n0c. For reference, the application source code is in `src/*`.\n\n1. Your task is to implement functionality per the specifications using parallel subagents. Follow @IMPLEMENTATION_PLAN.md and choose the most important item to address. Before making changes, search the codebase (don't assume not implemented) using ${executor} subagents. You may use up to 500 parallel ${executor} subagents for searches/reads and only 1 ${executor} subagent for build/tests. Use ${model} subagents when complex reasoning is needed (debugging, architectural decisions).\n\n2. After implementing functionality or resolving problems, run the tests for that unit of code that was improved. If functionality is missing then it's your job to add it as per the application specifications. Ultrathink.\n\n3. When you discover issues, immediately update @IMPLEMENTATION_PLAN.md with your findings using a subagent. When resolved, update and remove the item.\n\n4. When the tests pass, update @IMPLEMENTATION_PLAN.md, then `git add -A` then `git commit` with a message describing the changes. After the commit, `git push`.\n\n99999. When authoring documentation, capture the why \u2014 tests and implementation importance.\n999999. Single sources of truth, no migrations/adapters. If tests unrelated to your work fail, resolve them as part of the increment.\n9999999. As soon as there are no build or test errors create a git tag. If there are no git tags start at 0.0.0 and increment patch by 1.\n99999999. You may add extra logging if required to debug issues.\n999999999. Keep @IMPLEMENTATION_PLAN.md current with learnings using a subagent \u2014 future work depends on this.\n9999999999. When you learn something new about how to run the application, update @AGENTS.md using a subagent but keep it brief.\n99999999999. For any bugs you notice, resolve them or document them in @IMPLEMENTATION_PLAN.md even if unrelated to current work.\n999999999999. Implement functionality completely. Placeholders and stubs waste efforts and time redoing the same work.\n9999999999999. When @IMPLEMENTATION_PLAN.md becomes large periodically clean out the items that are completed using a subagent.\n99999999999999. IMPORTANT: Keep @AGENTS.md operational only \u2014 status updates belong in `IMPLEMENTATION_PLAN.md`. A bloated AGENTS.md pollutes every future loop's context.\n";
|
|
30
|
+
/**
|
|
31
|
+
* Default spec mode prompt
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_SPEC_PROMPT = "You are helping define requirements for: ${topic}\n\n## Context\n- Project: ${projectName}\n- Existing specs: ${existingSpecs}\n\n## Your Task\n\n1. Ask clarifying questions to understand the requirement fully\n2. Consider edge cases and constraints\n3. Draft a complete specification\n4. Present for user approval\n\n## Question Guidelines\n\nAsk about:\n- User personas and use cases\n- Happy path and error cases\n- Integration points\n- Performance requirements\n- Security considerations\n\n## Output Format\n\nWhen ready, output the spec in this format:\n\n# ${topic}\n\n## Overview\n[Brief description]\n\n## Requirements\n- [ ] Requirement 1\n- [ ] Requirement 2\n\n## Acceptance Criteria\n- [ ] Criterion 1\n- [ ] Criterion 2\n\n## Edge Cases\n[List edge cases]\n\n## Dependencies\n[List dependencies]\n";
|
|
34
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CA4BlF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtF;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,+wCAQ/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,u7EAsBhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,izBA4C/B,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
/**
|
|
4
|
+
* Load a prompt template from file
|
|
5
|
+
*/
|
|
6
|
+
export async function loadPromptTemplate(path) {
|
|
7
|
+
if (!existsSync(path)) {
|
|
8
|
+
throw new Error(`Prompt template not found: ${path}`);
|
|
9
|
+
}
|
|
10
|
+
return readFile(path, 'utf-8');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interpolate variables in prompt template
|
|
14
|
+
*/
|
|
15
|
+
export function interpolatePrompt(template, context) {
|
|
16
|
+
let result = template;
|
|
17
|
+
result = result.replace(/\$\{model\}/g, context.model);
|
|
18
|
+
result = result.replace(/\$\{executor\}/g, context.executor);
|
|
19
|
+
result = result.replace(/\$\{primary\}/g, context.model);
|
|
20
|
+
if (context.projectName) {
|
|
21
|
+
result = result.replace(/\$\{projectName\}/g, context.projectName);
|
|
22
|
+
}
|
|
23
|
+
if (context.existingSpecs) {
|
|
24
|
+
result = result.replace(/\$\{existingSpecs\}/g, context.existingSpecs.join(', ') || 'none');
|
|
25
|
+
}
|
|
26
|
+
if (context.skills) {
|
|
27
|
+
result = result.replace(/\$\{skills\}/g, context.skills);
|
|
28
|
+
}
|
|
29
|
+
if (context.agents) {
|
|
30
|
+
result = result.replace(/\$\{agents\}/g, context.agents);
|
|
31
|
+
}
|
|
32
|
+
if (context.topic) {
|
|
33
|
+
result = result.replace(/\$\{topic\}/g, context.topic);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load and interpolate prompt
|
|
39
|
+
*/
|
|
40
|
+
export async function loadPrompt(path, context) {
|
|
41
|
+
const template = await loadPromptTemplate(path);
|
|
42
|
+
return interpolatePrompt(template, context);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Default plan mode prompt
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_PLAN_PROMPT = `0a. Study \`specs/*\` with up to 250 parallel \${executor} subagents to learn the project specifications.
|
|
48
|
+
0b. Study @IMPLEMENTATION_PLAN.md (if present) to understand the plan so far.
|
|
49
|
+
0c. Study \`src/lib/*\` with up to 250 parallel \${executor} subagents to understand shared utilities & components.
|
|
50
|
+
0d. For reference, the application source code is in \`src/*\`.
|
|
51
|
+
|
|
52
|
+
1. Study @IMPLEMENTATION_PLAN.md (if present; it may be incorrect) and use up to 500 \${executor} subagents to study existing source code in \`src/*\` and compare it against \`specs/*\`. Use an \${model} subagent to analyze findings, prioritize tasks, and create/update @IMPLEMENTATION_PLAN.md as a bullet point list sorted in priority of items yet to be implemented. Ultrathink. Consider searching for TODO, minimal implementations, placeholders, skipped/flaky tests, and inconsistent patterns. Study @IMPLEMENTATION_PLAN.md to determine starting point for research and keep it up to date with items considered complete/incomplete using subagents.
|
|
53
|
+
|
|
54
|
+
IMPORTANT: Plan only. Do NOT implement anything. Do NOT assume functionality is missing; confirm with code search first. Treat \`src/lib\` as the project's standard library for shared utilities and components. Prefer consolidated, idiomatic implementations there over ad-hoc copies.
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* Default build mode prompt
|
|
58
|
+
*/
|
|
59
|
+
export const DEFAULT_BUILD_PROMPT = `0a. Study \`specs/*\` with up to 500 parallel \${executor} subagents to learn the project specifications.
|
|
60
|
+
0b. Study @IMPLEMENTATION_PLAN.md.
|
|
61
|
+
0c. For reference, the application source code is in \`src/*\`.
|
|
62
|
+
|
|
63
|
+
1. Your task is to implement functionality per the specifications using parallel subagents. Follow @IMPLEMENTATION_PLAN.md and choose the most important item to address. Before making changes, search the codebase (don't assume not implemented) using \${executor} subagents. You may use up to 500 parallel \${executor} subagents for searches/reads and only 1 \${executor} subagent for build/tests. Use \${model} subagents when complex reasoning is needed (debugging, architectural decisions).
|
|
64
|
+
|
|
65
|
+
2. After implementing functionality or resolving problems, run the tests for that unit of code that was improved. If functionality is missing then it's your job to add it as per the application specifications. Ultrathink.
|
|
66
|
+
|
|
67
|
+
3. When you discover issues, immediately update @IMPLEMENTATION_PLAN.md with your findings using a subagent. When resolved, update and remove the item.
|
|
68
|
+
|
|
69
|
+
4. When the tests pass, update @IMPLEMENTATION_PLAN.md, then \`git add -A\` then \`git commit\` with a message describing the changes. After the commit, \`git push\`.
|
|
70
|
+
|
|
71
|
+
99999. When authoring documentation, capture the why — tests and implementation importance.
|
|
72
|
+
999999. Single sources of truth, no migrations/adapters. If tests unrelated to your work fail, resolve them as part of the increment.
|
|
73
|
+
9999999. As soon as there are no build or test errors create a git tag. If there are no git tags start at 0.0.0 and increment patch by 1.
|
|
74
|
+
99999999. You may add extra logging if required to debug issues.
|
|
75
|
+
999999999. Keep @IMPLEMENTATION_PLAN.md current with learnings using a subagent — future work depends on this.
|
|
76
|
+
9999999999. When you learn something new about how to run the application, update @AGENTS.md using a subagent but keep it brief.
|
|
77
|
+
99999999999. For any bugs you notice, resolve them or document them in @IMPLEMENTATION_PLAN.md even if unrelated to current work.
|
|
78
|
+
999999999999. Implement functionality completely. Placeholders and stubs waste efforts and time redoing the same work.
|
|
79
|
+
9999999999999. When @IMPLEMENTATION_PLAN.md becomes large periodically clean out the items that are completed using a subagent.
|
|
80
|
+
99999999999999. IMPORTANT: Keep @AGENTS.md operational only — status updates belong in \`IMPLEMENTATION_PLAN.md\`. A bloated AGENTS.md pollutes every future loop's context.
|
|
81
|
+
`;
|
|
82
|
+
/**
|
|
83
|
+
* Default spec mode prompt
|
|
84
|
+
*/
|
|
85
|
+
export const DEFAULT_SPEC_PROMPT = `You are helping define requirements for: \${topic}
|
|
86
|
+
|
|
87
|
+
## Context
|
|
88
|
+
- Project: \${projectName}
|
|
89
|
+
- Existing specs: \${existingSpecs}
|
|
90
|
+
|
|
91
|
+
## Your Task
|
|
92
|
+
|
|
93
|
+
1. Ask clarifying questions to understand the requirement fully
|
|
94
|
+
2. Consider edge cases and constraints
|
|
95
|
+
3. Draft a complete specification
|
|
96
|
+
4. Present for user approval
|
|
97
|
+
|
|
98
|
+
## Question Guidelines
|
|
99
|
+
|
|
100
|
+
Ask about:
|
|
101
|
+
- User personas and use cases
|
|
102
|
+
- Happy path and error cases
|
|
103
|
+
- Integration points
|
|
104
|
+
- Performance requirements
|
|
105
|
+
- Security considerations
|
|
106
|
+
|
|
107
|
+
## Output Format
|
|
108
|
+
|
|
109
|
+
When ready, output the spec in this format:
|
|
110
|
+
|
|
111
|
+
# \${topic}
|
|
112
|
+
|
|
113
|
+
## Overview
|
|
114
|
+
[Brief description]
|
|
115
|
+
|
|
116
|
+
## Requirements
|
|
117
|
+
- [ ] Requirement 1
|
|
118
|
+
- [ ] Requirement 2
|
|
119
|
+
|
|
120
|
+
## Acceptance Criteria
|
|
121
|
+
- [ ] Criterion 1
|
|
122
|
+
- [ ] Criterion 2
|
|
123
|
+
|
|
124
|
+
## Edge Cases
|
|
125
|
+
[List edge cases]
|
|
126
|
+
|
|
127
|
+
## Dependencies
|
|
128
|
+
[List dependencies]
|
|
129
|
+
`;
|
|
130
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAYhC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,OAAsB;IACxE,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IA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F;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4ClC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface SkillMetadata {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
triggers?: string[];
|
|
5
|
+
alwaysInclude?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface Skill {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
metadata: SkillMetadata;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Load all skills from a directory
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadSkills(dir: string): Promise<Skill[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Filter skills by triggers matching text
|
|
19
|
+
*/
|
|
20
|
+
export declare function filterSkillsByTriggers(skills: Skill[], text: string): Skill[];
|
|
21
|
+
/**
|
|
22
|
+
* Format skills for prompt injection
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatSkillsForPrompt(skills: Skill[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* List available skills (for CLI command)
|
|
27
|
+
*/
|
|
28
|
+
export declare function listSkills(dir: string): Promise<{
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
}[]>;
|
|
32
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/lib/skills.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAgED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAoB9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,CAW7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAc7D;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAG/F"}
|