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): Dev Tools view for ruflo's integration surface

ruv8ca007ac416d
diff --git a/plugins/ruflo-console/hooks/actions.ts b/plugins/ruflo-console/hooks/actions.ts
index 5fb683024c..9fe7cb7b46 100644
--- a/plugins/ruflo-console/hooks/actions.ts
+++ b/plugins/ruflo-console/hooks/actions.ts
@@ -21,6 +21,8 @@ export type ActionSpec = {
lab?: string
/** What a run costs or writes, in words: the confirm row and the result panel show it. */
note?: string
+ /** How a lab-panel run reads what the CLI printed; the MetaHarness reader when unset. */
+ lines?: (stdout: string, stderr: string) => string[]
/** How long the CLI may take; 90 s when unset. */
timeoutMs?: number
}
diff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.ts
index a52ccfc673..de2842bb6a 100644
--- a/plugins/ruflo-console/hooks/bindings.ts
+++ b/plugins/ruflo-console/hooks/bindings.ts
@@ -4,6 +4,7 @@
*/
import { claimTask, handoffClaim, releaseClaim, stealClaim, whyNot } from './actions'
import { EVENT_KINDS } from './data/events'
+import { devtoolsActions } from './devtools'
import { HARNESSES, harnessSpec, isLive, newSession, send, whyNotRun } from './harness'
import { plain } from './data/parse'
import type { Host } from './host'
@@ -250,6 +251,7 @@ 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)),
+ devtools: devtoolsActions(state, host, runner.runById, why => runner.ask(null, why)),
}
return actions
diff --git a/plugins/ruflo-console/hooks/data/devtools.ts b/plugins/ruflo-console/hooks/data/devtools.ts
new file mode 100644
index 0000000000..b7b0313f47
--- /dev/null
+++ b/plugins/ruflo-console/hooks/data/devtools.ts
@@ -0,0 +1,151 @@
+/**
+ * The Dev Tools view's pure parts: the fields a person types into, each checked before it becomes an argv element,
+ * and the readers that turn what the ruflo CLI printed into lines worth reading. `mcp exec` wraps most tools' answers
+ * as `{"content":[{"type":"text","text":"<JSON>"}],"isError":…}`, so the readers unwrap that first.
+ */
+import { jsonAfter } from './cli'
+import { plain, recordOf } from './parse'
+import { labLines } from '../mh-lab'
+
+export type DevField = 'ref' | 'path' | 'label' | 'url' | 'target' | 'query' | 'task' | 'cmd' | 'id' | 'note'
+
+export type DevFields = Record<DevField, string>
+
+export const DEV_FIELDS: readonly DevField[] = ['ref', 'path', 'label', 'url', 'target', 'query', 'task', 'cmd', 'id', 'note']
+
+export const emptyFields = (): DevFields => ({ ref: 'HEAD', path: '', label: '', url: '', target: '', query: '', task: '', cmd: '', id: '', note: '' })
+
+const CONTROL = /[\u0000-\u001f\u007f]/
+
+/** Free text: trimmed, 1-`max` characters, no control characters, not starting with `-` (it could read as a flag). */
+function prose(text: string, max: number): string | null {
+ const value = text.trim()
+
+ return value === '' || value.length > max || value.startsWith('-') || CONTROL.test(value) ? null : value
+}
+
+/** A path under the project: relative, no `..` segment, no empty segment, a plain charset (the CLI resolves it). */
+function pathOf(text: string): string | null {
+ const value = text.trim()
+
+ if (!/^[A-Za-z0-9._][A-Za-z0-9._/-]{0,159}$/.test(value)) return null
+
+ return value.split('/').every(segment => segment !== '' && segment !== '..') ? value : null
+}
+
+function urlOf(text: string): string | null {
+ const value = text.trim()
+
+ if (!/^https?:\/\/[^\s"'<>`\\]{1,300}$/.test(value)) return null
+
+ try {
+ const url = new URL(value)
+
+ return url.protocol === 'http:' || url.protocol === 'https:' ? value : null
+ } catch {
+ return null
+ }
+}
+
+const RULES: Record<DevField, { test: (text: string) => string | null; rule: string }> = {
+ ref: { test: text => (/^[A-Za-z0-9@][A-Za-z0-9._/~^@{}-]{0,99}$/.test(text.trim()) ? text.trim() : null), rule: 'a git ref: HEAD, HEAD~3, main..HEAD, a branch or a sha (letters, digits . _ / ~ ^ @ { } -, not starting with -)' },
+ path: { test: pathOf, rule: 'a path under the project: relative, letters, digits . _ / -, no .. segment, at most 160' },
+ label: { test: text => (/^[A-Za-z0-9][A-Za-z0-9._-]{0,39}$/.test(text.trim()) ? text.trim() : null), rule: 'a label: letters, digits . _ -, at most 40, not starting with . or -' },
+ url: { test: urlOf, rule: 'an http(s) URL with no spaces or quotes, at most 300' },
+ target: { test: text => (/^@e\d{1,5}$/.test(text.trim()) ? text.trim() : null), rule: 'an element ref from a snapshot: @e1, @e12 …' },
+ query: { test: text => (/^[A-Za-z0-9@][A-Za-z0-9 ._@/-]{0,63}$/.test(text.trim()) ? text.trim() : null), rule: 'a search: 1-64 letters, digits, spaces, . _ @ / -, not starting with -' },
+ task: { test: text => prose(text, 200), rule: 'what you want to do, in words: 1-200 characters, no control characters, not starting with -' },
+ cmd: { test: text => prose(text, 200), rule: 'one command line: 1-200 characters, no newline or control character, not starting with -' },
+ id: { test: text => (/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(text.trim()) ? text.trim() : null), rule: 'an id: letters, digits _ . : -, at most 64, not starting with -' },
+ note: { test: text => prose(text, 200), rule: 'a note: 1-200 characters, no control characters, not starting with -' },
+}
+
+/** A field's text as it may enter an argv, or null when it breaks the field's rule. */
+export const fieldValue = (field: DevField, text: string): string | null => RULES[field].test(text)
+
+/** The rule a field's text must follow, in the footer's words. */
+export const fieldRule = (field: DevField): string => RULES[field].rule
+
+/** `ruflo mcp exec -t <tool> -p <json>`: one argv element of JSON, numbers and booleans kept as they are. */
+export const tool = (name: string, params: Record<string, unknown>): readonly string[] => ['mcp', 'exec', '-t', name, '-p', JSON.stringify(params)]
+
+/** The JSON a run printed, with `mcp exec`'s content wrapper taken off; `isError` when the tool said it failed. */
+export function unwrap(stdout: string): { value: unknown; isError: boolean } | null {
+ const json = jsonAfter(stdout)
+ const record = recordOf(json)
+
+ if (json === null) return null
+ if (record === null || !Array.isArray(record.content)) return { value: json, isError: record?.isError === true || record?.success === false }
+
+ const texts = record.content.map(recordOf).flatMap(part => (part !== null && typeof part.text === 'string' ? [part.text] : []))
+ const parsed = texts.map(text => {
+ try {
+ return JSON.parse(text) as unknown
+ } catch {
+ return text
+ }
+ })
+ const value = parsed.length === 1 ? parsed[0] : parsed
+ const inner = recordOf(value)
+
+ return { value, isError: record.isError === true || inner?.success === false || (inner !== null && typeof inner.error === 'string' && Object.keys(inner).length <= 2) }
+}
+
+const list = (value: unknown): string => (Array.isArray(value) ? value.map(item => plain(String(item), 40)).join(', ') : '')
+
+/** guidance_brain recommend: each matching domain with its tools and risk, then the loop's steps and their tools. */
+export function brainLines(value: unknown): string[] {
+ const record = recordOf(value)
+
+ if (record === null) return []
+
+ const out: string[] = []
+ const domains = (Array.isArray(record.domains) ? record.domains : []).map(recordOf)
+
+ if (typeof record.task === 'string') out.push(`for: ${plain(record.task, 140)}`)
+ if (domains.length === 0 && Array.isArray(record.domains)) out.push('no capability domain matched: try other words')
+
+ for (const domain of domains) {
+ if (domain === null) continue
+ out.push(`▸ ${plain(String(domain.name ?? domain.id ?? ''), 40)} · ${plain(String(domain.risk ?? 'n/a'), 20)} · ${plain(String(domain.authority ?? 'n/a'), 20)}`)
+ out.push(` tools: ${list(domain.registeredTools) || '(none registered)'}`)
+ }
+
+ const loop = (Array.isArray(record.implementationLoop) ? record.implementationLoop : []).map(recordOf)
+
+ if (loop.length > 0) out.push('then the loop:')
+
+ for (const step of loop) {
+ if (step === null) continue
+ out.push(` ${plain(String(step.name ?? step.id ?? ''), 14).padEnd(10)} ${list(step.preferredTools) || '—'}`)
+ }
+
+ for (const rule of (Array.isArray(record.guardrails) ? record.guardrails : []).slice(0, 4)) out.push(`! ${plain(String(rule), 150)}`)
+
+ return out
+}
+
+/** What a Dev Tools run printed, as clean lines: the wrapper unwrapped, the brain read for its picks, errors said first. */
+export function devLines(id: string, stdout: string, stderr = ''): string[] {
+ const answer = unwrap(stdout)
+
+ if (answer === null) return labLines(id, stdout, stderr)
+
+ const { value, isError } = answer
+ const record = recordOf(value)
+ const error = record !== null && typeof record.error === 'string' ? record.error : null
+
+ if (isError && error !== null) {
+ const rest = Object.fromEntries(Object.entries(record ?? {}).filter(([key]) => key !== 'error' && key !== 'success'))
+
+ return [`✗ ${plain(error, 200)}`, ...(Object.keys(rest).length > 0 ? labLines(id, JSON.stringify(rest), stderr) : [])].slice(0, 40)
+ }
+ if (typeof value === 'string') return labLines(id, value, stderr)
+
+ const brain = id.startsWith('dt-brain') ? brainLines(value) : []
+
+ return brain.length > 0 ? brain.slice(0, 40) : labLines(id, JSON.stringify(value), stderr)
+}
+
+/** True when what a run printed says the tool failed, though the CLI exited 0. */
+export const isToolError = (stdout: string): boolean => unwrap(stdout)?.isError === true
diff --git a/plugins/ruflo-console/hooks/devtools.ts b/plugins/ruflo-console/hooks/devtools.ts
new file mode 100644
index 0000000000..e12ac021ba
--- /dev/null
+++ b/plugins/ruflo-console/hooks/devtools.ts
@@ -0,0 +1,266 @@
+/**
+ * The Dev Tools view's catalog: ruflo's integration surface (GitHub, git diff analysis, agenticow, WASM agents, the
+ * browser, ruflo's terminal sessions, providers, the plugin registry, RuVLLM, DAA, the capability brain, managed agents
+ * and maintenance), each entry one fixed argv checked against the CLI source (commands/*.ts, mcp-tools/*.ts) and its
+ * --help. A local $0 read runs at once and fills the result panel; anything that writes, deletes, reaches the network
+ * or may spend asks first, and its confirm row says which. What a fixed argv cannot carry honestly is an n/a row with
+ * its reason, never a button that can only fail. Pure: entries, specs and closures; nothing here touches `$`.
+ */
+import type { ActionSpec } from './actions'
+import { devLines, fieldRule, fieldValue, tool, type DevField, type DevFields } from './data/devtools'
+import type { Host } from './host'
+import type { PaletteEntry } from './palette'
+import type { State } from './state'
+
+/** `read`: local, $0, changes nothing. `local`: local compute that keeps nothing. Then writes, the network, money, deletes. */
+export type DevCost = 'read' | 'local' | 'writes' | 'network' | 'spends' | 'deletes'
+
+export type DevGroup = 'github' | 'analyze' | 'cow' | 'wasm' | 'browser' | 'terminal' | 'providers' | 'plugins' | 'ruvllm' | 'daa' | 'brain' | 'managed' | 'maint'
+
+export type DevEntry = {
+ id: string
+ group: DevGroup
+ /** The row's name, and what the row says it does. */
+ name: string
+ about: string
+ /** The palette's line and the confirm row's question. */
+ label: string
+ cost: DevCost
+ /** The field this entry reads first: headless `/ruflo run <id> <text>` fills it. */
+ input?: DevField
+ /** The argv after the CLI prefix, from the fields; null when a field breaks its rule. */
+ args?: (fields: DevFields) => readonly string[] | null
+ /** Not runnable from the console: the reason the row shows instead of a button. */
+ na?: string
+ note?: string
+ timeoutMs?: number
+}
+
+export const DEV_GROUPS: readonly { id: DevGroup; title: string; right: string }[] = [
+ { id: 'brain', title: 'Capability brain', right: 'guidance_brain · local · $0' },
+ { id: 'analyze', title: 'Analyze · git diff', right: 'local · $0 · runs at once' },
+ { id: 'github', title: 'GitHub & delivery', right: 'gh + GitHub API · asks first' },
+ { id: 'cow', title: 'Agenticow · copy-on-write memory', right: 'an .rvf file · writes ask' },
+ { id: 'wasm', title: 'WASM agents', right: 'sandboxed · gallery' },
+ { id: 'browser', title: 'Browser', right: 'agent-browser session ruflo-console' },
+ { id: 'terminal', title: 'Terminal sessions', right: 'ruflo terminal_* · a command asks' },
+ { id: 'providers', title: 'Providers', right: 'keys are never shown or passed' },
+ { id: 'plugins', title: 'Plugin registry', right: 'local list · IPFS asks' },
+ { id: 'ruvllm', title: 'RuVLLM', right: 'status · creates ask' },
+ { id: 'daa', title: 'DAA · dynamic agents', right: '.claude-flow/daa · writes ask' },
+ { id: 'managed', title: 'Managed agents', right: 'Anthropic cloud · every call asks' },
+ { id: 'maint', title: 'Maintenance', right: 'cleanup · update · migrate · process · appliance' },
+]
+
+const SESSION = 'ruflo-console'
+const SHOT = 'ruflo-console-screenshot.png'
+
+/** A field's checked value, or null; `need` builds the argv only when every named field passes. */
+const need = (fields: DevFields, names: readonly DevField[], build: (values: Record<DevField, string>) => readonly string[]): readonly string[] | null => {
+ const values = {} as Record<DevField, string>
+
+ for (const name of names) {
+ const value = fieldValue(name, fields[name])
+
+ if (value === null) return null
+ values[name] = value
+ }
+
+ return build(values)
+}
+
+/** A `.rvf` file's branch beside it: `memory.rvf` with label `try` branches to `memory-try.rvf`. */
+export const branchPathOf = (path: string, label: string): string => (path.endsWith('.rvf') ? `${path.slice(0, -4)}-${label}.rvf` : `${path}-${label}.rvf`)
+
+const fixed = (argv: readonly string[]) => () => argv
+const GH = 'gh CLI in this repo: it reads GitHub over the network'
+const IN_PROCESS = 'a WASM agent lives inside one MCP server process; ruflo mcp exec starts a fresh process per call, so an agent id never reaches the next call. Use the ruflo MCP server (/mcp) for a session'
+
+export const DEV: readonly DevEntry[] = [
+ { id: 'dt-brain', group: 'brain', name: 'WHAT SHOULD I DO?', about: 'ask ruflo which tools fit a task: type it above', label: 'capability brain: recommend tools for the task', cost: 'read', input: 'task', args: f => need(f, ['task'], v => tool('guidance_brain', { mode: 'recommend', task: v.task })) },
+ { id: 'dt-brain-overview', group: 'brain', name: 'OVERVIEW', about: 'every capability domain and its health facts', label: 'capability brain: the overview', cost: 'read', args: fixed(tool('guidance_brain', { mode: 'overview' })) },
+ { id: 'dt-brain-loop', group: 'brain', name: 'IMPLEMENTATION LOOP', about: 'recall → inspect → … → publish, each step its tools', label: 'capability brain: the implementation loop', cost: 'read', args: fixed(tool('guidance_brain', { mode: 'implementation-loop' })) },
+
+ { id: 'dt-diff', group: 'analyze', name: 'DIFF', about: 'classification, risk, file risks and reviewers for the ref', label: 'analyze the diff (risk, class, reviewers)', cost: 'read', input: 'ref', args: f => need(f, ['ref'], v => tool('analyze_diff', { ref: v.ref, includeFileRisks: true, includeReviewers: true })) },
+ { id: 'dt-diff-stats', group: 'analyze', name: 'STATS', about: 'files, additions and deletions by status', label: 'diff stats for the ref', cost: 'read', input: 'ref', args: f => need(f, ['ref'], v => tool('analyze_diff-stats', { ref: v.ref })) },
+ { id: 'dt-diff-classify', group: 'analyze', name: 'CLASSIFY', about: 'feature, fix, refactor, docs … with confidence', label: 'classify the diff', cost: 'read', input: 'ref', args: f => need(f, ['ref'], v => tool('analyze_diff-classify', { ref: v.ref })) },
+ { id: 'dt-diff-risk', group: 'analyze', name: 'RISK', about: 'the overall risk score and what drives it', label: 'risk of the diff', cost: 'read', input: 'ref', args: f => need(f, ['ref'], v => tool('analyze_diff-risk', { ref: v.ref })) },
+ { id: 'dt-diff-reviewers', group: 'analyze', name: 'REVIEWERS', about: 'who should review it, from the history', label: 'suggested reviewers for the diff', cost: 'read', input: 'ref', args: f => need(f, ['ref'], v => tool('analyze_diff-reviewers', { ref: v.ref, limit: 5 })) },
+ { id: 'dt-file-risk', group: 'analyze', name: 'FILE RISK', about: 'the risk of changing the file in the path field', label: 'risk of changing the file at the path', cost: 'read', input: 'path', args: f => need(f, ['path'], v => tool('analyze_file-risk', { path: v.path })) },
+
+ { id: 'dt-gh-repo', group: 'github', name: 'REPO', about: 'branches, commits, open issues and PRs of this repo', label: 'analyze this GitHub repo', cost: 'network', args: fixed(tool('github_repo_analyze', {})), note: GH },
+ { id: 'dt-gh-prs', group: 'github', name: 'PULL REQUESTS', about: 'the last 20 pull requests and their state', label: 'list pull requests', cost: 'network', args: fixed(tool('github_pr_manage', { action: 'list' })), note: GH },
+ { id: 'dt-gh-issues', group: 'github', name: 'ISSUES', about: 'the issues ruflo tracks for this repo', label: 'list tracked issues', cost: 'network', args: fixed(tool('github_issue_track', { action: 'list' })), note: GH },
+ { id: 'dt-gh-runs', group: 'github', name: 'WORKFLOW RUNS', about: 'the last 10 Actions runs and how they ended', label: 'list GitHub Actions runs', cost: 'network', args: fixed(tool('github_workflow', { action: 'list' })), note: GH },
+ { id: 'dt-gh-metrics', group: 'github', name: 'METRICS', about: 'commits, contributors, releases', label: 'GitHub metrics for this repo', cost: 'network', args: fixed(tool('github_metrics', { metric: 'all' })), note: GH },
+ { id: 'dt-issues', group: 'github', name: 'ISSUE CLAIMS', about: 'who claimed which issue (ADR-016), from disk', label: 'issues list: issue claims', cost: 'read', args: fixed(['issues', 'list']) },
+ { id: 'dt-issues-board', group: 'github', name: 'CLAIMS BOARD', about: 'the claims as a board, by state', label: 'issues board', cost: 'read', args: fixed(['issues', 'board']) },
+ { id: 'dt-deploy-status', group: 'github', name: 'DEPLOYMENTS', about: 'each environment and what is deployed there', label: 'deployment status', cost: 'read', args: fixed(['deployment', 'status']) },
+ { id: 'dt-deploy-history', group: 'github', name: 'DEPLOY HISTORY', about: 'the last 10 deployments and rollbacks', label: 'deployment history', cost: 'read', args: fixed(['deployment', 'history', '--limit', '10']) },
+
+ { id: 'dt-cow-status', group: 'cow', name: 'STATUS', about: 'the .rvf in the path field: size, edits, checkpoints', label: 'agenticow status of the .rvf', cost: 'read', input: 'path', args: f => need(f, ['path'], v => tool('agenticow_status', { path: v.path })) },
+ { id: 'dt-cow-diff', group: 'cow', name: 'DIFF', about: 'its edits against its base', label: 'agenticow diff of the .rvf', cost: 'read', input: 'path', args: f => need(f, ['path'], v => tool('agenticow_diff', { path: v.path })) },
+ { id: 'dt-cow-lineage', group: 'cow', name: 'LINEAGE', about: 'base → checkpoints → working, from its manifest', label: 'agenticow lineage of the .rvf', cost: 'read', input: 'path', args: f => need(f, ['path'], v => tool('agenticow_lineage', { path: v.path })) },
+ { id: 'dt-cow-checkpoint', group: 'cow', name: 'CHECKPOINT', about: 'mark the working state with the label', label: 'agenticow checkpoint the .rvf', cost: 'writes', input: 'label', args: f => need(f, ['path', 'label'], v => tool('agenticow_checkpoint', { path: v.path, label: v.label })), note: 'writes a checkpoint into the .rvf lineage manifest' },
+ { id: 'dt-cow-branch', group: 'cow', name: 'BRANCH', about: 'fork it to <name>-<label>.rvf beside it', label: 'agenticow branch the .rvf', cost: 'writes', input: 'label', args: f => need(f, ['path', 'label'], v => tool('agenticow_branch', { basePath: v.path, branchPath: branchPathOf(v.path, v.label), label: v.label })), note: 'writes a new branch .rvf beside the base' },
+ { id: 'dt-cow-rollback', group: 'cow', name: 'ROLLBACK', about: 'discard every edit since the last checkpoint', label: 'agenticow rollback the .rvf to its last checkpoint', cost: 'deletes', input: 'path', args: f => need(f, ['path'], v => tool('agenticow_rollback', { path: v.path })), note: 'DISCARDS every edit made since the most recent checkpoint' },
+ { id: 'dt-cow-promote', group: 'cow', name: 'PROMOTE', about: 'merge this branch .rvf into its base', label: 'agenticow promote the branch into its base', cost: 'writes', input: 'path', args: f => need(f, ['path'], v => tool('agenticow_promote', { branchPath: v.path })), note: 'writes the branch edits and tombstones into its base .rvf' },
+ { id: 'dt-cow-vectors', group: 'cow', name: 'QUERY · INGEST · SPECULATE', about: 'n/a here: they take vectors and records as JSON arrays', label: 'agenticow query, ingest, speculate', cost: 'read', na: 'they take vectors or records (JSON arrays) a field cannot carry: call agenticow_query/ingest/speculate from an agent' },
+
+ { id: 'dt-wasm-gallery', group: 'wasm', name: 'GALLERY', about: 'every agent template in the gallery', label: 'WASM gallery: the templates', cost: 'read', args: fixed(tool('wasm_gallery_list', {})) },
+ { id: 'dt-wasm-categories', group: 'wasm', name: 'CATEGORIES', about: 'the gallery by category', label: 'WASM gallery categories', cost: 'read', args: fixed(tool('wasm_gallery_categories', {})) },
+ { id: 'dt-wasm-search', group: 'wasm', name: 'SEARCH', about: 'the gallery for the search field’s words', label: 'search the WASM gallery', cost: 'read', input: 'query', args: f => need(f, ['query'], v => tool('wasm_gallery_search', { query: v.query })) },
+ { id: 'dt-wasm-list', group: 'wasm', name: 'AGENTS', about: 'agents in the answering process (exec keeps none)', label: 'list WASM agents', cost: 'read', args: fixed(tool('wasm_agent_list', {})) },
+ { id: 'dt-wasm-agent', group: 'wasm', name: 'CREATE · PROMPT · STATE · STOP', about: 'n/a here: an agent id dies with its CLI process', label: 'WASM agent create, prompt, state, terminate', cost: 'read', na: IN_PROCESS },
+
+ { id: 'dt-br-open', group: 'browser', name: 'OPEN', about: 'open the URL field in the session', label: 'open the URL in the browser', cost: 'network', input: 'url', args: f => need(f, ['url'], v => tool('browser_open', { url: v.url, session: SESSION })), note: 'the browser loads the page from the network' },
+ { id: 'dt-br-snapshot', group: 'browser', name: 'SNAPSHOT', about: 'the page as an accessibility tree with @e refs', label: 'snapshot the open page', cost: 'read', args: fixed(tool('browser_snapshot', { session: SESSION, interactive: true, compact: true })) },
+ { id: 'dt-br-url', group: 'browser', name: 'WHERE', about: 'the URL the page is on now', label: 'the open page’s URL', cost: 'read', args: fixed(tool('browser_get-url', { session: SESSION })) },
+ { id: 'dt-br-click', group: 'browser', name: 'CLICK', about: 'click the @e ref in the target field', label: 'click the element in the browser', cost: 'network', input: 'target', args: f => need(f, ['target'], v => tool('browser_click', { target: v.target, session: SESSION })), note: 'a click can submit a form or navigate: the page may reach the network' },
+ { id: 'dt-br-back', group: 'browser', name: 'BACK', about: 'go back one page', label: 'browser back', cost: 'network', args: fixed(tool('browser_back', { session: SESSION })), note: 'the browser may load the page again from the network' },
+ { id: 'dt-br-shot', group: 'browser', name: 'SCREENSHOT', about: `a PNG of the page to ./${SHOT}`, label: 'screenshot the page', cost: 'writes', args: fixed(tool('browser_screenshot', { session: SESSION, path: SHOT })), note: `writes ./${SHOT}` },
+ { id: 'dt-br-sessions', group: 'browser', name: 'SESSIONS', about: 'the browser sessions open now', label: 'list browser sessions', cost: 'read', args: fixed(tool('browser_session-list', {})) },
+ { id: 'dt-br-close', group: 'browser', name: 'CLOSE', about: 'close the console’s browser session', label: 'close the browser session', cost: 'writes', args: fixed(tool('browser_close', { session: SESSION })), note: 'closes the ruflo-console browser session' },
+
+ { id: 'dt-term-list', group: 'terminal', name: 'SESSIONS', about: 'ruflo’s terminal sessions and their state', label: 'list terminal sessions', cost: 'read', args: fixed(tool('terminal_list', { status: 'all' })) },
+ { id: 'dt-term-history', group: 'terminal', name: 'HISTORY', about: 'the last 20 commands they ran', label: 'terminal history', cost: 'read', args: fixed(tool('terminal_history', { limit: 20 })) },
+ { id: 'dt-term-create', group: 'terminal', name: 'NEW SESSION', about: 'a session named ruflo-console', label: 'create a terminal session', cost: 'writes', args: fixed(tool('terminal_create', { name: SESSION })), note: 'writes a session to .claude-flow/terminals/store.json' },
+ { id: 'dt-term-exec', group: 'terminal', name: 'RUN COMMAND', about: 'run the command field (in the id field’s session)', label: 'run the command in a ruflo terminal', cost: 'writes', input: 'cmd', args: f => need(f, ['cmd'], v => { const session = fieldValue('id', f.id); return tool('terminal_execute', { command: v.cmd, ...(session !== null && { sessionId: session }) }) }), note: 'RUNS A SHELL COMMAND in this project, as you: read it on the line above' },
+ { id: 'dt-term-close', group: 'terminal', name: 'CLOSE SESSION', about: 'close the session in the id field', label: 'close the terminal session', cost: 'writes', input: 'id', args: f => need(f, ['id'], v => tool('terminal_close', { sessionId: v.id })), note: 'closes that terminal session' },
+
+ { id: 'dt-prov-list', group: 'providers', name: 'PROVIDERS', about: 'each provider: configured (env/config) or not, never the key', label: 'providers list', cost: 'read', args: fixed(['providers', 'list']) },
+ { id: 'dt-prov-test', group: 'providers', name: 'TEST ALL', about: 'ask each configured provider for its models', label: 'test every configured provider', cost: 'network', args: fixed(['providers', 'test', '--all']), note: 'calls each provider’s API (a models list, no completion)' },
+ { id: 'dt-prov-configure', group: 'providers', name: 'CONFIGURE', about: 'n/a here: a key never goes through the console', label: 'providers configure', cost: 'read', na: 'a key on an argv shows in the process list: run ruflo providers configure -p <provider> yourself, or set the provider’s env var' },
+
+ { id: 'dt-plug-installed', group: 'plugins', name: 'INSTALLED', about: 'ruflo plugins installed here (local manifest)', label: 'plugins list --installed', cost: 'read', args: fixed(['plugins', 'list', '--installed']) },
+ { id: 'dt-plug-official', group: 'plugins', name: 'OFFICIAL', about: 'the official plugins in the registry', label: 'registry: official plugins', cost: 'network', args: fixed(tool('transfer_plugin-official', {})), note: 'reads the plugin registry from IPFS' },
+ { id: 'dt-plug-featured', group: 'plugins', name: 'FEATURED', about: 'ten featured plugins', label: 'registry: featured plugins', cost: 'network', args: fixed(tool('transfer_plugin-featured', { limit: 10 })), note: 'reads the plugin registry from IPFS' },
+ { id: 'dt-plug-search', group: 'plugins', name: 'SEARCH', about: 'the registry for the search field’s words', label: 'search the plugin registry', cost: 'network', input: 'query', args: f => need(f, ['query'], v => tool('transfer_plugin-search', { query: v.query, limit: 10 })), note: 'reads the plugin registry from IPFS' },
+
+ { id: 'dt-llm-status', group: 'ruvllm', name: 'STATUS', about: 'WASM, native coordinator and graph backends', label: 'ruvllm status', cost: 'read', args: fixed(tool('ruvllm_status', {})) },
+ { id: 'dt-llm-hnsw', group: 'ruvllm', name: 'HNSW ROUTER', about: 'a 384-dim router for 64 patterns', label: 'create a ruvllm HNSW router', cost: 'local', args: fixed(tool('ruvllm_hnsw_create', { dimensions: 384, maxPatterns: 64 })), note: 'in memory in that one CLI process: it answers its id and config, and keeps nothing' },
+ { id: 'dt-llm-sona', group: 'ruvllm', name: 'SONA', about: 'a SONA adapter with the default sizes', label: 'create a SONA adapter', cost: 'local', args: fixed(tool('ruvllm_sona_create', {})), note: 'in memory in that one CLI process: it answers its id and config, and keeps nothing' },
+ { id: 'dt-llm-lora', group: 'ruvllm', name: 'MICROLORA', about: 'a rank-8 384→384 MicroLoRA', label: 'create a MicroLoRA', cost: 'local', args: fixed(tool('ruvllm_microlora_create', { inputDim: 384, outputDim: 384, rank: 8 })), note: 'in memory in that one CLI process: it answers its id and config, and keeps nothing' },
+
+ { id: 'dt-daa-status', group: 'daa', name: 'LEARNING', about: 'each DAA agent’s learning and adaptations', label: 'DAA learning status', cost: 'read', args: fixed(tool('daa_learning_status', { detailed: true })) },
+ { id: 'dt-daa-metrics', group: 'daa', name: 'METRICS', about: 'agents, workflows and learning, all time', label: 'DAA performance metrics', cost: 'read', args: fixed(tool('daa_performance_metrics', { category: 'all' })) },
+ { id: 'dt-daa-create', group: 'daa', name: 'NEW AGENT', about: 'an adaptive agent with the id field', label: 'create a DAA agent', cost: 'writes', input: 'id', args: f => need(f, ['id'], v => tool('daa_agent_create', { id: v.id, cognitivePattern: 'adaptive', enableMemory: true })), note: 'writes the agent to .claude-flow/daa' },
+ { id: 'dt-daa-adapt', group: 'daa', name: 'ADAPT', about: 'feed the note to the agent in the id field', label: 'adapt the DAA agent with the note', cost: 'writes', input: 'note', args: f => need(f, ['id', 'note'], v => tool('daa_agent_adapt', { agentId: v.id, feedback: v.note })), note: 'writes the adaptation to .claude-flow/daa' },
+ { id: 'dt-daa-workflow', group: 'daa', name: 'NEW WORKFLOW', about: 'an adaptive workflow named by the label field', label: 'create a DAA workflow', cost: 'writes', input: 'label', args: f => need(f, ['label'], v => tool('daa_workflow_create', { id: v.label, name: v.label, strategy: 'adaptive' })), note: 'writes the workflow to .claude-flow/daa' },
+ { id: 'dt-daa-share', group: 'daa', name: 'SHARE', about: 'the note, from the id agent to the label agent', label: 'share knowledge between DAA agents', cost: 'writes', input: 'note', args: f => need(f, ['id', 'label', 'note'], v => tool('daa_knowledge_share', { sourceAgentId: v.id, targetAgentIds: [v.label], knowledgeDomain: 'console', knowledgeContent: { note: v.note } })), note: 'writes the shared knowledge to .claude-flow/daa' },
+
+ { id: 'dt-ma-list', group: 'managed', name: 'SESSIONS', about: 'your cloud sessions (ANTHROPIC_API_KEY)', label: 'list managed-agent sessions', cost: 'network', args: fixed(tool('managed_agent_list', { limit: 10 })), note: 'calls the Anthropic API with your key' },
+ { id: 'dt-ma-status', group: 'managed', name: 'STATUS', about: 'the session in the id field', label: 'managed-agent status', cost: 'network', input: 'id', args: f => need(f, ['id'], v => tool('managed_agent_status', { sessionId: v.id })), note: 'calls the Anthropic API with your key' },
+ { id: 'dt-ma-events', group: 'managed', name: 'TRANSCRIPT', about: 'that session’s events', label: 'managed-agent transcript', cost: 'network', input: 'id', args: f => need(f, ['id'], v => tool('managed_agent_events', { sessionId: v.id })), note: 'calls the Anthropic API with your key' },
+ { id: 'dt-ma-create', group: 'managed', name: 'NEW SESSION', about: 'a cloud agent session, networking off', label: 'create a managed-agent session', cost: 'spends', args: fixed(tool('managed_agent_create', { name: SESSION, networking: 'none' })), note: 'COSTS MONEY: starts a billed cloud session on the Anthropic API' },
+ { id: 'dt-ma-prompt', group: 'managed', name: 'PROMPT', about: 'send the note to the id session', label: 'prompt the managed agent with the note', cost: 'spends', input: 'note', args: f => need(f, ['id', 'note'], v => tool('managed_agent_prompt', { sessionId: v.id, message: v.note })), note: 'COSTS MONEY: a model turn in that cloud session', timeoutMs: 180_000 },
+ { id: 'dt-ma-stop', group: 'managed', name: 'TERMINATE', about: 'end the id session', label: 'terminate the managed-agent session', cost: 'deletes', input: 'id', args: f => need(f, ['id'], v => tool('managed_agent_terminate', { sessionId: v.id })), note: 'ends that cloud session on the Anthropic API' },
+
+ { id: 'dt-cleanup', group: 'maint', name: 'CLEANUP PLAN', about: 'what cleanup would remove (dry run)', label: 'cleanup dry run', cost: 'read', args: fixed(['cleanup']) },
+ // --keep-config is not offered: the parser hands it over as keepConfig and cleanup.ts reads ['keep-config'], so it is ignored.
+ { id: 'dt-cleanup-force', group: 'maint', name: 'CLEANUP', about: 'remove everything CLEANUP PLAN lists', label: 'cleanup --force', cost: 'deletes', args: fixed(['cleanup', '--force']), note: 'DELETES what CLEANUP PLAN lists: .claude-flow, .swarm, .hive-mind, .claude/helpers, claude-flow.config.json, ruflo’s blocks in .claude/settings.json' },
+ { id: 'dt-update-check', group: 'maint', name: 'UPDATE CHECK', about: 'newer @claude-flow packages on npm', label: 'update check', cost: 'network', args: fixed(['update', 'check', '--json']), note: 'asks the npm registry' },
+ { id: 'dt-update-history', group: 'maint', name: 'UPDATE HISTORY', about: 'the updates applied here', label: 'update history', cost: 'read', args: fixed(['update', 'history', '--json']) },
+ { id: 'dt-update-all', group: 'maint', name: 'UPDATE ALL', about: 'install the newer @claude-flow packages', label: 'update all @claude-flow packages', cost: 'network', args: fixed(['update', 'all']), note: 'downloads from npm and writes node_modules', timeoutMs: 300_000 },
+ { id: 'dt-update-rollback', group: 'maint', name: 'UPDATE ROLLBACK', about: 'undo the last update', label: 'update rollback', cost: 'writes', args: fixed(['update', 'rollback']), note: 'reinstalls the versions before the last update', timeoutMs: 300_000 },
+ { id: 'dt-migrate-status', group: 'maint', name: 'MIGRATE STATUS', about: 'what of v2 is left to migrate', label: 'migrate status', cost: 'read', args: fixed(['migrate', 'status']) },
+ { id: 'dt-migrate-breaking', group: 'maint', name: 'BREAKING', about: 'the v3 breaking changes', label: 'migrate breaking', cost: 'read', args: fixed(['migrate', 'breaking']) },
+ { id: 'dt-migrate-plan', group: 'maint', name: 'MIGRATE PLAN', about: 'n/a: this CLI ignores migrate run --dry-run', label: 'migrate run --dry-run', cost: 'read', na: 'migrate.ts reads flags["dry-run"] but the parser passes dryRun, so --dry-run runs the real migration (with a backup): use MIGRATE STATUS to see what is left' },
+ { id: 'dt-migrate-run', group: 'maint', name: 'MIGRATE', about: 'run the full v2 → v3 migration', label: 'migrate run --target all', cost: 'writes', args: fixed(['migrate', 'run', '--target', 'all']), note: 'migrates config, memory, agents, hooks, workflows and embeddings to v3 in place' },
+ { id: 'dt-daemon', group: 'maint', name: 'DAEMON', about: 'is the daemon up, its pid and port', label: 'process daemon status', cost: 'read', args: fixed(['process', 'daemon', '--action', 'status']) },
+ { id: 'dt-daemon-start', group: 'maint', name: 'DAEMON START', about: 'start the background daemon', label: 'start the ruflo daemon', cost: 'writes', args: fixed(['process', 'daemon', '--action', 'start']), note: 'starts a background process and writes .claude-flow/daemon.pid' },
+ { id: 'dt-daemon-stop', group: 'maint', name: 'DAEMON STOP', about: 'stop the background daemon', label: 'stop the ruflo daemon', cost: 'writes', args: fixed(['process', 'daemon', '--action', 'stop']), note: 'stops the background daemon' },
+ { id: 'dt-workers', group: 'maint', name: 'WORKERS', about: 'the background worker processes', label: 'process workers list', cost: 'read', args: fixed(['process', 'workers', '--action', 'list']) },
+ { id: 'dt-logs', group: 'maint', name: 'LOGS', about: 'the last 50 log lines', label: 'process logs', cost: 'read', args: fixed(['process', 'logs', '--tail', '50']) },
+ { id: 'dt-app-inspect', group: 'maint', name: 'APPLIANCE', about: 'the RVFA header and sections of the path field’s .rvf', label: 'appliance inspect', cost: 'read', input: 'path', args: f => need(f, ['path'], v => ['appliance', 'inspect', '-f', v.path, '--json']) },
+ { id: 'dt-app-verify', group: 'maint', name: 'APPLIANCE VERIFY', about: 'its integrity (quick, no capability tests)', label: 'appliance verify --quick', cost: 'read', input: 'path', args: f => need(f, ['path'], v => ['appliance', 'verify', '-f', v.path, '--quick']) },
+]
+
+/** The confirm-free spec for a local read, the asked one for the rest; null when a field breaks its rule or it is n/a. */
+export function devSpec(entry: DevEntry, fields: DevFields): ActionSpec | null {
+ const args = entry.na === undefined ? (entry.args?.(fields) ?? null) : null
+
+ if (args === null) return null
+
+ return {
+ label: entry.label,
+ args,
+ expect: entry.cost === 'read' ? 'its output in Dev Tools' : `its result in Dev Tools${entry.note !== undefined ? `; ${entry.note}` : ''}`,
+ lab: entry.id,
+ lines: (stdout, stderr) => devLines(entry.id, stdout, stderr),
+ ...(entry.cost === 'read' && { isReadOnly: true }),
+ ...(entry.note !== undefined && { note: entry.note }),
+ ...(entry.timeoutMs !== undefined && { timeoutMs: entry.timeoutMs }),
+ }
+}
+
+/** Why an entry has nothing to run now, in the footer's words. */
+export function devWhy(entry: DevEntry, fields: DevFields): string {
+ if (entry.na !== undefined) return `n/a: ${entry.na}`
+
+ // With every failing field given a passing value it builds: the first failing field it cannot build without is the one to name.
+ const failing = (Object.keys(SAMPLE) as DevField[]).filter(field => fieldValue(field, fields[field]) === null)
+ const filled = (except: DevField | null): DevFields => ({ ...fields, ...Object.fromEntries(failing.filter(field => field !== except).map(field => [field, SAMPLE[field]])) })
+ const broken = entry.args === undefined || entry.args(filled(null)) === null ? undefined : failing.find(field => entry.args?.(filled(field)) === null)
+
+ return broken === undefined ? 'nothing to run' : `${broken} field: ${fieldRule(broken)}`
+}
+
+/** A value each field accepts, to find which field kept an entry from running. */
+const SAMPLE: DevFields = { ref: 'HEAD', path: 'memory.rvf', label: 'l', url: 'https://example.com', target: '@e1', query: 'q', task: 't', cmd: 'c', id: 'i', note: 'n' }
+
+/**
+ * Every runnable entry as a palette entry, so `/ruflo run dt-diff HEAD~3` works headless: an entry with an input field
+ * is a text entry whose keyword is its id, and its text (when given) fills that field first.
+ */
+export function devPalette(state: State): PaletteEntry[] {
+ const fields = state.devtools.fields
+
+ return DEV.filter(entry => entry.na === undefined).map(entry => {
+ const input = entry.input
+
+ if (input === undefined) return { id: entry.id, group: 'devtools', label: entry.label, run: { kind: 'spec', spec: devSpec(entry, fields), why: devWhy(entry, fields) } }
+
+ return {
+ id: entry.id,
+ group: 'devtools',
+ label: entry.label,
+ run: {
+ kind: 'text',
+ keyword: entry.id,
+ make: text => {
+ if (text.trim() !== '') fields[input] = text.trim()
+
+ return devSpec(entry, fields)
+ },
+ },
+ }
+ })
+}
+
+/** Which entry Enter in each field runs; a field with none only keeps its text. */
+const SUBMITS: Partial<Record<DevField, string>> = { task: 'dt-brain', ref: 'dt-diff', path: 'dt-cow-status', url: 'dt-br-open', target: 'dt-br-click', query: 'dt-plug-search', cmd: 'dt-term-exec' }
+
+export type DevtoolsActions = {
+ draft: (field: DevField, text: string) => void
+ /** Enter in a field: keep its text and run its entry (a read at once, the rest asked first). */
+ submit: (field: DevField, text: string) => void
+}
+
+export function devtoolsActions(state: State, host: Host, run: (id: string, text: string) => boolean, refuse: (why: string) => void): DevtoolsActions {
+ return {
+ draft: (field, text) => {
+ state.devtools.fields[field] = text
+ },
+ submit: (field, text) => {
+ state.devtools.fields[field] = text
+ host.invalidate()
+
+ const id = SUBMITS[field]
+
+ if (id === undefined) return
+ if (fieldValue(field, text) === null) refuse(`${field} field: ${fieldRule(field)}`)
+ else run(id, '')
+ },
+ }
+}
diff --git a/plugins/ruflo-console/hooks/palette.ts b/plugins/ruflo-console/hooks/palette.ts
index 320a67f328..93cb817a14 100644
--- a/plugins/ruflo-console/hooks/palette.ts
+++ b/plugins/ruflo-console/hooks/palette.ts
@@ -6,6 +6,7 @@
import { HIVE_ROLES, pickedProposal } from './data/hive'
import { hiveBroadcast, hivePropose, hiveSpawn, hiveVote } from './hive'
import { claimTask, handoffClaim, releaseClaim, stealClaim, type ActionSpec } from './actions'
+import { devPalette } from './devtools'
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'
@@ -116,6 +117,9 @@ 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) })
+ // Dev Tools: local reads run at once, the rest ask first; an entry with a field takes its text (see devtools.ts).
+ out.push(...devPalette(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..900556b267 100644
--- a/plugins/ruflo-console/hooks/runner.ts
+++ b/plugins/ruflo-console/hooks/runner.ts
@@ -56,11 +56,12 @@ export function createRunner(state: State, host: Host, deps: RunnerDeps): Runner
const result = await host.run([...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
+ // `mcp exec` wraps a tool's failure as `"isError": true` with its message escaped inside: that is a failure too.
+ const ok = result.exitCode === 0 && answer !== 'false' && error === undefined && !/"isError"\s*:\s*true/.test(result.stdout)
// 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 ?? ((out: string, err: string) => labLines(spec.lab ?? '', out, err)))(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..21a1e5d54f 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -1,6 +1,7 @@
import type { PluginOptions, Timer } from 'claude-code'
import type { ProbeResult } from './data/cli'
+import { emptyFields, type DevFields } from './data/devtools'
import type { ConsoleEvent } from './data/events'
import type { ReadCache } from './data/files'
import { emptySkills, type SkillsState } from './data/skills'
@@ -10,7 +11,7 @@ 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' | 'devtools' | '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 },
+ // Keyless too. The menu prompt, the tab and /ruflo devtools reach it by name.
+ { id: 'devtools', key: '', label: 'Dev Tools', short: 'Dev', icon: '🔧', blurb: 'the integration surface: GitHub, diff analysis, agenticow, WASM, browser, terminal, providers, maintenance', rows: 40 },
]
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 Dev Tools view: what is typed in its fields (its runs share the lab result panel, ids dt-*). */
+ devtools: { fields: DevFields }
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(),
+ devtools: { fields: emptyFields() },
timers: new Map(),
stats: { renders: [], refreshes: [], frames: [] },
}
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index 482d9f5b70..622f7e9dcb 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -6,6 +6,7 @@
import type { Elements, RenderChildren, RenderElement } from 'claude-code'
import type { ProbeResult } from '../data/cli'
+import type { DevtoolsActions } from '../devtools'
import type { Grid } from '../gfx/raster'
import type { SkillActions } from '../skills'
import type { HarnessId, State, ViewId } from '../state'
@@ -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 Dev Tools view: keep a field's text, and Enter in a field runs its entry. */
+ devtools: DevtoolsActions
}
export type Ctx = {
diff --git a/plugins/ruflo-console/hooks/views/devtools.ts b/plugins/ruflo-console/hooks/views/devtools.ts
new file mode 100644
index 0000000000..168379aecd
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/devtools.ts
@@ -0,0 +1,138 @@
+import type { RenderElement } from 'claude-code'
+
+import type { DevField } from '../data/devtools'
+import { DEV, DEV_GROUPS, devSpec, type DevCost, type DevEntry, type DevGroup } from '../devtools'
+import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
+
+/** Result lines in view at once; j/k scroll the rest. */
+const RESULT_ROWS = 14
+
+/** Each cost as a four-cell tag, as the MetaHarness lab tags its rows. */
+const TAG: Record<DevCost, { text: string; color: () => string }> = {
+ read: { text: ' $0 ', color: () => THEME.ok },
+ local: { text: 'cpu ', color: () => THEME.info },
+ writes: { text: ' wr ', color: () => THEME.info },
+ network: { text: 'net ', color: () => THEME.warn },
+ spends: { text: ' $$ ', color: () => THEME.bad },
+ deletes: { text: 'del ', color: () => THEME.bad },
+}
+
+/** The fields each section shows above its rows: one field may serve several sections, and says so. */
+const FIELDS: Partial<Record<DevGroup, readonly { field: DevField; label: string; placeholder: string; submit?: string }[]>> = {
+ brain: [{ field: 'task', label: 'ask', placeholder: 'what should I do? e.g. review my pull request, add OAuth login …', submit: 'ask' }],
+ analyze: [{ field: 'ref', label: 'ref', placeholder: 'HEAD · HEAD~3 · main..HEAD · a sha', submit: 'diff' }],
+ cow: [
+ { field: 'path', label: 'path', placeholder: 'an .rvf memory file under the project (also file risk, appliance)', submit: 'status' },
+ { field: 'label', label: 'label', placeholder: 'a checkpoint or branch label (also a DAA workflow / target agent)' },
+ ],
+ wasm: [{ field: 'query', label: 'search', placeholder: 'words to search the WASM gallery or the plugin registry' }],
+ browser: [
+ { field: 'url', label: 'url', placeholder: 'https://… to open in the ruflo-console session', submit: 'open' },
+ { field: 'target', label: 'target', placeholder: '@e1: an element ref from SNAPSHOT', submit: 'click' },
+ ],
+ terminal: [
+ { field: 'cmd', label: 'command', placeholder: 'one command line: Enter shows it, then asks before it runs', submit: 'run' },
+ { field: 'id', label: 'id', placeholder: 'a session / agent id (terminal, DAA, managed agents)' },
+ ],
+ plugins: [{ field: 'query', label: 'search', placeholder: 'words to search the plugin registry (IPFS: asks first)', submit: 'search' }],
+ daa: [{ field: 'note', label: 'note', placeholder: 'feedback or knowledge to send (also a managed-agent prompt)' }],
+}
+
+/** One dotted-leader row: the cost tag, the name, what it does, and its â–¸ button; an n/a row says why instead. */
+function entryRow(ctx: Ctx, entry: DevEntry, lead: number): RenderElement {
+ const tag = TAG[entry.cost]
+ const isNa = entry.na !== undefined
+ const isBlocked = !isNa && devSpec(entry, ctx.state.devtools.fields) === null
+
+ return row(
+ ctx,
+ [
+ ctx.kit.Text({ bold: true, color: isNa ? THEME.info : tag.color(), dimColor: isNa, children: ` ${isNa ? 'n/a ' : tag.text}` }),
+ ctx.kit.Text({ bold: true, color: entry.cost === 'spends' || entry.cost === 'deletes' ? THEME.warn : THEME.head, dimColor: isNa, children: clip(` ${entry.name} `, lead).padEnd(lead, '.') }),
+ ctx.kit.Text({ color: THEME.info, dimColor: isNa || isBlocked, wrap: 'truncate-end', children: clip(` ${entry.about}`, Math.max(4, ctx.columns - lead - 16)) }),
+ // A blocked row keeps its button: pressing it says which field to fill.
+ ...(isNa ? [] : [ctx.kit.Button({ key: `dt-${entry.id.slice(3)}`, label: ' â–¸ run', plain: true, dimColor: true, onPress: () => void ctx.act.run(entry.id) })]),
+ ],
+ `dt-row-${entry.id}`,
+ )
+}
+
+function fieldRows(ctx: Ctx, group: DevGroup): RenderElement[] {
+ const fields = FIELDS[group] ?? []
+
+ const Input = ctx.kit.Input
+
+ if (fields.length === 0) return []
+ if (Input === undefined) return [text(ctx, ` this surface has no text field: /ruflo run <id> <text> fills one (${fields.map(entry => entry.field).join(', ')})`, { dimColor: true })]
+
+ return fields.map(({ field, label, placeholder, submit }) =>
+ Input({
+ key: `dt-field-${group}-${field}`,
+ label,
+ placeholder,
+ value: ctx.state.devtools.fields[field],
+ submitLabel: submit ?? 'keep',
+ onInput: value => ctx.act.devtools.draft(field, value),
+ onSubmit: value => ctx.act.devtools.submit(field, value),
+ }),
+ )
+}
+
+/** The last Dev Tools run: what it was, how it exited, its note, and a window of its lines. */
+function resultRows(ctx: Ctx): RenderElement[] {
+ const { state, nowMs } = ctx
+ const running = state.lab.running?.id.startsWith('dt-') === true ? state.lab.running : null
+ const result = state.lab.result?.id.startsWith('dt-') === 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, ' â–¸ press a row: a $0 read shows here at once; the rest ask first (y), their cost on the confirm row', { 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: /MONEY|DELETES|DISCARDS|SHELL/.test(result.note) ? THEME.bad : THEME.warn }))
+
+ const top = Math.max(0, Math.min(state.select.item, result.lines.length - RESULT_ROWS))
+
+ for (const line of result.lines.slice(top, top + RESULT_ROWS)) rows.push(text(ctx, ` ${line}`))
+
+ if (result.lines.length > RESULT_ROWS) {
+ rows.push(
+ row(ctx, [
+ text(ctx, ` lines ${top + 1}-${Math.min(result.lines.length, top + RESULT_ROWS)} of ${result.lines.length} `, { dimColor: true }),
+ button(ctx, 'dt-up', 'up', () => ctx.act.select(-1), { hotkey: 'k' }),
+ button(ctx, 'dt-down', 'down', () => ctx.act.select(1), { hotkey: 'j' }),
+ ]),
+ )
+ }
+
+ return rows
+}
+
+/**
+ * ruflo's integration surface by purpose: each section its fields and its rows, the last run's output under the first
+ * section so it stays in view, and a key to the cost tags. Drawing it runs nothing; every row is a press.
+ */
+export function devtoolsView(ctx: Ctx): RenderElement {
+ const lead = Math.max(16, Math.min(24, ctx.columns - 44))
+ const rows: RenderElement[] = [text(ctx, ' $0 local read, runs at once · cpu/wr local work or a write · net the network · $$ may spend · del deletes: each of these asks first', { dimColor: true })]
+
+ DEV_GROUPS.forEach((group, i) => {
+ rows.push(rule(ctx, group.title, group.right))
+ rows.push(...fieldRows(ctx, group.id))
+
+ for (const entry of DEV.filter(candidate => candidate.group === group.id)) rows.push(entryRow(ctx, entry, lead))
+
+ // The result sits under the brain and the diff tools, so a read's answer appears beside what asked for it.
+ if (i === 1) rows.push(...resultRows(ctx))
+ })
+
+ rows.push(text(ctx, ' every row is a palette id too: /ruflo run dt-diff HEAD~3, /ruflo run dt-brain review my PR', { dimColor: true }))
+
+ return col(ctx, rows, 'devtools')
+}
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 585f47c21c..6aba8d2945 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -11,6 +11,7 @@ import { agentView } from './agent'
import { claimsView } from './claims'
import { ago, button, clip, col, isBbs, row, setLook, text, THEME, type Ctx } from './common'
import { costView } from './cost'
+import { devtoolsView } from './devtools'
import { federationView } from './federation'
import { hiveView } from './hive'
import { learningView } from './learning'
@@ -53,6 +54,7 @@ const BODIES: Record<ViewId, (ctx: Ctx) => RenderElement> = {
xruv: xruvView,
terminal: terminalView,
skills: skillsView,
+ devtools: devtoolsView,
agent: agentView,
}
diff --git a/plugins/ruflo-console/tests/devtools.spec.ts b/plugins/ruflo-console/tests/devtools.spec.ts
new file mode 100644
index 0000000000..a92f0c458c
--- /dev/null
+++ b/plugins/ruflo-console/tests/devtools.spec.ts
@@ -0,0 +1,296 @@
+/**
+ * The Dev Tools view's pure parts under vitest: every entry's argv against the MCP schemas and CLI flags it was checked
+ * with, what asks first and what it says it costs, what each field refuses, and the readers against what `mcp exec`
+ * printed. Run with
+ * npx vitest run plugins/ruflo-console/tests/devtools.spec.ts
+ */
+import { describe, expect, it, vi } from 'vitest'
+
+import { brainLines, devLines, emptyFields, fieldValue, isToolError, unwrap, type DevFields } from '../hooks/data/devtools'
+import { branchPathOf, DEV, DEV_GROUPS, devPalette, devSpec, devtoolsActions, devWhy } from '../hooks/devtools'
+import type { Host } from '../hooks/host'
+import { newState } from '../hooks/state'
+
+/** Each MCP tool's input properties and required ones, as `@claude-flow/cli` 3.51.1 declares them (mcp-tools/*.ts). */
+const SCHEMA: Record<string, { props: readonly string[]; req?: readonly string[] }> = {
+ guidance_brain: { props: ['mode', 'task', 'domain'] },
+ analyze_diff: { props: ['ref', 'includeFileRisks', 'includeReviewers', 'useRuVector'] },
+ 'analyze_diff-stats': { props: ['ref'] },
+ 'analyze_diff-classify': { props: ['ref'] },
+ 'analyze_diff-risk': { props: ['ref'] },
+ 'analyze_diff-reviewers': { props: ['ref', 'limit'] },
+ 'analyze_file-risk': { props: ['path', 'additions', 'deletions', 'status'], req: ['path'] },
+ github_repo_analyze: { props: ['owner', 'repo', 'branch', 'deep'] },
+ github_pr_manage: { props: ['action', 'owner', 'repo', 'prNumber', 'title', 'branch', 'baseBranch', 'body'] },
+ github_issue_track: { props: ['action', 'owner', 'repo', 'issueNumber', 'title', 'body', 'labels', 'assignees'] },
+ github_workflow: { props: ['action', 'owner', 'repo', 'workflowId', 'ref'] },
+ github_metrics: { props: ['owner', 'repo', 'metric', 'timeRange'] },
+ agenticow_status: { props: ['path'], req: ['path'] },
+ agenticow_diff: { props: ['path'], req: ['path'] },
+ agenticow_lineage: { props: ['path'], req: ['path'] },
+ agenticow_checkpoint: { props: ['path', 'label'], req: ['path', 'label'] },
+ agenticow_branch: { props: ['basePath', 'branchPath', 'label', 'dimension', 'nativeAnn'], req: ['basePath', 'branchPath', 'label'] },
+ agenticow_rollback: { props: ['path', 'checkpointId'], req: ['path'] },
+ agenticow_promote: { props: ['branchPath', 'basePath'], req: ['branchPath'] },
+ wasm_gallery_list: { props: [] },
+ wasm_gallery_categories: { props: [] },
+ wasm_gallery_search: { props: ['query'], req: ['query'] },
+ wasm_agent_list: { props: [] },
+ browser_open: { props: ['url', 'session', 'waitUntil', 'args'], req: ['url'] },
+ browser_snapshot: { props: ['session', 'interactive', 'compact', 'depth', 'selector'] },
+ 'browser_get-url': { props: ['session'] },
+ browser_click: { props: ['target', 'session', 'button', 'count'], req: ['target'] },
+ browser_back: { props: ['session'] },
+ browser_screenshot: { props: ['session', 'path', 'fullPage'] },
+ 'browser_session-list': { props: [] },
+ browser_close: { props: ['session'] },
+ terminal_list: { props: ['status', 'includeHistory'] },
+ terminal_history: { props: ['sessionId', 'limit', 'offset'] },
+ terminal_create: { props: ['name', 'workingDir', 'env'] },
+ terminal_execute: { props: ['sessionId', 'command', 'timeout', 'captureOutput'], req: ['command'] },
+ terminal_close: { props: ['sessionId', 'force'], req: ['sessionId'] },
+ 'transfer_plugin-official': { props: [] },
+ 'transfer_plugin-featured': { props: ['limit'] },
+ 'transfer_plugin-search': { props: ['query', 'category', 'type', 'verified', 'minRating', 'limit'] },
+ ruvllm_status: { props: [] },
+ ruvllm_hnsw_create: { props: ['dimensions', 'maxPatterns', 'efSearch'], req: ['dimensions', 'maxPatterns'] },
+ ruvllm_sona_create: { props: ['hiddenDim', 'learningRate', 'patternCapacity'] },
+ ruvllm_microlora_create: { props: ['inputDim', 'outputDim', 'rank', 'alpha'], req: ['inputDim', 'outputDim'] },
+ daa_learning_status: { props: ['agentId', 'detailed'] },
+ daa_performance_metrics: { props: ['category', 'timeRange'] },
+ daa_agent_create: { props: ['id', 'name', 'type', 'cognitivePattern', 'learningRate', 'enableMemory', 'capabilities'], req: ['id'] },
+ daa_agent_adapt: { props: ['agentId', 'feedback', 'performanceScore', 'suggestions'], req: ['agentId'] },
+ daa_workflow_create: { props: ['id', 'name', 'steps', 'strategy', 'dependencies'], req: ['id', 'name'] },
+ daa_knowledge_share: { props: ['sourceAgentId', 'targetAgentIds', 'knowledgeDomain', 'knowledgeContent'], req: ['sourceAgentId', 'targetAgentIds'] },
+ managed_agent_list: { props: ['limit'] },
+ managed_agent_status: { props: ['sessionId'], req: ['sessionId'] },
+ managed_agent_events: { props: ['sessionId', 'raw'], req: ['sessionId'] },
+ managed_agent_create: { props: ['name', 'model', 'system', 'title', 'mcpServers', 'skills', 'packages', 'networking', 'initScript'] },
+ managed_agent_prompt: { props: ['sessionId', 'message', 'maxWaitMs'], req: ['sessionId', 'message'] },
+ managed_agent_terminate: { props: ['sessionId', 'environmentId'], req: ['sessionId'] },
+}
+
+/** The CLI subcommands and flags used, each read from its --help (3.51.1). */
+const COMMANDS: Record<string, readonly string[]> = {
+ 'issues list': [],
+ 'issues board': [],
+ 'deployment status': [],
+ 'deployment history': ['--limit'],
+ 'providers list': [],
+ 'providers test': ['--all'],
+ 'plugins list': ['--installed'],
+ cleanup: ['--force'],
+ 'update check': ['--json'],
+ 'update history': ['--json'],
+ 'update all': [],
+ 'update rollback': [],
+ 'migrate status': [],
+ 'migrate breaking': [],
+ 'migrate run': ['--target'],
+ 'process daemon': ['--action'],
+ 'process workers': ['--action'],
+ 'process logs': ['--tail'],
+ 'appliance inspect': ['-f', '--json'],
+ 'appliance verify': ['-f', '--quick'],
+}
+
+const FULL: DevFields = { ref: 'main..HEAD', path: '.swarm/memory.rvf', label: 'try-1', url: 'https://example.com/a?b=1', target: '@e3', query: 'neural', task: 'review my pull request', cmd: 'git status', id: 'agent-1', note: 'worked well' }
+
+const runnable = DEV.filter(entry => entry.na === undefined)
+
+describe('the Dev Tools catalog', () => {
+ it('every entry has a unique dt- id and a known section; every runnable one builds an argv from filled fields', () => {
+ const ids = DEV.map(entry => entry.id)
+
+ expect(new Set(ids).size).toBe(ids.length)
+ expect(ids.every(id => id.startsWith('dt-'))).toBe(true)
+ expect(DEV.every(entry => DEV_GROUPS.some(group => group.id === entry.group))).toBe(true)
+ expect(DEV_GROUPS.every(group => DEV.some(entry => entry.group === group.id))).toBe(true)
+
+ for (const entry of runnable) expect(devSpec(entry, FULL)?.args, entry.id).toBeDefined()
+ })
+
+ it('every MCP call names a tool and only parameters its schema declares, with its required ones', () => {
+ for (const entry of runnable) {
+ const argv = devSpec(entry, FULL)?.args ?? []
+
+ if (argv[0] !== 'mcp') continue
+
+ expect(argv.slice(0, 3), entry.id).toEqual(['mcp', 'exec', '-t'])
+ expect(argv[4], entry.id).toBe('-p')
+ expect(argv).toHaveLength(6)
+
+ const schema = SCHEMA[argv[3] ?? '']
+ const params = JSON.parse(argv[5] ?? '') as Record<string, unknown>
+
+ expect(schema, `${entry.id}: ${argv[3]}`).toBeDefined()
+ for (const key of Object.keys(params)) expect(schema?.props, `${entry.id} ${key}`).toContain(key)
+ for (const key of schema?.req ?? []) expect(params, `${entry.id} needs ${key}`).toHaveProperty(key)
+ }
+ })
+
+ it('every CLI call is a checked subcommand with checked flags, and nothing reaches a shell', () => {
+ for (const entry of runnable) {
+ const argv = devSpec(entry, FULL)?.args ?? []
+
+ expect(argv.some(word => /^(sh|bash|zsh)$/.test(word)), entry.id).toBe(false)
+ if (argv[0] === 'mcp') continue
+
+ const name = Object.keys(COMMANDS).find(command => argv.join(' ').startsWith(command))
+
+ expect(name, entry.id).toBeDefined()
+ for (const flag of argv.filter(word => word.startsWith('-'))) expect(COMMANDS[name ?? ''], `${entry.id} ${flag}`).toContain(flag)
+ }
+ })
+
+ it('local reads run at once; everything else asks first and says what it does; money and deletes say so loudly', () => {
+ for (const entry of runnable) {
+ const spec = devSpec(entry, FULL)
+
+ expect(spec?.lab, entry.id).toBe(entry.id)
+ expect(spec?.isReadOnly === true, entry.id).toBe(entry.cost === 'read')
+ if (entry.cost !== 'read') expect(spec?.note, entry.id).toBeDefined()
+ if (entry.cost === 'spends') expect(spec?.note, entry.id).toMatch(/^COSTS MONEY/)
+ if (entry.cost === 'network') expect(spec?.note, entry.id).toMatch(/network|API|IPFS|npm|registry/)
+ if (entry.cost === 'deletes') expect(spec?.note, entry.id).toMatch(/DELETES|DISCARDS|ends/)
+ }
+
+ // The GitHub reads call gh over the network: they ask, even though they change nothing.
+ expect(DEV.filter(entry => entry.id.startsWith('dt-gh-')).every(entry => entry.cost === 'network')).toBe(true)
+ // A terminal command runs in a shell: it asks, and the note says so.
+ expect(devSpec(DEV.find(entry => entry.id === 'dt-term-exec')!, FULL)?.note).toMatch(/SHELL COMMAND/)
+ })
+
+ it('n/a rows have a reason and no argv; no key ever reaches an argv', () => {
+ for (const entry of DEV.filter(candidate => candidate.na !== undefined)) {
+ expect(devSpec(entry, FULL), entry.id).toBeNull()
+ expect(devWhy(entry, FULL)).toMatch(/^n\/a: .{20,}/)
+ }
+
+ for (const entry of runnable) expect((devSpec(entry, FULL)?.args ?? []).some(word => /^(-k|--key|--api-key)$/.test(word)), entry.id).toBe(false)
+ // Kebab flags the 3.51.1 parser hands over camelCased and these commands then read kebab: never passed, never trusted.
+ for (const entry of runnable) expect((devSpec(entry, FULL)?.args ?? []).some(word => word === '--dry-run' || word === '--keep-config'), entry.id).toBe(false)
+ })
+
+ it('a branch sits beside its base; an empty field blocks the entry and names the field', () => {
+ expect(branchPathOf('.swarm/memory.rvf', 'try')).toBe('.swarm/memory-try.rvf')
+ expect(branchPathOf('data/mem', 'x')).toBe('data/mem-x.rvf')
+
+ const fields = emptyFields()
+ const checkpoint = DEV.find(entry => entry.id === 'dt-cow-checkpoint')!
+
+ expect(devSpec(checkpoint, fields)).toBeNull()
+ expect(devWhy(checkpoint, fields)).toMatch(/^path field: /)
+ expect(devSpec(DEV.find(entry => entry.id === 'dt-diff-stats')!, fields)?.args).toEqual(['mcp', 'exec', '-t', 'analyze_diff-stats', '-p', '{"ref":"HEAD"}'])
+ })
+})
+
+describe('the fields', () => {
+ it('refuse what could read as a flag, control characters, and over-long text', () => {
+ for (const field of ['ref', 'path', 'label', 'query', 'task', 'cmd', 'id', 'note'] as const) {
+ expect(fieldValue(field, '-rf'), field).toBeNull()
+ expect(fieldValue(field, '--help'), field).toBeNull()
+ expect(fieldValue(field, 'a\nb'), field).toBeNull()
+ expect(fieldValue(field, 'a\u0000b'), field).toBeNull()
+ expect(fieldValue(field, 'x'.repeat(400)), field).toBeNull()
+ expect(fieldValue(field, ''), field).toBeNull()
+ }
+ })
+
+ it('a path stays under the project; a URL is http(s); a target is a snapshot ref', () => {
+ expect(fieldValue('path', '.swarm/memory.rvf')).toBe('.swarm/memory.rvf')
+ expect(fieldValue('path', '../etc/passwd')).toBeNull()
+ expect(fieldValue('path', 'a/../../b')).toBeNull()
+ expect(fieldValue('path', '/etc/passwd')).toBeNull()
+ expect(fieldValue('path', 'a//b')).toBeNull()
+ expect(fieldValue('url', 'https://example.com/x?y=1')).toBe('https://example.com/x?y=1')
+ expect(fieldValue('url', 'javascript:alert(1)')).toBeNull()
+ expect(fieldValue('url', 'file:///etc/passwd')).toBeNull()
+ expect(fieldValue('url', 'https://a b')).toBeNull()
+ expect(fieldValue('target', '@e12')).toBe('@e12')
+ expect(fieldValue('target', 'button.submit')).toBeNull()
+ expect(fieldValue('ref', 'HEAD~3')).toBe('HEAD~3')
+ expect(fieldValue('ref', 'main..HEAD')).toBe('main..HEAD')
+ expect(fieldValue('ref', 'HEAD; rm -rf')).toBeNull()
+ expect(fieldValue('cmd', ' npm test -- --watch=false ')).toBe('npm test -- --watch=false')
+ })
+})
+
+const wrapped = (inner: unknown, isError = false) => `[INFO] Executing tool: x\n[OK] Tool executed in 6ms\nResult:\n${JSON.stringify({ content: [{ type: 'text', text: JSON.stringify(inner, null, 2) }], ...(isError && { isError: true }) }, null, 2)}\n`
+
+describe('reading what the CLI printed', () => {
+ it('unwraps mcp exec content, plain JSON, and says when the tool failed though the CLI exited 0', () => {
+ expect(unwrap(wrapped({ agents: [], count: 0 }))).toEqual({ value: { agents: [], count: 0 }, isError: false })
+ expect(unwrap('Result:\n{\n "ref": "HEAD",\n "totalFiles": 1\n}\n')).toEqual({ value: { ref: 'HEAD', totalFiles: 1 }, isError: false })
+ expect(unwrap('no json here')).toBeNull()
+ expect(isToolError(wrapped({ error: 'Error: Failed to initialize @ruvector/rvagent-wasm' }, true))).toBe(true)
+ expect(isToolError('Result:\n{\n "success": false,\n "error": "gh not found"\n}\n')).toBe(true)
+ expect(isToolError(wrapped({ agents: [] }))).toBe(false)
+ })
+
+ it('a wrapped error reads as one ✗ line; a wrapped answer as its fields', () => {
+ expect(devLines('dt-wasm-gallery', wrapped({ error: 'Error: Failed to initialize @ruvector/rvagent-wasm' }, true))).toEqual(['✗ Error: Failed to initialize @ruvector/rvagent-wasm'])
+ expect(devLines('dt-llm-status', wrapped({ wasm: { available: false }, native: { available: true, coordinator: 'active' } }))).toEqual(['wasm:', 'available: false', 'native:', 'available: true', 'coordinator: active'])
+ expect(devLines('dt-diff-stats', 'Result:\n{\n "ref": "HEAD",\n "totalFiles": 1,\n "totalAdditions": 1\n}\n')).toEqual(['ref: HEAD', 'totalFiles: 1', 'totalAdditions: 1'])
+ expect(devLines('dt-prov-list', '\nProviders\n───\nanthropic Configured (env)\n')).toEqual(['Providers', 'anthropic Configured (env)'])
+ })
+
+ it('the brain: each domain with its tools and risk, then the loop and its guardrails', () => {
+ const brain = {
+ task: 'review my pull request',
+ domains: [{ id: 'analysis-quality', name: 'Analysis & Quality', score: 1, registeredTools: ['analyze_diff', 'analyze_diff-risk'], authority: 'advisory', risk: 'read-only' }],
+ implementationLoop: [{ id: 'recall', name: 'Recall', preferredTools: ['memory_search', 'guidance_brain'] }, { id: 'publish', name: 'Publish', preferredTools: [] }],
+ guardrails: ['Ruflo coordinates and records; the executor performs implementation.'],
+ }
+
+ expect(brainLines(brain)).toEqual([
+ 'for: review my pull request',
+ '▸ Analysis & Quality · read-only · advisory',
+ ' tools: analyze_diff, analyze_diff-risk',
+ 'then the loop:',
+ ' Recall memory_search, guidance_brain',
+ ' Publish —',
+ '! Ruflo coordinates and records; the executor performs implementation.',
+ ])
+ expect(devLines('dt-brain', wrapped(brain))[1]).toBe('▸ Analysis & Quality · read-only · advisory')
+ expect(brainLines({ task: 'zzz', domains: [] })).toEqual(['for: zzz', 'no capability domain matched: try other words'])
+ })
+})
+
+describe('headless and the fields', () => {
+ it('a field entry is a text entry keyed by its id; its text fills the field before it builds the argv', () => {
+ const state = newState({})
+ const entries = devPalette(state)
+ const diff = entries.find(entry => entry.id === 'dt-diff-stats')
+
+ expect(entries.some(entry => entry.id === 'dt-wasm-agent')).toBe(false)
+ expect(diff?.run.kind).toBe('text')
+ if (diff?.run.kind !== 'text') return
+ expect(diff.run.keyword).toBe('dt-diff-stats')
+ expect(diff.run.make('HEAD~2')?.args).toEqual(['mcp', 'exec', '-t', 'analyze_diff-stats', '-p', '{"ref":"HEAD~2"}'])
+ expect(state.devtools.fields.ref).toBe('HEAD~2')
+ // An empty text uses what the field holds: the view's button press.
+ expect(diff.run.make('')?.args[5]).toBe('{"ref":"HEAD~2"}')
+ expect(entries.find(entry => entry.id === 'dt-prov-list')?.run).toMatchObject({ kind: 'spec', spec: { args: ['providers', 'list'], isReadOnly: true } })
+ })
+
+ it('Enter in a field keeps its text and runs its entry, or says the rule; a field with no entry only keeps it', () => {
+ const state = newState({})
+ const host = { invalidate: vi.fn() } as unknown as Host
+ const run = vi.fn(() => true)
+ const refuse = vi.fn()
+ const actions = devtoolsActions(state, host, run, refuse)
+
+ actions.submit('task', 'add OAuth login')
+ expect(run).toHaveBeenCalledWith('dt-brain', '')
+ expect(state.devtools.fields.task).toBe('add OAuth login')
+
+ actions.submit('url', 'javascript:alert(1)')
+ expect(refuse).toHaveBeenCalledWith(expect.stringMatching(/^url field: /))
+ expect(run).toHaveBeenCalledTimes(1)
+
+ actions.submit('label', 'try-1')
+ expect(run).toHaveBeenCalledTimes(1)
+ expect(state.devtools.fields.label).toBe('try-1')
+ })
+})
diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts
index 39a1187e2b..2f283977cc 100644
--- a/plugins/ruflo-console/tests/views.test.ts
+++ b/plugins/ruflo-console/tests/views.test.ts
@@ -369,4 +369,67 @@ describe('views', () => {
expect(textOf(await pane.drawn())).toContain('no area "nope"')
await pane.unmount()
})
+
+ test('devtools: every section with its fields and rows; drawing it runs nothing', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+
+ const { text, tree } = await drawn($, 'devtools')
+
+ for (const title of ['CAPABILITY BRAIN', 'ANALYZE · GIT DIFF', 'GITHUB & DELIVERY', 'AGENTICOW', 'WASM AGENTS', 'BROWSER', 'TERMINAL SESSIONS', 'PROVIDERS', 'PLUGIN REGISTRY', 'RUVLLM', 'DAA', 'MANAGED AGENTS', 'MAINTENANCE']) expect(text.toUpperCase()).toContain(title)
+ expect(text).toMatch(/ net \n PULL REQUESTS \.+/)
+ expect(text).toContain(' n/a ')
+ expect(text).toContain('nothing run yet')
+ expect(elementsOf(tree, 'Input').map(keyOf)).toEqual(expect.arrayContaining(['dt-field-brain-task', 'dt-field-analyze-ref', 'dt-field-browser-url', 'dt-field-terminal-cmd']))
+ expect(elementsOf(tree, 'Button').map(keyOf)).toEqual(expect.arrayContaining(['dt-diff-stats', 'dt-gh-prs', 'dt-term-exec', 'dt-cleanup-force']))
+ expect(world.runs.some(argv => /analyze_|github_|browser_|terminal_|guidance_|agenticow_|wasm_|managed_|daa_|ruvllm_|transfer_|providers|cleanup|update|migrate|appliance/.test(argv.join(' ')))).toBe(false)
+ })
+
+ test('devtools: a diff read runs at once with one fixed argv; a GitHub read asks first, runs nothing on no and one argv on yes', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ const STATS = 'Result:\n{\n "ref": "HEAD",\n "totalFiles": 3,\n "totalAdditions": 12\n}\n'
+ world.respond = argv => (argv.includes('analyze_diff-stats') ? { exitCode: 0, stdout: STATS, stderr: '' } : cliAnswer(argv))
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('devtools'))
+
+ const pane = await $.ui.mount({ ...paneAt(110), plugin: PLUGIN })
+ const runsOf = (word: string) => world.runs.filter(argv => argv.join(' ').includes(word)).map(argv => argv.slice(4))
+
+ await pane.press({ key: 'dt-diff-stats' })
+ let text = textOf(await pane.drawn())
+ expect(text).not.toContain('Confirm:')
+ expect(text).toContain('totalFiles: 3')
+ expect(runsOf('analyze_diff-stats')).toEqual([['mcp', 'exec', '-t', 'analyze_diff-stats', '-p', '{"ref":"HEAD"}']])
+
+ await pane.press({ key: 'dt-gh-prs' })
+ text = textOf(await pane.drawn())
+ expect(text).toContain('Confirm: list pull requests?')
+ expect(text).toContain('runs: ruflo mcp exec -t github_pr_manage -p {"action":"list"}')
+ expect(text).toContain('gh CLI in this repo: it reads GitHub over the network')
+ await pane.press({ key: 'cancel' })
+ expect(runsOf('github_')).toHaveLength(0)
+
+ await pane.press({ key: 'dt-gh-prs' })
+ await pane.press({ key: 'confirm' })
+ expect(runsOf('github_')).toEqual([['mcp', 'exec', '-t', 'github_pr_manage', '-p', '{"action":"list"}']])
+ await pane.unmount()
+ })
+
+ test('devtools headless: a terminal command asks with the command shown, runs once on yes; a wrapped tool error reads ✗', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ const FAILED = 'Result:\n' + JSON.stringify({ content: [{ type: 'text', text: JSON.stringify({ error: 'Error: Failed to initialize @ruvector/rvagent-wasm' }) }], isError: true })
+ world.respond = argv => (argv.includes('wasm_gallery_list') ? { exitCode: 0, stdout: FAILED, stderr: '' } : cliAnswer(argv))
+ mock.clock(on)
+ await $.session.start({ ...SESSION, isInteractive: false })
+
+ expect((await $.command.run(command('run dt-term-exec git status'))).text).toBe('Asked: run the command in a ruflo terminal. Confirm with /ruflo yes (or y in the pane), cancel with /ruflo no.')
+ expect(world.runs.some(argv => argv.includes('terminal_execute'))).toBe(false)
+ await $.command.run(command('yes'))
+ expect(world.runs.filter(argv => argv.includes('terminal_execute')).map(argv => argv.slice(4))).toEqual([['mcp', 'exec', '-t', 'terminal_execute', '-p', '{"command":"git status"}']])
+
+ expect((await $.command.run(command('run dt-wasm-gallery'))).text).toBe('✗ WASM gallery: the templates · exit 0\n ✗ Error: Failed to initialize @ruvector/rvagent-wasm')
+ expect((await $.command.run(command('run dt-br-open javascript:alert(1)'))).text).toMatch(/^nothing to do: type "dt-br-open <text>"/)
+ })
})