Move things to external.ts

This commit is contained in:
Colin McDonnell
2025-11-19 16:02:37 -08:00
parent 7e0dcd5374
commit e3a7b09df4
10 changed files with 1252 additions and 1219 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import type { Payload } from "../external.ts";
import { ghPullfrogMcpName } from "../mcp/index.ts";
import { ghPullfrogMcpName } from "../external.ts";
import { modes } from "../modes.ts";
export const addInstructions = (payload: Payload) =>
+327 -327
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env node
/**
* Entry point for GitHub Action
*/
+33 -1
View File
@@ -1,6 +1,38 @@
import type { AgentName } from "./main.ts";
/**
* ⚠️ NO IMPORTS except modes.ts - this file is imported by Next.js and must avoid pulling in backend code.
* All shared constants, types, and data used by both the Next.js app and the action runtime live here.
* Other files in action/ re-export from this file for backward compatibility.
*/
import type { Mode } from "./modes.ts";
// mcp name constant
export const ghPullfrogMcpName = "gh-pullfrog";
// agent manifest - static metadata about available agents
export const agentsManifest = {
claude: {
name: "claude",
apiKeys: ["anthropic_api_key"],
},
codex: {
name: "codex",
apiKeys: ["openai_api_key"],
},
cursor: {
name: "cursor",
apiKeys: ["cursor_api_key"],
},
gemini: {
name: "gemini",
apiKeys: ["google_api_key", "gemini_api_key"],
},
} as const;
// agent name type - union of agent slugs
export type AgentName = keyof typeof agentsManifest;
// payload type for agent execution
export type Payload = {
"~pullfrog": true;
+8 -7
View File
@@ -5,7 +5,7 @@ import { join } from "node:path";
import { flatMorph } from "@ark/util";
import { type } from "arktype";
import { agents } from "./agents/index.ts";
import type { Payload } from "./external.ts";
import type { AgentName as AgentNameType, Payload } from "./external.ts";
import { createMcpConfigs } from "./mcp/config.ts";
import { modes } from "./modes.ts";
import packageJson from "./package.json" with { type: "json" };
@@ -19,8 +19,9 @@ import {
} from "./utils/github.ts";
import { setupGitAuth, 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
export const AgentName = type.enumerated(...Object.values(agents).map((agent) => agent.name));
export type AgentName = typeof AgentName.infer;
export const AgentInputKey = type.enumerated(
...Object.values(agents).flatMap((agent) => agent.inputKeys)
@@ -34,7 +35,7 @@ const keyInputDefs = flatMorph(agents, (_, agent) =>
export const Inputs = type({
prompt: "string",
...keyInputDefs,
"agent?": AgentName.or("undefined"),
"agent?": type.enumerated(...Object.values(agents).map((agent) => agent.name)).or("undefined"),
});
export type Inputs = typeof Inputs.infer;
@@ -129,8 +130,8 @@ interface MainContext {
githubInstallationToken: string;
tokenToRevoke: string | null;
repoContext: RepoContext;
agentName: AgentName;
agent: (typeof agents)[AgentName];
agentName: AgentNameType;
agent: (typeof agents)[AgentNameType];
sharedTempDir: string;
mcpLogPath: string;
pollInterval: NodeJS.Timeout | null;
@@ -156,7 +157,7 @@ async function initializeContext(
githubInstallationToken,
tokenToRevoke,
repoContext,
agentName: "claude" as AgentName,
agentName: "claude" as AgentNameType,
agent: agents.claude,
sharedTempDir: "",
mcpLogPath: "",
@@ -230,7 +231,7 @@ async function installAgentCli(ctx: MainContext): Promise<void> {
function validateApiKey(ctx: MainContext): void {
const matchingInputKey = ctx.agent.inputKeys.find(
(inputKey) => ctx.inputs[inputKey as AgentInputKey]
(inputKey: string) => ctx.inputs[inputKey as AgentInputKey]
);
if (!matchingInputKey) {
throwMissingApiKeyError({
+876 -876
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -6,7 +6,7 @@ import type { McpStdioServerConfig } from "@anthropic-ai/claude-agent-sdk";
import { fromHere } from "@ark/fs";
import type { Mode } from "../modes.ts";
import { parseRepoContext } from "../utils/github.ts";
import { ghPullfrogMcpName } from "./index.ts";
import { ghPullfrogMcpName } from "../external.ts";
export type McpName = typeof ghPullfrogMcpName;
+2 -4
View File
@@ -1,4 +1,2 @@
// for reasos this can't live alongide config.ts
// because its imported into the frontend UI
// and we don't want to pull in FastMCP, etc
export const ghPullfrogMcpName = "gh-pullfrog";
// re-export from external.ts for backward compatibility
export { ghPullfrogMcpName } from "../external.ts";
+1 -1
View File
@@ -1,4 +1,4 @@
import { ghPullfrogMcpName } from "./mcp/index.ts";
import { ghPullfrogMcpName } from "./external.ts";
export interface Mode {
name: string;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { AgentName } from "../main.ts";
import type { AgentName } from "../external.ts";
import { log } from "./cli.ts";
import type { RepoContext } from "./github.ts";