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.4 KB
Raw Blame
import { readPrefAudit, renderPrefAudit } from "../../../core/brain/pref-audit.ts";
import { stripBrainIdPrefix } from "../../../core/brain/wikilink.ts";
import { brainVerbContext, fail, parse } from "../helpers.ts";

/**
 * `o2b brain audit <pref-id>` - render a preference's full mutation
 * audit trail (create / promote / update / retire / merge). The trail
 * is keyed by the original `pref-<slug>` id, so a `ret-<slug>` or bare
 * `<slug>` argument is normalised to the same file. Read-only.
 */
export async function cmdBrainAudit(argv: string[]): Promise<number> {
  const { flags, positional } = parse(argv, {
    vault: { type: "string" },
    json: { type: "boolean" },
  });
  const raw = positional[0];
  if (!raw) return fail("usage: o2b brain audit <pref-id>");
  const slug = stripBrainIdPrefix(raw);
  if (slug.length === 0) {
    return fail(`audit: empty preference slug after stripping prefix from '${raw}'`);
  }
  const prefId = `pref-${slug}`;

  const { vault } = brainVerbContext(flags);

  let result;
  try {
    result = readPrefAudit(vault, prefId);
  } catch (exc) {
    return fail(`audit failed: ${(exc as Error).message ?? exc}`);
  }

  if (flags["json"]) {
    process.stdout.write(JSON.stringify({ pref_id: prefId, ...result }, null, 2) + "\n");
  } else {
    process.stdout.write(renderPrefAudit(prefId, result.records) + "\n");
  }
  return 0;
}