56db06811e
* Add native Codex hooks integration * Address Codex review feedback * Use durable Codex marketplace root * Address Codex file context review feedback * Harden Codex installer review paths * Report Codex legacy cleanup failures * fix: keep MCP manifests in marketplace sync * fix: bundle zod in MCP server * fix: warn on Codex legacy cleanup failure * Fix hook observation readiness timeouts * Address Codex hook review notes * Tighten Codex MCP file context matching * Resolve final Codex review nits * Add Codex marketplace version guidance * Reset worker failure counter on API fallback * Fix Codex cat flag file extraction
50 lines
1.5 KiB
JavaScript
50 lines
1.5 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);
|
|
|
|
function emitUpgradeHint(message) {
|
|
if (process.env.CLAUDE_MEM_CODEX_HOOK === '1') {
|
|
console.log(JSON.stringify({
|
|
hookSpecificOutput: {
|
|
hookEventName: 'SessionStart',
|
|
additionalContext: message,
|
|
},
|
|
}));
|
|
} else {
|
|
console.error(message);
|
|
}
|
|
}
|
|
|
|
try {
|
|
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
|
|
const markerPath = join(ROOT, '.install-version');
|
|
if (!existsSync(markerPath)) {
|
|
emitUpgradeHint('claude-mem: runtime not yet set up - run: npx claude-mem@latest install');
|
|
process.exit(0);
|
|
}
|
|
const marker = JSON.parse(readFileSync(markerPath, 'utf-8'));
|
|
if (marker.version !== pkg.version) {
|
|
emitUpgradeHint(`claude-mem: upgraded to v${pkg.version} - run: npx claude-mem@latest install`);
|
|
}
|
|
} catch {
|
|
emitUpgradeHint('claude-mem: install marker unreadable - run: npx claude-mem@latest install');
|
|
}
|
|
process.exit(0);
|