Skip to content

fix(agent-core-v2): detect PowerShell 7 via PATH and fix Windows installer probes - #2719

Open
MaxwellGengYF wants to merge 1 commit into
MoonshotAI:mainfrom
Sikao-Engine:dev-fix-pwsh
Open

fix(agent-core-v2): detect PowerShell 7 via PATH and fix Windows installer probes#2719
MaxwellGengYF wants to merge 1 commit into
MoonshotAI:mainfrom
Sikao-Engine:dev-fix-pwsh

Conversation

@MaxwellGengYF

Copy link
Copy Markdown

Related Issue

#2715

Problem

Installing the Kimi Computer Use plugin on Windows fails even when both Windows
PowerShell 5.1 and PowerShell 7 are installed:

  1. PowerShell 7 installed via winget install Microsoft.PowerShell (MSIX) has no
    C:\Program Files\PowerShell\7\pwsh.exe — the binary lives in WindowsApps with an
    execution alias on PATH. The installer only probed the hardcoded MSI path, so spawn
    failed with ENOENT.
  2. A PowerShell 7 installation adds C:\Program Files\PowerShell\7\Modules to the
    machine PSModulePath. Under Windows PowerShell 5.1 this shadows the system modules
    (Microsoft.PowerShell.Utility/.Archive/.Security), so the probe falsely reported
    Get-FileHash, Expand-Archive, and Get-AuthenticodeSignature as missing.
  3. The post-install runtime check used the 3 s detect-probe timeout; a fresh
    kimi-cu.exe doctor can exceed it ("command timed out after 3000ms").

What changed

  • Probe pwsh via where.exe pwsh and the %LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe
    MSIX alias (deduped, probed until one passes), keeping the standard locations first.
  • Pin $env:PSModulePath to $PSHOME first inside both the installer probe and the
    official setup-script invocation, so a PowerShell 7 install can no longer shadow the
    cmdlets Windows PowerShell 5.1 needs.
  • Give the post-install runtime verification the 10 s installer timeout instead of 3 s.
  • Fixed the installerProbeTimeoutMs copy-paste that read ctx.detectProbeTimeoutMs.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0bc0054

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bc005400e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

path.win32.join(localAppData, 'Microsoft', 'WindowsApps', 'pwsh.exe'),
);
}
return candidates.slice(0, MAX_WINDOWS_POWERSHELL_CANDIDATES - 2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the WindowsApps alias within the probe limit

When where.exe returns four or more unique pwsh paths before the WindowsApps execution alias, this slice drops the explicit %LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe candidate that was just appended. In the standard-locations-fail scenario this change is meant to fix, stale PATH shims can consume all four additional slots and the MSIX-only alias is never probed, so installation still fails even though PowerShell 7 is available; reserve a slot for the explicit alias or prioritize it ahead of PATH results.

Useful? React with 👍 / 👎.

Comment on lines +711 to +713
// MSIX installs have no C:\Program Files\PowerShell\7\pwsh.exe; the
// working binary is the WindowsApps execution alias on PATH.
const alias = 'C:\\Users\\probe\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move inline test comments into the header

This adds explanatory comments inside the test body, but the scoped package guide requires comments to live only in the top-of-file /** */ header and not beside statements. Please fold this rationale into the scenario header or the test name so the file stays consistent with the package convention.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L36-L40

Useful? React with 👍 / 👎.

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