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): Security & Doctor and Dev Tools fold into sections whose headers carry their state

ruvf0490ea9a308
diff --git a/plugins/ruflo-console/hooks/views/devtools.ts b/plugins/ruflo-console/hooks/views/devtools.ts
index 0188784a1f..e7f4ae9836 100644
--- a/plugins/ruflo-console/hooks/views/devtools.ts
+++ b/plugins/ruflo-console/hooks/views/devtools.ts
@@ -3,7 +3,8 @@ 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 { slot } from './attention'
-import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
+import { ago, button, clip, col, row, section, text, THEME, type Ctx } from './common'
+import { spinAt } from '../spinner'
/** Result lines in view at once; j/k scroll the rest. */
const RESULT_ROWS = 14
@@ -79,15 +80,23 @@ function fieldRows(ctx: Ctx, group: DevGroup): RenderElement[] {
)
}
+/** The Result section's header: a running run with its seconds and spinner, the last exit, or that nothing ran yet. */
+function resultRight(ctx: Ctx): string {
+ 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
+
+ return running !== null ? `${spinAt(nowMs)} running ${Math.round((nowMs - running.startedAtMs) / 1000)}s` : result === null ? 'nothing run yet' : `${result.ok ? '✓' : '✗'} exit ${result.exitCode ?? 'n/a'} · ${ago(result.atMs, nowMs)}`
+}
+
/** 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)]
+ const rows: RenderElement[] = []
- if (running !== null) rows.push(text(ctx, ` ▸ ${running.label} … ${Math.floor(nowMs / 500) % 2 === 0 ? '█' : ' '}`, { color: THEME.warn }))
+ if (running !== null) rows.push(text(ctx, ` ${spinAt(nowMs)} ${running.label} · ${Math.round((nowMs - running.startedAtMs) / 1000)}s`, { 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 }))
@@ -116,23 +125,23 @@ function resultRows(ctx: Ctx): RenderElement[] {
}
/**
- * 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.
+ * ruflo's integration surface by purpose: each group a section with its fields and rows, the first open and the rest folded
+ * (each header names its count and cost), and the last run's output in a section of its own, open while a run is in flight or has
+ * finished. Drawing it runs nothing; every row is a press.
*/
export function devtoolsView(ctx: Ctx): RenderElement {
+ const { state } = ctx
const lead = Math.max(16, Math.min(24, ctx.columns - 44))
+ const hasRun = state.lab.running?.id.startsWith('dt-') === true || state.lab.result?.id.startsWith('dt-') === true
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))
+ const entries = DEV.filter(candidate => candidate.group === group.id)
- // 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(...section(ctx, `dt-${group.id}`, group.title, `${entries.length} · ${group.right}`, [...fieldRows(ctx, group.id), ...entries.map(entry => entryRow(ctx, entry, lead))], i === 0))
})
+ rows.push(...section(ctx, 'dt-result', 'Result', resultRight(ctx), resultRows(ctx), hasRun))
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/secure.ts b/plugins/ruflo-console/hooks/views/secure.ts
index a884f13c99..6b6cb41392 100644
--- a/plugins/ruflo-console/hooks/views/secure.ts
+++ b/plugins/ruflo-console/hooks/views/secure.ts
@@ -3,7 +3,7 @@ import type { RenderElement } from 'claude-code'
import { DOCTOR_COMPONENTS, isSecureResult, SECURE, SECURE_TEXT, secMemo, SEVERITIES, type SecCost, type Severity } from '../secure'
import { slot } from './attention'
import { spinAt } from '../spinner'
-import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
+import { ago, button, clip, col, row, rule, section, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
export const RESULT_ROWS = 14
@@ -83,7 +83,7 @@ const SEVERITY_COLOR: Record<Severity, () => string> = { critical: () => THEME.b
/** The last findings by severity as bars, each scaled to the largest count. */
export function meterRows(ctx: Ctx): RenderElement[] {
const findings = secMemo(ctx.state).findings
- const rows: RenderElement[] = [rule(ctx, 'Findings', findings === null ? 'none measured yet' : `${findings.source} · ${ago(findings.atMs, ctx.nowMs)}`)]
+ const rows: RenderElement[] = []
if (findings === null) {
rows.push(text(ctx, ' â–¸ a scan, a channel/plan check or a paste check fills this meter with its findings by severity', { dimColor: true }))
@@ -113,7 +113,7 @@ export function meterRows(ctx: Ctx): RenderElement[] {
/** The paste field: Enter runs the local check at once; the buttons run the other checks on the same text. */
function pasteRows(ctx: Ctx): RenderElement[] {
const memo = secMemo(ctx.state)
- const rows: RenderElement[] = [rule(ctx, 'Check text', 'AIDefence · injection, jailbreak, PII · policy')]
+ const rows: RenderElement[] = []
if (ctx.kit.Input !== undefined) {
rows.push(
@@ -145,7 +145,7 @@ function pasteRows(ctx: Ctx): RenderElement[] {
/** The doctor: the full run and --fix, one button per local component, then the last run's checks as ✓/⚠/✗ rows. */
function doctorRows(ctx: Ctx): RenderElement[] {
const doctor = secMemo(ctx.state).doctor
- const rows: RenderElement[] = [rule(ctx, 'Doctor', doctor === null ? 'not run yet' : `${doctor.label} · ${ago(doctor.atMs, ctx.nowMs)}`)]
+ const rows: RenderElement[] = []
for (const entry of SECURE.filter(candidate => candidate.id === 'doc-all' || candidate.id === 'doc-fix')) rows.push(entryRow(ctx, entry))
@@ -188,13 +188,45 @@ function doctorRows(ctx: Ctx): RenderElement[] {
* checks, and the last run's output. Nothing runs on open; a $0 read runs on its button, the rest ask first.
*/
export function secureView(ctx: Ctx): RenderElement {
- const rows: RenderElement[] = [...meterRows(ctx), ...pasteRows(ctx), rule(ctx, 'Scan & inspect', 'scans are local; npm audit is the network')]
-
- for (const entry of SECURE.filter(candidate => candidate.group === 'scan')) rows.push(entryRow(ctx, entry))
- rows.push(naRow(ctx, 'VALIDATE', 'no `security validate` in the CLI: the check text field above is the input check'))
- rows.push(naRow(ctx, 'REPORT', 'no `security report` in the CLI: a scan writes .claude/security-scans/<scan>.json'))
- rows.push(text(ctx, COST_KEY, { dimColor: true }))
- rows.push(...doctorRows(ctx), ...resultRows(ctx, isSecureResult))
+ const { state, nowMs } = ctx
+ const memo = secMemo(state)
+ const findings = memo.findings
+ const doctor = memo.doctor
+ const running = state.lab.running !== null && isSecureResult(state.lab.running.id) ? state.lab.running : null
+ const doctorBusy = running !== null && running.id.startsWith('doc-')
+ const scanBusy = running !== null && !doctorBusy
+ const fails = doctor === null ? 0 : doctor.checks.filter(check => check.status === 'fail').length
+ const warns = doctor === null ? 0 : doctor.checks.filter(check => check.status === 'warn').length
+ const scanRows: RenderElement[] = [
+ ...SECURE.filter(candidate => candidate.group === 'scan').map(entry => entryRow(ctx, entry)),
+ naRow(ctx, 'VALIDATE', 'no `security validate` in the CLI: the check text field above is the input check'),
+ naRow(ctx, 'REPORT', 'no `security report` in the CLI: a scan writes .claude/security-scans/<scan>.json'),
+ text(ctx, COST_KEY, { dimColor: true }),
+ ]
+
+ // Each part is a section. The findings are open; the check field and the scans fold; the doctor opens when a check failed or
+ // warned, or while it runs. Each header names its state, so the page reads without opening anything.
+ const rows: RenderElement[] = [
+ ...section(
+ ctx,
+ 'sec-findings',
+ 'Findings',
+ findings === null ? 'none measured yet' : `${SEVERITIES.map(level => `${findings.counts[level]} ${level}`).join(' · ')} · ${ago(findings.atMs, nowMs)}`,
+ meterRows(ctx),
+ true,
+ ),
+ ...section(ctx, 'sec-check', 'Check text', 'AIDefence · injection, jailbreak, PII · policy', pasteRows(ctx), false),
+ ...section(ctx, 'sec-scan', 'Scan & inspect', scanBusy ? `${spinAt(nowMs)} ${running?.label ?? 'scanning'}` : 'scans are local; npm audit is the network', scanRows, scanBusy),
+ ...section(
+ ctx,
+ 'sec-doctor',
+ 'Doctor',
+ doctor === null ? 'not run yet' : `${doctor.label} · ${fails} failed · ${warns} warnings · ${ago(doctor.atMs, nowMs)}`,
+ doctorRows(ctx),
+ doctorBusy || fails > 0 || warns > 0,
+ ),
+ ...resultRows(ctx, isSecureResult),
+ ]
return col(ctx, rows, 'secure')
}