docs: Clean up README formatting and remove deprecated CLI hook commands
Removes crystal ball emoji and bullet formatting inconsistencies from README headers. Eliminates mark-dirty and sync-if-dirty CLI commands and related hook configuration code, simplifying the codebase after transitioning to file watcher-based auto-sync.
This commit is contained in:
+1
-89
@@ -16,18 +16,12 @@
|
||||
* codegraph files [options] Show project file structure
|
||||
* codegraph context <task> Build context for a task
|
||||
* codegraph affected [files] Find test files affected by changes
|
||||
* codegraph mark-dirty [path] Mark project as needing sync (hooks)
|
||||
* codegraph sync-if-dirty [path] Sync if marked dirty (hooks)
|
||||
*
|
||||
* Note: Git hooks have been removed. CodeGraph sync is triggered automatically
|
||||
* through codegraph's Claude Code hooks integration.
|
||||
*/
|
||||
|
||||
import { Command } from 'commander';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { spawn } from 'child_process';
|
||||
import { getCodeGraphDir, findNearestCodeGraphRoot, isInitialized } from '../directory';
|
||||
import { getCodeGraphDir, isInitialized } from '../directory';
|
||||
import { createShimmerProgress } from '../ui/shimmer-progress';
|
||||
|
||||
// Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
|
||||
@@ -1078,88 +1072,6 @@ program
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* codegraph mark-dirty [path]
|
||||
*
|
||||
* Touches .codegraph/.dirty to signal that files have changed.
|
||||
* Used by Claude Code PostToolUse hooks to batch syncs.
|
||||
* Runs silently and always exits 0.
|
||||
*/
|
||||
program
|
||||
.command('mark-dirty [path]')
|
||||
.description('Mark project as needing sync (used by Claude Code hooks)')
|
||||
.action(async (pathArg: string | undefined) => {
|
||||
try {
|
||||
const startPath = path.resolve(pathArg || process.cwd());
|
||||
const projectRoot = findNearestCodeGraphRoot(startPath);
|
||||
if (!projectRoot) {
|
||||
// No .codegraph/ found — exit silently
|
||||
process.exit(0);
|
||||
}
|
||||
const dirtyPath = path.join(getCodeGraphDir(projectRoot), '.dirty');
|
||||
fs.writeFileSync(dirtyPath, Date.now().toString(), 'utf-8');
|
||||
} catch {
|
||||
// Never fail — this runs in the background during edits
|
||||
}
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
/**
|
||||
* codegraph sync-if-dirty [path]
|
||||
*
|
||||
* Checks if .codegraph/.dirty exists and, if so, spawns a detached
|
||||
* background process to run `codegraph sync`. The hook process exits
|
||||
* immediately so Claude Code's Stop hook never blocks.
|
||||
*
|
||||
* Removes the marker BEFORE spawning so edits during sync
|
||||
* create a new marker for the next Stop event.
|
||||
* Runs silently and always exits 0.
|
||||
*/
|
||||
program
|
||||
.command('sync-if-dirty [path]')
|
||||
.description('Sync if project was marked dirty (used by Claude Code hooks)')
|
||||
.action(async (pathArg: string | undefined) => {
|
||||
try {
|
||||
const startPath = path.resolve(pathArg || process.cwd());
|
||||
const projectRoot = findNearestCodeGraphRoot(startPath);
|
||||
if (!projectRoot) {
|
||||
process.exit(0);
|
||||
}
|
||||
const dirtyPath = path.join(getCodeGraphDir(projectRoot!), '.dirty');
|
||||
|
||||
// No marker → nothing to do (sub-ms exit)
|
||||
if (!fs.existsSync(dirtyPath)) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Remove marker FIRST so edits during sync create a new one
|
||||
try { fs.unlinkSync(dirtyPath); } catch { /* ignore */ }
|
||||
|
||||
// If not fully initialized (no DB), exit
|
||||
if (!isInitialized(projectRoot!)) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Spawn sync as a detached background process
|
||||
// so this hook exits immediately and doesn't block Claude Code.
|
||||
// Uses process.argv[0]/[1] (e.g. node /path/to/codegraph.js) so it
|
||||
// works whether invoked via global install, npx, or directly.
|
||||
const child = spawn(
|
||||
process.argv[0]!,
|
||||
[process.argv[1]!, 'sync', '--quiet', projectRoot!],
|
||||
{
|
||||
detached: true,
|
||||
stdio: 'ignore',
|
||||
windowsHide: true,
|
||||
}
|
||||
);
|
||||
child.unref();
|
||||
} catch {
|
||||
// Never fail — this runs at the end of Claude responses
|
||||
}
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
/**
|
||||
* codegraph unlock [path]
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user