Skip to content

feat: Phase Separators in Worktree Creation Output - #16

Merged
sahil-noon merged 2 commits into
mainfrom
260531-pnmi-add-phase-separators
Jun 1, 2026
Merged

sahil-noon merged 2 commits into
mainfrom
260531-pnmi-add-phase-separators

Conversation

@sahil87

@sahil87 sahil87 commented May 31, 2026

Copy link
Copy Markdown
Owner

Meta

ID Type Confidence Plan Review
pnmi feat 4.0/5.0 7/7 tasks, 13/13 acceptance ✓ ✓ 1 cycle

Pipeline: intake ✓ → spec ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr

Impact: +189/−8 code (excluding fab/, docs/) · +909/−12 total

Summary

wt create runs three distinct phases in sequence — git worktree operations, the init step (which shells out to fab sync or a user-supplied WORKTREE_INIT_SCRIPT), and the open step — and streams their output to the terminal with no visual demarcation. When something looks wrong or a phase fails, the user cannot tell at a glance which phase owns a given line, nor where wt's own output ends and the external init script's output begins. Labeled phase separators add visual structure without changing any existing message text, exit codes, or the stdout contract.

Changes

  • New PhaseSeparator(label string) string helper in errors.go — NO_COLOR-aware (unicode ── rule on a colored TTY, plain-ASCII -- rule otherwise), fixed ~40-col width, reuses the existing package color vars.
  • wt create emits Git and Open separators on stderr around the deferred-summary and open phases; no change to signal handling, rollback, or stdout.
  • The Init separator is owned by the init runner (crud.go / init.go) so it prints exactly once, with the label echoing the resolved init command's first token (e.g. Init (fab sync)).
  • wt init's diagnostics (banner + init-script output) realigned from stdout to stderr, matching wt create; the stdout final-path contract is untouched and existing substring assertions are preserved.

sahil87 added 2 commits May 31, 2026 21:37
Emit labeled phase separators (Git/Init/Open) on stderr around the three
phases of wt create, and an Init separator from the init runner so it
prints exactly once. The Init label echoes the resolved init command's
first token (e.g. "Init (fab sync)"). Separators are NO_COLOR-aware:
unicode rule on a colored TTY, plain-ASCII rule otherwise, so labels
survive in captured failure logs where attribution matters most.

Also realign wt init's diagnostics (banner + init-script output) from
stdout to stderr, matching wt create. wt init has no machine-readable
result, so its diagnostics belong on stderr; this fixes a latent
inconsistency. The stdout final-path contract consumed by external
callers is untouched, and existing substring assertions are preserved.
@sahil-noon
sahil-noon requested a review from Copilot May 31, 2026 16:34
@sahil-noon
sahil-noon marked this pull request as ready for review May 31, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds labeled phase separators to wt create and wt init output so users can attribute each line to the Git, Init, or Open phase. Output is stderr-only (preserving the stdout launcher contract), NO_COLOR-aware (unicode ── vs ASCII --), and fixed at 40 visible columns. As part of the change, wt init diagnostics and the init child's stdout are realigned from stdout to stderr to match wt create.

Changes:

  • New PhaseSeparator(label string) string helper in internal/worktree/errors.go, with NO_COLOR detection via the existing blanked color vars and rune-counted width.
  • wt create emits Git and Open separators on stderr; the Open separator is gated on worktreeOpen != "skip". The Init separator is owned by the init runner (crud.go) so it prints exactly once and uses the resolved init command as its label.
  • wt init's banner and init-script stdout/stderr realigned to parent stderr; the Init separator is added there too, but skipped on the *InitNotFound path.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/internal/worktree/errors.go Adds the PhaseSeparator helper and phaseSeparatorWidth constant.
src/internal/worktree/errors_test.go Adds colored, NO_COLOR, fixed-width, and multibyte-label tests plus a stripANSI helper.
src/internal/worktree/crud.go Runner emits the Init phase separator before Running worktree init....
src/cmd/wt/create.go Emits Git and Open phase separators on stderr; Open gated on non-skip.
src/cmd/wt/init.go Emits Init separator; realigns banner and init child stdout to stderr.
docs/specs/init-protocol.md Documents stderr wiring and the phase-separator contract.
docs/memory/wt-cli/create-output-phases.md New memory file capturing the contract.
docs/memory/wt-cli/init-failure-contract.md Notes the stderr realignment.
docs/memory/index.md Indexes the new memory file.
.gitignore Ignores .uploads/.
fab/changes/260531-pnmi-add-phase-separators/* Intake, spec, plan, and status artifacts for the change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sahil-noon
sahil-noon merged commit 79aa393 into main Jun 1, 2026
2 checks passed
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.

3 participants