- 全局重命名 claude-mem → codebuddy-mem - AI 后端改为 DeepSeek V4 直连 - 适配 CodeBuddy Code 作为 MCP 客户端 - 修复 GS 函数 timeoutMs bug - 新增 README / CHANGELOG / UPSTREAM / install.sh - 协议:AGPL-3.0
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
import { existsSync, readFileSync } from 'fs';
|
|
import { join, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
function resolveRoot() {
|
|
if (process.env.CLAUDE_PLUGIN_ROOT) {
|
|
const root = process.env.CLAUDE_PLUGIN_ROOT;
|
|
if (existsSync(join(root, 'package.json'))) return root;
|
|
}
|
|
try {
|
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
const candidate = dirname(scriptDir);
|
|
if (existsSync(join(candidate, 'package.json'))) return candidate;
|
|
} catch {}
|
|
return null;
|
|
}
|
|
|
|
const ROOT = resolveRoot();
|
|
if (!ROOT) process.exit(0);
|
|
|
|
try {
|
|
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
|
|
const markerPath = join(ROOT, '.install-version');
|
|
if (!existsSync(markerPath)) {
|
|
console.error('claude-mem: runtime not yet set up — run: npx claude-mem repair');
|
|
process.exit(0);
|
|
}
|
|
const marker = JSON.parse(readFileSync(markerPath, 'utf-8'));
|
|
if (marker.version !== pkg.version) {
|
|
console.error(`claude-mem: upgraded to v${pkg.version} — run: npx claude-mem repair`);
|
|
}
|
|
} catch {
|
|
console.error('claude-mem: install marker unreadable — run: npx claude-mem repair');
|
|
}
|
|
process.exit(0);
|