@speclife/core 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/dist/adapters/claude-cli-adapter.d.ts +57 -0
- package/dist/adapters/claude-cli-adapter.d.ts.map +1 -0
- package/dist/adapters/claude-cli-adapter.js +161 -0
- package/dist/adapters/claude-cli-adapter.js.map +1 -0
- package/dist/adapters/claude-sdk-adapter.d.ts +49 -0
- package/dist/adapters/claude-sdk-adapter.d.ts.map +1 -0
- package/dist/adapters/claude-sdk-adapter.js +278 -0
- package/dist/adapters/claude-sdk-adapter.js.map +1 -0
- package/dist/adapters/cursor-adapter.d.ts +26 -0
- package/dist/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/adapters/cursor-adapter.js +54 -0
- package/dist/adapters/cursor-adapter.js.map +1 -0
- package/dist/adapters/environment-adapter.d.ts +153 -0
- package/dist/adapters/environment-adapter.d.ts.map +1 -0
- package/dist/adapters/environment-adapter.js +690 -0
- package/dist/adapters/environment-adapter.js.map +1 -0
- package/dist/adapters/git-adapter.d.ts +41 -0
- package/dist/adapters/git-adapter.d.ts.map +1 -0
- package/dist/adapters/git-adapter.js +95 -0
- package/dist/adapters/git-adapter.js.map +1 -0
- package/dist/adapters/github-adapter.d.ts +39 -0
- package/dist/adapters/github-adapter.d.ts.map +1 -0
- package/dist/adapters/github-adapter.js +129 -0
- package/dist/adapters/github-adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +13 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/openspec-adapter.d.ts +36 -0
- package/dist/adapters/openspec-adapter.d.ts.map +1 -0
- package/dist/adapters/openspec-adapter.js +182 -0
- package/dist/adapters/openspec-adapter.js.map +1 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +112 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/dist/workflows/implement.d.ts +28 -0
- package/dist/workflows/implement.d.ts.map +1 -0
- package/dist/workflows/implement.js +277 -0
- package/dist/workflows/implement.js.map +1 -0
- package/dist/workflows/index.d.ts +9 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +9 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/init.d.ts +55 -0
- package/dist/workflows/init.d.ts.map +1 -0
- package/dist/workflows/init.js +195 -0
- package/dist/workflows/init.js.map +1 -0
- package/dist/workflows/merge.d.ts +40 -0
- package/dist/workflows/merge.d.ts.map +1 -0
- package/dist/workflows/merge.js +90 -0
- package/dist/workflows/merge.js.map +1 -0
- package/dist/workflows/status.d.ts +34 -0
- package/dist/workflows/status.d.ts.map +1 -0
- package/dist/workflows/status.js +53 -0
- package/dist/workflows/status.js.map +1 -0
- package/dist/workflows/submit.d.ts +44 -0
- package/dist/workflows/submit.d.ts.map +1 -0
- package/dist/workflows/submit.js +143 -0
- package/dist/workflows/submit.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude CLI adapter for implementation
|
|
3
|
+
*
|
|
4
|
+
* Uses the Claude CLI which supports MCP servers natively.
|
|
5
|
+
* This is the primary/recommended implementation mode.
|
|
6
|
+
*/
|
|
7
|
+
/** Options for running Claude CLI */
|
|
8
|
+
export interface ClaudeCliOptions {
|
|
9
|
+
/** Working directory for the CLI */
|
|
10
|
+
cwd: string;
|
|
11
|
+
/** Model to use (optional, uses CLI default if not specified) */
|
|
12
|
+
model?: string;
|
|
13
|
+
/** Maximum tokens to generate */
|
|
14
|
+
maxTokens?: number;
|
|
15
|
+
/** Whether to print to stdout/stderr */
|
|
16
|
+
print?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Result from Claude CLI execution */
|
|
19
|
+
export interface ClaudeCliResult {
|
|
20
|
+
/** Exit code from the process */
|
|
21
|
+
exitCode: number;
|
|
22
|
+
/** Standard output */
|
|
23
|
+
stdout: string;
|
|
24
|
+
/** Standard error */
|
|
25
|
+
stderr: string;
|
|
26
|
+
/** Whether execution was successful */
|
|
27
|
+
success: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Claude CLI adapter interface */
|
|
30
|
+
export interface ClaudeCliAdapter {
|
|
31
|
+
/** Check if Claude CLI is available */
|
|
32
|
+
isAvailable(): Promise<boolean>;
|
|
33
|
+
/** Get Claude CLI version */
|
|
34
|
+
getVersion(): Promise<string | null>;
|
|
35
|
+
/** Run Claude CLI with a prompt */
|
|
36
|
+
run(prompt: string, options: ClaudeCliOptions): Promise<ClaudeCliResult>;
|
|
37
|
+
/** Run Claude CLI with streaming output */
|
|
38
|
+
runStreaming(prompt: string, options: ClaudeCliOptions, onOutput?: (chunk: string) => void): Promise<ClaudeCliResult>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a Claude CLI adapter
|
|
42
|
+
*/
|
|
43
|
+
export declare function createClaudeCliAdapter(): ClaudeCliAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* Generate an implementation prompt for Claude CLI
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateImplementationPrompt(context: {
|
|
48
|
+
changeId: string;
|
|
49
|
+
proposal: string;
|
|
50
|
+
tasks: string;
|
|
51
|
+
design?: string;
|
|
52
|
+
contextFiles?: Array<{
|
|
53
|
+
path: string;
|
|
54
|
+
content: string;
|
|
55
|
+
}>;
|
|
56
|
+
}): string;
|
|
57
|
+
//# sourceMappingURL=claude-cli-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-cli-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-cli-adapter.ts"],"names":[],"mappings":"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AAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD,GAAG,MAAM,CAmDT"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude CLI adapter for implementation
|
|
3
|
+
*
|
|
4
|
+
* Uses the Claude CLI which supports MCP servers natively.
|
|
5
|
+
* This is the primary/recommended implementation mode.
|
|
6
|
+
*/
|
|
7
|
+
import { execa } from 'execa';
|
|
8
|
+
/**
|
|
9
|
+
* Create a Claude CLI adapter
|
|
10
|
+
*/
|
|
11
|
+
export function createClaudeCliAdapter() {
|
|
12
|
+
return {
|
|
13
|
+
async isAvailable() {
|
|
14
|
+
try {
|
|
15
|
+
await execa('claude', ['--version']);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async getVersion() {
|
|
23
|
+
try {
|
|
24
|
+
const result = await execa('claude', ['--version']);
|
|
25
|
+
return result.stdout.trim();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async run(prompt, options) {
|
|
32
|
+
const args = buildArgs(options);
|
|
33
|
+
try {
|
|
34
|
+
const result = await execa('claude', args, {
|
|
35
|
+
cwd: options.cwd,
|
|
36
|
+
input: prompt,
|
|
37
|
+
reject: false,
|
|
38
|
+
});
|
|
39
|
+
const exitCode = result.exitCode ?? 1;
|
|
40
|
+
return {
|
|
41
|
+
exitCode,
|
|
42
|
+
stdout: result.stdout,
|
|
43
|
+
stderr: result.stderr,
|
|
44
|
+
success: exitCode === 0,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
49
|
+
return {
|
|
50
|
+
exitCode: 1,
|
|
51
|
+
stdout: '',
|
|
52
|
+
stderr: message,
|
|
53
|
+
success: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
async runStreaming(prompt, options, onOutput) {
|
|
58
|
+
const args = buildArgs(options);
|
|
59
|
+
try {
|
|
60
|
+
const subprocess = execa('claude', args, {
|
|
61
|
+
cwd: options.cwd,
|
|
62
|
+
input: prompt,
|
|
63
|
+
reject: false,
|
|
64
|
+
});
|
|
65
|
+
// Stream stdout if callback provided
|
|
66
|
+
if (onOutput && subprocess.stdout) {
|
|
67
|
+
subprocess.stdout.on('data', (chunk) => {
|
|
68
|
+
onOutput(chunk.toString());
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Also optionally stream stderr
|
|
72
|
+
if (onOutput && subprocess.stderr) {
|
|
73
|
+
subprocess.stderr.on('data', (chunk) => {
|
|
74
|
+
onOutput(chunk.toString());
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const result = await subprocess;
|
|
78
|
+
const exitCode = result.exitCode ?? 1;
|
|
79
|
+
return {
|
|
80
|
+
exitCode,
|
|
81
|
+
stdout: result.stdout,
|
|
82
|
+
stderr: result.stderr,
|
|
83
|
+
success: exitCode === 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
return {
|
|
89
|
+
exitCode: 1,
|
|
90
|
+
stdout: '',
|
|
91
|
+
stderr: message,
|
|
92
|
+
success: false,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build CLI arguments from options
|
|
100
|
+
*/
|
|
101
|
+
function buildArgs(options) {
|
|
102
|
+
const args = [];
|
|
103
|
+
// Use print mode for non-interactive execution
|
|
104
|
+
args.push('--print');
|
|
105
|
+
if (options.model) {
|
|
106
|
+
args.push('--model', options.model);
|
|
107
|
+
}
|
|
108
|
+
if (options.maxTokens) {
|
|
109
|
+
args.push('--max-tokens', String(options.maxTokens));
|
|
110
|
+
}
|
|
111
|
+
return args;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generate an implementation prompt for Claude CLI
|
|
115
|
+
*/
|
|
116
|
+
export function generateImplementationPrompt(context) {
|
|
117
|
+
const sections = [];
|
|
118
|
+
sections.push(`# Implementation Request: ${context.changeId}`);
|
|
119
|
+
sections.push('');
|
|
120
|
+
sections.push('You are implementing a change based on the following proposal and tasks.');
|
|
121
|
+
sections.push('Please implement each uncompleted task, writing code and running tests as needed.');
|
|
122
|
+
sections.push('');
|
|
123
|
+
sections.push('## Proposal');
|
|
124
|
+
sections.push('```markdown');
|
|
125
|
+
sections.push(context.proposal);
|
|
126
|
+
sections.push('```');
|
|
127
|
+
sections.push('');
|
|
128
|
+
sections.push('## Tasks');
|
|
129
|
+
sections.push('```markdown');
|
|
130
|
+
sections.push(context.tasks);
|
|
131
|
+
sections.push('```');
|
|
132
|
+
sections.push('');
|
|
133
|
+
if (context.design) {
|
|
134
|
+
sections.push('## Design');
|
|
135
|
+
sections.push('```markdown');
|
|
136
|
+
sections.push(context.design);
|
|
137
|
+
sections.push('```');
|
|
138
|
+
sections.push('');
|
|
139
|
+
}
|
|
140
|
+
if (context.contextFiles && context.contextFiles.length > 0) {
|
|
141
|
+
sections.push('## Context Files');
|
|
142
|
+
for (const file of context.contextFiles) {
|
|
143
|
+
sections.push(`### ${file.path}`);
|
|
144
|
+
sections.push('```');
|
|
145
|
+
sections.push(file.content);
|
|
146
|
+
sections.push('```');
|
|
147
|
+
sections.push('');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
sections.push('## Instructions');
|
|
151
|
+
sections.push('');
|
|
152
|
+
sections.push('1. Work through each uncompleted task (marked with `[ ]`)');
|
|
153
|
+
sections.push('2. Write the necessary code changes');
|
|
154
|
+
sections.push('3. Run tests to verify your changes work');
|
|
155
|
+
sections.push('4. If tests fail, analyze the failure and fix the code');
|
|
156
|
+
sections.push('5. Continue until all tasks are complete or you encounter a blocking issue');
|
|
157
|
+
sections.push('');
|
|
158
|
+
sections.push('Begin implementation now.');
|
|
159
|
+
return sections.join('\n');
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=claude-cli-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-cli-adapter.js","sourceRoot":"","sources":["../../src/adapters/claude-cli-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AA6C9B;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,KAAK,CAAC,WAAW;YACf,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;gBACrC,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,KAAK,CAAC,UAAU;YACd,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;gBACpD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,OAAyB;YACjD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;YAEhC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE;oBACzC,GAAG,EAAE,OAAO,CAAC,GAAG;oBAChB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,KAAK;iBACd,CAAC,CAAC;gBAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;gBAC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YAAY,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC5B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IAC3E,QAAQ,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACrD,QAAQ,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IAC1D,QAAQ,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACxE,QAAQ,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAE3C,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude SDK adapter for fully automated implementation
|
|
3
|
+
*
|
|
4
|
+
* Uses the Anthropic SDK directly with tool-use for a fully automated
|
|
5
|
+
* agentic loop that can read/write files and execute shell commands.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProgressCallback } from '../types.js';
|
|
8
|
+
/** Options for the agentic loop */
|
|
9
|
+
export interface AgenticLoopOptions {
|
|
10
|
+
/** Working directory */
|
|
11
|
+
cwd: string;
|
|
12
|
+
/** Model to use */
|
|
13
|
+
model: string;
|
|
14
|
+
/** Maximum iterations for the agentic loop */
|
|
15
|
+
maxIterations?: number;
|
|
16
|
+
/** Maximum tokens per response */
|
|
17
|
+
maxTokens?: number;
|
|
18
|
+
/** Progress callback */
|
|
19
|
+
onProgress?: ProgressCallback;
|
|
20
|
+
}
|
|
21
|
+
/** Result from the agentic loop */
|
|
22
|
+
export interface AgenticLoopResult {
|
|
23
|
+
/** Whether the loop completed successfully */
|
|
24
|
+
success: boolean;
|
|
25
|
+
/** Number of iterations performed */
|
|
26
|
+
iterations: number;
|
|
27
|
+
/** Files that were modified */
|
|
28
|
+
filesModified: string[];
|
|
29
|
+
/** Final response from Claude */
|
|
30
|
+
finalResponse: string;
|
|
31
|
+
/** Any errors encountered */
|
|
32
|
+
errors: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Claude SDK adapter interface */
|
|
35
|
+
export interface ClaudeSdkAdapter {
|
|
36
|
+
/** Check if API key is configured */
|
|
37
|
+
isConfigured(): boolean;
|
|
38
|
+
/** Run the agentic loop with tool-use */
|
|
39
|
+
runAgenticLoop(systemPrompt: string, userPrompt: string, options: AgenticLoopOptions): Promise<AgenticLoopResult>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a Claude SDK adapter
|
|
43
|
+
*/
|
|
44
|
+
export declare function createClaudeSdkAdapter(): ClaudeSdkAdapter;
|
|
45
|
+
/**
|
|
46
|
+
* Generate system prompt for the agentic implementation loop
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateAgenticSystemPrompt(): string;
|
|
49
|
+
//# sourceMappingURL=claude-sdk-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-sdk-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-sdk-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAoBpD,mCAAmC;AACnC,MAAM,WAAW,kBAAkB;IACjC,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,mCAAmC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,YAAY,IAAI,OAAO,CAAC;IAExB,yCAAyC;IACzC,cAAc,CACZ,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CA0IzD;AA4ID;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAkBpD"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude SDK adapter for fully automated implementation
|
|
3
|
+
*
|
|
4
|
+
* Uses the Anthropic SDK directly with tool-use for a fully automated
|
|
5
|
+
* agentic loop that can read/write files and execute shell commands.
|
|
6
|
+
*/
|
|
7
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
8
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
9
|
+
import { dirname, join } from 'path';
|
|
10
|
+
import { execa } from 'execa';
|
|
11
|
+
/**
|
|
12
|
+
* Create a Claude SDK adapter
|
|
13
|
+
*/
|
|
14
|
+
export function createClaudeSdkAdapter() {
|
|
15
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
16
|
+
return {
|
|
17
|
+
isConfigured() {
|
|
18
|
+
return !!apiKey;
|
|
19
|
+
},
|
|
20
|
+
async runAgenticLoop(systemPrompt, userPrompt, options) {
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
iterations: 0,
|
|
25
|
+
filesModified: [],
|
|
26
|
+
finalResponse: '',
|
|
27
|
+
errors: ['ANTHROPIC_API_KEY environment variable is not set'],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const client = new Anthropic({ apiKey });
|
|
31
|
+
const tools = buildToolDefinitions();
|
|
32
|
+
const maxIterations = options.maxIterations ?? 50;
|
|
33
|
+
const maxTokens = options.maxTokens ?? 4096;
|
|
34
|
+
const messages = [
|
|
35
|
+
{ role: 'user', content: userPrompt },
|
|
36
|
+
];
|
|
37
|
+
const filesModified = new Set();
|
|
38
|
+
const errors = [];
|
|
39
|
+
let iterations = 0;
|
|
40
|
+
let finalResponse = '';
|
|
41
|
+
while (iterations < maxIterations) {
|
|
42
|
+
iterations++;
|
|
43
|
+
options.onProgress?.({
|
|
44
|
+
type: 'step_completed',
|
|
45
|
+
message: `Agentic loop iteration ${iterations}`,
|
|
46
|
+
data: { iteration: iterations },
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
const response = await client.messages.create({
|
|
50
|
+
model: options.model,
|
|
51
|
+
max_tokens: maxTokens,
|
|
52
|
+
system: systemPrompt,
|
|
53
|
+
tools: tools,
|
|
54
|
+
messages,
|
|
55
|
+
});
|
|
56
|
+
// Check if we're done (no more tool use)
|
|
57
|
+
if (response.stop_reason === 'end_turn') {
|
|
58
|
+
// Extract final text response
|
|
59
|
+
for (const block of response.content) {
|
|
60
|
+
if (block.type === 'text') {
|
|
61
|
+
finalResponse = block.text;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
// Process tool calls
|
|
67
|
+
const assistantContent = [];
|
|
68
|
+
const toolResults = [];
|
|
69
|
+
for (const block of response.content) {
|
|
70
|
+
if (block.type === 'text') {
|
|
71
|
+
assistantContent.push({ type: 'text', text: block.text });
|
|
72
|
+
}
|
|
73
|
+
else if (block.type === 'tool_use') {
|
|
74
|
+
assistantContent.push({
|
|
75
|
+
type: 'tool_use',
|
|
76
|
+
id: block.id,
|
|
77
|
+
name: block.name,
|
|
78
|
+
input: block.input,
|
|
79
|
+
});
|
|
80
|
+
// Execute the tool
|
|
81
|
+
const result = await executeTool(block.name, block.input, options.cwd);
|
|
82
|
+
// Track modified files
|
|
83
|
+
if (block.name === 'write_file' && result.success) {
|
|
84
|
+
const input = block.input;
|
|
85
|
+
if (input.path) {
|
|
86
|
+
filesModified.add(input.path);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!result.success && result.error) {
|
|
90
|
+
errors.push(result.error);
|
|
91
|
+
}
|
|
92
|
+
options.onProgress?.({
|
|
93
|
+
type: 'step_completed',
|
|
94
|
+
message: `Tool ${block.name}: ${result.success ? 'success' : 'failed'}`,
|
|
95
|
+
data: { tool: block.name, success: result.success },
|
|
96
|
+
});
|
|
97
|
+
toolResults.push({
|
|
98
|
+
type: 'tool_result',
|
|
99
|
+
tool_use_id: block.id,
|
|
100
|
+
content: result.output,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Add assistant message
|
|
105
|
+
messages.push({ role: 'assistant', content: assistantContent });
|
|
106
|
+
// Add tool results
|
|
107
|
+
if (toolResults.length > 0) {
|
|
108
|
+
messages.push({ role: 'user', content: toolResults });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
113
|
+
errors.push(`API error: ${message}`);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
success: errors.length === 0,
|
|
119
|
+
iterations,
|
|
120
|
+
filesModified: Array.from(filesModified),
|
|
121
|
+
finalResponse,
|
|
122
|
+
errors,
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Build tool definitions for the agentic loop
|
|
129
|
+
*/
|
|
130
|
+
function buildToolDefinitions() {
|
|
131
|
+
return [
|
|
132
|
+
{
|
|
133
|
+
name: 'read_file',
|
|
134
|
+
description: 'Read the contents of a file at the given path',
|
|
135
|
+
input_schema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {
|
|
138
|
+
path: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'The file path to read, relative to the working directory',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ['path'],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'write_file',
|
|
148
|
+
description: 'Write content to a file at the given path. Creates directories if needed.',
|
|
149
|
+
input_schema: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
path: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'The file path to write, relative to the working directory',
|
|
155
|
+
},
|
|
156
|
+
content: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'The content to write to the file',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
required: ['path', 'content'],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'run_command',
|
|
166
|
+
description: 'Run a shell command and return its output. Use for running tests, builds, etc.',
|
|
167
|
+
input_schema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
command: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
description: 'The shell command to execute',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
required: ['command'],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'list_directory',
|
|
180
|
+
description: 'List files and directories at the given path',
|
|
181
|
+
input_schema: {
|
|
182
|
+
type: 'object',
|
|
183
|
+
properties: {
|
|
184
|
+
path: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: 'The directory path to list, relative to the working directory',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
required: ['path'],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Execute a tool and return the result
|
|
196
|
+
*/
|
|
197
|
+
async function executeTool(name, input, cwd) {
|
|
198
|
+
try {
|
|
199
|
+
switch (name) {
|
|
200
|
+
case 'read_file': {
|
|
201
|
+
const path = join(cwd, input.path);
|
|
202
|
+
const content = await readFile(path, 'utf-8');
|
|
203
|
+
return { success: true, output: content };
|
|
204
|
+
}
|
|
205
|
+
case 'write_file': {
|
|
206
|
+
const path = join(cwd, input.path);
|
|
207
|
+
const content = input.content;
|
|
208
|
+
await mkdir(dirname(path), { recursive: true });
|
|
209
|
+
await writeFile(path, content, 'utf-8');
|
|
210
|
+
return { success: true, output: `File written: ${input.path}` };
|
|
211
|
+
}
|
|
212
|
+
case 'run_command': {
|
|
213
|
+
const command = input.command;
|
|
214
|
+
const result = await execa(command, {
|
|
215
|
+
cwd,
|
|
216
|
+
shell: true,
|
|
217
|
+
reject: false,
|
|
218
|
+
});
|
|
219
|
+
const output = [
|
|
220
|
+
`Exit code: ${result.exitCode}`,
|
|
221
|
+
result.stdout ? `stdout:\n${result.stdout}` : '',
|
|
222
|
+
result.stderr ? `stderr:\n${result.stderr}` : '',
|
|
223
|
+
].filter(Boolean).join('\n');
|
|
224
|
+
return {
|
|
225
|
+
success: result.exitCode === 0,
|
|
226
|
+
output,
|
|
227
|
+
error: result.exitCode !== 0 ? `Command failed with exit code ${result.exitCode}` : undefined,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
case 'list_directory': {
|
|
231
|
+
const path = join(cwd, input.path);
|
|
232
|
+
const { readdir } = await import('fs/promises');
|
|
233
|
+
const entries = await readdir(path, { withFileTypes: true });
|
|
234
|
+
const output = entries
|
|
235
|
+
.map(e => `${e.isDirectory() ? 'd' : 'f'} ${e.name}`)
|
|
236
|
+
.join('\n');
|
|
237
|
+
return { success: true, output };
|
|
238
|
+
}
|
|
239
|
+
default:
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
output: '',
|
|
243
|
+
error: `Unknown tool: ${name}`,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
249
|
+
return {
|
|
250
|
+
success: false,
|
|
251
|
+
output: '',
|
|
252
|
+
error: message,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Generate system prompt for the agentic implementation loop
|
|
258
|
+
*/
|
|
259
|
+
export function generateAgenticSystemPrompt() {
|
|
260
|
+
return `You are an expert software engineer implementing changes based on a proposal and task list.
|
|
261
|
+
|
|
262
|
+
Your capabilities:
|
|
263
|
+
- read_file: Read file contents
|
|
264
|
+
- write_file: Create or modify files
|
|
265
|
+
- run_command: Execute shell commands (tests, builds, etc.)
|
|
266
|
+
- list_directory: Explore the codebase structure
|
|
267
|
+
|
|
268
|
+
Guidelines:
|
|
269
|
+
1. Work through each uncompleted task systematically
|
|
270
|
+
2. Read relevant files before making changes
|
|
271
|
+
3. Make minimal, focused changes to complete each task
|
|
272
|
+
4. Run tests after making changes to verify correctness
|
|
273
|
+
5. If tests fail, analyze the output and fix the issues
|
|
274
|
+
6. Continue until all tasks are complete or you encounter a blocking issue
|
|
275
|
+
|
|
276
|
+
When you've completed all tasks or cannot proceed further, provide a summary of what was accomplished.`;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=claude-sdk-adapter.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C7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;gBAChD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC7D,MAAM,MAAM,GAAG,OAAO;qBACnB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;qBACpD,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACnC,CAAC;YAED;gBACE,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,iBAAiB,IAAI,EAAE;iBAC/B,CAAC;QACN,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,OAAO;SACf,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;uGAgB8F,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor IDE adapter for manual implementation
|
|
3
|
+
*
|
|
4
|
+
* Opens Cursor IDE in the worktree directory for manual/assisted implementation.
|
|
5
|
+
*/
|
|
6
|
+
/** Result from Cursor operations */
|
|
7
|
+
export interface CursorResult {
|
|
8
|
+
/** Whether the operation was successful */
|
|
9
|
+
success: boolean;
|
|
10
|
+
/** Human-readable message */
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
/** Cursor adapter interface */
|
|
14
|
+
export interface CursorAdapter {
|
|
15
|
+
/** Check if Cursor CLI is available */
|
|
16
|
+
isAvailable(): Promise<boolean>;
|
|
17
|
+
/** Get Cursor version if available */
|
|
18
|
+
getVersion(): Promise<string | null>;
|
|
19
|
+
/** Open Cursor in the specified directory */
|
|
20
|
+
open(directoryPath: string): Promise<CursorResult>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Cursor adapter
|
|
24
|
+
*/
|
|
25
|
+
export declare function createCursorAdapter(): CursorAdapter;
|
|
26
|
+
//# sourceMappingURL=cursor-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+BAA+B;AAC/B,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC,sCAAsC;IACtC,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAErC,6CAA6C;IAC7C,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CA4CnD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor IDE adapter for manual implementation
|
|
3
|
+
*
|
|
4
|
+
* Opens Cursor IDE in the worktree directory for manual/assisted implementation.
|
|
5
|
+
*/
|
|
6
|
+
import { execa } from 'execa';
|
|
7
|
+
/**
|
|
8
|
+
* Create a Cursor adapter
|
|
9
|
+
*/
|
|
10
|
+
export function createCursorAdapter() {
|
|
11
|
+
return {
|
|
12
|
+
async isAvailable() {
|
|
13
|
+
try {
|
|
14
|
+
await execa('cursor', ['--version']);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
async getVersion() {
|
|
22
|
+
try {
|
|
23
|
+
const result = await execa('cursor', ['--version']);
|
|
24
|
+
return result.stdout.trim();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
async open(directoryPath) {
|
|
31
|
+
try {
|
|
32
|
+
// Open Cursor in the background (don't wait for it to close)
|
|
33
|
+
const subprocess = execa('cursor', [directoryPath], {
|
|
34
|
+
detached: true,
|
|
35
|
+
stdio: 'ignore',
|
|
36
|
+
});
|
|
37
|
+
// Unref so the parent process can exit
|
|
38
|
+
subprocess.unref();
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
message: `Cursor opened at: ${directoryPath}`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
message: `Failed to open Cursor: ${message}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=cursor-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-adapter.js","sourceRoot":"","sources":["../../src/adapters/cursor-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAsB9B;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAA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