Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b33deb1b5a | |||
| 5034ff8285 |
+2
-2
@@ -14,11 +14,11 @@ export const claude = agent({
|
||||
executablePath: "cli.js",
|
||||
});
|
||||
},
|
||||
run: async ({ payload, mcpServers, apiKey, cliPath, prepResults, repo }) => {
|
||||
run: async ({ payload, mcpServers, apiKey, cliPath, repo }) => {
|
||||
// Ensure API key is NOT in process.env - only pass via SDK's env option
|
||||
delete process.env.ANTHROPIC_API_KEY;
|
||||
|
||||
const prompt = addInstructions({ payload, prepResults, repo });
|
||||
const prompt = addInstructions({ payload, repo });
|
||||
log.group("» Full prompt", () => log.info(prompt));
|
||||
|
||||
// configure sandbox mode if enabled
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ export const codex = agent({
|
||||
executablePath: "bin/codex.js",
|
||||
});
|
||||
},
|
||||
run: async ({ payload, mcpServers, apiKey, cliPath, prepResults, repo }) => {
|
||||
run: async ({ payload, mcpServers, apiKey, cliPath, repo }) => {
|
||||
// create config directory for codex before setting HOME
|
||||
const tempHome = process.env.PULLFROG_TEMP_DIR!;
|
||||
const configDir = join(tempHome, ".config", "codex");
|
||||
@@ -61,7 +61,7 @@ export const codex = agent({
|
||||
);
|
||||
|
||||
try {
|
||||
const streamedTurn = await thread.runStreamed(addInstructions({ payload, prepResults, repo }));
|
||||
const streamedTurn = await thread.runStreamed(addInstructions({ payload, repo }));
|
||||
|
||||
let finalOutput = "";
|
||||
for await (const event of streamedTurn.events) {
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ export const cursor = agent({
|
||||
executableName: "cursor-agent",
|
||||
});
|
||||
},
|
||||
run: async ({ payload, apiKey, cliPath, mcpServers, prepResults, repo }) => {
|
||||
run: async ({ payload, apiKey, cliPath, mcpServers, repo }) => {
|
||||
configureCursorMcpServers({ mcpServers, cliPath });
|
||||
configureCursorSandbox({ sandbox: payload.sandbox ?? false });
|
||||
|
||||
@@ -166,7 +166,7 @@ export const cursor = agent({
|
||||
};
|
||||
|
||||
try {
|
||||
const fullPrompt = addInstructions({ payload, prepResults, repo });
|
||||
const fullPrompt = addInstructions({ payload, repo });
|
||||
log.group("» Full prompt", () => log.info(fullPrompt));
|
||||
|
||||
// configure sandbox mode if enabled
|
||||
|
||||
+2
-2
@@ -154,14 +154,14 @@ export const gemini = agent({
|
||||
...(githubInstallationToken && { githubInstallationToken }),
|
||||
});
|
||||
},
|
||||
run: async ({ payload, apiKey, mcpServers, cliPath, prepResults, repo }) => {
|
||||
run: async ({ payload, apiKey, mcpServers, cliPath, repo }) => {
|
||||
configureGeminiMcpServers({ mcpServers, cliPath });
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error("google_api_key or gemini_api_key is required for gemini agent");
|
||||
}
|
||||
|
||||
const sessionPrompt = addInstructions({ payload, prepResults, repo });
|
||||
const sessionPrompt = addInstructions({ payload, repo });
|
||||
log.group("» Full prompt", () => log.info(sessionPrompt));
|
||||
|
||||
// configure sandbox mode if enabled
|
||||
|
||||
+6
-81
@@ -3,68 +3,6 @@ import { encode as toonEncode } from "@toon-format/toon";
|
||||
import type { Payload } from "../external.ts";
|
||||
import { ghPullfrogMcpName } from "../external.ts";
|
||||
import { getModes } from "../modes.ts";
|
||||
import type { PrepResult } from "../prep/index.ts";
|
||||
|
||||
/**
|
||||
* Format prep results into a human-readable string for the agent prompt
|
||||
*/
|
||||
function formatPrepResults(results: PrepResult[]): string {
|
||||
if (results.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const result of results) {
|
||||
if (result.language === "unknown") {
|
||||
continue;
|
||||
}
|
||||
|
||||
const langDisplay = result.language === "node" ? "Node.js" : "Python";
|
||||
|
||||
if (result.language === "node") {
|
||||
if (result.dependenciesInstalled) {
|
||||
lines.push(
|
||||
`✅ ${langDisplay} dependencies installed successfully via \`${result.packageManager}\`.`
|
||||
);
|
||||
} else {
|
||||
lines.push(
|
||||
`⚠️ ${langDisplay} dependency installation FAILED (using \`${result.packageManager}\`).`
|
||||
);
|
||||
for (const issue of result.issues) {
|
||||
lines.push(` - ${issue}`);
|
||||
}
|
||||
lines.push(
|
||||
` You may need to run \`${result.packageManager} install\` or address this issue before proceeding.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.language === "python") {
|
||||
if (result.dependenciesInstalled) {
|
||||
lines.push(
|
||||
`✅ ${langDisplay} dependencies installed successfully via \`${result.packageManager}\` (from ${result.configFile}).`
|
||||
);
|
||||
} else {
|
||||
lines.push(
|
||||
`⚠️ ${langDisplay} dependency installation FAILED (using \`${result.packageManager}\` from ${result.configFile}).`
|
||||
);
|
||||
for (const issue of result.issues) {
|
||||
lines.push(` - ${issue}`);
|
||||
}
|
||||
lines.push(
|
||||
` You may need to run the appropriate install command or address this issue before proceeding.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
interface RepoInfo {
|
||||
owner: string;
|
||||
@@ -72,15 +10,10 @@ interface RepoInfo {
|
||||
defaultBranch: string;
|
||||
}
|
||||
|
||||
interface BuildRuntimeContextParams {
|
||||
repo: RepoInfo;
|
||||
prepResults: PrepResult[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build runtime context string with git status, repo data, and GitHub Actions variables
|
||||
*/
|
||||
function buildRuntimeContext({ repo, prepResults }: BuildRuntimeContextParams): string {
|
||||
function buildRuntimeContext(repo: RepoInfo): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// working directory
|
||||
@@ -114,24 +47,15 @@ function buildRuntimeContext({ repo, prepResults }: BuildRuntimeContextParams):
|
||||
}
|
||||
}
|
||||
|
||||
// environment setup (dependency installation results)
|
||||
const envSetup = formatPrepResults(prepResults);
|
||||
if (envSetup) {
|
||||
lines.push("");
|
||||
lines.push("environment_setup:");
|
||||
lines.push(envSetup);
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
interface AddInstructionsParams {
|
||||
payload: Payload;
|
||||
prepResults: PrepResult[];
|
||||
repo: RepoInfo;
|
||||
}
|
||||
|
||||
export const addInstructions = ({ payload, prepResults, repo }: AddInstructionsParams) => {
|
||||
export const addInstructions = ({ payload, repo }: AddInstructionsParams) => {
|
||||
let encodedEvent = "";
|
||||
|
||||
const eventKeys = Object.keys(payload.event);
|
||||
@@ -143,8 +67,7 @@ export const addInstructions = ({ payload, prepResults, repo }: AddInstructionsP
|
||||
encodedEvent = toonEncode(payload.event);
|
||||
}
|
||||
|
||||
const runtimeContext = buildRuntimeContext({ repo, prepResults });
|
||||
const dependenciesPreinstalled = prepResults.every((r) => r.dependenciesInstalled) || undefined;
|
||||
const runtimeContext = buildRuntimeContext(repo);
|
||||
|
||||
return (
|
||||
`
|
||||
@@ -247,6 +170,8 @@ Tool names may be formatted as \`(server name)/(tool name)\`, for example: \`${g
|
||||
|
||||
**Efficiency**: Trust the tools - do not repeatedly verify file contents or git status after operations. If a tool reports success, proceed to the next step. Only verify if you encounter an actual error.
|
||||
|
||||
**Command execution**: Never use \`sleep\` to wait for commands to complete. Commands run synchronously - when the bash tool returns, the command has finished.
|
||||
|
||||
**Commenting style**: When posting comments via ${ghPullfrogMcpName}, write as a professional team member would. Your final comments should be polished and actionable—do not include intermediate reasoning like "I'll now look at the code" or "Let me respond to the question."
|
||||
|
||||
**If you get stuck**: If you cannot complete a task due to missing information, ambiguity, or an unrecoverable error:
|
||||
@@ -264,7 +189,7 @@ Tool names may be formatted as \`(server name)/(tool name)\`, for example: \`${g
|
||||
|
||||
### Available modes
|
||||
|
||||
${[...getModes({ disableProgressComment: payload.disableProgressComment, dependenciesPreinstalled }), ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
||||
${[...getModes({ disableProgressComment: payload.disableProgressComment }), ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
|
||||
|
||||
### Following the mode instructions
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ export const opencode = agent({
|
||||
installDependencies: true,
|
||||
});
|
||||
},
|
||||
run: async ({ payload, apiKey: _apiKey, apiKeys, mcpServers, cliPath, prepResults, repo }) => {
|
||||
run: async ({ payload, apiKey: _apiKey, apiKeys, mcpServers, cliPath, repo }) => {
|
||||
// 1. configure home/config directory
|
||||
const tempHome = process.env.PULLFROG_TEMP_DIR!;
|
||||
const configDir = join(tempHome, ".config", "opencode");
|
||||
@@ -29,7 +29,7 @@ export const opencode = agent({
|
||||
|
||||
configureOpenCode({ mcpServers, sandbox: payload.sandbox ?? false });
|
||||
|
||||
const prompt = addInstructions({ payload, prepResults, repo });
|
||||
const prompt = addInstructions({ payload, repo });
|
||||
log.group("» Full prompt", () => log.info(prompt));
|
||||
|
||||
// message positional must come right after "run", before flags
|
||||
|
||||
@@ -7,7 +7,6 @@ import { pipeline } from "node:stream/promises";
|
||||
import type { McpHttpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||
import type { show } from "@ark/util";
|
||||
import { type AgentManifest, type AgentName, agentsManifest, type Payload } from "../external.ts";
|
||||
import type { PrepResult } from "../prep/index.ts";
|
||||
import { log } from "../utils/cli.ts";
|
||||
import { getGitHubInstallationToken } from "../utils/github.ts";
|
||||
|
||||
@@ -39,7 +38,6 @@ export interface AgentConfig {
|
||||
payload: Payload;
|
||||
mcpServers: Record<string, McpHttpServerConfig>;
|
||||
cliPath: string;
|
||||
prepResults: PrepResult[];
|
||||
repo: RepoInfo;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
run pnpm --version and print the output
|
||||
add a file implementing quicksort and test it
|
||||
|
||||
@@ -14,7 +14,7 @@ import { createMcpConfigs } from "./mcp/config.ts";
|
||||
import { startMcpHttpServer } from "./mcp/server.ts";
|
||||
import { getModes, type Mode, modes } from "./modes.ts";
|
||||
import packageJson from "./package.json" with { type: "json" };
|
||||
import { type PrepResult, runPrepPhase } from "./prep/index.ts";
|
||||
import type { PrepResult } from "./prep/index.ts";
|
||||
import { fetchRepoSettings, fetchWorkflowRunInfo, type RepoSettings } from "./utils/api.ts";
|
||||
import { log } from "./utils/cli.ts";
|
||||
import { reportErrorToComment } from "./utils/errorReport.ts";
|
||||
@@ -104,10 +104,9 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
||||
return { success: false, error: apiKeySetup.error };
|
||||
}
|
||||
|
||||
// phase 5: parallel long-running operations (prep + agent install + git auth)
|
||||
// phase 5: parallel long-running operations (agent install + git auth)
|
||||
const toolState: ToolState = {};
|
||||
const [prepResults, cliPath] = await Promise.all([
|
||||
runPrepPhase(),
|
||||
const [cliPath] = await Promise.all([
|
||||
installAgentCli({ agent, token: githubSetup.token }),
|
||||
setupGitAuth({
|
||||
token: githubSetup.token,
|
||||
@@ -118,14 +117,12 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
||||
toolState,
|
||||
}),
|
||||
]);
|
||||
timer.checkpoint("prep+agentSetup+gitAuth");
|
||||
timer.checkpoint("agentSetup+gitAuth");
|
||||
|
||||
// phase 6: compute modes (needs prep results)
|
||||
const dependenciesPreinstalled = prepResults.every((r) => r.dependenciesInstalled) || undefined;
|
||||
// phase 6: compute modes
|
||||
const computedModes: Mode[] = [
|
||||
...getModes({
|
||||
disableProgressComment: resolvedPayload.disableProgressComment,
|
||||
dependenciesPreinstalled,
|
||||
}),
|
||||
...(resolvedPayload.modes || []),
|
||||
];
|
||||
@@ -165,7 +162,6 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
||||
repo: githubSetup.repo,
|
||||
repoSettings: githubSetup.repoSettings,
|
||||
modes: computedModes,
|
||||
prepResults,
|
||||
toolState,
|
||||
agent,
|
||||
sharedTempDir,
|
||||
@@ -199,9 +195,9 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
||||
Array.isArray(ctx.payload.event.comment_ids) &&
|
||||
ctx.payload.event.comment_ids.length === 0
|
||||
) {
|
||||
await reportProgress(ctx, {
|
||||
body: `👍 **No approved comments found**\n\nTo use "Fix 👍s", add a 👍 reaction to one or more inline review comments you want fixed.`,
|
||||
});
|
||||
const noThumbsMessage = `👍 **No approved comments found**\n\nTo use "Fix 👍s", add a 👍 reaction to one or more inline review comments you want fixed.`;
|
||||
log.error(noThumbsMessage);
|
||||
await reportProgress(ctx, { body: noThumbsMessage });
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -315,7 +311,6 @@ export interface ToolContext {
|
||||
repo: Awaited<ReturnType<Octokit["repos"]["get"]>>["data"];
|
||||
repoSettings: RepoSettings;
|
||||
modes: Mode[];
|
||||
prepResults: PrepResult[];
|
||||
toolState: ToolState;
|
||||
agent: Agent;
|
||||
sharedTempDir: string;
|
||||
@@ -333,6 +328,12 @@ export interface AgentContext extends Readonly<ToolContext> {
|
||||
readonly apiKeys: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface DependencyInstallationState {
|
||||
status: "not_started" | "in_progress" | "completed" | "failed";
|
||||
promise: Promise<PrepResult[]> | undefined;
|
||||
results: PrepResult[] | undefined;
|
||||
}
|
||||
|
||||
export interface ToolState {
|
||||
prNumber?: number;
|
||||
issueNumber?: number;
|
||||
@@ -340,6 +341,7 @@ export interface ToolState {
|
||||
id: number; // REST API database ID (for fix URLs)
|
||||
nodeId: string; // GraphQL node ID (for mutations)
|
||||
};
|
||||
dependencyInstallation?: DependencyInstallationState;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,7 +520,6 @@ async function runAgent(ctx: AgentContext): Promise<AgentResult> {
|
||||
apiKey: ctx.apiKey,
|
||||
apiKeys: ctx.apiKeys,
|
||||
cliPath: ctx.cliPath,
|
||||
prepResults: ctx.prepResults,
|
||||
repo: {
|
||||
owner: ctx.owner,
|
||||
name: ctx.name,
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
import { type } from "arktype";
|
||||
import type { ToolContext } from "../main.ts";
|
||||
import type { PrepResult } from "../prep/index.ts";
|
||||
import { runPrepPhase } from "../prep/index.ts";
|
||||
import { execute, tool } from "./shared.ts";
|
||||
|
||||
// empty schema for tools with no parameters
|
||||
const EmptyParams = type({});
|
||||
|
||||
/**
|
||||
* format prep results into agent-friendly message
|
||||
*/
|
||||
function formatPrepResults(results: PrepResult[]): string {
|
||||
if (results.length === 0) {
|
||||
return `No supported language detected in this repository (checked for package.json, requirements.txt, pyproject.toml, etc.).
|
||||
|
||||
Inspect the repository structure to determine how dependencies should be installed, then use bash to install them.`;
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const result of results) {
|
||||
if (result.language === "unknown") {
|
||||
continue;
|
||||
}
|
||||
|
||||
const langDisplay = result.language === "node" ? "Node.js" : "Python";
|
||||
|
||||
if (result.dependenciesInstalled) {
|
||||
if (result.language === "node") {
|
||||
lines.push(
|
||||
`${langDisplay} dependencies installed successfully via ${result.packageManager}.`
|
||||
);
|
||||
} else if (result.language === "python") {
|
||||
lines.push(
|
||||
`${langDisplay} dependencies installed successfully via ${result.packageManager} (from ${result.configFile}).`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const errorMsg = result.issues.length > 0 ? result.issues.join("\n") : "unknown error";
|
||||
|
||||
if (result.language === "node") {
|
||||
lines.push(`${langDisplay} dependency installation failed via ${result.packageManager}.
|
||||
|
||||
Error:
|
||||
${errorMsg}
|
||||
|
||||
Use bash or other tools at your disposal to diagnose and resolve the issue, then install dependencies manually.`);
|
||||
} else if (result.language === "python") {
|
||||
lines.push(`${langDisplay} dependency installation failed via ${result.packageManager} (from ${result.configFile}).
|
||||
|
||||
Error:
|
||||
${errorMsg}
|
||||
|
||||
Use bash or other tools at your disposal to diagnose and resolve the issue, then install dependencies manually.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.length === 0) {
|
||||
return `No supported language detected in this repository (checked for package.json, requirements.txt, pyproject.toml, etc.).
|
||||
|
||||
Inspect the repository structure to determine how dependencies should be installed, then use bash to install them.`;
|
||||
}
|
||||
|
||||
return lines.join("\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* start dependency installation in the background (non-blocking, idempotent)
|
||||
*/
|
||||
function startInstallation(ctx: ToolContext): void {
|
||||
// already started or completed - do nothing
|
||||
if (ctx.toolState.dependencyInstallation) {
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize state and start installation
|
||||
const promise = runPrepPhase();
|
||||
ctx.toolState.dependencyInstallation = {
|
||||
status: "in_progress",
|
||||
promise,
|
||||
results: undefined,
|
||||
};
|
||||
|
||||
// when promise completes, update state
|
||||
promise.then(
|
||||
(results) => {
|
||||
if (ctx.toolState.dependencyInstallation) {
|
||||
const hasFailure = results.some((r) => !r.dependenciesInstalled && r.issues.length > 0);
|
||||
ctx.toolState.dependencyInstallation.status = hasFailure ? "failed" : "completed";
|
||||
ctx.toolState.dependencyInstallation.results = results;
|
||||
}
|
||||
},
|
||||
() => {
|
||||
if (ctx.toolState.dependencyInstallation) {
|
||||
ctx.toolState.dependencyInstallation.status = "failed";
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function StartDependencyInstallationTool(ctx: ToolContext) {
|
||||
return tool({
|
||||
name: "start_dependency_installation",
|
||||
description:
|
||||
"Start installing project dependencies in the background. This is non-blocking and returns immediately. Call this early (right after branch checkout) if you anticipate needing to run tests, builds, or other commands that require dependencies. Idempotent - safe to call multiple times.",
|
||||
parameters: EmptyParams,
|
||||
execute: execute(async () => {
|
||||
const state = ctx.toolState.dependencyInstallation;
|
||||
|
||||
// already completed
|
||||
if (state?.status === "completed" || state?.status === "failed") {
|
||||
return {
|
||||
status: state.status,
|
||||
message: `Dependency installation already completed.`,
|
||||
summary: formatPrepResults(state.results || []),
|
||||
};
|
||||
}
|
||||
|
||||
// already in progress
|
||||
if (state?.status === "in_progress") {
|
||||
return {
|
||||
status: "in_progress",
|
||||
message:
|
||||
"Dependency installation is already in progress. Call await_dependency_installation when you need to use them.",
|
||||
};
|
||||
}
|
||||
|
||||
// start installation
|
||||
startInstallation(ctx);
|
||||
|
||||
return {
|
||||
status: "started",
|
||||
message:
|
||||
"Dependency installation started in background. Continue with other tasks and call await_dependency_installation when you need to run tests, builds, or other commands that require dependencies.",
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function AwaitDependencyInstallationTool(ctx: ToolContext) {
|
||||
return tool({
|
||||
name: "await_dependency_installation",
|
||||
description:
|
||||
"Wait for dependency installation to complete and get the results. If installation hasn't been started yet, this will start it automatically. Call this before running tests, builds, or other commands that require dependencies.",
|
||||
parameters: EmptyParams,
|
||||
execute: execute(async () => {
|
||||
// auto-start if not started
|
||||
if (!ctx.toolState.dependencyInstallation) {
|
||||
startInstallation(ctx);
|
||||
}
|
||||
|
||||
const state = ctx.toolState.dependencyInstallation;
|
||||
if (!state) {
|
||||
throw new Error("failed to initialize dependency installation state");
|
||||
}
|
||||
|
||||
// if already completed, return cached results
|
||||
if (state.status === "completed" || state.status === "failed") {
|
||||
return {
|
||||
status: state.status,
|
||||
message: formatPrepResults(state.results || []),
|
||||
};
|
||||
}
|
||||
|
||||
// await the promise
|
||||
if (!state.promise) {
|
||||
throw new Error("dependency installation state is corrupted - no promise found");
|
||||
}
|
||||
|
||||
const results = await state.promise;
|
||||
|
||||
return {
|
||||
status: state.status,
|
||||
message: formatPrepResults(results),
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -13,6 +13,10 @@ import {
|
||||
ReportProgressTool,
|
||||
} from "./comment.ts";
|
||||
import { DebugShellCommandTool } from "./debug.ts";
|
||||
import {
|
||||
AwaitDependencyInstallationTool,
|
||||
StartDependencyInstallationTool,
|
||||
} from "./dependencies.ts";
|
||||
import { ListFilesTool } from "./files.ts";
|
||||
import { CommitFilesTool, CreateBranchTool, PushBranchTool } from "./git.ts";
|
||||
import { IssueTool } from "./issue.ts";
|
||||
@@ -70,6 +74,8 @@ export async function startMcpHttpServer(
|
||||
// create all tools as factories, passing ctx
|
||||
const tools: Tool<any, any>[] = [
|
||||
SelectModeTool(ctx),
|
||||
StartDependencyInstallationTool(ctx),
|
||||
AwaitDependencyInstallationTool(ctx),
|
||||
CreateCommentTool(ctx),
|
||||
EditCommentTool(ctx),
|
||||
ReplyToReviewCommentTool(ctx),
|
||||
|
||||
@@ -8,28 +8,33 @@ export interface Mode {
|
||||
|
||||
export interface GetModesParams {
|
||||
disableProgressComment: true | undefined;
|
||||
dependenciesPreinstalled: true | undefined;
|
||||
}
|
||||
|
||||
const reportProgressInstruction = `Use ${ghPullfrogMcpName}/report_progress to share progress and results. Continue calling it as you make progress - it will update the same comment. Never create additional comments manually.`;
|
||||
|
||||
export function getModes({
|
||||
disableProgressComment,
|
||||
dependenciesPreinstalled,
|
||||
}: GetModesParams): Mode[] {
|
||||
const depsContext = dependenciesPreinstalled
|
||||
? "Dependencies have already been installed."
|
||||
: "understand how to install dependencies,";
|
||||
const dependencyInstallationGuidance = `## Dependency Installation
|
||||
|
||||
**IMPORTANT**: Immediately after the working branch is checked out, evaluate whether dependencies will be needed at any point during this task:
|
||||
- Making code changes that will require testing? → Call \`${ghPullfrogMcpName}/start_dependency_installation\` NOW
|
||||
- Running builds, linters, or CLI commands that require installed packages? → Call \`${ghPullfrogMcpName}/start_dependency_installation\` NOW
|
||||
- Only reading code or answering questions? → Skip dependency installation
|
||||
|
||||
Calling \`start_dependency_installation\` early allows dependencies to install in the background while you explore the codebase and make changes. This is a non-blocking call.
|
||||
|
||||
When you need to run tests, builds, or other commands that require dependencies, call \`${ghPullfrogMcpName}/await_dependency_installation\` to ensure they're ready. This will block until installation completes (or auto-start if you forgot to call start earlier).`;
|
||||
|
||||
export function getModes({ disableProgressComment }: GetModesParams): Mode[] {
|
||||
return [
|
||||
{
|
||||
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. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists, ${depsContext} run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
1. If this is a PR event, the PR branch is already checked out - skip branch creation. Otherwise, create a branch using ${ghPullfrogMcpName}/create_branch. The branch name should be prefixed with "pullfrog/". The rest of the name should reflect the exact changes you are making. It should be specific to avoid collisions with other branches. Never commit directly to main, master, or production. Do NOT use git commands directly (including \`git branch\`, \`git status\`, \`git log\`) - always use ${ghPullfrogMcpName} MCP tools for git operations.
|
||||
|
||||
2. If this is a PR event, the PR branch is already checked out - skip branch creation. Otherwise, create a branch using ${ghPullfrogMcpName}/create_branch. The branch name should be prefixed with "pullfrog/". The rest of the name should reflect the exact changes you are making. It should be specific to avoid collisions with other branches. Never commit directly to main, master, or production. Do NOT use git commands directly (including \`git branch\`, \`git status\`, \`git log\`) - always use ${ghPullfrogMcpName} MCP tools for git operations.
|
||||
${dependencyInstallationGuidance}
|
||||
|
||||
2. If the request requires understanding the codebase structure or conventions, gather relevant context. Read AGENTS.md if it exists. Skip this step if the prompt is trivial and self-contained.
|
||||
|
||||
3. Understand the requirements and any existing plan
|
||||
|
||||
@@ -66,11 +71,13 @@ export function getModes({
|
||||
prompt: `Follow these steps:
|
||||
1. Checkout the PR using ${ghPullfrogMcpName}/checkout_pr with the PR number. This fetches the PR branch and configures push settings (including for fork PRs).
|
||||
|
||||
${dependencyInstallationGuidance}
|
||||
|
||||
2. Review the feedback provided. Understand each review comment and what changes are being requested.
|
||||
- **EVENT DATA may contain review comment details**: If available, \`approved_comments\` are comments to address, \`unapproved_comments\` are for context only. The \`triggerer\` field indicates who initiated this action - prioritize their replies when deciding how to implement fixes.
|
||||
- You can use ${ghPullfrogMcpName}/get_pull_request to get PR metadata if needed.
|
||||
|
||||
3. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context. Read AGENTS.md if it exists.
|
||||
3. If the request requires understanding the codebase structure or conventions, gather relevant context. Read AGENTS.md if it exists.
|
||||
|
||||
4. Make the necessary code changes to address the feedback. Work through each review comment systematically.
|
||||
|
||||
@@ -132,7 +139,7 @@ ${
|
||||
description:
|
||||
"Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
|
||||
prompt: `Follow these steps:
|
||||
1. If the request requires understanding the codebase structure, dependencies, or conventions, gather relevant context (read AGENTS.md if it exists, ${depsContext} run tests, run builds, and make changes according to best practices). Skip this step if the prompt is trivial and self-contained.
|
||||
1. If the request requires understanding the codebase structure or conventions, gather relevant context (read AGENTS.md if it exists). Skip this step if the prompt is trivial and self-contained.
|
||||
|
||||
2. Analyze the request and break it down into clear, actionable tasks
|
||||
|
||||
@@ -149,6 +156,9 @@ ${
|
||||
|
||||
2. If the task involves making code changes:
|
||||
- Create a branch using ${ghPullfrogMcpName}/create_branch. Branch names should be prefixed with "pullfrog/" and reflect the exact changes you are making. Never commit directly to main, master, or production.
|
||||
|
||||
${dependencyInstallationGuidance}
|
||||
|
||||
- Use file operations to create/modify files with your changes.
|
||||
- Use ${ghPullfrogMcpName}/commit_files to commit your changes, then ${ghPullfrogMcpName}/push_branch to push the branch. Do NOT use git commands directly (\`git commit\`, \`git push\`, \`git checkout\`, \`git branch\`) as these will use incorrect credentials.
|
||||
- Test your changes to ensure they work correctly.
|
||||
@@ -163,5 +173,4 @@ ${
|
||||
|
||||
export const modes: Mode[] = getModes({
|
||||
disableProgressComment: undefined,
|
||||
dependenciesPreinstalled: undefined,
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/action",
|
||||
"version": "0.0.147",
|
||||
"version": "0.0.148",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
@@ -19,7 +19,7 @@ config({ path: join(process.cwd(), "..", ".env") });
|
||||
export async function run(prompt: string): Promise<AgentResult> {
|
||||
try {
|
||||
const tempDir = join(process.cwd(), ".temp");
|
||||
setupTestRepo({ tempDir, forceClean: true });
|
||||
setupTestRepo({ tempDir });
|
||||
|
||||
const originalCwd = process.cwd();
|
||||
process.chdir(tempDir);
|
||||
|
||||
+6
-27
@@ -9,42 +9,21 @@ import { $ } from "./shell.ts";
|
||||
|
||||
export interface SetupOptions {
|
||||
tempDir: string;
|
||||
forceClean?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the test repository for running actions
|
||||
*/
|
||||
export function setupTestRepo(options: SetupOptions): void {
|
||||
const { tempDir, forceClean = false } = options;
|
||||
|
||||
const { tempDir } = options;
|
||||
const repo = process.env.GITHUB_REPOSITORY;
|
||||
if (!repo) {
|
||||
throw new Error(
|
||||
"GITHUB_REPOSITORY environment variable must be specified (e.g. pullfrog/scratch)"
|
||||
);
|
||||
}
|
||||
|
||||
const cloneUrl = `git@github.com:${repo}.git`;
|
||||
|
||||
if (!repo) throw new Error("GITHUB_REPOSITORY is required");
|
||||
if (existsSync(tempDir)) {
|
||||
if (forceClean) {
|
||||
log.info("» removing existing .temp directory...");
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
|
||||
log.info(`» cloning ${repo} into .temp...`);
|
||||
$("git", ["clone", cloneUrl, tempDir]);
|
||||
} else {
|
||||
log.info("» resetting existing .temp repository...");
|
||||
execSync("git reset --hard HEAD && git clean -fd", {
|
||||
cwd: tempDir,
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
log.info(`» cloning ${repo} into .temp...`);
|
||||
$("git", ["clone", cloneUrl, tempDir]);
|
||||
log.info("» removing existing .temp directory...");
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
log.info(`» cloning ${repo} into .temp...`);
|
||||
$("git", ["clone", `git@github.com:${repo}.git`, tempDir]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user