aicm
Version:
A TypeScript CLI tool for managing AI IDE rules across different projects and teams
51 lines (50 loc) • 1.92 kB
TypeScript
export type HookType = "beforeShellExecution" | "beforeMCPExecution" | "afterShellExecution" | "afterMCPExecution" | "beforeReadFile" | "afterFileEdit" | "beforeSubmitPrompt" | "stop";
export interface HookCommand {
command: string;
}
export interface HooksJson {
version: number;
hooks: {
[K in HookType]?: HookCommand[];
};
}
export interface HookFile {
name: string;
basename: string;
content: Buffer;
sourcePath: string;
source: "local" | "preset";
presetName?: string;
}
/**
* Load hooks configuration from a root directory
* The directory should contain hooks.json (sibling to hooks/ directory)
* All files in the hooks/ subdirectory are copied during installation
*/
export declare function loadHooksFromDirectory(rootDir: string, source: "local" | "preset", presetName?: string): Promise<{
config: HooksJson;
files: HookFile[];
}>;
/**
* Merge multiple hooks configurations into one
* Later configurations override earlier ones for the same hook type
*/
export declare function mergeHooksConfigs(configs: HooksJson[]): HooksJson;
/**
* Rewrite command paths to point to the managed hooks directory (hooks/aicm/)
* At this point, paths are already namespaced filenames from loadHooksFromDirectory
*/
export declare function rewriteHooksConfigToManagedDir(hooksConfig: HooksJson): HooksJson;
/**
* Count the number of hook entries in a hooks configuration
*/
export declare function countHooks(hooksConfig: HooksJson): number;
/**
* Dedupe hook files by namespaced path, warn on content conflicts
* Presets are namespaced with directories, so same basename from different presets won't collide
*/
export declare function dedupeHookFiles(hookFiles: HookFile[]): HookFile[];
/**
* Write hooks configuration and files to Cursor target
*/
export declare function writeHooksToCursor(hooksConfig: HooksJson, hookFiles: HookFile[], cwd: string): void;