diff --git a/action.yml b/action.yml index 348f2f6..56be1e2 100644 --- a/action.yml +++ b/action.yml @@ -10,9 +10,6 @@ inputs: anthropic_api_key: description: "Anthropic API key for Claude Code authentication" required: false - github_installation_token: - description: "GitHub App installation token" - required: false runs: using: "composite" diff --git a/agents/claude.ts b/agents/claude.ts index 55de609..b9db502 100644 --- a/agents/claude.ts +++ b/agents/claude.ts @@ -10,6 +10,7 @@ import type { Agent, AgentConfig, AgentResult } from "./types.ts"; */ export class ClaudeAgent implements Agent { private apiKey: string; + private githubInstallationToken?: string; public runStats = { toolsUsed: 0, turns: 0, @@ -21,6 +22,7 @@ export class ClaudeAgent implements Agent { throw new Error("Claude agent requires an API key"); } this.apiKey = config.apiKey; + this.githubInstallationToken = config.githubInstallationToken; } /** @@ -90,13 +92,13 @@ export class ClaudeAgent implements Agent { "bypassPermissions", ]; - if (!process.env.GITHUB_INSTALLATION_TOKEN) { + if (!this.githubInstallationToken) { throw new Error( "GITHUB_INSTALLATION_TOKEN is required for GitHub integration" ); } - const mcpConfig = createMcpConfig(process.env.GITHUB_INSTALLATION_TOKEN); + const mcpConfig = createMcpConfig(this.githubInstallationToken); console.log("📋 MCP Config:", mcpConfig); args.push("--mcp-config", mcpConfig); diff --git a/main.ts b/main.ts index f2991bc..c8e3d26 100644 --- a/main.ts +++ b/main.ts @@ -1,11 +1,11 @@ import * as core from "@actions/core"; import { type } from "arktype"; import { ClaudeAgent } from "./agents/claude.ts"; +import { setupGitHubInstallationToken } from "./utils/github.ts"; export const Inputs = type({ prompt: "string", "anthropic_api_key?": "string | undefined", - "github_installation_token?": "string | undefined", }); export type ActionInputs = typeof Inputs.infer; @@ -20,7 +20,13 @@ export async function main(inputs: ActionInputs): Promise { try { core.info(`→ Starting agent run with Claude Code`); - const agent = new ClaudeAgent({ apiKey: inputs.anthropic_api_key! }); + // Setup GitHub installation token + const githubInstallationToken = await setupGitHubInstallationToken(); + + const agent = new ClaudeAgent({ + apiKey: inputs.anthropic_api_key!, + githubInstallationToken + }); await agent.install(); const result = await agent.execute(inputs.prompt); diff --git a/package.json b/package.json index f05639a..858cb25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pullfrog/action", - "version": "0.0.45", + "version": "0.0.46", "type": "module", "files": [ "index.js", diff --git a/play.ts b/play.ts index 4a33086..7b7b190 100644 --- a/play.ts +++ b/play.ts @@ -7,7 +7,6 @@ import { config } from "dotenv"; import { type ActionInputs, main } from "./main.ts"; import packageJson from "./package.json" with { type: "json" }; import { runAct } from "./utils/act.ts"; -import { setupGitHubInstallationToken } from "./utils/github.ts"; import { setupTestRepo } from "./utils/setup.ts"; config(); @@ -36,16 +35,9 @@ export async function run( console.log(prompt); console.log("─".repeat(50)); - console.log("🔑 Setting up GitHub installation token..."); - const installationToken = await setupGitHubInstallationToken(); - process.env.GITHUB_INSTALLATION_TOKEN = installationToken; - - console.log("✅ GitHub installation token setup successfully"); - const inputs: ActionInputs = { prompt, anthropic_api_key: process.env.ANTHROPIC_API_KEY, - github_installation_token: installationToken, }; const result = await main(inputs);