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:
Colin McDonnell
2026-01-19 17:16:20 +00:00
committed by pullfrog[bot]
parent 26ced25a8f
commit 995b39a122
5 changed files with 38 additions and 3 deletions
+16 -1
View File
@@ -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 };
}
+2
View File
@@ -21,6 +21,7 @@ const JsonPayload = type({
"~pullfrog": "true",
"agent?": AgentName.or("null"),
"prompt?": "string",
"repoInstructions?": "string",
"event?": "object",
"effort?": Effort,
});
@@ -123,6 +124,7 @@ export function resolvePayload(repoSettings: RepoSettings) {
// inverted: jsonPayload.prompt extracts the text from the JSON payload,
// whereas inputs.prompt IS the raw JSON string when internally dispatched
prompt: jsonPayload?.prompt ?? inputs.prompt,
repoInstructions: jsonPayload?.repoInstructions,
event,
effort: inputs.effort ?? jsonPayload?.effort ?? "auto",
cwd: resolveCwd(inputs.cwd),
+4
View File
@@ -11,6 +11,7 @@ export interface Mode {
export interface RepoSettings {
defaultAgent: AgentName | null;
modes: Mode[];
repoInstructions: string;
web: ToolPermission;
search: ToolPermission;
write: ToolPermission;
@@ -49,6 +50,7 @@ export async function fetchRepoSettings(params: {
return {
defaultAgent: null,
modes: [],
repoInstructions: "",
web: "enabled",
search: "enabled",
write: "enabled",
@@ -61,6 +63,7 @@ export async function fetchRepoSettings(params: {
return {
defaultAgent: null,
modes: [],
repoInstructions: "",
web: "enabled",
search: "enabled",
write: "enabled",
@@ -74,6 +77,7 @@ export async function fetchRepoSettings(params: {
return {
defaultAgent: null,
modes: [],
repoInstructions: "",
web: "enabled",
search: "enabled",
write: "enabled",