* feat(workflows): add native Workflow JS orchestration surface (ADR-0002) ruflo-workflows now documents both workflow surfaces: the existing 10 workflow_* MCP tools and the native Claude Code Workflow JS capability (.claude/workflows/*.js — agent/parallel/pipeline/phase fan-out). - ADR-0002 (Accepted): adopts native orchestration alongside the MCP surface - Reference workflow .claude/workflows/plugin-contract-audit.js (fans smoke contracts across all plugins, diagnoses failures in parallel) - README: native orchestration section + four-hook API + surface decision table - workflow-create/workflow-run skills, workflow-specialist agent, /workflow command made surface-aware - plugin.json 0.3.0 -> 0.4.0; native-workflow keywords + component block - smoke.sh reconciled (stale version + ADR-0001 status) and extended 11 -> 15 checks; smoke-gaia.sh version assertion bumped to 0.4.0 Co-Authored-By: RuFlo <ruv@ruv.net> * fix(routing): #bugB stale route cache + #bugC --explore false (3.10.8) Two routing-learning correctness bugs from the intelligence audit's remaining punch-list (docs/reviews/intelligence-system-audit-2026-05-29.md §Remediation). - Bug B (stale route cache): QLearningRouter.update() only invalidated the whole route cache every 50 updates, so a freshly-learned Q-update stayed hidden behind a stale cached decision — feedback appeared to have no effect on routing in-process until 50 updates accumulated. Now update() invalidates the updated state's cache entry immediately (new invalidateCacheEntry). Verified: learned route flips coder→researcher within 10 updates (was 50+). - Bug C (--explore false ignored): boolean flags dropped an explicit space-form value, forcing a default-true boolean (explore) to true even with , so exploitation could never be forced. parser.ts now consumes a true/false literal for boolean flags (--explore false / -e false), while --explore=false and --no-explore keep working. Verified deterministic. +4 regression tests (15/15 bug-cluster pass); 52/52 parser tests pass; cli build clean. Audit doc updated with full remediation status (3.10.7 + 3.10.8 shipped; SONA-default/MicroLoRA/EWC-Fisher/per-task-bandit deferred with honest rationale — the latter two need an ADR/upstream fix, not a patch). Co-Authored-By: RuFlo <ruv@ruv.net>
CLI Module Tests
This directory contains comprehensive tests for the V3 CLI module using Vitest.
Test Files
1. cli.test.ts (~15+ tests)
Tests for the main CLI class covering:
- Version command (
--version,-V) - Help output (
--help,-h) - Command parsing (long flags, short flags, equals syntax)
- Positional arguments
- Boolean flags and negation
- Global flags (
--quiet,--format,--config,--no-color) - Error handling (unknown commands, missing options)
- Subcommand execution and aliases
- Exit codes
2. mcp-client.test.ts (~10+ tests)
Tests for MCP tool invocation:
callMCPTool()- Tool execution with various inputsgetToolMetadata()- Metadata retrievallistMCPTools()- Tool listing and filtering by categoryhasTool()- Tool existence checksgetToolCategories()- Category enumerationvalidateToolInput()- Input validation against schemasMCPClientError- Custom error handling
3. commands.test.ts (~48+ tests)
Tests for all CLI commands:
Agent Commands (spawn, list, status, stop, metrics):
- Spawning agents with various configurations
- Listing agents with filters
- Getting agent status and metrics
- Stopping agents (graceful/force)
- Agent performance metrics
Swarm Commands (init, start, status, stop, scale, coordinate):
- Initializing swarms with different topologies
- Starting swarm execution with objectives
- Checking swarm status
- Stopping and scaling swarms
- V3 15-agent coordination structure
Memory Commands (store, retrieve, search, list, delete, stats, configure):
- Storing data in memory (with/without vectors)
- Retrieving data by key
- Semantic/vector search
- Listing memory entries
- Deleting entries
- Viewing statistics
- Backend configuration
Config Commands (init, get, set, providers, reset, export, import):
- Initializing configuration
- Getting/setting config values
- Managing AI providers
- Resetting to defaults
- Exporting/importing configuration
Mocking Strategy
MCP Tools
All MCP tools are mocked at the module level to prevent actual tool execution:
agent-tools.js- Mocked agent operationsswarm-tools.js- Mocked swarm coordinationmemory-tools.js- Mocked memory operationsconfig-tools.js- Mocked configuration
Output
The output module is fully mocked to capture formatted output without console pollution.
Prompts
Interactive prompts (select, confirm, input, multiSelect) are mocked to return default values for non-interactive testing.
Process
process.exit() is mocked to throw errors instead of terminating the test process.
Running Tests
# Run all CLI tests
npm test -- v3/@claude-flow/cli/__tests__/
# Run specific test file
npm test -- v3/@claude-flow/cli/__tests__/cli.test.ts
# Run with coverage
npm test -- v3/@claude-flow/cli/__tests__/ --coverage
# Run in watch mode
npm test -- v3/@claude-flow/cli/__tests__/ --watch
Test Coverage Goals
- Statements: >80%
- Branches: >75%
- Functions: >80%
- Lines: >80%
Key Testing Patterns
1. Command Execution
const result = await command.action!(ctx);
expect(result.success).toBe(true);
expect(result.data).toHaveProperty('expectedField');
2. Flag Parsing
ctx.flags = { myFlag: 'value', _: [] };
await command.action!(ctx);
// Assertions in action callback
3. Error Handling
try {
await cli.run(['invalid-command']);
} catch (e) {
expect((e as Error).message).toContain('process.exit');
}
4. Output Validation
const output = consoleOutput.join('');
expect(output).toContain('Expected text');
Notes
- All tests are non-interactive (
interactive: false) - Console output is captured for verification
- Process exits are converted to exceptions
- MCP client is fully isolated from actual MCP server
- Tests use unique command names to avoid conflicts