mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
* docs(ruflo-rure): ADR-0001 scope/dual-use policy, ADR-0002 Phase 1 architecture
Fixes #4395 (part 1 — research/planning phase)
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(ruflo-rure): Phase 1 implementation — JS/Electron static analysis
Implements the plugin scaffold (manifest, skill, command, agent, smoke
test, benchmark) and the three Phase 1 MCP tools per ADR-0001/0002:
- rure_extract_asar: resource-capped .asar extraction via @electron/asar,
checking the archive header's declared size/file count before writing
anything (decompression-bomb guard).
- rure_analyze_js_app: TypeScript-compiler-API-based static analysis —
import/export graph, Electron process-boundary detection (ipcMain/
ipcRenderer/contextBridge, require("electron"), nodeIntegration flags),
every finding evidence-sourced to file + line range.
- rure_find_feature: deterministic lexical/structural feature search,
explicitly not semantic/LLM matching.
Every extracted string is routed through the AIDefence content gate
before being returned; flagged content is redacted, never dropped
silently. Parses only — never executes analyzed code, independently
verified by scripts/smoke.mjs grepping the real source (comments
stripped first, so the doc comment describing the property can't trip
its own check).
27 new tests, all passing. Typecheck clean. Tool-description audit
(ADR-112) clean. Benchmark: ~3.6k-18k files/s on a synthetic Electron
bundle (plugins/ruflo-rure/scripts/benchmark.ts).
Trust tier: experimental. Marketplace/directory submission is a
separate, explicit decision, not part of this change (ADR-0001).
Part of #4395.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(console): add ruflo-rure to the plugin map (devtools section)
Every plugin directory needs a line in PLUGIN_MAP or the console's own
plugin-coverage test fails. ruflo-rure lands in devtools, same section
as the other inspection/analysis plugins (ruflo-browser, ruflo-jujutsu,
ruflo-testgen).
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): fix CI failures — real deps, capability-brain classification
Three real bugs surfaced by PR #4396's CI, not flakes:
- typescript was only a devDependency of @claude-flow/cli, but
src/rure/ts-walk.ts needs it at runtime. Moved to dependencies.
(CI: "Cannot find package 'typescript'" in a from-source install.)
- @claude-flow/aidefence was never declared as a dependency of
@claude-flow/cli at all (only resolvable locally via monorepo
hoisting), so the AIDefence gate silently no-op'd in CI's isolated
install. Added as an optionalDependency, matching the existing
graceful-degradation code path and the browser_act precedent this
also fixes.
- capability-brain.ts classified every registered MCP tool into a
domain by prefix; the three new rure_* tools had no domain, so
guidance-brain.test.ts's "classifies every live registered tool"
assertion failed. Added a 'reverse-engineering' domain (experimental
maturity, matching ADR-0001's trust tier) and its package-owner
lookup entry.
All 35 rure + guidance-brain tests pass; typecheck clean;
audit-tool-descriptions and audit-cli-mcp-tools clean.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): revert @claude-flow/aidefence optionalDependency, mock it in tests instead
Reverts the optionalDependency added in 2570cf39d — it's on the #2561
forbidden-heavy-optionalDependencies list (CI's "Enforce CLI + ruflo
optionalDependencies budget" guard caught it): adding it back to
@claude-flow/cli regresses the cold `npx -y @claude-flow/cli@alpha
--version` startup time that #2561 fixed.
gateWithAIDefence's dynamic import was always meant to be speculative
— present only if something else in the install graph happens to pull
it in, same as the existing (unexported) copy in
browser-intent-tools.ts, which never declares it as a dependency
either. The real fix for "my tests need deterministic flagging
behavior" is mocking the module boundary, not forcing the real
optional package to be installed. Both rure-aidefence-gate.test.ts and
rure-tools.test.ts now vi.mock('@claude-flow/aidefence', ...), matching
the precedent in issue-2670-security-defend.test.ts. Added one more
test asserting graceful pass-through (not a thrown error) when the
module genuinely isn't resolvable.
36/36 rure + guidance-brain tests pass; typecheck clean; CLI
optionalDependencies back to 12 (budget 13), no forbidden entries.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): alias typescript/@electron/asar in the isolated analyze-command test
analyze-json-output.test.ts runs analyzeCommand in a fully isolated temp
directory (scrubbed PATH/HOME/TMPDIR, no real node_modules reachable),
resolving only the handful of packages it explicitly aliases to this
package's own resolved paths (vitest, semver, bcryptjs, zod, plus the
cli-core/security source trees). The capability-brain / mcp-tools
registry analyzeCommand transitively loads now reaches rure-tools.ts,
so the same treatment is needed for its two real dependencies:
typescript (compiler API, src/rure/ts-walk.ts) and @electron/asar
(src/rure/extract-asar.ts) — both aliased to requireHere.resolve(...),
matching the existing zod/semver/bcryptjs pattern exactly. This is the
sanctioned mechanism this test already uses for a dependency it
genuinely needs to execute; it's unrelated to the heavy-package
absence assertions earlier in the same file (ruvector, agentic-flow,
@huggingface/transformers, etc.), which stay untouched.
20/20 analyze-json-output tests pass; full rure + guidance-brain suite
(56 tests) passes alongside it in the same run.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): memoize the aidefence module resolution, make gateAll sequential
CI's "Test V3 Packages" job reproducibly failed exactly one test —
gateAll's "preserves order and length across mixed benign/flagged
input" — twice, while every other mock-dependent test in the same file
passed both times. gateAll was the only caller that resolves
@claude-flow/aidefence via several concurrent gateWithAIDefence calls
(Promise.all over the input array); every other test calls it once.
In CI, @claude-flow/aidefence is genuinely absent from node_modules
(confirmed by this job's own "@claude-flow/aidefence not loadable"
log line elsewhere in the same run) — unlike this dev environment,
where it's pnpm-hoisted and physically present, just mocked over.
Fix: memoize the dynamic import behind a single shared promise, so
concurrent callers all await the same resolution attempt instead of
each firing their own against a module vi.mock has to intercept
without a real file backing it. Also made gateAll sequential as
defense in depth — gating is cheap, and there's no reason multiple
calls need to race the first-ever resolution attempt at all.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): add @electron/asar to the root package.json for CI's Test Suite job
Root CI's "Test Suite" job never installs v3/'s own pnpm workspace —
it runs `npm ci` at repo root only, then runs vitest from repo root
against v3/@claude-flow/cli/__tests__/*. Module resolution for those
test files walks up from v3/@claude-flow/cli (no node_modules there in
this job) through v3/ (also none) to the repo root's node_modules,
which is why `typescript` already resolved (already a root
devDependency, for an unrelated reason) while `@electron/asar` did
not (never referenced anywhere in the root tree before this).
Added @electron/asar to the root dependencies, matching how zod/ws
are already placed there for the same reason, and regenerated
package-lock.json. The regen also synced two pieces of real,
pre-existing lockfile staleness this surfaced: the recorded root
version (3.58.0, several releases behind the actual 3.59.17) and a
leftover `toml` dependency entry (removed from package.json before
this PR, but never swept from the lockfile until this install).
Verified against CI's actual invocation shape: `node
node_modules/vitest/vitest.mjs run v3/@claude-flow/cli/__tests__/rure-*`
from repo root, not just the v3-workspace-scoped `npx vitest run` I'd
been using to verify until now.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ruflo-rure): lazy-load the TypeScript compiler instead of a top-level import
ts-walk.ts statically imported `typescript` at module scope. Since
rure-tools.ts is registered into mcp-client.ts's shared tool list, every
CLI invocation loaded the full TypeScript compiler into memory at
startup, not just commands that use ruRE — the same failure shape as the
#2561 cold-start regression (@claude-flow/aidefence).
This also explains three straight CI failures on the exact same file
(mods-cli-bin.test.ts, which exec's the built CLI's `init` through
execFileSync): the heavier startup made it the most likely victim of the
repo's known tinypool worker-crash flake under CI's resource limits.
Fix: import type-only `typescript` for AST types, and lazy-load the real
module (memoized) inside analyzeModuleSource, matching the pattern
already used by aidefence-gate.ts and extract-asar.ts. This makes
analyzeModuleSource/analyzeJsApp/findFeature async; updated their two
call sites in rure-tools.ts and the benchmark script, plus the test
files's call sites.
Verified: `node bin/cli.js --version` succeeds with node_modules/typescript
physically removed (previously would have crashed), confirming the
compiler is no longer loaded on every invocation.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: r <r@x>
75 lines
3.6 KiB
TypeScript
75 lines
3.6 KiB
TypeScript
/**
|
|
* Which console section owns each ruflo plugin: the section that launches its slash commands (the Launch row) and answers
|
|
* "ask Claude" about it. Every plugin directory under `plugins/`, and every external plugin the marketplace lists by a git
|
|
* source, appears here, and a test fails when one is added without a line, so no plugin is ever unreachable from the console.
|
|
* A plugin with no section of its own says why (`catalogOnly`) and is reached from the Plugin Catalog. Pure data.
|
|
*/
|
|
import type { ViewId } from './state'
|
|
|
|
export type PluginHome = { view: ViewId; /** Set when the plugin has no surface of its own yet: why, and where it is reached instead. */ catalogOnly?: string }
|
|
|
|
const home = (view: ViewId): PluginHome => ({ view })
|
|
const catalog = (why: string): PluginHome => ({ view: 'market', catalogOnly: why })
|
|
|
|
export const PLUGIN_MAP: Readonly<Record<string, PluginHome>> = {
|
|
'agentic-qe-fleet': home('devtools'),
|
|
'ruflo-adr': home('devtools'),
|
|
'ruflo-agent': home('swarm'),
|
|
'ruflo-agentdb': home('memory'),
|
|
'ruflo-agntcy': home('federation'),
|
|
'ruflo-aidefence': home('secure'),
|
|
'ruflo-ai-team': home('swarm'),
|
|
'ruflo-arena': home('evolve'),
|
|
'ruflo-autopilot': home('automate'),
|
|
'ruflo-bbs-federation': home('xruv'),
|
|
'ruflo-browser': home('devtools'),
|
|
'ruflo-business-pods': home('federation'),
|
|
'ruflo-chatgpt-federation': home('federation'),
|
|
'ruflo-console': catalog('this mod: it is the console'),
|
|
'ruflo-core': home('overview'),
|
|
'ruflo-cost-tracker': home('cost'),
|
|
'ruflo-daa': home('neural'),
|
|
'ruflo-ddd': home('devtools'),
|
|
'ruflo-deepseek-harness': home('terminal'),
|
|
'ruflo-docs': home('devtools'),
|
|
'ruflo-federation': home('federation'),
|
|
'ruflo-goals': home('missions'),
|
|
'ruflo-graph-intelligence': home('vector'),
|
|
'ruflo-intelligence': home('learning'),
|
|
'ruflo-iot-cognitum': catalog('a device fleet with firmware writes: launched from the Plugin Catalog until the Domains view'),
|
|
'ruflo-jujutsu': home('devtools'),
|
|
'ruflo-knowledge-graph': home('memory'),
|
|
'ruflo-loop-workers': home('automate'),
|
|
'ruflo-market-data': catalog('a market-data domain plugin: launched from the Plugin Catalog until the Domains view'),
|
|
'ruflo-metaharness': home('metaharness'),
|
|
'ruflo-migrations': home('devtools'),
|
|
'ruflo-mods': home('plugins'),
|
|
'ruflo-music': catalog('a creative-domain plugin that may spend on generation: launched from the Plugin Catalog until the Domains view'),
|
|
'ruflo-neural-trader': catalog('a trading domain plugin (never live from the console): launched from the Plugin Catalog until the Domains view'),
|
|
'ruflo-observability': home('timeline'),
|
|
'ruflo-plugin-creator': home('plugins'),
|
|
'ruflo-rag-memory': home('memory'),
|
|
'ruflo-ruos': home('swarm'),
|
|
'ruflo-rure': home('devtools'),
|
|
'ruflo-ruvector': home('vector'),
|
|
'ruflo-ruvllm': home('neural'),
|
|
'ruflo-rvf': home('sandbox'),
|
|
'ruflo-protector': home('secure'),
|
|
'ruflo-security-audit': home('secure'),
|
|
'ruflo-sparc': home('missions'),
|
|
'ruflo-swarm': home('swarm'),
|
|
'ruflo-testgen': home('devtools'),
|
|
'ruflo-workflows': home('automate'),
|
|
'ruflo-x-gateway': home('xruv'),
|
|
}
|
|
|
|
/** The section that owns a plugin (by directory name, or by the `plugin:command` slash name). */
|
|
export const homeOf = (pluginOrSlash: string): ViewId | null => PLUGIN_MAP[pluginOrSlash.split(':')[0] ?? '']?.view ?? null
|
|
|
|
/** The plugins a section owns, in name order: what its Launch row can offer. */
|
|
export const pluginsOfView = (view: ViewId): string[] =>
|
|
Object.entries(PLUGIN_MAP)
|
|
.filter(([, entry]) => entry.view === view)
|
|
.map(([plugin]) => plugin)
|
|
.sort()
|