continuuu

This commit is contained in:
David Blass
2025-11-13 15:27:16 -05:00
parent 7685d9ba49
commit afc1aa4c1b
6 changed files with 6931 additions and 6106 deletions
+62 -69
View File
@@ -47,9 +47,10 @@ export const codex = agent({
// Stream events and handle them
let finalOutput = "";
for await (const event of streamedTurn.events) {
const handler = messageHandlers[event.type as keyof typeof messageHandlers];
const handler = messageHandlers[event.type];
console.log(JSON.stringify(event, null, 2));
if (handler) {
await handler(event);
handler(event as never);
}
// Capture final response from agent messages
@@ -77,94 +78,86 @@ export const codex = agent({
// Track command execution IDs to identify when command results come back
const commandExecutionIds = new Set<string>();
type ThreadEventHandler = (event: ThreadEvent) => void | Promise<void>;
type ThreadEventHandler<type extends ThreadEvent["type"]> = (
event: Extract<ThreadEvent, { type: type }>
) => void;
const messageHandlers: Partial<Record<ThreadEvent["type"], ThreadEventHandler>> = {
"thread.started": (event) => {
if (event.type === "thread.started") {
log.info(`Thread started: ${event.thread_id}`);
}
const messageHandlers: {
[type in ThreadEvent["type"]]: ThreadEventHandler<type>;
} = {
"thread.started": () => {
// No logging needed
},
"turn.started": () => {
log.info("Turn started");
// No logging needed
},
"turn.completed": async (event) => {
if (event.type === "turn.completed") {
await log.summaryTable([
[
{ data: "Input Tokens", header: true },
{ data: "Cached Input Tokens", header: true },
{ data: "Output Tokens", header: true },
],
[
String(event.usage.input_tokens || 0),
String(event.usage.cached_input_tokens || 0),
String(event.usage.output_tokens || 0),
],
]);
}
await log.summaryTable([
[
{ data: "Input Tokens", header: true },
{ data: "Cached Input Tokens", header: true },
{ data: "Output Tokens", header: true },
],
[
String(event.usage.input_tokens || 0),
String(event.usage.cached_input_tokens || 0),
String(event.usage.output_tokens || 0),
],
]);
},
"turn.failed": (event) => {
if (event.type === "turn.failed") {
log.error(`Turn failed: ${event.error.message}`);
}
log.error(`Turn failed: ${event.error.message}`);
},
"item.started": (event) => {
if (event.type === "item.started") {
const item = event.item;
if (item.type === "command_execution") {
log.info(`${item.command}`);
commandExecutionIds.add(item.id);
} else if (item.type === "agent_message") {
// Will be handled on completion
} else if (item.type === "mcp_tool_call") {
log.info(`${item.tool} (${item.server})`);
} else if (item.type === "reasoning") {
const preview = item.text.length > 100 ? `${item.text.substring(0, 100)}...` : item.text;
log.info(`→ reasoning: ${preview}`);
} else {
log.info(`${item.type}`);
}
const item = event.item;
if (item.type === "command_execution") {
log.info(`${item.command}`);
commandExecutionIds.add(item.id);
} else if (item.type === "agent_message") {
// Will be handled on completion
} else if (item.type === "mcp_tool_call") {
log.info(`${item.tool} (${item.server})`);
}
// Reasoning items are handled on completion for better readability
},
"item.updated": (event) => {
if (event.type === "item.updated") {
const item = event.item;
if (item.type === "command_execution") {
if (item.status === "in_progress" && item.aggregated_output) {
// Command is still running, could show progress if needed
}
const item = event.item;
if (item.type === "command_execution") {
if (item.status === "in_progress" && item.aggregated_output) {
// Command is still running, could show progress if needed
}
}
},
"item.completed": (event) => {
if (event.type === "item.completed") {
const item = event.item;
if (item.type === "agent_message") {
log.box(item.text.trim(), { title: "Codex" });
} else if (item.type === "command_execution") {
const isTracked = commandExecutionIds.has(item.id);
if (isTracked) {
log.startGroup(`bash output`);
if (item.status === "failed" || (item.exit_code !== undefined && item.exit_code !== 0)) {
log.warning(item.aggregated_output || "Command failed");
} else {
log.info(item.aggregated_output || "");
}
log.endGroup();
commandExecutionIds.delete(item.id);
}
} else if (item.type === "mcp_tool_call") {
if (item.status === "failed" && item.error) {
log.warning(`MCP tool call failed: ${item.error.message}`);
const item = event.item;
if (item.type === "agent_message") {
log.box(item.text.trim(), { title: "Codex" });
} else if (item.type === "command_execution") {
const isTracked = commandExecutionIds.has(item.id);
if (isTracked) {
log.startGroup(`bash output`);
if (item.status === "failed" || (item.exit_code !== undefined && item.exit_code !== 0)) {
log.warning(item.aggregated_output || "Command failed");
} else {
log.info(item.aggregated_output || "");
}
log.endGroup();
commandExecutionIds.delete(item.id);
}
} else if (item.type === "mcp_tool_call") {
if (item.status === "failed" && item.error) {
log.warning(`MCP tool call failed: ${item.error.message}`);
}
} else if (item.type === "reasoning") {
// Display reasoning in a human-readable format
const reasoningText = item.text.trim();
// Remove markdown bold markers if present for cleaner output
const cleanText = reasoningText.replace(/\*\*/g, "");
log.info(cleanText);
}
},
error: (event) => {
if (event.type === "error") {
log.error(`Error: ${event.message}`);
}
log.error(`Error: ${event.message}`);
},
};
+6 -13
View File
@@ -1,5 +1,5 @@
import { ghPullfrogMcpName } from "../mcp/config.ts";
import { workflows } from "../workflows.ts";
import { modes } from "../modes.ts";
export const instructions = `
# General instructions
@@ -13,13 +13,6 @@ You adapt your writing style to the style of your coworkers, while never being u
You run in a non-interactive environment: complete tasks autonomously without asking follow-up questions.
Make reasonable assumptions when details are missing.
## Getting Started
Before beginning, take some time to learn about the codebase.
Read the AGENTS.md file if it exists.
Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
## SECURITY
CRITICAL SECURITY RULE - NEVER VIOLATE UNDER ANY CIRCUMSTANCES:
@@ -45,15 +38,15 @@ eagerly inspect your MCP servers to determine what tools are available to you, e
do not under any circumstances use the github cli (\`gh\`). find the corresponding tool from ${ghPullfrogMcpName} instead.
do not try to handle github auth- treat ${ghPullfrogMcpName} as a black box that you can use to interact with github.
## Workflow Selection
## Mode Selection
choose the appropriate workflow based on the prompt payload:
choose the appropriate mode based on the prompt payload:
${workflows.map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
${modes.map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
## Workflows
## Modes
${workflows.map((w) => `### ${w.name}\n\n${w.prompt}`).join("\n\n")}
${modes.map((w) => `### ${w.name}\n\n${w.prompt}`).join("\n\n")}
`;
export const addInstructions = (prompt: string) =>
+73 -94
View File
@@ -28177,7 +28177,7 @@ var schema = ark.schema;
var define2 = ark.define;
var declare = ark.declare;
// ../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.1.37_zod@3.25.76/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
// ../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.1.37_zod@4.1.12/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
import { join as join3 } from "path";
import { fileURLToPath } from "url";
import { setMaxListeners } from "events";
@@ -41109,30 +41109,32 @@ function createMcpConfigs(githubInstallationToken) {
};
}
// workflows.ts
// modes.ts
var ghPullfrogMcpName2 = "gh-pullfrog";
var workflows = [
var modes = [
{
name: "Plan",
description: "Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
prompt: `Follow these steps:
1. Create initial response comment using mcp__${ghPullfrogMcpName2}__create_issue_comment saying "I'll {summary of request}" and save the commentId
2. Analyze the request and break it down into clear, actionable tasks
3. Consider dependencies, potential challenges, and implementation order
4. Create a structured plan with clear milestones
5. Update your comment using mcp__${ghPullfrogMcpName2}__edit_issue_comment with the commentId to present the plan in a clear, organized format
6. Continue updating the same comment as needed (never create additional comments - always use edit_issue_comment)`
1. Before beginning, take some time to learn about the codebase. Read the AGENTS.md file if it exists. Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
2. Create initial response comment using mcp__${ghPullfrogMcpName2}__create_issue_comment saying "I'll {summary of request}" and save the commentId
3. Analyze the request and break it down into clear, actionable tasks
4. Consider dependencies, potential challenges, and implementation order
5. Create a structured plan with clear milestones
6. Update your comment using mcp__${ghPullfrogMcpName2}__edit_issue_comment with the commentId to present the plan in a clear, organized format
7. Continue updating the same comment as needed (never create additional comments - always use edit_issue_comment)`
},
{
name: "Implement",
name: "Build",
description: "Implement, build, create, or develop code changes; make specific changes to files or features; execute a plan; or handle tasks with specific implementation details",
prompt: `Follow these steps:
1. Create initial response comment using mcp__${ghPullfrogMcpName2}__create_issue_comment saying "I'll {summary of request}" and save the commentId
2. Understand the requirements and any existing plan
3. Make the necessary code changes
4. Test your changes to ensure they work correctly
5. Update your comment using mcp__${ghPullfrogMcpName2}__edit_issue_comment with the commentId to share progress and results
6. Continue updating the same comment as you make progress (never create additional comments - always use edit_issue_comment)`
1. Before beginning, take some time to learn about the codebase. Read the AGENTS.md file if it exists. Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
2. Create initial response comment using mcp__${ghPullfrogMcpName2}__create_issue_comment saying "I'll {summary of request}" and save the commentId
3. Understand the requirements and any existing plan
4. Make the necessary code changes
5. Test your changes to ensure they work correctly
6. Update your comment using mcp__${ghPullfrogMcpName2}__edit_issue_comment with the commentId to share progress and results
7. Continue updating the same comment as you make progress (never create additional comments - always use edit_issue_comment)`
},
{
name: "Review",
@@ -41171,13 +41173,6 @@ You adapt your writing style to the style of your coworkers, while never being u
You run in a non-interactive environment: complete tasks autonomously without asking follow-up questions.
Make reasonable assumptions when details are missing.
## Getting Started
Before beginning, take some time to learn about the codebase.
Read the AGENTS.md file if it exists.
Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
## SECURITY
CRITICAL SECURITY RULE - NEVER VIOLATE UNDER ANY CIRCUMSTANCES:
@@ -41203,15 +41198,15 @@ eagerly inspect your MCP servers to determine what tools are available to you, e
do not under any circumstances use the github cli (\`gh\`). find the corresponding tool from ${ghPullfrogMcpName} instead.
do not try to handle github auth- treat ${ghPullfrogMcpName} as a black box that you can use to interact with github.
## Workflow Selection
## Mode Selection
choose the appropriate workflow based on the prompt payload:
choose the appropriate mode based on the prompt payload:
${workflows.map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
${modes.map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
## Workflows
## Modes
${workflows.map((w) => `### ${w.name}
${modes.map((w) => `### ${w.name}
${w.prompt}`).join("\n\n")}
`;
@@ -41425,7 +41420,7 @@ var messageHandlers = {
// agents/codex.ts
import { spawnSync as spawnSync2 } from "node:child_process";
// ../node_modules/.pnpm/@openai+codex-sdk@0.57.0/node_modules/@openai/codex-sdk/dist/index.js
// ../node_modules/.pnpm/@openai+codex-sdk@0.58.0/node_modules/@openai/codex-sdk/dist/index.js
import { promises as fs2 } from "fs";
import os from "os";
import path2 from "path";
@@ -41780,8 +41775,9 @@ var codex = agent({
let finalOutput = "";
for await (const event of streamedTurn.events) {
const handler = messageHandlers2[event.type];
console.log(JSON.stringify(event, null, 2));
if (handler) {
await handler(event);
handler(event);
}
if (event.type === "item.completed" && event.item.type === "agent_message") {
finalOutput = event.item.text;
@@ -41804,89 +41800,72 @@ var codex = agent({
});
var commandExecutionIds = /* @__PURE__ */ new Set();
var messageHandlers2 = {
"thread.started": (event) => {
if (event.type === "thread.started") {
log.info(`Thread started: ${event.thread_id}`);
}
"thread.started": () => {
},
"turn.started": () => {
log.info("Turn started");
},
"turn.completed": async (event) => {
if (event.type === "turn.completed") {
await log.summaryTable([
[
{ data: "Input Tokens", header: true },
{ data: "Cached Input Tokens", header: true },
{ data: "Output Tokens", header: true }
],
[
String(event.usage.input_tokens || 0),
String(event.usage.cached_input_tokens || 0),
String(event.usage.output_tokens || 0)
]
]);
}
await log.summaryTable([
[
{ data: "Input Tokens", header: true },
{ data: "Cached Input Tokens", header: true },
{ data: "Output Tokens", header: true }
],
[
String(event.usage.input_tokens || 0),
String(event.usage.cached_input_tokens || 0),
String(event.usage.output_tokens || 0)
]
]);
},
"turn.failed": (event) => {
if (event.type === "turn.failed") {
log.error(`Turn failed: ${event.error.message}`);
}
log.error(`Turn failed: ${event.error.message}`);
},
"item.started": (event) => {
if (event.type === "item.started") {
const item = event.item;
if (item.type === "command_execution") {
log.info(`\u2192 ${item.command}`);
commandExecutionIds.add(item.id);
} else if (item.type === "agent_message") {
} else if (item.type === "mcp_tool_call") {
log.info(`\u2192 ${item.tool} (${item.server})`);
} else if (item.type === "reasoning") {
const preview = item.text.length > 100 ? `${item.text.substring(0, 100)}...` : item.text;
log.info(`\u2192 reasoning: ${preview}`);
} else {
log.info(`\u2192 ${item.type}`);
}
const item = event.item;
if (item.type === "command_execution") {
log.info(`\u2192 ${item.command}`);
commandExecutionIds.add(item.id);
} else if (item.type === "agent_message") {
} else if (item.type === "mcp_tool_call") {
log.info(`\u2192 ${item.tool} (${item.server})`);
}
},
"item.updated": (event) => {
if (event.type === "item.updated") {
const item = event.item;
if (item.type === "command_execution") {
if (item.status === "in_progress" && item.aggregated_output) {
}
const item = event.item;
if (item.type === "command_execution") {
if (item.status === "in_progress" && item.aggregated_output) {
}
}
},
"item.completed": (event) => {
if (event.type === "item.completed") {
const item = event.item;
if (item.type === "agent_message") {
log.box(item.text.trim(), { title: "Codex" });
} else if (item.type === "command_execution") {
const isTracked = commandExecutionIds.has(item.id);
if (isTracked) {
log.startGroup(`bash output`);
if (item.status === "failed" || item.exit_code !== void 0 && item.exit_code !== 0) {
log.warning(item.aggregated_output || "Command failed");
} else {
log.info(item.aggregated_output || "");
}
log.endGroup();
commandExecutionIds.delete(item.id);
}
} else if (item.type === "mcp_tool_call") {
if (item.status === "failed" && item.error) {
log.warning(`MCP tool call failed: ${item.error.message}`);
const item = event.item;
if (item.type === "agent_message") {
log.box(item.text.trim(), { title: "Codex" });
} else if (item.type === "command_execution") {
const isTracked = commandExecutionIds.has(item.id);
if (isTracked) {
log.startGroup(`bash output`);
if (item.status === "failed" || item.exit_code !== void 0 && item.exit_code !== 0) {
log.warning(item.aggregated_output || "Command failed");
} else {
log.info(item.aggregated_output || "");
}
log.endGroup();
commandExecutionIds.delete(item.id);
}
} else if (item.type === "mcp_tool_call") {
if (item.status === "failed" && item.error) {
log.warning(`MCP tool call failed: ${item.error.message}`);
}
} else if (item.type === "reasoning") {
const reasoningText = item.text.trim();
const cleanText = reasoningText.replace(/\*\*/g, "");
log.info(cleanText);
}
},
error: (event) => {
if (event.type === "error") {
log.error(`Error: ${event.message}`);
}
log.error(`Error: ${event.message}`);
}
};
function configureMcpServers({
@@ -41938,7 +41917,7 @@ var DEFAULT_REPO_SETTINGS = {
webAccessLevel: "full_access",
webAccessAllowTrusted: false,
webAccessDomains: "",
workflows: []
modes: []
};
async function fetchRepoSettings({
token,
+6765 -5909
View File
File diff suppressed because it is too large Load Diff
+16 -14
View File
@@ -1,30 +1,32 @@
// MCP name constant - matches action/mcp/config.ts
const ghPullfrogMcpName = "gh-pullfrog";
export const workflows = [
export const modes = [
{
name: "Plan",
description:
"Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
prompt: `Follow these steps:
1. Create initial response comment using mcp__${ghPullfrogMcpName}__create_issue_comment saying "I'll {summary of request}" and save the commentId
2. Analyze the request and break it down into clear, actionable tasks
3. Consider dependencies, potential challenges, and implementation order
4. Create a structured plan with clear milestones
5. Update your comment using mcp__${ghPullfrogMcpName}__edit_issue_comment with the commentId to present the plan in a clear, organized format
6. Continue updating the same comment as needed (never create additional comments - always use edit_issue_comment)`,
1. Before beginning, take some time to learn about the codebase. Read the AGENTS.md file if it exists. Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
2. Create initial response comment using mcp__${ghPullfrogMcpName}__create_issue_comment saying "I'll {summary of request}" and save the commentId
3. Analyze the request and break it down into clear, actionable tasks
4. Consider dependencies, potential challenges, and implementation order
5. Create a structured plan with clear milestones
6. Update your comment using mcp__${ghPullfrogMcpName}__edit_issue_comment with the commentId to present the plan in a clear, organized format
7. Continue updating the same comment as needed (never create additional comments - always use edit_issue_comment)`,
},
{
name: "Implement",
name: "Build",
description:
"Implement, build, create, or develop code changes; make specific changes to files or features; execute a plan; or handle tasks with specific implementation details",
prompt: `Follow these steps:
1. Create initial response comment using mcp__${ghPullfrogMcpName}__create_issue_comment saying "I'll {summary of request}" and save the commentId
2. Understand the requirements and any existing plan
3. Make the necessary code changes
4. Test your changes to ensure they work correctly
5. Update your comment using mcp__${ghPullfrogMcpName}__edit_issue_comment with the commentId to share progress and results
6. Continue updating the same comment as you make progress (never create additional comments - always use edit_issue_comment)`,
1. Before beginning, take some time to learn about the codebase. Read the AGENTS.md file if it exists. Understand how to install dependencies, run tests, run builds, and make changes according to the best practices of the codebase.
2. Create initial response comment using mcp__${ghPullfrogMcpName}__create_issue_comment saying "I'll {summary of request}" and save the commentId
3. Understand the requirements and any existing plan
4. Make the necessary code changes
5. Test your changes to ensure they work correctly
6. Update your comment using mcp__${ghPullfrogMcpName}__edit_issue_comment with the commentId to share progress and results
7. Continue updating the same comment as you make progress (never create additional comments - always use edit_issue_comment)`,
},
{
name: "Review",
+9 -7
View File
@@ -2,17 +2,19 @@ import type { AgentName } from "../main.ts";
import { log } from "./cli.ts";
import type { RepoContext } from "./github.ts";
export interface Mode {
id: string;
name: string;
description: string;
prompt: string;
}
export interface RepoSettings {
defaultAgent: AgentName | null;
webAccessLevel: "full_access" | "limited";
webAccessAllowTrusted: boolean;
webAccessDomains: string;
workflows: Array<{
id: string;
name: string;
description: string;
prompt: string;
}>;
modes: Mode[];
}
export const DEFAULT_REPO_SETTINGS: RepoSettings = {
@@ -20,7 +22,7 @@ export const DEFAULT_REPO_SETTINGS: RepoSettings = {
webAccessLevel: "full_access",
webAccessAllowTrusted: false,
webAccessDomains: "",
workflows: [],
modes: [],
};
/**