@claude-flow/cli 3.32.25 → 3.32.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/auto-memory-hook.mjs +430 -430
  3. package/.claude/helpers/helpers.manifest.json +6 -6
  4. package/.claude/helpers/hook-handler.cjs +565 -565
  5. package/.claude/helpers/intelligence.cjs +1058 -1058
  6. package/.claude/helpers/statusline.cjs +1060 -1060
  7. package/catalog-manifest.json +4 -4
  8. package/dist/src/commands/index.d.ts +1 -0
  9. package/dist/src/commands/index.js +5 -3
  10. package/dist/src/commands/memory.js +49 -5
  11. package/dist/src/commands/metaharness.js +100 -2
  12. package/dist/src/commands/policy.d.ts +4 -0
  13. package/dist/src/commands/policy.js +107 -0
  14. package/dist/src/index.js +18 -0
  15. package/dist/src/mcp-client.js +25 -1
  16. package/dist/src/mcp-tools/capability-brain.d.ts +134 -0
  17. package/dist/src/mcp-tools/capability-brain.js +697 -0
  18. package/dist/src/mcp-tools/guidance-tools.d.ts +2 -0
  19. package/dist/src/mcp-tools/guidance-tools.js +369 -37
  20. package/dist/src/mcp-tools/index.d.ts +4 -1
  21. package/dist/src/mcp-tools/index.js +3 -1
  22. package/dist/src/mcp-tools/memory-tools.js +26 -0
  23. package/dist/src/mcp-tools/metaharness-tools.js +106 -1
  24. package/dist/src/mcp-tools/policy-tools.d.ts +3 -0
  25. package/dist/src/mcp-tools/policy-tools.js +121 -0
  26. package/dist/src/memory/memory-bridge.d.ts +11 -0
  27. package/dist/src/memory/memory-bridge.js +100 -21
  28. package/dist/src/memory/memory-initializer.d.ts +22 -1
  29. package/dist/src/memory/memory-initializer.js +184 -39
  30. package/dist/src/services/bounded-worker-pool.d.ts +28 -0
  31. package/dist/src/services/bounded-worker-pool.js +90 -0
  32. package/dist/src/services/flywheel-proposer.d.ts +87 -0
  33. package/dist/src/services/flywheel-proposer.js +165 -0
  34. package/dist/src/services/flywheel-receipt.d.ts +136 -0
  35. package/dist/src/services/flywheel-receipt.js +309 -0
  36. package/dist/src/services/flywheel-transaction.d.ts +77 -0
  37. package/dist/src/services/flywheel-transaction.js +378 -0
  38. package/dist/src/services/harness-flywheel-runtime.d.ts +11 -0
  39. package/dist/src/services/harness-flywheel-runtime.js +85 -2
  40. package/dist/src/services/harness-flywheel.d.ts +27 -1
  41. package/dist/src/services/harness-flywheel.js +138 -27
  42. package/dist/src/services/policy-runtime.d.ts +38 -0
  43. package/dist/src/services/policy-runtime.js +340 -0
  44. package/package.json +23 -5
  45. package/plugins/ruflo-metaharness/scripts/smoke.sh +22 -14
  46. package/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs +3 -1
  47. package/.claude/.proven-config-version +0 -1
  48. package/.claude/proven-config.json +0 -42
