Lines 1-23javascript
1import { readFileSync, writeFileSync, existsSync, copyFileSync, rmSync } from 'fs'
2import { homedir } from 'os'
3import { join } from 'path'
4import { execFileSync } from 'child_process'
6// Full uninstall — the reverse of setup.mjs. Removes EVERY touch-point Cortex writes onto a machine:
7// 1. ~/.claude.json → mcpServers.cortex
8// 2. ~/.claude/settings.json → Stop/SessionStart/PreCompact cortex hooks
9// 3. ~/.codex/config.toml → [mcp_servers.cortex] + [mcp_servers.cortex.env]
10// 4. ~/.codex/hooks.json → cortex capture Stop hook
11// 5. managed skills → ~/.claude/skills/cortex* + ~/.codex/skills/cortex*
12// 6. launchd agent → ~/Library/LaunchAgents/com.cortex.*.plist (unload + remove)
13// 7. crontab → lines tagged "# cortex ..."
14// 8. off-switch env → launchctl unsetenv CORTEX_SUMMARIZE_DISABLED (macOS)
15// --purge also removes: ~/.cortex state dir, the npx cache, and every .cortex-bak backup.
17// Safe by construction: --dry-run prints the plan and changes nothing; every JSON/TOML file is backed
18// up to <file>.cortex-uninstall-bak before edit; JSON surgery filters only cortex-tagged entries and
19// leaves every other MCP server / hook untouched. Idempotent — re-running is a no-op.
22const CLAUDE_JSON = join(HOME, '.claude.json')
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
lib/uninstall.mjsView on unpkg · L3 23const SETTINGS = join(HOME, '.claude', 'settings.json')