This commit is contained in:
jparkerweb committed 2026-02-17 09:13:23 -08:00
1 parent 725af08c90
commit b942b2b9f0
25 files changed
+1518 -1601

No files matched your search

+13 -7
View File
@@ -1,19 +1,21 @@
import type { StateManager } from '../state/index.js';
import { LOOP_PROMPT_TEMPLATE } from './templates.js';
import type { StateManager, LoopMode } from '../state/index.js';
import { LOOP_PROMPT_TEMPLATE, LOOP_PROMPT_TEMPLATE_PHASE } from './templates.js';
export interface PromptContext {
specPath: string;
iteration: number;
maxIterations: number;
stateManager: StateManager;
loopMode: LoopMode;
jiraTicketId?: string;
}
/**
* Build the prompt for the AI agent
* Simple: just pass spec path and let the LLM discover the next task
* Selects template based on loop mode (task vs phase)
*/
export async function buildLoopPrompt(context: PromptContext): Promise<string> {
const { specPath, iteration, maxIterations, stateManager } = context;
const { specPath, iteration, maxIterations, stateManager, loopMode, jiraTicketId } = context;
// Read scratchpad content for session continuity (LLM writes to this)
const scratchpadContent = await stateManager.readScratchpad();
@@ -21,13 +23,17 @@ export async function buildLoopPrompt(context: PromptContext): Promise<string> {
// Project root is where plan2code-loop was invoked from
const projectRoot = process.cwd();
// Simple template substitution
const prompt = LOOP_PROMPT_TEMPLATE
// Select template based on loop mode
const template = loopMode === 'phase' ? LOOP_PROMPT_TEMPLATE_PHASE : LOOP_PROMPT_TEMPLATE;
// Template substitution
const prompt = template
.replace(/{{projectRoot}}/g, projectRoot)
.replace(/{{specPath}}/g, specPath)
.replace(/{{iteration}}/g, iteration.toString())
.replace(/{{maxIterations}}/g, maxIterations.toString())
.replace(/{{scratchpadContent}}/g, scratchpadContent || '(First iteration - no previous progress)');
.replace(/{{scratchpadContent}}/g, scratchpadContent || '(First iteration - no previous progress)')
.replace(/{{jiraTicketId}}/g, jiraTicketId || '');
return prompt;
}