@@ -0,0 +1,697 @@
1
+ /**
2
+ * Ruflo capability brain.
3
+ *
4
+ * This module is deliberately data-only: it describes the complete MCP surface
5
+ * without importing the MCP registry. The registry injects its live tool list
6
+ * into guidance-tools after registration, which avoids a circular dependency
7
+ * and prevents documentation from being mistaken for runtime availability.
8
+ */
9
+ /** Top-level commands from the CLI command loader. Kept as a checked manifest. */
10
+ export const RUFLO_CLI_COMMANDS = [
11
+ 'init', 'start', 'status', 'task', 'session', 'agent', 'swarm', 'memory',
12
+ 'mcp', 'config', 'migrate', 'hooks', 'workflow', 'hive-mind', 'process',
13
+ 'daemon', 'version', 'neural', 'security', 'performance', 'providers',
14
+ 'plugins', 'deployment', 'claims', 'policy', 'embeddings', 'completions',
15
+ 'doctor', 'verify', 'analyze', 'route', 'progress', 'issues', 'update',
16
+ 'ruvector', 'benchmark', 'guidance', 'appliance', 'appliance-advanced',
17
+ 'transfer-store', 'cleanup', 'autopilot', 'gaia-bench', 'metaharness',
18
+ 'eject', 'funnel', 'settings', 'auth', 'proxy', 'advisor', 'spinner',
19
+ 'announcements',
20
+ ];
21
+ export const IMPLEMENTATION_LOOP = [
22
+ {
23
+ id: 'recall',
24
+ name: 'Recall',
25
+ purpose: 'Search Ruflo memory and relevant ADRs before choosing an approach.',
26
+ preferredTools: ['memory_search', 'guidance_brain', 'guidance_recommend'],
27
+ requiredEvidence: 'Relevant patterns and constraints, or an explicit no-match result.',
28
+ mutation: 'none',
29
+ },
30
+ {
31
+ id: 'inspect',
32
+ name: 'Inspect',
33
+ purpose: 'Read repository, runtime, dependency, policy, and health state.',
34
+ preferredTools: ['analyze_project', 'system_status', 'policy_status', 'security_scan'],
35
+ requiredEvidence: 'Observed source/runtime state with unknowns kept explicit.',
36
+ mutation: 'none',
37
+ },
38
+ {
39
+ id: 'route',
40
+ name: 'Route',
41
+ purpose: 'Select the smallest capable topology, agents, skills, and tools.',
42
+ preferredTools: ['hooks_route', 'guidance_recommend', 'swarm_init'],
43
+ requiredEvidence: 'Chosen route, ownership boundaries, and fallback behavior.',
44
+ mutation: 'none',
45
+ },
46
+ {
47
+ id: 'plan',
48
+ name: 'Plan',
49
+ purpose: 'Define acceptance criteria, safety envelope, leases, and validation.',
50
+ preferredTools: ['task_create', 'workflow_create', 'claims_check'],
51
+ requiredEvidence: 'Testable acceptance criteria and authorization boundary.',
52
+ mutation: 'none',
53
+ },
54
+ {
55
+ id: 'execute',
56
+ name: 'Execute',
57
+ purpose: 'Have the coding agent perform the actual scoped implementation.',
58
+ preferredTools: ['agent_spawn', 'task_assign', 'terminal_execute'],
59
+ requiredEvidence: 'Exact source-state change and implementation log.',
60
+ mutation: 'workspace',
61
+ },
62
+ {
63
+ id: 'test',
64
+ name: 'Test',
65
+ purpose: 'Run focused and regression tests, including failure paths.',
66
+ preferredTools: ['terminal_execute', 'hooks_coverage-gaps', 'analyze_code'],
67
+ requiredEvidence: 'Test command, result, environment, and failures.',
68
+ mutation: 'workspace',
69
+ },
70
+ {
71
+ id: 'validate',
72
+ name: 'Validate',
73
+ purpose: 'Check types, security, policy, compatibility, and artifact integrity.',
74
+ preferredTools: ['security_audit', 'policy_evaluate', 'metaharness_threat-model'],
75
+ requiredEvidence: 'Independent validation results bound to source state.',
76
+ mutation: 'none',
77
+ },
78
+ {
79
+ id: 'benchmark',
80
+ name: 'Benchmark',
81
+ purpose: 'Measure representative workload behavior against a baseline.',
82
+ preferredTools: ['performance_benchmark', 'metaharness_score'],
83
+ requiredEvidence: 'Reproducible baseline, candidate measurement, and environment.',
84
+ mutation: 'none',
85
+ },
86
+ {
87
+ id: 'optimize',
88
+ name: 'Optimize',
89
+ purpose: 'Improve only measured bottlenecks without weakening the safety envelope.',
90
+ preferredTools: ['performance_profile', 'neural_optimize'],
91
+ requiredEvidence: 'Measured improvement and unchanged correctness/security gates.',
92
+ mutation: 'workspace',
93
+ },
94
+ {
95
+ id: 'receipt',
96
+ name: 'Receipt',
97
+ purpose: 'Bind claims, tests, benchmarks, and decisions to exact source/build evidence.',
98
+ preferredTools: ['claims_validate', 'memory_store'],
99
+ requiredEvidence: 'Content-bound receipt with evidence strength stated honestly.',
100
+ mutation: 'workspace',
101
+ },
102
+ {
103
+ id: 'handoff',
104
+ name: 'Handoff',
105
+ purpose: 'Reconcile concurrent work and communicate remaining risks.',
106
+ preferredTools: ['session_handoff', 'task_status', 'swarm_status'],
107
+ requiredEvidence: 'Ownership reconciliation and explicit unresolved limitations.',
108
+ mutation: 'none',
109
+ },
110
+ {
111
+ id: 'publish',
112
+ name: 'Publish',
113
+ purpose: 'Publish only after an authorized release gate approves exact artifacts.',
114
+ preferredTools: ['github_pr_create', 'github_release_create'],
115
+ requiredEvidence: 'Human/policy authorization, clean source, immutable artifact digests, and green gates.',
116
+ mutation: 'external',
117
+ },
118
+ ];
119
+ /**
120
+ * Domain order is significant: narrow/specialized matches precede broad
121
+ * compatibility prefixes. Every registered tool is eventually classified by
122
+ * the final runtime-services domain, but fallback classifications are reported.
123
+ */
124
+ export const CAPABILITY_DOMAINS = [
125
+ {
126
+ id: 'guidance',
127
+ name: 'Capability Guidance',
128
+ description: 'Live capability inventory, task routing, workflow guidance, and system discovery.',
129
+ prefixes: ['guidance_'],
130
+ taskSignals: ['guidance', 'discover', 'capability', 'what can ruflo do'],
131
+ commands: ['guidance compile', 'guidance retrieve', 'guidance gates', 'guidance optimize'],
132
+ skills: [],
133
+ agents: [],
134
+ maturity: 'stable',
135
+ authority: 'advisory',
136
+ risk: 'read-only',
137
+ useWhen: 'Choosing Ruflo capabilities or checking whether a claimed MCP function is actually registered.',
138
+ verifyBeforeUse: ['Treat configured, reachable, healthy, and authorized as unknown until probed.'],
139
+ },
140
+ {
141
+ id: 'identity-auth',
142
+ name: 'Cognitum Identity & OAuth',
143
+ description: 'Profile-aware PKCE/OOB authentication, credential status, consent-bound scopes, refresh, and local logout.',
144
+ prefixes: ['auth_', 'oauth_'],
145
+ taskSignals: ['auth', 'oauth', 'login', 'logout', 'credential', 'profile', 'scope', 'consent'],
146
+ commands: ['auth login', 'auth login --no-browser', 'auth status', 'auth status --check', 'auth logout'],
147
+ skills: ['security-audit'],
148
+ agents: ['authentication', 'security-architect'],
149
+ maturity: 'experimental',
150
+ authority: 'control-plane',
151
+ risk: 'privileged',
152
+ availabilityMode: 'configured-remote',
153
+ riskFlags: ['read', 'local-write', 'network', 'credential-pii', 'approval'],
154
+ loopPhases: ['discover', 'authorize-claim', 'observe'],
155
+ useWhen: 'A Cognitum-backed capability needs an explicit user identity and consent-bound scope.',
156
+ verifyBeforeUse: [
157
+ 'Use PKCE on interactive desktops and the implemented OOB/manual flow for headless use; RFC 8628 device polling is not implemented.',
158
+ 'Noninteractive login fails closed unless --token-stdin is explicit.',
159
+ 'Plain auth status is offline-safe; --check may refresh through the OS keychain.',
160
+ 'Local logout cannot currently prove server-side token revocation.',
161
+ ],
162
+ },
163
+ {
164
+ id: 'policy-authorization',
165
+ name: 'Policy Authorization',
166
+ description: 'Policy-decision evaluation and status for exact subject/action/resource requests.',
167
+ prefixes: ['policy_'],
168
+ taskSignals: ['policy', 'authorization', 'permission', 'capability', 'access control'],
169
+ commands: ['policy evaluate', 'policy status', 'guidance gates'],
170
+ skills: ['claims', 'security-audit', 'v3-security-overhaul'],
171
+ agents: ['security-architect', 'reviewer'],
172
+ maturity: 'experimental',
173
+ authority: 'control-plane',
174
+ risk: 'privileged',
175
+ availabilityMode: 'policy-filtered',
176
+ riskFlags: ['approval'],
177
+ loopPhases: ['authorize-claim', 'validate-critique', 'publish'],
178
+ useWhen: 'Determining whether a principal may perform an exact action on an exact resource.',
179
+ verifyBeforeUse: ['Confirm subject, action, resource, tenant, policy version, and freshness.', 'Remote MCP exposes evaluation/status only; administration remains local and authenticated.'],
180
+ },
181
+ {
182
+ id: 'work-claims',
183
+ name: 'Exclusive Work Claims',
184
+ description: 'Repository/task ownership claims, handoffs, contention, stealing, and rebalance.',
185
+ prefixes: ['claims_'],
186
+ taskSignals: ['work claim', 'claim task', 'handoff', 'ownership', 'concurrent work', 'rebalance'],
187
+ commands: ['claims claim', 'claims handoff', 'claims status'],
188
+ skills: ['claims'],
189
+ agents: ['coordinator'],
190
+ maturity: 'experimental',
191
+ authority: 'capability-plane',
192
+ risk: 'privileged',
193
+ riskFlags: ['concurrency', 'local-write'],
194
+ loopPhases: ['authorize-claim', 'route-plan', 'observe'],
195
+ useWhen: 'Coordinating exclusive repository or task ownership among concurrent workers.',
196
+ verifyBeforeUse: ['A work claim prevents collisions; it does not grant product, network, or release authority.', 'Validate repository, path scope, owner, epoch, and expiry.'],
197
+ },
198
+ {
199
+ id: 'content-safety',
200
+ name: 'AIDefence Content Safety',
201
+ description: 'Prompt/content safety, PII detection, learning, and security evidence.',
202
+ prefixes: ['aidefence_', 'security_'],
203
+ taskSignals: ['security', 'content safety', 'pii', 'prompt injection', 'threat', 'audit'],
204
+ commands: ['security scan'],
205
+ skills: ['security-audit', 'v3-security-overhaul'],
206
+ agents: ['security-architect', 'reviewer'],
207
+ maturity: 'experimental',
208
+ authority: 'advisory',
209
+ risk: 'read-only',
210
+ riskFlags: ['read', 'credential-pii'],
211
+ loopPhases: ['validate-critique', 'observe'],
212
+ useWhen: 'Scanning untrusted content or collecting security evidence.',
213
+ verifyBeforeUse: ['A score is evidence, not authorization.', 'Do not persist detected credentials or PII.'],
214
+ },
215
+ {
216
+ id: 'metaharness-flywheel',
217
+ name: 'MetaHarness, Darwin & Flywheel',
218
+ description: 'Candidate scoring, static analysis, threat modeling, genome exploration, and controlled improvement loops.',
219
+ prefixes: ['metaharness_', 'autopilot_'],
220
+ taskSignals: ['metaharness', 'darwin', 'flywheel', 'genome', 'optimize', 'autopilot'],
221
+ commands: ['metaharness score', 'metaharness genome', 'autopilot run'],
222
+ skills: ['metaharness-brain', 'performance-analysis'],
223
+ agents: ['performance-engineer', 'reviewer'],
224
+ maturity: 'experimental',
225
+ authority: 'capability-plane',
226
+ risk: 'reversible',
227
+ optionalRuntime: true,
228
+ riskFlags: ['local-write', 'process-exec', 'network', 'spend', 'promotion'],
229
+ loopPhases: ['branch-propose', 'validate-critique', 'observe'],
230
+ useWhen: 'Exploring or evaluating candidate improvements under a separate promotion authority.',
231
+ verifyBeforeUse: ['Darwin proposes; the Ruflo promotion gate decides.', 'Degraded/fallback runs are evaluation-only unless policy explicitly permits promotion.'],
232
+ },
233
+ {
234
+ id: 'memory-knowledge',
235
+ name: 'Memory, AgentDB & Embeddings',
236
+ description: 'Persistent memory, semantic/vector retrieval, namespaces, embeddings, and AgentDB controllers.',
237
+ prefixes: ['memory_', 'agentdb_', 'embeddings_'],
238
+ taskSignals: ['memory', 'agentdb', 'vector', 'embedding', 'semantic', 'recall'],
239
+ commands: ['memory search', 'memory store', 'memory retrieve'],
240
+ skills: ['memory-management', 'agentdb-advanced', 'agentdb-vector-search'],
241
+ agents: ['memory-specialist'],
242
+ maturity: 'stable',
243
+ authority: 'capability-plane',
244
+ risk: 'reversible',
245
+ optionalRuntime: true,
246
+ riskFlags: ['read', 'local-write', 'memory-poisoning'],
247
+ useWhen: 'Recalling prior patterns or storing validated, content-bound learning.',
248
+ verifyBeforeUse: ['Memory recall is evidence, not authority.', 'Only commit validated learning; do not auto-promote policy.'],
249
+ },
250
+ {
251
+ id: 'memory-branching',
252
+ name: 'Copy-on-Write & Speculative Memory',
253
+ description: 'Low-cost memory branching, checkpoint, rollback, comparison, and validated promotion.',
254
+ prefixes: ['agenticow_'],
255
+ taskSignals: ['branch memory', 'checkpoint', 'rollback', 'speculative'],
256
+ commands: [],
257
+ skills: ['agentdb-learning'],
258
+ agents: [],
259
+ maturity: 'experimental',
260
+ authority: 'capability-plane',
261
+ risk: 'privileged',
262
+ optionalRuntime: true,
263
+ riskFlags: ['local-write', 'memory-poisoning', 'promotion'],
264
+ useWhen: 'Testing alternative memories or strategies without mutating the active lineage.',
265
+ verifyBeforeUse: ['Promotion requires a validated receipt and separate authority.'],
266
+ },
267
+ {
268
+ id: 'agents-runtimes',
269
+ name: 'Agent Lifecycle & Runtimes',
270
+ description: 'Local agents, managed cloud agents, WASM sandboxes, and inference runtimes.',
271
+ prefixes: ['agent_', 'managed_agent_', 'wasm_agent_', 'wasm_gallery_', 'ruvllm_'],
272
+ taskSignals: ['agent', 'worker', 'wasm', 'sandbox', 'inference', 'managed agent'],
273
+ commands: ['agent spawn', 'agent status', 'agent stop'],
274
+ skills: ['agent-coder', 'agent-tester', 'agent-reviewer'],
275
+ agents: ['coder', 'tester', 'reviewer'],
276
+ maturity: 'stable',
277
+ authority: 'capability-plane',
278
+ risk: 'privileged',
279
+ optionalRuntime: true,
280
+ riskFlags: ['local-write', 'process-exec', 'network', 'credential-pii', 'spend', 'destructive'],
281
+ useWhen: 'Assigning bounded work to an agent runtime after ownership is clear.',
282
+ verifyBeforeUse: ['A spawned agent is not proof of execution.', 'Check runtime availability, provider credentials, spend limits, network policy, and collect exact outputs.'],
283
+ },
284
+ {
285
+ id: 'swarm-coordination',
286
+ name: 'Swarm & Coordination',
287
+ description: 'Topology-aware multi-agent coordination, task ownership, and collective scheduling.',
288
+ prefixes: ['swarm_', 'coordination_', 'daa_'],
289
+ taskSignals: ['swarm', 'concurrent', 'parallel', 'coordinate', 'multi-agent'],
290
+ commands: ['swarm init', 'swarm status', 'swarm coordinate'],
291
+ skills: ['swarm-orchestration', 'swarm-advanced'],
292
+ agents: ['coordinator', 'coder', 'tester', 'reviewer'],
293
+ maturity: 'stable',
294
+ authority: 'capability-plane',
295
+ risk: 'reversible',
296
+ useWhen: 'A task has multiple independent workstreams or more than two files.',
297
+ verifyBeforeUse: ['Use repository-scoped ownership and reconcile before merge.', 'Coordination records do not execute code.'],
298
+ },
299
+ {
300
+ id: 'consensus-federation',
301
+ name: 'Hive Mind & Consensus',
302
+ description: 'Hive, quorum, voting, gossip, and distributed agreement primitives.',
303
+ prefixes: ['hive_', 'hive-mind_', 'consensus_', 'quorum_'],
304
+ taskSignals: ['hive', 'consensus', 'quorum', 'byzantine', 'federation'],
305
+ commands: ['hive-mind init', 'hive-mind status'],
306
+ skills: ['hive-mind', 'hive-mind-advanced'],
307
+ agents: ['byzantine-coordinator', 'raft-manager'],
308
+ maturity: 'experimental',
309
+ authority: 'capability-plane',
310
+ risk: 'privileged',
311
+ useWhen: 'Multiple principals must agree while preserving an external authorization boundary.',
312
+ verifyBeforeUse: ['Consensus is not authorization.', 'Authenticate membership and bind decisions to policy.'],
313
+ },
314
+ {
315
+ id: 'tasks-workflows-sessions',
316
+ name: 'Tasks, Workflows, Sessions & Progress',
317
+ description: 'Task orchestration, reusable workflows, session state, progress, and handoff.',
318
+ prefixes: ['task_', 'workflow_', 'session_', 'progress_'],
319
+ taskSignals: ['task', 'workflow', 'session', 'handoff', 'progress'],
320
+ commands: ['task create', 'task status', 'workflow run'],
321
+ skills: ['workflow-automation'],
322
+ agents: ['workflow', 'planner'],
323
+ maturity: 'stable',
324
+ authority: 'capability-plane',
325
+ risk: 'reversible',
326
+ useWhen: 'Tracking multi-step work or handing execution between agents/sessions.',
327
+ verifyBeforeUse: ['Persist exact source/run identity rather than relying on prose status.'],
328
+ },
329
+ {
330
+ id: 'hooks-learning-routing',
331
+ name: 'Hooks, Coverage & Learning Routing',
332
+ description: 'Lifecycle hooks, coverage-aware routing, background workers, and validated pattern capture.',
333
+ prefixes: ['hooks_', 'coverage_'],
334
+ taskSignals: ['hook', 'coverage', 'route', 'worker', 'learning'],
335
+ commands: ['hooks pre-task', 'hooks post-task', 'hooks route', 'hooks coverage-gaps'],
336
+ skills: ['hooks-automation'],
337
+ agents: [],
338
+ maturity: 'stable',
339
+ authority: 'capability-plane',
340
+ risk: 'reversible',
341
+ riskFlags: ['local-write', 'memory-poisoning', 'concurrency'],
342
+ useWhen: 'Routing work, measuring coverage, or recording validated outcomes.',
343
+ verifyBeforeUse: ['Hooks advise and record; Codex or another executor performs the work.'],
344
+ },
345
+ {
346
+ id: 'analysis-quality',
347
+ name: 'Analysis & Quality',
348
+ description: 'Code/project analysis, quality assessment, and change inspection.',
349
+ prefixes: ['analyze_', 'analysis_'],
350
+ taskSignals: ['analyze', 'review', 'quality', 'dependency'],
351
+ commands: ['analyze code', 'analyze project'],
352
+ skills: ['verification-quality'],
353
+ agents: ['code-analyzer', 'reviewer'],
354
+ maturity: 'stable',
355
+ authority: 'advisory',
356
+ risk: 'read-only',
357
+ useWhen: 'Understanding a codebase or validating change impact.',
358
+ verifyBeforeUse: ['Bind conclusions to the inspected source state.'],
359
+ },
360
+ {
361
+ id: 'test-generation',
362
+ name: 'TDD Test Generation',
363
+ description: 'TDD repair and test-generation capability exported by Ruflo but intentionally reported as unregistered until the MCP registry enables it.',
364
+ prefixes: ['testgen_'],
365
+ exactTools: ['testgen_tdd_repair'],
366
+ taskSignals: ['generate tests', 'tdd repair', 'test generation'],
367
+ commands: [],
368
+ skills: ['verification-quality'],
369
+ agents: ['tester'],
370
+ maturity: 'experimental',
371
+ authority: 'capability-plane',
372
+ risk: 'reversible',
373
+ availabilityMode: 'registered-degraded',
374
+ riskFlags: ['local-write'],
375
+ loopPhases: ['execute', 'validate-critique'],
376
+ useWhen: 'Generating or repairing tests once the testgen tool is explicitly registered.',
377
+ verifyBeforeUse: ['Catalogued does not mean registered; check live health.registered.', 'Generated tests still require review and execution.'],
378
+ },
379
+ {
380
+ id: 'performance-neural',
381
+ name: 'Performance & Neural Optimization',
382
+ description: 'Profiling, benchmarks, learned routing, pattern training, and optimization.',
383
+ prefixes: ['performance_', 'neural_'],
384
+ taskSignals: ['performance', 'benchmark', 'profile', 'latency', 'neural', 'train'],
385
+ commands: ['performance benchmark', 'performance profile', 'neural train'],
386
+ skills: ['performance-analysis', 'neural-training'],
387
+ agents: ['performance-engineer'],
388
+ maturity: 'experimental',
389
+ authority: 'capability-plane',
390
+ risk: 'privileged',
391
+ optionalRuntime: true,
392
+ riskFlags: ['read', 'local-write', 'memory-poisoning', 'process-exec', 'spend', 'promotion'],
393
+ useWhen: 'A reproducible baseline exists and a measured optimization is needed.',
394
+ verifyBeforeUse: ['Apply hard resource/safety constraints before Pareto ranking.', 'Re-run correctness and security gates after optimization.'],
395
+ },
396
+ {
397
+ id: 'browser-web',
398
+ name: 'Browser & Web Actions',
399
+ description: 'Browser sessions, page actions, intent routing, and guarded HTTP probes.',
400
+ prefixes: ['browser_', 'http_fetch'],
401
+ taskSignals: ['browser', 'web page', 'navigate', 'click', 'http', 'fetch'],
402
+ commands: ['browser open', 'browser act'],
403
+ skills: [],
404
+ agents: [],
405
+ maturity: 'experimental',
406
+ authority: 'capability-plane',
407
+ risk: 'privileged',
408
+ optionalRuntime: true,
409
+ riskFlags: ['network', 'credential-pii', 'spend', 'approval'],
410
+ useWhen: 'Interacting with web surfaces or testing endpoints under explicit network policy.',
411
+ verifyBeforeUse: ['Check network target policy, authentication, side effects, and runtime provider health.'],
412
+ },
413
+ {
414
+ id: 'github-delivery',
415
+ name: 'GitHub & Delivery',
416
+ description: 'Issues, pull requests, workflows, releases, repository automation, and handoff.',
417
+ prefixes: ['github_', 'pr_', 'release_'],
418
+ taskSignals: ['github', 'issue', 'pull request', 'merge', 'release', 'publish'],
419
+ commands: ['github pr', 'github release'],
420
+ skills: ['github-automation', 'github-release-management'],
421
+ agents: ['pr-manager', 'release-manager'],
422
+ maturity: 'stable',
423
+ authority: 'control-plane',
424
+ risk: 'privileged',
425
+ riskFlags: ['network', 'credential-pii', 'approval', 'destructive'],
426
+ useWhen: 'Managing GitHub state after explicit authorization and validation.',
427
+ verifyBeforeUse: ['External writes require current authorization.', 'Publish immutable artifacts from a clean, exact source state.'],
428
+ },
429
+ {
430
+ id: 'business-collaboration',
431
+ name: 'AgentBBS & Business Pods',
432
+ description: 'Federated business rooms, domain-affinity routing, and business-pod validation.',
433
+ // Metadata classification only; execution remains behind the existing loadAgentbbs guard.
434
+ prefixes: ['agentbbs_', 'business_pod_', 'federation_bbs_'],
435
+ taskSignals: ['business pod', 'bbs', 'room', 'domain affinity'],
436
+ commands: [],
437
+ skills: [],
438
+ agents: [],
439
+ maturity: 'experimental',
440
+ authority: 'capability-plane',
441
+ risk: 'privileged',
442
+ optionalRuntime: true,
443
+ riskFlags: ['network', 'credential-pii', 'spend', 'concurrency'],
444
+ useWhen: 'Coordinating business-domain agents across a federated room or pod.',
445
+ verifyBeforeUse: ['Authenticate room membership and enforce claim/resource policy at ingress.'],
446
+ },
447
+ {
448
+ id: 'configuration-transfer',
449
+ name: 'Configuration & Transfer',
450
+ description: 'Configuration state plus portable import, export, backup, and migration.',
451
+ prefixes: ['config_', 'transfer_'],
452
+ taskSignals: ['config', 'setup', 'import', 'export', 'backup', 'migrate'],
453
+ commands: ['config show', 'memory export'],
454
+ skills: [],
455
+ agents: [],
456
+ maturity: 'stable',
457
+ authority: 'control-plane',
458
+ risk: 'privileged',
459
+ riskFlags: ['read', 'local-write', 'credential-pii', 'destructive'],
460
+ useWhen: 'Inspecting configuration or moving Ruflo state between installations.',
461
+ verifyBeforeUse: ['Redact secrets and validate destination compatibility before mutation.'],
462
+ },
463
+ {
464
+ id: 'system-terminal',
465
+ name: 'System & Terminal Compatibility',
466
+ description: 'System diagnostics and legacy-compatible terminal execution surfaces.',
467
+ prefixes: ['system_', 'terminal_', 'mcp_'],
468
+ taskSignals: ['terminal', 'shell', 'doctor', 'system status'],
469
+ commands: ['doctor', 'status'],
470
+ skills: [],
471
+ agents: [],
472
+ maturity: 'compatibility',
473
+ authority: 'control-plane',
474
+ risk: 'privileged',
475
+ riskFlags: ['read', 'local-write', 'process-exec', 'credential-pii', 'destructive', 'approval'],
476
+ useWhen: 'Diagnosing Ruflo or using an MCP execution surface that policy explicitly permits.',
477
+ verifyBeforeUse: ['Prefer native executor tools for ordinary shell/file work.', 'Validate command, cwd, environment, timeout, and destructive scope.'],
478
+ },
479
+ {
480
+ id: 'runtime-services',
481
+ name: 'Other Registered Runtime Services',
482
+ description: 'Live MCP tools not yet assigned to a specialized domain; included so coverage is never silently incomplete.',
483
+ prefixes: [],
484
+ taskSignals: [],
485
+ commands: [],
486
+ skills: [],
487
+ agents: [],
488
+ maturity: 'experimental',
489
+ authority: 'capability-plane',
490
+ risk: 'privileged',
491
+ useWhen: 'Only after inspecting the tool schema and policy because specialized guidance is not yet available.',
492
+ verifyBeforeUse: ['Treat fallback classification as a guidance coverage gap.', 'Inspect the tool description, schema, side effects, and policy before use.'],
493
+ },
494
+ ];
495
+ function toolMatchesDomain(tool, domain) {
496
+ if (domain.exactTools?.includes(tool.name))
497
+ return true;
498
+ return domain.prefixes.some((prefix) => tool.name.startsWith(prefix));
499
+ }
500
+ export function classifyCapabilityTool(tool) {
501
+ return CAPABILITY_DOMAINS.find((domain) => domain.id !== 'runtime-services' && toolMatchesDomain(tool, domain)) ?? CAPABILITY_DOMAINS[CAPABILITY_DOMAINS.length - 1];
502
+ }
503
+ function defaultAvailabilityMode(definition) {
504
+ if (definition.availabilityMode)
505
+ return definition.availabilityMode;
506
+ if (definition.id === 'browser-web')
507
+ return 'conditional-registration';
508
+ if (definition.id === 'github-delivery' || definition.id === 'business-collaboration') {
509
+ return 'configured-remote';
510
+ }
511
+ if (definition.optionalRuntime)
512
+ return 'registered-degraded';
513
+ return 'always-local';
514
+ }
515
+ function defaultRiskFlags(definition) {
516
+ if (definition.riskFlags)
517
+ return [...definition.riskFlags];
518
+ if (definition.risk === 'read-only')
519
+ return ['read'];
520
+ if (definition.risk === 'reversible')
521
+ return ['local-write'];
522
+ return definition.authority === 'control-plane'
523
+ ? ['approval', 'local-write']
524
+ : ['local-write', 'concurrency'];
525
+ }
526
+ function defaultLoopPhases(definition) {
527
+ if (definition.loopPhases)
528
+ return [...definition.loopPhases];
529
+ if (definition.authority === 'advisory')
530
+ return ['discover', 'validate-critique', 'observe'];
531
+ if (definition.authority === 'control-plane')
532
+ return ['authorize-claim', 'execute', 'publish'];
533
+ return ['route-plan', 'execute', 'observe'];
534
+ }
535
+ const TOOL_OWNERSHIP = [
536
+ { prefixes: ['policy_'], packageOwner: '@claude-flow/security', pluginOwner: 'ruflo-security-audit' },
537
+ { prefixes: ['aidefence_', 'security_'], packageOwner: '@claude-flow/aidefence', pluginOwner: 'ruflo-aidefence' },
538
+ { prefixes: ['claims_'], packageOwner: '@claude-flow/claims', pluginOwner: 'ruflo-core' },
539
+ { prefixes: ['memory_'], packageOwner: '@claude-flow/memory', pluginOwner: 'ruflo-rag-memory' },
540
+ { prefixes: ['agentdb_'], packageOwner: 'agentdb', pluginOwner: 'ruflo-agentdb' },
541
+ { prefixes: ['embeddings_'], packageOwner: '@claude-flow/embeddings', pluginOwner: 'ruflo-rag-memory' },
542
+ { prefixes: ['swarm_', 'coordination_'], packageOwner: '@claude-flow/swarm', pluginOwner: 'ruflo-swarm' },
543
+ { prefixes: ['hooks_', 'coverage_'], packageOwner: '@claude-flow/hooks', pluginOwner: 'ruflo-loop-workers' },
544
+ { prefixes: ['neural_'], packageOwner: '@claude-flow/neural', pluginOwner: 'ruflo-intelligence' },
545
+ { prefixes: ['ruvllm_'], packageOwner: '@ruvector/ruvllm', pluginOwner: 'ruflo-ruvllm' },
546
+ { prefixes: ['browser_'], packageOwner: '@claude-flow/browser', pluginOwner: 'ruflo-browser' },
547
+ { prefixes: ['metaharness_'], packageOwner: 'metaharness', pluginOwner: 'ruflo-metaharness' },
548
+ { prefixes: ['agenticow_'], packageOwner: 'agenticow', pluginOwner: 'ruflo-rvf' },
549
+ { prefixes: ['federation_bbs_'], packageOwner: '@claude-flow/plugin-agent-federation', pluginOwner: 'ruflo-bbs-federation' },
550
+ { prefixes: ['business_pod_'], packageOwner: '@claude-flow/cli', pluginOwner: 'ruflo-business-pods' },
551
+ { prefixes: ['testgen_'], packageOwner: '@claude-flow/cli', pluginOwner: 'ruflo-testgen' },
552
+ { prefixes: ['managed_agent_', 'wasm_agent_', 'wasm_gallery_'], packageOwner: '@claude-flow/cli', pluginOwner: 'ruflo-agent' },
553
+ { prefixes: ['guidance_'], packageOwner: '@claude-flow/guidance', pluginOwner: 'ruflo-core' },
554
+ ];
555
+ function ownershipForTool(toolName, definition) {
556
+ const explicit = TOOL_OWNERSHIP.find((entry) => entry.prefixes.some((prefix) => toolName.startsWith(prefix)));
557
+ if (explicit) {
558
+ return {
559
+ packageOwner: explicit.packageOwner,
560
+ ...(explicit.pluginOwner ? { pluginOwner: explicit.pluginOwner } : {}),
561
+ };
562
+ }
563
+ return {
564
+ packageOwner: definition.packageOwners?.[0] ?? '@claude-flow/cli',
565
+ ...(definition.pluginOwners?.[0] ? { pluginOwner: definition.pluginOwners[0] } : {}),
566
+ };
567
+ }
568
+ export function buildCapabilityBrain(registeredTools, now = new Date()) {
569
+ const seen = new Set();
570
+ const duplicates = new Set();
571
+ const toolsByDomain = new Map();
572
+ const fallbackClassifiedTools = [];
573
+ for (const tool of registeredTools) {
574
+ if (seen.has(tool.name))
575
+ duplicates.add(tool.name);
576
+ seen.add(tool.name);
577
+ const domain = classifyCapabilityTool(tool);
578
+ if (domain.id === 'runtime-services')
579
+ fallbackClassifiedTools.push(tool.name);
580
+ const tools = toolsByDomain.get(domain.id) ?? [];
581
+ tools.push({ ...tool });
582
+ toolsByDomain.set(domain.id, tools);
583
+ }
584
+ const domains = CAPABILITY_DOMAINS.map((definition) => {
585
+ const packageOwners = definition.packageOwners ?? ['@claude-flow/cli'];
586
+ const pluginOwners = definition.pluginOwners ?? [];
587
+ const availabilityMode = defaultAvailabilityMode(definition);
588
+ const riskFlags = defaultRiskFlags(definition);
589
+ const loopPhases = defaultLoopPhases(definition);
590
+ const tools = (toolsByDomain.get(definition.id) ?? [])
591
+ .sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
592
+ .map((tool) => {
593
+ const ownership = ownershipForTool(tool.name, definition);
594
+ return {
595
+ ...tool,
596
+ domain: definition.id,
597
+ packageOwner: ownership.packageOwner,
598
+ ...(ownership.pluginOwner ? { pluginOwner: ownership.pluginOwner } : {}),
599
+ availabilityMode,
600
+ authority: definition.authority,
601
+ risk: definition.risk,
602
+ riskFlags: [...riskFlags],
603
+ loopPhases: [...loopPhases],
604
+ };
605
+ });
606
+ return {
607
+ ...definition,
608
+ prefixes: [...definition.prefixes],
609
+ exactTools: definition.exactTools ? [...definition.exactTools] : undefined,
610
+ taskSignals: [...definition.taskSignals],
611
+ commands: [...definition.commands],
612
+ skills: [...definition.skills],
613
+ agents: [...definition.agents],
614
+ packageOwners: [...packageOwners],
615
+ pluginOwners: [...pluginOwners],
616
+ availabilityMode,
617
+ riskFlags,
618
+ loopPhases,
619
+ tools,
620
+ health: {
621
+ registered: tools.length > 0,
622
+ configured: 'unknown',
623
+ reachable: 'unknown',
624
+ healthy: 'unknown',
625
+ authorized: 'unknown',
626
+ },
627
+ };
628
+ });
629
+ const uniqueToolCount = seen.size;
630
+ const classifiedToolCount = uniqueToolCount;
631
+ return {
632
+ schemaVersion: 'ruflo.capability-brain/v1',
633
+ generatedAt: now.toISOString(),
634
+ truthModel: {
635
+ catalogued: 'Described by this version of Ruflo; it does not prove runtime presence.',
636
+ registered: 'Present in this process MCP registry; it does not prove configuration or health.',
637
+ configured: 'Required providers and settings are present.',
638
+ reachable: 'Dependencies answer a non-mutating probe.',
639
+ healthy: 'Dependencies satisfy their service-specific health contract.',
640
+ authorized: 'Current subject is allowed to perform the exact action on the exact resource.',
641
+ },
642
+ domains,
643
+ cliCommands: [...RUFLO_CLI_COMMANDS],
644
+ implementationLoop: IMPLEMENTATION_LOOP.map((step) => ({
645
+ ...step,
646
+ preferredTools: [...step.preferredTools],
647
+ })),
648
+ coverage: {
649
+ registeredToolCount: uniqueToolCount,
650
+ classifiedToolCount,
651
+ coveragePercent: uniqueToolCount === 0 ? 100 : 100,
652
+ fallbackClassifiedTools: fallbackClassifiedTools.sort(),
653
+ duplicateToolNames: [...duplicates].sort(),
654
+ },
655
+ };
656
+ }
657
+ export function recommendCapabilities(brain, task) {
658
+ const normalized = task.toLocaleLowerCase('en-US');
659
+ const scored = brain.domains
660
+ .filter((domain) => domain.id !== 'runtime-services')
661
+ .map((domain) => {
662
+ const score = domain.taskSignals.reduce((total, signal) => normalized.includes(signal.toLocaleLowerCase('en-US')) ? total + 1 : total, 0);
663
+ return { domain, score };
664
+ })
665
+ .filter(({ score }) => score > 0)
666
+ .sort((left, right) => right.score - left.score || (left.domain.id < right.domain.id ? -1 : left.domain.id > right.domain.id ? 1 : 0))
667
+ .slice(0, 6);
668
+ const selected = scored.length > 0
669
+ ? scored
670
+ : brain.domains
671
+ .filter((domain) => ['guidance', 'tasks-workflows-sessions'].includes(domain.id))
672
+ .map((domain) => ({ domain, score: 0 }));
673
+ return {
674
+ task,
675
+ domains: selected.map(({ domain, score }) => ({
676
+ id: domain.id,
677
+ name: domain.name,
678
+ score,
679
+ registeredTools: domain.tools.map((tool) => tool.name),
680
+ health: { ...domain.health },
681
+ authority: domain.authority,
682
+ risk: domain.risk,
683
+ verifyBeforeUse: [...domain.verifyBeforeUse],
684
+ })),
685
+ implementationLoop: brain.implementationLoop.map((step) => ({
686
+ ...step,
687
+ preferredTools: step.preferredTools.filter((name) => brain.domains.some((domain) => domain.tools.some((tool) => tool.name === name))),
688
+ })),
689
+ guardrails: [
690
+ 'Registered, configured, reachable, healthy, and authorized are independent facts.',
691
+ 'Ruflo coordinates and records; the executor performs implementation.',
692
+ 'Learning, optimization, consensus, and claims are capability-plane inputs, never self-authorizing promotion.',
693
+ 'External publication requires explicit authority and exact source/build evidence.',
694
+ ],
695
+ };
696
+ }
697
+ //# sourceMappingURL=capability-brain.js.map