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:
justsisyphus
2026-01-15 14:23:15 +09:00
parent 84e97ba900
commit 1dd369fda5
2 changed files with 69 additions and 4 deletions
+1 -4
View File
@@ -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")