Skip to content

Keep pip extras and long hints intact in installer output - #149

Merged
qian-harvard merged 3 commits into
mainfrom
fix/wizard-escape-pip-hint
Nov 11, 2026
Merged

qian-harvard merged 3 commits into
mainfrom
fix/wizard-escape-pip-hint

Conversation

@qian-harvard

@qian-harvard qian-harvard commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

powermcp install prints its pip hints through Rich, and Rich reads [andes,ltspice] as a markup tag and drops it. So every hint that shows the spec loses its extras.

To reproduce on 0.4.1 / current main:

python -m powermcp install --tools andes,ltspice --clients none --dry-run </dev/null
# (dry-run) would run: pip install powermcp

python -m powermcp install --tools andes --clients none </dev/null
# Non-interactive; skipping dependency install. Run: pip install powermcp

Anyone (or any AI agent) who copies that hint installs none of the selected tools. The real install call, subprocess.run([..., "pip", "install", spec]), was never affected. Only the displayed text was wrong.

A second display problem shows up once the extras are visible. Without a TTY, Rich renders at 80 columns and folds any word wider than that. With every Windows tool selected the spec is about 110 characters, so the hint broke powermcp[...] across two lines and a copied command failed. Long config paths in the "Done" line wrapped the same way.

Fix

  • wizard._pip_install: pass the spec through rich.markup.escape in the dry-run, non-interactive, "Skipped", "Installing" and "pip install failed" messages, and print those lines with soft_wrap=True so the command stays on one line. The questionary confirm prompt is not Rich markup, so it keeps the raw spec. The subprocess still gets the raw spec.
  • Other wizard console.print calls that include user-derived text are escaped too: the config path in the "Done" line, client config paths, detected install paths, unknown --tools ids, and exception text. A path like ~/cfg[old]/config.toml was losing [old] the same way. The "Done" and "Configured" path lines also use soft_wrap=True.
  • doctor.py already escaped its table cells and status lines (install_hint goes through there). Only its trailing "Config file:" line was unescaped, and now it is escaped and soft-wrapped.

After the fix:

(dry-run) would run: pip install powermcp[andes,ltspice]
Non-interactive; skipping dependency install. Run: pip install powermcp[andes]
(dry-run) would run: pip install powermcp[andes,egret,genx,hope,ltspice,opendss,plexosdb,powerfactory,powerworld,pscad-windows,pslf,psse,surge]

The change is limited to output. Selection and install behaviour are unchanged.

Tests

New tests in tests/test_wizard.py capture the output:

  • powermcp[andes] appears in dry-run and non-TTY modes (parametrized),
  • in the declined-confirm path (the questionary prompt gets the raw spec),
  • and in the install-failed path (the subprocess still receives powermcp[andes]).
  • The "Done" line keeps a bracketed config path wider than 80 columns.
  • The full Windows --tools all spec stays on one line at 80 columns.

The first five fail on main. The last one, plus the wider-path version of the "Done" test, fail without soft_wrap. All pass on this branch. pytest tests/test_wizard.py tests/test_doctor.py -q gives 41 passed (Python 3.12 venv, pip install -e .).

🤖 Generated with Claude Code

qian-harvard and others added 2 commits November 11, 2026 11:15
`powermcp install` printed its pip hints through Rich, which reads
`[andes,ltspice]` as a markup tag and drops it. The dry-run and
non-interactive hints read `pip install powermcp` with no extras, so
anyone copying them installed none of the selected tools. The actual
pip subprocess call was unaffected.

Escape the spec in every wizard message that shows it, and escape the
user-derived values (config and client paths, detected paths, unknown
tool ids, exception text) that also go through Rich markup. doctor
already escaped its table; its config-file line now does too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a TTY Rich renders at 80 columns and folds any word wider than
that. With every Windows tool selected the spec is ~110 characters, so
the hint split `powermcp[...]` across lines and a copied command broke.
Long config paths in the "Done" and "Configured" lines wrapped the same
way. Print those lines with soft_wrap=True so they stay intact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qian-harvard qian-harvard changed the title Escape pip extras in installer hints so Rich doesn't swallow them Keep pip extras and long hints intact in installer output Nov 11, 2026
@qian-harvard
qian-harvard merged commit d11ae14 into main Nov 11, 2026
5 checks passed
@qian-harvard qian-harvard mentioned this pull request Nov 11, 2026
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