clangd-query
Version:
Fast C++ code intelligence CLI tool for humans and AI agents. Provides semantic search, source code reading and usage lookups.
76 lines • 2.97 kB
TypeScript
/**
* Socket utilities for clangd-query client-server architecture
*
* This module provides shared utilities for managing Unix domain sockets and lock files
* used by both the clangd-query client and clangd-daemon server. It handles:
* - Generating consistent socket and lock file paths based on project root
* - Reading and writing lock files with daemon metadata
* - Detecting and cleaning up stale lock files from crashed daemons
* - Process existence checking via signal 0
*/
/**
* Interface for the lock file contents
*/
export interface LockFileData {
/** Process ID of the daemon */
pid: number;
/** Path to the Unix domain socket */
socketPath: string;
/** When the daemon was started */
startTime: number;
/** Absolute path to the project root */
projectRoot: string;
/** Timestamp of newest .js file in dist/ when daemon started */
buildTimestamp?: number;
}
/**
* Generate socket path from project root using MD5 hash
* @param projectRoot Absolute path to the project root
* @returns Path to the Unix domain socket
*/
export declare function generateSocketPath(projectRoot: string): string;
/**
* Generate lock file path from project root
* @param projectRoot Absolute path to the project root
* @returns Path to the lock file
*/
export declare function generateLockFilePath(projectRoot: string): string;
/**
* Read lock file and parse its contents
* @param lockFilePath Path to the lock file
* @returns Parsed lock file data or null if file doesn't exist or is invalid
*/
export declare function readLockFile(lockFilePath: string): LockFileData | null;
/**
* Write lock file with daemon information
* @param lockFilePath Path to the lock file
* @param data Lock file data to write
*/
export declare function writeLockFile(lockFilePath: string, data: LockFileData): void;
/**
* Check if a process with given PID is running
* @param pid Process ID to check
* @returns true if process is running, false otherwise
*/
export declare function isProcessRunning(pid: number): boolean;
/**
* Clean up stale lock files where the process is no longer running
* @param lockFilePath Path to the lock file
* @returns true if lock file was cleaned up, false if it's still valid
*/
export declare function cleanupStaleLockFile(lockFilePath: string): boolean;
/**
* Get log file path for a project
* @param projectRoot Absolute path to the project root
* @returns Path to the log file
*/
export declare function getLogFilePath(projectRoot: string): string;
/**
* Calculate the build timestamp by finding the newest .js file in dist/
* This is used to detect when the daemon code has been rebuilt and needs restart.
*
* @param importMetaUrl The import.meta.url from the calling module (daemon or client)
* @returns Timestamp of the newest .js file in milliseconds
*/
export declare function calculateBuildTimestamp(importMetaUrl: string): number;
//# sourceMappingURL=socket-utils.d.ts.map