merge main

This commit is contained in:
Shawn Morreau
2025-11-21 15:47:20 -05:00
5 changed files with 8 additions and 28 deletions
-9
View File
@@ -7,15 +7,6 @@ inputs:
description: "Prompt to send to Claude Code"
required: true
default: "Hello from Claude Code!"
defaultAgent:
description: "Default agent to use. Overridden by payload.agent if present."
required: false
type: choice
options:
- claude
- codex
- cursor
- gemini
anthropic_api_key:
description: "Anthropic API key for Claude Code authentication"
required: false
+1 -2
View File
@@ -7,7 +7,7 @@
import * as core from "@actions/core";
import { flatMorph } from "@ark/util";
import { agents } from "./agents/index.ts";
import { AgentName, type Inputs, main } from "./main.ts";
import { type Inputs, main } from "./main.ts";
import { log } from "./utils/cli.ts";
async function run(): Promise<void> {
@@ -22,7 +22,6 @@ async function run(): Promise<void> {
try {
const inputs: Required<Inputs> = {
prompt: core.getInput("prompt", { required: true }),
defaultAgent: core.getInput("defaultAgent") ? AgentName.assert(core.getInput("defaultAgent")) : undefined,
...flatMorph(agents, (_, agent) =>
agent.apiKeyNames.map((inputKey) => [inputKey, core.getInput(inputKey)])
),
+7 -15
View File
@@ -5,6 +5,7 @@ import { join } from "node:path";
import { flatMorph } from "@ark/util";
import { type } from "arktype";
import { agents } from "./agents/index.ts";
import type { AgentResult } from "./agents/shared.ts";
import type { AgentName, AgentName as AgentNameType, Payload } from "./external.ts";
import { agentsManifest } from "./external.ts";
import { createMcpConfigs } from "./mcp/config.ts";
@@ -23,7 +24,7 @@ import { setupGitAuth, setupGitBranch, setupGitConfig } from "./utils/setup.ts";
// runtime validation using agents (needed for ArkType)
// Note: The AgentName type is defined in external.ts, this is the runtime validator
const AGENT_OVERRIDE: AgentName | null = null;
const AGENT_OVERRIDE: AgentName | null = "cursor";
export const AgentInputKey = type.enumerated(
...Object.values(agents).flatMap((agent) => agent.apiKeyNames)
);
@@ -36,9 +37,6 @@ const keyInputDefs = flatMorph(agents, (_, agent) =>
export const Inputs = type({
prompt: "string",
...keyInputDefs,
"defaultAgent?": type
.enumerated(...Object.values(agents).map((agent) => agent.name))
.or("undefined"),
});
export type Inputs = typeof Inputs.infer;
@@ -193,11 +191,9 @@ async function determineAgent(
repoContext: ctx.repoContext,
});
// precedence: override agent > payload.agent > inputs.defaultAgent > repoSettings.defaultAgent > first available agent
const configuredAgentName =
ctx.agentName =
(process.env.NODE_ENV === "development" && AGENT_OVERRIDE) ||
ctx.payload.agent ||
ctx.inputs.defaultAgent ||
repoSettings.defaultAgent ||
null;
@@ -282,9 +278,7 @@ async function installAgentCli(ctx: MainContext): Promise<void> {
}
function validateApiKey(ctx: MainContext): void {
const matchingInputKey = ctx.agent.apiKeyNames.find(
(inputKey: string) => ctx.inputs[inputKey as AgentInputKey]
);
const matchingInputKey = ctx.agent.apiKeyNames.find((inputKey) => ctx.inputs[inputKey]);
if (!matchingInputKey) {
throwMissingApiKeyError({
agentName: ctx.agentName,
@@ -292,10 +286,10 @@ function validateApiKey(ctx: MainContext): void {
repoContext: ctx.repoContext,
});
}
ctx.apiKey = ctx.inputs[matchingInputKey as AgentInputKey]!;
ctx.apiKey = ctx.inputs[matchingInputKey]!;
}
async function runAgent(ctx: MainContext): Promise<import("./agents/shared.ts").AgentResult> {
async function runAgent(ctx: MainContext): Promise<AgentResult> {
log.info(`Running ${ctx.agentName}...`);
log.box(ctx.payload.prompt, { title: "Prompt" });
@@ -308,9 +302,7 @@ async function runAgent(ctx: MainContext): Promise<import("./agents/shared.ts").
});
}
async function handleAgentResult(
result: import("./agents/shared.ts").AgentResult
): Promise<MainResult> {
async function handleAgentResult(result: AgentResult): Promise<MainResult> {
if (!result.success) {
return {
success: false,
-1
View File
@@ -27,7 +27,6 @@ export async function run(prompt: string): Promise<AgentResult> {
// we don't need to extract it here since main() will parse the payload
const inputs: Required<Inputs> = {
prompt,
defaultAgent: "gemini",
...flatMorph(agents, (_, agent) =>
agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]])
),
-1
View File
@@ -1,5 +1,4 @@
import type { AgentName } from "../external.ts";
import { log } from "./cli.ts";
import type { RepoContext } from "./github.ts";
export interface Mode {