Skip to content

feat: parallelize all CLI commands and standardize output rendering#42

Merged
wpfleger96 merged 5 commits into
mainfrom
feat/parallel-cli-standardization
May 18, 2026
Merged

feat: parallelize all CLI commands and standardize output rendering#42
wpfleger96 merged 5 commits into
mainfrom
feat/parallel-cli-standardization

Conversation

@wpfleger96
Copy link
Copy Markdown
Owner

@wpfleger96 wpfleger96 commented May 15, 2026

This PR completes full parallelization and CLI output standardization for ai-rules, mirroring what shell-configs#33 did for that repo — then goes further with a unified display system that centralizes all Rich markup through display.py.

ai-rules status, ai-rules diff, and ai-rules validate still iterated components sequentially while install and uninstall already used ThreadPoolExecutor with per-thread console buffering. The CLI had 15+ output inconsistencies across error formatting, warning styles, status symbols, user prompts, and section headers — accumulated since the original parallel install refactor.

  • Add display.py with a ContextVar-backed _ConsoleProxy singleton, 16 print helpers (print_error/print_warning/print_info/print_hint/print_success/print_done/print_unchanged/print_skipped/print_absent/print_update/print_would/print_add/print_progress/print_dim/print_label), dim() markup builder, and 13 ICON_* constants — raw Rich markup remains only in intentional string-building contexts (diff coloring, interactive prompts)
  • Route status, diff, and validate through run_components_parallel via a unified run_parallel() function; label on Component is the single source of truth for orchestrator-injected section headers
  • Fix buffered replay ordering (component definition order, not completion order), add defensive ContextVar reset in _make_task, and upgrade _run_unbuffered to a full Progress bar
  • Use Console.print() for buffered replay instead of raw file.write(), enabling proper Rich translation on all platforms
  • Migrate all Confirm.ask() to click.confirm(), remove Console() fallback in config component's _display_symlink_status
  • Fix is_cache_stale() false positives: base settings mtime now falls through to content diff check, preventing "stale" reports after every upgrade when content is unchanged
  • Add "Points to / Expected" output for Wrong target status in skills and extensions, matching the existing behavior in config files
  • Replace brittle type() is not ComponentPlan filter with has_changes property check
  • Propagate KeyboardInterrupt/SystemExit from worker threads instead of swallowing them
  • Defer plan-failure warnings until after Progress bar closes to prevent visual corruption
  • Add tests for run_parallel aggregation, buffer replay ordering, and user-cancellation flows

@wpfleger96 wpfleger96 force-pushed the feat/parallel-cli-standardization branch from ffdb358 to 55f59d0 Compare May 15, 2026 21:22
status, diff, and validate iterated components sequentially while
install and uninstall already used ThreadPoolExecutor with per-thread
console buffering. Routing all five through run_components_parallel
completes the parallelization started in the plan/apply refactor.

Introduces display.py with a ContextVar-backed _ConsoleProxy singleton
and print_error/print_warning/print_info/print_hint helpers, replacing
45+ scattered Console() instantiations and eliminating 15 formatting
inconsistencies across commands, components, and groups.

Fixes buffered replay ordering (component definition order, not
completion order), adds defensive ContextVar reset to prevent
thread-reuse leakage, centralizes section headers in the orchestrator
via display_name, and upgrades _run_unbuffered to a full Progress bar.

Migrates all Confirm.ask() to click.confirm(), fixes false-positive
stale cache detection when base settings mtime changes without content
diff, and adds Points to / Expected output for wrong-target skills
and extensions.
Raw Rich markup patterns ([yellow]⚠, [red]✗, [dim]Run...) replaced
with shared display helpers (print_warning, print_error, print_hint)
throughout the codebase. Adds indent parameter to all display helpers
for indented table-row usage. Migrates remaining Confirm.ask sites to
click.confirm. Removes Console() fallback in config component.
Add print_success, print_done, print_unchanged, print_skipped,
print_absent, print_update, print_would, print_add, print_progress
to display.py. Migrate every remaining console.print call with a
status symbol to the corresponding helper across all components,
commands, and groups. Fixes whole-line dim wrapping inconsistency
and eliminates all ctx.console.print calls with status symbols in
install() methods.
Add dim() markup builder, print_dim/print_label helpers, and ICON_*
constants to display.py. Migrate every remaining [dim], [green]✓,
[yellow]○, [red]✗ pattern across all components, commands, and groups
to the unified display API. Zero raw Rich symbol or dim markup remains
outside display.py.
Crossfire review (3 Claude specialists + Codex + Gemini) surfaced 12
findings. Key changes:

- Replace brittle `type() is not ComponentPlan` filter with `has_changes`
  property check to avoid silently dropping future component plans
- Unify four identical parallel wrapper functions into `run_parallel()`
  with backward-compatible delegates
- Remove redundant `display_name` attribute from Component base class;
  `label` is the single source of truth for section headers
- Fix buffered replay to use `Console.print()` instead of raw
  `file.write()`, enabling proper Rich translation on all platforms
- Defer plan-failure warnings until after Progress bar closes to prevent
  visual corruption
- Propagate `KeyboardInterrupt`/`SystemExit` from worker threads instead
  of swallowing them as component errors
- Remove duplicate section headers from buffered component methods
- Complete raw Rich markup migration in symlinks.py and cli/__init__.py
- Standardize deferred per-method imports across all components
- Fix dead mock targets in confirmation tests (Confirm.ask → click.confirm)
  and add user-cancellation test coverage
- Add tests for run_parallel aggregation and buffer replay ordering
@wpfleger96 wpfleger96 force-pushed the feat/parallel-cli-standardization branch from 6fbf27a to e632843 Compare May 18, 2026 17:23
@wpfleger96 wpfleger96 merged commit 1e4ef69 into main May 18, 2026
4 checks passed
@wpfleger96 wpfleger96 deleted the feat/parallel-cli-standardization branch May 18, 2026 17:48
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