fix(doctor): align qmd probe cwd with runtime

This commit is contained in:
Vincent Koc
2026-03-31 19:22:11 +09:00
parent 6b3f99a11f
commit da7f016db6
3 changed files with 15 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import type { checkQmdBinaryAvailability as checkQmdBinaryAvailabilityFn } from
const note = vi.hoisted(() => vi.fn());
const resolveDefaultAgentId = vi.hoisted(() => vi.fn(() => "agent-default"));
const resolveAgentDir = vi.hoisted(() => vi.fn(() => "/tmp/agent-default"));
const resolveAgentWorkspaceDir = vi.hoisted(() => vi.fn(() => "/tmp/agent-default/workspace"));
const resolveMemorySearchConfig = vi.hoisted(() => vi.fn());
const resolveApiKeyForProvider = vi.hoisted(() => vi.fn());
const resolveActiveMemoryBackendConfig = vi.hoisted(() => vi.fn());
@@ -21,6 +22,7 @@ vi.mock("../terminal/note.js", () => ({
vi.mock("../agents/agent-scope.js", () => ({
resolveDefaultAgentId,
resolveAgentDir,
resolveAgentWorkspaceDir,
}));
vi.mock("../agents/memory-search.js", () => ({
@@ -62,6 +64,7 @@ describe("noteMemorySearchHealth", () => {
note.mockClear();
resolveDefaultAgentId.mockClear();
resolveAgentDir.mockClear();
resolveAgentWorkspaceDir.mockClear();
resolveMemorySearchConfig.mockReset();
resolveApiKeyForProvider.mockReset();
resolveApiKeyForProvider.mockRejectedValue(new Error("missing key"));
@@ -141,6 +144,11 @@ describe("noteMemorySearchHealth", () => {
await noteMemorySearchHealth(cfg, {});
expect(note).not.toHaveBeenCalled();
expect(checkQmdBinaryAvailability).toHaveBeenCalledWith({
command: "qmd",
env: process.env,
cwd: "/tmp/agent-default/workspace",
});
});
it("warns when QMD backend is active but the qmd binary is unavailable", async () => {

View File

@@ -1,5 +1,9 @@
import fsSync from "node:fs";
import { resolveAgentDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import {
resolveAgentDir,
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
} from "../agents/agent-scope.js";
import { resolveMemorySearchConfig } from "../agents/memory-search.js";
import { resolveApiKeyForProvider } from "../agents/model-auth.js";
import { formatCliCommand } from "../cli/command-format.js";
@@ -58,6 +62,7 @@ export async function noteMemorySearchHealth(
const qmdCheck = await checkQmdBinaryAvailability({
command: backendConfig.qmd?.command ?? "qmd",
env: process.env,
cwd: resolveAgentWorkspaceDir(cfg, agentId),
});
if (!qmdCheck.available) {
note(