Skip to content

Fix #512: Auto-persist consultation output to project directory#519

Merged
waleedkadous merged 2 commits intomainfrom
builder/bugfix-512-consultation-output-files-dele
Feb 22, 2026
Merged

Fix #512: Auto-persist consultation output to project directory#519
waleedkadous merged 2 commits intomainfrom
builder/bugfix-512-consultation-output-files-dele

Conversation

@waleedkadous
Copy link
Contributor

Summary

When consultations run as background tasks without --output, results were only captured in Claude Code temp files that get cleaned up mid-session. This fix makes the consult command auto-generate persistent output paths in the project directory when running in a builder context.

Fixes #512

Root Cause

The consult command wrote results only to stdout when --output wasn't explicitly provided. Claude Code captures background task stdout in temp files that get aggressively cleaned up. For build_verify phases, porch already passes --output, but for once phases (bugfix, tick) and manually-run consultations, no --output was passed.

Additionally, getBuilderProjectState() had a regex that only matched numeric project IDs, missing bugfix-style IDs like bugfix-512.

Fix

  1. Auto-persist in builder context: When --output is not provided and running in a builder worktree with protocol mode (--type), the consult command now auto-generates a persistent output path: codev/projects/<id>-<name>/<id>-<phase>-iter<N>-<model>.txt

  2. Extended project state: getBuilderProjectState() now returns phase, iteration, and projectDir (and handles non-numeric IDs)

  3. Path compatibility: The auto-generated path matches the pattern used by porch's findReviewFiles() and getReviewFilePath(), so porch can find the results

Test Plan

  • Regression test added (5 tests in persistent-output.test.ts)
  • Build passes
  • All 1964 tests pass (13 skipped)

CMAP Review

(To be added after review)

When running in a builder worktree without --output, the consult command
now auto-generates a persistent output path in the project directory
(codev/projects/<id>-<name>/<id>-<phase>-iter<N>-<model>.txt) so results
survive Claude Code's temp file cleanup.

Also fixes getBuilderProjectState() to handle non-numeric project IDs
like "bugfix-512" and extracts phase/iteration from status.yaml.
Prevents misrouting output when architect-mode consult (--issue) runs
from inside a builder worktree.
@waleedkadous waleedkadous merged commit 41fca10 into main Feb 22, 2026
6 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-512-consultation-output-files-dele branch February 22, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consultation output files deleted mid-session by Claude Code temp file cleanup

1 participant