@papi-ai/server 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +819 -47
- package/dist/prompts.js +236 -6
- package/package.json +1 -1
package/dist/prompts.js
CHANGED
|
@@ -157,13 +157,19 @@ Standard planning cycle with full board review.
|
|
|
157
157
|
|
|
158
158
|
### Steps:
|
|
159
159
|
1. **Cycle Health Check** \u2014 Flag issues: >7 day gaps, unprocessed discovered issues, AD conflicts, stale In Progress tasks (3+ cycles).
|
|
160
|
-
**\u26A0\uFE0F CARRY-FORWARD STALENESS:** Check the latest carry-forward text for items containing "stale", "already exists", "already implemented", or "already built". For each such item that references a specific task ID, check whether the task is still in Backlog. If a carry-forward says a task's deliverables already exist but the task is still Backlog, emit a \`boardCorrections\` entry setting it to Done with \`closureReason: "Auto-closed \u2014 carry-forward indicates deliverables already exist"\`. Log in the cycle log: "Auto-closed task-XXX \u2014 carry-forward confirmed deliverables exist." This prevents scheduling already-shipped tasks.
|
|
160
|
+
**\u26A0\uFE0F CARRY-FORWARD STALENESS (already-built):** Check the latest carry-forward text for items containing "stale", "already exists", "already implemented", or "already built". For each such item that references a specific task ID, check whether the task is still in Backlog. If a carry-forward says a task's deliverables already exist but the task is still Backlog, emit a \`boardCorrections\` entry setting it to Done with \`closureReason: "Auto-closed \u2014 carry-forward indicates deliverables already exist"\`. Log in the cycle log: "Auto-closed task-XXX \u2014 carry-forward confirmed deliverables exist." This prevents scheduling already-shipped tasks.
|
|
161
|
+
**\u26A0\uFE0F CARRY-FORWARD FORCED RESOLUTION:** If a "Carry-Forward Staleness" section is provided in the context below, it lists task IDs that have been deferred for 3+ consecutive cycles. For each listed task, you MUST take one of these actions \u2014 deferring again without justification is not acceptable:
|
|
162
|
+
- **Escalate:** Emit a \`boardCorrections\` entry upgrading the task to P1 High (if currently P2+) and include a "Carry-Forward Escalation" paragraph in the cycle log: list each escalated task by ID with a 1-sentence rationale.
|
|
163
|
+
- **Cancel:** Emit a \`boardCorrections\` entry setting status to "Cancelled" with a \`closureReason\` explaining why the task is no longer worth pursuing.
|
|
164
|
+
- **Schedule:** Include the task in this cycle's BUILD HANDOFFs. If scheduled, no further action needed.
|
|
165
|
+
If you defer a stale task again, you MUST provide an explicit justification in the cycle log \u2014 e.g. "task-XXX deferred again: blocked on task-YYY which must ship first."
|
|
161
166
|
|
|
162
167
|
2. **Inbox Triage** \u2014 Find unreviewed tasks (reviewed = false). For each: clean title, fill all fields, check for duplicates, verify alignment with Active Decisions. You MUST set priority on unreviewed tasks during triage using these criteria:
|
|
163
168
|
- **P0 Critical** \u2014 Broken, blocking, or data-loss risk. Fix now.
|
|
164
169
|
- **P1 High** \u2014 Strategically aligned: directly advances the current horizon/phase goals or Active Decisions.
|
|
165
170
|
- **P2 Medium** \u2014 Valuable but not strategically urgent: quality improvements, efficiency, polish, infrastructure.
|
|
166
171
|
- **P3 Low** \u2014 Nice-to-have, speculative, or future-horizon work.
|
|
172
|
+
**\u26A0\uFE0F PRIORITY RECALIBRATION \u2014 do NOT rubber-stamp the submitted priority.** The priority set at idea submission reflects the submitter's view at that time, which may be outdated by the time the planner runs. For EVERY unreviewed task, evaluate its priority FROM SCRATCH against: (a) current horizon/stage/phase goals, (b) recent Active Decision changes, (c) recently shipped functionality that makes this task more or less urgent. If your assessed priority differs from the submitted one, set the new priority in \`boardCorrections\` and include the change in a **Priority Recalibration** paragraph in your cycle log (Step 8): list each changed task by ID, old priority \u2192 new priority, and a 1-sentence rationale. This paragraph is how the user sees what the planner recalibrated and why. If no priorities changed during triage, omit the paragraph.
|
|
167
173
|
Also set complexity using the full range \u2014 **XS, Small, Medium, Large, XL** \u2014 based on actual scope, not conservatively. XS = single-line or config change. Small = one file, < 50 lines. Medium = 2-5 files. Large = cross-module, multiple components. XL = architectural, multi-day.
|
|
168
174
|
If a task is clearly obsolete, duplicated, or rejected, set its status to "Cancelled" with a \`closureReason\` explaining why.
|
|
169
175
|
**\u2192 PERSIST:** For each task you set reviewed: true, corrected fields on, or marked "Cancelled", include it in \`boardCorrections\` in Part 2.
|
|
@@ -171,6 +177,7 @@ Standard planning cycle with full board review.
|
|
|
171
177
|
3. **Board Integrity** \u2014 All tasks have complete fields? Priority still accurate? Duplicates? Stale In Progress tasks?
|
|
172
178
|
**\u2192 PERSIST:** Include any field corrections (status updates, field fixes) in \`boardCorrections\` in Part 2.
|
|
173
179
|
**\u26A0\uFE0F PRIORITY LOCK RULE:** Do NOT change the priority of any task that has \`reviewed: true\`. Reviewed tasks have had their priority confirmed by a human. If you believe a reviewed task's priority should change, note your recommendation in the cycle log but do NOT include a priority change in \`boardCorrections\`. You may only set priority on unreviewed tasks (during triage) or on newly created tasks (\`newTasks\` array). Priority values: P0 Critical, P1 High, P2 Medium, P3 Low.
|
|
180
|
+
**Priority Drift Check:** For reviewed Backlog tasks, check whether their priority still reflects strategic reality. A task submitted as P2 six cycles ago may now be P1 (strategic context shifted) or P3 (redundant, superseded, or de-prioritised by an AD). For each task where drift is detected, check three signals: (1) Does it still align with the current horizon/stage/phase? (2) Has a recent AD changed the strategic importance of this area? (3) Has a recent build shipped functionality that makes this task redundant or more urgent? If drift is found on 1+ tasks, include a **Priority Drift Suggestions** paragraph in your cycle log: list each drifted task by ID, current priority, suggested priority, and a 1-sentence rationale. Do NOT include priority changes in \`boardCorrections\` \u2014 these are suggestions requiring human confirmation, not auto-corrections. Omit this paragraph entirely if no drift is detected.
|
|
174
181
|
|
|
175
182
|
4. **Security Posture Check** \u2014 Review recently completed tasks and current board state for security concerns. Only flag genuine issues \u2014 do not add boilerplate security notes every cycle. Look for:
|
|
176
183
|
- Data exposure risks introduced by recent builds (PII in logs, secrets in storage/config)
|
|
@@ -188,7 +195,8 @@ Standard planning cycle with full board review.
|
|
|
188
195
|
- **Task maturity:** Tasks with \`maturity: "raw"\` are unscoped ideas from the idea tool. The planner IS the scoping mechanism \u2014 scope them as part of planning. For raw tasks selected for a cycle: (a) derive clear scope, acceptance criteria, and effort from the title, notes, and project context, (b) upgrade them to \`maturity: "investigated"\` via a \`boardCorrections\` entry, and (c) generate a BUILD HANDOFF as normal. For research-type raw tasks, scope the handoff as an investigation task \u2014 the deliverable is findings + follow-up backlog tasks, not code. Only leave a raw task unscheduled if you genuinely cannot derive scope from the available context \u2014 note why in the cycle log. Tasks with \`maturity: "ready"\` or no maturity field are considered cycle-ready. Tasks with \`maturity: "investigated"\` have been scoped but may still need refinement \u2014 schedule them if priority warrants it.
|
|
189
196
|
- **What to do with premature tasks:** Leave them in Backlog. Do NOT generate BUILD HANDOFFs for them. If a high-priority task fails the maturity gate due to phase prerequisites or dependencies, note it in the cycle log: "task-XXX deferred \u2014 Phase N prerequisites not met". Raw tasks are NOT premature \u2014 they just need scoping (see Task maturity above).
|
|
190
197
|
|
|
191
|
-
7. **Recommendation** \u2014
|
|
198
|
+
7. **Recommendation** \u2014 Select tasks for this cycle:
|
|
199
|
+
**Pre-assigned tasks:** If a "Pre-Assigned Tasks" section is provided in the context below, those tasks are ALREADY committed to this cycle by the user. Include them automatically \u2014 do NOT re-evaluate whether they belong. Generate BUILD HANDOFFs for each. Count their effort toward the cycle budget. Then fill remaining slots (up to 5 total) from the backlog using the priority rules below.
|
|
192
200
|
**If USER DIRECTION is provided above:** Follow the user's stated focus. Pick the highest-impact task that aligns with their direction. The user knows what they need. Only deviate if a genuine P0 Critical fix exists (broken builds, data loss).
|
|
193
201
|
**Otherwise, select by priority level then impact:**
|
|
194
202
|
- **P0 Critical** \u2014 Broken, blocking, or data-loss risk. Always first.
|
|
@@ -200,7 +208,7 @@ Standard planning cycle with full board review.
|
|
|
200
208
|
**Cycle sizing:** Size the cycle based on what the selected tasks actually require \u2014 not a fixed budget. Select the highest-priority unblocked tasks, estimate each one's effort from its scope, and let the total emerge from the tasks themselves. The historical average effort from Methodology Trends is a reference point for calibration, not a target or floor. A healthy cycle has 4-6 tasks. Cycles with fewer than 4 tasks require explicit justification in the cycle log \u2014 explain why more tasks could not be included. When the backlog has 10+ tasks, the cycle SHOULD have 5+ tasks \u2014 undersized cycles waste planning overhead relative to the available work. If fewer than 4 tasks qualify after filtering (blocked, deferred, raw), check Deferred tasks \u2014 some may be ready to un-defer via a \`boardCorrections\` entry. A 1-task cycle is almost never correct.
|
|
201
209
|
**Theme coherence:** After selecting candidate tasks, check whether they form a coherent theme \u2014 all serving one goal, phase, or module. Single-theme cycles produce better build quality and less context switching. If the top candidates touch 3+ unrelated modules or epics, prefer regrouping around the highest-priority theme and deferring the outliers. Mixed-theme cycles are acceptable when justified (e.g. a P0 fix alongside P1 feature work), but the justification must appear in the cycle log. Name the theme in 3-5 words \u2014 it becomes the \`cycleLogTitle\`.
|
|
202
210
|
|
|
203
|
-
8. **Cycle Log** \u2014 Write 5-10 line entry: what was triaged, what was recommended and why, observations, AD updates.
|
|
211
|
+
8. **Cycle Log** \u2014 Write 5-10 line entry: what was triaged, what was recommended and why, observations, AD updates. Include a **Priority Recalibration** paragraph if any unreviewed task priorities were changed during triage (Step 2) \u2014 list each by ID with old \u2192 new priority and rationale. Include a **Priority Drift Suggestions** paragraph if reviewed task drift was detected (Step 3).
|
|
204
212
|
**Cycle Notes** \u2014 Optionally include 1-3 lines of cycle-level observations in \`cycleLogNotes\`: estimation accuracy patterns, recurring blockers, velocity trends, or dependency signals. These notes persist across cycles so future planning runs can learn from them. Use null if there are no noteworthy observations this cycle.
|
|
205
213
|
|
|
206
214
|
9. **Active Decisions** \u2014 If any AD needs updating: Type A (confidence change), Type B (modification), or Type C (reversal/supersede).
|
|
@@ -214,7 +222,7 @@ Standard planning cycle with full board review.
|
|
|
214
222
|
|
|
215
223
|
10. **BUILD HANDOFFs** \u2014 Generate a full BUILD HANDOFF block for the recommended task and up to 4 additional high-priority unblocked tasks (5 total max). Include each handoff in the \`cycleHandoffs\` array in the structured output. The handoffs are written to each task on the board for durability. Remaining tasks will get handoffs in subsequent plans \u2014 do NOT try to cover the entire backlog.
|
|
216
224
|
**SKIP existing handoffs:** Tasks marked with "Has BUILD HANDOFF: yes" or "\u2713 handoff" on the board already have a valid handoff from a previous plan. Do NOT regenerate handoffs for these tasks \u2014 omit them from the \`cycleHandoffs\` array entirely. Only generate handoffs for tasks that do NOT have one yet. Exception: if a task's dependencies have been completed since its handoff was written, or a relevant Active Decision has changed, you MAY regenerate its handoff \u2014 but note this explicitly in the cycle log.
|
|
217
|
-
**Scope pre-check:** Before writing the SCOPE section of each handoff,
|
|
225
|
+
**Scope pre-check:** Before writing the SCOPE section of each handoff, cross-reference the task against the "Recently Shipped Capabilities" section in the context below (if present). For each candidate task: (1) check if the task's title or scope overlaps with any recently shipped task, (2) check if the FILES LIKELY TOUCHED overlap with files already modified in recent builds, (3) check the architecture notes from recent builds for patterns that already cover this task's scope. If >80% of a task's scope appears in recently shipped capabilities, recommend cancellation via \`boardCorrections\` or reduce the handoff scope to only the missing pieces \u2014 explicitly note what already exists. C126 task-728 was over-scoped because the planner assumed Blocked status needed creating from scratch \u2014 it already existed in types, DB, orient, and build_list. Over-scoped handoffs waste builder time on verification and cause estimation mismatches.
|
|
218
226
|
**Simplest Viable Path rule:** Before writing each BUILD HANDOFF, identify the simplest approach that satisfies the task's goal \u2014 the minimum change, fewest new abstractions, and smallest blast radius. Write the SCOPE (DO THIS) section for that simplest path FIRST. If you believe a more complex approach is warranted (new abstractions, multi-file refactors, framework changes), you MUST include a "WHY NOT SIMPLER" line in the handoff explaining why the simple path is insufficient. If you cannot articulate a concrete reason, use the simpler path. Pay special attention to tasks involving auth, data access, multi-user features, and infrastructure \u2014 these are the most common over-engineering targets.
|
|
219
227
|
**Maturity gate applies here:** Do NOT generate BUILD HANDOFFs for tasks that failed the maturity gate in step 6 (phase prerequisites not met, dependency chain incomplete). Raw tasks that the planner has scoped and upgraded to "investigated" in step 6 ARE eligible for handoffs.
|
|
220
228
|
**Security section guidance:** Each handoff includes a SECURITY CONSIDERATIONS section. Populate it when the task involves: data exposure risks (PII, secrets in logs/storage), secrets or credentials handling (API keys, tokens, env vars), auth/access control changes, or dependency security risks (new packages, version changes). For pure refactoring, documentation, prompt-text, or UI-only tasks, write "None \u2014 no security-relevant changes".
|
|
@@ -250,7 +258,7 @@ Standard planning cycle with full board review.
|
|
|
250
258
|
- **Surprises:** If a surprise reveals a gap (e.g. "schema assumed but not verified"), propose a task to close it.
|
|
251
259
|
- **Architecture Notes:** If a pattern was established that needs follow-up (e.g. "shared service layer created, MCP migration needed"), propose the follow-up.
|
|
252
260
|
- **Strategy gaps:** If an Active Decision has no board tasks supporting it, propose one.
|
|
253
|
-
- **Dogfood observations:** If unactioned dogfood entries are listed in context (with IDs), check if any map to existing tasks. If not, propose a new task. Include \`dogfood
|
|
261
|
+
- **Dogfood observations:** If unactioned dogfood entries are listed in context (with IDs), check if any map to existing tasks. If not, propose a new task. **CRITICAL: Include \`dogfood:<uuid>\` in the new task's \`notes\` field** (e.g. \`"notes": "Addresses recurring friction. dogfood:abc12345-..."\`). This links the task to the observation so the pipeline can track what was actioned. Without this annotation, the observation stays unactioned forever.
|
|
254
262
|
Create new tasks via the \`newTasks\` array in Part 2. Use \`new-N\` IDs in \`cycleHandoffs\` to reference them. **Limit: 3 new tasks per cycle** to prevent backlog bloat.
|
|
255
263
|
**\u26A0\uFE0F DUPLICATE CHECK:** Before adding a task to \`newTasks\`, scan the Cycle Board above for any existing task with the same or very similar title/scope. If a matching task already exists (even with slightly different wording), do NOT create a duplicate \u2014 reference the existing task ID instead. The board already contains all active tasks; re-creating them wastes IDs and bloats the board.
|
|
256
264
|
**\u26A0\uFE0F ALREADY-BUILT CHECK:** Before creating a task, check the recent build reports and cycle log for evidence that this capability was already shipped. If a recent build report shows this feature was completed (even under a different task name), do NOT create a new task for it. This is especially important for UI features, data models, and integrations that may already exist.
|
|
@@ -270,6 +278,151 @@ Standard planning cycle with full board review.
|
|
|
270
278
|
If the Forward Horizon context is absent or there are no meaningful decisions to surface, omit this section entirely. Do NOT generate generic advice like "plan ahead" or "consider testing".
|
|
271
279
|
|
|
272
280
|
**CRITICAL: Review your Part 2 JSON before finishing. Every action from Part 1 must have a corresponding entry in Part 2. If Part 1 mentions corrections, new tasks, AD changes, or handoffs but Part 2 has empty arrays \u2014 you have a persistence bug.**`;
|
|
281
|
+
var PLAN_FRAGMENT_DISCOVERY_GAPS = `
|
|
282
|
+
5. **Discovery Gaps** \u2014 If a Discovery Canvas section is provided in the context below, check which sections are populated vs empty. In cycles 1-10, or whenever canvas sections have been empty for 5+ cycles, include a "Discovery Gaps" paragraph in your cycle log suggesting what context would improve planning. Examples: "Your project context would benefit from MVP boundary definition" or "Consider documenting key user journeys." Keep suggestions conversational \u2014 do NOT create tasks for discovery gaps. If all canvas sections are populated, or no Discovery Canvas is provided, skip this step entirely.`;
|
|
283
|
+
var PLAN_FRAGMENT_RESEARCH = `
|
|
284
|
+
**Research task detection:** When a task's title starts with "Research:" or the task type is "research", add a RESEARCH OUTPUT section to the BUILD HANDOFF after ACCEPTANCE CRITERIA:
|
|
285
|
+
|
|
286
|
+
RESEARCH OUTPUT
|
|
287
|
+
Deliverable: docs/research/[topic]-findings.md (draft path)
|
|
288
|
+
Review status: pending owner approval
|
|
289
|
+
Follow-up tasks: DO NOT submit to backlog until owner confirms findings are actionable
|
|
290
|
+
|
|
291
|
+
Also add to ACCEPTANCE CRITERIA: "[ ] Findings doc drafted and saved to docs/research/ before submitting any follow-up ideas"`;
|
|
292
|
+
var PLAN_FRAGMENT_BUG = `
|
|
293
|
+
**Bug task detection:** When a task's task type is "bug" or the title starts with "Bug:" or "Fix:", apply these rules:
|
|
294
|
+
- **Auto-P1:** If the task's current priority is P2 or lower, upgrade it to "P1 High" via a boardCorrections entry in Part 2. Note the upgrade in Part 1 analysis.
|
|
295
|
+
- Add a BLAST RADIUS note to the BUILD HANDOFF SCOPE section: "Bug fix \u2014 minimal blast radius. Change only what is necessary to fix the reported behaviour. Do not refactor surrounding code or expand scope."
|
|
296
|
+
- Add to ACCEPTANCE CRITERIA: "[ ] Fix is targeted \u2014 no unrelated code changed"`;
|
|
297
|
+
var PLAN_FRAGMENT_IDEA = `
|
|
298
|
+
**Idea task detection:** When a task's task type is "idea", add a scope clarification note to the BUILD HANDOFF:
|
|
299
|
+
- Add to SCOPE (DO THIS): "This task originated as an idea. Confirm the exact deliverable before implementing \u2014 check task notes and any referenced docs for intent. If scope is unclear, flag it in the build report surprises."`;
|
|
300
|
+
var PLAN_FRAGMENT_UI = `
|
|
301
|
+
**UI/visual task detection:** When a task's title or notes contain keywords suggesting frontend visual work (e.g. "visual", "design", "UI", "styling", "refresh", "frontend", "landing page", "hero", "carousel", "theme", "layout", "cockpit", "dashboard", "page"), apply these handoff additions:
|
|
302
|
+
- Add to SCOPE: "Read \`.impeccable.md\` for brand palette, design principles, and audience context before writing any code. Use the \`frontend-design\` skill for implementation."
|
|
303
|
+
- For M/L UI tasks, add to SCOPE: "Use the full UI toolchain: Playground (design preview) \u2192 Frontend-design (build) \u2192 Playwright (verify). The playground is the quality bar. Expect 2-3 iterations."
|
|
304
|
+
- Add to ACCEPTANCE CRITERIA: "[ ] Visually verify rendered output in browser \u2014 provide localhost URL or screenshot to user for review." and "[ ] No raw IDs, abbreviations, or jargon visible without human-readable labels or tooltips."
|
|
305
|
+
- If the task involves image selection, add to SCOPE: "Include brand/theme direction constraints for image selection."
|
|
306
|
+
The planner's job is scoping, not design direction. Design decisions happen at build time via \`.impeccable.md\` and the frontend-design skill \u2014 don't try to write design specs in the handoff.`;
|
|
307
|
+
var PLAN_FRAGMENT_PRODUCT_BRIEF = `
|
|
308
|
+
12. **Product Brief** \u2014 Check whether the product brief still reflects reality. Update the brief when ANY of these apply:
|
|
309
|
+
- A new AD was created or an existing AD was superseded that changes product scope, target user, or positioning
|
|
310
|
+
- The North Star changed or was validated in a way that the brief doesn't reflect
|
|
311
|
+
- A phase completed that shifts what the product IS (not just what was built)
|
|
312
|
+
- The brief describes capabilities, architecture, or direction that are no longer accurate
|
|
313
|
+
- **DRIFT CHECK:** Compare the brief's content against current reality. The brief is drifted if: (a) it describes capabilities that don't exist or have been removed, (b) it references user types, architecture, or positioning that ADs have since changed, (c) the current phase/stage has shifted from what the brief describes, or (d) key metrics or success criteria no longer match the project's direction. Cycle count since last update is a secondary signal only \u2014 a brief updated 15 cycles ago that still accurately describes the product is NOT stale. A brief updated 3 cycles ago that contradicts a recent AD IS drifted.
|
|
314
|
+
If any of these apply, include an updated \`productBrief\` in the structured output. Include the FULL updated brief (not a diff). Preserve all existing sections and user-added content; update facts, numbers, and status to reflect current reality. Do not regenerate the brief every cycle \u2014 but do not let it go stale either.`;
|
|
315
|
+
var PLAN_FRAGMENT_FORWARD_HORIZON = `
|
|
316
|
+
13. **Forward Horizon** \u2014 If a Forward Horizon section is provided in the context below, write a "## Forward Horizon" section in Part 1. Surface 2-3 decisions the team should make before the next phase starts. Each item must be:
|
|
317
|
+
- **Specific** \u2014 reference the upcoming phase by name and the architectural fork or tradeoff involved
|
|
318
|
+
- **Actionable** \u2014 frame as a decision to make, not a vague warning (e.g. "Decide whether to use WebSockets or SSE for real-time updates before starting Phase 4: Real-Time Features")
|
|
319
|
+
- **Tied to trajectory** \u2014 based on current board state, ADs, and velocity, not generic advice
|
|
320
|
+
If the Forward Horizon context is absent or there are no meaningful decisions to surface, omit this section entirely. Do NOT generate generic advice like "plan ahead" or "consider testing".`;
|
|
321
|
+
function buildPlanFullInstructionsConditional(flags, ctx) {
|
|
322
|
+
if (!flags || !ctx) return PLAN_FULL_INSTRUCTIONS;
|
|
323
|
+
const parts = [
|
|
324
|
+
`## FULL MODE
|
|
325
|
+
|
|
326
|
+
Standard planning cycle with full board review.
|
|
327
|
+
|
|
328
|
+
### Steps:
|
|
329
|
+
1. **Cycle Health Check** \u2014 Flag issues: >7 day gaps, unprocessed discovered issues, AD conflicts, stale In Progress tasks (3+ cycles).
|
|
330
|
+
**\u26A0\uFE0F CARRY-FORWARD STALENESS (already-built):** Check the latest carry-forward text for items containing "stale", "already exists", "already implemented", or "already built". For each such item that references a specific task ID, check whether the task is still in Backlog. If a carry-forward says a task's deliverables already exist but the task is still Backlog, emit a \`boardCorrections\` entry setting it to Done with \`closureReason: "Auto-closed \u2014 carry-forward indicates deliverables already exist"\`. Log in the cycle log: "Auto-closed task-XXX \u2014 carry-forward confirmed deliverables exist." This prevents scheduling already-shipped tasks.
|
|
331
|
+
**\u26A0\uFE0F CARRY-FORWARD FORCED RESOLUTION:** If a "Carry-Forward Staleness" section is provided in the context below, it lists task IDs that have been deferred for 3+ consecutive cycles. For each listed task, you MUST take one of these actions \u2014 deferring again without justification is not acceptable:
|
|
332
|
+
- **Escalate:** Emit a \`boardCorrections\` entry upgrading the task to P1 High (if currently P2+) and include a "Carry-Forward Escalation" paragraph in the cycle log: list each escalated task by ID with a 1-sentence rationale.
|
|
333
|
+
- **Cancel:** Emit a \`boardCorrections\` entry setting status to "Cancelled" with a \`closureReason\` explaining why the task is no longer worth pursuing.
|
|
334
|
+
- **Schedule:** Include the task in this cycle's BUILD HANDOFFs. If scheduled, no further action needed.
|
|
335
|
+
If you defer a stale task again, you MUST provide an explicit justification in the cycle log \u2014 e.g. "task-XXX deferred again: blocked on task-YYY which must ship first."
|
|
336
|
+
|
|
337
|
+
2. **Inbox Triage** \u2014 Find unreviewed tasks (reviewed = false). For each: clean title, fill all fields, check for duplicates, verify alignment with Active Decisions. You MUST set priority on unreviewed tasks during triage using these criteria:
|
|
338
|
+
- **P0 Critical** \u2014 Broken, blocking, or data-loss risk. Fix now.
|
|
339
|
+
- **P1 High** \u2014 Strategically aligned: directly advances the current horizon/phase goals or Active Decisions.
|
|
340
|
+
- **P2 Medium** \u2014 Valuable but not strategically urgent: quality improvements, efficiency, polish, infrastructure.
|
|
341
|
+
- **P3 Low** \u2014 Nice-to-have, speculative, or future-horizon work.
|
|
342
|
+
**\u26A0\uFE0F PRIORITY RECALIBRATION \u2014 do NOT rubber-stamp the submitted priority.** The priority set at idea submission reflects the submitter's view at that time, which may be outdated by the time the planner runs. For EVERY unreviewed task, evaluate its priority FROM SCRATCH against: (a) current horizon/stage/phase goals, (b) recent Active Decision changes, (c) recently shipped functionality that makes this task more or less urgent. If your assessed priority differs from the submitted one, set the new priority in \`boardCorrections\` and include the change in a **Priority Recalibration** paragraph in your cycle log (Step 8): list each changed task by ID, old priority \u2192 new priority, and a 1-sentence rationale. This paragraph is how the user sees what the planner recalibrated and why. If no priorities changed during triage, omit the paragraph.
|
|
343
|
+
Also set complexity using the full range \u2014 **XS, Small, Medium, Large, XL** \u2014 based on actual scope, not conservatively. XS = single-line or config change. Small = one file, < 50 lines. Medium = 2-5 files. Large = cross-module, multiple components. XL = architectural, multi-day.
|
|
344
|
+
If a task is clearly obsolete, duplicated, or rejected, set its status to "Cancelled" with a \`closureReason\` explaining why.
|
|
345
|
+
**\u2192 PERSIST:** For each task you set reviewed: true, corrected fields on, or marked "Cancelled", include it in \`boardCorrections\` in Part 2.
|
|
346
|
+
|
|
347
|
+
3. **Board Integrity** \u2014 All tasks have complete fields? Priority still accurate? Duplicates? Stale In Progress tasks?
|
|
348
|
+
**\u2192 PERSIST:** Include any field corrections (status updates, field fixes) in \`boardCorrections\` in Part 2.
|
|
349
|
+
**\u26A0\uFE0F PRIORITY LOCK RULE:** Do NOT change the priority of any task that has \`reviewed: true\`. Reviewed tasks have had their priority confirmed by a human. If you believe a reviewed task's priority should change, note your recommendation in the cycle log but do NOT include a priority change in \`boardCorrections\`. You may only set priority on unreviewed tasks (during triage) or on newly created tasks (\`newTasks\` array). Priority values: P0 Critical, P1 High, P2 Medium, P3 Low.
|
|
350
|
+
**Priority Drift Check:** For reviewed Backlog tasks, check whether their priority still reflects strategic reality. A task submitted as P2 six cycles ago may now be P1 (strategic context shifted) or P3 (redundant, superseded, or de-prioritised by an AD). For each task where drift is detected, check three signals: (1) Does it still align with the current horizon/stage/phase? (2) Has a recent AD changed the strategic importance of this area? (3) Has a recent build shipped functionality that makes this task redundant or more urgent? If drift is found on 1+ tasks, include a **Priority Drift Suggestions** paragraph in your cycle log: list each drifted task by ID, current priority, suggested priority, and a 1-sentence rationale. Do NOT include priority changes in \`boardCorrections\` \u2014 these are suggestions requiring human confirmation, not auto-corrections. Omit this paragraph entirely if no drift is detected.
|
|
351
|
+
|
|
352
|
+
4. **Security Posture Check** \u2014 Review recently completed tasks and current board state for security concerns. Only flag genuine issues \u2014 do not add boilerplate security notes every cycle. Look for:
|
|
353
|
+
- Data exposure risks introduced by recent builds (PII in logs, secrets in storage/config)
|
|
354
|
+
- Unprotected endpoints or missing auth/access control in new features
|
|
355
|
+
- Undocumented secrets or environment variables added without documentation
|
|
356
|
+
- New dependencies with known vulnerabilities or excessive permissions
|
|
357
|
+
**\u2192 PERSIST:** If concerns exist, include them in \`cycleLogNotes\` with a \`[SECURITY]\` tag prefix (e.g. "[SECURITY] New /admin endpoint in task-042 has no auth middleware"). If no concerns, omit \u2014 do not write "[SECURITY] No issues found".`
|
|
358
|
+
];
|
|
359
|
+
if (ctx.hasDiscoveryCanvas) {
|
|
360
|
+
parts.push(PLAN_FRAGMENT_DISCOVERY_GAPS);
|
|
361
|
+
}
|
|
362
|
+
parts.push(`
|
|
363
|
+
6. **Maturity Gate** \u2014 Before scheduling any task, check whether the project is ready for it:
|
|
364
|
+
- **Cycle number as signal:** A Cycle 3 project should not be scheduling OAuth, billing, or analytics tasks. Early cycles focus on core functionality and proving the concept works.
|
|
365
|
+
- **Phase prerequisites:** If the board has phases, tasks from later phases should only be scheduled when earlier phases have completed tasks (check Done count per phase). A task in "Phase 4: Monetisation" is premature if Phase 2 tasks are still in Backlog.
|
|
366
|
+
- **Dependency chain:** If a task's \`dependsOn\` references incomplete tasks, it cannot be scheduled regardless of priority.
|
|
367
|
+
- **Task maturity:** Tasks with \`maturity: "raw"\` are unscoped ideas from the idea tool. The planner IS the scoping mechanism \u2014 scope them as part of planning. For raw tasks selected for a cycle: (a) derive clear scope, acceptance criteria, and effort from the title, notes, and project context, (b) upgrade them to \`maturity: "investigated"\` via a \`boardCorrections\` entry, and (c) generate a BUILD HANDOFF as normal. For research-type raw tasks, scope the handoff as an investigation task \u2014 the deliverable is findings + follow-up backlog tasks, not code. Only leave a raw task unscheduled if you genuinely cannot derive scope from the available context \u2014 note why in the cycle log. Tasks with \`maturity: "ready"\` or no maturity field are considered cycle-ready. Tasks with \`maturity: "investigated"\` have been scoped but may still need refinement \u2014 schedule them if priority warrants it.
|
|
368
|
+
- **What to do with premature tasks:** Leave them in Backlog. Do NOT generate BUILD HANDOFFs for them. If a high-priority task fails the maturity gate due to phase prerequisites or dependencies, note it in the cycle log: "task-XXX deferred \u2014 Phase N prerequisites not met". Raw tasks are NOT premature \u2014 they just need scoping (see Task maturity above).
|
|
369
|
+
|
|
370
|
+
7. **Recommendation** \u2014 Select tasks for this cycle:
|
|
371
|
+
**Pre-assigned tasks:** If a "Pre-Assigned Tasks" section is provided in the context below, those tasks are ALREADY committed to this cycle by the user. Include them automatically \u2014 do NOT re-evaluate whether they belong. Generate BUILD HANDOFFs for each. Count their effort toward the cycle budget. Then fill remaining slots (up to 5 total) from the backlog using the priority rules below.
|
|
372
|
+
**If USER DIRECTION is provided above:** Follow the user's stated focus. Pick the highest-impact task that aligns with their direction. The user knows what they need. Only deviate if a genuine P0 Critical fix exists (broken builds, data loss).
|
|
373
|
+
**Otherwise, select by priority level then impact:**
|
|
374
|
+
- **P0 Critical** \u2014 Broken, blocking, or data-loss risk. Always first.
|
|
375
|
+
- **P1 High** \u2014 Strategically aligned: directly advances the current horizon, phase, or Active Decision goals.
|
|
376
|
+
- **P2 Medium** \u2014 Valuable but not strategically urgent: quality improvements, efficiency, polish, infra.
|
|
377
|
+
- **P3 Low** \u2014 Nice-to-have, speculative, or future-horizon work.
|
|
378
|
+
Within the same priority level, prefer tasks with the highest **impact-to-effort ratio**. Impact is measured by: (a) strategic alignment \u2014 does it advance the current horizon/phase? (b) unlocks other work \u2014 are tasks blocked by this? (c) user-facing \u2014 does it change what users see? (d) compounds over time \u2014 does it make future cycles faster? A high-impact Medium task beats a low-impact Small task at the same priority level. Justify in 2-3 sentences.
|
|
379
|
+
**Blocked tasks:** Tasks with status "Blocked" MUST be skipped during task selection \u2014 they are waiting on external dependencies or gates and cannot be built. Do NOT generate BUILD HANDOFFs for blocked tasks. Do NOT recommend blocked tasks. If a blocked task's gate has been resolved (check the notes and recent build reports), emit a \`boardCorrections\` entry to move it back to Backlog. Report blocked task count in the cycle log.
|
|
380
|
+
**Cycle sizing:** Size the cycle based on what the selected tasks actually require \u2014 not a fixed budget. Select the highest-priority unblocked tasks, estimate each one's effort from its scope, and let the total emerge from the tasks themselves. The historical average effort from Methodology Trends is a reference point for calibration, not a target or floor. A healthy cycle has 4-6 tasks. Cycles with fewer than 4 tasks require explicit justification in the cycle log \u2014 explain why more tasks could not be included. When the backlog has 10+ tasks, the cycle SHOULD have 5+ tasks \u2014 undersized cycles waste planning overhead relative to the available work. If fewer than 4 tasks qualify after filtering (blocked, deferred, raw), check Deferred tasks \u2014 some may be ready to un-defer via a \`boardCorrections\` entry. A 1-task cycle is almost never correct.
|
|
381
|
+
**Theme coherence:** After selecting candidate tasks, check whether they form a coherent theme \u2014 all serving one goal, phase, or module. Single-theme cycles produce better build quality and less context switching. If the top candidates touch 3+ unrelated modules or epics, prefer regrouping around the highest-priority theme and deferring the outliers. Mixed-theme cycles are acceptable when justified (e.g. a P0 fix alongside P1 feature work), but the justification must appear in the cycle log. Name the theme in 3-5 words \u2014 it becomes the \`cycleLogTitle\`.
|
|
382
|
+
|
|
383
|
+
8. **Cycle Log** \u2014 Write 5-10 line entry: what was triaged, what was recommended and why, observations, AD updates. Include a **Priority Recalibration** paragraph if any unreviewed task priorities were changed during triage (Step 2) \u2014 list each by ID with old \u2192 new priority and rationale. Include a **Priority Drift Suggestions** paragraph if reviewed task drift was detected (Step 3).
|
|
384
|
+
**Cycle Notes** \u2014 Optionally include 1-3 lines of cycle-level observations in \`cycleLogNotes\`: estimation accuracy patterns, recurring blockers, velocity trends, or dependency signals. These notes persist across cycles so future planning runs can learn from them. Use null if there are no noteworthy observations this cycle.
|
|
385
|
+
|
|
386
|
+
9. **Active Decisions** \u2014 If any AD needs updating: Type A (confidence change), Type B (modification), or Type C (reversal/supersede).
|
|
387
|
+
**AD Quality Bar:** ADs are for product and architecture choices that constrain future work \u2014 technology selections, data model designs, UX principles, strategic positioning. They are NOT for: process preferences (commit style, PR size), configuration choices (linter rules, tab width), or temporary workarounds. If a decision doesn't affect what gets built or how it's architected, it's not an AD. Apply this bar when proposing new ADs and when triaging existing ones.
|
|
388
|
+
**\u2192 PERSIST:** EVERY AD you created, updated, or confirmed with changes MUST appear in \`activeDecisions\` array in Part 2. Include the full replacement body with ### heading.
|
|
389
|
+
|
|
390
|
+
### Operational Quality Rules
|
|
391
|
+
- **Idea similarity pause:** When the idea tool finds similar tasks during planning, stop and explain the overlap \u2014 do not silently ignore the similarity warning. Duplicates bloat the board and waste build slots.
|
|
392
|
+
- **Backlog as steering wheel:** Task priority and notes in the backlog are the user's primary control mechanism over what gets planned. Respect the priority rankings and read task notes carefully \u2014 they contain user intent that shapes scope and scheduling.
|
|
393
|
+
- **Planning quality is the bar:** Strategy review depth and plan quality set the standard for the product. Do not cut corners on analysis depth, triage thoroughness, or handoff specificity \u2014 these are what users experience as PAPI's value.
|
|
394
|
+
|
|
395
|
+
10. **BUILD HANDOFFs** \u2014 Generate a full BUILD HANDOFF block for the recommended task and up to 4 additional high-priority unblocked tasks (5 total max). Include each handoff in the \`cycleHandoffs\` array in the structured output. The handoffs are written to each task on the board for durability. Remaining tasks will get handoffs in subsequent plans \u2014 do NOT try to cover the entire backlog.
|
|
396
|
+
**SKIP existing handoffs:** Tasks marked with "Has BUILD HANDOFF: yes" or "\u2713 handoff" on the board already have a valid handoff from a previous plan. Do NOT regenerate handoffs for these tasks \u2014 omit them from the \`cycleHandoffs\` array entirely. Only generate handoffs for tasks that do NOT have one yet. Exception: if a task's dependencies have been completed since its handoff was written, or a relevant Active Decision has changed, you MAY regenerate its handoff \u2014 but note this explicitly in the cycle log.
|
|
397
|
+
**Scope pre-check:** Before writing the SCOPE section of each handoff, cross-reference the task against the "Recently Shipped Capabilities" section in the context below (if present). For each candidate task: (1) check if the task's title or scope overlaps with any recently shipped task, (2) check if the FILES LIKELY TOUCHED overlap with files already modified in recent builds, (3) check the architecture notes from recent builds for patterns that already cover this task's scope. If >80% of a task's scope appears in recently shipped capabilities, recommend cancellation via \`boardCorrections\` or reduce the handoff scope to only the missing pieces \u2014 explicitly note what already exists. C126 task-728 was over-scoped because the planner assumed Blocked status needed creating from scratch \u2014 it already existed in types, DB, orient, and build_list. Over-scoped handoffs waste builder time on verification and cause estimation mismatches.
|
|
398
|
+
**Simplest Viable Path rule:** Before writing each BUILD HANDOFF, identify the simplest approach that satisfies the task's goal \u2014 the minimum change, fewest new abstractions, and smallest blast radius. Write the SCOPE (DO THIS) section for that simplest path FIRST. If you believe a more complex approach is warranted (new abstractions, multi-file refactors, framework changes), you MUST include a "WHY NOT SIMPLER" line in the handoff explaining why the simple path is insufficient. If you cannot articulate a concrete reason, use the simpler path. Pay special attention to tasks involving auth, data access, multi-user features, and infrastructure \u2014 these are the most common over-engineering targets.
|
|
399
|
+
**Maturity gate applies here:** Do NOT generate BUILD HANDOFFs for tasks that failed the maturity gate in step 6 (phase prerequisites not met, dependency chain incomplete). Raw tasks that the planner has scoped and upgraded to "investigated" in step 6 ARE eligible for handoffs.
|
|
400
|
+
**Security section guidance:** Each handoff includes a SECURITY CONSIDERATIONS section. Populate it when the task involves: data exposure risks (PII, secrets in logs/storage), secrets or credentials handling (API keys, tokens, env vars), auth/access control changes, or dependency security risks (new packages, version changes). For pure refactoring, documentation, prompt-text, or UI-only tasks, write "None \u2014 no security-relevant changes".
|
|
401
|
+
**Estimation calibration:** Estimate **XS** for: copy/text-only changes, single string replacements, config tweaks, and any task where the scope is "change words in an existing file" with no logic changes. Estimate **S** for: wiring existing adapter methods, adding API routes following established patterns, modifying prompts, or documentation-only changes. Default to S for pattern-following work. Only use M when genuine new architecture, new DB tables, or multi-file architectural changes are needed. Historical data shows systematic over-estimation (198 over vs 8 under out of 528 tasks) \u2014 when in doubt, estimate smaller. If an "Estimation Calibration (Historical)" section is provided in the context below, use its data to adjust your estimates \u2014 it shows how often each estimated size matched the actual effort. Pay special attention to systematic over/under-estimation patterns (e.g. if M\u2192S happens frequently, estimate S instead of M for similar work).
|
|
402
|
+
**Reference docs:** If a task's notes include a \`Reference:\` path (e.g. \`Reference: docs/architecture/papi-brain-v1.md\`), include a REFERENCE DOCS section in the BUILD HANDOFF with those paths. This tells the builder to read the referenced doc for background context before implementing. Do NOT omit or summarise the reference \u2014 pass it through so the builder can access the full document. Only tasks with explicit \`Reference:\` paths in their notes should have this section.
|
|
403
|
+
**Pre-build verification:** EVERY handoff MUST include a PRE-BUILD VERIFICATION section listing 2-5 specific file paths the builder should read before implementing. Derive these from FILES LIKELY TOUCHED \u2014 pick the files most likely to already contain the target functionality. This is the #1 prevention mechanism for wasted build slots (C120, C125, C126 all scheduled already-shipped work). If the builder finds >80% of the scope already implemented, they report "already built" instead of re-implementing.`);
|
|
404
|
+
if (flags.hasResearchTasks) parts.push(PLAN_FRAGMENT_RESEARCH);
|
|
405
|
+
if (flags.hasBugTasks) parts.push(PLAN_FRAGMENT_BUG);
|
|
406
|
+
if (flags.hasIdeaTasks) parts.push(PLAN_FRAGMENT_IDEA);
|
|
407
|
+
if (flags.hasUITasks) parts.push(PLAN_FRAGMENT_UI);
|
|
408
|
+
parts.push(`
|
|
409
|
+
11. **New Tasks (max 3 per cycle)** \u2014 Actively mine the Recent Build Reports for task candidates. For each report, check:
|
|
410
|
+
- **Discovered Issues:** If a build report lists a discovered issue and no existing board task covers it, propose a new task.
|
|
411
|
+
- **Surprises:** If a surprise reveals a gap (e.g. "schema assumed but not verified"), propose a task to close it.
|
|
412
|
+
- **Architecture Notes:** If a pattern was established that needs follow-up (e.g. "shared service layer created, MCP migration needed"), propose the follow-up.
|
|
413
|
+
- **Strategy gaps:** If an Active Decision has no board tasks supporting it, propose one.
|
|
414
|
+
- **Dogfood observations:** If unactioned dogfood entries are listed in context (with IDs), check if any map to existing tasks. If not, propose a new task. **CRITICAL: Include \`dogfood:<uuid>\` in the new task's \`notes\` field** (e.g. \`"notes": "Addresses recurring friction. dogfood:abc12345-..."\`). This links the task to the observation so the pipeline can track what was actioned. Without this annotation, the observation stays unactioned forever.
|
|
415
|
+
Create new tasks via the \`newTasks\` array in Part 2. Use \`new-N\` IDs in \`cycleHandoffs\` to reference them. **Limit: 3 new tasks per cycle** to prevent backlog bloat.
|
|
416
|
+
**\u26A0\uFE0F DUPLICATE CHECK:** Before adding a task to \`newTasks\`, scan the Cycle Board above for any existing task with the same or very similar title/scope. If a matching task already exists (even with slightly different wording), do NOT create a duplicate \u2014 reference the existing task ID instead. The board already contains all active tasks; re-creating them wastes IDs and bloats the board.
|
|
417
|
+
**\u26A0\uFE0F ALREADY-BUILT CHECK:** Before creating a task, check the recent build reports and cycle log for evidence that this capability was already shipped. If a recent build report shows this feature was completed (even under a different task name), do NOT create a new task for it. This is especially important for UI features, data models, and integrations that may already exist.`);
|
|
418
|
+
parts.push(PLAN_FRAGMENT_PRODUCT_BRIEF);
|
|
419
|
+
if (ctx.hasHorizonContext) {
|
|
420
|
+
parts.push(PLAN_FRAGMENT_FORWARD_HORIZON);
|
|
421
|
+
}
|
|
422
|
+
parts.push(`
|
|
423
|
+
**CRITICAL: Review your Part 2 JSON before finishing. Every action from Part 1 must have a corresponding entry in Part 2. If Part 1 mentions corrections, new tasks, AD changes, or handoffs but Part 2 has empty arrays \u2014 you have a persistence bug.**`);
|
|
424
|
+
return parts.join("\n");
|
|
425
|
+
}
|
|
273
426
|
function buildPlanUserMessage(ctx) {
|
|
274
427
|
const modeLabel = ctx.mode.toUpperCase();
|
|
275
428
|
const parts = [
|
|
@@ -290,7 +443,11 @@ function buildPlanUserMessage(ctx) {
|
|
|
290
443
|
if (ctx.mode === "bootstrap") {
|
|
291
444
|
parts.push(PLAN_BOOTSTRAP_INSTRUCTIONS);
|
|
292
445
|
} else {
|
|
293
|
-
|
|
446
|
+
const instructions = ctx.boardFlags ? buildPlanFullInstructionsConditional(ctx.boardFlags, {
|
|
447
|
+
hasDiscoveryCanvas: !!ctx.discoveryCanvas,
|
|
448
|
+
hasHorizonContext: !!ctx.horizonContext
|
|
449
|
+
}) : PLAN_FULL_INSTRUCTIONS;
|
|
450
|
+
parts.push(instructions);
|
|
294
451
|
}
|
|
295
452
|
parts.push("", "---", "", "## PROJECT CONTEXT", "");
|
|
296
453
|
parts.push("### Product Brief", "", ctx.productBrief, "");
|
|
@@ -304,12 +461,18 @@ function buildPlanUserMessage(ctx) {
|
|
|
304
461
|
if (ctx.recentBuildReports) {
|
|
305
462
|
parts.push("### Recent Build Reports", "", ctx.recentBuildReports, "");
|
|
306
463
|
}
|
|
464
|
+
if (ctx.recentlyShippedCapabilities) {
|
|
465
|
+
parts.push("### Recently Shipped Capabilities", "", ctx.recentlyShippedCapabilities, "");
|
|
466
|
+
}
|
|
307
467
|
if (ctx.cycleLog) {
|
|
308
468
|
parts.push("### Cycle Log", "", ctx.cycleLog, "");
|
|
309
469
|
}
|
|
310
470
|
if (ctx.board) {
|
|
311
471
|
parts.push("### Board", "", ctx.board, "");
|
|
312
472
|
}
|
|
473
|
+
if (ctx.preAssignedTasks) {
|
|
474
|
+
parts.push("### Pre-Assigned Tasks", "", ctx.preAssignedTasks, "");
|
|
475
|
+
}
|
|
313
476
|
if (ctx.buildPatterns) {
|
|
314
477
|
parts.push("### Build Patterns", "", ctx.buildPatterns, "");
|
|
315
478
|
}
|
|
@@ -340,6 +503,71 @@ function buildPlanUserMessage(ctx) {
|
|
|
340
503
|
if (ctx.discoveryCanvas) {
|
|
341
504
|
parts.push("### Discovery Canvas", "", ctx.discoveryCanvas, "");
|
|
342
505
|
}
|
|
506
|
+
if (ctx.registeredDocs) {
|
|
507
|
+
parts.push("### Relevant Research Docs", "", ctx.registeredDocs, "");
|
|
508
|
+
}
|
|
509
|
+
if (ctx.carryForwardStaleness) {
|
|
510
|
+
parts.push("### Carry-Forward Staleness", "", ctx.carryForwardStaleness, "");
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return parts.join("\n");
|
|
514
|
+
}
|
|
515
|
+
function buildHandoffsOnlyUserMessage(inputs) {
|
|
516
|
+
const targetCycle = inputs.cycleNumber + 1;
|
|
517
|
+
const taskLines = inputs.preAssignedTasks.map((t) => {
|
|
518
|
+
const notes = t.notes ? `
|
|
519
|
+
Notes: ${t.notes.slice(0, 300)}` : "";
|
|
520
|
+
const hasHandoff = t.hasHandoff;
|
|
521
|
+
return `- **${t.id}:** ${t.title}
|
|
522
|
+
Priority: ${t.priority} | Complexity: ${t.complexity} | Module: ${t.module}
|
|
523
|
+
Phase: ${t.phase} | Epic: ${t.epic}${hasHandoff ? " | Has BUILD HANDOFF: yes" : ""}${notes}`;
|
|
524
|
+
});
|
|
525
|
+
const parts = [
|
|
526
|
+
`## MODE: HANDOFFS-ONLY`,
|
|
527
|
+
`## Cycle Number: ${targetCycle}`,
|
|
528
|
+
"",
|
|
529
|
+
`## HANDOFFS-ONLY MODE`,
|
|
530
|
+
"",
|
|
531
|
+
`The user has pre-assigned ${inputs.preAssignedTasks.length} task(s) to Cycle ${targetCycle} and wants BUILD HANDOFFs generated without full backlog analysis.`,
|
|
532
|
+
"",
|
|
533
|
+
`**Skip these steps entirely:** Inbox Triage, Board Integrity, Security Posture Check, Discovery Gaps, Maturity Gate, Recommendation (task selection), New Tasks, Product Brief update.`,
|
|
534
|
+
"",
|
|
535
|
+
`**Do these steps only:**`,
|
|
536
|
+
`1. Generate a BUILD HANDOFF for each pre-assigned task listed below.`,
|
|
537
|
+
`2. Write a brief Cycle Log entry (3-5 lines) noting this was a handoffs-only cycle and listing the tasks.`,
|
|
538
|
+
`3. If any task already has a BUILD HANDOFF (marked "Has BUILD HANDOFF: yes"), skip it \u2014 do NOT regenerate.`,
|
|
539
|
+
"",
|
|
540
|
+
`Follow the BUILD HANDOFF format from the system prompt. Include SCOPE, SCOPE BOUNDARY, ACCEPTANCE CRITERIA, SECURITY CONSIDERATIONS, PRE-BUILD VERIFICATION, FILES LIKELY TOUCHED, and EFFORT for each task.`,
|
|
541
|
+
"",
|
|
542
|
+
`Your output MUST have TWO parts:`,
|
|
543
|
+
`1. Natural language markdown with BUILD HANDOFF blocks`,
|
|
544
|
+
`2. After \`<!-- PAPI_STRUCTURED_OUTPUT -->\`, a JSON block with structured data`,
|
|
545
|
+
"",
|
|
546
|
+
`The structured output format is the same as full mode. Use empty arrays for \`newTasks\`, \`boardCorrections\`, and \`activeDecisions\`. Populate \`cycleHandoffs\` with your handoffs.`,
|
|
547
|
+
"",
|
|
548
|
+
`---`,
|
|
549
|
+
"",
|
|
550
|
+
`## PRE-ASSIGNED TASKS`,
|
|
551
|
+
"",
|
|
552
|
+
...taskLines,
|
|
553
|
+
"",
|
|
554
|
+
`---`,
|
|
555
|
+
"",
|
|
556
|
+
`## PROJECT CONTEXT`,
|
|
557
|
+
"",
|
|
558
|
+
`### Product Brief`,
|
|
559
|
+
"",
|
|
560
|
+
inputs.productBrief,
|
|
561
|
+
""
|
|
562
|
+
];
|
|
563
|
+
if (inputs.northStar) {
|
|
564
|
+
parts.push("### North Star (current)", "", inputs.northStar, "");
|
|
565
|
+
}
|
|
566
|
+
if (inputs.activeDecisions) {
|
|
567
|
+
parts.push("### Active Decisions", "", inputs.activeDecisions, "");
|
|
568
|
+
}
|
|
569
|
+
if (inputs.recentBuildReports) {
|
|
570
|
+
parts.push("### Recent Build Reports", "", inputs.recentBuildReports, "");
|
|
343
571
|
}
|
|
344
572
|
return parts.join("\n");
|
|
345
573
|
}
|
|
@@ -1077,7 +1305,9 @@ export {
|
|
|
1077
1305
|
buildAdSeedPrompt,
|
|
1078
1306
|
buildConventionsPrompt,
|
|
1079
1307
|
buildHandoffRegenMessage,
|
|
1308
|
+
buildHandoffsOnlyUserMessage,
|
|
1080
1309
|
buildInitialTasksPrompt,
|
|
1310
|
+
buildPlanFullInstructionsConditional,
|
|
1081
1311
|
buildPlanUserMessage,
|
|
1082
1312
|
buildProductBriefPrompt,
|
|
1083
1313
|
buildReviewSystemPrompt,
|
package/package.json
CHANGED