swellai 1.0.1 → 1.0.3
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/src/cli/install.d.ts.map +1 -1
- package/dist/src/cli/install.js +7 -3
- package/dist/src/cli/install.js.map +1 -1
- package/package.json +2 -2
- package/templates/actions/detect-runtime/action.yml +113 -0
- package/templates/actions/fetch-agents/action.yml +34 -0
- package/templates/actions/get-issue-details/action.yml +60 -0
- package/templates/actions/setup-claude/action.yml +45 -0
- package/templates/actions/setup-opencode/action.yml +128 -0
- package/templates/workflows/claude-plan.yml +4 -4
- package/dist/agents/linear-agent.d.ts +0 -32
- package/dist/agents/linear-agent.d.ts.map +0 -1
- package/dist/agents/linear-agent.js +0 -263
- package/dist/agents/linear-agent.js.map +0 -1
- package/dist/agents/planning-agent.d.ts +0 -36
- package/dist/agents/planning-agent.d.ts.map +0 -1
- package/dist/agents/planning-agent.js +0 -248
- package/dist/agents/planning-agent.js.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -102
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/install.d.ts +0 -11
- package/dist/cli/install.d.ts.map +0 -1
- package/dist/cli/install.js +0 -257
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/manifest.d.ts +0 -27
- package/dist/cli/manifest.d.ts.map +0 -1
- package/dist/cli/manifest.js +0 -65
- package/dist/cli/manifest.js.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/lib/claude-agent-sdk.d.ts +0 -73
- package/dist/lib/claude-agent-sdk.d.ts.map +0 -1
- package/dist/lib/claude-agent-sdk.js +0 -114
- package/dist/lib/claude-agent-sdk.js.map +0 -1
- package/dist/lib/conversation-logger.d.ts +0 -66
- package/dist/lib/conversation-logger.d.ts.map +0 -1
- package/dist/lib/conversation-logger.js +0 -159
- package/dist/lib/conversation-logger.js.map +0 -1
- package/dist/lib/opencode.d.ts +0 -68
- package/dist/lib/opencode.d.ts.map +0 -1
- package/dist/lib/opencode.js +0 -151
- package/dist/lib/opencode.js.map +0 -1
- package/dist/lib/turso-schema.d.ts +0 -13
- package/dist/lib/turso-schema.d.ts.map +0 -1
- package/dist/lib/turso-schema.js +0 -69
- package/dist/lib/turso-schema.js.map +0 -1
- package/dist/lib/turso.d.ts +0 -56
- package/dist/lib/turso.d.ts.map +0 -1
- package/dist/lib/turso.js +0 -144
- package/dist/lib/turso.js.map +0 -1
- package/dist/lib/types.d.ts +0 -31
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js +0 -20
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -34
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -72
- package/dist/lib/utils.js.map +0 -1
|
@@ -1,263 +0,0 @@
|
|
|
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
|
-
console.error(`\n${"=".repeat(60)}`);
|
|
100
|
-
console.error(`Linear Agent - Plan Consolidation`);
|
|
101
|
-
console.error(`${"=".repeat(60)}`);
|
|
102
|
-
console.error(`Provider: ${provider}`);
|
|
103
|
-
console.error(`Model: ${model}`);
|
|
104
|
-
console.error(`Issue: ${issueTitle}`);
|
|
105
|
-
console.error(`GitHub URL: ${githubIssueUrl}`);
|
|
106
|
-
console.error(`Linear Team: ${linearTeamId}`);
|
|
107
|
-
console.error(`Linear Project: ${linearProjectId || "(none)"}`);
|
|
108
|
-
console.error("");
|
|
109
|
-
// Initialize conversation logger (optional)
|
|
110
|
-
const logger = await createConversationLogger();
|
|
111
|
-
if (logger) {
|
|
112
|
-
console.error(`✓ Conversation logging enabled`);
|
|
113
|
-
}
|
|
114
|
-
// Read external prompt template file
|
|
115
|
-
let promptTemplate;
|
|
116
|
-
let promptFile;
|
|
117
|
-
try {
|
|
118
|
-
promptFile = await findPromptFile();
|
|
119
|
-
promptTemplate = await readFile(promptFile, "utf-8");
|
|
120
|
-
console.error(`✓ Loaded prompt template from ${promptFile}`);
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
124
|
-
console.error(`✗ Failed to read prompt file: ${errorMessage}`);
|
|
125
|
-
console.error("Please create consolidate-and-create-linear.md file in the prompts directory");
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
// Replace placeholders in the prompt template
|
|
129
|
-
const prompt = promptTemplate
|
|
130
|
-
.replace(/\{\{ANTHROPIC_PLAN\}\}/g, anthropicPlan)
|
|
131
|
-
.replace(/\{\{OPENAI_PLAN\}\}/g, openaiPlan)
|
|
132
|
-
.replace(/\{\{GOOGLE_PLAN\}\}/g, googlePlan)
|
|
133
|
-
.replace(/\{\{GITHUB_ISSUE_URL\}\}/g, githubIssueUrl)
|
|
134
|
-
.replace(/\{\{ISSUE_TITLE\}\}/g, issueTitle)
|
|
135
|
-
.replace(/\{\{LINEAR_TEAM_ID\}\}/g, linearTeamId)
|
|
136
|
-
.replace(/\{\{LINEAR_PROJECT_ID\}\}/g, linearProjectId);
|
|
137
|
-
console.error(`✓ Filled prompt template with plans and context`);
|
|
138
|
-
// Create OpenCode server with linear agent configuration
|
|
139
|
-
const { client, server } = await createOpencodeServer({
|
|
140
|
-
provider,
|
|
141
|
-
apiKey,
|
|
142
|
-
model,
|
|
143
|
-
agentName: AGENT_NAME,
|
|
144
|
-
agentDescription: "Consolidate implementation plans and create Linear issues",
|
|
145
|
-
agentPrompt: prompt,
|
|
146
|
-
agentTools: {
|
|
147
|
-
write: false, // No file creation
|
|
148
|
-
edit: false, // No file modification
|
|
149
|
-
bash: true, // Allow shell commands
|
|
150
|
-
read: true, // Allow reading files
|
|
151
|
-
list: true, // Allow listing directories
|
|
152
|
-
glob: true, // Allow file pattern matching
|
|
153
|
-
grep: true, // Allow searching content
|
|
154
|
-
webfetch: true, // Allow web research
|
|
155
|
-
...(linearApiKey && { "mcp__linear__*": true }), // Enable Linear MCP tools if available
|
|
156
|
-
},
|
|
157
|
-
agentPermissions: {
|
|
158
|
-
edit: "deny",
|
|
159
|
-
bash: "allow",
|
|
160
|
-
webfetch: "allow",
|
|
161
|
-
...(linearApiKey && { "mcp__linear__*": "allow" }), // Allow Linear MCP tools if available
|
|
162
|
-
},
|
|
163
|
-
maxSteps: 30,
|
|
164
|
-
linearApiKey,
|
|
165
|
-
});
|
|
166
|
-
// Setup event monitoring
|
|
167
|
-
setupEventMonitoring(client, logger);
|
|
168
|
-
try {
|
|
169
|
-
// Start logging session if logger is available
|
|
170
|
-
if (logger) {
|
|
171
|
-
await logger.startSession({
|
|
172
|
-
id: crypto.randomUUID(),
|
|
173
|
-
agentType: "linear",
|
|
174
|
-
model,
|
|
175
|
-
provider,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
// Create session
|
|
179
|
-
console.error(`Creating session...`);
|
|
180
|
-
const sessionResponse = await client.session.create({
|
|
181
|
-
body: { title: `Plan consolidation: ${issueTitle}` },
|
|
182
|
-
});
|
|
183
|
-
if (!sessionResponse.data) {
|
|
184
|
-
throw new Error("Failed to create session: no data in response");
|
|
185
|
-
}
|
|
186
|
-
const session = sessionResponse.data;
|
|
187
|
-
console.error(`✓ Session created: ${session.id}`);
|
|
188
|
-
// Send prompt to linear agent
|
|
189
|
-
console.error(`Consolidating plans and creating Linear issues with ${AGENT_NAME}...`);
|
|
190
|
-
console.error(`This may take a few moments while the AI consolidates the plans...`);
|
|
191
|
-
const promptResponse = await client.session.prompt({
|
|
192
|
-
path: { id: session.id },
|
|
193
|
-
body: {
|
|
194
|
-
model: {
|
|
195
|
-
providerID: provider,
|
|
196
|
-
modelID: model,
|
|
197
|
-
},
|
|
198
|
-
agent: AGENT_NAME, // Use the linear agent
|
|
199
|
-
parts: [{ type: "text", text: prompt }],
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
if (!promptResponse.data) {
|
|
203
|
-
throw new Error("Failed to get response: no data in response");
|
|
204
|
-
}
|
|
205
|
-
// Check for errors
|
|
206
|
-
const responseInfo = promptResponse.data.info;
|
|
207
|
-
if (responseInfo?.error) {
|
|
208
|
-
const err = responseInfo.error;
|
|
209
|
-
const errorName = err.name;
|
|
210
|
-
const errorData = "data" in err ? err.data : {};
|
|
211
|
-
const errorMessage = "message" in errorData ? errorData.message : JSON.stringify(errorData);
|
|
212
|
-
throw new Error(`Provider error: ${errorName}: ${errorMessage}`);
|
|
213
|
-
}
|
|
214
|
-
// Extract consolidated plan and Linear issue creation results
|
|
215
|
-
const resultText = extractTextFromParts(promptResponse.data.parts);
|
|
216
|
-
if (resultText.length === 0) {
|
|
217
|
-
throw new Error("Empty response from linear agent");
|
|
218
|
-
}
|
|
219
|
-
console.error("");
|
|
220
|
-
console.error(`${"=".repeat(60)}`);
|
|
221
|
-
console.error(`SUCCESS!`);
|
|
222
|
-
console.error(`${"=".repeat(60)}`);
|
|
223
|
-
console.error(`Consolidated plan and Linear issues: ${resultText.length} characters`);
|
|
224
|
-
console.error(`Session ID: ${session.id}`);
|
|
225
|
-
console.error("");
|
|
226
|
-
// Output result to stdout (this will be captured by workflows)
|
|
227
|
-
console.log(resultText);
|
|
228
|
-
// End logging session successfully and sync to cloud
|
|
229
|
-
if (logger) {
|
|
230
|
-
await logger.endSession("completed");
|
|
231
|
-
await logger.syncToCloud();
|
|
232
|
-
}
|
|
233
|
-
process.exit(0);
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
237
|
-
console.error("");
|
|
238
|
-
console.error(`${"=".repeat(60)}`);
|
|
239
|
-
console.error("ERROR!");
|
|
240
|
-
console.error(`${"=".repeat(60)}`);
|
|
241
|
-
console.error(`Error: ${errorMessage}`);
|
|
242
|
-
if (error instanceof Error && error.stack) {
|
|
243
|
-
console.error("Stack trace:", error.stack);
|
|
244
|
-
}
|
|
245
|
-
console.error("");
|
|
246
|
-
// End logging session with error and sync to cloud
|
|
247
|
-
if (logger) {
|
|
248
|
-
await logger.endSession("error", errorMessage);
|
|
249
|
-
await logger.syncToCloud();
|
|
250
|
-
}
|
|
251
|
-
process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
finally {
|
|
254
|
-
console.error("Shutting down OpenCode server...");
|
|
255
|
-
server.close();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
// Run the main function
|
|
259
|
-
main().catch((error) => {
|
|
260
|
-
console.error("FATAL ERROR:", error);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
});
|
|
263
|
-
//# sourceMappingURL=linear-agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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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AElB,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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planning-agent.d.ts","sourceRoot":"","sources":["../../src/agents/planning-agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG"}
|
|
@@ -1,248 +0,0 @@
|
|
|
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
|
-
import { access, readFile } from "node:fs/promises";
|
|
36
|
-
import { join } from "node:path";
|
|
37
|
-
import { createConversationLogger } from "../lib/conversation-logger.js";
|
|
38
|
-
import { createOpencodeServer, setupEventMonitoring } from "../lib/opencode.js";
|
|
39
|
-
import { DEFAULT_MODELS } from "../lib/types.js";
|
|
40
|
-
import { extractTextFromParts, getApiKey, validateProvider } from "../lib/utils.js";
|
|
41
|
-
// Note: __filename and __dirname are not needed here anymore
|
|
42
|
-
// Prompts are resolved from process.cwd() in installed locations
|
|
43
|
-
// ============================================================================
|
|
44
|
-
// Configuration
|
|
45
|
-
// ============================================================================
|
|
46
|
-
const AGENT_NAME = "planning-agent";
|
|
47
|
-
// Helper to find prompt file in multiple possible locations
|
|
48
|
-
async function findPromptFile() {
|
|
49
|
-
const possiblePaths = [
|
|
50
|
-
// Installed location (via installer)
|
|
51
|
-
join(process.cwd(), ".github", "claude-parallel", "prompts", "plan-generation.md"),
|
|
52
|
-
// Source repository location
|
|
53
|
-
join(process.cwd(), "prompts", "plan-generation.md"),
|
|
54
|
-
];
|
|
55
|
-
for (const path of possiblePaths) {
|
|
56
|
-
try {
|
|
57
|
-
await access(path);
|
|
58
|
-
return path;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
// File doesn't exist at this path, try next
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
throw new Error(`Could not find plan-generation.md in any of these locations:\n${possiblePaths.map((p) => ` - ${p}`).join("\n")}`);
|
|
65
|
-
}
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// Main Execution
|
|
68
|
-
// ============================================================================
|
|
69
|
-
async function main() {
|
|
70
|
-
// Parse command line arguments
|
|
71
|
-
const args = process.argv.slice(2);
|
|
72
|
-
if (args.length < 1) {
|
|
73
|
-
console.error("Usage: planning-agent.ts <feature-description>");
|
|
74
|
-
console.error("");
|
|
75
|
-
console.error("Examples:");
|
|
76
|
-
console.error(" # Use default (Anthropic Claude)");
|
|
77
|
-
console.error(' ANTHROPIC_API_KEY=xxx planning-agent.ts "Add user authentication"');
|
|
78
|
-
console.error("");
|
|
79
|
-
console.error(" # Use OpenAI GPT-4");
|
|
80
|
-
console.error(' PROVIDER=openai OPENAI_API_KEY=xxx planning-agent.ts "Add user authentication"');
|
|
81
|
-
console.error("");
|
|
82
|
-
console.error(" # Use Google Gemini");
|
|
83
|
-
console.error(' PROVIDER=google GOOGLE_GENERATIVE_AI_API_KEY=xxx planning-agent.ts "Add user authentication"');
|
|
84
|
-
console.error("");
|
|
85
|
-
console.error("Environment variables:");
|
|
86
|
-
console.error(" PROVIDER - anthropic (default), openai, or google");
|
|
87
|
-
console.error(" MODEL - Override default model for the provider");
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
const featureDescription = args.join(" ");
|
|
91
|
-
// Get provider from environment or use default
|
|
92
|
-
const providerEnv = (process.env.PROVIDER || "anthropic").toLowerCase();
|
|
93
|
-
// Validate provider
|
|
94
|
-
validateProvider(providerEnv);
|
|
95
|
-
const provider = providerEnv;
|
|
96
|
-
// Get API key from environment based on provider
|
|
97
|
-
const apiKey = getApiKey(provider);
|
|
98
|
-
// Get model from environment or use provider-specific default
|
|
99
|
-
const model = process.env.MODEL || DEFAULT_MODELS[provider];
|
|
100
|
-
console.error(`\n${"=".repeat(60)}`);
|
|
101
|
-
console.error(`Planning Agent`);
|
|
102
|
-
console.error(`${"=".repeat(60)}`);
|
|
103
|
-
console.error(`Provider: ${provider}`);
|
|
104
|
-
console.error(`Model: ${model}`);
|
|
105
|
-
console.error(`Feature: ${featureDescription}`);
|
|
106
|
-
console.error("");
|
|
107
|
-
// Initialize conversation logger (optional)
|
|
108
|
-
const logger = await createConversationLogger();
|
|
109
|
-
if (logger) {
|
|
110
|
-
console.error(`✓ Conversation logging enabled`);
|
|
111
|
-
}
|
|
112
|
-
// Read external prompt file
|
|
113
|
-
let prompt;
|
|
114
|
-
let promptFile;
|
|
115
|
-
try {
|
|
116
|
-
promptFile = await findPromptFile();
|
|
117
|
-
prompt = await readFile(promptFile, "utf-8");
|
|
118
|
-
console.error(`✓ Loaded prompt from ${promptFile}`);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
122
|
-
console.error(`✗ Failed to read prompt file: ${errorMessage}`);
|
|
123
|
-
console.error("Please create a plan-generation.md file in the prompts directory");
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
// Create OpenCode server with planning agent configuration
|
|
127
|
-
const { client, server } = await createOpencodeServer({
|
|
128
|
-
provider,
|
|
129
|
-
apiKey,
|
|
130
|
-
model,
|
|
131
|
-
agentName: AGENT_NAME,
|
|
132
|
-
agentDescription: "Generate a comprehensive implementation plan for a given feature",
|
|
133
|
-
agentPrompt: prompt,
|
|
134
|
-
agentTools: {
|
|
135
|
-
write: false, // No file creation
|
|
136
|
-
edit: false, // No file modification
|
|
137
|
-
bash: false, // No shell commands
|
|
138
|
-
read: true, // Allow reading files
|
|
139
|
-
list: true, // Allow listing directories
|
|
140
|
-
glob: true, // Allow file pattern matching
|
|
141
|
-
grep: true, // Allow searching content
|
|
142
|
-
webfetch: true, // Allow web research
|
|
143
|
-
},
|
|
144
|
-
agentPermissions: {
|
|
145
|
-
edit: "deny",
|
|
146
|
-
bash: "deny",
|
|
147
|
-
webfetch: "allow",
|
|
148
|
-
},
|
|
149
|
-
maxSteps: 30,
|
|
150
|
-
});
|
|
151
|
-
// Setup event monitoring
|
|
152
|
-
setupEventMonitoring(client, logger);
|
|
153
|
-
try {
|
|
154
|
-
// Start logging session if logger is available
|
|
155
|
-
if (logger) {
|
|
156
|
-
await logger.startSession({
|
|
157
|
-
id: crypto.randomUUID(),
|
|
158
|
-
agentType: "planning",
|
|
159
|
-
model,
|
|
160
|
-
provider,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
// Create session
|
|
164
|
-
console.error(`Creating session...`);
|
|
165
|
-
const sessionResponse = await client.session.create({
|
|
166
|
-
body: { title: `Plan generation: ${featureDescription}` },
|
|
167
|
-
});
|
|
168
|
-
if (!sessionResponse.data) {
|
|
169
|
-
throw new Error("Failed to create session: no data in response");
|
|
170
|
-
}
|
|
171
|
-
const session = sessionResponse.data;
|
|
172
|
-
console.error(`✓ Session created: ${session.id}`);
|
|
173
|
-
// Send prompt to planning agent
|
|
174
|
-
console.error(`Generating plan with ${AGENT_NAME}...`);
|
|
175
|
-
console.error(`This may take a few moments while the AI generates the plan...`);
|
|
176
|
-
const promptResponse = await client.session.prompt({
|
|
177
|
-
path: { id: session.id },
|
|
178
|
-
body: {
|
|
179
|
-
model: {
|
|
180
|
-
providerID: provider,
|
|
181
|
-
modelID: model,
|
|
182
|
-
},
|
|
183
|
-
agent: AGENT_NAME, // Use the planning agent
|
|
184
|
-
parts: [{ type: "text", text: featureDescription }],
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
if (!promptResponse.data) {
|
|
188
|
-
throw new Error("Failed to get response: no data in response");
|
|
189
|
-
}
|
|
190
|
-
// Check for errors
|
|
191
|
-
const responseInfo = promptResponse.data.info;
|
|
192
|
-
if (responseInfo?.error) {
|
|
193
|
-
const err = responseInfo.error;
|
|
194
|
-
const errorName = err.name;
|
|
195
|
-
const errorData = "data" in err ? err.data : {};
|
|
196
|
-
const errorMessage = "message" in errorData ? errorData.message : JSON.stringify(errorData);
|
|
197
|
-
throw new Error(`Provider error: ${errorName}: ${errorMessage}`);
|
|
198
|
-
}
|
|
199
|
-
// Extract plan text
|
|
200
|
-
const planText = extractTextFromParts(promptResponse.data.parts);
|
|
201
|
-
if (planText.length === 0) {
|
|
202
|
-
throw new Error("Empty response from planning agent");
|
|
203
|
-
}
|
|
204
|
-
console.error("");
|
|
205
|
-
console.error(`${"=".repeat(60)}`);
|
|
206
|
-
console.error(`SUCCESS!`);
|
|
207
|
-
console.error(`${"=".repeat(60)}`);
|
|
208
|
-
console.error(`Generated plan: ${planText.length} characters`);
|
|
209
|
-
console.error(`Session ID: ${session.id}`);
|
|
210
|
-
console.error("");
|
|
211
|
-
// Output plan to stdout (this will be captured by scripts)
|
|
212
|
-
console.log(planText);
|
|
213
|
-
// End logging session successfully and sync to cloud
|
|
214
|
-
if (logger) {
|
|
215
|
-
await logger.endSession("completed");
|
|
216
|
-
await logger.syncToCloud();
|
|
217
|
-
}
|
|
218
|
-
process.exit(0);
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
222
|
-
console.error("");
|
|
223
|
-
console.error(`${"=".repeat(60)}`);
|
|
224
|
-
console.error("ERROR!");
|
|
225
|
-
console.error(`${"=".repeat(60)}`);
|
|
226
|
-
console.error(`Error: ${errorMessage}`);
|
|
227
|
-
if (error instanceof Error && error.stack) {
|
|
228
|
-
console.error("Stack trace:", error.stack);
|
|
229
|
-
}
|
|
230
|
-
console.error("");
|
|
231
|
-
// End logging session with error and sync to cloud
|
|
232
|
-
if (logger) {
|
|
233
|
-
await logger.endSession("error", errorMessage);
|
|
234
|
-
await logger.syncToCloud();
|
|
235
|
-
}
|
|
236
|
-
process.exit(1);
|
|
237
|
-
}
|
|
238
|
-
finally {
|
|
239
|
-
console.error("Shutting down OpenCode server...");
|
|
240
|
-
server.close();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// Run the main function
|
|
244
|
-
main().catch((error) => {
|
|
245
|
-
console.error("FATAL ERROR:", error);
|
|
246
|
-
process.exit(1);
|
|
247
|
-
});
|
|
248
|
-
//# sourceMappingURL=planning-agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planning-agent.js","sourceRoot":"","sources":["../../src/agents/planning-agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,6DAA6D;AAC7D,iEAAiE;AAEjE,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC,4DAA4D;AAC5D,KAAK,UAAU,cAAc;IAC3B,MAAM,aAAa,GAAG;QACpB,qCAAqC;QACrC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,oBAAoB,CAAC;QAClF,6BAA6B;QAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,oBAAoB,CAAC;KACrD,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,MA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,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"}
|
package/dist/cli/index.d.ts
DELETED
package/dist/cli/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|