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-workflows): function-hook mod (guard, status file, local slash command)

ruv6d3aef01e870
diff --git a/plugins/ruflo-workflows/.claude-plugin/plugin.json b/plugins/ruflo-workflows/.claude-plugin/plugin.json
index 8b61cc4e8d..ad4d157f2b 100644
--- a/plugins/ruflo-workflows/.claude-plugin/plugin.json
+++ b/plugins/ruflo-workflows/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-workflows",
"description": "Workflow automation across two surfaces: the 10 workflow_* MCP tools (create/run/execute/status/list/pause/resume/cancel/delete/template) with full state-machine lifecycle (created β†’ running ↔ paused β†’ completed/cancelled), and native Claude Code Workflow JS orchestration (.claude/workflows/*.js β€” agent/parallel/pipeline/phase fan-out). Includes GAIA benchmark component for Princeton HAL leaderboard submissions.",
- "version": "0.5.1",
+ "version": "0.6.0",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
@@ -26,7 +26,9 @@
"benchmark",
"hal-leaderboard",
"evaluation",
- "agent-benchmark"
+ "agent-benchmark",
+ "function-hooks",
+ "guard"
],
"components": {
"gaia": {
@@ -50,8 +52,15 @@
"gaia-submission-coordinator"
],
"cli_backend": "@claude-flow/cli gaia-bench",
- "scripts": ["scripts/gaia-audit.mjs"],
- "adrs": ["ADR-133", "ADR-135", "ADR-136", "ADR-167"],
+ "scripts": [
+ "scripts/gaia-audit.mjs"
+ ],
+ "adrs": [
+ "ADR-133",
+ "ADR-135",
+ "ADR-136",
+ "ADR-167"
+ ],
"memory_namespaces": [
"gaia-runs",
"gaia-submissions",
@@ -62,10 +71,31 @@
"native_workflows": {
"description": "Native Claude Code Workflow JS orchestration β€” deterministic subagent fan-out via agent/parallel/pipeline/phase, authored as .claude/workflows/*.js named workflows",
"location": ".claude/workflows/*.js",
- "api": ["agent", "parallel", "pipeline", "phase", "log"],
+ "api": [
+ "agent",
+ "parallel",
+ "pipeline",
+ "phase",
+ "log"
+ ],
"invocation": "Workflow tool β€” Workflow({ name }) | Workflow({ scriptPath }) | Workflow({ resumeFromRunId })",
"reference_workflow": ".claude/workflows/plugin-contract-audit.js",
- "adrs": ["ADR-0002"]
+ "adrs": [
+ "ADR-0002"
+ ]
+ }
+ },
+ "userConfig": {
+ "guard": {
+ "type": "string",
+ "title": "Secret guard",
+ "description": "Refuse workflow definitions and run records that hold a secret, and workflow deletes that name no single id.",
+ "required": false,
+ "default": "on",
+ "options": [
+ "on",
+ "off"
+ ]
}
}
}
diff --git a/plugins/ruflo-workflows/README.md b/plugins/ruflo-workflows/README.md
index 9052d52081..f6d8732a63 100644
--- a/plugins/ruflo-workflows/README.md
+++ b/plugins/ruflo-workflows/README.md
@@ -146,3 +146,14 @@ bash plugins/ruflo-workflows/scripts/smoke.sh
- `ruflo-agentdb` β€” namespace convention owner
- `ruflo-loop-workers` β€” sibling automation surface (loops are recurring; workflows are stateful pipelines)
- `ruflo-sparc` β€” SPARC phase transitions can be modeled as workflows
+
+## As a mod
+
+This plugin also loads as a function-hook mod (ADR-445 pattern, `hooks/hooks.json` β†’ `register.ts`). No network, no process spawn, no model call.
+
+- **Guard (default on, tighten-only).** It refuses a workflow definition, run or `gaia*`/`workflow*` memory record that holds a secret, and a `workflow_delete` that names no single workflow id (empty, `*`, `all`). The refusal never repeats the secret.
+- **Status file.** `.claude-flow/wf-mod/status.json` (`{version: 1, updatedMs, guard, checked, blocked, seen}`), written at session start and when a counter changes.
+- **`/wf-mod`** answers locally: `status`, `scan <text>`, `lifecycle`. (The plugin's own commands are prompt commands, which a hook cannot answer, so the mod has its own name.)
+- **Option.** `guard` (`on` | `off`, default `on`) in the plugin's `userConfig`.
+
+Test it: `claude plugin validate plugins/ruflo-workflows`, `claude plugin test plugins/ruflo-workflows`, `bash plugins/ruflo-workflows/scripts/smoke.sh`.
diff --git a/plugins/ruflo-workflows/hooks/command.ts b/plugins/ruflo-workflows/hooks/command.ts
new file mode 100644
index 0000000000..6aeffe6844
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/command.ts
@@ -0,0 +1,31 @@
+import { secretsIn } from './screen'
+import type { ModOptions } from './options'
+import type { Stats } from './status'
+
+/** `/wf-mod` is answered locally and takes no model turn. */
+export type CommandDeps = { readonly opts: ModOptions; readonly stats: Stats; readonly tools: () => Promise<readonly string[]> }
+
+const HELP = ['/wf-mod status', '/wf-mod scan <text>', '/wf-mod lifecycle'].join('\n')
+
+export async function answer(args: string, deps: CommandDeps): Promise<string> {
+ const [verb = '', ...rest] = args.trim().split(/\s+/)
+ const arg = rest.join(' ')
+ const { opts, stats } = deps
+
+ if (verb === '' || verb === 'help') return HELP
+
+ if (verb === 'status') {
+ const seen = Object.entries(stats.seen).map(([k, n]) => `${k} ${n}`).join(' Β· ')
+ return [`guard ${opts.guard ? 'on' : 'off'} Β· checked ${stats.checked} Β· blocked ${stats.blocked}`, seen === '' ? 'no workflow calls this session' : seen].join('\n')
+ }
+
+ if (verb === 'scan') {
+ if (arg === '') return 'usage: /wf-mod scan <text>'
+ const found = secretsIn(arg)
+ return found.length ? `The guard would refuse that (looks like: ${found.join(', ')}).` : 'Nothing found: the guard would let that through.'
+ }
+
+ if (verb === 'lifecycle') return 'created -> running <-> paused -> completed | cancelled. Delete refuses a running workflow, and this mod refuses a delete that names no single id.'
+
+ return `Unknown: ${verb}\n${HELP}`
+}
diff --git a/plugins/ruflo-workflows/hooks/guard.ts b/plugins/ruflo-workflows/hooks/guard.ts
new file mode 100644
index 0000000000..335e9ad268
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/guard.ts
@@ -0,0 +1,50 @@
+import { hasSecret } from './screen'
+
+/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
+export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
+ if (budget.left <= 0 || depth > 6) return []
+ if (typeof input === 'string') {
+ budget.left -= input.length
+ return [input]
+ }
+ if (Array.isArray(input)) return input.slice(0, 200).flatMap(v => textsOf(v, budget, depth + 1))
+ if (typeof input === 'object' && input !== null) return Object.values(input).slice(0, 200).flatMap(v => textsOf(v, budget, depth + 1))
+ return []
+}
+
+/** The tool's short name: `mcp__<server>__<tool>` to `<tool>`. */
+export const shortName = (name: string) => (name.startsWith('mcp__') && name.lastIndexOf('__') > 5 ? name.slice(name.lastIndexOf('__') + 2) : name)
+
+const field = (input: unknown, key: string): string => {
+ const v = typeof input === 'object' && input !== null ? (input as Record<string, unknown>)[key] : undefined
+ return typeof v === 'string' ? v : ''
+}
+
+const FLOW = new Set(['workflow_create', 'workflow_run', 'workflow_execute', 'workflow_template'])
+const MEMORY = new Set(['memory_store', 'agentdb_hierarchical-store', 'agentdb_pattern-store'])
+const NS = /^(?:gaia|workflow)/i
+// An id that stands for many workflows, or for none.
+const BROAD = /^(?:\*|all|\.|\.\.|%|\.\*)?$/i
+
+/** The label of a workflow call, else undefined: the guard only watches workflow tools and gaia/workflow memory writes. */
+export function watched(tool: string, input: unknown): string | undefined {
+ const t = shortName(tool)
+ if (t === 'workflow_delete') return 'workflow delete'
+ if (FLOW.has(t)) return t.replace('_', ' ')
+ if (MEMORY.has(t) && NS.test(field(input, 'namespace'))) return 'gaia/workflow memory write'
+ return undefined
+}
+
+/** The reason a call is refused, or undefined when it may go. Never names or echoes the secret. */
+export function verdict(tool: string, input: unknown): string | undefined {
+ const label = watched(tool, input)
+ if (label === undefined) return undefined
+ if (label === 'workflow delete') {
+ return BROAD.test(field(input, 'workflowId').trim())
+ ? 'ruflo-workflows: a delete must name one workflow id. List the workflows and delete a specific one.'
+ : undefined
+ }
+ return textsOf(input).some(hasSecret)
+ ? 'ruflo-workflows: this workflow or run record holds what looks like a secret (a key, token or password). Reference the secret by name and keep its value in the environment.'
+ : undefined
+}
diff --git a/plugins/ruflo-workflows/hooks/hooks.json b/plugins/ruflo-workflows/hooks/hooks.json
new file mode 100644
index 0000000000..e3727a423f
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/hooks.json
@@ -0,0 +1,6 @@
+{
+ "description": "Workflows as a mod (ADR-445 pattern): a guard that keeps secrets out of workflow definitions and GAIA run records, and refuses a workflow delete that names no single workflow, `/wf-mod`, and a status file the console reads.",
+ "modules": [
+ "./register.ts"
+ ]
+}
diff --git a/plugins/ruflo-workflows/hooks/options.ts b/plugins/ruflo-workflows/hooks/options.ts
new file mode 100644
index 0000000000..a5d4812327
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/options.ts
@@ -0,0 +1,11 @@
+import type { PluginOptions } from 'claude-code'
+
+/** The plugin's `userConfig`, validated: a bad value is the default (guard on). */
+export type ModOptions = { readonly guard: boolean }
+
+const flag = (value: unknown, fallback: boolean) =>
+ value === true || value === 'true' || value === 'on' ? true : value === false || value === 'false' || value === 'off' ? false : fallback
+
+export function readOptions(options: PluginOptions | undefined): ModOptions {
+ return { guard: flag((options ?? {}).guard, true) }
+}
diff --git a/plugins/ruflo-workflows/hooks/register.ts b/plugins/ruflo-workflows/hooks/register.ts
new file mode 100644
index 0000000000..d165680fb8
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/register.ts
@@ -0,0 +1,60 @@
+import type { Hook, Register } from 'claude-code'
+
+import { answer } from './command'
+import { verdict, watched } from './guard'
+import { readOptions, type ModOptions } from './options'
+import { newStats, STATUS_PATH, statusText, type Stats } from './status'
+
+type Dollar = Parameters<Hook<'session.start'>>[0]
+
+/** Everything one session of the mod keeps: its settings, its counters and the project root. */
+type Session = { readonly opts: ModOptions; readonly stats: Stats; root?: string }
+
+async function flush($: Dollar, s: Session): Promise<void> {
+ if (s.root === undefined) return
+ try {
+ await $.fs.write(`${s.root}/${STATUS_PATH}`, statusText(s.stats, s.opts, await $.clock.now()))
+ } catch {
+ /* the status file is a courtesy */
+ }
+}
+
+/**
+ * Workflows as a mod (ADR-445 pattern): a guard that keeps secrets out of workflow definitions and GAIA run records, and refuses a workflow delete that names no single workflow, `/wf-mod`, and a status file the console reads. No network, no process: only tools already connected.
+ */
+export const register: Register = (on, options) => {
+ const s: Session = { opts: readOptions(options), stats: newStats() }
+
+ on('session.start', async ($, e, next) => {
+ const result = await next(e)
+ s.root = (await $.session.root()) as string | undefined
+ try {
+ await $.command.register({ name: 'wf-mod', description: 'Workflows mod: status, scan <text>, lifecycle' })
+ } catch {
+ /* a name taken by another plugin must not stop the mod */
+ }
+ await flush($, s)
+ return result
+ })
+
+ // Tighten-only: a deny, or the event unchanged. Only this plugin's own tools are looked at.
+ on('tool.call', async ($, e, next) => {
+ const label = watched(e.tool, e)
+ if (label === undefined) return next(e)
+ s.stats.checked++
+ s.stats.seen[label] = (s.stats.seen[label] ?? 0) + 1
+ const reason = s.opts.guard ? verdict(e.tool, e) : undefined
+ if (reason !== undefined) {
+ s.stats.blocked++
+ s.stats.lastReason = reason.slice(0, 160)
+ }
+ await flush($, s)
+ return reason === undefined ? next(e) : { deny: reason }
+ })
+
+ /** `/wf-mod` (the plugin's own commands are prompt commands, which no hook can answer). */
+ on('command.run', { command: 'wf-mod' }, async ($, e) => {
+ const args = typeof e.args === 'string' ? e.args : ''
+ return { text: await answer(args, { opts: s.opts, stats: s.stats, tools: async () => (await $.tool.list()).map(t => t.name) }) }
+ })
+}
diff --git a/plugins/ruflo-workflows/hooks/screen.ts b/plugins/ruflo-workflows/hooks/screen.ts
new file mode 100644
index 0000000000..324cd0dd7b
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/screen.ts
@@ -0,0 +1,29 @@
+/**
+ * Secret screening for the Workflows mod (copied from the ADR-445 AgentDB screen). Findings are NAMES only: the matched text is never
+ * returned, logged or counted by value.
+ */
+
+const SECRETS: readonly (readonly [string, RegExp])[] = [
+ ['private key', /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
+ ['aws access key', /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/],
+ ['github token', /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{40,})\b/],
+ ['slack token', /\bxox[abprs]-[A-Za-z0-9-]{10,}/],
+ ['google api key', /\bAIza[0-9A-Za-z_-]{35}\b/],
+ ['anthropic or openai key', /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{24,}/],
+ ['jwt', /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],
+ ['bearer token', /\bBearer\s+[A-Za-z0-9._~+/=-]{24,}/],
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+const INVISIBLE = new RegExp('[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2060-\\u2064\\ufeff]', 'g')
+
+const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => {
+ const bounded = bare(text)
+ return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+}
+
+export const hasSecret = (text: string) => secretsIn(text).length > 0
diff --git a/plugins/ruflo-workflows/hooks/status.ts b/plugins/ruflo-workflows/hooks/status.ts
new file mode 100644
index 0000000000..1a7bc1db11
--- /dev/null
+++ b/plugins/ruflo-workflows/hooks/status.ts
@@ -0,0 +1,11 @@
+/** Counters the mod keeps for the session and writes to `.claude-flow/wf-mod/status.json` for the console. */
+export type Stats = { checked: number; blocked: number; seen: Record<string, number>; lastReason?: string }
+
+export const newStats = (): Stats => ({ checked: 0, blocked: 0, seen: {} })
+
+export const STATUS_PATH = '.claude-flow/wf-mod/status.json'
+
+/** The file's text; `version` lets the console refuse a shape it does not know. */
+export function statusText(stats: Stats, mode: { guard: boolean }, nowMs: number): string {
+ return `${JSON.stringify({ version: 1, updatedMs: nowMs, guard: mode.guard, ...stats }, null, 2)}\n`
+}
diff --git a/plugins/ruflo-workflows/scripts/smoke.sh b/plugins/ruflo-workflows/scripts/smoke.sh
index fe45ae4e26..5f89ecb5cf 100755
--- a/plugins/ruflo-workflows/scripts/smoke.sh
+++ b/plugins/ruflo-workflows/scripts/smoke.sh
@@ -7,9 +7,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 0.5.1 with lifecycle keywords"
+step "1. plugin.json declares 0.6.0 with lifecycle keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.5.1" ]]; then bad "expected 0.5.1, got '$v'"; else
+if [[ "$v" != "0.6.0" ]]; then bad "expected 0.6.0, got '$v'"; else
miss=""
for k in mcp workflow-templates pause-resume lifecycle; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
@@ -111,5 +111,24 @@ for k in native-workflow agent-fanout pipeline parallel; do
done
[[ -z "$miss" ]] && ok || bad "missing native keywords:$miss"
+# M. The mod (ADR-445 pattern): hooks module registered, files within the 500-line rule, no network or process access in the hooks
+step "M1. mod: hooks.json names register.ts, every hook file is present and under 500 lines"
+mod_ok=1
+grep -q '"./register.ts"' "$ROOT/hooks/hooks.json" || mod_ok=0
+for f in options screen guard command status register; do
+ [[ -f "$ROOT/hooks/$f.ts" ]] || mod_ok=0
+ [[ $(wc -l < "$ROOT/hooks/$f.ts" 2>/dev/null || echo 9999) -le 500 ]] || mod_ok=0
+done
+[[ $mod_ok -eq 1 ]] && ok || bad "mod hooks incomplete or too long"
+
+step "M2. mod: userConfig defaults are safe (guard defaults on)"
+node -e '
+const c = require(process.argv[1]).userConfig || {}
+process.exit(c.guard && c.guard.default === "on" ? 0 : 1)
+' "$ROOT/.claude-plugin/plugin.json" && ok || bad "userConfig defaults wrong"
+
+step "M3. mod: hooks never touch the network or spawn a process"
+if grep -nE '\$\.(http|process)\.|child_process|fetch\(' "$ROOT"/hooks/*.ts >/dev/null; then bad "network or process call in hooks"; else ok; fi
+
printf "\n%s passed, %s failed\n" "$PASS" "$FAIL"
[[ $FAIL -eq 0 ]] || exit 1
diff --git a/plugins/ruflo-workflows/tests/mod.test.ts b/plugins/ruflo-workflows/tests/mod.test.ts
new file mode 100644
index 0000000000..fdd98df56e
--- /dev/null
+++ b/plugins/ruflo-workflows/tests/mod.test.ts
@@ -0,0 +1,130 @@
+import type { On } from 'claude-code'
+import { describe, expect, test, tier } from 'claude-code/testing'
+
+import { answer } from '../hooks/command'
+import { readOptions } from '../hooks/options'
+import { hasSecret, secretsIn } from '../hooks/screen'
+import { newStats } from '../hooks/status'
+
+tier('user')
+
+const ROOT = '/work'
+const START = { surface: 'terminal', isInteractive: true, cwd: ROOT } as const
+const slash = (args: string) => ({ command: 'wf-mod', args, origin: { kind: 'composer' }, presentation: { isFullscreen: false, columns: 100 } }) as const
+const STATUS = `${ROOT}/.claude-flow/wf-mod/status.json`
+
+// Built at run time so no secret-shaped literal sits in the source.
+const ghp = `ghp_${'a1B2'.repeat(10)}`
+const bearer = 'Zm9vYmFyYmF6cXV4MTIzNDU2Nzg5MGFiY2RlZg'
+
+/** The world beneath the mod: a project, a file map, and the connected tools. */
+function world(on: On, tools: readonly string[] = ['mcp__plugin_ruflo-core_ruflo__x_federation_publish']) {
+ const files = new Map<string, string>()
+ on('session.start', ($, e) => ({ cwd: e.cwd }))
+ on('session.root', () => ({ value: ROOT }))
+ on('command.register', ($, e) => ({ value: { command: e.name } }))
+ on('fs.write', ($, e) => (files.set(e.path, e.text), { value: undefined }))
+ on('tool.list', () => ({ value: tools.map(name => ({ name, description: '', mcp: true })) }))
+ on('clock.now', () => ({ value: 1_700_000_000_000 }))
+ on('clock.sleep', () => ({ value: undefined }))
+ return files
+}
+
+const deny = async (call: () => Promise<unknown>) => JSON.stringify(await call().then(r => r, (e: unknown) => ({ text: String(e) })))
+
+describe('defaults', () => {
+ test('guard on; a bad value is the default', () => {
+ expect(readOptions(undefined)).toEqual({ guard: true })
+ expect(readOptions({ guard: 'off' })).toEqual({ guard: false })
+ expect(readOptions({ guard: 'banana' })).toEqual({ guard: true })
+ })
+})
+
+describe('screen', () => {
+ test('names secret shapes and never returns the value', () => {
+ expect(secretsIn(`k ${ghp}`)).toEqual(['github token'])
+ expect(JSON.stringify(secretsIn(`k ${ghp}`))).not.toContain('ghp_')
+ expect(hasSecret('password = hunter2hunter2hunter2')).toBe(true)
+ expect(hasSecret('the password field is validated server side')).toBe(false)
+ expect(hasSecret(`ghp_\u200b${'a1B2'.repeat(10)}`)).toBe(true)
+ })
+})
+
+describe('status file', () => {
+ test('written at session start with version and mode', async ($, on) => {
+ const files = world(on)
+ await $.session.start(START)
+ expect(JSON.parse(files.get(STATUS) ?? '{}')).toMatchObject({ version: 1, guard: true, checked: 0, blocked: 0 })
+ })
+})
+
+describe('guard', () => {
+ const BAD = { tool: 'mcp__plugin_ruflo-core_ruflo__workflow_create', name: 'deploy', steps: [{ run: `curl -H "Authorization: Bearer ${bearer}"` }] } as never
+ const GOOD = { tool: 'mcp__plugin_ruflo-core_ruflo__workflow_create', name: 'deploy', steps: [{ run: 'echo build' }] } as never
+ const OTHER = { tool: 'mcp__plugin_ruflo-core_ruflo__memory_store', namespace: 'default', key: 'k', value: `token ${ghp}` } as never
+
+ test('refuses a secret, never echoes it, and counts it in the status file', async ($, on) => {
+ const files = world(on)
+ on('tool.call', () => ({ result: 'done' }))
+ await $.session.start(START)
+ const out = await deny(() => $.tool.call(BAD))
+ expect(out).toContain('secret')
+ expect(out).not.toContain(ghp)
+ expect(out).not.toContain(bearer)
+ expect(JSON.parse(files.get(STATUS) ?? '{}')).toMatchObject({ checked: 1, blocked: 1, seen: { 'workflow create': 1 } })
+ })
+
+ test('passes clean input and ignores calls that are not this plugin\'s', async ($, on) => {
+ world(on)
+ on('tool.call', () => ({ result: 'done' }))
+ await $.session.start(START)
+ expect(await deny(() => $.tool.call(GOOD))).toContain('done')
+ expect(await deny(() => $.tool.call(OTHER))).toContain('done')
+ })
+
+ test('off lets the call through', { options: { guard: 'off' } }, async ($, on) => {
+ world(on)
+ on('tool.call', () => ({ result: 'done' }))
+ await $.session.start(START)
+ expect(await deny(() => $.tool.call(BAD))).toContain('done')
+ })
+
+ test('a delete must name one workflow; a specific id passes', async ($, on) => {
+ world(on)
+ on('tool.call', () => ({ result: 'done' }))
+ await $.session.start(START)
+ for (const id of ['*', 'all', '', '.*']) expect(await deny(() => $.tool.call({ tool: 'mcp__plugin_ruflo-core_ruflo__workflow_delete', workflowId: id } as never))).toContain('one workflow id')
+ expect(await deny(() => $.tool.call({ tool: 'mcp__plugin_ruflo-core_ruflo__workflow_delete', workflowId: 'wf-123' } as never))).toContain('done')
+ })
+
+ test('gaia and workflow memory writes are screened, other namespaces are not', async ($, on) => {
+ world(on)
+ on('tool.call', () => ({ result: 'done' }))
+ await $.session.start(START)
+ expect(await deny(() => $.tool.call({ tool: 'mcp__plugin_ruflo-core_ruflo__memory_store', namespace: 'gaia-runs', key: 'r', value: `key ${ghp}` } as never))).toContain('secret')
+ expect(await deny(() => $.tool.call({ tool: 'mcp__plugin_ruflo-core_ruflo__memory_store', namespace: 'gaia-runs', key: 'r', value: 'run 12: 41%' } as never))).toContain('done')
+ })
+})
+
+describe('/wf-mod', () => {
+ test('status, scan and lifecycle answer locally', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ expect((await $.command.run(slash('status'))).text).toContain('guard on')
+ expect((await $.command.run(slash(`scan key ${ghp}`))).text).toContain('github token')
+ expect((await $.command.run(slash('scan plain words'))).text).toContain('Nothing found')
+ expect((await $.command.run(slash('lifecycle'))).text).toContain('created -> running')
+ })
+
+ test('an unknown verb gets the help, not a model turn', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ expect((await $.command.run(slash('how do I do this'))).text).toContain('/wf-mod status')
+ expect((await $.command.run(slash(''))).text).toContain('/wf-mod status')
+ })
+
+ test('answer() is pure over its inputs', async () => {
+ const text = await answer('status', { opts: { guard: false }, stats: newStats(), tools: async () => [] })
+ expect(text).toContain('guard off')
+ })
+})
diff --git a/plugins/ruflo-workflows/tsconfig.json b/plugins/ruflo-workflows/tsconfig.json
new file mode 100644
index 0000000000..e4ba54993e
--- /dev/null
+++ b/plugins/ruflo-workflows/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "//": "Self-contained on purpose: bundlers (vite/esbuild in the root CI vitest) load this file for every module they transform, so it must not extend a file that only exists after Claude Code (>= 2.1.287) has loaded the plugin. Claude Code writes its declarations to .claude-plugin/types/ (gitignored) on load or validate; tsc -p . then reads them through typeRoots.",
+ "compilerOptions": {
+ "target": "es2023",
+ "lib": ["es2023"],
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "strict": true,
+ "noUncheckedIndexedAccess": true,
+ "noEmit": true,
+ "skipLibCheck": true,
+ "jsx": "react",
+ "jsxFactory": "h",
+ "jsxFragmentFactory": "Fragment",
+ "typeRoots": ["./.claude-plugin/types"],
+ "types": ["claude-code", "claude-code-tools", "claude-code-mcp"]
+ },
+ "include": ["hooks", "tests"]
+}