Skip to content

fix update logic#265

Merged
khaliqgant merged 1 commit intomainfrom
fix-upgrade
Mar 23, 2026
Merged

fix update logic#265
khaliqgant merged 1 commit intomainfrom
fix-upgrade

Conversation

@khaliqgant
Copy link
Copy Markdown
Collaborator

@khaliqgant khaliqgant commented Mar 23, 2026

CodeAnt-AI Description

Keep package updates in the same install format

What Changed

  • Updates now keep the package’s existing format when reinstalling, so converted packages stay in the same location instead of being auto-detected differently.
  • Older lockfiles still update correctly by falling back to the format stored in the package key when the newer format field is missing.
  • Added coverage for format preservation, skipping major version updates, and continuing when one package update fails.

Impact

✅ Packages stay in the expected folder after update
✅ Fewer broken updates for converted packages
✅ Safer bulk updates with one failure not stopping the rest

💡 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
Copy link
Copy Markdown

codeant-ai bot commented Mar 23, 2026

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

@my-senior-dev-pr-review
Copy link
Copy Markdown

🤖 My Senior Dev — Analysis Complete

👤 For @khaliqgant

📁 Expert in packages/ (217 edits) • ⚡ 8th PR this month

View your contributor analytics →


📊 2 files reviewed • 3 high risk • 3 need attention

🚨 High Risk:

  • packages/cli/src/commands/update.ts — Critical update logic affected with no test coverage.

⚠️ Needs Attention:

  • packages/cli/src/commands/update.ts — Changes impact core functionality and could affect multiple other files.

🚀 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.

@codeant-ai codeant-ai bot added the size:L This PR changes 100-499 lines, ignoring generated files label Mar 23, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai bot commented Mar 23, 2026

Sequence Diagram

This PR fixes update behavior so the installer always receives an explicit target format when one is known. This prevents unintended auto detection and keeps updated packages in the correct tool specific location, with a fallback for older lockfile entries.

sequenceDiagram
    participant User
    participant UpdateCommand
    participant Registry
    participant Installer

    User->>UpdateCommand: Run update
    UpdateCommand->>UpdateCommand: Read installed packages and parse package key format
    UpdateCommand->>Registry: Check latest version for each package
    Registry-->>UpdateCommand: Return latest version
    UpdateCommand->>UpdateCommand: Choose target format from package format or key format
    alt Update needed
        UpdateCommand->>Installer: Install latest version with as target format
    else Already latest or skipped major
        UpdateCommand->>UpdateCommand: Skip install
    end
Loading

Generated by CodeAnt AI

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@codeant-ai
Copy link
Copy Markdown

codeant-ai bot commented Mar 23, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Format Regression
    The update flow now prefers pkg.format over the installed lockfile format. If a package was previously installed or converted with a specific format, this may cause the update to reinstall it in the registry/default format instead of preserving the existing local format. Please validate that updates keep the on-disk format stable for all package variants.

await handleInstall(`${packageId}@${latestVersion}`, installOptions);
// Always pass the installed format to prevent auto-detection
// Use pkg.format (entry data) with installedFormat (from key suffix) as fallback
const targetFormat = pkg.format || installedFormat;
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: This passes the internal alias claude-md directly into handleInstall, but the install conversion path supports claude.md (dot) and can throw an unsupported target-format error during updates. Normalize this alias before calling install so CLAUDE.md-installed packages can be updated successfully. [logic error]

Severity Level: Major ⚠️
-`prpm update` fails for CLAUDE.md-installed rule packages.
- ⚠️ Those packages remain outdated after update runs.
Suggested change
const targetFormat = pkg.format || installedFormat;
const rawFormat = pkg.format || installedFormat;
const targetFormat = rawFormat === "claude-md" ? "claude.md" : rawFormat;
Steps of Reproduction ✅
1. Run CLI command `prpm install <claude-rule-package>` in a project without `CLAUDE.md`;
`handleInstall()` sets `format = 'claude-md'` at
`packages/cli/src/commands/install.ts:570` (special CLAUDE.md install path).

2. Install writes lockfile entry using installed format via `addToLockfile(... format:
effectiveFormat ...)` at `packages/cli/src/commands/install.ts:1636-1640`, and lock key
generation in `packages/cli/src/core/lockfile.ts:136-145` stores `#claude-md`.

3. Run `prpm update`; command is wired in `packages/cli/src/index.ts:82` and executes
`handleUpdate()` in `packages/cli/src/commands/update.ts:16`, which parses lock key
(`parseLockfileKey`) and sets `targetFormat = pkg.format || installedFormat` at
`update.ts:90`.

4. `handleUpdate()` calls `handleInstall(... { as: 'claude-md' })` at `update.ts:91-93`;
conversion switch in `packages/cli/src/commands/install.ts:762-853` supports `claude.md`
but not `claude-md`, hitting default and throwing `Unsupported target format for
conversion` (`install.ts:852-853`), then update logs failure in `update.ts:96-99`.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** packages/cli/src/commands/update.ts
**Line:** 90:90
**Comment:**
	*Logic Error: This passes the internal alias `claude-md` directly into `handleInstall`, but the install conversion path supports `claude.md` (dot) and can throw an unsupported target-format error during updates. Normalize this alias before calling install so CLAUDE.md-installed packages can be updated successfully.

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.
👍 | 👎

@codeant-ai
Copy link
Copy Markdown

codeant-ai bot commented Mar 23, 2026

CodeAnt AI finished reviewing your PR.

@khaliqgant khaliqgant merged commit 6685e9a into main Mar 23, 2026
12 checks passed
@khaliqgant khaliqgant deleted the fix-upgrade branch March 23, 2026 10:30
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