Skip to content

Local-first 🧠 memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.

TypeScript
1.2 KB
Raw Blame
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { parseWindow, cmdBrainDigest } from "../../src/cli/brain/verbs/digest.ts";
import { makeTestVault, type TestVault } from "../helpers/test-vault.ts";

describe("parseWindow", () => {
  test("parses day windows with or without the d suffix", () => {
    for (const [raw, days] of [
      ["7d", 7],
      ["7", 7],
      ["1d", 1],
      ["30d", 30],
    ] as const) {
      expect(parseWindow(raw)).toBe(days);
    }
  });

  test("rejects non-positive and malformed windows", () => {
    for (const raw of ["0d", "-1d", "abc", "1.5d"]) {
      expect(() => parseWindow(raw)).toThrow();
    }
  });
});

describe("cmdBrainDigest --window exit codes", () => {
  // The verb resolves the vault before it reads its flags.
  let tv: TestVault;
  beforeEach(() => {
    tv = makeTestVault();
  });
  afterEach(() => {
    tv.cleanup();
  });

  test("invalid --window exits with code 2", async () => {
    const code = await cmdBrainDigest(["--window", "abc"]);
    expect(code).toBe(2);
  });

  test("non-positive --window exits with code 2", async () => {
    const code = await cmdBrainDigest(["--window", "0d"]);
    expect(code).toBe(2);
  });
});