- Node.js 20+
- pnpm
- Bun (for building standalone binaries)
pnpm install # install dependencies
pnpm test # run vitest
pnpm tsc --noEmit # type checkbun run build.ts # build for current platform
bun run build.ts --target bun-linux-x64 # cross-compile| Target | Platform |
|---|---|
bun-linux-x64 |
Linux x86_64 |
bun-linux-arm64 |
Linux ARM64 |
bun-darwin-x64 |
macOS Intel |
bun-darwin-arm64 |
macOS Apple Silicon |
bun-windows-x64 |
Windows x86_64 |
Output goes to dist/<platform>/ with the binary and ONNX runtime shared libraries.
- Stubs out
sharpinnode_modules(image processing dep from@huggingface/transformers— unused, we only do text embeddings) - Compiles via
bun build --compilewhich embeds the bun runtime, bundled JS, and the ONNX native.nodeaddon - Copies the ONNX shared library (
libonnxruntime.so,.dylib, or.dll) alongside the binary - Restores the
sharpsymlink innode_modules
bin/memex is a shell wrapper that:
- Sets
LD_LIBRARY_PATH/DYLD_LIBRARY_PATHso the ONNX shared lib is found - Execs the compiled binary (
bin/memex.bin) - If no binary is found, runs
install.shsynchronously (with a 12-second download timeout) - If the download succeeds, re-execs itself to run the newly installed binary
- If the download fails, outputs
{}with a one-liner install command on stderr
There is no tsx/node fallback — the binary is the only production runtime. install.sh verifies downloads against checksums.txt (SHA256) when available.
bin/memex.cmd is the Windows equivalent with inline PowerShell download logic (DLLs are found automatically from the same directory).
src/
├── core/ Claude-specific wrappers
│ ├── config.ts Config loading and defaults (extends memex-core)
│ ├── paths.ts Claude path configuration (~/.claude/...)
│ └── session.ts File-based session persistence
├── hooks/ Hook handlers
│ ├── user-prompt.ts UserPromptSubmit — semantic matching
│ ├── pre-tool-use.ts PreToolUse — tool-specific guidance
│ ├── stop.ts Stop — session learnings + behavioral rules
│ ├── pre-compact.ts PreCompact — context compaction
│ └── session-start.ts SessionStart — sync pull
├── main.ts Entry point — reads stdin JSON, dispatches by hook event
bin/
├── memex Unix wrapper script
├── memex.cmd Windows wrapper
└── install.sh Downloads prebuilt binary from GitHub releases
build.ts Build script for standalone binaries
- Tests mock
embedTextsto avoid loading ONNX models - Cache and session modules are mocked to avoid filesystem side effects
- All paths use
node:pathjoin +node:oshomedir — no hardcoded absolute paths
Releases are automated via release-please on push to main. Use conventional commits:
feat:— minor version bump, triggers binary buildsfix:— patch version bump, triggers binary buildschore:,docs:,test:— no release
The CI workflow builds binaries for all supported platforms, generates checksums.txt (SHA256), and attaches everything to the GitHub release. The binary embeds the version at compile time via --define process.env.SKILL_ROUTER_VERSION.