Dependency-free Node.js bridge for OpenClaw semantic memory. It provides:
memory-query.jsfor on-demand memory search from any coding agentpreflight-context.jsfor pulling relevant memory into aCONTEXT.mdfile before agent startup
- Node.js 24+
openclawavailable inPATH- Windows environment supported by the OpenClaw CLI
memory-query.jspreflight-context.jstest.js
node memory-query.js "how does the auth module work"
node memory-query.js "past decisions about database schema" --max-results 10
node memory-query.js "error handling patterns" --agent ops --jsonDefault behavior:
- agent:
ops - max results:
5 - output: human-readable summary with path, score, and snippet
node preflight-context.js --task "Build a REST API for user management" --workdir C:\path\to\projectOptional flags:
node preflight-context.js --task "Refactor auth middleware" --workdir C:\repo --agent ops --max-results 8 --context-limit 18Behavior:
- Builds 3-5 search angles from the task.
- Queries memory for each angle.
- Deduplicates and ranks results.
- Writes
CONTEXT.mdin the target workdir.
CONTEXT.md is structured for LLM consumption and includes:
- source file path
- line range
- relevance score
- matched query angles
- raw text snippet
The scripts fail clearly when:
openclawis not installed or not inPATH- the memory search command returns non-zero
- JSON returned by the CLI is invalid
- the target workdir does not exist
Run smoke tests:
node test.jsThe tests validate CLI formatting, JSON passthrough, query generation, deduplication, and markdown output by stubbing the openclaw binary.