Skip to content

fix(scripts): emit 'Copied plan template' status in setup-plan.ps1 (parity with bash)#3198

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-setup-plan-copied-message-parity
Open

fix(scripts): emit 'Copied plan template' status in setup-plan.ps1 (parity with bash)#3198
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-setup-plan-copied-message-parity

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

Description

setup-plan.sh prints a status message after copying the plan template on a fresh run:

cp "$TEMPLATE" "$IMPL_PLAN"
if $JSON_MODE; then echo "Copied plan template to $IMPL_PLAN" >&2
else echo "Copied plan template to $IMPL_PLAN"; fi

The PowerShell twin setup-plan.ps1 emitted nothing on the successful-copy path — only the Plan already exists skip message and the Plan template not found warning had equivalents. So on a first run the two scripts had a divergent status-output contract (the bash behavior is even covered by a test, test_setup_plan_json_parseable_on_first_run, which asserts Copied plan template on stderr).

Fix

Emit the same message after WriteAllText, routed exactly like the sibling Plan already exists message — [Console]::Error.WriteLine in -Json mode so stdout stays pure JSON, Write-Output in text mode. Mirrors the bash wording and stream routing. One source file.

Testing

  • uvx ruff check clean; tests/test_ps1_encoding.py green (edited .ps1 stays ASCII / PowerShell 5.1-safe).
  • New test_ps_setup_plan_copied_message_on_stderr_in_json_mode mirrors the existing bash test_setup_plan_json_parseable_on_first_run: asserts -Json first-run stdout is parseable JSON and Copied plan template is on stderr.
  • Verified fail-before / pass-after locally with Windows PowerShell 5.1: before, stderr is empty and the test fails; after, the message is on stderr and stdout remains pure JSON ({...,"BRANCH":""}). Existing setup-plan tests still pass.

AI Disclosure

  • I did use AI assistance (describe below)

Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI located the missing status message across the bash/PowerShell twins and drafted the fix plus a mirroring regression test; I confirmed the bash wording/stream routing, verified fail-before/pass-after under Windows PowerShell 5.1 (stdout stays pure JSON), and reviewed the diff before submitting.

…arity with bash)

setup-plan.sh prints 'Copied plan template to $IMPL_PLAN' after copying the template (to stderr in --json mode, stdout otherwise), but the PowerShell twin emitted nothing on the successful-copy path -- only the 'Plan already exists' skip message and the 'Plan template not found' warning existed. So the two scripts had a divergent status-output contract on a fresh run.

Emit the same message after WriteAllText, routed like the sibling skip message ([Console]::Error.WriteLine in -Json so stdout stays pure JSON, Write-Output in text mode). Mirrors the bash wording and stream routing exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jawwad-ali jawwad-ali requested a review from mnriem as a code owner June 27, 2026 13:24
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.

1 participant