From d8b9bf1aada970e457e1d70b151e6c4a6148f03d Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 12 Apr 2026 02:29:49 +0900 Subject: [PATCH] fix(doctor): check comment-checker lazy-download cache path (#2911, #3315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doctor's comment-checker probe only checked system PATH and the package binary while the runtime resolution path checks the lazy-download cache first. Aligned the doctor resolution order with runtime so the cached binary is recognized as installed. 🤖 Generated with OhMyOpenCode assistance https://github.com/code-yeongyu/oh-my-opencode --- src/cli/doctor/checks/dependencies.test.ts | 22 +++++++++++++++++++++- src/cli/doctor/checks/dependencies.ts | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/cli/doctor/checks/dependencies.test.ts b/src/cli/doctor/checks/dependencies.test.ts index 3fd371632..19ce142b7 100644 --- a/src/cli/doctor/checks/dependencies.test.ts +++ b/src/cli/doctor/checks/dependencies.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from "bun:test" +import { describe, it, expect, mock } from "bun:test" import * as deps from "./dependencies" describe("dependencies check", () => { @@ -41,5 +41,25 @@ describe("dependencies check", () => { expect(info.required).toBe(false) expect(typeof info.installed).toBe("boolean") }) + + it("returns installed=true when cached binary exists", async () => { + //#given cached binary exists + const mockCachedPath = "/mock/path/to/comment-checker" + + mock.module("../../../hooks/comment-checker/downloader", () => ({ + getCachedBinaryPath: () => mockCachedPath, + getCacheDir: () => "/mock/cache/dir", + getBinaryName: () => "comment-checker", + downloadCommentChecker: async () => mockCachedPath, + ensureCommentCheckerBinary: async () => mockCachedPath, + })) + + //#when checking + const info = await deps.checkCommentChecker() + + //#then reports installed=true with cached path + expect(info.installed).toBe(true) + expect(info.path).toBe(mockCachedPath) + }) }) }) diff --git a/src/cli/doctor/checks/dependencies.ts b/src/cli/doctor/checks/dependencies.ts index 8ba478433..7e273c96b 100644 --- a/src/cli/doctor/checks/dependencies.ts +++ b/src/cli/doctor/checks/dependencies.ts @@ -4,6 +4,7 @@ import { dirname, join } from "node:path" import type { DependencyInfo } from "../types" import { spawnWithTimeout } from "../spawn-with-timeout" +import { getCachedBinaryPath } from "../../../hooks/comment-checker/downloader" async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> { try { @@ -113,6 +114,19 @@ function findCommentCheckerPackageBinary(): string | null { } export async function checkCommentChecker(): Promise { + // Check cached binary first (matches runtime resolution order) + const cachedPath = getCachedBinaryPath() + if (cachedPath) { + const version = await getBinaryVersion(cachedPath) + return { + name: "Comment Checker", + required: false, + installed: true, + version, + path: cachedPath, + } + } + const binaryCheck = await checkBinaryExists("comment-checker") const resolvedPath = binaryCheck.exists ? binaryCheck.path : findCommentCheckerPackageBinary()