swellai 1.0.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/README.md +711 -0
- package/dist/agents/linear-agent.d.ts +32 -0
- package/dist/agents/linear-agent.d.ts.map +1 -0
- package/dist/agents/linear-agent.js +263 -0
- package/dist/agents/linear-agent.js.map +1 -0
- package/dist/agents/planning-agent.d.ts +36 -0
- package/dist/agents/planning-agent.d.ts.map +1 -0
- package/dist/agents/planning-agent.js +248 -0
- package/dist/agents/planning-agent.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +102 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install.d.ts +11 -0
- package/dist/cli/install.d.ts.map +1 -0
- package/dist/cli/install.js +257 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/manifest.d.ts +27 -0
- package/dist/cli/manifest.d.ts.map +1 -0
- package/dist/cli/manifest.js +65 -0
- package/dist/cli/manifest.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/claude-agent-sdk.d.ts +73 -0
- package/dist/lib/claude-agent-sdk.d.ts.map +1 -0
- package/dist/lib/claude-agent-sdk.js +114 -0
- package/dist/lib/claude-agent-sdk.js.map +1 -0
- package/dist/lib/conversation-logger.d.ts +66 -0
- package/dist/lib/conversation-logger.d.ts.map +1 -0
- package/dist/lib/conversation-logger.js +159 -0
- package/dist/lib/conversation-logger.js.map +1 -0
- package/dist/lib/opencode.d.ts +68 -0
- package/dist/lib/opencode.d.ts.map +1 -0
- package/dist/lib/opencode.js +151 -0
- package/dist/lib/opencode.js.map +1 -0
- package/dist/lib/turso-schema.d.ts +13 -0
- package/dist/lib/turso-schema.d.ts.map +1 -0
- package/dist/lib/turso-schema.js +69 -0
- package/dist/lib/turso-schema.js.map +1 -0
- package/dist/lib/turso.d.ts +56 -0
- package/dist/lib/turso.d.ts.map +1 -0
- package/dist/lib/turso.js +144 -0
- package/dist/lib/turso.js.map +1 -0
- package/dist/lib/types.d.ts +31 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +20 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +34 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +72 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/scripts/build-templates.d.ts +17 -0
- package/dist/scripts/build-templates.d.ts.map +1 -0
- package/dist/scripts/build-templates.js +132 -0
- package/dist/scripts/build-templates.js.map +1 -0
- package/dist/scripts/claude-agent-runner.d.ts +28 -0
- package/dist/scripts/claude-agent-runner.d.ts.map +1 -0
- package/dist/scripts/claude-agent-runner.js +278 -0
- package/dist/scripts/claude-agent-runner.js.map +1 -0
- package/dist/src/agents/linear-agent.d.ts +32 -0
- package/dist/src/agents/linear-agent.d.ts.map +1 -0
- package/dist/src/agents/linear-agent.js +285 -0
- package/dist/src/agents/linear-agent.js.map +1 -0
- package/dist/src/agents/planning-agent.d.ts +36 -0
- package/dist/src/agents/planning-agent.d.ts.map +1 -0
- package/dist/src/agents/planning-agent.js +248 -0
- package/dist/src/agents/planning-agent.js.map +1 -0
- package/dist/src/cli/index.d.ts +3 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +102 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/install.d.ts +11 -0
- package/dist/src/cli/install.d.ts.map +1 -0
- package/dist/src/cli/install.js +257 -0
- package/dist/src/cli/install.js.map +1 -0
- package/dist/src/cli/manifest.d.ts +27 -0
- package/dist/src/cli/manifest.d.ts.map +1 -0
- package/dist/src/cli/manifest.js +65 -0
- package/dist/src/cli/manifest.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/claude-agent-sdk.d.ts +73 -0
- package/dist/src/lib/claude-agent-sdk.d.ts.map +1 -0
- package/dist/src/lib/claude-agent-sdk.js +114 -0
- package/dist/src/lib/claude-agent-sdk.js.map +1 -0
- package/dist/src/lib/conversation-logger.d.ts +66 -0
- package/dist/src/lib/conversation-logger.d.ts.map +1 -0
- package/dist/src/lib/conversation-logger.js +159 -0
- package/dist/src/lib/conversation-logger.js.map +1 -0
- package/dist/src/lib/opencode.d.ts +153 -0
- package/dist/src/lib/opencode.d.ts.map +1 -0
- package/dist/src/lib/opencode.js +153 -0
- package/dist/src/lib/opencode.js.map +1 -0
- package/dist/src/lib/turso-schema.d.ts +13 -0
- package/dist/src/lib/turso-schema.d.ts.map +1 -0
- package/dist/src/lib/turso-schema.js +69 -0
- package/dist/src/lib/turso-schema.js.map +1 -0
- package/dist/src/lib/turso.d.ts +56 -0
- package/dist/src/lib/turso.d.ts.map +1 -0
- package/dist/src/lib/turso.js +144 -0
- package/dist/src/lib/turso.js.map +1 -0
- package/dist/src/lib/types.d.ts +31 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +20 -0
- package/dist/src/lib/types.js.map +1 -0
- package/dist/src/lib/utils.d.ts +34 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +72 -0
- package/dist/src/lib/utils.js.map +1 -0
- package/package.json +63 -0
- package/templates/.env.example +51 -0
- package/templates/agents/codebase-analyzer.md +121 -0
- package/templates/agents/codebase-locator.md +105 -0
- package/templates/agents/coding-agent.md +187 -0
- package/templates/agents/debug-agent.md +300 -0
- package/templates/prompts/consolidate-and-create-linear.md +282 -0
- package/templates/prompts/implementation.md +94 -0
- package/templates/prompts/plan-generation.md +171 -0
- package/templates/prompts/review.md +39 -0
- package/templates/prompts/verify.md +80 -0
- package/templates/scripts/claude-agent-runner.js +12887 -0
- package/templates/scripts/detect-runtime.sh +95 -0
- package/templates/scripts/linear-agent.js +1753 -0
- package/templates/scripts/planning-agent.js +1738 -0
- package/templates/workflows/claude-implement.yml +931 -0
- package/templates/workflows/claude-plan.yml +301 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* claude-agent-runner.ts
|
|
4
|
+
*
|
|
5
|
+
* CLI wrapper for running Claude Agent SDK queries.
|
|
6
|
+
* This script can be invoked by parallel-impl.sh and other automation scripts.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* echo "prompt" | claude-agent-runner.ts --cwd /path --model claude-opus-4-5-20251101 --mode implementation
|
|
10
|
+
*
|
|
11
|
+
* Arguments:
|
|
12
|
+
* --cwd <path> Working directory for the agent (required)
|
|
13
|
+
* --model <modelName> Model to use (default: claude-opus-4-5-20251101)
|
|
14
|
+
* --mode <mode> Execution mode: implementation or review (default: implementation)
|
|
15
|
+
*
|
|
16
|
+
* Input:
|
|
17
|
+
* Reads prompt from stdin (supports multiline)
|
|
18
|
+
*
|
|
19
|
+
* Output:
|
|
20
|
+
* - stdout: Final result JSON (type: 'result' message)
|
|
21
|
+
* - stderr: Progress logs and errors
|
|
22
|
+
*
|
|
23
|
+
* Exit codes:
|
|
24
|
+
* 0: Success
|
|
25
|
+
* 1: Error (authentication, SDK error, no result, etc.)
|
|
26
|
+
*/
|
|
27
|
+
import { stdin } from "node:process";
|
|
28
|
+
import { runClaudeQuery } from "../src/lib/claude-agent-sdk.js";
|
|
29
|
+
import { createConversationLogger } from "../src/lib/conversation-logger.js";
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Review Decision Schema
|
|
32
|
+
// ============================================================================
|
|
33
|
+
const REVIEW_DECISION_SCHEMA = {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
best: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
minimum: 1,
|
|
39
|
+
description: "The number (1-based) of the best implementation",
|
|
40
|
+
},
|
|
41
|
+
reasoning: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Detailed explanation for why this implementation was chosen",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ["best", "reasoning"],
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
};
|
|
49
|
+
function parseArgs() {
|
|
50
|
+
const args = process.argv.slice(2);
|
|
51
|
+
const parsedArgs = {
|
|
52
|
+
model: "claude-opus-4-5-20251101",
|
|
53
|
+
mode: "implementation",
|
|
54
|
+
};
|
|
55
|
+
for (let i = 0; i < args.length; i++) {
|
|
56
|
+
const arg = args[i];
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case "--cwd":
|
|
59
|
+
parsedArgs.cwd = args[++i];
|
|
60
|
+
break;
|
|
61
|
+
case "--model":
|
|
62
|
+
parsedArgs.model = args[++i];
|
|
63
|
+
break;
|
|
64
|
+
case "--mode": {
|
|
65
|
+
const mode = args[++i];
|
|
66
|
+
if (mode !== "implementation" && mode !== "review") {
|
|
67
|
+
console.error(`Error: Invalid mode "${mode}". Must be "implementation" or "review".`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
parsedArgs.mode = mode;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "--help":
|
|
74
|
+
case "-h":
|
|
75
|
+
printUsage();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
default:
|
|
78
|
+
console.error(`Error: Unknown argument "${arg}"`);
|
|
79
|
+
printUsage();
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Validate required arguments
|
|
84
|
+
if (!parsedArgs.cwd) {
|
|
85
|
+
console.error("Error: --cwd is required");
|
|
86
|
+
printUsage();
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
return parsedArgs;
|
|
90
|
+
}
|
|
91
|
+
function printUsage() {
|
|
92
|
+
console.error(`
|
|
93
|
+
Usage: claude-agent-runner.ts --cwd <path> [options]
|
|
94
|
+
|
|
95
|
+
Arguments:
|
|
96
|
+
--cwd <path> Working directory for the agent (required)
|
|
97
|
+
--model <modelName> Model to use (default: claude-opus-4-5-20251101)
|
|
98
|
+
--mode <mode> Execution mode: implementation or review (default: implementation)
|
|
99
|
+
-h, --help Show this help message
|
|
100
|
+
|
|
101
|
+
Input:
|
|
102
|
+
Reads prompt from stdin (supports multiline prompts)
|
|
103
|
+
|
|
104
|
+
Output:
|
|
105
|
+
- stdout: Final result JSON (the 'result' message from SDK)
|
|
106
|
+
- stderr: Progress logs and error messages
|
|
107
|
+
|
|
108
|
+
Examples:
|
|
109
|
+
# Implementation mode
|
|
110
|
+
echo "What is 2+2?" | claude-agent-runner.ts --cwd /tmp --mode implementation
|
|
111
|
+
|
|
112
|
+
# Review mode with structured output
|
|
113
|
+
echo "Review these implementations" | claude-agent-runner.ts --cwd /tmp --mode review
|
|
114
|
+
|
|
115
|
+
# Custom model
|
|
116
|
+
echo "Analyze this code" | claude-agent-runner.ts --cwd /tmp --model claude-sonnet-4-5
|
|
117
|
+
|
|
118
|
+
Environment Variables:
|
|
119
|
+
CLAUDE_CODE_OAUTH_TOKEN OAuth token (preferred)
|
|
120
|
+
ANTHROPIC_API_KEY API key (fallback)
|
|
121
|
+
`);
|
|
122
|
+
}
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// Read Stdin
|
|
125
|
+
// ============================================================================
|
|
126
|
+
async function readStdin() {
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
const chunks = [];
|
|
129
|
+
stdin.on("data", (chunk) => {
|
|
130
|
+
chunks.push(chunk);
|
|
131
|
+
});
|
|
132
|
+
stdin.on("end", () => {
|
|
133
|
+
resolve(Buffer.concat(chunks).toString("utf-8"));
|
|
134
|
+
});
|
|
135
|
+
stdin.on("error", (error) => {
|
|
136
|
+
reject(error);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Main Execution
|
|
142
|
+
// ============================================================================
|
|
143
|
+
async function main() {
|
|
144
|
+
// Parse command line arguments
|
|
145
|
+
const args = parseArgs();
|
|
146
|
+
console.error("");
|
|
147
|
+
console.error("=".repeat(60));
|
|
148
|
+
console.error("Claude Agent Runner");
|
|
149
|
+
console.error("=".repeat(60));
|
|
150
|
+
console.error(`CWD: ${args.cwd}`);
|
|
151
|
+
console.error(`Model: ${args.model}`);
|
|
152
|
+
console.error(`Mode: ${args.mode}`);
|
|
153
|
+
console.error("");
|
|
154
|
+
// Read prompt from stdin
|
|
155
|
+
console.error("Reading prompt from stdin...");
|
|
156
|
+
const prompt = await readStdin();
|
|
157
|
+
if (!prompt.trim()) {
|
|
158
|
+
console.error("Error: Empty prompt received from stdin");
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
console.error(`✓ Received prompt: ${prompt.length} characters`);
|
|
162
|
+
console.error("");
|
|
163
|
+
// Initialize conversation logger (optional)
|
|
164
|
+
const logger = await createConversationLogger();
|
|
165
|
+
if (logger) {
|
|
166
|
+
console.error(`✓ Conversation logging enabled`);
|
|
167
|
+
}
|
|
168
|
+
// Build MCP servers configuration
|
|
169
|
+
const mcpServers = {
|
|
170
|
+
deepwiki: {
|
|
171
|
+
type: "sse",
|
|
172
|
+
url: "https://mcp.deepwiki.com/sse",
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// Add Linear MCP if API key is available
|
|
176
|
+
const linearApiKey = process.env.LINEAR_API_KEY;
|
|
177
|
+
if (linearApiKey) {
|
|
178
|
+
console.error(`✓ LINEAR_API_KEY found - enabling Linear MCP`);
|
|
179
|
+
mcpServers.linear = {
|
|
180
|
+
type: "stdio",
|
|
181
|
+
command: "npx",
|
|
182
|
+
args: ["-y", "@linear/mcp-server-linear"],
|
|
183
|
+
env: {
|
|
184
|
+
LINEAR_API_KEY: linearApiKey,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.error(`⚠️ LINEAR_API_KEY not found - Linear MCP disabled`);
|
|
190
|
+
console.error(` Set LINEAR_API_KEY to enable Linear issue fetching`);
|
|
191
|
+
}
|
|
192
|
+
// Build query options
|
|
193
|
+
const queryOptions = {
|
|
194
|
+
cwd: args.cwd,
|
|
195
|
+
model: args.model,
|
|
196
|
+
mode: args.mode,
|
|
197
|
+
mcpServers,
|
|
198
|
+
logger,
|
|
199
|
+
...(args.mode === "review" ? { outputSchema: REVIEW_DECISION_SCHEMA } : {}),
|
|
200
|
+
};
|
|
201
|
+
try {
|
|
202
|
+
// Start logging session if logger is available
|
|
203
|
+
if (logger) {
|
|
204
|
+
await logger.startSession({
|
|
205
|
+
id: crypto.randomUUID(),
|
|
206
|
+
agentType: args.mode === "review" ? "review" : "implementation",
|
|
207
|
+
model: args.model,
|
|
208
|
+
provider: "anthropic",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// Run the query
|
|
212
|
+
console.error("Starting Claude query...");
|
|
213
|
+
console.error("");
|
|
214
|
+
let messageCount = 0;
|
|
215
|
+
let finalResult = null;
|
|
216
|
+
for await (const message of runClaudeQuery(prompt, queryOptions)) {
|
|
217
|
+
messageCount++;
|
|
218
|
+
// Log message type to stderr for debugging
|
|
219
|
+
console.error(`[Message ${messageCount}] Type: ${message.type}`);
|
|
220
|
+
// Check if this is the final result
|
|
221
|
+
if (message.type === "result") {
|
|
222
|
+
finalResult = message;
|
|
223
|
+
console.error(`[Message ${messageCount}] Subtype: ${message.subtype}`);
|
|
224
|
+
if (message.subtype === "success") {
|
|
225
|
+
console.error(`[Message ${messageCount}] ✓ Query completed successfully`);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
console.error(`[Message ${messageCount}] ✗ Query failed: ${message.subtype}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
console.error("");
|
|
233
|
+
console.error("=".repeat(60));
|
|
234
|
+
// Check if we got a result
|
|
235
|
+
if (!finalResult) {
|
|
236
|
+
console.error("ERROR: No result message received from query");
|
|
237
|
+
console.error("=".repeat(60));
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
// Output the result to stdout as JSON
|
|
241
|
+
console.log(JSON.stringify(finalResult, null, 2));
|
|
242
|
+
console.error("SUCCESS: Result written to stdout");
|
|
243
|
+
console.error("=".repeat(60));
|
|
244
|
+
console.error("");
|
|
245
|
+
// End logging session successfully and sync to cloud
|
|
246
|
+
if (logger) {
|
|
247
|
+
await logger.endSession("completed");
|
|
248
|
+
await logger.syncToCloud();
|
|
249
|
+
}
|
|
250
|
+
process.exit(0);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
254
|
+
console.error("");
|
|
255
|
+
console.error("=".repeat(60));
|
|
256
|
+
console.error("ERROR!");
|
|
257
|
+
console.error("=".repeat(60));
|
|
258
|
+
console.error(`Error: ${errorMessage}`);
|
|
259
|
+
if (error instanceof Error && error.stack) {
|
|
260
|
+
console.error("");
|
|
261
|
+
console.error("Stack trace:");
|
|
262
|
+
console.error(error.stack);
|
|
263
|
+
}
|
|
264
|
+
console.error("");
|
|
265
|
+
// End logging session with error and sync to cloud
|
|
266
|
+
if (logger) {
|
|
267
|
+
await logger.endSession("error", errorMessage);
|
|
268
|
+
await logger.syncToCloud();
|
|
269
|
+
}
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Run the main function
|
|
274
|
+
main().catch((error) => {
|
|
275
|
+
console.error("FATAL ERROR:", error);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
});
|
|
278
|
+
//# sourceMappingURL=claude-agent-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-agent-runner.js","sourceRoot":"","sources":["../../scripts/claude-agent-runner.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,C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I,KAAK,CAAC,KAAK,EAAE,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAElB,mDAAmD;QACnD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/C,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,wBAAwB;AACxB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* linear-agent.ts
|
|
4
|
+
*
|
|
5
|
+
* Consolidates three implementation plans from different AI providers and creates Linear issues.
|
|
6
|
+
* This is the v2 workflow approach that receives pre-generated plans via environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* linear-agent.ts
|
|
10
|
+
*
|
|
11
|
+
* Environment variables (all required):
|
|
12
|
+
* - ANTHROPIC_PLAN - Plan from Anthropic provider
|
|
13
|
+
* - OPENAI_PLAN - Plan from OpenAI provider
|
|
14
|
+
* - GOOGLE_PLAN - Plan from Google provider
|
|
15
|
+
* - GITHUB_ISSUE_URL - URL of the GitHub issue
|
|
16
|
+
* - ISSUE_TITLE - Title of the GitHub issue
|
|
17
|
+
* - LINEAR_TEAM_ID - Linear team ID
|
|
18
|
+
* - LINEAR_PROJECT_ID - Linear project ID (optional)
|
|
19
|
+
* - ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN - API key for consolidation agent
|
|
20
|
+
* - LINEAR_API_KEY - Linear API key for creating issues
|
|
21
|
+
*
|
|
22
|
+
* Optional:
|
|
23
|
+
* - MODEL (defaults to claude-opus-4-5)
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* ANTHROPIC_PLAN="..." OPENAI_PLAN="..." GOOGLE_PLAN="..." \
|
|
27
|
+
* GITHUB_ISSUE_URL="..." ISSUE_TITLE="..." LINEAR_TEAM_ID="..." \
|
|
28
|
+
* ANTHROPIC_API_KEY=xxx LINEAR_API_KEY=xxx \
|
|
29
|
+
* linear-agent.ts
|
|
30
|
+
*/
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=linear-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-agent.d.ts","sourceRoot":"","sources":["../../../src/agents/linear-agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* linear-agent.ts
|
|
4
|
+
*
|
|
5
|
+
* Consolidates three implementation plans from different AI providers and creates Linear issues.
|
|
6
|
+
* This is the v2 workflow approach that receives pre-generated plans via environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* linear-agent.ts
|
|
10
|
+
*
|
|
11
|
+
* Environment variables (all required):
|
|
12
|
+
* - ANTHROPIC_PLAN - Plan from Anthropic provider
|
|
13
|
+
* - OPENAI_PLAN - Plan from OpenAI provider
|
|
14
|
+
* - GOOGLE_PLAN - Plan from Google provider
|
|
15
|
+
* - GITHUB_ISSUE_URL - URL of the GitHub issue
|
|
16
|
+
* - ISSUE_TITLE - Title of the GitHub issue
|
|
17
|
+
* - LINEAR_TEAM_ID - Linear team ID
|
|
18
|
+
* - LINEAR_PROJECT_ID - Linear project ID (optional)
|
|
19
|
+
* - ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN - API key for consolidation agent
|
|
20
|
+
* - LINEAR_API_KEY - Linear API key for creating issues
|
|
21
|
+
*
|
|
22
|
+
* Optional:
|
|
23
|
+
* - MODEL (defaults to claude-opus-4-5)
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* ANTHROPIC_PLAN="..." OPENAI_PLAN="..." GOOGLE_PLAN="..." \
|
|
27
|
+
* GITHUB_ISSUE_URL="..." ISSUE_TITLE="..." LINEAR_TEAM_ID="..." \
|
|
28
|
+
* ANTHROPIC_API_KEY=xxx LINEAR_API_KEY=xxx \
|
|
29
|
+
* linear-agent.ts
|
|
30
|
+
*/
|
|
31
|
+
import { access, readFile } from "node:fs/promises";
|
|
32
|
+
import { join } from "node:path";
|
|
33
|
+
import { createConversationLogger } from "../lib/conversation-logger.js";
|
|
34
|
+
import { createOpencodeServer, setupEventMonitoring } from "../lib/opencode.js";
|
|
35
|
+
import { extractTextFromParts, getApiKey, validateEnvVars } from "../lib/utils.js";
|
|
36
|
+
// Note: __filename and __dirname are not needed here anymore
|
|
37
|
+
// Prompts are resolved from process.cwd() in installed locations
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Configuration
|
|
40
|
+
// ============================================================================
|
|
41
|
+
const AGENT_NAME = "linear-agent";
|
|
42
|
+
const DEFAULT_MODEL = "claude-opus-4-5";
|
|
43
|
+
// Helper to find prompt file in multiple possible locations
|
|
44
|
+
async function findPromptFile() {
|
|
45
|
+
const possiblePaths = [
|
|
46
|
+
// Installed location (via installer)
|
|
47
|
+
join(process.cwd(), ".github", "claude-parallel", "prompts", "consolidate-and-create-linear.md"),
|
|
48
|
+
// Source repository location
|
|
49
|
+
join(process.cwd(), "prompts", "consolidate-and-create-linear.md"),
|
|
50
|
+
];
|
|
51
|
+
for (const path of possiblePaths) {
|
|
52
|
+
try {
|
|
53
|
+
await access(path);
|
|
54
|
+
return path;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// File doesn't exist at this path, try next
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`Could not find consolidate-and-create-linear.md in any of these locations:\n${possiblePaths.map((p) => ` - ${p}`).join("\n")}`);
|
|
61
|
+
}
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Main Execution
|
|
64
|
+
// ============================================================================
|
|
65
|
+
async function main() {
|
|
66
|
+
// Validate required environment variables
|
|
67
|
+
const requiredEnvVars = [
|
|
68
|
+
"ANTHROPIC_PLAN",
|
|
69
|
+
"OPENAI_PLAN",
|
|
70
|
+
"GOOGLE_PLAN",
|
|
71
|
+
"GITHUB_ISSUE_URL",
|
|
72
|
+
"ISSUE_TITLE",
|
|
73
|
+
"LINEAR_TEAM_ID",
|
|
74
|
+
"LINEAR_API_KEY",
|
|
75
|
+
];
|
|
76
|
+
try {
|
|
77
|
+
validateEnvVars(requiredEnvVars);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
81
|
+
console.error("");
|
|
82
|
+
console.error("Usage: Set all required environment variables and run:");
|
|
83
|
+
console.error(" bun run linear-agent.ts");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
// Get API key for Anthropic (consolidation provider)
|
|
87
|
+
const provider = "anthropic";
|
|
88
|
+
const apiKey = getApiKey(provider);
|
|
89
|
+
// Get configuration from environment
|
|
90
|
+
const anthropicPlan = process.env.ANTHROPIC_PLAN;
|
|
91
|
+
const openaiPlan = process.env.OPENAI_PLAN;
|
|
92
|
+
const googlePlan = process.env.GOOGLE_PLAN;
|
|
93
|
+
const githubIssueUrl = process.env.GITHUB_ISSUE_URL;
|
|
94
|
+
const issueTitle = process.env.ISSUE_TITLE;
|
|
95
|
+
const linearTeamId = process.env.LINEAR_TEAM_ID;
|
|
96
|
+
const linearProjectId = process.env.LINEAR_PROJECT_ID || "";
|
|
97
|
+
const linearApiKey = process.env.LINEAR_API_KEY;
|
|
98
|
+
const model = process.env.MODEL || DEFAULT_MODEL;
|
|
99
|
+
// Validate required environment variables
|
|
100
|
+
if (!anthropicPlan) {
|
|
101
|
+
throw new Error("ANTHROPIC_PLAN environment variable is required");
|
|
102
|
+
}
|
|
103
|
+
if (!openaiPlan) {
|
|
104
|
+
throw new Error("OPENAI_PLAN environment variable is required");
|
|
105
|
+
}
|
|
106
|
+
if (!googlePlan) {
|
|
107
|
+
throw new Error("GOOGLE_PLAN environment variable is required");
|
|
108
|
+
}
|
|
109
|
+
if (!githubIssueUrl) {
|
|
110
|
+
throw new Error("GITHUB_ISSUE_URL environment variable is required");
|
|
111
|
+
}
|
|
112
|
+
if (!issueTitle) {
|
|
113
|
+
throw new Error("ISSUE_TITLE environment variable is required");
|
|
114
|
+
}
|
|
115
|
+
if (!linearTeamId) {
|
|
116
|
+
throw new Error("LINEAR_TEAM_ID environment variable is required");
|
|
117
|
+
}
|
|
118
|
+
if (!linearApiKey) {
|
|
119
|
+
throw new Error("LINEAR_API_KEY environment variable is required");
|
|
120
|
+
}
|
|
121
|
+
console.error(`\n${"=".repeat(60)}`);
|
|
122
|
+
console.error(`Linear Agent - Plan Consolidation`);
|
|
123
|
+
console.error(`${"=".repeat(60)}`);
|
|
124
|
+
console.error(`Provider: ${provider}`);
|
|
125
|
+
console.error(`Model: ${model}`);
|
|
126
|
+
console.error(`Issue: ${issueTitle}`);
|
|
127
|
+
console.error(`GitHub URL: ${githubIssueUrl}`);
|
|
128
|
+
console.error(`Linear Team: ${linearTeamId}`);
|
|
129
|
+
console.error(`Linear Project: ${linearProjectId || "(none)"}`);
|
|
130
|
+
console.error("");
|
|
131
|
+
// Initialize conversation logger (optional)
|
|
132
|
+
const logger = await createConversationLogger();
|
|
133
|
+
if (logger) {
|
|
134
|
+
console.error(`✓ Conversation logging enabled`);
|
|
135
|
+
}
|
|
136
|
+
// Read external prompt template file
|
|
137
|
+
let promptTemplate;
|
|
138
|
+
let promptFile;
|
|
139
|
+
try {
|
|
140
|
+
promptFile = await findPromptFile();
|
|
141
|
+
promptTemplate = await readFile(promptFile, "utf-8");
|
|
142
|
+
console.error(`✓ Loaded prompt template from ${promptFile}`);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
146
|
+
console.error(`✗ Failed to read prompt file: ${errorMessage}`);
|
|
147
|
+
console.error("Please create consolidate-and-create-linear.md file in the prompts directory");
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
// Replace placeholders in the prompt template
|
|
151
|
+
const prompt = promptTemplate
|
|
152
|
+
.replace(/\{\{ANTHROPIC_PLAN\}\}/g, anthropicPlan)
|
|
153
|
+
.replace(/\{\{OPENAI_PLAN\}\}/g, openaiPlan)
|
|
154
|
+
.replace(/\{\{GOOGLE_PLAN\}\}/g, googlePlan)
|
|
155
|
+
.replace(/\{\{GITHUB_ISSUE_URL\}\}/g, githubIssueUrl)
|
|
156
|
+
.replace(/\{\{ISSUE_TITLE\}\}/g, issueTitle)
|
|
157
|
+
.replace(/\{\{LINEAR_TEAM_ID\}\}/g, linearTeamId)
|
|
158
|
+
.replace(/\{\{LINEAR_PROJECT_ID\}\}/g, linearProjectId);
|
|
159
|
+
console.error(`✓ Filled prompt template with plans and context`);
|
|
160
|
+
// Create OpenCode server with linear agent configuration
|
|
161
|
+
const { client, server } = await createOpencodeServer({
|
|
162
|
+
provider,
|
|
163
|
+
apiKey,
|
|
164
|
+
model,
|
|
165
|
+
agentName: AGENT_NAME,
|
|
166
|
+
agentDescription: "Consolidate implementation plans and create Linear issues",
|
|
167
|
+
agentPrompt: prompt,
|
|
168
|
+
agentTools: {
|
|
169
|
+
write: false, // No file creation
|
|
170
|
+
edit: false, // No file modification
|
|
171
|
+
bash: true, // Allow shell commands
|
|
172
|
+
read: true, // Allow reading files
|
|
173
|
+
list: true, // Allow listing directories
|
|
174
|
+
glob: true, // Allow file pattern matching
|
|
175
|
+
grep: true, // Allow searching content
|
|
176
|
+
webfetch: true, // Allow web research
|
|
177
|
+
...(linearApiKey && { "mcp__linear__*": true }), // Enable Linear MCP tools if available
|
|
178
|
+
},
|
|
179
|
+
agentPermissions: {
|
|
180
|
+
edit: "deny",
|
|
181
|
+
bash: "allow",
|
|
182
|
+
webfetch: "allow",
|
|
183
|
+
...(linearApiKey && { "mcp__linear__*": "allow" }), // Allow Linear MCP tools if available
|
|
184
|
+
},
|
|
185
|
+
maxSteps: 30,
|
|
186
|
+
linearApiKey,
|
|
187
|
+
});
|
|
188
|
+
// Setup event monitoring
|
|
189
|
+
setupEventMonitoring(client, logger);
|
|
190
|
+
try {
|
|
191
|
+
// Start logging session if logger is available
|
|
192
|
+
if (logger) {
|
|
193
|
+
await logger.startSession({
|
|
194
|
+
id: crypto.randomUUID(),
|
|
195
|
+
agentType: "linear",
|
|
196
|
+
model,
|
|
197
|
+
provider,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// Create session
|
|
201
|
+
console.error(`Creating session...`);
|
|
202
|
+
const sessionResponse = await client.session.create({
|
|
203
|
+
body: { title: `Plan consolidation: ${issueTitle}` },
|
|
204
|
+
});
|
|
205
|
+
if (!sessionResponse.data) {
|
|
206
|
+
throw new Error("Failed to create session: no data in response");
|
|
207
|
+
}
|
|
208
|
+
const session = sessionResponse.data;
|
|
209
|
+
console.error(`✓ Session created: ${session.id}`);
|
|
210
|
+
// Send prompt to linear agent
|
|
211
|
+
console.error(`Consolidating plans and creating Linear issues with ${AGENT_NAME}...`);
|
|
212
|
+
console.error(`This may take a few moments while the AI consolidates the plans...`);
|
|
213
|
+
const promptResponse = await client.session.prompt({
|
|
214
|
+
path: { id: session.id },
|
|
215
|
+
body: {
|
|
216
|
+
model: {
|
|
217
|
+
providerID: provider,
|
|
218
|
+
modelID: model,
|
|
219
|
+
},
|
|
220
|
+
agent: AGENT_NAME, // Use the linear agent
|
|
221
|
+
parts: [{ type: "text", text: prompt }],
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
if (!promptResponse.data) {
|
|
225
|
+
throw new Error("Failed to get response: no data in response");
|
|
226
|
+
}
|
|
227
|
+
// Check for errors
|
|
228
|
+
const responseInfo = promptResponse.data.info;
|
|
229
|
+
if (responseInfo?.error) {
|
|
230
|
+
const err = responseInfo.error;
|
|
231
|
+
const errorName = err.name;
|
|
232
|
+
const errorData = "data" in err ? err.data : undefined;
|
|
233
|
+
const errorMessage = errorData && "message" in errorData ? errorData.message : JSON.stringify(errorData);
|
|
234
|
+
throw new Error(`Provider error: ${errorName}: ${errorMessage}`);
|
|
235
|
+
}
|
|
236
|
+
// Extract consolidated plan and Linear issue creation results
|
|
237
|
+
const resultText = extractTextFromParts(promptResponse.data.parts);
|
|
238
|
+
if (resultText.length === 0) {
|
|
239
|
+
throw new Error("Empty response from linear agent");
|
|
240
|
+
}
|
|
241
|
+
console.error("");
|
|
242
|
+
console.error(`${"=".repeat(60)}`);
|
|
243
|
+
console.error(`SUCCESS!`);
|
|
244
|
+
console.error(`${"=".repeat(60)}`);
|
|
245
|
+
console.error(`Consolidated plan and Linear issues: ${resultText.length} characters`);
|
|
246
|
+
console.error(`Session ID: ${session.id}`);
|
|
247
|
+
console.error("");
|
|
248
|
+
// Output result to stdout (this will be captured by workflows)
|
|
249
|
+
console.log(resultText);
|
|
250
|
+
// End logging session successfully and sync to cloud
|
|
251
|
+
if (logger) {
|
|
252
|
+
await logger.endSession("completed");
|
|
253
|
+
await logger.syncToCloud();
|
|
254
|
+
}
|
|
255
|
+
process.exit(0);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
259
|
+
console.error("");
|
|
260
|
+
console.error(`${"=".repeat(60)}`);
|
|
261
|
+
console.error("ERROR!");
|
|
262
|
+
console.error(`${"=".repeat(60)}`);
|
|
263
|
+
console.error(`Error: ${errorMessage}`);
|
|
264
|
+
if (error instanceof Error && error.stack) {
|
|
265
|
+
console.error("Stack trace:", error.stack);
|
|
266
|
+
}
|
|
267
|
+
console.error("");
|
|
268
|
+
// End logging session with error and sync to cloud
|
|
269
|
+
if (logger) {
|
|
270
|
+
await logger.endSession("error", errorMessage);
|
|
271
|
+
await logger.syncToCloud();
|
|
272
|
+
}
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
console.error("Shutting down OpenCode server...");
|
|
277
|
+
server.close();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Run the main function
|
|
281
|
+
main().catch((error) => {
|
|
282
|
+
console.error("FATAL ERROR:", error);
|
|
283
|
+
process.exit(1);
|
|
284
|
+
});
|
|
285
|
+
//# sourceMappingURL=linear-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-agent.js","sourceRoot":"","sources":["../../../src/agents/linear-agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnF,6DAA6D;AAC7D,iEAAiE;AAEjE,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,4DAA4D;AAC5D,KAAK,UAAU,cAAc;IAC3B,MAAM,a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;QACnC,OAAO,CAAC,KAAK,CAAC,UAAU,YAAY,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAElB,mDAAmD;QACnD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/C,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,wBAAwB;AACxB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* planning-agent.ts
|
|
4
|
+
*
|
|
5
|
+
* Generates an implementation plan using a custom planning agent.
|
|
6
|
+
* The planning agent is configured for read-only operations with web research capabilities.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* planning-agent.ts <feature-description>
|
|
10
|
+
*
|
|
11
|
+
* Environment variables:
|
|
12
|
+
* - PROVIDER (optional, defaults to 'anthropic')
|
|
13
|
+
* Supported values: anthropic, openai, google
|
|
14
|
+
*
|
|
15
|
+
* API Keys (required based on provider):
|
|
16
|
+
* - ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN (for provider=anthropic)
|
|
17
|
+
* - OPENAI_API_KEY (for provider=openai)
|
|
18
|
+
* - GOOGLE_GENERATIVE_AI_API_KEY (for provider=google)
|
|
19
|
+
*
|
|
20
|
+
* - MODEL (optional, defaults to provider-specific model)
|
|
21
|
+
* anthropic: claude-haiku-4-5-20251001
|
|
22
|
+
* openai: gpt-4o
|
|
23
|
+
* google: gemini-2.0-flash-exp
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* # Use default (Anthropic Claude)
|
|
27
|
+
* ANTHROPIC_API_KEY=xxx planning-agent.ts "Add user authentication"
|
|
28
|
+
*
|
|
29
|
+
* # Use OpenAI GPT-4
|
|
30
|
+
* PROVIDER=openai OPENAI_API_KEY=xxx planning-agent.ts "Add user authentication"
|
|
31
|
+
*
|
|
32
|
+
* # Use Google Gemini with custom model
|
|
33
|
+
* PROVIDER=google GOOGLE_GENERATIVE_AI_API_KEY=xxx MODEL=gemini-1.5-pro planning-agent.ts "Add user authentication"
|
|
34
|
+
*/
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=planning-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning-agent.d.ts","sourceRoot":"","sources":["../../../src/agents/planning-agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG"}
|