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
SOLID/DRY refactor - implementation plan
One feature branch (feat/solid-dry-refactor), six atomic units, each its own conventional commit with the full suite green. TDD: characterization or unit tests land before each move.
Tasks
Task 1: Canonical wikilink module (kanban t_c82bdae0)
- Files: new
src/core/brain/wikilink.ts; newtests/core/brain/wikilink.test.ts; migratesrc/core/vault.ts,src/core/brain/lint-consolidate.ts,src/core/brain/link-graph/parse-wikilink.ts,src/core/brain/link-graph/format-wikilink.ts,src/core/search/links.ts,src/core/search/entities.ts,src/core/search/query-plan.ts - Acceptance: characterization tests pin each variant's contract (quoted/heading, strict, alias-capturing, minimal) and pass before and after migration; no regex literal for
[[...]]remains outside the module; full suite green. - Depends on: none
Task 2: Unify atomic file writes (kanban t_82213b08)
- Files:
src/core/reliability/atomic.ts(absorbs exclusive create), deletesrc/core/fs-atomic.ts, migrate its importers; new/extended tests intests/core/reliability/atomic.test.ts - Acceptance: one implementation of temp-name + fsync + rename; tests cover simple write, validated write, exclusive create (success and already-exists), mode override; full suite green.
- Depends on: none
Task 3: Extract policy YAML parser and dream sub-modules (kanban t_3d9369d0)
- Files: new
src/core/brain/yaml-parse.ts(frompolicy.ts), newsrc/core/brain/dream-refresh.tsandsrc/core/brain/reconcile-outcomes.ts(fromdream.ts); unit tests for each new module - Acceptance:
policy.tsno longer contains parsing code;dream.tsshrinks by the extracted ranges; extracted modules unit-tested in isolation; existing policy/dream tests green unchanged. - Depends on: none
Task 4: Split brain-tools.ts into domain modules (kanban t_c567a35e)
- Files: new
src/mcp/brain/domain modules (~13) plus shared helper module;src/mcp/brain-tools.tsbecomes the aggregator; new parity test asserting the BRAIN_TOOLS name set is unchanged - Acceptance: parity test green; no file in
src/mcpover ~700 lines;tools.tsand existing test imports unchanged; full suite green. - Depends on: Task 1 (wikilink), Task 2 (atomic) so moved code imports canonical modules once.
Task 5: CLI brain-command wrapper migration (kanban t_6467b4af)
- Files: new
src/cli/brain/command.ts(+ unit tests for context resolution and error formatting); migratesrc/cli/brain/verbs/*.ts - Acceptance: wrapper unit tests green; verb files contain no repeated vault/config/catch boilerplate; CLI output strings and exit codes unchanged (existing CLI tests); full suite green.
- Depends on: none (parallel-safe, but lands after Task 4 to avoid merge noise in shared helper files).
Task 6: Cleanup and layering guard (kanban t_bee11d1a)
- Files: delete
scripts/sync-version.py; newtests/core/layering.test.ts - Acceptance: layering test fails on injected
process.exitin a core fixture-style check and passes on the real tree;bun run sync-version:checkstill works; full suite green. - Depends on: Tasks 1-5 (guard validates the final tree).
QA gate (after all tasks)
bun run validate (typecheck + lint + test), bun run fmt:check, bun run sync-version:check, rebuild openclaw/index.js via bun run build:openclaw if bundled sources moved, smoke-test o2b CLI and MCP server startup.