Compare commits

...

3 Commits

Author SHA1 Message Date
David Blass d03debab4b bump version 2025-10-14 15:56:27 -04:00
David Blass a05829f781 fix type errors 2025-10-14 14:58:46 -04:00
David Blass c8ba7940e3 fix installation token propagation 2025-10-13 17:21:14 -04:00
7 changed files with 23 additions and 30 deletions
-3
View File
@@ -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"
+4 -2
View File
@@ -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);
+5 -9
View File
@@ -1,13 +1,9 @@
import type { MainParams } from "../main.ts";
import type { Inputs } from "../main.ts";
const testParams = {
inputs: {
prompt:
"List all files in the current directory, then create a file called dynamic-test.txt with the content 'This was loaded from a TypeScript file!', then delete it.",
anthropic_api_key: "sk-test-key",
},
env: {},
cwd: process.cwd(),
} satisfies MainParams;
prompt:
"List all files in the current directory, then create a file called dynamic-test.txt with the content 'This was loaded from a TypeScript file!', then delete it.",
anthropic_api_key: "sk-test-key",
} satisfies Inputs;
export default testParams;
+1 -1
View File
@@ -6,7 +6,7 @@
export { ClaudeAgent } from "./agents/claude.ts";
export type { Agent, AgentConfig, AgentResult } from "./agents/types.ts";
export {
type ActionInputs as ExecutionInputs,
type Inputs as ExecutionInputs,
type MainResult,
main,
} from "./main.ts";
+10 -4
View File
@@ -1,14 +1,14 @@
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;
export type Inputs = typeof Inputs.infer;
export interface MainResult {
success: boolean;
@@ -16,11 +16,17 @@ export interface MainResult {
error?: string | undefined;
}
export async function main(inputs: ActionInputs): Promise<MainResult> {
export async function main(inputs: Inputs): Promise<MainResult> {
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);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@pullfrog/action",
"version": "0.0.45",
"version": "0.0.47",
"type": "module",
"files": [
"index.js",
+2 -10
View File
@@ -4,10 +4,9 @@ import { pathToFileURL } from "node:url";
import { fromHere } from "@ark/fs";
import arg from "arg";
import { config } from "dotenv";
import { type ActionInputs, main } from "./main.ts";
import { type Inputs, 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 = {
const inputs: Inputs = {
prompt,
anthropic_api_key: process.env.ANTHROPIC_API_KEY,
github_installation_token: installationToken,
};
const result = await main(inputs);