Skip to content

[BUG] RunVsAgent vscode-powershell integrations break Jetbrains Powershell terminal #1752

Closed

Description

@aGitForEveryone

Problem (one or two sentences)

Zoocode uses RunVsAgent vscode-powershell integrations in Jetbrains IDE's, e.g. PyCharm. The PowerShell profile defined by RunVsAgent is broken and blocks automatic virtual environment activation. It suffers the same issues as reported in Kilo-Org/kilocode#2590 and Kilo-Org/kilocode#2800.

Context (who is affected and when)

The problem occurs when starting a new PowerShell terminal in a Jetbrains IDE. The Powershell profile loads and runs into an error. The first issue is with improper ]-expansion. It returns errors like:

.run-vs-agent-shell-integrations\vscode-powershell\profile.ps1:89 char:21
+     $Result += $esc + "]633;A" + $bell
+                        ~
Unexpected token ']' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

Following the proposed fixes in this PR, solves the issue. The profile now loads correctly.

However, then the second issue pops up, the virtual environment is no longer loaded automatically by the IDE. This PR proposes a fix and manually implementing that also solves the issue.

Now, these changes don't last as reported by that PR. Can these fixes be implemented so they are available for everyone?

Reproduction steps

Used IDE: Pycharm 2026.2.3: Build #PY-262.10968.92, built on September 18, 2026
OS: Windows 11

  1. Open a Pycharm project
  2. Make sure the ZooCode plugin is enabled
  3. Open a fresh PowerShell terminal
  4. Error appears as the profile is run on startup

Expected result

Powershell loads without errors and the project interpreter loads automatically

Actual result

Parsing errors occurred and after fixing that, the virtual environment activation script does not run

Variations tried (optional)

No response

App Version

v3.82.1

API Provider (optional)

None

Model Used (optional)

No response

Zoo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Activity

  1. PierrunoYT commented on Sep 28, 2026

    @PierrunoYT
    Contributor

    Working on it!

  2. PierrunoYT commented on Sep 28, 2026

    @PierrunoYT
    Contributor

    I verified both findings. Neither is in this repo: the profile ships from Zoo-Code-Org/Zoo-Code-Jetbrains. WeCoderTerminalCustomizer.kt copies run-vs-agent-shell-integrations/vscode-powershell/profile.ps1 to ~/.run-vs-agent-shell-integrations/ and launches PowerShell terminals with it.

    1. Parse error: the cause is file encoding, not ]

    Parsing the shipped profile.ps1 with PowerShell's own parser reproduces the report exactly:

    Variant Windows PowerShell 5.1 PowerShell 7
    Shipped file 2 errors: line 89 col 21 and line 144, unexpected token ] 0 errors
    Kilo's fix (double → single quotes, 2fdced3) 1 error, moved to line 154 0 errors
    Shipped file saved with a UTF-8 BOM 0 errors 0 errors
    Shipped file with the emoji removed 0 errors 0 errors

    profile.ps1 is UTF-8 without a BOM, and Windows PowerShell 5.1 reads BOM-less scripts as Windows-1252. The emoji on lines 9, 10, 28 and 182 (📁, 🔑, 🔍) contain the bytes 0x93/0x94, which Windows-1252 decodes as curly double quotes. PowerShell treats those as string delimiters, so string boundaries drift through the rest of the file and the error surfaces at the ] on line 89. That's why Kilo's quote swap only moves the error. Saving the file with a BOM (as JetBrains' own powershell-integration.ps1 does) or keeping it ASCII-only fixes it. PowerShell 7 reads BOM-less files as UTF-8, which is why only 5.1 users see this.

    2. Virtual environment not activated

    PyCharm starts PowerShell with -File <IDE>/plugins/terminal/shell-integrations/powershell/powershell-integration.ps1. That script applies the _INTELLIJ_FORCE_* variables and runs $Env:JEDITERM_SOURCE, which is the venv activate script.

    injectPowerShellScript replaces that -File argument with our profile.ps1 and stores the original path in ORIGINAL_POWERSHELL_SCRIPT, but profile.ps1 never reads that variable. The JetBrains script therefore never runs, and neither does venv activation.

    A simulated launch (stand-in scripts, Windows PowerShell 5.1) confirms it:

    • -File jb-integration.ps1 → venv activated
    • -File profile.ps1 with ORIGINAL_POWERSHELL_SCRIPT set → nothing runs

    Proposed fix (in Zoo-Code-Jetbrains)

    1. Save profile.ps1 (and diagnose.ps1) as UTF-8 with BOM, or remove the emoji.
    2. After the user profile is loaded, run the script the -File swap replaced:
      if ($env:ORIGINAL_POWERSHELL_SCRIPT -and (Test-Path -LiteralPath $env:ORIGINAL_POWERSHELL_SCRIPT)) {
      	. $env:ORIGINAL_POWERSHELL_SCRIPT
      }
      $env:ORIGINAL_POWERSHELL_SCRIPT = $null

    With both changes, the simulated launch parses cleanly in 5.1 and activates the venv again. This was only tested with stand-in scripts, not in a real PyCharm. The real JetBrains script also installs its own prompt hooks, so how they interact with our Prompt override still needs checking in the IDE.

  3. aGitForEveryone commented on Sep 28, 2026

    @aGitForEveryone
    Author

    Awesome analysis! Thanks for picking it up.

  4. aGitForEveryone commented on Oct 22, 2026

    @aGitForEveryone
    Author

    Bumping this issue again. Part of it was addressed in Zoo-Code-Org/Zoo-Code-Jetbrains#10. However, the part where it runs PyCharms activation scripts was not added. I wrote a comment on that in this issue: Zoo-Code-Org/Zoo-Code-Jetbrains#7.

    Can the branch that activates Pycharm/JetBrains activation scripts be added?

  5. aGitForEveryone commented on Oct 27, 2026

    @aGitForEveryone
    Author

    Issue has been solved in Jetbrains repo.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions