Skip to content

Commit ede6cfd

Browse files
committed
Implement Claude Code basics
1 parent 7745a0b commit ede6cfd

File tree

14 files changed

+7723
-628
lines changed

14 files changed

+7723
-628
lines changed

agents/claude.ts

Lines changed: 324 additions & 36 deletions
Large diffs are not rendered by default.

agents/factory.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

agents/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from "./claude";
2-
export * from "./factory";
32
export * from "./types";

index.cjs

Lines changed: 6516 additions & 505 deletions
Large diffs are not rendered by default.

index.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
import * as core from "@actions/core";
2-
import { createAgent } from "./agents/factory";
1+
import { main } from "./main";
32

4-
async function main(): Promise<void> {
5-
try {
6-
// Get inputs
7-
const prompt = core.getInput("prompt", { required: true });
8-
const anthropicApiKey = core.getInput("anthropic_api_key", { required: true });
9-
10-
if (!anthropicApiKey) {
11-
throw new Error("anthropic_api_key is required");
12-
}
13-
14-
core.info(`🐸 Pullfrog Claude Code Action starting...`);
15-
core.info(`Prompt: ${prompt}`);
16-
17-
// Create and install the Claude agent
18-
const agent = createAgent("claude", { apiKey: anthropicApiKey });
19-
await agent.install();
20-
21-
// Execute the agent with the prompt
22-
const result = await agent.execute(prompt);
23-
24-
if (!result.success) {
25-
throw new Error(result.error || "Agent execution failed");
26-
}
27-
28-
// Set outputs
29-
core.setOutput("status", "success");
30-
core.setOutput("prompt", prompt);
31-
core.setOutput("output", result.output || "");
32-
} catch (error) {
33-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
34-
core.setFailed(`Action failed: ${errorMessage}`);
35-
}
36-
}
37-
38-
// Execute main function
393
main();

main.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as core from "@actions/core";
2+
import { ClaudeAgent } from "./agents";
3+
4+
export async function main(): Promise<void> {
5+
try {
6+
// Get inputs
7+
const prompt = core.getInput("prompt", { required: true });
8+
const anthropicApiKey = core.getInput("anthropic_api_key", { required: true });
9+
10+
if (!anthropicApiKey) {
11+
throw new Error("anthropic_api_key is required");
12+
}
13+
14+
core.info(`→ Starting agent run with Claude Code`);
15+
// core.info(`Prompt: ${prompt}`);
16+
17+
// Create and install the Claude agent
18+
const agent = new ClaudeAgent({ apiKey: anthropicApiKey });
19+
await agent.install();
20+
21+
// Execute the agent with the prompt
22+
const result = await agent.execute(prompt);
23+
24+
if (!result.success) {
25+
throw new Error(result.error || "Agent execution failed");
26+
}
27+
28+
// Set outputs
29+
core.setOutput("status", "success");
30+
core.setOutput("prompt", prompt);
31+
core.setOutput("output", result.output || "");
32+
} catch (error) {
33+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
34+
core.setFailed(`Action failed: ${errorMessage}`);
35+
}
36+
}

0 commit comments

Comments
 (0)