diff --git a/package.json b/package.json index 8ff7f54..b4e1f10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mikefreno/ralpi", - "version": "0.1.5", + "version": "0.1.7", "description": "Execute tasks from task files/PRD's using DAG-based dependency resolution with persistent progress tracking", "keywords": [ "pi-package", diff --git a/src/executor.ts b/src/executor.ts index 37071c4..d92a043 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -155,7 +155,6 @@ export async function runTask( durationMs: number; toolUsage?: ToolUsage; outputPreview?: string; - sessionFile?: string; commitMessages?: string[]; commitSummary?: string; }> { @@ -169,12 +168,6 @@ export async function runTask( config.prompts.projectContext, ); - // Write prompt to .ralpi/ with timestamp (for debugging) - const ralpiDir = path.join(projectDir, ".ralpi"); - ensureDir(ralpiDir); - const promptFile = path.join(ralpiDir, `prompt-${startMs}.md`); - writeFileSafe(promptFile, prompt); - const taskHeader = `${task.id} · ${task.title}`; // When running in parallel, all tasks share a single widget so ordering @@ -262,11 +255,6 @@ export async function runTask( // Use task-level timeout if set, otherwise fall back to config const timeoutMs = task.timeoutMs ?? config.execution.timeoutMs; - // Pre-create session file path so events stream to disk (avoids 300+ MB in-memory accumulation) - const sessionsDir = path.join(ralpiDir, "sessions"); - ensureDir(sessionsDir); - const sessionFilePath = path.join(sessionsDir, `${task.id}-${startMs}.txt`); - // Run task asynchronously via Pi SDK — event loop stays responsive const output = await runAgentSession( prompt, @@ -291,7 +279,6 @@ export async function runTask( } }, undefined, // no abort signal - sessionFilePath, // stream events to file assignedModel ?? config.model, config.thinkingLevel, ); @@ -318,7 +305,6 @@ export async function runTask( success: false, error: output.error, durationMs, - sessionFile: sessionFilePath, // events streamed to file for debugging }; } @@ -328,13 +314,10 @@ export async function runTask( // Capture git commits made during this task const { commitMessages, commitSummary } = captureGitCommits(projectDir); - // Session file already written by runAgentSession (events streamed to disk) - const sessionFile = sessionFilePath; - // Build output preview (first 500 chars of agent text) const outputPreview = agentText.length > 500 - ? agentText.slice(0, 500) + "\n... (truncated, see session file)" + ? agentText.slice(0, 500) + "\n... (truncated)" : agentText; // Extract reflection from agent output @@ -350,7 +333,6 @@ export async function runTask( durationMs, toolUsage, outputPreview, - sessionFile, commitMessages, commitSummary, }; @@ -702,7 +684,6 @@ async function executeTask( result.durationMs, result.reflection, result.toolUsage, - result.sessionFile, result.outputPreview, result.commitMessages, result.commitSummary, diff --git a/src/progress.ts b/src/progress.ts index 531e9ce..9e0f821 100644 --- a/src/progress.ts +++ b/src/progress.ts @@ -171,7 +171,6 @@ export class ProgressTracker { durationMs: number, reflection?: Reflection, toolUsage?: ToolUsage, - sessionFile?: string, outputPreview?: string, commitMessages?: string[], commitSummary?: string, @@ -183,7 +182,6 @@ export class ProgressTracker { prd.tasks[taskId].durationMs = durationMs; if (reflection) prd.tasks[taskId].reflection = reflection; if (toolUsage) prd.tasks[taskId].toolUsage = toolUsage; - if (sessionFile) prd.tasks[taskId].sessionFile = sessionFile; if (outputPreview) prd.tasks[taskId].outputPreview = outputPreview; if (commitMessages) prd.tasks[taskId].commitMessages = commitMessages; if (commitSummary) prd.tasks[taskId].commitSummary = commitSummary; diff --git a/src/types.ts b/src/types.ts index a4852a9..cdce6b0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -97,8 +97,6 @@ export interface TaskProgressInfo { error?: string; /** Tool usage counts from parsed subprocess output */ toolUsage?: ToolUsage; - /** Path to session output file */ - sessionFile?: string; /** Truncated output preview for expanded view */ outputPreview?: string; /** Git commit messages from task execution */ diff --git a/src/utils.ts b/src/utils.ts index b51af59..bf27688 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -432,7 +432,6 @@ export async function runAgentSession( timeoutMs: number, onEvent?: (event: AgentSessionEvent) => void, signal?: AbortSignal, - sessionFile?: string, model?: unknown, thinkingLevel?: unknown, ): Promise<{ @@ -450,13 +449,6 @@ export async function runAgentSession( bash: 0, other: 0, }; - // Stream events to file instead of accumulating in memory. - // Accumulating caused "Invalid string length" crashes when - // JSON.stringify(output.events, null, 2) produced 300+ MB strings. - const eventStream = sessionFile - ? fs.createWriteStream(sessionFile, { flags: "a" }) - : null; - // Wire timeout via abort signal (only when set; 0 means inherit Pi's defaults) let timeoutHandle: NodeJS.Timeout | null = null; if (timeoutMs > 0) { @@ -500,10 +492,6 @@ export async function runAgentSession( let stopReason: string | undefined; const unsubscribe = result.session.subscribe((event) => { - // Stream event to file (avoids accumulating 300+ MB in memory) - if (eventStream) { - eventStream.write(JSON.stringify(event) + "\n"); - } onEvent?.(event); if (event.type === "message_end") { @@ -540,11 +528,6 @@ export async function runAgentSession( signal?.removeEventListener("abort", abortHandler); if (timeoutHandle) clearTimeout(timeoutHandle); - // Flush and close the event stream before returning - if (eventStream) { - await new Promise((resolve) => eventStream.end(resolve)); - } - if (errorMessage && !finalText) { return { success: false, @@ -561,19 +544,16 @@ export async function runAgentSession( text: finalText.trim(), toolUsage, stopReason, - events: [], // streamed to file + events: [], }; } catch (error) { if (timeoutHandle) clearTimeout(timeoutHandle); - if (eventStream && !eventStream.destroyed) { - eventStream.end(); - } return { success: false, text: "", error: error instanceof Error ? error.message : String(error), toolUsage, - events: [], // streamed to file + events: [], }; } finally { sessionRef.session?.dispose();