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
import { readFileSync } from "node:fs";
import { compress, expand } from "../../../core/brain/portability/codec.ts";
import { fail, parse } from "../helpers.ts";
import { readStdinText } from "../../stdin.ts";
/**
* `o2b brain codec --compress|--expand [--in <file>]` - run the
* deterministic session codec over stdin (or `--in <file>`) and print
* the result to stdout. Read-only; does not touch the vault.
*/
export async function cmdBrainCodec(argv: string[]): Promise<number> {
const { flags } = parse(argv, {
compress: { type: "boolean" },
expand: { type: "boolean" },
in: { type: "string" },
});
if (flags["compress"] === flags["expand"]) {
return fail("usage: o2b brain codec --compress | --expand [--in <file>]");
}
let input: string;
try {
input =
typeof flags["in"] === "string" ? readFileSync(flags["in"], "utf8") : await readStdinText();
} catch (exc) {
return fail(`codec: failed to read input: ${(exc as Error).message ?? exc}`);
}
try {
process.stdout.write(flags["compress"] ? compress(input) : expand(input));
} catch (exc) {
return fail(`codec failed: ${(exc as Error).message ?? exc}`);
}
return 0;
}