The ekb-mcp -> hose-use rename migration (LEGACY_* constants, syncLegacyEnterprisesDir/syncLegacyGlobalConfig with 7-day grace cleanup, dual-source enterprises resolution) has completed its job: legacy data self-deleted on active machines years of grace ago. Config resolution now returns the single primary ~/.config/hose-use source; startup no longer scans the legacy dir. - core/config/loader.ts: drop legacy constants, sync functions, and LEGACY path from diagnostics candidates; loader.test.ts drops the three legacy-migration cases - domains/approval/db.ts deleted: pure pass-through over core/db whose consumers (repository.ts) already call core/db directly; the four test files now import getDatabase/closeDatabase from core/db - scripts/dev-hygiene.ts: drop the config.legacy finding and legacyConfig snapshot field - docs/daily/* removed: Python-era (ekb-cli/ekb-mcp) notes describing commands and architecture that no longer exist (preserved in git history) No behavior change on machines without legacy data: tsc clean, 313 tests pass (316 minus the 3 removed legacy cases).
49 lines
2.5 KiB
TypeScript
49 lines
2.5 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { buildCleanupPlan, classifyExitCode, isCompatibleBinaryVersion, parseDevHygieneArgs, type Finding } from "./dev-hygiene.ts";
|
|
|
|
describe("dev hygiene tooling", () => {
|
|
test("only accepts development-scoped modes and confirmation flags", () => {
|
|
expect(parseDevHygieneArgs(["status"])).toEqual({ mode: "status", dryRun: false, yes: false, pruneUnreachable: false, help: false });
|
|
expect(parseDevHygieneArgs(["clean", "--dry-run"])).toEqual({ mode: "clean", dryRun: true, yes: false, pruneUnreachable: false, help: false });
|
|
expect(parseDevHygieneArgs(["clean", "--yes", "--prune-unreachable"])).toEqual({ mode: "clean", dryRun: false, yes: true, pruneUnreachable: true, help: false });
|
|
});
|
|
|
|
test("uses semantic exit codes for clean, warning, and blocked states", () => {
|
|
const finding = (level: Finding["level"]): Finding => ({ id: level, level, message: level });
|
|
expect(classifyExitCode([])).toBe(0);
|
|
expect(classifyExitCode([finding("info")])).toBe(0);
|
|
expect(classifyExitCode([finding("warning")])).toBe(2);
|
|
expect(classifyExitCode([finding("blocked")])).toBe(3);
|
|
});
|
|
|
|
test("accepts a development build based on the current stable version", () => {
|
|
expect(isCompatibleBinaryVersion("0.8.6", "0.8.6")).toBe(true);
|
|
expect(isCompatibleBinaryVersion("0.8.6-dev.2+gabc1234", "0.8.6")).toBe(true);
|
|
expect(isCompatibleBinaryVersion("0.8.5-dev.1+gold", "0.8.6")).toBe(false);
|
|
expect(isCompatibleBinaryVersion(undefined, "0.8.6")).toBe(false);
|
|
});
|
|
|
|
test("only plans deletion for clean merged worktrees and local branches", () => {
|
|
const snapshot = {
|
|
repository: {} as any,
|
|
worktrees: [
|
|
{ path: "/tmp/merged", head: "a", branch: "feat/merged", current: false, exists: true, clean: true },
|
|
{ path: "/tmp/dirty", head: "b", branch: "feat/dirty", current: false, exists: true, clean: false },
|
|
],
|
|
branches: [
|
|
{ name: "main", sha: "m", merged: true, gone: false },
|
|
{ name: "feat/merged", sha: "a", merged: true, gone: false },
|
|
{ name: "feat/dirty", sha: "b", merged: true, gone: false },
|
|
{ name: "feat/live", sha: "c", merged: false, gone: false },
|
|
],
|
|
unreachableCommits: ["deadbeef"],
|
|
skill: {} as any,
|
|
binaries: [],
|
|
};
|
|
const plan = buildCleanupPlan(snapshot, false);
|
|
expect(plan.map((action) => action.target)).toEqual(["/tmp/merged", "feat/merged"]);
|
|
expect(plan[1]?.kind).toBe("branch-delete");
|
|
expect(plan.some((action) => action.kind === "git-prune")).toBe(false);
|
|
});
|
|
});
|