refactor: server-side user prompt construction with @pullfrog tag check (#123)
- Move prompt construction logic from action-side to server-side (webhook handler and trigger page) - Include issue/comment body in USER PROMPT only if @pullfrog was tagged (checked server-side using containsTriggerPhrase) - Add repoInstructions as separate REPO-LEVEL INSTRUCTIONS section in FULL prompt - Macro-expand repoInstructions server-side before sending to action - Trigger page never includes body (manual triggers) - Remove redundant customInstructions field (now combined into prompt server-side) files changed: - action/external.ts: add repoInstructions to WriteablePayload, remove customInstructions - action/utils/payload.ts: add repoInstructions to JsonPayload schema, remove customInstructions - action/utils/repoSettings.ts: add repoInstructions to RepoSettings interface - action/utils/instructions.ts: use payload.prompt directly, add repo section to full prompt, add repo field to ResolvedInstructions - utils/webhooks/handleWebhook.ts: check @pullfrog tag and include body if tagged, macro-expand repoInstructions - app/trigger/[owner]/[repo]/[number]/page.tsx: macro-expand repoInstructions (never include body)
This commit is contained in:
committed by
pullfrog[bot]
parent
26ced25a8f
commit
995b39a122
+16
-1
@@ -63,6 +63,7 @@ export interface ResolvedInstructions {
|
||||
full: string;
|
||||
system: string;
|
||||
user: string;
|
||||
repo: string;
|
||||
event: string;
|
||||
runtime: string;
|
||||
}
|
||||
@@ -82,8 +83,12 @@ export function resolveInstructions(ctx: InstructionsContext): ResolvedInstructi
|
||||
|
||||
const runtime = buildRuntimeContext(ctx);
|
||||
|
||||
// user prompt is constructed server-side (body if @pullfrog tagged + per-trigger instructions)
|
||||
const user = ctx.payload.prompt;
|
||||
|
||||
// repo-level instructions are macro-expanded server-side and passed separately
|
||||
const repo = ctx.payload.repoInstructions ?? "";
|
||||
|
||||
const userQuoted = user
|
||||
.split("\n")
|
||||
.map((line) => `> ${line}`)
|
||||
@@ -163,12 +168,22 @@ After selecting a mode, follow the detailed step-by-step instructions provided b
|
||||
|
||||
Eagerly inspect the MCP tools available to you via the \`${ghPullfrogMcpName}\` MCP server. These are VITALLY IMPORTANT to completing your task.`;
|
||||
|
||||
// build repo instructions section (only if non-empty)
|
||||
const repoSection = repo
|
||||
? `
|
||||
|
||||
************* REPO-LEVEL INSTRUCTIONS *************
|
||||
|
||||
${repo}`
|
||||
: "";
|
||||
|
||||
const full = `
|
||||
${system}
|
||||
|
||||
************* USER PROMPT *************
|
||||
|
||||
${userQuoted}
|
||||
${repoSection}
|
||||
|
||||
************* EVENT DATA *************
|
||||
|
||||
@@ -180,5 +195,5 @@ ${event}
|
||||
|
||||
${runtime}`;
|
||||
|
||||
return { full, system, user, event, runtime };
|
||||
return { full, system, user, repo, event, runtime };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user