fix: doctor ignore install dir in legacy workspace check

This commit is contained in:
Peter Steinberger
2026-01-10 16:23:28 +01:00
parent db5e4b986b
commit e60c3fc1b3
4 changed files with 71 additions and 6 deletions

View File

@@ -0,0 +1,37 @@
import path from "node:path";
import { describe, expect, it } from "vitest";
import { detectLegacyWorkspaceDirs } from "./doctor-workspace.js";
describe("detectLegacyWorkspaceDirs", () => {
it("ignores ~/clawdbot when it doesn't look like a workspace (e.g. install dir)", () => {
const home = "/home/user";
const workspaceDir = "/home/user/clawd";
const candidate = path.join(home, "clawdbot");
const detection = detectLegacyWorkspaceDirs({
workspaceDir,
homedir: () => home,
exists: (value) => value === candidate,
});
expect(detection.activeWorkspace).toBe(path.resolve(workspaceDir));
expect(detection.legacyDirs).toEqual([]);
});
it("flags ~/clawdis when it contains workspace markers", () => {
const home = "/home/user";
const workspaceDir = "/home/user/clawd";
const candidate = path.join(home, "clawdis");
const agentsPath = path.join(candidate, "AGENTS.md");
const detection = detectLegacyWorkspaceDirs({
workspaceDir,
homedir: () => home,
exists: (value) => value === candidate || value === agentsPath,
});
expect(detection.legacyDirs).toEqual([candidate]);
});
});