fix: Use bare codegraph everywhere, add preuninstall cleanup
- Revert configs (MCP, hooks) to use bare `codegraph` command - Remove all npx references from configs and messaging - Add preuninstall script that runs on `npm uninstall -g` to clean up MCP server, permissions, hooks, and CLAUDE.md section - Show uninstall instructions in post-install next steps
This commit is contained in:
@@ -113,21 +113,18 @@ export function warn(message: string): void {
|
||||
/**
|
||||
* Show the "next steps" section after installation
|
||||
*/
|
||||
export function showNextSteps(location: 'global' | 'local', codegraphAvailable?: boolean): void {
|
||||
export function showNextSteps(location: 'global' | 'local'): void {
|
||||
console.log();
|
||||
console.log(chalk.bold(' Done!') + ' Restart Claude Code to use CodeGraph.');
|
||||
console.log();
|
||||
|
||||
if (location === 'global') {
|
||||
const cmd = codegraphAvailable ? 'codegraph' : 'npx @colbymchenry/codegraph';
|
||||
console.log(chalk.dim(' Quick start:'));
|
||||
console.log(chalk.dim(' cd your-project'));
|
||||
console.log(chalk.cyan(` ${cmd} init -i`));
|
||||
if (!codegraphAvailable) {
|
||||
console.log();
|
||||
console.log(chalk.dim(' Tip: For a shorter command, install globally:'));
|
||||
console.log(chalk.dim(' npm install -g @colbymchenry/codegraph'));
|
||||
}
|
||||
console.log(chalk.cyan(' codegraph init -i'));
|
||||
console.log();
|
||||
console.log(chalk.dim(' To uninstall:'));
|
||||
console.log(chalk.dim(' npm uninstall -g @colbymchenry/codegraph'));
|
||||
} else {
|
||||
console.log(chalk.dim(' CodeGraph is ready to use in this project!'));
|
||||
}
|
||||
|
||||
@@ -98,13 +98,13 @@ function writeJsonFile(filePath: string, data: Record<string, any>): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MCP server configuration — always uses npx for reliability
|
||||
* Get the MCP server configuration
|
||||
*/
|
||||
function getMcpServerConfig(): Record<string, any> {
|
||||
return {
|
||||
type: 'stdio',
|
||||
command: 'npx',
|
||||
args: ['@colbymchenry/codegraph', 'serve', '--mcp'],
|
||||
command: 'codegraph',
|
||||
args: ['serve', '--mcp'],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export function hasPermissions(location: InstallLocation): boolean {
|
||||
* Stop → sync-if-dirty (sync, ensures fresh index before next user turn)
|
||||
*/
|
||||
function getHooksConfig(): Record<string, any> {
|
||||
const command = 'npx @colbymchenry/codegraph';
|
||||
const command = 'codegraph';
|
||||
|
||||
return {
|
||||
PostToolUse: [
|
||||
|
||||
+6
-11
@@ -25,13 +25,10 @@ export async function runInstaller(): Promise<void> {
|
||||
showBanner();
|
||||
|
||||
try {
|
||||
// Step 1: Try global install for bare `codegraph` command convenience.
|
||||
// This is best-effort — configs always use npx regardless.
|
||||
let codegraphAvailable = false;
|
||||
// Step 1: Ensure codegraph is installed globally
|
||||
try {
|
||||
const checkCmd = process.platform === 'win32' ? 'where codegraph' : 'command -v codegraph';
|
||||
execSync(checkCmd, { stdio: 'pipe' });
|
||||
codegraphAvailable = true;
|
||||
} catch {
|
||||
// Not installed globally yet — try to install
|
||||
console.log(chalk.dim(' Installing codegraph globally...'));
|
||||
@@ -40,18 +37,16 @@ export async function runInstaller(): Promise<void> {
|
||||
// Verify it actually worked (PATH may not include npm global bin)
|
||||
try {
|
||||
execSync(process.platform === 'win32' ? 'where codegraph' : 'command -v codegraph', { stdio: 'pipe' });
|
||||
codegraphAvailable = true;
|
||||
success('Installed codegraph command globally');
|
||||
} catch {
|
||||
// Install "succeeded" but command not in PATH — common with nvm/fnm
|
||||
info('Global install succeeded but codegraph is not in your PATH');
|
||||
info('You may need to add npm\'s global bin to your PATH, or use:');
|
||||
info(' npx @colbymchenry/codegraph <command>');
|
||||
info('You may need to add npm\'s global bin directory to your PATH');
|
||||
info('Then restart your terminal and run: codegraph init -i');
|
||||
}
|
||||
} catch {
|
||||
info('Could not install globally (permission denied)');
|
||||
info('You can install manually with: sudo npm install -g @colbymchenry/codegraph');
|
||||
info('Or use: npx @colbymchenry/codegraph <command>');
|
||||
info('Try: sudo npm install -g @colbymchenry/codegraph');
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
@@ -113,7 +108,7 @@ export async function runInstaller(): Promise<void> {
|
||||
}
|
||||
|
||||
// Show next steps
|
||||
showNextSteps(location, codegraphAvailable);
|
||||
showNextSteps(location);
|
||||
} catch (err) {
|
||||
console.log();
|
||||
if (err instanceof Error && err.message.includes('readline was closed')) {
|
||||
@@ -139,7 +134,7 @@ async function initializeLocalProject(): Promise<void> {
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
error(`Could not load native modules: ${msg}`);
|
||||
info('Skipping project initialization. You can run "npx @colbymchenry/codegraph init -i" later.');
|
||||
info('Skipping project initialization. You can run "codegraph init -i" later.');
|
||||
info('If this persists, try a Node.js LTS version (20 or 22).');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user