From 1ca43a85e00fa896b912e1eeba620c0eb4ffcf20 Mon Sep 17 00:00:00 2001 From: Colby McHenry Date: Mon, 19 Jan 2026 15:20:53 -0600 Subject: [PATCH] Installer now installs codegraph globally The installer runs `npm install -g @colbymchenry/codegraph` so users can simply run `codegraph init -i` instead of the full npx command. Co-Authored-By: Claude Opus 4.5 --- README.md | 2 +- package.json | 2 +- src/installer/banner.ts | 2 +- src/installer/index.ts | 20 ++++++++++++++++---- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 66ba831..11f8315 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ For each project you want to use CodeGraph with: ```bash cd your-project -npx @colbymchenry/codegraph init -i +codegraph init -i ``` That's it! Claude Code will now use CodeGraph tools automatically when a `.codegraph/` directory exists. diff --git a/package.json b/package.json index e1308dd..771f071 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@colbymchenry/codegraph", - "version": "0.2.3", + "version": "0.2.4", "description": "A local-first code intelligence system that builds a semantic knowledge graph from any codebase", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/installer/banner.ts b/src/installer/banner.ts index 3630405..952f6e0 100644 --- a/src/installer/banner.ts +++ b/src/installer/banner.ts @@ -121,7 +121,7 @@ export function showNextSteps(location: 'global' | 'local'): void { if (location === 'global') { console.log(chalk.dim(' Quick start:')); console.log(chalk.dim(' cd your-project')); - console.log(chalk.cyan(' npx @colbymchenry/codegraph init -i')); + console.log(chalk.cyan(' codegraph init -i')); } else { console.log(chalk.dim(' CodeGraph is ready to use in this project!')); } diff --git a/src/installer/index.ts b/src/installer/index.ts index 6542aa4..c70edc5 100644 --- a/src/installer/index.ts +++ b/src/installer/index.ts @@ -5,6 +5,7 @@ * with Claude Code. */ +import { execSync } from 'child_process'; import { showBanner, showNextSteps, success, error, info, chalk } from './banner'; import { promptInstallLocation, promptAutoAllow, InstallLocation } from './prompts'; import { writeMcpConfig, writePermissions, hasMcpConfig, hasPermissions } from './config-writer'; @@ -25,11 +26,22 @@ export async function runInstaller(): Promise { showBanner(); try { - // Step 1: Ask for installation location + // Step 1: Install codegraph globally + console.log(chalk.dim(' Installing codegraph globally...')); + try { + execSync('npm install -g @colbymchenry/codegraph', { stdio: 'pipe' }); + success('Installed codegraph command globally'); + } catch { + // May fail if no permissions, but that's ok - npx still works + info('Could not install globally (try with sudo if needed)'); + } + console.log(); + + // Step 2: Ask for installation location const location = await promptInstallLocation(); console.log(); - // Step 2: Write MCP configuration + // Step 3: Write MCP configuration const alreadyHasMcp = hasMcpConfig(location); writeMcpConfig(location); @@ -39,7 +51,7 @@ export async function runInstaller(): Promise { success(`Added MCP server to ${location === 'global' ? '~/.claude.json' : './.claude.json'}`); } - // Step 3: Ask about auto-allow permissions + // Step 4: Ask about auto-allow permissions const autoAllow = await promptAutoAllow(); console.log(); @@ -54,7 +66,7 @@ export async function runInstaller(): Promise { } } - // Step 4: For local install, initialize the project + // Step 5: For local install, initialize the project if (location === 'local') { await initializeLocalProject(); }