Implement Plan button

This commit is contained in:
Colin McDonnell
2025-12-30 20:14:49 -08:00
parent 573c473dc1
commit ad1f51d704
5 changed files with 138 additions and 15 deletions
+51 -7
View File
@@ -98415,7 +98415,11 @@ var addTools = (ctx, server, tools) => {
// mcp/comment.ts
var LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
async function buildCommentFooter(payload, octokit) {
async function buildCommentFooter({
payload,
octokit,
customParts
}) {
const repoContext = parseRepoContext();
const runId = process.env.GITHUB_RUN_ID;
const agentName = payload.agent;
@@ -98432,7 +98436,7 @@ async function buildCommentFooter(payload, octokit) {
} catch {
}
}
return buildPullfrogFooter({
const footerParams = {
triggeredBy: true,
agent: {
displayName: agentInfo?.displayName || "Unknown agent",
@@ -98444,11 +98448,19 @@ async function buildCommentFooter(payload, octokit) {
runId,
...workflowRunHtmlUrl ? { htmlUrl: workflowRunHtmlUrl } : {}
} : void 0
});
};
if (customParts && customParts.length > 0) {
return buildPullfrogFooter({ ...footerParams, customParts });
}
return buildPullfrogFooter(footerParams);
}
function buildImplementPlanLink(owner, repo, issueNumber, commentId) {
const apiUrl = process.env.API_URL || "https://pullfrog.com";
return `[Implement plan \u2794](${apiUrl}/trigger/${owner}/${repo}/${issueNumber}?action=implement&comment_id=${commentId})`;
}
async function addFooter(body, payload, octokit) {
const bodyWithoutFooter = stripExistingFooter(body);
const footer = await buildCommentFooter(payload, octokit);
const footer = await buildCommentFooter({ payload, octokit });
return `${bodyWithoutFooter}${footer}`;
}
var Comment = type({
@@ -98532,9 +98544,18 @@ var ReportProgress = type({
body: type.string.describe("the progress update content to share")
});
async function reportProgress(ctx, { body }) {
const bodyWithFooter = await addFooter(body, ctx.payload, ctx.octokit);
const existingCommentId = getProgressCommentId();
const issueNumber = ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
const isPlanMode = ctx.toolState.selectedMode === "Plan";
if (existingCommentId) {
const customParts = isPlanMode && issueNumber !== void 0 ? [buildImplementPlanLink(ctx.owner, ctx.name, issueNumber, existingCommentId)] : void 0;
const bodyWithoutFooter = stripExistingFooter(body);
const footer = await buildCommentFooter({
payload: ctx.payload,
octokit: ctx.octokit,
customParts
});
const bodyWithFooter = `${bodyWithoutFooter}${footer}`;
const result2 = await ctx.octokit.rest.issues.updateComment({
owner: ctx.owner,
repo: ctx.name,
@@ -98549,18 +98570,40 @@ async function reportProgress(ctx, { body }) {
action: "updated"
};
}
const issueNumber = ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
if (issueNumber === void 0) {
return void 0;
}
const initialBody = await addFooter(body, ctx.payload, ctx.octokit);
const result = await ctx.octokit.rest.issues.createComment({
owner: ctx.owner,
repo: ctx.name,
issue_number: issueNumber,
body: bodyWithFooter
body: initialBody
});
setProgressCommentId(result.data.id);
progressCommentWasUpdated = true;
if (isPlanMode) {
const customParts = [buildImplementPlanLink(ctx.owner, ctx.name, issueNumber, result.data.id)];
const bodyWithoutFooter = stripExistingFooter(body);
const footer = await buildCommentFooter({
payload: ctx.payload,
octokit: ctx.octokit,
customParts
});
const bodyWithPlanLink = `${bodyWithoutFooter}${footer}`;
const updateResult = await ctx.octokit.rest.issues.updateComment({
owner: ctx.owner,
repo: ctx.name,
comment_id: result.data.id,
body: bodyWithPlanLink
});
return {
commentId: updateResult.data.id,
url: updateResult.data.html_url,
body: updateResult.data.body || "",
action: "created"
};
}
return {
commentId: result.data.id,
url: result.data.html_url,
@@ -124718,6 +124761,7 @@ function SelectModeTool(ctx) {
availableModes: ctx.modes.map((m) => ({ name: m.name, description: m.description }))
};
}
ctx.toolState.selectedMode = selectedMode.name;
return {
modeName: selectedMode.name,
description: selectedMode.description,