← Back to Pull requests

fix(cli): detect newer layout for bun global installs to avoid error message of unsupported package manager or layout #2291

Open
unknown opened this pull request with 308 lines diff across 3 files
View on GitHub
unknown unknown commented on Jul 28, 2026 03:28 UTC
Author

Related Issue

Discovered while investigating a user report that starting the TUI shows "Detected install source: unsupported package manager or layout" for a bun global installation.

Problem


bw@bws-MacBook-Pro kimi-code % bun list -g | grep kimi
├── @moonshot-ai/kimi-code@0.29.2
bw@bws-MacBook-Pro kimi-code % kimi update
A newer version of @moonshot-ai/kimi-code is available (0.29.2 -> 0.31.0).
Detected install source: unsupported package manager or layout.
To update manually, run: npm install -g @moonshot-ai/kimi-code@0.31.

With installed kimi cli via bun with newer bun 1.3.x+ layout, the kimi or kimi update throws warning messages for "Detected install source: unsupported package manager or layout" .

Recent versions of bun install global packages under ~/.bun/node_modules/<pkg> and create a shim in ~/.bun/bin/. Kimi Code's install-source detection only recognized the older ~/.bun/install/global/node_modules/<pkg> layout, so bun global installs were misclassified as unsupported. This caused:

  • The startup warning Detected install source: unsupported package manager or layout.

  • kimi upgrade falling back to a manual npm command instead of using bun add -g.
  • Both layouts are valid bun global installs and expose the CLI through ~/.bun/bin/:

    # Legacy layout expected by the old code
    ~/.bun/
    ├── bin/
    │   └── kimi -> ../../install/global/node_modules/@moonshot-ai/kimi-code/dist/main.mjs
    └── install/global/node_modules/
        └── @moonshot-ai/kimi-code/
    
    # Current layout used by bun 1.3.14+
    ~/.bun/
    ├── bin/
    │   └── kimi -> ../../node_modules/@moonshot-ai/kimi-code/dist/main.mjs
    └── node_modules/
        └── @moonshot-ai/kimi-code/
    

    What changed

  • Updated apps/kimi-code/src/cli/update/source.ts so the bun heuristic matches both the legacy .bun/install/global/ path and the current .bun/node_modules/ path.

  • Added unit tests in apps/kimi-code/test/cli/update/source.test.ts covering the real-world ~/.bun/node_modules/@moonshot-ai/kimi-code layout.
  • 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.
  • Diff: 308 lines (+231 / -77) across 3 files Reviewer: bowenliang123 Review duration: 169489m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.47) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 308 lines diff across 3 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.343
    Real PR Conversation Timeline
    1 comments
    "Review active on #2291"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.2% (MEDIUM) · Higher = larger blast radius
    47.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.9% · Safe to merge
    27.9%