refactor: complete action testing system overhaul
- Removed /scratch directory, now cloning pullfrogai/scratch as needed - Implemented new play.ts testing system with local and Docker/act modes - Added environment variable propagation to cloned test repositories - Created minimal .act-dist approach to avoid pnpm symlink issues with Docker - Migrated from dist/index.js to entry.cjs bundled output - Added TypeScript fixture support with MainParams type safety - Organized all test fixtures in fixtures/ directory - Updated publish workflow to trigger on package.json changes - Removed unnecessary INPUT_ANTHROPIC_API_KEY references - Added comprehensive documentation for new testing system - Fixed pre-commit hook to use entry.cjs instead of dist/
This commit is contained in:
@@ -1,36 +1,54 @@
|
||||
import * as core from "@actions/core";
|
||||
import { ClaudeAgent } from "./agents";
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
export interface MainParams {
|
||||
prompt: string;
|
||||
anthropicApiKey?: string;
|
||||
}
|
||||
|
||||
export interface MainResult {
|
||||
success: boolean;
|
||||
output?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export async function main(params: MainParams): Promise<MainResult> {
|
||||
try {
|
||||
// Get inputs
|
||||
const prompt = core.getInput("prompt", { required: true });
|
||||
const anthropicApiKey = core.getInput("anthropic_api_key", { required: true });
|
||||
// Use provided API key or fall back to environment variable
|
||||
const anthropicApiKey =
|
||||
params.anthropicApiKey || process.env.ANTHROPIC_API_KEY;
|
||||
|
||||
if (!anthropicApiKey) {
|
||||
throw new Error("anthropic_api_key is required");
|
||||
}
|
||||
|
||||
core.info(`→ Starting agent run with Claude Code`);
|
||||
// core.info(`Prompt: ${prompt}`);
|
||||
|
||||
// Create and install the Claude agent
|
||||
const agent = new ClaudeAgent({ apiKey: anthropicApiKey });
|
||||
await agent.install();
|
||||
|
||||
// Execute the agent with the prompt
|
||||
const result = await agent.execute(prompt);
|
||||
const result = await agent.execute(params.prompt);
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(result.error || "Agent execution failed");
|
||||
return {
|
||||
success: false,
|
||||
error: result.error || "Agent execution failed",
|
||||
output: result.output,
|
||||
};
|
||||
}
|
||||
|
||||
// Set outputs
|
||||
core.setOutput("status", "success");
|
||||
core.setOutput("prompt", prompt);
|
||||
core.setOutput("output", result.output || "");
|
||||
return {
|
||||
success: true,
|
||||
output: result.output || "",
|
||||
};
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
||||
core.setFailed(`Action failed: ${errorMessage}`);
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : "Unknown error occurred";
|
||||
return {
|
||||
success: false,
|
||||
error: errorMessage,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user