Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(ruflo-console): Vector Lab view for the ruvector toolchain

ruv0aa5c83a9279
diff --git a/plugins/ruflo-console/hooks/actions.ts b/plugins/ruflo-console/hooks/actions.ts
index 5fb683024c..7cb57ef893 100644
--- a/plugins/ruflo-console/hooks/actions.ts
+++ b/plugins/ruflo-console/hooks/actions.ts
@@ -23,6 +23,10 @@ export type ActionSpec = {
note?: string
/** How long the CLI may take; 90 s when unset. */
timeoutMs?: number
+ /** The whole command when it is another CLI than ruflo's (the ruvector CLI): it runs instead of the prefix and `args`. */
+ argv?: readonly string[]
+ /** Reads a lab run's output into its result lines instead of the MetaHarness reader (the Vector Lab redacts keys). */
+ lines?: (stdout: string, stderr: string) => string[]
}
export const exec = (tool: string, params: Record<string, string>) => ['mcp', 'exec', '-t', tool, '-p', JSON.stringify(params)] as const
diff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.ts
index a52ccfc673..65fd753a41 100644
--- a/plugins/ruflo-console/hooks/bindings.ts
+++ b/plugins/ruflo-console/hooks/bindings.ts
@@ -11,6 +11,7 @@ import { filterPalette, paletteEntries } from './palette'
import type { Runner } from './runner'
import { skillActions } from './skills'
import { PANE_ID, viewOf, type State } from './state'
+import { vectorActions } from './vector'
import type { Actions } from './views/common'
import { openTasks, selection } from './views/select'
@@ -250,6 +251,8 @@ export function actionsOf(state: State, host: Host, runner: Runner, steps: Steps
},
// â–¸ edit hands the skill to the AI terminal, as x.ruv.io's â–¸ open does: typed, not run.
skills: skillActions(state, host, runner, text => actions.term.load('claude', text)),
+ // An rvlite query is MCP-only: it goes to the AI terminal typed, as â–¸ edit does, and runs only when sent.
+ vector: vectorActions(state, runner, text => actions.term.load('claude', text)),
}
return actions
diff --git a/plugins/ruflo-console/hooks/data/vector.ts b/plugins/ruflo-console/hooks/data/vector.ts
new file mode 100644
index 0000000000..ded5a0d22e
--- /dev/null
+++ b/plugins/ruflo-console/hooks/data/vector.ts
@@ -0,0 +1,146 @@
+/**
+ * The ruvector CLI as fixed argv, the checks every typed value passes before it becomes an argv element, and the
+ * readers for what it prints. Read against ruvector 0.3.3's own source (bin/cli.js) and `--help`: none of its brain,
+ * rvf, rvlite, decompile, edge, identity or workers tools are in ruflo's MCP server, so each runs through this CLI or
+ * not at all. Under a pipe the CLI prints JSON for brain, edge and identity; hooks and rvf print coloured text.
+ * Pure: nothing here runs anything.
+ */
+import { plain } from './parse'
+
+/**
+ * The pin: the version the session's ruvector MCP server runs (`npx -y ruvector mcp start` resolved to 0.3.3), from
+ * the npx cache only. The ruflo-ruvector plugin documents 0.2.25, which has no decompile MCP surface.
+ */
+export const RUVECTOR_VERSION = '0.3.3'
+export const RV = ['npx', '--offline', '-y', `ruvector@${RUVECTOR_VERSION}`] as const
+
+/** The vector lab's fields between renders: each Input's text, as the person typed it. */
+export type VectorState = {
+ /** A brain query, a memory id, a domain, `source target`, or `title :: content`, per the button pressed. */
+ brain: string
+ rvfPath: string
+ /** The second RVF field: a query vector, an ingest file, a derived store, or a dimension. */
+ rvfArg: string
+ sql: string
+ /** A local `./file.js` or an npm package to decompile. */
+ target: string
+ /** A task to route, a query to recall, or a note to remember. */
+ task: string
+ /** What a background worker is asked to look at. */
+ worker: string
+}
+
+export const emptyVector = (): VectorState => ({ brain: '', rvfPath: '', rvfArg: '', sql: '', target: '', task: '', worker: '' })
+
+export type VectorField = keyof VectorState
+
+const TEXT = /^[\p{L}\p{N} .,:;!?'"()[\]{}/_@#+=&%*<>|~^$-]+$/u
+const ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/
+const DOMAIN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
+const NUMBER = '-?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][-+]?\\d+)?'
+const VECTOR = new RegExp(`^${NUMBER}(?:,${NUMBER})*$`)
+const NPM = /^(?:@[a-z0-9][a-z0-9._-]{0,63}\/)?[a-z0-9][a-z0-9._-]{0,127}(?:@[A-Za-z0-9.^~<>=+-]{1,40})?$/
+
+export const MAX_TEXT = 200
+
+/** Free text, trimmed, or null: empty, too long, a control character, a character outside TEXT, or a leading -. */
+export function textOf(value: string, max = MAX_TEXT): string | null {
+ const text = value.trim()
+
+ return text === '' || text.length > max || text.startsWith('-') || !TEXT.test(text) || plain(text, max + 1) !== text ? null : text
+}
+
+export const vecIdOf = (value: string): string | null => (ID.test(value.trim()) ? value.trim() : null)
+export const domainOf = (value: string): string | null => (DOMAIN.test(value.trim()) ? value.trim() : null)
+
+/**
+ * A path inside the project, or null: relative (no leading / or -), no `..` segment, plain characters only, and the
+ * file kind asked for. `./` is kept off: the CLI joins it to the working directory either way.
+ */
+export function relPathOf(value: string, ext: string): string | null {
+ const path = value.trim().replace(/^\.\//, '')
+
+ if (path === '' || path.length > 160 || path.startsWith('/') || path.startsWith('-') || !path.endsWith(ext)) return null
+ if (!/^[A-Za-z0-9._/-]+$/.test(path) || path.split('/').some(part => part === '..' || part === '' || part === '.')) return null
+
+ return path
+}
+
+/** A query vector as the CLI takes it (`--vector=<values>`), commas between at most 4096 finite numbers. */
+export function vectorOf(value: string): string | null {
+ const text = value.replace(/[\s[\]]/g, '')
+
+ if (text === '' || text.length > 65_536 || !VECTOR.test(text)) return null
+
+ const parts = text.split(',')
+
+ return parts.length <= 4096 && parts.every(part => Number.isFinite(Number(part))) ? text : null
+}
+
+/** A store dimension for `rvf create`: 1-4096, 384 when the field is empty. */
+export function dimensionOf(value: string): string | null {
+ const text = value.trim()
+
+ if (text === '') return '384'
+
+ return /^\d{1,4}$/.test(text) && Number(text) >= 1 && Number(text) <= 4096 ? String(Number(text)) : null
+}
+
+/** What `decompile` is pointed at, classified as ruvector's own parseTarget does: `./…` is a file, the rest npm. */
+export type Target = { kind: 'file'; arg: string } | { kind: 'npm'; arg: string }
+
+/**
+ * A decompile target, or null. A file must be a relative `.js`, `.mjs` or `.cjs` (passed as `./path`, which the CLI
+ * reads as a file); a package is an npm name with an optional `@version`. URLs are refused: the console fetches no
+ * address a person typed.
+ */
+export function targetOf(value: string): Target | null {
+ const text = value.trim()
+
+ if (/^[a-z]+:/i.test(text)) return null
+
+ const file = /\.(m|c)?js$/.test(text) && (text.startsWith('./') || text.includes('/')) && !text.startsWith('@') ? relPathOf(text, text.slice(text.lastIndexOf('.'))) : null
+
+ if (file !== null) return { kind: 'file', arg: `./${file}` }
+
+ return text.length <= 214 && NPM.test(text) ? { kind: 'npm', arg: text } : null
+}
+
+/** `title :: content` for brain share: both present, each plain text. */
+export function shareOf(value: string): { title: string; content: string } | null {
+ const at = value.indexOf('::')
+ const title = at < 0 ? null : textOf(value.slice(0, at), 120)
+ const content = at < 0 ? null : textOf(value.slice(at + 2), 2000)
+
+ return title === null || content === null ? null : { title, content }
+}
+
+/** Two words split at the first space: `source target`, `store.rvf vector`. */
+export function twoOf(value: string): [string, string] {
+ const text = value.trim()
+ const at = text.search(/\s/)
+
+ return at < 0 ? [text, ''] : [text.slice(0, at), text.slice(at + 1).trim()]
+}
+
+// Key material never reaches a line: a 64-hex pi key, its preview, the MCP token, or an `export PI=` hint.
+const KEY_LINE = /(^|\s)(key|key_preview|mcp_token|apiKey)\s*:|export PI=|pi-key\s*:/i
+const HEX_KEY = /\b[0-9a-f]{32,}\b/gi
+
+/** Lines with any key material taken out: whole lines that name a key, and any long hex run in what is left. */
+export function redact(lines: readonly string[]): string[] {
+ return lines.filter(line => !KEY_LINE.test(line)).map(line => line.replace(HEX_KEY, hex => (/^[0-9a-f]{32}$/i.test(hex) ? hex : '‹redacted›')))
+}
+
+/** `identity generate --save --json`: only the pseudonym and where the key went; the key itself is never read out. */
+export function generatedLines(stdout: string, stderr = ''): string[] {
+ const pseudonym = /"pseudonym"\s*:\s*"([0-9a-f]{16,64})"/i.exec(stdout)?.[1]
+ const saved = /Key saved to (\S+)/.exec(stdout)?.[1]
+
+ if (pseudonym === undefined) return redact([plain(stderr, 160) || 'identity generate printed no pseudonym'])
+
+ return [`pseudonym ${pseudonym}`, `key saved to ${saved !== undefined ? plain(saved, 120) : '~/.ruvector/pi-key'} (not shown: it is the secret)`]
+}
+
+/** True when the newest identity show said there is no key: the only state in which generate --save cannot overwrite one. */
+export const isKeyless = (lines: readonly string[]): boolean => lines.some(line => /No pi key found/i.test(line))
diff --git a/plugins/ruflo-console/hooks/palette.ts b/plugins/ruflo-console/hooks/palette.ts
index 320a67f328..97b6e57c77 100644
--- a/plugins/ruflo-console/hooks/palette.ts
+++ b/plugins/ruflo-console/hooks/palette.ts
@@ -9,6 +9,7 @@ import { claimTask, handoffClaim, releaseClaim, stealClaim, type ActionSpec } fr
import { LAB, labSpec, labWhy } from './mh-lab'
import { AGENT_TYPES, agentLogs, dispatchWorker, memorySearch, memoryStore, reroute, setClaimStatus, spawnAgent, stopAgent, swarmInit, swarmStop, vote, WORKERS } from './ops'
import { VIEWS, type State, type ViewId } from './state'
+import { VEC, vecSpec, vecWhy } from './vector'
import { selection } from './views/select'
export type PaletteRun =
@@ -116,6 +117,12 @@ export function paletteEntries(state: State, nowMs: number): PaletteEntry[] {
// The MetaHarness lab: reads run at once, the rest ask first; promotion is never an entry (see mh-lab.ts).
for (const entry of LAB) add(entry.id, 'metaharness', entry.label, { kind: 'spec', spec: labSpec(entry, state), why: labWhy(entry) })
+ // The Vector Lab: a typed entry's id is its keyword (`/ruflo run vec-brain-search hnsw`); n/a ones say why.
+ for (const entry of VEC) {
+ if (entry.field !== undefined && entry.na === undefined) add(entry.id, 'vector', `${entry.label} <${entry.rule ?? 'text'}>`, { kind: 'text', keyword: entry.id, make: text => vecSpec(entry, state, text) })
+ else add(entry.id, 'vector', entry.label, { kind: 'spec', spec: vecSpec(entry, state), why: vecWhy(entry, state) })
+ }
+
for (const worker of WORKERS) add(`worker-${worker}`, 'workers', `dispatch the ${worker} background worker`, { kind: 'spec', spec: dispatchWorker(worker), why: 'unknown worker' })
add('route', 'learning', 'route <task words>: ask the router for a pick', { kind: 'text', keyword: 'route', make: reroute })
diff --git a/plugins/ruflo-console/hooks/runner.ts b/plugins/ruflo-console/hooks/runner.ts
index 6a61fe2313..287801e27c 100644
--- a/plugins/ruflo-console/hooks/runner.ts
+++ b/plugins/ruflo-console/hooks/runner.ts
@@ -53,14 +53,14 @@ export function createRunner(state: State, host: Host, deps: RunnerDeps): Runner
host.invalidate()
try {
- const result = await host.run([...CLI_PREFIXES[state.options.cli], ...spec.args], spec.timeoutMs ?? 90_000)
+ const result = await host.run(spec.argv ?? [...CLI_PREFIXES[state.options.cli], ...spec.args], spec.timeoutMs ?? 90_000)
const answer = /"success"\s*:\s*(true|false)/.exec(result.stdout)?.[1]
const error = /"error"\s*:\s*"([^"]{0,160})"/.exec(result.stdout)?.[1] ?? /\[ERROR\]\s*(.{0,160})/.exec(result.stdout)?.[1]
const ok = result.exitCode === 0 && answer !== 'false' && error === undefined
// A lab run's output goes to the lab's result panel, scrolled from its top; the footer keeps the one-line outcome.
if (spec.lab !== undefined) {
- state.lab.result = { id: spec.lab, label: spec.label, ok, exitCode: result.exitCode, ...(spec.note !== undefined && { note: spec.note }), lines: labLines(spec.lab, result.stdout, result.stderr), atMs: Date.now() }
+ state.lab.result = { id: spec.lab, label: spec.label, ok, exitCode: result.exitCode, ...(spec.note !== undefined && { note: spec.note }), lines: spec.lines?.(result.stdout, result.stderr) ?? labLines(spec.lab, result.stdout, result.stderr), atMs: Date.now() }
state.select.item = 0
}
diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts
index 4270e97672..ecbda23722 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -4,13 +4,14 @@ import type { ProbeResult } from './data/cli'
import type { ConsoleEvent } from './data/events'
import type { ReadCache } from './data/files'
import { emptySkills, type SkillsState } from './data/skills'
+import { emptyVector, type VectorState } from './data/vector'
import type { Snapshot } from './data/snapshot'
import type { RufloRoute, RufloSnapshot } from '../types'
export const PLUGIN_NAME = 'ruflo-console'
export const PANE_ID = 'ruflo-console'
-export type ViewId = 'menu' | 'overview' | 'swarm' | 'hive' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'missions' | 'xruv' | 'terminal' | 'skills' | 'agent'
+export type ViewId = 'menu' | 'overview' | 'swarm' | 'hive' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'missions' | 'xruv' | 'terminal' | 'skills' | 'vector' | 'agent'
/**
* The views in tab order, each with its hotkey and the inline height it asks for. Digits are the first nine; the three
@@ -42,6 +43,8 @@ export const VIEWS: readonly { id: ViewId; key: string; label: string; short: st
{ id: 'terminal', key: 'i', label: 'Terminal', short: 'Trm', icon: '💻', blurb: 'an AI terminal: codex, claude or both, each a session that remembers the conversation, streamed live', rows: 32 },
// No hotkey: every digit and letter is taken. The tab, the menu prompt and /ruflo skills reach it by name.
{ id: 'skills', key: '', label: 'Skills', short: 'Skl', icon: '🧰', blurb: 'agent skills (npx skills, skills.sh): what is installed here and globally, search, add, update, remove, create', rows: 34 },
+ // No hotkey either: reached from the tab, the menu prompt (vector) or /ruflo vector.
+ { id: 'vector', key: '', label: 'Vector Lab', short: 'Vec', icon: '🧲', blurb: 'ruvector: the shared brain, RVF stores, rvlite queries, decompile, workers, edge, hooks intel and your pi identity', rows: 44 },
]
export const AGENT_VIEW = { id: 'agent' as const, rows: 28 }
@@ -217,6 +220,8 @@ export type State = {
}
/** The skills view: installed skills, the last search, and the change running now. */
skills: SkillsState
+ /** The Vector Lab's fields; its runs land in `lab` under vec- ids. */
+ vector: VectorState
timers: Map<string, Timer>
stats: { renders: number[]; refreshes: number[]; frames: number[] }
}
@@ -261,6 +266,7 @@ export function newState(raw: PluginOptions | undefined): State {
barDrawnAtMs: 0,
terminal: { harness: 'codex', draft: '', lines: [], runs: new Map(), sessions: {}, isLive: { codex: false, claude: false }, turns: { codex: 0, claude: 0 }, costUsd: 0, scroll: 0, unseen: 0, asked: null },
skills: emptySkills(),
+ vector: emptyVector(),
timers: new Map(),
stats: { renders: [], refreshes: [], frames: [] },
}
diff --git a/plugins/ruflo-console/hooks/vector.ts b/plugins/ruflo-console/hooks/vector.ts
new file mode 100644
index 0000000000..3f03769ca6
--- /dev/null
+++ b/plugins/ruflo-console/hooks/vector.ts
@@ -0,0 +1,223 @@
+/**
+ * The Vector Lab: the ruvector toolchain (its CLI, and the MCP server's tools that have a CLI verb) as fixed argv,
+ * each checked against ruvector 0.3.3's `--help` and source. ruflo's own MCP has none of these tools, so every entry
+ * runs `npx --offline -y [email protected] …` with no shell. A local read runs at once; a local write asks; anything that
+ * reaches the network (pi.ruv.io, the edge genesis node, the npm registry), publishes, spends or deletes asks first and
+ * says so on the confirm row. Tools with no CLI verb (rvlite_*, rvf_delete, decompile_witness/search) are n/a here; the
+ * rvlite queries are handed to the AI terminal, which asks before it runs anything. Pure: entries and specs only.
+ */
+import type { ActionSpec } from './actions'
+import { dimensionOf, domainOf, generatedLines, isKeyless, redact, relPathOf, RV, shareOf, targetOf, textOf, twoOf, vecIdOf, vectorOf, type VectorField } from './data/vector'
+import { labLines } from './mh-lab'
+import type { Runner } from './runner'
+import type { State } from './state'
+
+/** `read`: local, $0. `writes`: a local file. `net`: asks a remote host. `publish`: changes shared state on one. `spends`: may call models. `deletes`: cannot be undone. */
+export type VecCost = 'read' | 'writes' | 'net' | 'publish' | 'spends' | 'deletes'
+export type VecSection = 'brain' | 'rvf' | 'sql' | 'decompile' | 'workers' | 'edge' | 'hooks' | 'identity'
+
+export type VecEntry = {
+ id: string
+ section: VecSection
+ name: string
+ about: string
+ label: string
+ cost: VecCost
+ /** The argv after the ruvector prefix: fixed, or built from the entry's typed text (null when the text will not do). */
+ args?: readonly string[] | ((text: string) => readonly string[] | null)
+ /** The Input the text comes from in the view, and what it must look like when it will not do. */
+ field?: VectorField
+ rule?: string
+ /** Why it cannot run here at all: no CLI verb, a browser, or a missing package. */
+ na?: string
+ /** Why it cannot run now, from the state; null when it can. */
+ gate?: (state: State) => string | null
+ note?: string
+ timeoutMs?: number
+ lines?: (stdout: string, stderr: string) => string[]
+}
+
+export const VEC_SECTIONS: readonly { id: VecSection; title: string; right: string }[] = [
+ { id: 'brain', title: 'Brain', right: 'pi.ruv.io · shared · every call asks first' },
+ { id: 'rvf', title: 'RVF containers', right: 'local .rvf stores · reads run at once' },
+ { id: 'sql', title: 'SQL / Graph', right: 'rvlite · MCP-only · handed to the AI terminal' },
+ { id: 'decompile', title: 'Decompile', right: 'a file runs at once · a package asks (npm)' },
+ { id: 'workers', title: 'Workers', right: 'npx agentic-flow@alpha · asks first' },
+ { id: 'edge', title: 'Edge', right: 'edge-net genesis node · asks first' },
+ { id: 'hooks', title: 'Hooks intel', right: 'local · $0 · runs at once' },
+ { id: 'identity', title: 'Identity', right: 'pi key · never shown' },
+]
+
+const PI = 'reaches pi.ruv.io (the shared brain); needs @ruvector/pi-brain beside ruvector'
+const PUBLISH = `PUBLISHES to pi.ruv.io under your pi identity: other agents see it; ${PI.slice(PI.indexOf(';') + 2)}`
+const EDGE = 'reaches the edge-net genesis node (Cloud Run, us-central1)'
+const AGENTIC = 'reaches the npm registry: every workers verb runs npx agentic-flow@alpha'
+const TEXT_RULE = '1-200 characters of plain text, not starting with -'
+const ID_RULE = 'a memory id: letters, digits, . _ : -'
+const RVF_RULE = 'a project-relative .rvf path (no .., no leading / or -)'
+
+/** Each text kind, as argv or null. */
+const text = (fn: (value: string) => readonly string[] | null) => fn
+const free = (value: string) => textOf(value)
+const rvfWith = (verb: string, second?: (arg: string) => readonly string[] | null) =>
+ text(value => {
+ const [first, arg] = twoOf(value)
+ const path = relPathOf(first, '.rvf')
+ const rest = second === undefined ? [] : second(arg)
+
+ return path === null || rest === null ? null : ['rvf', verb, path, ...rest]
+ })
+
+export const VEC: readonly VecEntry[] = [
+ // BRAIN: every call reaches pi.ruv.io, so even the reads ask.
+ { id: 'vec-brain-status', section: 'brain', name: 'STATUS', about: 'memories, contributors, quality, drift', label: 'brain status: the shared brain’s health', cost: 'net', args: ['brain', 'status'], note: PI },
+ { id: 'vec-brain-list', section: 'brain', name: 'RECENT', about: 'the newest 20 shared memories', label: 'brain list: the newest 20 memories', cost: 'net', args: ['brain', 'list', '--limit', '20'], note: PI },
+ { id: 'vec-brain-search', section: 'brain', name: 'SEARCH', about: 'semantic search of the field’s words', label: 'brain search: the field’s words', cost: 'net', field: 'brain', rule: TEXT_RULE, args: value => { const q = free(value); return q === null ? null : ['brain', 'search', q, '--limit', '10'] }, note: PI },
+ { id: 'vec-brain-get', section: 'brain', name: 'GET', about: 'one memory by the id in the field, with provenance', label: 'brain get: the memory with that id', cost: 'net', field: 'brain', rule: ID_RULE, args: value => { const id = vecIdOf(value); return id === null ? null : ['brain', 'get', id] }, note: PI },
+ { id: 'vec-brain-drift', section: 'brain', name: 'DRIFT', about: 'knowledge drift, for the domain in the field or all', label: 'brain drift: for the field’s domain, or all', cost: 'net', field: 'brain', rule: 'a domain word, or nothing', args: value => (value.trim() === '' ? ['brain', 'drift'] : domainOf(value) === null ? null : ['brain', 'drift', value.trim()]), note: PI },
+ { id: 'vec-brain-partition', section: 'brain', name: 'PARTITION', about: 'knowledge topology, for the domain or all', label: 'brain partition: the topology of a domain, or all', cost: 'net', field: 'brain', rule: 'a domain word, or nothing', args: value => (value.trim() === '' ? ['brain', 'partition'] : domainOf(value) === null ? null : ['brain', 'partition', value.trim()]), note: PI },
+ { id: 'vec-brain-vote-up', section: 'brain', name: 'VOTE UP', about: 'up-vote the memory whose id is in the field', label: 'brain vote up on that memory', cost: 'publish', field: 'brain', rule: ID_RULE, args: value => { const id = vecIdOf(value); return id === null ? null : ['brain', 'vote', id, 'up'] }, note: PUBLISH },
+ { id: 'vec-brain-vote-down', section: 'brain', name: 'VOTE DOWN', about: 'down-vote the memory whose id is in the field', label: 'brain vote down on that memory', cost: 'publish', field: 'brain', rule: ID_RULE, args: value => { const id = vecIdOf(value); return id === null ? null : ['brain', 'vote', id, 'down'] }, note: PUBLISH },
+ { id: 'vec-brain-share', section: 'brain', name: 'SHARE', about: '`title :: content` as a pattern memory', label: 'brain share: publish the field as a pattern', cost: 'publish', field: 'brain', rule: 'title :: content, each plain text', args: value => { const share = shareOf(value); return share === null ? null : ['brain', 'share', share.title, '--category', 'pattern', '--content', share.content] }, note: PUBLISH },
+ { id: 'vec-brain-transfer', section: 'brain', name: 'TRANSFER', about: '`source target`: move knowledge between domains', label: 'brain transfer between the two domains', cost: 'publish', field: 'brain', rule: 'two domain words: source target', args: value => { const [from, to] = twoOf(value); return domainOf(from) === null || domainOf(to) === null ? null : ['brain', 'transfer', from, to] }, note: PUBLISH },
+ { id: 'vec-brain-sync-pull', section: 'brain', name: 'SYNC PULL', about: 'pull the shared LoRA weights here', label: 'brain sync pull: fetch the shared LoRA weights', cost: 'net', args: ['brain', 'sync', 'pull'], note: `${PI}; writes the pulled weights locally` },
+ { id: 'vec-brain-sync-push', section: 'brain', name: 'SYNC PUSH', about: 'push this machine’s LoRA weights up', label: 'brain sync push: upload the local LoRA weights', cost: 'publish', args: ['brain', 'sync', 'push'], note: PUBLISH },
+ { id: 'vec-brain-delete', section: 'brain', name: 'DELETE', about: 'delete a memory you contributed, by id', label: 'brain delete: the memory with that id', cost: 'deletes', field: 'brain', rule: ID_RULE, args: value => { const id = vecIdOf(value); return id === null ? null : ['brain', 'delete', id] }, note: `DELETES it from pi.ruv.io for everyone; it cannot be undone; ${PI}` },
+
+ // RVF: the store path is the first field; the second carries a vector, a file, a child store or a dimension.
+ { id: 'vec-rvf-examples', section: 'rvf', name: 'EXAMPLES', about: 'the 45 example stores and their sizes', label: 'rvf examples: the example store catalog', cost: 'read', args: ['rvf', 'examples'] },
+ { id: 'vec-rvf-status', section: 'rvf', name: 'STATUS', about: 'vectors, segments, epoch, dead space', label: 'rvf status of the store', cost: 'read', field: 'rvfPath', rule: RVF_RULE, args: rvfWith('status') },
+ { id: 'vec-rvf-segments', section: 'rvf', name: 'SEGMENTS', about: 'every segment in the file', label: 'rvf segments of the store', cost: 'read', field: 'rvfPath', rule: RVF_RULE, args: rvfWith('segments') },
+ { id: 'vec-rvf-query', section: 'rvf', name: 'QUERY', about: 'the 10 nearest to the vector in the second field', label: 'rvf query: the 10 nearest neighbours', cost: 'read', field: 'rvfPath', rule: `${RVF_RULE}, then a vector: numbers separated by commas`, args: rvfWith('query', arg => { const vector = vectorOf(arg); return vector === null ? null : [`--vector=${vector}`, '--k', '10'] }), note: 'reads; ruvector quarantines (renames) a corrupt id sidecar it meets' },
+ { id: 'vec-rvf-create', section: 'rvf', name: 'CREATE', about: 'a new cosine store, dimension from the second field (384)', label: 'rvf create: a new cosine store', cost: 'writes', field: 'rvfPath', rule: `${RVF_RULE}, then a dimension 1-4096 (or nothing: 384)`, args: rvfWith('create', arg => { const dim = dimensionOf(arg); return dim === null ? null : ['--dimension', dim, '--metric', 'cosine'] }), note: 'writes the .rvf file and its id sidecar in this project' },
+ { id: 'vec-rvf-ingest', section: 'rvf', name: 'INGEST', about: 'vectors from the JSON file in the second field', label: 'rvf ingest: vectors from a JSON file', cost: 'writes', field: 'rvfPath', rule: `${RVF_RULE}, then a project-relative .json of [{id, vector}]`, args: rvfWith('ingest', arg => { const file = relPathOf(arg, '.json'); return file === null ? null : ['--input', file] }), note: 'writes: appends the vectors to the store' },
+ { id: 'vec-rvf-derive', section: 'rvf', name: 'DERIVE', about: 'a child store at the second field’s path, with lineage', label: 'rvf derive: a child store with lineage', cost: 'writes', field: 'rvfPath', rule: `${RVF_RULE}, then the child .rvf path`, args: rvfWith('derive', arg => { const child = relPathOf(arg, '.rvf'); return child === null ? null : [child] }), note: 'writes a new .rvf file in this project' },
+ { id: 'vec-rvf-compact', section: 'rvf', name: 'COMPACT', about: 'reclaim the space of deleted vectors', label: 'rvf compact: reclaim deleted space', cost: 'writes', field: 'rvfPath', rule: RVF_RULE, args: rvfWith('compact'), note: 'rewrites the store in place' },
+ { id: 'vec-rvf-delete', section: 'rvf', name: 'DELETE', about: 'delete vectors by id', label: 'rvf delete vectors by id', cost: 'deletes', na: 'n/a: rvf_delete is an MCP tool of the ruvector server with no CLI verb, and ruflo’s MCP has no rvf tool' },
+
+ // SQL / GRAPH: rvlite has no CLI verb for these; the button hands the query to the AI terminal.
+ { id: 'vec-sql', section: 'sql', name: 'SQL', about: 'rvlite_sql over the rvlite database', label: 'rvlite SQL query', cost: 'read', field: 'sql', na: 'n/a as argv: rvlite_sql is MCP-only (ruvector’s CLI and rvlite 0.2.6’s have no sql verb); ▸ ask hands it to the AI terminal' },
+ { id: 'vec-cypher', section: 'sql', name: 'CYPHER', about: 'rvlite_cypher over the property graph', label: 'rvlite Cypher query', cost: 'read', field: 'sql', na: 'n/a as argv: rvlite_cypher is MCP-only; â–¸ ask hands it to the AI terminal' },
+ { id: 'vec-sparql', section: 'sql', name: 'SPARQL', about: 'rvlite_sparql over the RDF triples', label: 'rvlite SPARQL query', cost: 'read', field: 'sql', na: 'n/a as argv: rvlite_sparql is MCP-only; â–¸ ask hands it to the AI terminal' },
+
+ // DECOMPILE: ruvector's parseTarget reads ./… as a file and anything else as an npm package.
+ { id: 'vec-decompile-file', section: 'decompile', name: 'FILE', about: 'a local ./file.js into modules, with its witness root', label: 'decompile the local file', cost: 'read', field: 'target', rule: 'a project-relative ./file.js, .mjs or .cjs', args: value => { const target = targetOf(value); return target?.kind !== 'file' ? null : ['decompile', target.arg, '--json'] }, timeoutMs: 120_000 },
+ { id: 'vec-decompile-pkg', section: 'decompile', name: 'PACKAGE', about: 'an npm package (name or name@version), with witness', label: 'decompile the npm package', cost: 'net', field: 'target', rule: 'an npm package name, optionally @version', args: value => { const target = targetOf(value); return target?.kind !== 'npm' ? null : ['decompile', target.arg, '--json'] }, note: 'reaches the npm registry: downloads the package tarball; writes nothing here (--json)', timeoutMs: 180_000 },
+ { id: 'vec-decompile-witness', section: 'decompile', name: 'WITNESS', about: 'verify a witness chain, search decompiled code', label: 'decompile witness / search', cost: 'read', na: 'n/a: decompile_witness and decompile_search are MCP-only; the decompile result above carries the witness root and chain length' },
+
+ // WORKERS: ruvector hands each verb to npx agentic-flow@alpha, so all of them reach the registry.
+ { id: 'vec-workers-presets', section: 'workers', name: 'PRESETS', about: 'quick-scan, deep-analysis, security-scan…', label: 'workers presets', cost: 'net', args: ['workers', 'presets'], note: AGENTIC, timeoutMs: 180_000 },
+ { id: 'vec-workers-triggers', section: 'workers', name: 'TRIGGERS', about: 'the keywords that start a worker', label: 'workers triggers', cost: 'net', args: ['workers', 'triggers'], note: AGENTIC, timeoutMs: 180_000 },
+ { id: 'vec-workers-status', section: 'workers', name: 'STATUS', about: 'the worker dashboard', label: 'workers status', cost: 'net', args: ['workers', 'status'], note: AGENTIC, timeoutMs: 180_000 },
+ { id: 'vec-workers-results', section: 'workers', name: 'RESULTS', about: 'what the workers found', label: 'workers results', cost: 'net', args: ['workers', 'results', '--json'], note: AGENTIC, timeoutMs: 180_000 },
+ { id: 'vec-workers-stats', section: 'workers', name: 'STATS', about: 'the last 24 hours of work', label: 'workers stats (24h)', cost: 'net', args: ['workers', 'stats'], note: AGENTIC, timeoutMs: 180_000 },
+ { id: 'vec-workers-dispatch', section: 'workers', name: 'DISPATCH', about: 'start a background analysis of the field’s words', label: 'workers dispatch: analyse the field’s words', cost: 'spends', field: 'worker', rule: TEXT_RULE, args: value => { const prompt = free(value); return prompt === null ? null : ['workers', 'dispatch', '--', prompt] }, note: `MAY COST MONEY: the worker may call models; ${AGENTIC}`, timeoutMs: 180_000 },
+
+ // EDGE: the genesis node answers status, balance and tasks; join only prints the dashboard address.
+ { id: 'vec-edge-status', section: 'edge', name: 'STATUS', about: 'nodes, active nodes, rUv supply, phase', label: 'edge status', cost: 'net', args: ['edge', 'status'], note: EDGE },
+ { id: 'vec-edge-balance', section: 'edge', name: 'BALANCE', about: 'the rUv balance of your pi identity', label: 'edge balance of your identity', cost: 'net', args: ['edge', 'balance'], note: `${EDGE}; sends your pi key as the node id when PI is set` },
+ { id: 'vec-edge-tasks', section: 'edge', name: 'TASKS', about: 'distributed compute tasks on offer', label: 'edge tasks', cost: 'net', args: ['edge', 'tasks'], note: EDGE },
+ { id: 'vec-edge-join', section: 'edge', name: 'JOIN', about: 'how to join: the CLI prints the dashboard address', label: 'edge join: how to join as a node', cost: 'read', args: ['edge', 'join'] },
+ { id: 'vec-edge-dashboard', section: 'edge', name: 'DASHBOARD', about: 'open the edge-net dashboard', label: 'edge dashboard', cost: 'net', na: 'n/a: it opens a browser (xdg-open); edge join prints the same address' },
+
+ // HOOKS INTEL: ruvector's local intelligence store; only remember writes.
+ { id: 'vec-hooks-stats', section: 'hooks', name: 'STATS', about: 'patterns, memories, trajectories, errors', label: 'hooks stats: ruvector’s intelligence', cost: 'read', args: ['hooks', 'stats'] },
+ { id: 'vec-hooks-learning', section: 'hooks', name: 'LEARNING', about: 'the best algorithm, updates and reward', label: 'hooks learning-stats', cost: 'read', args: ['hooks', 'learning-stats', '--json'] },
+ { id: 'vec-hooks-route', section: 'hooks', name: 'ROUTE', about: 'which agent the field’s task should go to', label: 'hooks route: an agent for the task', cost: 'read', field: 'task', rule: TEXT_RULE, args: value => { const task = free(value); return task === null ? null : ['hooks', 'route', '--', task] } },
+ { id: 'vec-hooks-recall', section: 'hooks', name: 'RECALL', about: 'the five memories nearest the field’s words', label: 'hooks recall: the nearest memories', cost: 'read', field: 'task', rule: TEXT_RULE, args: value => { const query = free(value); return query === null ? null : ['hooks', 'recall', '--top-k', '5', '--', query] } },
+ { id: 'vec-hooks-rag', section: 'hooks', name: 'RAG CONTEXT', about: 'context for the field’s words, reranked', label: 'hooks rag-context for the words', cost: 'read', field: 'task', rule: TEXT_RULE, args: value => { const query = free(value); return query === null ? null : ['hooks', 'rag-context', '--top-k', '5', '--rerank', '--', query] } },
+ { id: 'vec-hooks-remember', section: 'hooks', name: 'REMEMBER', about: 'store the field’s words as a memory', label: 'hooks remember: store the words', cost: 'writes', field: 'task', rule: TEXT_RULE, args: value => { const note = free(value); return note === null ? null : ['hooks', 'remember', '--type', 'console', '--', note] }, note: 'writes one memory to .ruvector/intelligence.json' },
+
+ // IDENTITY: show runs at once with the key taken out; generate waits until show has found no key.
+ { id: 'vec-identity-show', section: 'identity', name: 'SHOW', about: 'your pseudonym and where the key lives (never the key)', label: 'identity show: your pseudonym', cost: 'read', args: ['identity', 'show'] },
+ {
+ id: 'vec-identity-generate',
+ section: 'identity',
+ name: 'GENERATE',
+ about: 'a new pi key saved to ~/.ruvector/pi-key, once there is none',
+ label: 'identity generate: a new pi key, saved',
+ cost: 'writes',
+ args: ['identity', 'generate', '--save', '--json'],
+ gate: state => (state.lab.result?.id === 'vec-identity-show' && isKeyless(state.lab.result.lines) ? null : 'run â–¸ SHOW first: generate --save overwrites ~/.ruvector/pi-key, so it waits until show finds no key'),
+ note: 'writes a new secret to ~/.ruvector/pi-key (mode 600); only its pseudonym is shown',
+ lines: generatedLines,
+ },
+]
+
+export const vecEntry = (id: string): VecEntry | undefined => VEC.find(entry => entry.id === id)
+
+/** What a run printed, as lines for the result panel, with every trace of key material taken out. */
+export const vecLines = (id: string, stdout: string, stderr: string): string[] => redact(labLines(id, stdout, stderr))
+
+/** The argv after the prefix for `text`, or null; the fixed ones ignore the text. */
+export function vecArgs(entry: VecEntry, text = ''): readonly string[] | null {
+ if (entry.na !== undefined || entry.args === undefined) return null
+
+ return typeof entry.args === 'function' ? entry.args(text) : entry.args
+}
+
+/** The spec to run: a local read runs at once, the rest ask with their note; null when it cannot run (see `vecWhy`). */
+export function vecSpec(entry: VecEntry, state: State, text = ''): ActionSpec | null {
+ const args = entry.gate?.(state) == null ? vecArgs(entry, text) : null
+
+ if (args === null) return null
+
+ const argv = [...RV, ...args]
+ const isRead = entry.cost === 'read'
+
+ return {
+ label: entry.label,
+ args,
+ argv,
+ shows: argv.join(' '),
+ expect: isRead ? 'its output in the Vector Lab' : `its result in the Vector Lab${entry.note !== undefined ? `; ${entry.note}` : ''}`,
+ lab: entry.id,
+ lines: entry.lines ?? ((stdout, stderr) => vecLines(entry.id, stdout, stderr)),
+ ...(isRead && { isReadOnly: true }),
+ ...(entry.note !== undefined && { note: entry.note }),
+ timeoutMs: entry.timeoutMs ?? 90_000,
+ }
+}
+
+/** Why an entry has nothing to run, in the footer's words. */
+export function vecWhy(entry: VecEntry, state: State): string {
+ return entry.na ?? entry.gate?.(state) ?? (entry.rule !== undefined ? `${entry.label}: type ${entry.rule}` : 'nothing to run')
+}
+
+/** The rvlite query handed to the AI terminal: claude calls the MCP tool, and the terminal asks before it runs. */
+export function rvlitePrompt(kind: 'sql' | 'cypher' | 'sparql', query: string): string | null {
+ const text = query.trim()
+
+ if (text === '' || text.length > 500 || /[\u0000-\u001f\u007f]/.test(text)) return null
+
+ const isWrite = kind === 'sparql' ? /\b(INSERT|DELETE|LOAD|CLEAR|DROP|CREATE)\b/i.test(text) : /\b(INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|MERGE|SET|REMOVE|DETACH)\b/i.test(text)
+
+ return `Use the ruvector MCP tool rvlite_${kind} to run this ${kind === 'sql' ? 'SQL' : kind === 'cypher' ? 'Cypher' : 'SPARQL'} query and show the rows as a table${isWrite ? '. It CHANGES the database: tell me what it will change and wait for my yes before running it' : ' (read-only)'}: ${text}`
+}
+
+export type VectorActions = {
+ draft: (field: VectorField, text: string) => void
+ /** Runs an entry with the text it takes (the view passes the field's text). */
+ run: (id: string, text?: string) => void
+ /** An rvlite query, typed into the AI terminal for claude. */
+ ask: (kind: 'sql' | 'cypher' | 'sparql', query: string) => void
+}
+
+export function vectorActions(state: State, runner: Runner, load: (text: string) => void): VectorActions {
+ return {
+ draft: (field, text) => {
+ state.vector[field] = text
+ },
+ run: (id, text = '') => {
+ const entry = vecEntry(id)
+
+ runner.ask(entry === undefined ? null : vecSpec(entry, state, text), entry === undefined ? `no vector entry ${id}` : vecWhy(entry, state))
+ },
+ ask: (kind, query) => {
+ const prompt = rvlitePrompt(kind, query)
+
+ if (prompt === null) runner.ask(null, `rvlite ${kind}: type a query of 1-500 characters`)
+ else load(prompt)
+ },
+ }
+}
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index 482d9f5b70..fc6d2afdc8 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -9,6 +9,7 @@ import type { ProbeResult } from '../data/cli'
import type { Grid } from '../gfx/raster'
import type { SkillActions } from '../skills'
import type { HarnessId, State, ViewId } from '../state'
+import type { VectorActions } from '../vector'
export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & { Raster?: Elements['terminal']['Raster']; Input?: Elements['terminal']['Input'] }
@@ -44,6 +45,8 @@ export type Actions = {
term: { harness: (id: HarnessId) => void; draft: (text: string) => void; submit: (text: string) => void; stop: () => void; fresh: () => void; clear: () => void; load: (id: HarnessId, text: string) => void; /** Moves the window up (positive) or down by screen rows. */ scroll: (by: number) => void; /** Puts an earlier question back in the field. */ reuse: (text: string) => void }
/** The skills view: list, search, and the confirm-gated add, remove, update and create; edit loads the terminal. */
skills: SkillActions
+ /** The Vector Lab: its fields, its entries (asked or run through the runner), and rvlite queries handed to the terminal. */
+ vector: VectorActions
}
export type Ctx = {
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 585f47c21c..f225d7ee02 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -25,6 +25,7 @@ import { pluginsView } from './plugins'
import { skillsView } from './skills'
import { swarmView } from './swarm'
import { terminalView } from './terminal'
+import { vectorView } from './vector'
import { xruvView } from './xruv'
export const NARROW = 44
@@ -53,6 +54,7 @@ const BODIES: Record<ViewId, (ctx: Ctx) => RenderElement> = {
xruv: xruvView,
terminal: terminalView,
skills: skillsView,
+ vector: vectorView,
agent: agentView,
}
diff --git a/plugins/ruflo-console/hooks/views/vector.ts b/plugins/ruflo-console/hooks/views/vector.ts
new file mode 100644
index 0000000000..8bc3efca22
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/vector.ts
@@ -0,0 +1,150 @@
+import type { RenderElement } from 'claude-code'
+
+import { targetOf, type VectorField } from '../data/vector'
+import { VEC, VEC_SECTIONS, vecSpec, type VecCost, type VecEntry, type VecSection } from '../vector'
+import { ago, button, clip, row, rule, text, THEME, type Ctx } from './common'
+
+/** Result lines in view at once; j/k scroll the rest. */
+export const VEC_ROWS = 12
+
+/** Each cost as a four-cell tag: $0 reads, local writes, network asks, publishing, spending and deleting. */
+const TAG: Record<VecCost, { text: string; color: () => string }> = {
+ read: { text: ' $0 ', color: () => THEME.ok },
+ writes: { text: ' wr ', color: () => THEME.info },
+ net: { text: 'net ', color: () => THEME.warn },
+ publish: { text: 'pub ', color: () => THEME.bad },
+ spends: { text: ' $$ ', color: () => THEME.bad },
+ deletes: { text: 'del ', color: () => THEME.bad },
+}
+
+/** Each section's fields: key, label, placeholder, and the entry Enter runs. */
+const FIELDS: Partial<Record<VecSection, readonly { field: VectorField; label: string; placeholder: string; submit: string }[]>> = {
+ brain: [{ field: 'brain', label: 'brain', placeholder: 'a query · a memory id · a domain · source target · title :: content', submit: 'vec-brain-search' }],
+ rvf: [
+ { field: 'rvfPath', label: 'store', placeholder: 'path/to/store.rvf (inside this project)', submit: 'vec-rvf-status' },
+ { field: 'rvfArg', label: 'with', placeholder: 'query: 0.1,0.2,… · ingest: vectors.json · derive: child.rvf · create: 384', submit: 'vec-rvf-query' },
+ ],
+ sql: [{ field: 'sql', label: 'query', placeholder: 'SELECT … · MATCH (n) RETURN n · SELECT ?s WHERE { ?s ?p ?o }', submit: 'vec-sql' }],
+ decompile: [{ field: 'target', label: 'target', placeholder: './dist/index.js (a file here) · [email protected] (an npm package)', submit: 'vec-decompile' }],
+ workers: [{ field: 'worker', label: 'ask', placeholder: 'what a background worker should analyse', submit: 'vec-workers-dispatch' }],
+ hooks: [{ field: 'task', label: 'task', placeholder: 'a task to route · words to recall · a note to remember', submit: 'vec-hooks-route' }],
+}
+
+const RVLITE: Record<string, 'sql' | 'cypher' | 'sparql'> = { 'vec-sql': 'sql', 'vec-cypher': 'cypher', 'vec-sparql': 'sparql' }
+
+/** The text an entry takes: its field's, and for RVF the store followed by the second field. */
+function textFor(ctx: Ctx, entry: VecEntry): string {
+ const fields = ctx.state.vector
+
+ if (entry.field === undefined) return ''
+
+ return entry.field === 'rvfPath' ? `${fields.rvfPath.trim()} ${fields.rvfArg.trim()}`.trim() : fields[entry.field]
+}
+
+/** Enter in a field: the section's first entry, with decompile picking file or package as ruvector reads the target. */
+function submit(ctx: Ctx, id: string, field: VectorField, value: string): void {
+ ctx.act.vector.draft(field, value)
+
+ if (id in RVLITE) ctx.act.vector.ask(RVLITE[id] as 'sql', value)
+ else if (id === 'vec-decompile') ctx.act.vector.run(targetOf(value)?.kind === 'npm' ? 'vec-decompile-pkg' : 'vec-decompile-file', value)
+ else ctx.act.vector.run(id, field === 'rvfArg' ? `${ctx.state.vector.rvfPath.trim()} ${value.trim()}` : field === 'rvfPath' ? `${value.trim()} ${ctx.state.vector.rvfArg.trim()}`.trim() : value)
+}
+
+/** One entry, dotted to its purpose like the MetaHarness lab: the tag, the name, what it does, and its button. */
+function entryRow(ctx: Ctx, entry: VecEntry, lead: number): RenderElement {
+ const tag = TAG[entry.cost]
+ const kind = RVLITE[entry.id]
+ const isNa = entry.na !== undefined && kind === undefined
+ const isBlocked = !isNa && kind === undefined && entry.field === undefined && vecSpec(entry, ctx.state) === null
+ const action = kind !== undefined ? ' â–¸ ask' : isNa ? ' n/a' : entry.cost === 'read' ? ' â–¸ run' : ' â–¸ asks'
+
+ return row(
+ ctx,
+ [
+ ctx.kit.Text({ bold: true, color: isNa ? THEME.info : tag.color(), dimColor: isNa, children: ` ${isNa ? ' -- ' : tag.text}` }),
+ ctx.kit.Text({ bold: true, color: entry.cost === 'deletes' || entry.cost === 'publish' || entry.cost === 'spends' ? THEME.warn : THEME.head, dimColor: isNa, children: ` ${entry.name} `.padEnd(lead, '.') }),
+ ctx.kit.Text({ color: THEME.info, dimColor: isNa || isBlocked, wrap: 'truncate-end', children: clip(` ${isNa ? (entry.na ?? '') : entry.about}`, Math.max(4, ctx.columns - lead - 16)) }),
+ isNa
+ ? ctx.kit.Text({ dimColor: true, children: action })
+ : ctx.kit.Button({ key: entry.id, label: action, plain: true, dimColor: true, onPress: kind !== undefined ? () => ctx.act.vector.ask(kind, ctx.state.vector.sql) : () => ctx.act.vector.run(entry.id, textFor(ctx, entry)) }),
+ ],
+ `vec-row-${entry.id}`,
+ )
+}
+
+function fieldRows(ctx: Ctx, section: VecSection): RenderElement[] {
+ const fields = FIELDS[section] ?? []
+ const Input = ctx.kit.Input
+
+ if (fields.length === 0) return []
+ if (Input === undefined) return [text(ctx, ' this surface has no text field: /ruflo run <vec-id> <text> takes the text instead', { dimColor: true })]
+
+ return fields.map(({ field, label, placeholder, submit: id }) =>
+ Input({
+ key: `vec-in-${field}`,
+ label,
+ placeholder,
+ value: ctx.state.vector[field],
+ submitLabel: 'go',
+ onInput: value => ctx.act.vector.draft(field, value),
+ onSubmit: value => submit(ctx, id, field, value),
+ }),
+ )
+}
+
+/** The last vec- run: what it was, how it exited, its note, and a window of its lines. A MetaHarness run is not shown here. */
+function resultRows(ctx: Ctx): RenderElement[] {
+ const { state, nowMs } = ctx
+ const running = state.lab.running?.id.startsWith('vec-') === true ? state.lab.running : null
+ const result = state.lab.result?.id.startsWith('vec-') === true ? state.lab.result : null
+ const right = running !== null ? `running ${Math.round((nowMs - running.startedAtMs) / 1000)}s` : result === null ? 'nothing run yet' : `${result.ok ? '✓' : '✗'} exit ${result.exitCode ?? 'n/a'} · ${ago(result.atMs, nowMs)}`
+ const rows: RenderElement[] = [rule(ctx, 'Result', right)]
+
+ if (running !== null) rows.push(text(ctx, ` ▸ ${running.label} … ${Math.floor(nowMs / 500) % 2 === 0 ? '█' : ' '}`, { color: THEME.warn }))
+
+ if (result === null) {
+ if (running === null) rows.push(text(ctx, ' â–¸ run shows a local read here at once; â–¸ asks shows the exact command first (y runs it, n cancels)', { dimColor: true }))
+
+ return rows
+ }
+
+ rows.push(text(ctx, ` ${result.label}`, { bold: true, color: result.ok ? THEME.ok : THEME.bad }))
+ if (result.note !== undefined) rows.push(text(ctx, ` ${result.note}`, { color: THEME.warn }))
+
+ const top = Math.max(0, Math.min(state.select.item, result.lines.length - VEC_ROWS))
+
+ for (const line of result.lines.slice(top, top + VEC_ROWS)) rows.push(text(ctx, ` ${line}`))
+
+ if (result.lines.length > VEC_ROWS) {
+ rows.push(
+ row(ctx, [
+ text(ctx, ` lines ${top + 1}-${Math.min(result.lines.length, top + VEC_ROWS)} of ${result.lines.length} `, { dimColor: true }),
+ button(ctx, 'vec-up', 'up', () => ctx.act.select(-1), { hotkey: 'k' }),
+ button(ctx, 'vec-down', 'down', () => ctx.act.select(1), { hotkey: 'j' }),
+ ]),
+ )
+ }
+
+ return rows
+}
+
+/**
+ * The Vector Lab: the ruvector CLI by section, each entry tagged by what it costs. The newest result sits on top so a
+ * run's output is in view without scrolling; below it each section's field, then its entries.
+ */
+export function vectorView(ctx: Ctx): RenderElement {
+ const lead = Math.max(13, Math.min(16, ctx.columns - 44))
+ const rows: RenderElement[] = [
+ ...resultRows(ctx),
+ text(ctx, ' $0 local read, runs at once · wr writes here · net asks a remote host · pub publishes · $$ may spend · del cannot be undone: all but $0 ask first', { dimColor: true }),
+ ]
+
+ for (const section of VEC_SECTIONS) {
+ rows.push(rule(ctx, section.title, section.right))
+ rows.push(...fieldRows(ctx, section.id))
+
+ for (const entry of VEC.filter(candidate => candidate.section === section.id)) rows.push(entryRow(ctx, entry, lead))
+ }
+
+ return ctx.kit.Box({ flexDirection: 'column', key: 'vector', children: rows })
+}
diff --git a/plugins/ruflo-console/tests/fixtures/vector.ts b/plugins/ruflo-console/tests/fixtures/vector.ts
new file mode 100644
index 0000000000..b8f4708a60
--- /dev/null
+++ b/plugins/ruflo-console/tests/fixtures/vector.ts
@@ -0,0 +1,16 @@
+/**
+ * What ruvector 0.3.3 prints under a pipe, captured from runs in a throwaway directory (the hooks and rvf text keep the
+ * CLI's colour codes). The identity outputs carry a made-up key: no real key is in this repository.
+ */
+export const FAKE_KEY = 'a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90'
+export const FAKE_PSEUDONYM = '0f1e2d3c4b5a69788796a5b4c3d2e1f0'
+
+export const VEC_OUT = {
+ hooksStats: '\u001b[1m\u001b[36m\u001b[39m\u001b[22m\n\u001b[1m\u001b[36m🧠 RuVector Intelligence Stats\u001b[39m\u001b[22m\n\u001b[1m\u001b[36m\u001b[39m\u001b[22m\n \u001b[32m2\u001b[39m Q-learning patterns\n \u001b[32m2\u001b[39m vector memories\n \u001b[32m3\u001b[39m learning trajectories\n \u001b[32m0\u001b[39m error patterns\n\n\u001b[1mSwarm Status:\u001b[22m\n \u001b[36m0\u001b[39m agents registered\n \u001b[36m0\u001b[39m coordination edges\n',
+ route: '{\n "task": "write tests for login",\n "recommended": "coder",\n "confidence": 0,\n "reasoning": "default for unknown files"\n}\n',
+ rvfStatus: '\u001b[36mRVF Store Status\u001b[39m\n\u001b[2m totalVectors: 2\u001b[22m\n\u001b[2m totalSegments: 2\u001b[22m\n\u001b[2m epoch: 0\u001b[22m\n\u001b[2m compactionState: idle\u001b[22m\n',
+ identityShow: JSON.stringify({ pseudonym: FAKE_PSEUDONYM, key_preview: `${FAKE_KEY.slice(0, 8)}...${FAKE_KEY.slice(-8)}`, source: '~/.ruvector/pi-key' }, null, 2),
+ identityNone: 'No pi key found. Set PI env var or run: ruvector identity generate --save\n',
+ generated: `${JSON.stringify({ key: FAKE_KEY, pseudonym: FAKE_PSEUDONYM }, null, 2)}\n Key saved to /home/dev/.ruvector/pi-key\n`,
+ brainMissing: 'Brain commands require @ruvector/pi-brain\n npm install @ruvector/pi-brain\n',
+} as const
diff --git a/plugins/ruflo-console/tests/vector.spec.ts b/plugins/ruflo-console/tests/vector.spec.ts
new file mode 100644
index 0000000000..1e02ae0fc8
--- /dev/null
+++ b/plugins/ruflo-console/tests/vector.spec.ts
@@ -0,0 +1,206 @@
+/**
+ * The Vector Lab's pure parts under vitest: what each typed value must look like, the fixed ruvector argv each entry
+ * builds, what asks first and says why, the readers, and that no key material ever reaches a line. Nothing here runs
+ * the ruvector CLI. Run with
+ * npx vitest run plugins/ruflo-console/tests/vector.spec.ts
+ */
+import { describe, expect, it } from 'vitest'
+
+import { dimensionOf, generatedLines, isKeyless, redact, relPathOf, RV, shareOf, targetOf, textOf, vecIdOf, vectorOf } from '../hooks/data/vector'
+import { filterPalette, paletteEntries } from '../hooks/palette'
+import { newState } from '../hooks/state'
+import { rvlitePrompt, VEC, vecArgs, vecEntry, vecLines, vecSpec, vecWhy } from '../hooks/vector'
+import { FAKE_KEY, FAKE_PSEUDONYM, VEC_OUT } from './fixtures/vector'
+
+/** One text each typed entry accepts, tried in turn. */
+const SAMPLES = ['store.rvf 0.1,0.2', 'store.rvf', 'store.rvf a/v.json', 'a.rvf b.rvf', 'mem-1', 'a b', './a.js', 'lodash', 't :: c']
+
+const entry = (id: string) => {
+ const found = vecEntry(id)
+
+ if (found === undefined) throw new Error(`no entry ${id}`)
+
+ return found
+}
+
+describe('typed values', () => {
+ it('free text: trimmed; empty, too long, a leading -, or a control character is refused', () => {
+ expect(textOf(' write the login tests ')).toBe('write the login tests')
+ expect(textOf('what is HNSW? (ef=200)')).toBe('what is HNSW? (ef=200)')
+ expect(textOf('')).toBeNull()
+ expect(textOf('-k 9')).toBeNull()
+ expect(textOf('--help')).toBeNull()
+ expect(textOf('a\u0007b')).toBeNull()
+ expect(textOf('x'.repeat(201))).toBeNull()
+ expect(textOf('a;b`c')).toBeNull()
+ })
+
+ it('paths stay inside the project: relative, no .., no leading / or -, the kind asked for', () => {
+ expect(relPathOf('./data/store.rvf', '.rvf')).toBe('data/store.rvf')
+ expect(relPathOf('store.rvf', '.rvf')).toBe('store.rvf')
+ expect(relPathOf('../store.rvf', '.rvf')).toBeNull()
+ expect(relPathOf('a/../../b.rvf', '.rvf')).toBeNull()
+ expect(relPathOf('/etc/x.rvf', '.rvf')).toBeNull()
+ expect(relPathOf('-x.rvf', '.rvf')).toBeNull()
+ expect(relPathOf('store.json', '.rvf')).toBeNull()
+ expect(relPathOf('a b.rvf', '.rvf')).toBeNull()
+ expect(relPathOf('a//b.rvf', '.rvf')).toBeNull()
+ })
+
+ it('vectors, dimensions, ids and share text', () => {
+ expect(vectorOf('[0.1, -0.5, 2e-3]')).toBe('0.1,-0.5,2e-3')
+ expect(vectorOf('1,,2')).toBeNull()
+ expect(vectorOf('1,x')).toBeNull()
+ expect(vectorOf('')).toBeNull()
+ expect(dimensionOf('')).toBe('384')
+ expect(dimensionOf('3')).toBe('3')
+ expect(dimensionOf('0')).toBeNull()
+ expect(dimensionOf('5000')).toBeNull()
+ expect(vecIdOf('mem-01HXYZ')).toBe('mem-01HXYZ')
+ expect(vecIdOf('-rf')).toBeNull()
+ expect(shareOf('HNSW tip :: raise ef_search for recall')).toEqual({ title: 'HNSW tip', content: 'raise ef_search for recall' })
+ expect(shareOf('no separator')).toBeNull()
+ expect(shareOf(' :: body')).toBeNull()
+ })
+
+ it('decompile targets: ./file is local, an npm name goes to the registry, a URL is refused', () => {
+ expect(targetOf('./dist/index.js')).toEqual({ kind: 'file', arg: './dist/index.js' })
+ expect(targetOf('dist/index.mjs')).toEqual({ kind: 'file', arg: './dist/index.mjs' })
+ expect(targetOf('[email protected]')).toEqual({ kind: 'npm', arg: '[email protected]' })
+ expect(targetOf('@ruvector/core')).toEqual({ kind: 'npm', arg: '@ruvector/core' })
+ expect(targetOf('https://unpkg.com/x')).toBeNull()
+ expect(targetOf('../secret.js')).toBeNull()
+ expect(targetOf('-o /tmp')).toBeNull()
+ expect(targetOf('/etc/passwd.js')).toBeNull()
+ })
+})
+
+describe('the catalog', () => {
+ it('every id is vec- and unique; every argv is the pinned offline ruvector, with no shell and no browser', () => {
+ const state = newState({})
+ const ids = VEC.map(one => one.id)
+
+ expect(new Set(ids).size).toBe(ids.length)
+ expect(ids.every(id => id.startsWith('vec-'))).toBe(true)
+ expect(RV).toEqual(['npx', '--offline', '-y', '[email protected]'])
+
+ for (const one of VEC) {
+ const spec = vecSpec(one, state, 'x')
+
+ if (spec === null) continue
+ expect(spec.argv?.slice(0, 4), one.id).toEqual([...RV])
+ expect(spec.shows, one.id).toBe(spec.argv?.join(' '))
+ expect(spec.argv?.some(word => /^(sh|bash|xdg-open)$/.test(word) || word === 'dashboard'), one.id).toBe(false)
+ expect(spec.lab).toBe(one.id)
+ }
+ })
+
+ it('only local reads run at once; everything else asks with a note; network, publish, spend and delete say so', () => {
+ const state = newState({})
+
+ for (const one of VEC.filter(candidate => candidate.na === undefined && candidate.gate === undefined)) {
+ const spec = SAMPLES.map(sample => vecSpec(one, state, sample)).find(found => found !== null) ?? null
+
+ expect(spec, one.id).not.toBeNull()
+ expect(spec?.isReadOnly === true, one.id).toBe(one.cost === 'read')
+ if (one.cost !== 'read') expect(spec?.note, one.id).toBeDefined()
+ if (one.cost === 'net') expect(spec?.note, one.id).toMatch(/reaches/)
+ if (one.cost === 'publish') expect(spec?.note, one.id).toMatch(/PUBLISHES/)
+ if (one.cost === 'spends') expect(spec?.note, one.id).toMatch(/MAY COST MONEY/)
+ if (one.cost === 'deletes') expect(spec?.note, one.id).toMatch(/cannot be undone/)
+ }
+
+ // Every brain verb reaches pi.ruv.io, so not one of them runs unasked.
+ expect(VEC.filter(one => one.section === 'brain').every(one => one.cost !== 'read')).toBe(true)
+ })
+
+ it('builds the argv each verb takes; typed text is one element after --, never a flag', () => {
+ expect(vecArgs(entry('vec-brain-search'), 'vector db')).toEqual(['brain', 'search', 'vector db', '--limit', '10'])
+ expect(vecArgs(entry('vec-brain-vote-down'), 'mem-1')).toEqual(['brain', 'vote', 'mem-1', 'down'])
+ expect(vecArgs(entry('vec-brain-share'), 'HNSW tip :: raise ef')).toEqual(['brain', 'share', 'HNSW tip', '--category', 'pattern', '--content', 'raise ef'])
+ expect(vecArgs(entry('vec-brain-transfer'), 'rust python')).toEqual(['brain', 'transfer', 'rust', 'python'])
+ expect(vecArgs(entry('vec-brain-drift'), '')).toEqual(['brain', 'drift'])
+ expect(vecArgs(entry('vec-rvf-query'), 'store.rvf -0.5,0.1,0.9')).toEqual(['rvf', 'query', 'store.rvf', '--vector=-0.5,0.1,0.9', '--k', '10'])
+ expect(vecArgs(entry('vec-rvf-create'), 'new.rvf')).toEqual(['rvf', 'create', 'new.rvf', '--dimension', '384', '--metric', 'cosine'])
+ expect(vecArgs(entry('vec-rvf-ingest'), 'new.rvf data/v.json')).toEqual(['rvf', 'ingest', 'new.rvf', '--input', 'data/v.json'])
+ expect(vecArgs(entry('vec-rvf-derive'), 'a.rvf b.rvf')).toEqual(['rvf', 'derive', 'a.rvf', 'b.rvf'])
+ expect(vecArgs(entry('vec-decompile-file'), './dist/x.js')).toEqual(['decompile', './dist/x.js', '--json'])
+ expect(vecArgs(entry('vec-decompile-file'), 'lodash')).toBeNull()
+ expect(vecArgs(entry('vec-decompile-pkg'), './dist/x.js')).toBeNull()
+ expect(vecArgs(entry('vec-hooks-route'), 'fix the login bug')).toEqual(['hooks', 'route', '--', 'fix the login bug'])
+ expect(vecArgs(entry('vec-hooks-remember'), '-rf')).toBeNull()
+ expect(vecArgs(entry('vec-workers-dispatch'), 'scan auth')).toEqual(['workers', 'dispatch', '--', 'scan auth'])
+ expect(vecArgs(entry('vec-rvf-status'), '../x.rvf')).toBeNull()
+ expect(vecWhy(entry('vec-rvf-status'), newState({}))).toMatch(/project-relative \.rvf path/)
+ })
+
+ it('MCP-only tools and the browser are n/a with the reason, never an argv', () => {
+ const state = newState({})
+
+ for (const id of ['vec-rvf-delete', 'vec-sql', 'vec-cypher', 'vec-sparql', 'vec-decompile-witness', 'vec-edge-dashboard']) {
+ expect(vecSpec(entry(id), state, 'x'), id).toBeNull()
+ expect(vecWhy(entry(id), state), id).toMatch(/^n\/a/)
+ }
+
+ expect(rvlitePrompt('sql', 'SELECT * FROM vectors')).toMatch(/rvlite_sql .*\(read-only\): SELECT \* FROM vectors$/)
+ expect(rvlitePrompt('cypher', 'MATCH (n) DETACH DELETE n')).toMatch(/CHANGES the database/)
+ expect(rvlitePrompt('sparql', '')).toBeNull()
+ })
+
+ it('identity generate waits until show has found no key, so --save cannot overwrite one', () => {
+ const generate = entry('vec-identity-generate')
+ const state = newState({})
+
+ expect(vecSpec(generate, state)).toBeNull()
+ expect(vecWhy(generate, state)).toMatch(/overwrites ~\/\.ruvector\/pi-key/)
+
+ state.lab.result = { id: 'vec-identity-show', label: 'show', ok: true, exitCode: 0, lines: ['pseudonym x'], atMs: 1 }
+ expect(vecSpec(generate, state)).toBeNull()
+
+ state.lab.result = { id: 'vec-identity-show', label: 'show', ok: false, exitCode: 1, lines: vecLines('vec-identity-show', '', VEC_OUT.identityNone), atMs: 1 }
+ expect(isKeyless(state.lab.result.lines)).toBe(true)
+ expect(vecSpec(generate, state)?.argv).toEqual([...RV, 'identity', 'generate', '--save', '--json'])
+ expect(vecSpec(generate, state)?.isReadOnly).toBeUndefined()
+ })
+})
+
+describe('readers', () => {
+ it('no key material reaches a line: not the key, not its preview, not an export hint', () => {
+ const show = vecLines('vec-identity-show', VEC_OUT.identityShow, '')
+ const made = generatedLines(VEC_OUT.generated)
+ const all = [...show, ...made].join('\n')
+
+ expect(show).toEqual([`pseudonym: ${FAKE_PSEUDONYM}`, 'source: ~/.ruvector/pi-key'])
+ expect(made).toEqual([`pseudonym ${FAKE_PSEUDONYM}`, 'key saved to /home/dev/.ruvector/pi-key (not shown: it is the secret)'])
+ expect(all).not.toContain(FAKE_KEY)
+ expect(all).not.toContain(FAKE_KEY.slice(0, 8))
+ expect(redact([`token ${FAKE_KEY}`, `export PI=${FAKE_KEY}`])).toEqual(['token ‹redacted›'])
+ // The generic reader would print `key: <hex>`; the spec for generate uses its own reader.
+ expect(vecSpec(entry('vec-identity-generate'), Object.assign(newState({}), { lab: { result: { id: 'vec-identity-show', label: '', ok: false, exitCode: 1, lines: ['No pi key found'], atMs: 1 }, running: null } }))?.lines?.(VEC_OUT.generated, '').join('\n')).not.toContain(FAKE_KEY)
+ })
+
+ it('text output loses its colour; JSON is read as fields; a missing add-on reads as the CLI says', () => {
+ expect(vecLines('vec-hooks-stats', VEC_OUT.hooksStats, '')).toContain('2 Q-learning patterns')
+ expect(vecLines('vec-hooks-stats', VEC_OUT.hooksStats, '').some(line => line.includes('\u001b'))).toBe(false)
+ expect(vecLines('vec-hooks-route', VEC_OUT.route, '')).toEqual(['task: write tests for login', 'recommended: coder', 'confidence: 0', 'reasoning: default for unknown files'])
+ expect(vecLines('vec-rvf-status', VEC_OUT.rvfStatus, '')).toContain('totalVectors: 2')
+ expect(vecLines('vec-brain-status', '', VEC_OUT.brainMissing)[0]).toBe('Brain commands require @ruvector/pi-brain')
+ })
+})
+
+describe('the palette', () => {
+ it('every entry is a vec- palette id; typed ones take their text after the id', () => {
+ const state = newState({})
+ const entries = paletteEntries(state, 0)
+ const ids = entries.map(one => one.id)
+
+ expect(ids).toEqual(expect.arrayContaining(VEC.map(one => one.id)))
+
+ const search = entries.find(one => one.id === 'vec-brain-search')
+
+ expect(search?.run.kind).toBe('text')
+ expect(search?.run.kind === 'text' ? search.run.make('hnsw recall')?.argv : null).toEqual([...RV, 'brain', 'search', 'hnsw recall', '--limit', '10'])
+ // The shared keywords still win their own text: a vector entry never takes route's words.
+ expect(filterPalette(entries, 'route fix the login bug', 'all').map(one => one.id)).toEqual(['route'])
+ })
+})
diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts
index 39a1187e2b..7ba318a973 100644
--- a/plugins/ruflo-console/tests/views.test.ts
+++ b/plugins/ruflo-console/tests/views.test.ts
@@ -5,6 +5,7 @@ import { HIVE_FILES, RAFT_ID, WORKERS } from './fixtures/hive'
import { MISSION_OBSERVATION } from './fixtures/missions'
import { HIVE_TOKEN, RUFLO_FILES } from './fixtures/ruflo-run'
import { FIND_OUT, LS_GLOBAL } from './fixtures/skills'
+import { VEC_OUT } from './fixtures/vector'
import { cliAnswer, command, elementsOf, fakeRuflo, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'
const HOME_FILES = {
@@ -345,6 +346,85 @@ describe('views', () => {
await pane.unmount()
})
+ test('vector lab: every section, its fields and tagged entries; opening it runs no ruvector command', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ const vecRuns = () => world.runs.filter(argv => argv[3] === '[email protected]')
+
+ world.respond = argv => (argv[3] !== '[email protected]' ? cliAnswer(argv) : { exitCode: 0, stdout: '{"success": true}', stderr: '' })
+ mock.clock(on)
+ await $.session.start(SESSION)
+
+ const { text, tree } = await drawn($, 'vector')
+
+ for (const title of ['RESULT', 'BRAIN', 'RVF CONTAINERS', 'SQL / GRAPH', 'DECOMPILE', 'WORKERS', 'EDGE', 'HOOKS INTEL', 'IDENTITY']) expect(text).toContain(`â–“â–’â–‘ ${title} â–‘â–’â–“`)
+ expect(text).toContain('nothing run yet')
+ expect(text).toMatch(/pub \n SHARE \.+/)
+ expect(text).toMatch(/del \n DELETE \.+/)
+ expect(text).toContain('rvf_delete is an MCP tool of the ruvector server with no CLI verb')
+ expect(elementsOf(tree, 'Input').map(keyOf)).toEqual(['vec-in-brain', 'vec-in-rvfPath', 'vec-in-rvfArg', 'vec-in-sql', 'vec-in-target', 'vec-in-worker', 'vec-in-task'])
+ expect(elementsOf(tree, 'Button').map(keyOf)).toEqual(expect.arrayContaining(['vec-brain-status', 'vec-brain-share', 'vec-rvf-query', 'vec-sql', 'vec-hooks-stats', 'vec-identity-generate']))
+ expect(elementsOf(tree, 'Button').map(keyOf)).not.toContain('vec-rvf-delete')
+ expect(vecRuns()).toHaveLength(0)
+ })
+
+ test('vector lab: a local read runs one fixed argv at once and shows its lines; the shared brain asks first', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ const vecRuns = () => world.runs.filter(argv => argv[3] === '[email protected]').map(argv => argv.slice(4).join(' '))
+
+ world.respond = argv => (argv[3] !== '[email protected]' ? cliAnswer(argv) : argv[4] === 'hooks' && argv[5] === 'stats' ? { exitCode: 0, stdout: VEC_OUT.hooksStats, stderr: '' } : argv[4] === 'hooks' ? { exitCode: 0, stdout: VEC_OUT.route, stderr: '' } : { exitCode: 0, stdout: '{"total_memories": 12}', stderr: '' })
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('vector'))
+
+ const pane = await $.ui.mount({ ...paneAt(110), surface: 'terminal' as const, plugin: PLUGIN })
+
+ await pane.press({ key: 'vec-hooks-stats' })
+ expect(textOf(await pane.drawn())).toContain('2 Q-learning patterns')
+ expect(world.runs.filter(argv => argv[3] === '[email protected]')).toEqual([['npx', '--offline', '-y', '[email protected]', 'hooks', 'stats']])
+
+ await pane.input({ key: 'vec-in-task', text: 'write the login tests', kind: 'submit' })
+ expect(textOf(await pane.drawn())).toContain('recommended: coder')
+ expect(vecRuns()).toEqual(['hooks stats', 'hooks route -- write the login tests'])
+
+ await pane.press({ key: 'vec-brain-status' })
+
+ const asked = textOf(await pane.drawn())
+
+ expect(asked).toContain('runs: npx --offline -y [email protected] brain status')
+ expect(asked).toContain('reaches pi.ruv.io')
+ expect(vecRuns()).toHaveLength(2)
+
+ await pane.press({ key: 'confirm' })
+ expect(textOf(await pane.drawn())).toContain('total_memories: 12')
+ expect(vecRuns()).toEqual(['hooks stats', 'hooks route -- write the login tests', 'brain status'])
+
+ // Generate waits for a show that found no key: nothing is asked, nothing runs.
+ await pane.press({ key: 'vec-identity-generate' })
+ expect(textOf(await pane.drawn())).toContain('run â–¸ SHOW first')
+ expect(vecRuns()).toHaveLength(3)
+ await pane.unmount()
+ })
+
+ test('vector lab headless: /ruflo run vec-<id> <text> answers with the lines; a network one asks and runs on yes', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ const vecRuns = () => world.runs.filter(argv => argv[3] === '[email protected]').map(argv => argv.slice(4).join(' '))
+
+ world.respond = argv => (argv[3] !== '[email protected]' ? cliAnswer(argv) : argv[4] === 'hooks' ? { exitCode: 0, stdout: VEC_OUT.route, stderr: '' } : { exitCode: 1, stdout: '', stderr: VEC_OUT.brainMissing })
+ mock.clock(on)
+ await $.session.start({ ...SESSION, isInteractive: false })
+
+ const routed = (await $.command.run(command('run vec-hooks-route Fix the login bug'))).text ?? ''
+
+ expect(routed).toMatch(/^✓ hooks route: an agent for the task · exit 0\n/)
+ expect(routed).toContain(' recommended: coder')
+ expect(vecRuns()).toEqual(['hooks route -- Fix the login bug'])
+ expect((await $.command.run(command('run vec-brain-search hnsw recall'))).text).toBe('Asked: brain search: the field’s words. Confirm with /ruflo yes (or y in the pane), cancel with /ruflo no.')
+ expect(vecRuns()).toHaveLength(1)
+ expect((await $.command.run(command('yes'))).text).toContain('Brain commands require @ruvector/pi-brain')
+ expect(vecRuns()).toEqual(['hooks route -- Fix the login bug', 'brain search hnsw recall --limit 10'])
+ expect((await $.command.run(command('run vec-rvf-delete'))).text).toMatch(/^nothing to do: n\/a: rvf_delete is an MCP tool/)
+ })
+
test('main menu: bare /ruflo lands on it in the BBS look; its prompt takes a key or a name', { options: { boot: false } }, async ($, on) => {
worldOf(on, RUFLO_FILES)
mock.clock(on)