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
/**
* P2 (t_e82101a5): the `o2b brain batch-plan` CLI plumbs `--src-subpath` and
* `--exclude` through to planBatches. Behavior is covered at the core level;
* this asserts the flags reach the planner and that omitting them is unchanged.
*/
import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { runCli } from "../helpers/run-cli.ts";
import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
let configPath: string;
beforeEach(() => {
vault = mkdtempSync(join(tmpdir(), "o2b-scope-cli-vault-"));
configHome = mkdtempSync(join(tmpdir(), "o2b-scope-cli-cfg-"));
configPath = join(configHome, "config.yaml");
writeFileSync(configPath, `vault: ${vault}\nagent_name: claude\n`, "utf8");
});
afterEach(() => {
rmSync(vault, { recursive: true, force: true });
rmSync(configHome, { recursive: true, force: true });
});
function write(rel: string): void {
const abs = join(vault, rel);
mkdirSync(join(abs, ".."), { recursive: true });
writeFileSync(abs, "content\n", "utf8");
}
const ENV = () => ({ OPEN_SECOND_BRAIN_CONFIG: configPath });
describe("o2b brain batch-plan source-dir contract", () => {
test("an absolute source dir refuses with the vault-relative contract, not a false non-existence", async () => {
// S20: the absolute argument was joined INSIDE the vault path, so a
// directory the operator had just listed was refused as missing - and
// the message never stated the real contract, that the argument is
// vault-relative.
write("sources/note.md");
const res = await runCli(["brain", "batch-plan", join(vault, "sources")], {
env: ENV(),
});
expect(res.returncode).toBe(1);
expect(res.stderr).toContain(
"planBatches: source dir must be a vault-relative path inside the vault " +
`(got "${join(vault, "sources")}")`,
);
expect(res.stderr).toContain("rerun with the directory path relative to the vault root");
expect(res.stderr).not.toContain("is not an existing directory");
});
});
describe("o2b brain batch-plan scoping flags", () => {
test("--src-subpath restricts discovery to the subtree", async () => {
write("mono/pkg/a/one.md");
write("mono/pkg/b/two.md");
const res = await runCli(["brain", "batch-plan", "mono", "--src-subpath", "pkg/a", "--json"], {
env: ENV(),
});
expect(res.returncode).toBe(0);
const plan = JSON.parse(res.stdout);
const paths = plan.batches.flatMap((b: { files: { path: string }[] }) =>
b.files.map((f) => f.path),
);
expect(paths).toContain("mono/pkg/a/one.md");
expect(paths).not.toContain("mono/pkg/b/two.md");
});
test("--exclude drops matching files", async () => {
write("mono/keep.md");
write("mono/vendor/dep.md");
const res = await runCli(["brain", "batch-plan", "mono", "--exclude", "vendor/", "--json"], {
env: ENV(),
});
expect(res.returncode).toBe(0);
const plan = JSON.parse(res.stdout);
const paths = plan.batches.flatMap((b: { files: { path: string }[] }) =>
b.files.map((f) => f.path),
);
expect(paths).toEqual(["mono/keep.md"]);
});
test("a subpath escaping the source root fails with a nonzero exit", async () => {
write("mono/a.md");
const res = await runCli(
["brain", "batch-plan", "mono", "--src-subpath", "../../etc", "--json"],
{ env: ENV() },
);
expect(res.returncode).not.toBe(0);
expect(res.stderr).toMatch(/escapes|outside/i);
});
});