paths.test.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { describe, expect, it } from "vitest";
  2. import { resolve } from "node:path";
  3. import { getModelIoDir, getProjectMemoryRoot } from "../src/app/paths.js";
  4. describe("getProjectMemoryRoot", () => {
  5. it("uses an opaque workspace identity and the canonical memory suffix", () => {
  6. const first = getProjectMemoryRoot(
  7. "/tmp/zcode-cli",
  8. "/workspace/first",
  9. " remote:ssh:host:/workspace/app ",
  10. );
  11. const second = getProjectMemoryRoot(
  12. "/tmp/zcode-cli",
  13. "/workspace/second",
  14. "remote:ssh:host:/workspace/app",
  15. );
  16. expect(first).toBe("/tmp/zcode-cli/memories/projects/project-dce7d1610bbf24dd/memory");
  17. expect(second).toBe(first);
  18. });
  19. it("normalizes the workspace path only when identity is absent", () => {
  20. const relativeRoot = getProjectMemoryRoot("/tmp/zcode-cli", ".");
  21. const absoluteRoot = getProjectMemoryRoot("/tmp/zcode-cli", resolve("."));
  22. const blankIdentityRoot = getProjectMemoryRoot("/tmp/zcode-cli", ".", " ");
  23. expect(relativeRoot).toBe(absoluteRoot);
  24. expect(blankIdentityRoot).toBe(absoluteRoot);
  25. expect(relativeRoot).toMatch(/\/memories\/projects\/.+\/memory$/);
  26. });
  27. });
  28. describe("getModelIoDir", () => {
  29. it("derives debug and rollout from the configured CLI storage root", () => {
  30. expect(getModelIoDir("/custom/storage/cli", true)).toBe("/custom/storage/cli/debug");
  31. expect(getModelIoDir("/custom/storage/cli", false)).toBe("/custom/storage/cli/rollout");
  32. });
  33. });