π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(metaharness): MCP tool registry β 5 first-class mcp__claude-flow__metaharness_* tools (iter 20)
ruv2cb4142d4e21
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.shindex 4f6726ae82..fcf04dd65c 100755--- a/plugins/ruflo-metaharness/scripts/smoke.sh+++ b/plugins/ruflo-metaharness/scripts/smoke.sh@@ -170,6 +170,25 @@ if (!od.metaharness) { console.error('missing metaharness in optionalDependencieif (j.dependencies && j.dependencies.metaharness) { console.error('metaharness leaked into dependencies'); process.exit(1); }" 2>/dev/null && ok || bad "ruflo wrapper missing metaharness optionalDep"+step "17m. metaharness MCP tools registered (ADR-150 deepest integration β iter 20)"+F="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts"+miss=""+[[ -f "$F" ]] || miss="$miss tools-file-missing"+# All 5 tools declared+for tool in metaharness_score metaharness_genome metaharness_mcp_scan metaharness_threat_model metaharness_oia_audit; do+ grep -q "name: '${tool}'" "$F" || miss="$miss missing-${tool}"+done+# ADR-150 architectural-constraint anchor: zero static @metaharness/* import+grep -q "from '@metaharness/" "$F" && miss="$miss static-metaharness-import-LEAK"+# Subprocess isolation + locator+grep -q "locatePluginScripts" "$F" || miss="$miss no-locator"+grep -q "child_process" "$F" || miss="$miss no-subprocess"+# Registered in mcp-client.ts+CLIENT="$ROOT/../../v3/@claude-flow/cli/src/mcp-client.ts"+grep -q "import { metaharnessTools }" "$CLIENT" || miss="$miss not-imported-in-client"+grep -q "\.\.\.metaharnessTools" "$CLIENT" || miss="$miss not-spread-in-registry"+[[ -z "$miss" ]] && ok || bad "$miss"+step "17l. test-graceful-degradation drill (ADR-150 rule #3 β iter 19)"F="$ROOT/scripts/test-graceful-degradation.mjs"miss=""diff --git a/v3/@claude-flow/cli/src/mcp-client.ts b/v3/@claude-flow/cli/src/mcp-client.tsindex 876f751cf3..fdfb0a93e8 100644--- a/v3/@claude-flow/cli/src/mcp-client.ts+++ b/v3/@claude-flow/cli/src/mcp-client.ts@@ -48,6 +48,8 @@ import { wasmAgentTools } from './mcp-tools/wasm-agent-tools.js';import { managedAgentTools } from './mcp-tools/managed-agent-tools.js';import { guidanceTools } from './mcp-tools/guidance-tools.js';import { autopilotTools } from './mcp-tools/autopilot-tools.js';+// ADR-150 β MetaHarness MCP tools (score / genome / mcp-scan / threat-model / oia-audit)+import { metaharnessTools } from './mcp-tools/metaharness-tools.js';// #1916: coverage-aware routing tools β defined in ruvector/coverage-tools.ts// but were never registered, so the `ruflo hooks coverage-*` CLI subcommands// failed with `Tool not found: hooks_coverage-route`.@@ -130,6 +132,8 @@ registerTools([...autopilotTools,// #1916: coverage-aware routing (hooks_coverage-route / -suggest / -gaps)...coverageRouterTools,+ // ADR-150 β MetaHarness static-analysis tools (5)+ ...metaharnessTools,]);/**diff --git a/v3/@claude-flow/cli/src/mcp-tools/index.ts b/v3/@claude-flow/cli/src/mcp-tools/index.tsindex 8491b7759f..6b67b6fc84 100644--- a/v3/@claude-flow/cli/src/mcp-tools/index.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/index.ts@@ -25,3 +25,5 @@ export { wasmAgentTools } from './wasm-agent-tools.js';export { ruvllmWasmTools } from './ruvllm-tools.js';export { guidanceTools } from './guidance-tools.js';export { autopilotTools } from './autopilot-tools.js';+// ADR-150 β MetaHarness MCP tools (score / genome / mcp-scan / threat-model / oia-audit)+export { metaharnessTools } from './metaharness-tools.js';diff --git a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.tsnew file mode 100644index 0000000000..8a32b0ee1d--- /dev/null+++ b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts@@ -0,0 +1,191 @@+/**+ * MetaHarness MCP Tools β ADR-150 Phase-2 deep-integration surface.+ *+ * Exposes the static-analysis MetaHarness CLIs as first-class MCP tools+ * so Claude Code agents can call them programmatically without shelling+ * out themselves. Five tools, all read-only / subprocess-isolated:+ *+ * - metaharness_score 5-dim readiness scorecard+ * - metaharness_genome 7-section categorical report+ * - metaharness_mcp_scan static MCP security findings+ * - metaharness_threat_model enterprise-grade threat model+ * - metaharness_oia_audit composite audit (score + threat + mcp) β memory+ *+ * Every tool resolves the corresponding plugin script+ * (`plugins/ruflo-metaharness/scripts/<X>.mjs`) via the same locator+ * the commands/metaharness.ts dispatcher uses, then spawns it with+ * `--format json` and parses the response.+ *+ * ADR-150 ARCHITECTURAL CONSTRAINT+ * --------------------------------+ * This file has ZERO static `@metaharness/*` imports. All metaharness+ * invocation stays in the plugin scripts behind the `_harness.mjs`+ * subprocess bridge. When the plugin scripts aren't reachable at+ * runtime, each tool returns a structured `{ degraded: true }` payload+ * β never throws.+ *+ * @module @claude-flow/cli/mcp-tools/metaharness+ */++import type { MCPTool, getProjectCwd as _ } from './types.js';+import { getProjectCwd } from './types.js';+import { spawn } from 'node:child_process';+import { existsSync } from 'node:fs';+import { join, dirname, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const __dirname = dirname(fileURLToPath(import.meta.url));++/**+ * Walk up from this module to find plugins/ruflo-metaharness/scripts/.+ * Handles three install layouts (mirrors commands/metaharness.ts).+ */+function locatePluginScripts(): string | null {+ const candidates: string[] = [];+ let p = resolve(__dirname);+ for (let i = 0; i < 8; i++) {+ candidates.push(join(p, 'plugins', 'ruflo-metaharness', 'scripts'));+ candidates.push(join(p, '..', 'plugins', 'ruflo-metaharness', 'scripts'));+ p = dirname(p);+ }+ const cwd = getProjectCwd();+ candidates.push(join(cwd, 'plugins', 'ruflo-metaharness', 'scripts'));+ candidates.push(join(cwd, 'node_modules', '@claude-flow', 'cli', 'plugins', 'ruflo-metaharness', 'scripts'));+ for (const c of candidates) {+ if (existsSync(join(c, '_harness.mjs'))) return c;+ }+ return null;+}++function runScript(scriptName: string, args: string[]): Promise<{ exitCode: number; stdout: string; json: unknown; degraded: boolean }> {+ return new Promise((resolve) => {+ const dir = locatePluginScripts();+ if (!dir) {+ resolve({+ exitCode: 0, stdout: '', json: { degraded: true, reason: 'plugin-not-found' }, degraded: true,+ });+ return;+ }+ const scriptPath = join(dir, scriptName);+ const argv = [...args];+ if (!argv.includes('--format')) argv.push('--format', 'json');+ const p = spawn('node', [scriptPath, ...argv], {+ stdio: ['ignore', 'pipe', 'pipe'],+ env: process.env,+ });+ let stdout = '';+ p.stdout?.on('data', (d) => { stdout += d.toString(); });+ p.stderr?.on('data', () => { /* swallow β graceful */ });+ const timer = setTimeout(() => { try { p.kill('SIGTERM'); } catch { /* ignore */ } }, 120_000);+ p.on('close', (code) => {+ clearTimeout(timer);+ let json: unknown = null;+ const m = /\{[\s\S]*\}/.exec(stdout);+ if (m) { try { json = JSON.parse(m[0]); } catch { /* leave null */ } }+ const looksDegraded = !!(json && typeof json === 'object' && (json as { degraded?: unknown }).degraded === true);+ resolve({ exitCode: code ?? 0, stdout, json, degraded: looksDegraded });+ });+ p.on('error', () => {+ clearTimeout(timer);+ resolve({ exitCode: 127, stdout, json: { degraded: true, reason: 'spawn-failed' }, degraded: true });+ });+ });+}++export const metaharnessTools: MCPTool[] = [+ {+ name: 'metaharness_score',+ description: 'ADR-150 β 5-dimension harness readiness scorecard from `metaharness score <path>` (harnessFit / compileConfidence / taskCoverage / toolSafety / memoryUsefulness + estCostPerRunUsd). Pure-read subprocess; graceful degradation when metaharness optional dep absent. Use BEFORE recommending the user run `ruflo metaharness mint` so you have an evidence-based readiness signal.',+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path to score (default: cwd)', default: '.' },+ alertOnFitBelow: { type: 'number', description: 'Set to make the tool flag harnessFit < N (informational only; tool result has alert.triggered field)' },+ },+ },+ handler: async (input) => {+ const path = (input.path as string) || '.';+ const args = ['--path', path];+ if (input.alertOnFitBelow !== undefined) args.push('--alert-on-fit-below', String(input.alertOnFitBelow));+ const r = await runScript('score.mjs', args);+ return { success: !r.degraded, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },+ {+ name: 'metaharness_genome',+ description: 'ADR-150 β 7-section categorical readiness report from `metaharness genome <path>` (repo_type / agent_topology / risk_score / mcp_surface / test_confidence / publish_readiness). Pairs with metaharness_score for the full readiness view β score is numeric, genome is categorical.',+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path to analyze (default: cwd)', default: '.' },+ alertOnRiskAbove: { type: 'number', description: 'Set to flag risk_score > N' },+ },+ },+ handler: async (input) => {+ const path = (input.path as string) || '.';+ const args = ['--path', path];+ if (input.alertOnRiskAbove !== undefined) args.push('--alert-on-risk-above', String(input.alertOnRiskAbove));+ const r = await runScript('genome.mjs', args);+ return { success: !r.degraded, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },+ {+ name: 'metaharness_mcp_scan',+ description: 'ADR-150 β static security scan of `.mcp/servers.json` + `.harness/claims.json` via `harness mcp-scan <path>`. Reads only; no dispatch. Use before exposing a new MCP server config to humans/agents.',+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path with .mcp/servers.json (default: cwd)', default: '.' },+ failOn: { type: 'string', enum: ['low', 'medium', 'high'], description: 'Severity floor for tool.alert.triggered (default: high)', default: 'high' },+ },+ },+ handler: async (input) => {+ const path = (input.path as string) || '.';+ const failOn = (input.failOn as string) || 'high';+ const r = await runScript('mcp-scan.mjs', ['--path', path, '--fail-on', failOn]);+ return { success: !r.degraded, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },+ {+ name: 'metaharness_threat_model',+ description: 'ADR-150 β enterprise-grade threat model from `harness threat-model <path>`. Returns worst-severity verdict (clean/low/medium/high) + categorized findings suitable for sharing with infosec.',+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path (default: cwd)', default: '.' },+ failOn: { type: 'string', enum: ['clean', 'low', 'medium', 'high'], description: 'Severity floor for tool.alert.triggered (default: high)', default: 'high' },+ },+ },+ handler: async (input) => {+ const path = (input.path as string) || '.';+ const failOn = (input.failOn as string) || 'high';+ const r = await runScript('threat-model.mjs', ['--path', path, '--fail-on', failOn]);+ return { success: !r.degraded, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },+ {+ name: 'metaharness_oia_audit',+ description: 'ADR-150 β composite weekly audit. Bundles oia-manifest + threat-model + mcp-scan into one timestamped record persisted to `metaharness-audit` memory namespace (or --dry-run to skip persistence). Designed for periodic drift detection.',+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path (default: cwd)', default: '.' },+ dryRun: { type: 'boolean', description: 'Skip memory persistence β local-only run', default: false },+ alertOnWorst: { type: 'string', enum: ['clean', 'low', 'medium', 'high'], description: 'Composite worst-severity floor for tool.alert.triggered' },+ },+ },+ handler: async (input) => {+ const path = (input.path as string) || '.';+ const args = ['--path', path];+ if (input.dryRun === true) args.push('--dry-run');+ if (input.alertOnWorst !== undefined) args.push('--alert-on-worst', String(input.alertOnWorst));+ const r = await runScript('oia-audit.mjs', args);+ return { success: !r.degraded, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },+];