diff --git a/agents/claude.ts b/agents/claude.ts index 68b98e1..4de7c40 100644 --- a/agents/claude.ts +++ b/agents/claude.ts @@ -3,12 +3,11 @@ import { createWriteStream, existsSync, rmSync } from "node:fs"; import { mkdtemp } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; - import { pipeline } from "node:stream/promises"; import { query, type SDKMessage } from "@anthropic-ai/claude-agent-sdk"; import packageJson from "../package.json" with { type: "json" }; import { log } from "../utils/cli.ts"; -import { agent, instructions } from "./shared.ts"; +import { addInstructions, agent } from "./shared.ts"; export const claude = agent({ name: "claude", @@ -94,7 +93,7 @@ export const claude = agent({ process.env.ANTHROPIC_API_KEY = apiKey; const queryInstance = query({ - prompt: `${instructions}\n\n****** USER PROMPT ******\n${prompt}`, + prompt: addInstructions(prompt), options: { permissionMode: "bypassPermissions", mcpServers, diff --git a/agents/codex.ts b/agents/codex.ts index bb533b0..4eeac46 100644 --- a/agents/codex.ts +++ b/agents/codex.ts @@ -1,7 +1,7 @@ import { spawnSync } from "node:child_process"; import { findCliPath, log } from "../utils/cli.ts"; -import { agent, instructions } from "./shared.ts"; +import { addInstructions, agent } from "./shared.ts"; export const codex = agent({ name: "codex", @@ -92,14 +92,10 @@ export const codex = agent({ } } - // Use codex exec command via CLI - const fullPrompt = `${instructions}\n\n****** USER PROMPT ******\n${prompt}`; - log.info("Running Codex via CLI..."); try { - // Execute codex via CLI using child_process - const result = spawnSync("codex", ["exec", fullPrompt], { + const result = spawnSync(cliPath, ["exec", addInstructions(prompt)], { encoding: "utf-8", env: { ...process.env, diff --git a/agents/shared.ts b/agents/shared.ts index c020f5c..afe7250 100644 --- a/agents/shared.ts +++ b/agents/shared.ts @@ -75,3 +75,6 @@ ${workflows.map((w) => ` - "${w.name}": ${w.description}`).join("\n")} ${workflows.map((w) => `### ${w.name}\n\n${w.prompt}`).join("\n\n")} `; + +export const addInstructions = (prompt: string) => + `****** GENERAL INSTRUCTIONS ******\n${instructions}\n\n****** USER PROMPT ******\n${prompt}`; diff --git a/entry.js b/entry.js index 2c69bf8..8c292e4 100755 --- a/entry.js +++ b/entry.js @@ -41218,6 +41218,11 @@ ${workflows.map((w) => `### ${w.name} ${w.prompt}`).join("\n\n")} `; +var addInstructions = (prompt) => `****** GENERAL INSTRUCTIONS ****** +${instructions} + +****** USER PROMPT ****** +${prompt}`; // agents/claude.ts var claude = agent({ @@ -41281,10 +41286,7 @@ var claude = agent({ run: async ({ prompt, mcpServers, apiKey, cliPath }) => { process.env.ANTHROPIC_API_KEY = apiKey; const queryInstance = query({ - prompt: `${instructions} - -****** USER PROMPT ****** -${prompt}`, + prompt: addInstructions(prompt), options: { permissionMode: "bypassPermissions", mcpServers, @@ -41465,13 +41467,9 @@ var codex = agent({ } } } - const fullPrompt = `${instructions} - -****** USER PROMPT ****** -${prompt}`; log.info("Running Codex via CLI..."); try { - const result = spawnSync2("codex", ["exec", fullPrompt], { + const result = spawnSync2(cliPath, ["exec", addInstructions(prompt)], { encoding: "utf-8", env: { ...process.env,