perf(comment-checker): lazy init for CLI path resolution
Remove COMMENT_CHECKER_CLI_PATH constant that was blocking on module import. Replace with getCommentCheckerPathSync() lazy function call. - Defer file system sync calls (existsSync, require.resolve) to first use - Add cli.test.ts with 4 BDD tests for lazy behavior verification
This commit is contained in:
@@ -121,9 +121,6 @@ export function startBackgroundInit(): void {
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy export for backwards compatibility (sync, no download)
|
||||
export const COMMENT_CHECKER_CLI_PATH = findCommentCheckerPathSync()
|
||||
|
||||
export interface HookInput {
|
||||
session_id: string
|
||||
tool_name: string
|
||||
@@ -152,7 +149,7 @@ export interface CheckResult {
|
||||
* @param customPrompt Optional custom prompt to replace default warning message
|
||||
*/
|
||||
export async function runCommentChecker(input: HookInput, cliPath?: string, customPrompt?: string): Promise<CheckResult> {
|
||||
const binaryPath = cliPath ?? resolvedCliPath ?? COMMENT_CHECKER_CLI_PATH
|
||||
const binaryPath = cliPath ?? resolvedCliPath ?? getCommentCheckerPathSync()
|
||||
|
||||
if (!binaryPath) {
|
||||
debugLog("comment-checker binary not found")
|
||||
|
||||
Reference in New Issue
Block a user