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(console): scripts/drive.sh drives the console from a headless Claude (0.33.9); isolated config

ruvdeaa2220e4be
diff --cc plugins/ruflo-console/.claude-plugin/plugin.json
index 4fae1545e6,f9ddfc3162..3215ed3bd0
--- a/plugins/ruflo-console/.claude-plugin/plugin.json
+++ b/plugins/ruflo-console/.claude-plugin/plugin.json
@@@ -1,7 -1,7 +1,7 @@@
{
"name": "ruflo-console",
"description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",
- "version": "0.33.1",
- "version": "0.33.8",
++ "version": "0.33.9",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --cc plugins/ruflo-console/README.md
index 849dd241ce,8d1829bbaf..50b3605bac
--- a/plugins/ruflo-console/README.md
+++ b/plugins/ruflo-console/README.md
@@@ -1,28 -1,13 +1,39 @@@
# ruflo-console
- ruflo's cockpit inside Claude Code and the one `/ruflo` command for every ruflo mod. See `.claude-plugin/plugin.json` for the full description.
+ ruflo's cockpit inside Claude Code: the `/ruflo` command, its pages, and a band above the prompt. It reads ruflo's own files; anything it cannot measure reads `n/a`. Design notes: ADR-407 (cockpit), ADR-448 (the Room), ADR-446 (plugin mods).
+## Drive the console from the command line
+
+`scripts/drive.sh` runs the console through its own model tools (`console_open`, `console_state`, `console_set`, `console_run`) from a real headless Claude, prints what each tool answered, and can assert on it, so a dev loop or CI job can check that a UI shows something.
+
+```bash
+RUFLO_E2E_LIVE=1 bash plugins/ruflo-console/scripts/drive.sh \
+ --expect 'Waiting for a yes' \
+ "$PWD/plugins/ruflo-console" read "Open the Room and quote back what is waiting for a yes."
+```
+
+Output is one `CALL <tool> <input>` and one `RESULT <tool> <text>` line per console call (each result cut at 4000 characters), then `COST <usd> CALLS <n>`, then one `EXPECT ok|FAIL /regex/` line per `--expect`.
+
+| Exit | Meaning |
+|------|---------|
+| 0 | a console call ran and every `--expect` matched (or the run was skipped, see below) |
+| 1 | no console tool call ran |
+| 2 | usage error: bad level or an invalid `--expect` regex |
+| 3 | at least one `--expect` regex (case-insensitive, repeatable) matched no `RESULT` |
+
+- **What it spends:** about $0.10 per run with haiku, hard-capped at $0.40 (`--max-budget-usd`). Use one to three runs, not a sweep.
++- **Isolated config:** the run uses a throwaway `CLAUDE_CONFIG_DIR` seeded with the level you ask for and confirm mode `auto` (your login is copied 0600 and shredded on exit), because `RUFLO_CONSOLE_CONTROL` can only lower the saved setting (ADR-450 T12) and your own saved mode would otherwise decide what a drive does.
+- **Why the level is capped:** the level is `read`, `write` or `manage`; `full` is rejected (exit 2). The run happens in a scratch project (`mktemp -d`), with Bash, Write and Edit disallowed, so a drive can never spend money or delete anything.
+- **Seeding:** `CONSOLE_DRIVE_SEED=<dir>` copies that directory into the scratch `.claude-flow/` first, for example a `claims/claims.json` to assert the claims view shows it.
+- **Skips cleanly:** without `RUFLO_E2E_LIVE=1` or a `claude` binary (on `PATH` or `$CLAUDE_BIN`) it prints `SKIP` and exits 0, so it is safe to call from CI.
+- **Extra plugins:** any further arguments are added as `--plugin-dir`.
++
+ ## Room and Mods
+
+ Open it with `/ruflo room` (menu: Safety → The Room).
+
+ - **Waiting for a yes**: the one confirm that is pending, with the seconds left to answer it.
+ - **The feed**: events, Claude's console actions and what you said, newest first. Filter by who, search, pause, page back. **â›” blocked** shows only what was refused or failed: Claude's actions the control log marked denied or error, and events that say denied. Press a line to open it; an event that came from a page of its own (swarm, claims, learning, plugins, missions) offers a jump button to that page.
+ - **Mods**: one line per plugin mod that has written `.claude-flow/<name>-mod/status.json`. Press a line for its detail: what it guards (the file's own `summary`), guard, calls, blocked, the *class* of its last refusal (`secret`, `destructive`, `path`, `network`, `policy`, `other`; the refused text is never kept), `modVersion`, session start, last write, file age, and a stale marker when the last write was an earlier session.
+
+ A status file is data, not instructions: it is size-capped, shape-checked (`version: 1` only), and every string is stripped of control and bidi characters and cut to length before it is drawn. `summary`, `modVersion` and `lastDenied` are optional; a mod that does not write them shows "not reported".
diff --cc plugins/ruflo-console/hooks/version.ts
index c282fe8640,8fbaa28ecc..dfb91bb3a2
--- a/plugins/ruflo-console/hooks/version.ts
+++ b/plugins/ruflo-console/hooks/version.ts
@@@ -2,4 -2,4 +2,4 @@@
* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest
* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.
*/
- export const CONSOLE_VERSION = '0.33.1'
-export const CONSOLE_VERSION = '0.33.8'
++export const CONSOLE_VERSION = '0.33.9'
diff --cc plugins/ruflo-console/scripts/drive.sh
index 5bbb6d9d5b,0000000000..ca95fa7d8a
mode 100755,000000..100755
--- a/plugins/ruflo-console/scripts/drive.sh
+++ b/plugins/ruflo-console/scripts/drive.sh
@@@ -1,60 -1,0 +1,70 @@@
+#!/usr/bin/env bash
+# Drive the console UI the way a person would, through its own model tools (ADR-444), from a headless Claude, and optionally assert
+# what the UI answered.
+#
+# RUFLO_E2E_LIVE=1 bash drive.sh [--expect REGEX]... <console-plugin-dir> <read|write|manage> "<what to do>" [extra plugin dirs...]
+#
+# Prints one CALL / RESULT line per console tool call (results cut at 4000 chars) and a final COST line.
+# Exit: 0 ok · 1 no console tool call ran · 2 usage error (bad level, bad regex) · 3 an --expect matched no RESULT.
+# Without RUFLO_E2E_LIVE=1 or a claude binary it prints SKIP and exits 0, so CI can call it everywhere. ~$0.10 per run (haiku, capped $0.40).
+# The level is capped at manage and the run happens in a scratch project, so a drive can never spend money or delete anything.
++# The saved control setting is seeded in an isolated, throwaway config dir (login copied 0600, shredded on exit), not taken from yours.
+# CONSOLE_DRIVE_SEED=<dir> copies that directory into the scratch .claude-flow before the run (seed claims, mods, ...).
+set -u
+EXPECT=(); POS=()
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --expect) [[ $# -ge 2 ]] || { echo "--expect needs a regex"; exit 2; }; EXPECT+=("$2"); shift 2 ;;
+ --expect=*) EXPECT+=("${1#--expect=}"); shift ;;
+ *) POS+=("$1"); shift ;;
+ esac
+done
+[[ ${#POS[@]} -ge 3 ]] || { echo "usage: drive.sh [--expect REGEX]... <console-plugin-dir> <read|write|manage> \"<what to do>\" [extra plugin dirs...]"; exit 2; }
+PLUG="${POS[0]}"; LEVEL="${POS[1]}"; ASK="${POS[2]}"; EXTRA_DIRS=("${POS[@]:3}")
+case "$LEVEL" in read|write|manage) ;; *) echo "level must be read|write|manage (full is never allowed here)"; exit 2 ;; esac
+for re in "${EXPECT[@]+"${EXPECT[@]}"}"; do
+ node -e 'new RegExp(process.argv[1], "i")' "$re" 2>/dev/null || { echo "bad --expect regex: $re"; exit 2; }
+done
+CLAUDE="${CLAUDE_BIN:-$(command -v claude || echo "$HOME/.local/bin/claude")}"
+if [[ "${RUFLO_E2E_LIVE:-0}" != 1 || ! -x "$CLAUDE" ]]; then
+ echo "SKIP drive: set RUFLO_E2E_LIVE=1 with a claude binary on PATH or at \$CLAUDE_BIN"
+ exit 0
+fi
+
+SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/console-drive.XXXXXX")"; mkdir -p "$SCRATCH/.claude-flow"
+[[ -n "${CONSOLE_DRIVE_SEED:-}" ]] && cp -r "$CONSOLE_DRIVE_SEED"/. "$SCRATCH/.claude-flow/" 2>/dev/null
+TOOLS="mcp__ruflo-console__console_state,mcp__ruflo-console__console_open,mcp__ruflo-console__console_set,mcp__ruflo-console__console_run"
+EXTRA=(); for d in "${EXTRA_DIRS[@]+"${EXTRA_DIRS[@]}"}"; do EXTRA+=(--plugin-dir "$d"); done
- OUT="$SCRATCH/out.jsonl"
- (cd "$SCRATCH" && RUFLO_CONSOLE_CONTROL="$LEVEL:auto" timeout 240 "$CLAUDE" -p "Use only the ruflo console tools (console_state, console_open, console_set, console_run). $ASK Report exactly what each tool answered." \
++OUTJ="$SCRATCH/out.jsonl"; OUT="$SCRATCH"; CLI=true
++# Control is seeded in an ISOLATED config dir (your login copied 0600, shredded on exit). RUFLO_CONSOLE_CONTROL may only LOWER the saved
++# setting (ADR-450 T12), so it cannot make a drive run with auto confirm when the person's saved mode is "ask": seed the saved setting instead.
++# shellcheck disable=SC1091
++source "$(dirname "${BASH_SOURCE[0]}")/e2e-lib.sh"
++make_config "$SCRATCH"
++trap 'shred_config 2>/dev/null; rm -rf "$CFG"' EXIT
++mkdir -p "$CFG/plugins/store"
++node -e 'require("node:fs").writeFileSync(process.argv[1], JSON.stringify({ "ai-prefs": { modelControl: process.argv[2], modelConfirm: "auto" } }))' \
++ "$CFG/plugins/store/ruflo-console_inline-b43d4e31bb1a.json" "$LEVEL"
++(cd "$SCRATCH" && CLAUDE_CONFIG_DIR="$CFG" timeout 240 "$CLAUDE" -p "Use only the ruflo console tools (console_state, console_open, console_set, console_run). $ASK Report exactly what each tool answered." \
+ --plugin-dir "$PLUG" "${EXTRA[@]+"${EXTRA[@]}"}" --allowedTools "$TOOLS" --disallowedTools Bash,Write,Edit,NotebookEdit --model haiku --max-budget-usd 0.40 \
- --output-format stream-json --verbose </dev/null >"$OUT" 2>"$SCRATCH/err.txt")
- node - "$OUT" "${EXPECT[@]+"${EXPECT[@]}"}" <<'NODE'
++ --output-format stream-json --verbose </dev/null >"$OUTJ" 2>"$SCRATCH/err.txt")
++node - "$OUTJ" "${EXPECT[@]+"${EXPECT[@]}"}" <<'NODE'
+const [file, ...expects] = process.argv.slice(2)
+const lines = require('node:fs').readFileSync(file, 'utf8').split('\n').filter(Boolean).flatMap(l => { try { return [JSON.parse(l)] } catch { return [] } })
+const names = new Map(); const results = []; let calls = 0
+for (const m of lines) for (const b of (m.message && Array.isArray(m.message.content) ? m.message.content : [])) {
+ if (b.type === 'tool_use' && b.name.startsWith('mcp__ruflo-console__')) { calls++; names.set(b.id, b.name.slice(20)); console.log(`CALL ${names.get(b.id)} ${JSON.stringify(b.input)}`) }
+ if (b.type === 'tool_result' && names.has(b.tool_use_id)) {
+ const text = (typeof b.content === 'string' ? b.content : JSON.stringify(b.content)).replace(/\n/g, ' ').slice(0, 4000)
+ results.push(text); console.log(`RESULT ${names.get(b.tool_use_id)} ${text}`)
+ }
+}
+const r = lines.find(m => m.type === 'result'); console.log(`COST ${r ? r.total_cost_usd : '?'} CALLS ${calls}`)
+if (calls === 0) process.exit(1)
+let missed = 0
+for (const e of expects) {
+ const hit = results.some(t => new RegExp(e, 'i').test(t)); console.log(`${hit ? 'EXPECT ok' : 'EXPECT FAIL'} /${e}/`); if (!hit) missed++
+}
+process.exit(missed ? 3 : 0)
+NODE
+rc=$?; echo "scratch: $SCRATCH"; exit $rc
diff --cc plugins/ruflo-console/scripts/smoke.sh
index 7785935490,e285911ba9..c51c37750a
--- a/plugins/ruflo-console/scripts/smoke.sh
+++ b/plugins/ruflo-console/scripts/smoke.sh
@@@ -11,9 -11,9 +11,9 @@@ step() { printf "→ %s ... " "$1";
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
- step "1. plugin.json declares ruflo-console 0.33.1"
-step "1. plugin.json declares ruflo-console 0.33.8"
++step "1. plugin.json declares ruflo-console 0.33.9"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
- && grep -q '"version": "0.33.8"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
++ && grep -q '"version": "0.33.9"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
step "2. hooks.json names exactly one module and no classic hook commands"
grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \