Skip to content

fix: installCLI() writes version-stable alias that self-updates across plugin upgrades#2056

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-installcli-claude-mem-alias
Closed

fix: installCLI() writes version-stable alias that self-updates across plugin upgrades#2056
Copilot wants to merge 3 commits intomainfrom
copilot/fix-installcli-claude-mem-alias

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

installCLI() bakes the versioned cache path (e.g. .../cache/.../10.5.2/scripts/worker-service.cjs) into ~/.zshrc/~/.bashrc, and the includes('alias claude-mem=') guard prevents any subsequent run from repairing it. After any plugin upgrade, claude-mem either runs stale code or fails with ENOENT.

Changes

  • Stable path: Alias now points to the marketplace path ($HOME/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs) instead of ROOT. Uses $HOME literal so the shell expands it at invocation time.
  • Content-aware guard: Replaced content.includes('alias claude-mem=') with /^alias claude-mem=.*$/m regex match. Detects stale aliases and replaces them in-place; canonical aliases are a no-op; commented-out lines are ignored.
  • Windows parity: Same fix for the PowerShell function claude-mem branch — stable path + regex-based update.
  • Removed .cli-installed marker: The per-ROOT marker file early-return is obsolete now that the guard is content-aware.

Before:

const WORKER_CLI = join(ROOT, 'scripts', 'worker-service.cjs');
const aliasLine = `alias claude-mem='${bunPath} "${WORKER_CLI}"'`;
// ...
if (!content.includes('alias claude-mem=')) {
  writeFileSync(config, content + '\n' + aliasLine + '\n');
}

After:

const STABLE_WORKER_PATH = '$HOME/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs';
const aliasLine = `alias claude-mem='${bunPath} "${STABLE_WORKER_PATH}"'`;
const ALIAS_RE = /^alias claude-mem=.*$/m;
// ...
const match = content.match(ALIAS_RE);
if (!match) {
  writeFileSync(config, content.trimEnd() + '\n' + aliasLine + '\n');
} else if (match[0] !== aliasLine) {
  writeFileSync(config, content.replace(ALIAS_RE, aliasLine));
}

Tests

Added source-level pattern tests and runtime simulation tests covering: fresh install, stale alias replacement, canonical no-op, and commented-out line handling.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bdba946b-4a95-46e4-8884-84858f5fb0c1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/fix-installcli-claude-mem-alias

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits April 17, 2026 20:34
…e aliases

Fixes two compound defects in installCLI():

Defect A: The alias was composed from ROOT which resolves to a
version-pinned cache directory (e.g. .../cache/.../10.5.2/...).
Now uses the stable marketplace path with $HOME for portability.

Defect B: The includes() guard prevented repair of stale aliases.
Now uses regex-based detection that can update stale/version-pinned
aliases to the canonical form on every installer run.

Also fixes the analogous Windows PowerShell branch and removes the
now-unnecessary .cli-installed marker early-return.

Agent-Logs-Url: https://github.com/thedotmack/claude-mem/sessions/e08b65f5-8940-41ad-b10c-fb568de0e873

Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix installCLI to allow self-updating claude-mem alias fix: installCLI() writes version-stable alias that self-updates across plugin upgrades Apr 17, 2026
Copilot AI requested a review from thedotmack April 17, 2026 20:38
@thedotmack thedotmack closed this Apr 26, 2026
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.

installCLI() writes a version-pinned claude-mem alias that can't self-update across plugin upgrades

2 participants