An open API service indexing awesome lists of open source software.

https://github.com/pacphi/ruflo-machine-ref

Make ruflo + Claude Code rock-solid on modern Node (24/26): native SQLite (no silent data loss), ~84k fewer tokens per session, and configure-once-per-machine setup that keeps every repo clean. A thin, reversible layer over ruflo.
https://github.com/pacphi/ruflo-machine-ref

anthropic better-sqlite3 claude claude-code developer-tools mcp nodejs ruflo

Last synced: 26 days ago
JSON representation

Make ruflo + Claude Code rock-solid on modern Node (24/26): native SQLite (no silent data loss), ~84k fewer tokens per session, and configure-once-per-machine setup that keeps every repo clean. A thin, reversible layer over ruflo.

Awesome Lists containing this project

README

          

# 🧰 ruflo-machine-ref

**A small, friendly setup kit that makes [ruflo](https://github.com/ruvnet/ruflo) actually work the way it promises β€” reliable memory, *active* self-learning, verified security, and an at-a-glance status line β€” especially on modern Node (24/26), where a stock install quietly breaks in ways that still look "green."**

> One-time setup per machine. One command to heal after upgrades. Nothing committed to your repos unless you mean it.

---

## πŸ€” What is this, in plain words?

[**ruflo**](https://github.com/ruvnet/ruflo) is an AI orchestration toolkit for [Claude Code](https://claude.com/claude-code) β€” it gives your AI assistant a memory that survives across sessions, the ability to learn from what works, multi-agent coordination, and security scanning.

The catch: on the versions of Node.js most developers run today, ruflo **silently falls back to a degraded mode**. It still says "βœ… OK", but underneath:

- πŸ’Ύ the **memory** that's supposed to persist… doesn't (writes vanish),
- 🧠 the **self-learning** that's supposed to be on… stays asleep,
- πŸŽ“ the optional **quality-engineering** add-on won't even finish installing,
- πŸ“Ÿ and you have no easy way to *see* which of these is actually working.

This kit closes all of those gaps with a few small, reversible helper scripts β€” and gives you a **status line** that shows, at a glance, exactly what's live.

> πŸ™‚ **Not a developer?** You only need three commands: `./install.sh` (once), then `ruflo-onboard` inside a project, and `ruflo-resync` after any upgrade. The rest of this README explains the "why" for the curious.

---

## ⚑ The 30-second version

| You want… | Stock ruflo on Node 24/26 | With this kit |
|---|---|---|
| πŸ’Ύ Memory that persists across sessions | Says "saved" but loses data | Saves for real, and **verifies** it landed on disk |
| 🧠 Self-learning that's actually on | Reports "Not loaded" | **Active & proven** (trains β†’ patterns persist) |
| πŸ›‘οΈ Security scanning | Ships but undocumented/unverified | **Verified**: scan, secrets, prompt-injection defense |
| πŸŽ“ Agentic-QE quality fleet (optional) | `aqe init` fails on Node 24/26 | **Installs cleanly** (same bug, auto-fixed) |
| πŸ“Ÿ Knowing what's active | No indication | **Status-line footer** shows 🧠 / πŸ›‘οΈ / πŸŽ“ live |
| πŸ” Surviving an upgrade | Re-breaks silently every upgrade | **`ruflo-resync`** β€” one command re-heals everything |
| πŸ’° Token budget | ~84k tokens/session of MCP tool defs | MCP optional; CLI-first saves the tokens |

---

## 🧩 What's actually wrong (the short story)

Modern Node.js (24 and 26) changed its native-addon ABI. ruflo's deeper dependencies pin an **old `better-sqlite3`** that has no prebuilt binary for those Node versions and won't compile against them. npm treats it as optional and **skips it silently**, so ruflo drops to a pure-JavaScript SQLite fallback whose write path **loses data** β€” while still printing success.

That single root cause cascades:

1. πŸ’Ύ **Memory loss** β€” the headline symptom.
2. 🧠 **Dormant self-learning** β€” the same missing binary keeps the ruvector engine (SONA, HNSW, ReasoningBank) asleep.
3. πŸŽ“ **Agentic-QE won't initialize** β€” it's a *separate* package ([`agentic-qe`](https://github.com/proffesor-for-testing/agentic-qe)) with the *same* bug.

> πŸ“Ž **A note on prior art.** A colleague, **Ciprian Melian**, wrote an excellent project-scoped repair kit as a gist ([link](https://gist.github.com/ciprianmelian/eb7e8ff7d24018141ca34bb8a7e216a6)) that pairs ruflo with agentic-qe. This kit builds on those ideas but takes a **machine-wide, upgrade-safe** approach β€” and our investigation found that several of the gist's source patches are now **already upstream in ruflo 3.10.5** (the real remaining lever is the missing native binary, not the source patches). The full story is in [docs/BACKGROUND.md](docs/BACKGROUND.md).

The deep dive β€” ABI tables, the exact files, why "HNSW: Not loaded" is a cosmetic lie β€” lives in **[docs/BACKGROUND.md](docs/BACKGROUND.md)**.

---

## ✨ What this kit gives you

- 🩹 **Native SQLite, everywhere ruflo needs it** β€” `ruflo-patch-native` swaps the broken dependency for one that works on Node 24/26.
- 🧠 **Activated + *proven* self-learning** β€” `ruflo-enable-learning` turns ruvector on and asserts it (5 real capability probes, not the misleading status text); `ruflo-learning-verify` trains a cycle and confirms patterns persist to disk.
- πŸ›‘οΈ **Verified security surface** β€” `ruflo-security-verify` confirms `@claude-flow/security` + `@claude-flow/aidefence` load, that prompt-injection defense actually fires, and flags the known CVE-database gap.
- πŸŽ“ **Opt-in agentic-qe** β€” `ruflo-setup-aqe` fixes the same native-SQLite bug in agentic-qe, then initializes it (with half-init repair).
- πŸ“Ÿ **A status-line footer** that shows 🧠 self-learning, πŸ›‘οΈ security, and πŸŽ“ agentic-qe β€” each only when genuinely active.
- πŸ” **`ruflo-resync`** β€” one command to re-apply *everything* after a ruflo or agentic-qe upgrade.
- 🧹 **Clean repos & cheap sessions** β€” strips MCP cruft `ruflo init` would commit, pins an absolute memory path, and keeps MCP optional to save ~84k tokens/session.
- ↩️ **Reversible** β€” `uninstall.sh` backs up and removes the machine-level setup; `--this-project` also reverts a repo's statusline patches.

---

## βœ… Prerequisites

This kit *configures and heals* ruflo β€” it doesn't bundle it. You need a few
things on your machine first. `install.sh` checks for these and can install the
npm packages for you (interactively, or via flags).

**Required (install.sh aborts if missing):**

| Tool | Why | Get it |
|---|---|---|
| Node.js (20–26 supported) | runtime for ruflo & the helpers | |
| npm | installs the global packages | ships with Node.js |
| `ruflo` | the orchestration toolkit this kit configures | `npm i -g ruflo` (install.sh can do this) |

**Recommended (install.sh warns, then continues):**

| Tool | Why |
|---|---|
| `claude` (Claude Code) | the agent this all runs inside |
| `sqlite3` | the status line + memory verifications read the DBs |
| `git` | to clone/update this kit |

**Optional (only for the QE fleet):**

| Tool | Why | Get it |
|---|---|---|
| `agentic-qe` (`aqe`) | the standalone quality-engineering fleet (πŸŽ“ segment) | `npm i -g agentic-qe` (install.sh `--with-aqe`) |

> πŸ”‘ **"Security" and "learning" are not separate installs.** `@claude-flow/security`,
> `@claude-flow/aidefence`, and the ruvector self-learning engine all ship *inside*
> ruflo β€” this kit *activates and verifies* them. So the "full boat" is just two
> npm packages (`ruflo` + `agentic-qe`); the kit lights up the rest.

---

## πŸš€ Quick start

The fastest path β€” install the kit, prereqs, and heal in one go:

```bash
# 1. Get the kit
git clone https://github.com/pacphi/ruflo-machine-ref.git && cd ruflo-machine-ref

# 2. Bootstrap the machine (pick your level)
./install.sh # friendly interactive onboard (asks per step)
./install.sh --full --yes # "full boat": ruflo + agentic-qe + heal, no prompts
./install.sh --ruflo-only # just ruflo + heal
./install.sh --minimal # only lay down the kit files (you have the prereqs)
exec $SHELL # load the helper functions

# 3. In any project you work in
cd ~/my-project
ruflo-onboard # clean setup + prove self-learning persists, in one step
ruflo-onboard --aqe # …and also initialize the agentic-qe fleet here
```

Try `./install.sh --dry-run` first to preview exactly what it will do.

πŸͺ™ **Prefer CLI-only (no MCP, ~84k tokens saved per session)?** Skip
`ruflo-setup-machine`; the installed `~/.claude/CLAUDE.md` reference teaches
Claude Code to drive ruflo through plain Bash.

---

## πŸ› οΈ The commands

| Command | What it does |
|---|---|
| πŸ” `ruflo-resync [--aqe]` | **The one you'll use most.** After any ruflo/agentic-qe upgrade, re-applies everything the upgrade wipes: native SQLite (ruflo + agentic-qe) + self-learning assert + statusline footer. `--aqe` also refreshes QE skills. |
| πŸ“‚ `ruflo-onboard [--with-security] [--aqe]` | **Per-repo, run from inside it.** One command: clean `setup-project` β†’ prove learning persists β†’ (`--aqe`) initialize agentic-qe. Prints what's active + what's next. |
| πŸ—οΈ `ruflo-setup-project [--with-security]` | Per repo: clean init, strip MCP cruft, pin an absolute DB path, native patch, activate memory/swarm/daemon, **verify a write persists**, sanitize CLAUDE.md, heal the status line. `--with-security` adds a security pass. |
| 🩹 `ruflo-patch-native [--check]` | Make ruflo's agentdb use native `better-sqlite3` on Node β‰₯24. |
| 🧠 `ruflo-enable-learning [--check]` | Activate ruvector self-learning and assert it (5 capability probes). |
| βœ… `ruflo-learning-verify [--keep]` | Prove the learning loop: train in an isolated dir, assert patterns persist 0 β†’ N on disk. |
| 🎚️ `ruflo-neural-train [args…]` | Wraps `ruflo neural train` in the current project and caches the MicroLoRA Ξ” for the status-line SONA segment (ruflo doesn't persist it). Args pass through. |
| πŸ›‘οΈ `ruflo-security-verify [--quick]` | Verify `@claude-flow/security` + `aidefence` load, injection defense fires, scan/secrets run; flag the CVE-DB gap. |
| πŸŽ“ `ruflo-setup-aqe [--force]` | **Opt-in.** Fix agentic-qe's native-SQLite bug, then initialize it in a repo (with half-init repair). |
| πŸ’Ύ `ruflo-memory-checkpoint [db]` | Force a WAL checkpoint to recover stale memory reads. |
| 🧽 `ruflo-remove-mcp` | Remove ruflo MCP from **all** scopes (recover ~84k tokens/session). |
| πŸ“‡ `ruflo-setup-machine` | One-time: register ruflo MCP at **user** scope (all projects). Optional. |
| πŸ” `ruflo-parity-test [--cleanup]` | 20-check end-to-end memory smoke test in an isolated `/tmp` dir. |
| πŸ“ `ruflo-reference-refresh [--diff\|--regenerate]` | Inspect/rebuild the machine-wide CLAUDE.md ruflo block from the template. |

---

## 🧭 Which command do I run?

**`install.sh` is the front door you walk through once; the functions are how you live in the house.**

| | `install.sh` | The functions |
|---|---|---|
| **Nature** | a script run *from the kit repo* | commands on your `PATH`, available everywhere after install |
| **Frequency** | once per machine (+ rarely, to re-lay the kit) | ongoing, day-to-day |
| **Scope** | machine-level bootstrap | machine-recurring **and** per-project |

On first run the functions aren't sourced yet, so `install.sh` sources them
in-process and calls the *same* `ruflo-patch-native` / `ruflo-enable-learning`
to heal β€” one source of truth, no drift. After that you never need `install.sh`
for healing again.

| Situation | Run this | Why not the other |
|---|---|---|
| πŸ†• Brand-new machine | **`install.sh`** | nothing's on PATH yet β€” only the script can bootstrap |
| πŸ” Re-cloned kit / new shell / wiped `~/.local/bin` | **`install.sh`** | re-lays the kit files (idempotent, backs up) |
| ⬆️ After `npm i -g ruflo@latest` (or aqe) | **`ruflo-resync`** | the upgrade only wiped native binaries β€” re-running install.sh is the heavier wrong tool |
| πŸ“‚ Starting in a new repo | **`ruflo-onboard`** | per-project; install.sh is machine-level and won't touch your repo |
| πŸ” Routine checks | **functions** (`ruflo-parity-test`, `ruflo-learning-verify`) | no reason to re-bootstrap |

**Rule of thumb:**
- *"I'm setting up"* β†’ `install.sh` (once).
- *"I upgraded ruflo/aqe"* β†’ `ruflo-resync`.
- *"I'm starting work in a repo"* β†’ `ruflo-onboard`.

---

## πŸ“Ÿ The status line

When set up with this kit, a two-line footer is appended **below** ruflo's own status line. It's append-only β€” it never rewrites ruflo's lines, so a ruflo update can't break it. Each piece appears **only when that feature is genuinely active**:

```
β–Š RuFlo V3.10.5 ● you β”‚ ⏇ main β”‚ Opus 4.x ┐
πŸ—οΈ DDD Domains … πŸ€– Swarm … πŸ”§ Architecture … β”‚ ruflo's own lines + the kit's
πŸ“Š AgentDB … β”‚ SONA/aidefence line (all ruflo)
🧠 SONA [●●●●●] 50 patterns Β· 55 traj Β· Ξ”1.32 LoRA Β· ⚑ HNSW πŸ›‘ aidefence on β”˜
───────────────────────────────────────────────────── ← divider (matches ruflo's header rule)
πŸŽ“ Agentic QE V3.10.1 πŸŽ“ 23 patterns Β· 🧭 114 traj Β· 🧬 543 vec⚑ Β· πŸ’Ύ 16MB
```

Every field renders only when its data is actually present (numbers above are illustrative):
- 🧠 **SONA** β€” `[bar]` is a volume gauge (~10 patterns/dot); `patterns`/`traj` from `.claude-flow/neural/stats.json`; `Ξ” LoRA` is shown only after you run `ruflo-neural-train` (it caches the transient MicroLoRA delta, which ruflo doesn't persist); `⚑ HNSW` only when a vector index exists.
- πŸ›‘οΈ **aidefence on** β€” proactive prompt-injection/PII defense is loaded (ruflo's native line already shows the `CVE n/m` count, so this signals the *other* half).
- πŸŽ“ **Agentic QE** β€” `V` is the installed `agentic-qe` package version (read from its `package.json`, mirroring `RuFlo V` in ruflo's header); `πŸŽ“ patterns` / `🧭 traj` / `🧬 vec` / `πŸ’Ύ size` from a few guarded `sqlite3` reads of `.agentic-qe/memory.db` (the `vec` count comes from `qe_pattern_embeddings`, falling back to `vectors`/`embeddings` across aqe versions). The branch is already in ruflo's header line, so it's not repeated here.

---

## πŸ” Keeping it working after upgrades

Every `npm install -g ruflo@latest` (or `agentic-qe@latest`) re-resolves dependency pins, **drops the native binaries again**, and regenerates the status line β€” so self-learning goes dormant and the footer disappears. You don't have to remember everything an upgrade wipes:

```bash
npm install -g ruflo@latest # or agentic-qe@latest
ruflo-resync # ✨ one command heals it all
ruflo-resync --aqe # …and also refresh agentic-qe skills
```

---

## 🧬 Node version policy (important)

ruflo's memory & learning are healthy out of the box on **Node 22 LTS**, and need the patch on **Node 24/26**:

| Node | ABI | Stock backend | What to do |
|------|-----|---------------|------------|
| ≀ 22 (LTS) | ≀ 127 | βœ… native | nothing β€” `ruflo-resync` just confirms green |
| 24 | 137 | ⚠️ JS fallback (loses data) | `ruflo-resync` |
| 26 | 147 | ⚠️ JS fallback (loses data) | `ruflo-resync` |

The patch keys off Node's ABI, so it's safe to run on any version (it no-ops where unneeded). Prefer zero patching? Run ruflo on **Node 22 LTS**.

---

## πŸ™… Why not just the ruflo one-liner?

The popular quickstart works for an afternoon in one repo:

```bash
ruflo init --full --start-all --force && claude mcp add ruflo -- ruflo mcp start && ruflo doctor
```

…but it bakes in choices that don't age well across many projects and modern Node:

| Concern | The one-liner | This kit |
|---|---|---|
| πŸ”­ **Mindset** | Per-project, repeated every repo | Configure the machine once, reuse everywhere |
| πŸ“„ **`.mcp.json`** | Written with cloud-SaaS servers β€” easy to commit by accident | Stripped; nothing project-scoped committed unless you mean it |
| πŸ’° **Token cost** | MCP always on β†’ ~84k tokens/session | MCP optional; CLI-first reference keeps sessions lean |
| πŸ’Ύ **Memory on Node 24/26** | `doctor` says "healthy" while writes silently vanish | Native SQLite + a real storeβ†’disk verification |
| 🧠 **Self-learning** | Looks "Not loaded"; no way to tell if it works | Activated and **proven** via a train/persist test |
| ↩️ **Reversibility** | Manual cleanup | `uninstall.sh` reverses the setup with backups (`--this-project` also reverts a repo's statusline) |

It's not a replacement for ruflo β€” just a thin, reversible layer that picks safe defaults and closes the gaps.

---

## πŸ“¦ What's in the box

```
ruflo-machine-ref/
β”œβ”€β”€ install.sh # machine bootstrap: prereqs + kit + heal (profiles, interactive)
β”œβ”€β”€ uninstall.sh # clean reversal (opt-in --purge for global npm packages)
β”œβ”€β”€ bin/
β”‚ β”œβ”€β”€ ruflo-patch-native # native better-sqlite3 on Node β‰₯24
β”‚ β”œβ”€β”€ ruflo-parity-test # 20-check end-to-end memory smoke test
β”‚ β”œβ”€β”€ ruflo-enable-learning # activate + assert ruvector self-learning
β”‚ β”œβ”€β”€ ruflo-learning-verify # prove the learning loop persists
β”‚ └── ruflo-security-verify # verify security scan/defend/secrets + aidefence
β”œβ”€β”€ shell/
β”‚ └── ruflo-functions.sh # ruflo-resync, ruflo-onboard, ruflo-setup-project, ruflo-setup-aqe, …
β”œβ”€β”€ claude/
β”‚ └── ruflo-reference.md # the machine-wide CLAUDE.md ruflo block (CLI-first)
└── docs/
β”œβ”€β”€ BACKGROUND.md # the full root-cause story (memory + learning + aqe + security)
β”œβ”€β”€ TROUBLESHOOTING.md # symptom β†’ diagnosis β†’ fix
└── superpowers/ # the design spec + implementation plan
```

---

## πŸ—‘οΈ Uninstall

```bash
./uninstall.sh # kit footprint only: bin scripts, template, CLAUDE.md block, rc line
./uninstall.sh --this-project # ALSO revert the kit's statusline patches in the current repo
./uninstall.sh --remove-ruflo # ALSO npm-uninstall global ruflo (machine-wide; asks first)
./uninstall.sh --remove-aqe # ALSO npm-uninstall global agentic-qe (machine-wide; asks first)
./uninstall.sh --purge # --remove-ruflo + --remove-aqe
./uninstall.sh --dry-run # preview without changing anything
```

The plain `uninstall.sh` removes only machine-level kit setup; your ruflo
install, memory DBs, and **project files** are left untouched. The
`--remove-ruflo` / `--remove-aqe` / `--purge` flags reach the *global npm
packages* β€” they affect every project on the machine, so each one prompts to
confirm (pass `--yes` to skip in scripts). Add `--this-project` from a repo root
to revert that repo's statusline patches too (it backs up first and leaves all
ruflo/agentic-qe data alone β€” use `ruflo cleanup --force` for per-project data).

---

## πŸ“š Further reading

- πŸ“– [docs/BACKGROUND.md](docs/BACKGROUND.md) β€” the full root-cause investigation (Node/ABI/WASM, why self-learning looked dormant, the agentic-qe variant, the security surface)
- πŸ”§ [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) β€” symptom β†’ diagnosis β†’ fix runbook
- 🧱 [docs/superpowers/](docs/superpowers/) β€” the design spec and implementation plan behind the self-learning work

---

## πŸ™ Credits & citations

This kit stands on the shoulders of several projects and people:

- 🧠 **ruflo** (a.k.a. claude-flow) by ruvnet β€” the orchestration toolkit this kit configures:
- πŸŽ“ **agentic-qe** by *proffesor-for-testing* β€” the standalone quality-engineering fleet:
- πŸ“Ž **Ciprian Melian's setup-and-repair gist** β€” prior art that paired ruflo with agentic-qe and inspired this kit's direction:
- 🐞 **Upstream tracking issue** for the memory/Node bug family: [ruvnet/ruflo#2219](https://github.com/ruvnet/ruflo/issues/2219)
- πŸ—„οΈ **better-sqlite3** β€” the native SQLite binding at the heart of the fix:
- πŸ€– **Claude Code** by Anthropic β€” the agent this all runs inside:

> Target: macOS / Linux Β· zsh or bash Β· ruflo 3.10.x Β· Node 20–26 Β· Python 3.10+.
> A thin, reversible layer β€” not a fork. PRs and issues welcome.