Skip to content

Fix global multi-format installs#268

Merged
khaliqgant merged 3 commits into
mainfrom
fix/global-multi-format-install
Apr 24, 2026
Merged

Fix global multi-format installs#268
khaliqgant merged 3 commits into
mainfrom
fix/global-multi-format-install

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

User description

Summary

  • make --global apply to regular Claude and Codex file installs, not only MCP config installs
  • track global installs separately in prpm.lock so local installs do not block global installs
  • preserve global installs during update and allow uninstall --as to find global format entries
  • add regression coverage for prpm install @agent-relay/running-headless-orchestrator --as claude,codex --global

Verification

  • npm test --workspace=prpm -- install-file-locations.test.ts
  • npm test --workspace=prpm -- install.test.ts
  • npm run typecheck --workspace=prpm
  • npm run build --workspace=prpm

CodeAnt-AI Description

Fix global installs for multi-format packages

What Changed

  • Global installs now place Claude, Codex, and Claude Markdown files in user-level locations instead of only changing MCP config files.
  • Updating a package keeps its global install path, and uninstall can now find and remove the global copy for a chosen format.
  • Global installs are tracked separately in the lock file so local installs do not block or overwrite them.
  • New coverage checks that a package installed for both Claude and Codex lands in the expected home-directory paths.

Impact

✅ Reliable global multi-format installs
✅ Fewer uninstall mismatches
✅ Local and global installs can coexist

🔄 Retrigger CodeAnt AI Review

Details

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Apr 24, 2026
@my-senior-dev-pr-review

my-senior-dev-pr-review Bot commented Apr 24, 2026

Copy link
Copy Markdown

🤖 My Senior Dev — Analysis Complete

👤 For @khaliqgant

📁 Expert in packages/ (230 edits) • ⚡ 3rd PR this month

View your contributor analytics →


📊 7 files reviewed • 3 high risk • 1 need attention

🚨 High Risk:

  • packages/cli/src/commands/install.ts — Core installation logic changes affecting global installations.

⚠️ Needs Attention:

  • packages/cli/src/commands/install.ts — The modified installation logic introduces significant risks and requires thorough review to ensure stability and security.

🚀 Open Interactive Review →

The full interface unlocks features not available in GitHub:

  • 💬 AI Chat — Ask questions on any file, get context-aware answers
  • 🔍 Smart Hovers — See symbol definitions and usage without leaving the diff
  • 📚 Code Archeology — Understand how files evolved over time (/archeology)
  • 🎯 Learning Insights — See how this PR compares to similar changes

💬 Chat here: @my-senior-dev explain this change — or try @chaos-monkey @security-auditor @optimizer @skeptic @junior-dev

📖 View all 12 personas & slash commands

You can interact with me by mentioning @my-senior-dev in any comment:

In PR comments or on any line of code:

  • Ask questions about the code or PR
  • Request explanations of specific changes
  • Get suggestions for improvements

Slash commands:

  • /help — Show all available commands
  • /archeology — See the history and evolution of changed files
  • /profile — Performance analysis and suggestions
  • /expertise — Find who knows this code best
  • /personas — List all available AI personas

AI Personas (mention to get their perspective):

Persona Focus
@chaos-monkey 🐵 Edge cases & failure scenarios
@skeptic 🤨 Challenge assumptions
@optimizer Performance & efficiency
@security-auditor 🔒 Security vulnerabilities
@accessibility-advocate Inclusive design
@junior-dev 🌱 Simple explanations
@tech-debt-collector 💳 Code quality & shortcuts
@ux-champion 🎨 User experience
@devops-engineer 🚀 Deployment & scaling
@documentation-nazi 📚 Documentation gaps
@legacy-whisperer 🏛️ Working with existing code
@test-driven-purist Testing & TDD

For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews.

