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