fix(doctor): check comment-checker lazy-download cache path (#2911, #3315)

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
This commit is contained in:
YeonGyu-Kim
2026-04-12 02:29:49 +09:00
parent 64e5593697
commit d8b9bf1aad
2 changed files with 35 additions and 1 deletions
+21 -1
View File
@@ -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)
})
})
})
+14
View File
@@ -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<DependencyInfo> {
// 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()