Comment thread packages/cli/src/commands/update.ts Outdated
Comment on lines 91 to 94
await handleInstall(`${packageId}@${latestVersion}`, {
as: targetFormat,
global: pkg.global,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Update only forwards pkg.global, which breaks preservation of global installs from existing lockfiles that don't have this new field populated (for example older MCP/plugin entries that tracked globalness in metadata). Those packages will be reinstalled as local during update. Add a fallback based on existing metadata/key location when pkg.global is undefined. [logic error]

Severity Level: Major ⚠️
- ❌ Global MCP installs updated as local via `prpm update`.
- ⚠️ Duplicate MCP configs in global and local config files.
- ⚠️ Editors may read stale global config instead of updated one.
- ⚠️ Behavior differs from original global install user intent.
Steps of Reproduction ✅
1. In a project, install an MCP server package for a global-only editor without using
`--global`, e.g. `prpm install my-mcp-server --as windsorf`. The CLI entrypoint
`createInstallCommand` in `packages/cli/src/commands/install.ts:95-176` routes this to
`handleInstall()` with `options.global` unset and `editor` set to `'windsurf'` for the MCP
install loop at `install.ts:216-245`.

2. During that install, `handleInstall()` in
`packages/cli/src/commands/install.ts:226-249` detects an MCP server package and enters
the MCP branch at `install.ts:151-215`. There, `editor` is `'windsurf'` and `isGlobal` is
forced to `true` via `const isGlobal = globalOnlyEditors.includes(editor) ? true :
(options.global || false);` at `install.ts:175-179`, so MCP servers are written to the
global config path, and `pluginMetadata.mcpGlobal` is stored as `true` when
`pluginMetadata` is assigned at `install.ts:205-211`. However, the lockfile entry is
written via `addToLockfile(updatedLockfile, packageId, { ..., global: options.global, ...
});` at `install.ts:30-44`, so `LockfilePackage.global` in `prpm.lock` remains `undefined`
for this global MCP install.

3. Later, run `prpm update` in the same project. The update handler `handleUpdate()` in
`packages/cli/src/commands/update.ts:16-52` loads installed packages from the lockfile
using `listPackages()` (`packages/cli/src/core/lockfile.ts:478-487`), so the MCP package
appears with `pkg.pluginMetadata.mcpGlobal === true` but `pkg.global === undefined`.
`handleUpdate()` parses the lockfile key with `parseLockfileKey(pkg.id)` at
`update.ts:52-55`, discarding any location information, and computes `const targetFormat =
pkg.format || installedFormat;` at `update.ts:88-90`.

4. For this MCP package, `handleUpdate()` calls `handleInstall()` with `await
handleInstall(\`${packageId}@${latestVersion}\`, { as: targetFormat, global: pkg.global
});` at `packages/cli/src/commands/update.ts:91-94`. Because `pkg.global` is `undefined`,
`options.global` is now falsy inside `handleInstall()`. In the MCP branch at
`install.ts:175-189`, `editor` defaults to `'claude'` when `options.editor` is unset, so
`isGlobal` becomes `false` (`globalOnlyEditors` does not include `'claude'` and
`options.global || false` is `false`). The updated MCP servers are therefore merged into
the *local* config path via `getMCPConfigLocation(editor, isGlobal)` at
`install.ts:193-214`, while the original global config written in step 2 is left
untouched. As a result, a previously global MCP server install is effectively converted to
a local install on update, with globalness not preserved because `handleUpdate` only
forwarded `pkg.global` and did not fall back to `pluginMetadata.mcpGlobal` or any location
information from the lockfile key.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** packages/cli/src/commands/update.ts
**Line:** 91:94
**Comment:**
	*Logic Error: Update only forwards `pkg.global`, which breaks preservation of global installs from existing lockfiles that don't have this new field populated (for example older MCP/plugin entries that tracked globalness in metadata). Those packages will be reinstalled as local during update. Add a fallback based on existing metadata/key location when `pkg.global` is undefined.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/commands/install.ts">

<violation number="1" location="packages/cli/src/commands/install.ts:1722">
P2: Global installs recorded in lockfile are not preserved when reinstalling from `prpm.lock` because `installFromLockfile()` does not forward `lockEntry.global` to `handleInstall`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/cli/src/commands/install.ts
@khaliqgant

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback from cubic and CodeAnt:

  • installFromLockfile() now preserves global installs from lockEntry.global, :global lockfile keys, and legacy pluginMetadata.mcpGlobal.
  • installFromLockfile() and update now preserve MCP editor metadata from pluginMetadata.mcpEditor, so global MCP installs do not get reinstalled into the wrong editor config.
  • Added regression coverage for global lockfile reinstalls and legacy global MCP update metadata.

Verification:

  • npm test --workspace=prpm -- install-from-lockfile.test.ts
  • npm test --workspace=prpm -- update.test.ts
  • npm test --workspace=prpm -- install-file-locations.test.ts install.test.ts update.test.ts install-from-lockfile.test.ts
  • npm run typecheck --workspace=prpm
  • npm run build --workspace=prpm

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/commands/install.ts">

<violation number="1" location="packages/cli/src/commands/install.ts:2190">
P2: Lockfile installs ignore editor-only `--as` values because `singleAs` is not forwarded as `editor`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/cli/src/commands/install.ts Outdated
@khaliqgant

Copy link
Copy Markdown
Collaborator Author

Follow-up review feedback addressed in e1ed48c.\n\n- Forward editor-only --as values, e.g. --as vscode, into installFromLockfile as the MCP editor.\n- Added a command-level regression test that installs an MCP package from prpm.lock with --as vscode and verifies it writes .vscode/mcp.json plus lockfile MCP editor metadata.\n\nVerification:\n- npm test --workspace=prpm -- install-file-locations.test.ts\n- npm test --workspace=prpm -- install-file-locations.test.ts install-from-lockfile.test.ts update.test.ts install.test.ts\n- npm run typecheck --workspace=prpm\n- npm run build --workspace=prpm

@khaliqgant
khaliqgant merged commit 27d92f7 into main Apr 24, 2026
12 checks passed
@khaliqgant
khaliqgant deleted the fix/global-multi-format-install branch April 24, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant