-
-
Notifications
You must be signed in to change notification settings - Fork 6k
fix(installer): cache-layout detection, tree-sitter dep, worker:status docs #2061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,8 @@ | |
|
|
||
| import { execSync, spawnSync } from 'child_process'; | ||
| import { existsSync, unlinkSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import { join, dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { logger } from '../../utils/logger.js'; | ||
| import { MARKETPLACE_ROOT } from '../../shared/paths.js'; | ||
|
|
||
|
|
@@ -101,20 +102,44 @@ function execNpm(args: string[], timeoutMs: number = NPM_INSTALL_TIMEOUT_MS): st | |
| return result.stdout.trim(); | ||
| } | ||
|
|
||
| /** | ||
| * Detect if the plugin was installed via Claude Code's cache layout | ||
| * (e.g., ~/.claude/plugins/cache/thedotmack/claude-mem/<version>/) rather than git clone. | ||
| * | ||
| * NOTE: INSTALLED_PLUGIN_PATH is an alias for MARKETPLACE_ROOT which always | ||
| * resolves to ~/.claude/plugins/marketplaces/thedotmack — it never contains | ||
| * '/cache/'. We must check the actual runtime module path instead. | ||
| */ | ||
| function isCacheLayoutInstall(): boolean { | ||
| // Derive the actual path this module is running from at runtime | ||
| let runtimeDir: string; | ||
| if (typeof __dirname !== 'undefined') { | ||
| runtimeDir = __dirname; | ||
| } else { | ||
| runtimeDir = dirname(fileURLToPath(import.meta.url)); | ||
| } | ||
|
|
||
| const normalizedRuntimePath = runtimeDir.replace(/\\/g, '/'); | ||
| return normalizedRuntimePath.includes('/cache/thedotmack/claude-mem/'); | ||
| } | ||
|
|
||
| /** | ||
|
Comment on lines
+112
to
126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The detection should target the running package root (where this code actually executes) rather than the fixed installation target path. Checking function isCacheLayoutInstall(): boolean {
const normalizedPath = getPackageRoot().replace(/\\/g, '/');
return normalizedPath.includes('/cache/thedotmack/claude-mem');
} |
||
| * Get current branch information | ||
| */ | ||
| export function getBranchInfo(): BranchInfo { | ||
| // Check if git repo exists | ||
| const gitDir = join(INSTALLED_PLUGIN_PATH, '.git'); | ||
| if (!existsSync(gitDir)) { | ||
| const isCacheLayout = isCacheLayoutInstall(); | ||
| return { | ||
| branch: null, | ||
| isBeta: false, | ||
| isGitRepo: false, | ||
| isDirty: false, | ||
| canSwitch: false, | ||
| error: 'Installed plugin is not a git repository' | ||
| error: isCacheLayout | ||
| ? 'Plugin installed via cache layout. Use `npx claude-mem install` or Claude Code plugin UI to update.' | ||
| : 'Installed plugin is not a git repository' | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -262,7 +287,7 @@ export async function pullUpdates(): Promise<SwitchResult> { | |
| if (!info.isGitRepo || !info.branch) { | ||
| return { | ||
| success: false, | ||
| error: 'Cannot pull updates: not a git repository' | ||
| error: info.error || 'Cannot pull updates: not a git repository' | ||
| }; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.