claude-flow 3.76.0 → 3.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/auto-memory-hook.mjs +4 -4
- package/.claude/proven-config.json +1 -1
- package/package.json +1 -1
- package/v3/@claude-flow/cli/README.md +78 -194
- package/v3/@claude-flow/cli/catalog-manifest.json +6 -6
- package/v3/@claude-flow/cli/dist/src/appliance/rvfa-builder.js +5 -1
- package/v3/@claude-flow/cli/dist/src/commands/analyze.js +15 -1
- package/v3/@claude-flow/cli/dist/src/commands/neural-wsp.d.ts +15 -0
- package/v3/@claude-flow/cli/dist/src/commands/neural-wsp.js +265 -0
- package/v3/@claude-flow/cli/dist/src/commands/neural.js +2 -1
- package/v3/@claude-flow/cli/dist/src/commands/security.js +1 -1
- package/v3/@claude-flow/cli/dist/src/init/helpers-generator.js +7 -6
- package/v3/@claude-flow/cli/dist/src/ruvector/ruv-fann-wsp.d.ts +129 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/ruv-fann-wsp.js +221 -0
- package/v3/@claude-flow/cli/package.json +5 -2
- package/v3/@claude-flow/guidance/package.json +1 -1
|
@@ -528,7 +528,7 @@ async function doImport() {
|
|
|
528
528
|
const { pkg: memPkg, searched } = await resolveMemoryPackage({ record: true });
|
|
529
529
|
if (!memPkg) {
|
|
530
530
|
warnMemoryUnavailable(searched);
|
|
531
|
-
return;
|
|
531
|
+
return 1; // #4963: nothing was imported/synced, so this is a failure, not a success
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
const config = readConfig();
|
|
@@ -614,7 +614,7 @@ async function doSync() {
|
|
|
614
614
|
const { pkg: memPkg, searched } = await resolveMemoryPackage({ record: true });
|
|
615
615
|
if (!memPkg) {
|
|
616
616
|
warnMemoryUnavailable(searched);
|
|
617
|
-
return;
|
|
617
|
+
return 1; // #4963: nothing was imported/synced, so this is a failure, not a success
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
const config = readConfig();
|
|
@@ -870,8 +870,8 @@ process.on('unhandledRejection', (reason) => {
|
|
|
870
870
|
let exitCode = 0;
|
|
871
871
|
try {
|
|
872
872
|
switch (command) {
|
|
873
|
-
case 'import': await doImport(); break;
|
|
874
|
-
case 'sync': await doSync(); break;
|
|
873
|
+
case 'import': exitCode = (await doImport()) || 0; break;
|
|
874
|
+
case 'sync': exitCode = (await doSync()) || 0; break;
|
|
875
875
|
case 'status': await doStatus(); break;
|
|
876
876
|
case 'read': exitCode = await doRead(commandArgs); break;
|
|
877
877
|
case 'read-id': exitCode = await doReadId(commandArgs); break;
|
package/package.json
CHANGED
|
@@ -1,101 +1,22 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**An agent meta-harness for Claude Code and Codex.**
|
|
3
|
+
[](https://cognitum.one/agentic-engineering)
|
|
6
4
|
|
|
7
5
|
<!-- Try Ruflo — the 3 badges first-time visitors actually act on -->
|
|
8
6
|
[](https://www.npmjs.com/package/ruflo)
|
|
9
7
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://x.com/rUv)
|
|
12
|
-
|
|
13
|
-
<p align="center">
|
|
14
|
-
<a href="docs/harness-origins.md"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/e69e4b95aa08d65ea0f7715489bbf8e62a83a0d2/docs/assets/readme/badges/first-commit.svg" width="300" height="76" alt="Claude Flow lineage: first commit June 2, 2025 by rUv; inspect the evidence"></a>
|
|
15
|
-
<a href="data/npm-downloads.latest.json"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/275aff65a198af758923669acff36f03d1f41623/docs/assets/readme/badges/downloads.svg" width="300" height="76" alt="Illustrative download counter starts at 98,000,000 and adds varied amounts each second in a 30 second loop. Verified dataset: 97,022,120 download events."></a>
|
|
16
|
-
<br>
|
|
17
|
-
<a href="https://github.com/ruvnet/claude-flow"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/d1e80400bdefe01d3b13e70395f88fffab76bb18/docs/assets/readme/badges/claude.svg" width="300" height="76" alt="Claude Code plugin"></a>
|
|
18
|
-
<a href="https://www.npmjs.com/package/@claude-flow/codex"><img src="https://raw.githubusercontent.com/ruvnet/ruflo/d1e80400bdefe01d3b13e70395f88fffab76bb18/docs/assets/readme/badges/codex.svg" width="300" height="76" alt="Codex plugin"></a>
|
|
19
|
-
<a href="https://chatgpt.com/plugins/plugin_asdk_app_6ab674ff53c48191bb37040c343e31f3"><img src="docs/assets/readme/badges/chatgpt.svg" width="300" height="76" alt="ChatGPT plugin: RuFlo Federation"></a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<a id="start-here"></a>
|
|
25
|
-
|
|
26
|
-
## <img src="docs/assets/readme/icons/terminal.svg" width="32" height="32" alt=""> Get started in one command
|
|
27
|
-
|
|
28
|
-
Run this in your project folder:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npx ruflo@latest init
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Then open Claude Code in the same folder and give it a real task, for example:
|
|
35
|
-
|
|
36
|
-
```text
|
|
37
|
-
Use a ruflo swarm to review this repo: find the riskiest module, write tests for it, and summarise what you changed.
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
`init` adds ruflo's agents, hooks, memory and MCP server to the project, and Claude Code picks them up on its next start. Codex and other MCP clients work too: point them at `npx -y ruflo@latest mcp start`.
|
|
41
|
-
|
|
42
|
-
<p align="center"><img src="docs/assets/ruflo-console-tour.gif" width="720" alt="Looping recording of the ruflo console: overview, swarm view and missions in a sample project"></p>
|
|
43
|
-
|
|
44
|
-
[First useful task, step by step](docs/ruflo-explained.md) · [User guide](docs/USERGUIDE.md) · [Compare install paths](#quick-start)
|
|
45
|
-
|
|
46
|
-
<details>
|
|
47
|
-
<summary><b>Other ways to install</b> (Claude Code plugins only, MCP-only clients, terminal UI)</summary>
|
|
48
|
-
|
|
49
|
-
**Claude Code plugins only.** This route installs core tools, the visual console and runtime mods, with no files added to your project. It needs Claude Code **2.1.287 or later**. Run inside Claude Code:
|
|
50
|
-
|
|
51
|
-
```text
|
|
52
|
-
/plugin marketplace add ruvnet/ruflo
|
|
53
|
-
/plugin install ruflo-core@ruflo
|
|
54
|
-
/plugin install ruflo-console@ruflo
|
|
55
|
-
/plugin install ruflo-mods@ruflo
|
|
56
|
-
/reload-plugins
|
|
57
|
-
/ruflo
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
From a terminal, on Claude Code 2.1.292 or later: `claude plugin install ruflo-core@ruflo --marketplace ruvnet/ruflo`. Mods run with your account's permissions, so review their code before installing.
|
|
61
|
-
|
|
62
|
-
**Codex or another MCP client, without project setup.** Configure the **command** `npx` with the **arguments** `["-y", "ruflo@latest", "mcp", "start"]`. To set up a project interactively, run `npx ruflo@latest init wizard`.
|
|
63
|
-
|
|
64
|
-
**Plain terminal.** The console also runs on its own, without Claude Code: `npx ruflo tui`. Add `--plain` to print one frame for scripts. See the [terminal UI guide](docs/USERGUIDE.md#terminal-ui-optional).
|
|
65
|
-
|
|
66
|
-
<p align="center"><img src="docs/assets/ruflo-tui-compact.svg" width="640" alt="Looping recording of the optional ruflo terminal UI with its pictures: Overview in the Classic BBS look, the Orbital look with its moving globe, and the Swarm graph, in a sample project"></p>
|
|
67
|
-
|
|
68
|
-
</details>
|
|
69
|
-
|
|
70
|
-
<div align="center">
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### Optional: ruOS Desktop
|
|
74
|
-
|
|
75
|
-
<a href="https://ruos.cognitum.one"><img src="ruflo/assets/ruos-animated.svg" alt="ruOS — A desktop that runs itself" width="100%"></a>
|
|
76
|
-
|
|
77
|
-
**Connect ruOS to ChatGPT or Claude via MCP:**
|
|
78
|
-
|
|
79
|
-
```text
|
|
80
|
-
https://ruos.cognitum.one/mcp
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<!-- RuVector promo -->
|
|
86
|
-
<a href="https://github.com/ruvnet/ruvector"><img src="docs/assets/readme/ruvector-promo-depth.svg" width="100%" alt="RuVector: Give your agents memory. Local vector search, persistent context, graph relationships and feedback learning. Explore RuVector."></a>
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
npx ruvector
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
8
|
+
[](https://github.com/ruvnet/claude-flow)
|
|
93
9
|
|
|
10
|
+
<!-- Ecosystem strip (collapsed visually with flat-square) -->
|
|
11
|
+
[](https://github.com/ruvnet/ruvector)
|
|
12
|
+
[](https://github.com/ruvnet/ruflo/blob/main/data/clone-data.proof.json)
|
|
13
|
+
[](https://github.com/ruvnet/ruflo/blob/main/data/clone-data.ledger.json)
|
|
14
|
+
[](https://github.com/ruvnet/claude-flow)
|
|
15
|
+
[](https://www.npmjs.com/package/@claude-flow/codex)
|
|
94
16
|
|
|
95
17
|
# Ruflo
|
|
96
18
|
|
|
97
|
-
|
|
98
|
-
|
|
19
|
+
**An agent meta-harness for Claude Code and Codex.**
|
|
99
20
|
|
|
100
21
|
[](docs/ruflo-explained.md)
|
|
101
22
|
|
|
@@ -108,29 +29,16 @@ A 14-chapter guide: from the basic idea to a first useful task, then memory, age
|
|
|
108
29
|
|
|
109
30
|
One `npx ruflo init` gives Claude Code a nervous system: agents self-organize into swarms, learn from every task, remember across sessions, and — with federation — securely talk to agents on other machines without leaking data. You keep writing code. Ruflo handles the coordination.
|
|
110
31
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<sub>Conceptual learning loop. Local vector retrieval and contrastive updates can run without an LLM; embeddings and configured learning modules are still required. See the <a href="v3/@claude-flow/cli/src/services/ruvector-training.ts">RuVector training integration</a> and <a href="v3/@claude-flow/neural/src/modes/balanced.ts">trajectory contrastive learning</a>.</sub>
|
|
114
|
-
|
|
115
|
-
<details>
|
|
116
|
-
<summary>Architecture in text</summary>
|
|
117
|
-
|
|
118
|
-
User → Ruflo (CLI/MCP) → Router → Swarm → Agents → Memory → LLM providers. Memory feeds useful experience back into routing. This is a conceptual flow, not a live execution trace.
|
|
32
|
+
```
|
|
33
|
+
Self-Learning / Self-Optimizing Agent Architecture
|
|
119
34
|
|
|
120
|
-
|
|
35
|
+
User --> Ruflo (CLI/MCP) --> Router --> Swarm --> Agents --> Memory --> LLM Providers
|
|
36
|
+
^ |
|
|
37
|
+
+---- Learning Loop <-------+
|
|
38
|
+
```
|
|
121
39
|
|
|
122
40
|
> **New to Ruflo?** You don't need to learn 406 MCP tools or 61 CLI commands. After `init`, just use Claude Code normally — the hooks system automatically routes tasks, learns from successful patterns, and coordinates agents in the background.
|
|
123
41
|
|
|
124
|
-
### An origin you can inspect
|
|
125
|
-
|
|
126
|
-
[](docs/harness-origins.md)
|
|
127
|
-
|
|
128
|
-
**Built by [Reuven Cohen (rUv)](https://github.com/ruvnet), originally as Claude Flow.** The [first commit, June 2, 2025](https://github.com/ruvnet/ruflo/commit/7c1f9402d70e7af56c01a879073cbac92564dc4e), describes a code orchestration layer for recursive agent cycles: Claude writes, edits, tests and improves. The [June 10 source snapshot](https://github.com/ruvnet/ruflo/tree/dba545f012ea92a2375a26332bbf3797495e93c9) adds orchestration, task scheduling, memory and terminal modules.
|
|
129
|
-
|
|
130
|
-
A harness is the workbench around the model: it organizes tasks, carries context between steps and helps check results. **This establishes Ruflo's lineage, not a universal first across every Claude Code tool.** [See the illustrated explainer, exact commits and earlier ecosystem context](docs/harness-origins.md).
|
|
131
|
-
|
|
132
|
-
**Grok Build:** `npx ruflo init --grok` writes the project host surface (`.grok/`, the team bus, and the operator guide) and nothing outside the project; add `--dry-run` to preview. Setup, the `spawn_subagent` contract, the optional status row, and what to re-check when Grok updates: [the Grok operator guide](v3/@claude-flow/cli/templates/grok/docs/README.md).
|
|
133
|
-
|
|
134
42
|
<details>
|
|
135
43
|
<summary><strong>📖 Background — where the name comes from</strong></summary>
|
|
136
44
|
|
|
@@ -140,52 +48,10 @@ A harness is the workbench around the model: it organizes tasks, carries context
|
|
|
140
48
|
|
|
141
49
|
---
|
|
142
50
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<p align="center"><a href="https://raw.githubusercontent.com/ruvnet/ruflo/main/docs/assets/ruflo-console-theme-compact.svg"><img src="docs/assets/ruflo-console-theme-compact.svg" width="100%" alt="Ruflo Orbital theme: animated boot checks, block logo, menu icons, rotating globe, swarm routing, six color palettes and responsive Theme Studio"></a></p>
|
|
146
|
-
|
|
147
|
-
[Open animated demo](https://raw.githubusercontent.com/ruvnet/ruflo/main/docs/assets/ruflo-console-theme-compact.svg) · [Theme Studio guide](plugins/ruflo-console/README.md) · [Workflow demo](docs/assets/ruflo-console-workflows.svg)
|
|
148
|
-
|
|
149
|
-
<img src="docs/assets/readme/console-icon-workflows.svg" width="28" height="28" alt=""> **Your agent cockpit.** Track workflows, agents, models, tokens and cost beside Claude Code. The 38 second animation shows **Orbital and Theme Studio** through actual renderer frames, including boot checks, six palettes, customization, saved themes, JSON import and resizing. This compact 3.84 MB SVG retains all 456 frames. Native host and AI provider execution are not demonstrated.
|
|
150
|
-
|
|
151
|
-
<img src="docs/assets/readme/console-icon-inspect.svg" width="28" height="28" alt=""> **Inspect any run.** Open agent logs and results, search, triage failures, replay and compare. Start with `npx ruflo init`, restart Claude Code, then `/ruflo`. [Full console tour](docs/assets/ruflo-console-walkthrough-wide.gif).
|
|
152
|
-
|
|
153
|
-
<img src="docs/assets/readme/console-icon-control.svg" width="28" height="28" alt=""> **Let Claude drive. You set the limits.** Enable **Settings → Claude control** to navigate and run console actions. Choose `read`, `write`, `manage` or `full`, with `ask` or `auto` approval. The current default is **read + ask**; raising the level is your choice. Actions above your permission level are refused, and network, spending and destructive actions require confirmation even in `auto`. Review the live action log or press **Take back control** to stop Claude control. [Details](v3/docs/adr/ADR-444-claude-controls-the-console.md).
|
|
154
|
-
|
|
155
|
-
<a id="console-walkthrough"></a>
|
|
156
|
-
|
|
157
|
-
### One task: create a mission with Claude
|
|
158
|
-
|
|
159
|
-
<img src="docs/assets/readme/console-icon-workflows.svg" width="28" height="28" alt=""> **Watch the recorded console session below.** Claude creates a mission, opens the Learning and Security pages, and reports its actions in Overview.
|
|
160
|
-
|
|
161
|
-
1. **Set the boundary.** Install the console using the commands below, open `/ruflo`, then choose **Settings → Claude control → write + ask**.
|
|
162
|
-
2. **Give a concrete request.** Try: “Create a mission to add a dark mode toggle. Show me the mission and its status.”
|
|
163
|
-
3. **Approve creation.** Claude opens Missions and sets the goal. Confirm the pending create action in the console.
|
|
164
|
-
4. **Verify the result.** Check that Missions contains the goal and Overview records the action. Creating a mission does not mean the feature has been implemented.
|
|
165
|
-
5. **Keep control.** **Take back control** pauses Claude's console tools. A later call should be refused until you restore control.
|
|
166
|
-
|
|
167
|
-
**What the recording demonstrates:** a real Claude Haiku session with `write + auto`, mission creation, page navigation, a refused swarm stop, and control being taken back. The steps above use `ask` so you approve creation yourself. The linked workflow animation uses sample data, while the theme demo replays renderer frames. Neither is evidence of completed swarm work or memory recall.
|
|
168
|
-
|
|
169
|
-
[Implementation and recorded test findings](v3/docs/adr/ADR-444-claude-controls-the-console.md) · [Reproduction script](plugins/ruflo-console/scripts/e2e-control.sh)
|
|
170
|
-
|
|
171
|
-
<p align="center"><img src="docs/assets/ruflo-console-claude-control.gif" alt="Claude Code with the ruflo console beside it: Claude sets a mission goal, creates the mission and opens the Learning, Security and Overview pages through the console tools; the Claude control dashboard logs each action; swarm-stop is refused because it needs the full level; the person clicks Take back control and the next request is refused"></p>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
**Install the mods from the ruflo marketplace** (Claude Code 2.1.287 or later; mods run with your account's permissions and are not sandboxed, so read the code first):
|
|
175
|
-
|
|
176
|
-
```text
|
|
177
|
-
/plugin marketplace add ruvnet/ruflo
|
|
178
|
-
/plugin install ruflo-console@ruflo
|
|
179
|
-
/plugin install ruflo-mods@ruflo
|
|
180
|
-
/reload-plugins
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
`ruflo-console` is the cockpit above, `ruflo-mods` routes prompts and enforces policy in-process, `ruflo-swarm` shows the swarm in a pane, and `ruflo-ruos` adds the ruOS status segment. Open `/plugin` to confirm they appear in the active mods line. Inside the console, `/ruflo market` is the Plugin Catalog: every ruflo plugin, mod and skill with what it ships, and buttons to install, enable, disable and update (each asks first).
|
|
51
|
+

|
|
184
52
|
|
|
185
53
|
## Quick Start
|
|
186
54
|
|
|
187
|
-
<p align="center"><img src="docs/assets/readme/quick-start.svg" alt="Start building with Ruflo" width="100%"></p>
|
|
188
|
-
|
|
189
55
|
There are **two different install paths** with very different surface areas. Pick based on what you need (#1744):
|
|
190
56
|
|
|
191
57
|
| | **Claude Code Plugin** | **CLI install (`npx ruflo init`)** |
|
|
@@ -212,7 +78,7 @@ There are **two different install paths** with very different surface areas. Pic
|
|
|
212
78
|
This adds slash commands and agent definitions. `ruflo-core` (installed above) does register its own MCP server on install — its tools are callable as `mcp__plugin_ruflo-core_ruflo__*` (e.g. `mcp__plugin_ruflo-core_ruflo__memory_store`), not the bare `memory_store`/`swarm_init`/`agent_spawn` names the CLI-track scaffold uses. Other plugins generally don't ship their own MCP server. For the full loop with the CLI-track tool names, use Path B below.
|
|
213
79
|
|
|
214
80
|
<details>
|
|
215
|
-
<summary><strong>🔌 All 48 plugins</strong
|
|
81
|
+
<summary><strong>🔌 All 48 plugins</strong></summary>
|
|
216
82
|
|
|
217
83
|
#### Core & Orchestration
|
|
218
84
|
|
|
@@ -263,9 +129,6 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
263
129
|
| [**ruflo-jujutsu**](plugins/ruflo-jujutsu/README.md) | Analyze git diffs, score risk, suggest reviewers |
|
|
264
130
|
| [**ruflo-rure**](plugins/ruflo-rure/) | Static analysis of a local JS/Electron app you are authorized to study, with file and line evidence |
|
|
265
131
|
| [**ruflo-docs**](plugins/ruflo-docs/README.md) | Generate and maintain documentation automatically |
|
|
266
|
-
| [**agentic-qe-fleet**](https://github.com/proffesor-for-testing/agentic-qe/tree/v3.15.17/plugins/agentic-qe-fleet) | External, maintained by [Agentic QE](https://github.com/proffesor-for-testing/agentic-qe): 11 QE agents, test generation, coverage, chaos and TDD skills, the `agentic-qe` MCP server, and a guard for AQE learning data (`/plugin install agentic-qe-fleet@ruflo`). Install it from one marketplace only, `agentic-qe` or `ruflo`: enabled from both, its mod and commands load twice |
|
|
267
|
-
| [**agentdb**](https://github.com/ruvnet/agentdb/tree/plugin-v3.2.0/plugins/agentdb) | External, maintained in [ruvnet/agentdb](https://github.com/ruvnet/agentdb): agentdb's own MCP server (pinned `agentdb@3.2.0`: hybrid keyword + vector search, opt-in cross-encoder rerank), a memory-specialist agent, vector-memory / learning / diagnostics skills, `/agentdb-status`, and a guard that keeps secrets out of memory and refuses delete/reset unless allowed (`/plugin install agentdb@ruflo`). Use `ruflo-agentdb` instead if you want AgentDB through ruflo's server; the two can coexist. Install it from one marketplace only, `agentdb` or `ruflo` |
|
|
268
|
-
| [**agentic-flow**](https://github.com/ruvnet/agentic-flow/tree/plugin-v3.1.0/plugins/agentic-flow) | External, maintained in [ruvnet/agentic-flow](https://github.com/ruvnet/agentic-flow): the agentic-flow MCP server (pinned `agentic-flow@3.1.0`, `readonly` profile by default, nothing pre-approved), ReasoningBank and model-router agents, routing / learning / autopilot skills, `/agentic-flow-status`, and a guard on `agentic_flow_agent` (`/plugin install agentic-flow@ruflo`). Install it from one marketplace only, `agentic-flow` or `ruflo` |
|
|
269
132
|
|
|
270
133
|
#### Security & Compliance
|
|
271
134
|
|
|
@@ -298,7 +161,7 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
298
161
|
|
|
299
162
|
| Plugin | What it does |
|
|
300
163
|
|--------|-------------|
|
|
301
|
-
| [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents — local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud)
|
|
164
|
+
| [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents — local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud) |
|
|
302
165
|
| [**ruflo-plugin-creator**](plugins/ruflo-plugin-creator/README.md) | Scaffold, validate, and publish your own plugins |
|
|
303
166
|
|
|
304
167
|
#### Domain-Specific
|
|
@@ -312,7 +175,7 @@ This adds slash commands and agent definitions. `ruflo-core` (installed above) d
|
|
|
312
175
|
|
|
313
176
|
</details>
|
|
314
177
|
|
|
315
|
-
###
|
|
178
|
+
### CLI Install
|
|
316
179
|
|
|
317
180
|
**macOS / Linux / WSL / Git-Bash:**
|
|
318
181
|
|
|
@@ -336,52 +199,82 @@ npm install -g ruflo@latest
|
|
|
336
199
|
|
|
337
200
|
> 💡 **Windows users:** the `curl ... | bash` form needs a POSIX shell (Git-Bash, WSL, MSYS). The `npx ruflo@latest init wizard` line works natively in PowerShell and cmd. If you hit an `'bash' is not recognized` error, use the `npx` line instead — both end up running the same init flow.
|
|
338
201
|
|
|
339
|
-
###
|
|
202
|
+
### MCP Server
|
|
340
203
|
|
|
341
204
|
```bash
|
|
342
205
|
# Add Ruflo as an MCP server in Claude Code
|
|
343
206
|
claude mcp add claude-flow -- npx ruflo@latest mcp start
|
|
344
207
|
```
|
|
345
208
|
|
|
346
|
-
|
|
209
|
+
#### HTTP transport security
|
|
347
210
|
|
|
348
|
-
|
|
211
|
+
`ruflo mcp start -t http` exposes every registered tool over HTTP (`/rpc`, `/mcp`, `/ws`). The default `stdio` transport is not affected.
|
|
349
212
|
|
|
350
|
-
|
|
213
|
+
| Setting | Effect |
|
|
214
|
+
|---|---|
|
|
215
|
+
| `RUFLO_MCP_HTTP_TOKEN=<token>` | Require `Authorization: Bearer <token>` on every request. Failure is a bare `401`. The token is compared in constant time and is never logged. Prefer this over `--auth-token`, which is visible in `ps`. |
|
|
216
|
+
| `--auth-token-file <path>` | Read the token from a file (one line). Takes precedence over the env var. |
|
|
217
|
+
| `--auth-token <token>` | Same, on the command line (visible in argv; highest precedence). |
|
|
218
|
+
| `RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1` | Allow an unauthenticated bind to a non-loopback `--host`. Only for a trusted network boundary or an authenticating reverse proxy. |
|
|
351
219
|
|
|
352
|
-
|
|
220
|
+
A token must be 16-512 printable ASCII characters (no spaces). `GET /health` stays public and returns only `{"status":"ok"}` when a token is set. Tokens are supported for `-t http` only; `-t websocket` rejects one.
|
|
353
221
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
</table>
|
|
222
|
+
| `--host` | no token | token set |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| `localhost`, `127.0.0.1`, `::1` | starts, **unauthenticated** | starts, token required |
|
|
225
|
+
| anything else (`0.0.0.0`, `::`, a LAN IP, `127.0.0.2`, `[::1]`, `LOCALHOST`) | **refuses to start** unless `RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1` | starts, token required |
|
|
359
226
|
|
|
360
|
-
|
|
361
|
-
|------------|-------------|
|
|
362
|
-
| <img src="docs/assets/readme/icons/agents.svg" width="28" height="28" alt=""> **100+ Agents** | Specialized agents for coding, testing, security, docs, architecture |
|
|
363
|
-
| <img src="docs/assets/readme/icons/network.svg" width="28" height="28" alt=""> **Comms Layer** | Zero-trust federation — agents across machines/orgs discover, authenticate, and exchange work securely |
|
|
364
|
-
| <img src="docs/assets/readme/icons/swarm.svg" width="28" height="28" alt=""> **Swarm Coordination** | Hierarchical, mesh, and adaptive topologies with consensus |
|
|
365
|
-
| <img src="docs/assets/readme/icons/learning.svg" width="28" height="28" alt=""> **Self-Learning** | SONA neural patterns, ReasoningBank, trajectory learning |
|
|
366
|
-
| <img src="docs/assets/readme/icons/memory.svg" width="28" height="28" alt=""> **Vector Memory** | HNSW-indexed AgentDB — measured ~1.9x faster at N=20k, ~3.2x–4.7x at N=5k vs brute force (recall@10 ~0.99); ANN wins above the crossover, ties/loses at small N. See [audit](docs/reviews/intelligence-system-audit-2026-05-29.md) + [`scripts/benchmark-intelligence.mjs`](scripts/benchmark-intelligence.mjs) |
|
|
367
|
-
| <img src="docs/assets/readme/icons/workers.svg" width="28" height="28" alt=""> **Background Workers** | 12 auto-triggered workers (audit, optimize, testgaps, etc.) |
|
|
368
|
-
| <img src="docs/assets/readme/icons/plugins.svg" width="28" height="28" alt=""> **Plugin Marketplace** | 48 native Claude Code plugins + 14 in-tree npm plugins |
|
|
369
|
-
| <img src="docs/assets/readme/icons/routing.svg" width="28" height="28" alt=""> **Multi-Provider** | Claude, GPT, Gemini, Cohere, Ollama with smart routing |
|
|
370
|
-
| <img src="docs/assets/readme/icons/security.svg" width="28" height="28" alt=""> **Security** | AIDefence, input validation, CVE remediation, path traversal prevention |
|
|
371
|
-
| <img src="docs/assets/readme/icons/federation.svg" width="28" height="28" alt=""> **Agent Federation** | Cross-installation agent collaboration with zero-trust security |
|
|
372
|
-
| <img src="docs/assets/readme/icons/audit.svg" width="28" height="28" alt=""> **[MetaHarness](docs/metaharness-user-guide.md)** | Audit your AI agent setup before you ship. Grade readiness (1-100), scan tool configs for security issues, snapshot the whole project to catch regressions over time, and find templates that match your repo. `ruflo eject` turns a ruflo project into a standalone agent toolkit with its own name. [Full guide](docs/metaharness-user-guide.md). |
|
|
227
|
+
Without a token, a loopback server is still unauthenticated: any process on the machine, and any web page that can reach it via DNS rebinding, can call tools. Set `RUFLO_MCP_HTTP_TOKEN` whenever the HTTP transport is used.
|
|
373
228
|
|
|
374
|
-
|
|
229
|
+
**Upgrading:** binding off loopback (for example `--host 0.0.0.0` in Docker) now needs a token or the opt-out above; otherwise the server exits with an error.
|
|
375
230
|
|
|
376
|
-
|
|
231
|
+
---
|
|
377
232
|
|
|
378
|
-
|
|
233
|
+
Startup checks report available updates without installing them. To opt in to
|
|
234
|
+
automatic patch installation, set `RUFLO_AUTO_UPDATE=true` (`1`, `yes` and `on`
|
|
235
|
+
also work). Minor and major updates remain manual; critical package priority
|
|
236
|
+
does not bypass an opt-out. CI detection and `CLAUDE_FLOW_AUTO_UPDATE=false`
|
|
237
|
+
still disable the update check.
|
|
379
238
|
|
|
380
|
-
|
|
239
|
+
## What You Get
|
|
240
|
+
|
|
241
|
+
Companion helper refresh (`session.cjs` / `memory.cjs`) skips symlinked helper
|
|
242
|
+
directories and symlinked/non-file targets. Regular files are preserved on
|
|
243
|
+
startup and replaced on an explicit upgrade through an exclusive temporary
|
|
244
|
+
file and rename. A skipped companion is left in place; remove or repair the
|
|
245
|
+
unsafe path before retrying. These pathname checks do not protect against an
|
|
246
|
+
attacker concurrently replacing ancestor directories, and do not extend the
|
|
247
|
+
signed helper set or protect other state writers.
|
|
248
|
+
|
|
249
|
+
| Capability | Description |
|
|
250
|
+
|------------|-------------|
|
|
251
|
+
| 🤖 **100+ Agents** | Specialized agents for coding, testing, security, docs, architecture |
|
|
252
|
+
| 📡 **Comms Layer** | Zero-trust federation — agents across machines/orgs discover, authenticate, and exchange work securely |
|
|
253
|
+
| 🐝 **Swarm Coordination** | Hierarchical, mesh, and adaptive topologies with consensus |
|
|
254
|
+
| 🧠 **Self-Learning** | SONA neural patterns, ReasoningBank, trajectory learning |
|
|
255
|
+
| 💾 **Vector Memory** | HNSW-indexed AgentDB — measured ~1.9x faster at N=20k, ~3.2x–4.7x at N=5k vs brute force (recall@10 ~0.99); ANN wins above the crossover, ties/loses at small N. See [audit](docs/reviews/intelligence-system-audit-2026-05-29.md) + [`scripts/benchmark-intelligence.mjs`](scripts/benchmark-intelligence.mjs) |
|
|
256
|
+
| ⚡ **Background Workers** | 12 auto-triggered workers (audit, optimize, testgaps, etc.) |
|
|
257
|
+
| 🧩 **Plugin Marketplace** | 48 native Claude Code plugins + 14 in-tree npm plugins |
|
|
258
|
+
| 🔌 **Multi-Provider** | Claude, GPT, Gemini, Cohere, Ollama with smart routing |
|
|
259
|
+
| 🛡️ **Security** | AIDefence, input validation, CVE remediation, path traversal prevention |
|
|
260
|
+
| 🌐 **Agent Federation** | Cross-installation agent collaboration with zero-trust security |
|
|
261
|
+
| 🔬 **[MetaHarness](docs/metaharness-user-guide.md)** | Audit your AI agent setup before you ship. Grade readiness (1-100), scan tool configs for security issues, snapshot the whole project to catch regressions over time, and find templates that match your repo. `ruflo eject` turns a ruflo project into a standalone agent toolkit with its own name. [Full guide](docs/metaharness-user-guide.md). |
|
|
381
262
|
|
|
382
|
-
|
|
263
|
+
### Agent Federation — Slack for Agents
|
|
383
264
|
|
|
384
|
-
|
|
265
|
+
```
|
|
266
|
+
Your Agent --> [ Remove secrets ] --> [ Sign message ] --> [ Encrypted channel ]
|
|
267
|
+
Emails, SSNs, Proves it came No one reads it
|
|
268
|
+
keys stripped from you in transit
|
|
269
|
+
|
|
|
270
|
+
v
|
|
271
|
+
Their Agent <-- [ Block attacks ] <-- [ Check identity ] <------+
|
|
272
|
+
Stops prompt Rejects forgeries
|
|
273
|
+
injection
|
|
274
|
+
|
|
275
|
+
Audit trail on both sides.
|
|
276
|
+
Trust builds over time. Bad behavior = instant downgrade.
|
|
277
|
+
```
|
|
385
278
|
|
|
386
279
|
Slack gave teams channels. Federation gives agents the same thing — **shared workspaces across trust boundaries**, where agents on different machines, orgs, or cloud regions can discover each other, prove who they are, and collaborate on tasks.
|
|
387
280
|
|
|
@@ -483,15 +376,12 @@ User --> Claude Code / CLI
|
|
|
483
376
|
|
|
484
377
|
## Documentation
|
|
485
378
|
|
|
486
|
-
<p align="center"><img src="docs/assets/readme/documentation.svg" alt="Guides, architecture and verification" width="100%"></p>
|
|
487
|
-
|
|
488
379
|
Four docs for four audiences:
|
|
489
380
|
|
|
490
381
|
| Doc | When to read it |
|
|
491
382
|
|-----|-----------------|
|
|
492
383
|
| **[Status](docs/STATUS.md)** | See what currently works — capability counts, test baselines, recent fixes, what's next. The *is-it-ready* doc. |
|
|
493
384
|
| **[User Guide](docs/USERGUIDE.md)** | Daily reference — every command, every config flag, every plugin. The *how-do-I* doc. |
|
|
494
|
-
| **[Compare frameworks](docs/compare.md)** | Deciding between Ruflo, Claude Code built-in agents, CrewAI, LangGraph, or AutoGen. The *which-one-for-me* doc. |
|
|
495
385
|
| **[MetaHarness Guide](docs/metaharness-user-guide.md)** | How to grade your agent setup, scan tool configs for security, detect changes between runs, and eject a project into a standalone agent toolkit. The *audit-my-setup* doc. |
|
|
496
386
|
| **[Benchmarks](https://gist.github.com/ruvnet/298f8c668c8859b369f91734a0e9cbbe)** | v3.8.0 SOTA matrix vs LangGraph / AutoGen / CrewAI on darwin-arm64 + linux-x64. ruflo wins cold start, single turn, RSS by 1.3×–1953×. The *is-it-fast* doc. |
|
|
497
387
|
| **[Verification](verification.md)** | Cryptographically prove your installed bytes match the signed witness — `ruflo verify`. The *trust-but-verify* doc. |
|
|
@@ -516,8 +406,6 @@ User Guide section index:
|
|
|
516
406
|
|
|
517
407
|
## Support
|
|
518
408
|
|
|
519
|
-
<p align="center"><img src="docs/assets/readme/support.svg" alt="Build with the Ruflo community" width="100%"></p>
|
|
520
|
-
|
|
521
409
|
| Resource | Link |
|
|
522
410
|
|----------|------|
|
|
523
411
|
| Documentation | [User Guide](docs/USERGUIDE.md) |
|
|
@@ -526,10 +414,6 @@ User Guide section index:
|
|
|
526
414
|
| Community | [Agentics Foundation Discord](https://discord.com/invite/dfxmpwkG2D) |
|
|
527
415
|
| Powered by | [Cognitum.one](https://cognitum.one) |
|
|
528
416
|
|
|
529
|
-
<p align="center"><img src="docs/assets/readme/signal-divider.svg" alt="Ruflo" width="100%"></p>
|
|
530
|
-
|
|
531
417
|
## License
|
|
532
418
|
|
|
533
419
|
MIT - [RuvNet](https://github.com/ruvnet)
|
|
534
|
-
|
|
535
|
-
<a href="https://cognitum.one"><img src="docs/assets/readme/cognitum-banner-v2.svg" width="100%" alt="Cognitum One: Ambient Intelligence at the edge of the Physical World. Explore cognitum.one."></a>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generation":
|
|
4
|
-
"generatedAt": "2026-
|
|
5
|
-
"gitSha": "
|
|
3
|
+
"generation": 6,
|
|
4
|
+
"generatedAt": "2026-09-17T21:28:47.530Z",
|
|
5
|
+
"gitSha": "702d1461",
|
|
6
6
|
"catalog": {
|
|
7
|
-
"agents":
|
|
8
|
-
"tools":
|
|
9
|
-
"skills":
|
|
7
|
+
"agents": 167,
|
|
8
|
+
"tools": 418,
|
|
9
|
+
"skills": 34
|
|
10
10
|
},
|
|
11
11
|
"benchmark": null
|
|
12
12
|
}
|
|
@@ -140,7 +140,11 @@ export class RvfaBuilder {
|
|
|
140
140
|
buildRufloSection() {
|
|
141
141
|
let packageMeta = null;
|
|
142
142
|
try {
|
|
143
|
-
const raw = execSync('npm pack ruflo@latest --dry-run --json
|
|
143
|
+
const raw = execSync('npm pack ruflo@latest --dry-run --json', {
|
|
144
|
+
encoding: 'utf-8',
|
|
145
|
+
timeout: 15_000,
|
|
146
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
147
|
+
});
|
|
144
148
|
const parsed = JSON.parse(raw);
|
|
145
149
|
if (Array.isArray(parsed) && parsed.length > 0)
|
|
146
150
|
packageMeta = parsed[0];
|
|
@@ -1317,7 +1317,21 @@ const depsCommand = {
|
|
|
1317
1317
|
output.writeln(output.bold('Security Audit'));
|
|
1318
1318
|
output.writeln(output.dim('-'.repeat(60)));
|
|
1319
1319
|
try {
|
|
1320
|
-
|
|
1320
|
+
let auditRaw;
|
|
1321
|
+
try {
|
|
1322
|
+
auditRaw = execSync('npm audit --json', {
|
|
1323
|
+
encoding: 'utf-8',
|
|
1324
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
1325
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
catch (auditErr) {
|
|
1329
|
+
// npm audit exits non-zero when vulnerabilities found — stdout still has JSON
|
|
1330
|
+
const stdout = auditErr instanceof Error && 'stdout' in auditErr ? auditErr.stdout : '';
|
|
1331
|
+
if (!stdout)
|
|
1332
|
+
throw auditErr;
|
|
1333
|
+
auditRaw = stdout;
|
|
1334
|
+
}
|
|
1321
1335
|
const audit = JSON.parse(auditRaw);
|
|
1322
1336
|
const vulns = audit.metadata?.vulnerabilities || audit.vulnerabilities || {};
|
|
1323
1337
|
const info = vulns.info || 0;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `neural wsp` — ruv-FANN weight-space tooling (ADR-528).
|
|
3
|
+
*
|
|
4
|
+
* Read-only evidence over dense models: fingerprint, inspect, invariant
|
|
5
|
+
* checks and bounded-patch regression gates. Nothing here promotes a model,
|
|
6
|
+
* writes routing state or changes what `hooks route` does. The only write is
|
|
7
|
+
* `export-centroid`, which writes the file the user names.
|
|
8
|
+
*
|
|
9
|
+
* Backed by the optional dependencies ruv-fann-wsp, ruv-fann-wsp-invariants
|
|
10
|
+
* and ruv-fann-wsp-lifecycle; every subcommand reports cleanly when they are
|
|
11
|
+
* missing.
|
|
12
|
+
*/
|
|
13
|
+
import type { Command } from '../types.js';
|
|
14
|
+
export declare const wspCommand: Command;
|
|
15
|
+
//# sourceMappingURL=neural-wsp.d.ts.map
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `neural wsp` — ruv-FANN weight-space tooling (ADR-528).
|
|
3
|
+
*
|
|
4
|
+
* Read-only evidence over dense models: fingerprint, inspect, invariant
|
|
5
|
+
* checks and bounded-patch regression gates. Nothing here promotes a model,
|
|
6
|
+
* writes routing state or changes what `hooks route` does. The only write is
|
|
7
|
+
* `export-centroid`, which writes the file the user names.
|
|
8
|
+
*
|
|
9
|
+
* Backed by the optional dependencies ruv-fann-wsp, ruv-fann-wsp-invariants
|
|
10
|
+
* and ruv-fann-wsp-lifecycle; every subcommand reports cleanly when they are
|
|
11
|
+
* missing.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { resolve as resolvePath } from 'node:path';
|
|
15
|
+
import { output } from '../output.js';
|
|
16
|
+
function str(flags, name) {
|
|
17
|
+
const v = flags[name];
|
|
18
|
+
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
19
|
+
}
|
|
20
|
+
function isJson(flags) {
|
|
21
|
+
return str(flags, 'format') === 'json';
|
|
22
|
+
}
|
|
23
|
+
function fail(message, json, exitCode = 1) {
|
|
24
|
+
if (json)
|
|
25
|
+
output.writeln(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
26
|
+
else
|
|
27
|
+
output.printError(message);
|
|
28
|
+
return { success: false, exitCode, message };
|
|
29
|
+
}
|
|
30
|
+
async function requireWsp(json) {
|
|
31
|
+
const { loadWsp } = await import('../ruvector/ruv-fann-wsp.js');
|
|
32
|
+
const load = await loadWsp();
|
|
33
|
+
if (!load.available)
|
|
34
|
+
return { error: fail(`ruv-FANN WSP unavailable: ${load.reason}`, json, 2) };
|
|
35
|
+
return { mods: load.modules };
|
|
36
|
+
}
|
|
37
|
+
/** The shipped (or CLAUDE_FLOW_ROUTER_CENTROID_PATH) centroid artifact. */
|
|
38
|
+
async function loadCentroid() {
|
|
39
|
+
const { loadCentroidArtifact } = await import('../ruvector/centroid-router.js');
|
|
40
|
+
return loadCentroidArtifact();
|
|
41
|
+
}
|
|
42
|
+
/** `--model <file>` when given, else the centroid router as a dense model. */
|
|
43
|
+
async function resolveModel(flags) {
|
|
44
|
+
const w = await import('../ruvector/ruv-fann-wsp.js');
|
|
45
|
+
const file = str(flags, 'model');
|
|
46
|
+
if (file)
|
|
47
|
+
return { model: w.assertDenseModel(w.readJsonInput(file, 'model')), source: resolvePath(file), artifact: null };
|
|
48
|
+
const c = await loadCentroid();
|
|
49
|
+
if (!c.artifact)
|
|
50
|
+
throw new Error(`centroid router artifact unavailable: ${c.error}`);
|
|
51
|
+
return { model: w.centroidToDenseModel(c.artifact), source: `centroid router (${c.path})`, artifact: c.artifact };
|
|
52
|
+
}
|
|
53
|
+
const formatOpt = { name: 'format', short: 'f', type: 'string', description: 'Output format: table, json', default: 'table' };
|
|
54
|
+
const modelOpt = { name: 'model', short: 'm', type: 'string', description: 'ruv-fann.dense-layers/1 JSON file (default: the centroid router)' };
|
|
55
|
+
const statusCommand = {
|
|
56
|
+
name: 'status',
|
|
57
|
+
description: 'Show whether the ruv-FANN WSP packages are installed, their versions and limits',
|
|
58
|
+
options: [formatOpt],
|
|
59
|
+
action: async (ctx) => {
|
|
60
|
+
const json = isJson(ctx.flags);
|
|
61
|
+
const { loadWsp, wspVersions } = await import('../ruvector/ruv-fann-wsp.js');
|
|
62
|
+
const load = await loadWsp();
|
|
63
|
+
const versions = wspVersions();
|
|
64
|
+
const limits = load.available
|
|
65
|
+
? { wsp: load.modules.wsp.WSP_LIMITS, invariants: load.modules.invariants.INVARIANT_LIMITS, lifecycle: load.modules.lifecycle.LIFECYCLE_LIMITS }
|
|
66
|
+
: null;
|
|
67
|
+
const data = { available: load.available, reason: load.available ? null : load.reason, versions, limits };
|
|
68
|
+
if (json)
|
|
69
|
+
output.writeln(JSON.stringify(data, null, 2));
|
|
70
|
+
else {
|
|
71
|
+
output.writeln(output.bold('ruv-FANN weight-space programming'));
|
|
72
|
+
output.writeln(` Available: ${load.available ? output.success('yes') : output.warning('no — ' + data.reason)}`);
|
|
73
|
+
for (const [k, v] of Object.entries(versions))
|
|
74
|
+
output.writeln(` ${k.padEnd(24)} ${v ?? output.dim('not installed')}`);
|
|
75
|
+
if (limits)
|
|
76
|
+
output.writeln(output.dim(` Patch limit: ${limits.wsp.maxEdits} edits · rows ≤ ${limits.wsp.maxRows} · params ≤ ${limits.wsp.maxParameters} · invariant cases ≤ ${limits.invariants.maxCases}`));
|
|
77
|
+
}
|
|
78
|
+
return { success: true, data };
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const inspectCommand = {
|
|
82
|
+
name: 'inspect',
|
|
83
|
+
description: 'Fingerprint and describe a dense model (default: the centroid router)',
|
|
84
|
+
options: [modelOpt, formatOpt],
|
|
85
|
+
examples: [
|
|
86
|
+
{ command: 'claude-flow neural wsp inspect', description: 'Hash and shape of the shipped centroid router' },
|
|
87
|
+
{ command: 'claude-flow neural wsp inspect -m model.json -f json', description: 'Inspect your own ruv-FANN model' },
|
|
88
|
+
],
|
|
89
|
+
action: async (ctx) => {
|
|
90
|
+
const json = isJson(ctx.flags);
|
|
91
|
+
const w = await requireWsp(json);
|
|
92
|
+
if ('error' in w)
|
|
93
|
+
return w.error;
|
|
94
|
+
try {
|
|
95
|
+
const { model, source } = await resolveModel(ctx.flags);
|
|
96
|
+
const inspection = await w.mods.wsp.inspectWeightModel(model);
|
|
97
|
+
const data = { source, ...inspection };
|
|
98
|
+
if (json)
|
|
99
|
+
output.writeln(JSON.stringify(data, null, 2));
|
|
100
|
+
else {
|
|
101
|
+
output.writeln(output.bold(`Model: ${source}`));
|
|
102
|
+
output.writeln(` Hash: ${inspection.baseHash}`);
|
|
103
|
+
output.writeln(` Shape: ${inspection.inputSize} → ${inspection.outputSize} (${inspection.parameterCount} parameters)`);
|
|
104
|
+
for (const l of inspection.layers) {
|
|
105
|
+
output.writeln(output.dim(` layer ${l.layer}: ${l.inputs}→${l.outputs} ${l.activation} (${l.parameterCount} params)`));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { success: true, data };
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
return fail(err instanceof Error ? err.message : String(err), json);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const checkCommand = {
|
|
116
|
+
name: 'check',
|
|
117
|
+
description: 'Run invariant checks: the built-in centroid self-routing suite, or --suite on --model',
|
|
118
|
+
options: [
|
|
119
|
+
modelOpt,
|
|
120
|
+
{ name: 'suite', short: 's', type: 'string', description: 'ruv-fann.invariants/1 JSON file (required with --model)' },
|
|
121
|
+
{ name: 'min-gap', type: 'number', description: 'Self-routing: required gap between a label and any other label on its own centroid', default: '0.05' },
|
|
122
|
+
formatOpt,
|
|
123
|
+
],
|
|
124
|
+
examples: [
|
|
125
|
+
{ command: 'claude-flow neural wsp check', description: 'Each centroid must route to its own label by a clear gap' },
|
|
126
|
+
{ command: 'claude-flow neural wsp check -m model.json -s invariants.json', description: 'Your own model and suite' },
|
|
127
|
+
],
|
|
128
|
+
action: async (ctx) => {
|
|
129
|
+
const json = isJson(ctx.flags);
|
|
130
|
+
const w = await requireWsp(json);
|
|
131
|
+
if ('error' in w)
|
|
132
|
+
return w.error;
|
|
133
|
+
const mod = await import('../ruvector/ruv-fann-wsp.js');
|
|
134
|
+
try {
|
|
135
|
+
const modelFile = str(ctx.flags, 'model');
|
|
136
|
+
const suiteFile = str(ctx.flags, 'suite');
|
|
137
|
+
let data, accepted;
|
|
138
|
+
if (!modelFile) {
|
|
139
|
+
if (suiteFile)
|
|
140
|
+
return fail('--suite needs --model; without --model the built-in self-routing suite runs', json);
|
|
141
|
+
const c = await loadCentroid();
|
|
142
|
+
if (!c.artifact)
|
|
143
|
+
return fail(`centroid router artifact unavailable: ${c.error}`, json);
|
|
144
|
+
const gapRaw = ctx.flags.minGap ?? ctx.flags['min-gap'];
|
|
145
|
+
const minGap = gapRaw === undefined ? undefined : Number(gapRaw);
|
|
146
|
+
if (minGap !== undefined && !(minGap > 0 && minGap < 1))
|
|
147
|
+
return fail('--min-gap must be in (0, 1)', json);
|
|
148
|
+
const r = await mod.checkCentroidSelfRouting(w.mods, c.artifact, { minGap });
|
|
149
|
+
accepted = r.accepted;
|
|
150
|
+
data = { suite: 'centroid-self-routing', source: c.path, ...r };
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (!suiteFile)
|
|
154
|
+
return fail('--model needs --suite (a ruv-fann.invariants/1 file)', json);
|
|
155
|
+
const model = mod.assertDenseModel(mod.readJsonInput(modelFile, 'model'));
|
|
156
|
+
const suite = mod.readJsonInput(suiteFile, 'suite');
|
|
157
|
+
const r = await w.mods.invariants.checkModelInvariants(model, suite);
|
|
158
|
+
accepted = r.accepted === true;
|
|
159
|
+
data = { suite: resolvePath(suiteFile), source: resolvePath(modelFile), ...r };
|
|
160
|
+
}
|
|
161
|
+
if (json)
|
|
162
|
+
output.writeln(JSON.stringify(data, null, 2));
|
|
163
|
+
else {
|
|
164
|
+
output.writeln(accepted ? output.success(`Invariants hold (${data.checks} checks, ${data.backend})`) : output.warning(`Invariants FAILED (${data.checks} checks)`));
|
|
165
|
+
const v = data.violations ?? [];
|
|
166
|
+
for (const x of v.slice(0, 20))
|
|
167
|
+
output.writeln(output.dim(` ${x.case}: output ${x.output} ${x.constraint} — actual ${x.actual}, bound ${x.bound}`));
|
|
168
|
+
if (v.length > 20)
|
|
169
|
+
output.writeln(output.dim(` … ${v.length - 20} more`));
|
|
170
|
+
}
|
|
171
|
+
return { success: accepted, exitCode: accepted ? 0 : 1, data };
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return fail(err instanceof Error ? err.message : String(err), json);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
const gateCommand = {
|
|
179
|
+
name: 'gate',
|
|
180
|
+
description: 'Regression-gate a bounded weight patch against one or more datasets (evidence only; never promotes)',
|
|
181
|
+
options: [
|
|
182
|
+
{ name: 'model', short: 'm', type: 'string', description: 'ruv-fann.dense-layers/1 JSON file', required: true },
|
|
183
|
+
{ name: 'patch', short: 'p', type: 'string', description: 'ruv-fann.weight-patch/1 JSON file (≤128 edits)', required: true },
|
|
184
|
+
{ name: 'suites', short: 's', type: 'string', description: 'JSON array of {name, dataset:{inputs,targets,rows}, policy:{maxMSE,maxRegressionMSE}}', required: true },
|
|
185
|
+
formatOpt,
|
|
186
|
+
],
|
|
187
|
+
examples: [
|
|
188
|
+
{ command: 'claude-flow neural wsp gate -m model.json -p patch.json -s suites.json', description: 'Accept or reject a patch on every suite' },
|
|
189
|
+
],
|
|
190
|
+
action: async (ctx) => {
|
|
191
|
+
const json = isJson(ctx.flags);
|
|
192
|
+
const w = await requireWsp(json);
|
|
193
|
+
if ('error' in w)
|
|
194
|
+
return w.error;
|
|
195
|
+
const mod = await import('../ruvector/ruv-fann-wsp.js');
|
|
196
|
+
try {
|
|
197
|
+
const m = str(ctx.flags, 'model'), p = str(ctx.flags, 'patch'), s = str(ctx.flags, 'suites');
|
|
198
|
+
if (!m || !p || !s)
|
|
199
|
+
return fail('--model, --patch and --suites are all required', json);
|
|
200
|
+
const model = mod.assertDenseModel(mod.readJsonInput(m, 'model'));
|
|
201
|
+
const patch = mod.readJsonInput(p, 'patch');
|
|
202
|
+
const suites = mod.readJsonInput(s, 'suites');
|
|
203
|
+
if (!Array.isArray(suites))
|
|
204
|
+
return fail('suites: expected a JSON array', json);
|
|
205
|
+
const r = await w.mods.lifecycle.runRegressionGate({ model, patch, suites });
|
|
206
|
+
if (json)
|
|
207
|
+
output.writeln(JSON.stringify(r, null, 2));
|
|
208
|
+
else {
|
|
209
|
+
output.writeln(r.accepted ? output.success('Patch ACCEPTED on every suite') : output.warning('Patch REJECTED'));
|
|
210
|
+
output.writeln(output.dim(` base ${r.baseHash.slice(0, 16)}… → candidate ${r.candidateHash.slice(0, 16)}…`));
|
|
211
|
+
for (const x of r.suites) {
|
|
212
|
+
const e = x.evaluation;
|
|
213
|
+
output.writeln(` ${x.name}: ${e.accepted ? 'pass' : 'fail'} mse ${e.baseline.mse.toFixed(6)} → ${e.candidate.mse.toFixed(6)}${e.reasons.length ? ' (' + e.reasons.join('; ') + ')' : ''}`);
|
|
214
|
+
}
|
|
215
|
+
output.writeln(output.dim(' Evidence only: nothing was promoted or written.'));
|
|
216
|
+
}
|
|
217
|
+
return { success: r.accepted, exitCode: r.accepted ? 0 : 1, data: r };
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
return fail(err instanceof Error ? err.message : String(err), json);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const exportCentroidCommand = {
|
|
225
|
+
name: 'export-centroid',
|
|
226
|
+
description: 'Write the centroid router as a ruv-fann.dense-layers/1 model (one Linear layer)',
|
|
227
|
+
options: [
|
|
228
|
+
{ name: 'output', short: 'o', type: 'string', description: 'Destination JSON file', required: true },
|
|
229
|
+
{ name: 'force', type: 'boolean', description: 'Overwrite an existing file', default: 'false' },
|
|
230
|
+
],
|
|
231
|
+
examples: [
|
|
232
|
+
{ command: 'claude-flow neural wsp export-centroid -o centroid-router.json', description: 'Export for use with other ruv-FANN tooling' },
|
|
233
|
+
],
|
|
234
|
+
action: async (ctx) => {
|
|
235
|
+
const out = str(ctx.flags, 'output');
|
|
236
|
+
if (!out)
|
|
237
|
+
return fail('--output is required', false);
|
|
238
|
+
const dest = resolvePath(out);
|
|
239
|
+
if (existsSync(dest) && ctx.flags.force !== true)
|
|
240
|
+
return fail(`${dest} exists; pass --force to overwrite`, false);
|
|
241
|
+
const c = await loadCentroid();
|
|
242
|
+
if (!c.artifact)
|
|
243
|
+
return fail(`centroid router artifact unavailable: ${c.error}`, false);
|
|
244
|
+
const { centroidToDenseModel } = await import('../ruvector/ruv-fann-wsp.js');
|
|
245
|
+
const model = centroidToDenseModel(c.artifact);
|
|
246
|
+
writeFileSync(dest, JSON.stringify(model) + '\n', { mode: 0o644 });
|
|
247
|
+
output.writeln(output.success(`Wrote ${dest}`));
|
|
248
|
+
output.writeln(output.dim(` ${c.artifact.labels.length} outputs (labels, in order): ${c.artifact.labels.join(', ')}`));
|
|
249
|
+
return { success: true, data: { path: dest, labels: c.artifact.labels } };
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
export const wspCommand = {
|
|
253
|
+
name: 'wsp',
|
|
254
|
+
description: 'ruv-FANN weight-space tooling: inspect, invariant checks, regression gates (ADR-528)',
|
|
255
|
+
subcommands: [statusCommand, inspectCommand, checkCommand, gateCommand, exportCentroidCommand],
|
|
256
|
+
examples: [
|
|
257
|
+
{ command: 'claude-flow neural wsp status', description: 'Are the optional ruv-FANN packages installed?' },
|
|
258
|
+
{ command: 'claude-flow neural wsp check', description: 'Self-routing invariants on the shipped centroid router' },
|
|
259
|
+
],
|
|
260
|
+
action: async () => {
|
|
261
|
+
output.writeln('Use a subcommand: status | inspect | check | gate | export-centroid');
|
|
262
|
+
return { success: true };
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=neural-wsp.js.map
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { output } from '../output.js';
|
|
8
8
|
import { getProjectRoot } from '../services/project-root.js';
|
|
9
|
+
import { wspCommand } from './neural-wsp.js';
|
|
9
10
|
// Train subcommand - REAL WASM training with RuVector
|
|
10
11
|
const trainCommand = {
|
|
11
12
|
name: 'train',
|
|
@@ -4323,7 +4324,7 @@ const distillCommand = {
|
|
|
4323
4324
|
export const neuralCommand = {
|
|
4324
4325
|
name: 'neural',
|
|
4325
4326
|
description: 'Neural pattern training, MoE, Flash Attention, pattern learning',
|
|
4326
|
-
subcommands: [trainCommand, statusCommand, patternsCommand, predictCommand, optimizeCommand, benchmarkCommand, listCommand, exportCommand, importCommand, routerCommand, distillCommand],
|
|
4327
|
+
subcommands: [trainCommand, statusCommand, patternsCommand, predictCommand, optimizeCommand, benchmarkCommand, listCommand, exportCommand, importCommand, routerCommand, distillCommand, wspCommand],
|
|
4327
4328
|
examples: [
|
|
4328
4329
|
{ command: 'claude-flow neural status', description: 'Check neural system status' },
|
|
4329
4330
|
{ command: 'claude-flow neural train -p coordination', description: 'Train coordination patterns' },
|
|
@@ -489,7 +489,7 @@ const cveCommand = {
|
|
|
489
489
|
// If --check CVE-XXXX is given, filter to that specific CVE ID.
|
|
490
490
|
let auditJson;
|
|
491
491
|
try {
|
|
492
|
-
auditJson = execSync('npm audit --json
|
|
492
|
+
auditJson = execSync('npm audit --json', {
|
|
493
493
|
encoding: 'utf-8',
|
|
494
494
|
timeout: 30000,
|
|
495
495
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -1374,7 +1374,7 @@ async function doImport() {
|
|
|
1374
1374
|
|
|
1375
1375
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
1376
1376
|
warnMemoryUnavailable();
|
|
1377
|
-
return;
|
|
1377
|
+
return 1; // #4963: nothing was imported/synced
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
1380
1380
|
// Full implementation deferred to copied version
|
|
@@ -1391,7 +1391,7 @@ async function doSync() {
|
|
|
1391
1391
|
|
|
1392
1392
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
1393
1393
|
warnMemoryUnavailable();
|
|
1394
|
-
return;
|
|
1394
|
+
return 1; // #4963: nothing was imported/synced
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
dim('Auto memory sync available — run init --upgrade for full support');
|
|
@@ -1412,10 +1412,11 @@ process.on('unhandledRejection', () => {});
|
|
|
1412
1412
|
const COMMANDS = ['import', 'sync', 'status'];
|
|
1413
1413
|
const command = process.argv[2] || (COMMANDS.includes(process.argv[1]) ? process.argv[1] : 'status');
|
|
1414
1414
|
|
|
1415
|
+
let exitCode = 0;
|
|
1415
1416
|
try {
|
|
1416
1417
|
switch (command) {
|
|
1417
|
-
case 'import': await doImport(); break;
|
|
1418
|
-
case 'sync': await doSync(); break;
|
|
1418
|
+
case 'import': exitCode = (await doImport()) || 0; break;
|
|
1419
|
+
case 'sync': exitCode = (await doSync()) || 0; break;
|
|
1419
1420
|
case 'status': doStatus(); break;
|
|
1420
1421
|
default:
|
|
1421
1422
|
console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
|
|
@@ -1425,8 +1426,8 @@ try {
|
|
|
1425
1426
|
// Hooks must never crash Claude Code - fail silently
|
|
1426
1427
|
dim(\`Error (non-critical): \${err.message}\`);
|
|
1427
1428
|
}
|
|
1428
|
-
//
|
|
1429
|
-
process.exit(
|
|
1429
|
+
// A missing memory package exits 1 (#4963); other failures above stay non-critical.
|
|
1430
|
+
process.exit(exitCode);
|
|
1430
1431
|
`;
|
|
1431
1432
|
}
|
|
1432
1433
|
/**
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ruv-fann-wsp.ts — optional ruv-FANN weight-space tooling (ADR-528).
|
|
3
|
+
*
|
|
4
|
+
* Wraps three exact-pinned optional dependencies:
|
|
5
|
+
* - `ruv-fann-wsp` fingerprint, inspect, sensitivity
|
|
6
|
+
* - `ruv-fann-wsp-invariants` finite-domain output-bound checks
|
|
7
|
+
* - `ruv-fann-wsp-lifecycle` bounded-patch regression gates
|
|
8
|
+
*
|
|
9
|
+
* They share the `ruv-fann` core and `ruv-fann-wasm` runtime that agentdb and
|
|
10
|
+
* @metaharness/darwin already install, so they add no native code and no
|
|
11
|
+
* install scripts. The `ruv-fann` 0.3.0 facade is deliberately NOT used: it
|
|
12
|
+
* pulls esbuild (an install script) and a native RVF binding into every
|
|
13
|
+
* install for capabilities ruflo does not call.
|
|
14
|
+
*
|
|
15
|
+
* Every entry point loads the packages lazily. When they are absent the
|
|
16
|
+
* caller gets `{ available: false, reason }`; nothing else in the CLI
|
|
17
|
+
* imports this module, so cold start and routing are unchanged.
|
|
18
|
+
*
|
|
19
|
+
* Results are hash-bound evidence, not authority: nothing here promotes,
|
|
20
|
+
* writes or reroutes on its own.
|
|
21
|
+
*
|
|
22
|
+
* @module ruv-fann-wsp
|
|
23
|
+
*/
|
|
24
|
+
import type { CentroidArtifact } from './centroid-router.js';
|
|
25
|
+
export declare const WSP_PACKAGES: readonly ["ruv-fann-wsp", "ruv-fann-wsp-invariants", "ruv-fann-wsp-lifecycle"];
|
|
26
|
+
export type WspPackage = (typeof WSP_PACKAGES)[number];
|
|
27
|
+
/** Upper bound for any JSON file this module reads (models, suites, patches). */
|
|
28
|
+
export declare const MAX_INPUT_BYTES: number;
|
|
29
|
+
/** INVARIANT_LIMITS.maxCases in ruv-fann-wsp-invariants 0.1.0. */
|
|
30
|
+
export declare const MAX_CASES_PER_SUITE = 16;
|
|
31
|
+
/** Centroids are stored rounded, so a centroid scores slightly below 1 against itself. */
|
|
32
|
+
export declare const SELF_SCORE_TOLERANCE = 0.00001;
|
|
33
|
+
export interface DenseLayer {
|
|
34
|
+
inputs: number;
|
|
35
|
+
outputs: number;
|
|
36
|
+
/** Row-major [outputs, inputs]. */
|
|
37
|
+
weights: number[];
|
|
38
|
+
bias?: number[] | null;
|
|
39
|
+
activation: string;
|
|
40
|
+
steepness: number;
|
|
41
|
+
}
|
|
42
|
+
export interface DenseModel {
|
|
43
|
+
schema: 'ruv-fann.dense-layers/1';
|
|
44
|
+
layers: DenseLayer[];
|
|
45
|
+
}
|
|
46
|
+
export interface InvariantCase {
|
|
47
|
+
name: string;
|
|
48
|
+
inputs: number[];
|
|
49
|
+
rows: number;
|
|
50
|
+
minimum?: number[];
|
|
51
|
+
maximum?: number[];
|
|
52
|
+
expected?: number[];
|
|
53
|
+
tolerance?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface InvariantSuite {
|
|
56
|
+
schema: 'ruv-fann.invariants/1';
|
|
57
|
+
cases: InvariantCase[];
|
|
58
|
+
}
|
|
59
|
+
export interface WspModules {
|
|
60
|
+
wsp: Record<string, any>;
|
|
61
|
+
invariants: Record<string, any>;
|
|
62
|
+
lifecycle: Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
export type WspLoad = {
|
|
65
|
+
available: true;
|
|
66
|
+
modules: WspModules;
|
|
67
|
+
} | {
|
|
68
|
+
available: false;
|
|
69
|
+
reason: string;
|
|
70
|
+
};
|
|
71
|
+
export type Importer = (specifier: string) => Promise<Record<string, any>>;
|
|
72
|
+
/** Load all three packages once. Never throws. */
|
|
73
|
+
export declare function loadWsp(importer?: Importer): Promise<WspLoad>;
|
|
74
|
+
/**
|
|
75
|
+
* Installed version of each package, or null. `ruv-fann` is not a direct
|
|
76
|
+
* dependency, so it is looked up where ruv-fann-wsp resolves it: nested
|
|
77
|
+
* under it (pnpm, npm conflicts) or beside it (flat npm).
|
|
78
|
+
*/
|
|
79
|
+
export declare function wspVersions(): Record<WspPackage | 'ruv-fann', string | null>;
|
|
80
|
+
/**
|
|
81
|
+
* The centroid router as a one-layer Linear ruv-FANN model. Output k is the
|
|
82
|
+
* dot product with centroid k, which is the router's cosine score for a
|
|
83
|
+
* unit-length query, so the model ranks labels exactly as `classify` does.
|
|
84
|
+
*/
|
|
85
|
+
export declare function centroidToDenseModel(artifact: CentroidArtifact): DenseModel;
|
|
86
|
+
/**
|
|
87
|
+
* Self-routing invariants: fed its own centroid, each label must score
|
|
88
|
+
* 1 ± tolerance and every other label at most `1 - minGap`. A failure means
|
|
89
|
+
* two labels are (near-)duplicates or the artifact is corrupt — the router
|
|
90
|
+
* could not separate them even on their own means.
|
|
91
|
+
*
|
|
92
|
+
* Returned as several suites when there are more labels than one suite allows.
|
|
93
|
+
*/
|
|
94
|
+
export declare function centroidSelfRoutingSuites(artifact: CentroidArtifact, opts?: {
|
|
95
|
+
tolerance?: number;
|
|
96
|
+
minGap?: number;
|
|
97
|
+
}): InvariantSuite[];
|
|
98
|
+
/**
|
|
99
|
+
* Read a JSON file the user named. Refuses non-regular files (FIFOs, devices,
|
|
100
|
+
* directories), symlinks that leave nothing to read, and anything larger
|
|
101
|
+
* than MAX_INPUT_BYTES, before reading it into memory.
|
|
102
|
+
*/
|
|
103
|
+
export declare function readJsonInput(path: string, what: string, maxBytes?: number): unknown;
|
|
104
|
+
/** Shape check before handing a user model to WSP (which validates fully). */
|
|
105
|
+
export declare function assertDenseModel(x: unknown, what?: string): DenseModel;
|
|
106
|
+
export interface SelfRoutingResult {
|
|
107
|
+
accepted: boolean;
|
|
108
|
+
modelHash: string;
|
|
109
|
+
labels: number;
|
|
110
|
+
suites: number;
|
|
111
|
+
checks: number;
|
|
112
|
+
violations: Array<{
|
|
113
|
+
case: string;
|
|
114
|
+
output: string;
|
|
115
|
+
constraint: string;
|
|
116
|
+
actual: number;
|
|
117
|
+
bound: number;
|
|
118
|
+
}>;
|
|
119
|
+
backend: string;
|
|
120
|
+
ms: number;
|
|
121
|
+
}
|
|
122
|
+
/** Run the self-routing invariants against a centroid artifact. */
|
|
123
|
+
export declare function checkCentroidSelfRouting(mods: WspModules, artifact: CentroidArtifact, opts?: {
|
|
124
|
+
tolerance?: number;
|
|
125
|
+
minGap?: number;
|
|
126
|
+
}): Promise<SelfRoutingResult>;
|
|
127
|
+
/** Test hook. */
|
|
128
|
+
export declare function __resetWspForTests(): void;
|
|
129
|
+
//# sourceMappingURL=ruv-fann-wsp.d.ts.map
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ruv-fann-wsp.ts — optional ruv-FANN weight-space tooling (ADR-528).
|
|
3
|
+
*
|
|
4
|
+
* Wraps three exact-pinned optional dependencies:
|
|
5
|
+
* - `ruv-fann-wsp` fingerprint, inspect, sensitivity
|
|
6
|
+
* - `ruv-fann-wsp-invariants` finite-domain output-bound checks
|
|
7
|
+
* - `ruv-fann-wsp-lifecycle` bounded-patch regression gates
|
|
8
|
+
*
|
|
9
|
+
* They share the `ruv-fann` core and `ruv-fann-wasm` runtime that agentdb and
|
|
10
|
+
* @metaharness/darwin already install, so they add no native code and no
|
|
11
|
+
* install scripts. The `ruv-fann` 0.3.0 facade is deliberately NOT used: it
|
|
12
|
+
* pulls esbuild (an install script) and a native RVF binding into every
|
|
13
|
+
* install for capabilities ruflo does not call.
|
|
14
|
+
*
|
|
15
|
+
* Every entry point loads the packages lazily. When they are absent the
|
|
16
|
+
* caller gets `{ available: false, reason }`; nothing else in the CLI
|
|
17
|
+
* imports this module, so cold start and routing are unchanged.
|
|
18
|
+
*
|
|
19
|
+
* Results are hash-bound evidence, not authority: nothing here promotes,
|
|
20
|
+
* writes or reroutes on its own.
|
|
21
|
+
*
|
|
22
|
+
* @module ruv-fann-wsp
|
|
23
|
+
*/
|
|
24
|
+
import { lstatSync, readFileSync, realpathSync } from 'node:fs';
|
|
25
|
+
import { dirname, resolve as resolvePath } from 'node:path';
|
|
26
|
+
import { fileURLToPath } from 'node:url';
|
|
27
|
+
export const WSP_PACKAGES = ['ruv-fann-wsp', 'ruv-fann-wsp-invariants', 'ruv-fann-wsp-lifecycle'];
|
|
28
|
+
/** Upper bound for any JSON file this module reads (models, suites, patches). */
|
|
29
|
+
export const MAX_INPUT_BYTES = 2 * 1024 * 1024;
|
|
30
|
+
/** INVARIANT_LIMITS.maxCases in ruv-fann-wsp-invariants 0.1.0. */
|
|
31
|
+
export const MAX_CASES_PER_SUITE = 16;
|
|
32
|
+
/** Centroids are stored rounded, so a centroid scores slightly below 1 against itself. */
|
|
33
|
+
export const SELF_SCORE_TOLERANCE = 1e-5;
|
|
34
|
+
// A non-literal specifier keeps tsc from resolving the optional packages at
|
|
35
|
+
// build time; they are ESM-only, so `require` cannot load them.
|
|
36
|
+
const defaultImporter = (specifier) => import(specifier);
|
|
37
|
+
let _load = null;
|
|
38
|
+
function isMissingModule(err) {
|
|
39
|
+
const code = err?.code;
|
|
40
|
+
return code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND';
|
|
41
|
+
}
|
|
42
|
+
/** Load all three packages once. Never throws. */
|
|
43
|
+
export function loadWsp(importer = defaultImporter) {
|
|
44
|
+
if (importer !== defaultImporter)
|
|
45
|
+
return doLoad(importer);
|
|
46
|
+
if (!_load)
|
|
47
|
+
_load = doLoad(importer);
|
|
48
|
+
return _load;
|
|
49
|
+
}
|
|
50
|
+
async function doLoad(importer) {
|
|
51
|
+
const mods = {};
|
|
52
|
+
for (const name of WSP_PACKAGES) {
|
|
53
|
+
try {
|
|
54
|
+
mods[name] = await importer(name);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
const why = isMissingModule(err) ? 'is not installed' : `failed to load: ${err instanceof Error ? err.message : String(err)}`;
|
|
58
|
+
return { available: false, reason: `${name} ${why} (optional dependency of @claude-flow/cli)` };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
available: true,
|
|
63
|
+
modules: { wsp: mods['ruv-fann-wsp'], invariants: mods['ruv-fann-wsp-invariants'], lifecycle: mods['ruv-fann-wsp-lifecycle'] },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Package root of `name` at or above `dir`, or null. */
|
|
67
|
+
function packageRootAbove(dir, name) {
|
|
68
|
+
for (let i = 0; i < 4; i++) {
|
|
69
|
+
try {
|
|
70
|
+
const pkg = JSON.parse(readFileSync(resolvePath(dir, 'package.json'), 'utf8'));
|
|
71
|
+
if (pkg && pkg.name === name && typeof pkg.version === 'string')
|
|
72
|
+
return { root: dir, version: pkg.version };
|
|
73
|
+
}
|
|
74
|
+
catch { /* keep walking */ }
|
|
75
|
+
dir = dirname(dir);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Installed version of each package, or null. `ruv-fann` is not a direct
|
|
81
|
+
* dependency, so it is looked up where ruv-fann-wsp resolves it: nested
|
|
82
|
+
* under it (pnpm, npm conflicts) or beside it (flat npm).
|
|
83
|
+
*/
|
|
84
|
+
export function wspVersions() {
|
|
85
|
+
const out = {};
|
|
86
|
+
let wspRoot = null;
|
|
87
|
+
for (const name of WSP_PACKAGES) {
|
|
88
|
+
out[name] = null;
|
|
89
|
+
try {
|
|
90
|
+
const found = packageRootAbove(dirname(fileURLToPath(import.meta.resolve(name))), name);
|
|
91
|
+
if (found) {
|
|
92
|
+
out[name] = found.version;
|
|
93
|
+
if (name === 'ruv-fann-wsp')
|
|
94
|
+
wspRoot = found.root;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch { /* not installed */ }
|
|
98
|
+
}
|
|
99
|
+
out['ruv-fann'] = null;
|
|
100
|
+
if (wspRoot) {
|
|
101
|
+
for (const dir of [resolvePath(wspRoot, 'node_modules', 'ruv-fann'), resolvePath(wspRoot, '..', 'ruv-fann')]) {
|
|
102
|
+
const found = packageRootAbove(dir, 'ruv-fann');
|
|
103
|
+
if (found && found.root === dir) {
|
|
104
|
+
out['ruv-fann'] = found.version;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The centroid router as a one-layer Linear ruv-FANN model. Output k is the
|
|
113
|
+
* dot product with centroid k, which is the router's cosine score for a
|
|
114
|
+
* unit-length query, so the model ranks labels exactly as `classify` does.
|
|
115
|
+
*/
|
|
116
|
+
export function centroidToDenseModel(artifact) {
|
|
117
|
+
const weights = [];
|
|
118
|
+
for (const c of artifact.centroids)
|
|
119
|
+
for (const v of c)
|
|
120
|
+
weights.push(v);
|
|
121
|
+
return {
|
|
122
|
+
schema: 'ruv-fann.dense-layers/1',
|
|
123
|
+
layers: [{
|
|
124
|
+
inputs: artifact.dim,
|
|
125
|
+
outputs: artifact.labels.length,
|
|
126
|
+
weights,
|
|
127
|
+
bias: new Array(artifact.labels.length).fill(0),
|
|
128
|
+
activation: 'Linear',
|
|
129
|
+
steepness: 1,
|
|
130
|
+
}],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function caseName(prefix, label, i) {
|
|
134
|
+
const safe = label.replace(/[^A-Za-z0-9_.-]/g, '_');
|
|
135
|
+
return `${prefix}${i}-${safe}`.slice(0, 64);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Self-routing invariants: fed its own centroid, each label must score
|
|
139
|
+
* 1 ± tolerance and every other label at most `1 - minGap`. A failure means
|
|
140
|
+
* two labels are (near-)duplicates or the artifact is corrupt — the router
|
|
141
|
+
* could not separate them even on their own means.
|
|
142
|
+
*
|
|
143
|
+
* Returned as several suites when there are more labels than one suite allows.
|
|
144
|
+
*/
|
|
145
|
+
export function centroidSelfRoutingSuites(artifact, opts = {}) {
|
|
146
|
+
const tol = opts.tolerance ?? SELF_SCORE_TOLERANCE;
|
|
147
|
+
const minGap = opts.minGap ?? 0.05;
|
|
148
|
+
if (!(tol >= 0 && tol < 0.5))
|
|
149
|
+
throw new RangeError('tolerance must be in [0, 0.5)');
|
|
150
|
+
if (!(minGap > 0 && minGap < 1))
|
|
151
|
+
throw new RangeError('minGap must be in (0, 1)');
|
|
152
|
+
const n = artifact.labels.length;
|
|
153
|
+
const cases = artifact.centroids.map((c, i) => ({
|
|
154
|
+
name: caseName('self-', artifact.labels[i], i),
|
|
155
|
+
inputs: c.slice(),
|
|
156
|
+
rows: 1,
|
|
157
|
+
// Unit vectors: every score is within [-1, 1]; pad by tol for rounding.
|
|
158
|
+
minimum: Array.from({ length: n }, (_, j) => (j === i ? 1 - tol : -1 - tol)),
|
|
159
|
+
maximum: Array.from({ length: n }, (_, j) => (j === i ? 1 + tol : 1 - minGap)),
|
|
160
|
+
}));
|
|
161
|
+
const suites = [];
|
|
162
|
+
for (let i = 0; i < cases.length; i += MAX_CASES_PER_SUITE) {
|
|
163
|
+
suites.push({ schema: 'ruv-fann.invariants/1', cases: cases.slice(i, i + MAX_CASES_PER_SUITE) });
|
|
164
|
+
}
|
|
165
|
+
return suites;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read a JSON file the user named. Refuses non-regular files (FIFOs, devices,
|
|
169
|
+
* directories), symlinks that leave nothing to read, and anything larger
|
|
170
|
+
* than MAX_INPUT_BYTES, before reading it into memory.
|
|
171
|
+
*/
|
|
172
|
+
export function readJsonInput(path, what, maxBytes = MAX_INPUT_BYTES) {
|
|
173
|
+
if (typeof path !== 'string' || path.length === 0 || path.includes('\0')) {
|
|
174
|
+
throw new Error(`${what}: a file path is required`);
|
|
175
|
+
}
|
|
176
|
+
const real = realpathSync(resolvePath(path));
|
|
177
|
+
const st = lstatSync(real);
|
|
178
|
+
if (!st.isFile())
|
|
179
|
+
throw new Error(`${what}: ${path} is not a regular file`);
|
|
180
|
+
if (st.size > maxBytes)
|
|
181
|
+
throw new Error(`${what}: ${path} is ${st.size} bytes; limit is ${maxBytes}`);
|
|
182
|
+
const text = readFileSync(real, 'utf8');
|
|
183
|
+
try {
|
|
184
|
+
return JSON.parse(text);
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
throw new Error(`${what}: ${path} is not valid JSON (${err instanceof Error ? err.message : String(err)})`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Shape check before handing a user model to WSP (which validates fully). */
|
|
191
|
+
export function assertDenseModel(x, what = 'model') {
|
|
192
|
+
const m = x;
|
|
193
|
+
if (!m || typeof m !== 'object' || m.schema !== 'ruv-fann.dense-layers/1' || !Array.isArray(m.layers) || m.layers.length === 0) {
|
|
194
|
+
throw new Error(`${what}: expected a ruv-fann.dense-layers/1 model with at least one layer`);
|
|
195
|
+
}
|
|
196
|
+
return m;
|
|
197
|
+
}
|
|
198
|
+
/** Run the self-routing invariants against a centroid artifact. */
|
|
199
|
+
export async function checkCentroidSelfRouting(mods, artifact, opts = {}) {
|
|
200
|
+
const t0 = performance.now();
|
|
201
|
+
const model = centroidToDenseModel(artifact);
|
|
202
|
+
const suites = centroidSelfRoutingSuites(artifact, opts);
|
|
203
|
+
let accepted = true, checks = 0, backend = '', modelHash = '';
|
|
204
|
+
const violations = [];
|
|
205
|
+
for (const suite of suites) {
|
|
206
|
+
const r = await mods.invariants.checkModelInvariants(model, suite);
|
|
207
|
+
accepted &&= r.accepted === true;
|
|
208
|
+
checks += r.checks;
|
|
209
|
+
backend = r.backend;
|
|
210
|
+
modelHash = r.modelHash;
|
|
211
|
+
for (const v of r.violations) {
|
|
212
|
+
violations.push({ case: v.case, output: artifact.labels[v.output] ?? String(v.output), constraint: v.constraint, actual: v.actual, bound: v.bound });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return { accepted, modelHash, labels: artifact.labels.length, suites: suites.length, checks, violations, backend, ms: Math.round(performance.now() - t0) };
|
|
216
|
+
}
|
|
217
|
+
/** Test hook. */
|
|
218
|
+
export function __resetWspForTests() {
|
|
219
|
+
_load = null;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=ruv-fann-wsp.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.77.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -149,7 +149,10 @@
|
|
|
149
149
|
"ruvector": "^0.3.13",
|
|
150
150
|
"nostr-tools": "^2.7.0",
|
|
151
151
|
"@ruvector/learning-wasm": "0.1.29",
|
|
152
|
-
"agent-booster": "^0.2.2"
|
|
152
|
+
"agent-booster": "^0.2.2",
|
|
153
|
+
"ruv-fann-wsp": "0.2.0",
|
|
154
|
+
"ruv-fann-wsp-invariants": "0.1.0",
|
|
155
|
+
"ruv-fann-wsp-lifecycle": "0.1.0"
|
|
153
156
|
},
|
|
154
157
|
"peerDependencies": {
|
|
155
158
|
"@metaharness/router": "^0.4.0",
|