Skip to content

perf(shell): optimize PowerShell detection to prevent false positives on Windows - #72

Merged
nikomatt69 merged 1 commit into
nikomatt69:live-mainfrom
SandroHub013:live-main
May 23, 2026
Merged

perf(shell): optimize PowerShell detection to prevent false positives on Windows#72
nikomatt69 merged 1 commit into
nikomatt69:live-mainfrom
SandroHub013:live-main

Conversation

@SandroHub013

Copy link
Copy Markdown
Collaborator

This PR refines the PowerShell command detection in packages/nikcli/src/shell/shell.ts on Windows.

Problem

Previously, any command referencing standard environment variables using the $ symbol (such as echo $PATH or export FOO=$BAR) was incorrectly flagged as a PowerShell command, forcing nikcli to spawn powershell.exe under the hood.

Because powershell.exe has high startup latency (0.5s to 2.0s due to .NET CLR and profile loading), this caused a severe lag of 1-2 seconds per command. Moreover, Unix-style commands like export FOO=$BAR would fail completely under PowerShell.

Solution

  1. Removed the overly broad /\$(?:\w+|{[^}]+})/ regex from POWERSHELL_MARKERS.
  2. Replaced it with a targeted regex matching actual PowerShell automatic variables (e.g., $PSVersionTable, $profile, $true, $false, $null, $args, $input, $Matches).
  3. Ensures Unix/Bash commands correctly execute in the preferred fallback shell (such as Git Bash or CMD), speeding up execution by up to 50x.

@SandroHub013
SandroHub013 requested a review from nikomatt69 as a code owner May 23, 2026 18:12
@github-actions

Copy link
Copy Markdown

Hey! Your PR title perf(shell): optimize PowerShell detection to prevent false positives on Windows doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, nikcli).

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@nikomatt69
nikomatt69 merged commit 6de81a4 into nikomatt69:live-main May 23, 2026
3 of 5 checks passed
@nikomatt69

Copy link
Copy Markdown
Owner

⚠️ CI Validation Failed

@nikomatt69 — validation failed on this commit.

Detail Value
Failed step Unknown step
Autofix status ⏭️ Autofix skipped
Run View full logs

Failure Summary

(no summary available)

Please inspect the full Actions logs for complete output. Do not share this comment publicly — it may contain redacted paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants