π 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
fix(3.7.0-alpha.12): batch resolve issue-fix loop #1839-#1847
Reuven1884ed10100d
diff --git a/package.json b/package.jsonindex 945ee6e346..726eb8a6d9 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "claude-flow",- "version": "3.7.0-alpha.11",+ "version": "3.7.0-alpha.12","description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "dist/index.js","type": "module",diff --git a/ruflo/package.json b/ruflo/package.jsonindex 4fa0ae0672..aae98c8453 100644--- a/ruflo/package.json+++ b/ruflo/package.json@@ -1,6 +1,6 @@{"name": "ruflo",- "version": "3.7.0-alpha.11",+ "version": "3.7.0-alpha.12","description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "bin/ruflo.js","type": "module",diff --git a/v3/@claude-flow/cli/__tests__/plugins-transfer-deep.test.ts b/v3/@claude-flow/cli/__tests__/plugins-transfer-deep.test.tsindex 338be0dd46..378eeb4a1b 100644--- a/v3/@claude-flow/cli/__tests__/plugins-transfer-deep.test.ts+++ b/v3/@claude-flow/cli/__tests__/plugins-transfer-deep.test.ts@@ -898,7 +898,7 @@ describe('Config Adapter', () => {const v3 = systemConfigToV3Config({} as any);const sys = v3ConfigToSystemConfig(v3);expect(sys.swarm?.topology).toBe('hierarchical');- expect(sys.mcp?.name).toBe('claude-flow');+ expect(sys.mcp?.name).toBe('ruflo');});it('should denormalize hybrid topology to hierarchical-mesh', () => {diff --git a/v3/@claude-flow/cli/bin/cli.js b/v3/@claude-flow/cli/bin/cli.jsindex a479a8ed1c..e3ae8977d4 100755--- a/v3/@claude-flow/cli/bin/cli.js+++ b/v3/@claude-flow/cli/bin/cli.js@@ -134,7 +134,7 @@ if (isMCPMode) {id: message.id,result: {protocolVersion: '2024-11-05',- serverInfo: { name: 'claude-flow', version: VERSION },+ serverInfo: { name: 'ruflo', version: VERSION },capabilities: {tools: { listChanged: true },resources: { subscribe: true, listChanged: true },diff --git a/v3/@claude-flow/cli/bin/mcp-server.js b/v3/@claude-flow/cli/bin/mcp-server.jsindex 60801cf240..121c779dcf 100755--- a/v3/@claude-flow/cli/bin/mcp-server.js+++ b/v3/@claude-flow/cli/bin/mcp-server.js@@ -138,7 +138,7 @@ async function handleMessage(message) {id: message.id,result: {protocolVersion: '2024-11-05',- serverInfo: { name: 'claude-flow', version: VERSION },+ serverInfo: { name: 'ruflo', version: VERSION },capabilities: {tools: { listChanged: true },resources: { subscribe: true, listChanged: true },diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.jsonindex ab40eeca7f..81eada4779 100644--- a/v3/@claude-flow/cli/package.json+++ b/v3/@claude-flow/cli/package.json@@ -1,6 +1,6 @@{"name": "@claude-flow/cli",- "version": "3.7.0-alpha.11",+ "version": "3.7.0-alpha.12","type": "module","description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code","main": "dist/src/index.js",@@ -101,7 +101,8 @@"@claude-flow/shared": "^3.0.0-alpha.7","@noble/ed25519": "^2.1.0","@ruvector/rabitq-wasm": "^0.1.0",- "semver": "^7.6.0"+ "semver": "^7.6.0",+ "yaml": "^2.8.0"},"optionalDependencies": {"@claude-flow/aidefence": "^3.0.2",diff --git a/v3/@claude-flow/cli/src/commands/doctor.ts b/v3/@claude-flow/cli/src/commands/doctor.tsindex cd2cbffbcd..3313025fbb 100644--- a/v3/@claude-flow/cli/src/commands/doctor.ts+++ b/v3/@claude-flow/cli/src/commands/doctor.ts@@ -272,31 +272,74 @@ async function checkAIDefence(): Promise<HealthCheck> {// Check MCP serversasync function checkMcpServers(): Promise<HealthCheck> {+ const home = process.env.HOME || process.env.USERPROFILE || '';+ // #1842: ~/.claude.json holds project-scoped registrations under+ // parsed.projects[<projectPath>].mcpServers.ruflo, in addition to any+ // top-level mcpServers. Check both shapes plus the legacy desktop and+ // local .mcp.json paths.const mcpConfigPaths = [- join(process.env.HOME || '', '.claude/claude_desktop_config.json'),- join(process.env.HOME || '', '.config/claude/mcp.json'),- '.mcp.json'+ join(home, '.claude.json'),+ join(home, '.claude/claude_desktop_config.json'),+ join(home, '.config/claude/mcp.json'),+ '.mcp.json',];+ const isRufloKey = (k: string) =>+ k === 'ruflo' || k === 'ruflo_alpha' || k === 'claude-flow' || k === 'claude-flow_alpha';+for (const configPath of mcpConfigPaths) {- if (existsSync(configPath)) {- try {- const content = JSON.parse(readFileSync(configPath, 'utf8'));- const servers = content.mcpServers || content.servers || {};- const count = Object.keys(servers).length;- const hasClaudeFlow = 'claude-flow' in servers || 'claude-flow_alpha' in servers || 'ruflo' in servers || 'ruflo_alpha' in servers;- if (hasClaudeFlow) {- return { name: 'MCP Servers', status: 'pass', message: `${count} servers (ruflo configured)` };- } else {- return { name: 'MCP Servers', status: 'warn', message: `${count} servers (ruflo not found)`, fix: 'claude mcp add ruflo -- npx -y ruflo@latest mcp start' };+ if (!existsSync(configPath)) continue;+ try {+ const content = JSON.parse(readFileSync(configPath, 'utf8'));+ // Top-level mcpServers (legacy / desktop form)+ const topServers = content.mcpServers || content.servers || {};+ const topServerKeys = Object.keys(topServers);+ const topHasRuflo = topServerKeys.some(isRufloKey);++ // Project-scoped (Claude Code shape): projects[*].mcpServers.ruflo+ let projectHits = 0;+ let projectScannedServers = 0;+ if (content.projects && typeof content.projects === 'object') {+ for (const projectVal of Object.values(content.projects)) {+ const pm = (projectVal as { mcpServers?: Record<string, unknown> })?.mcpServers;+ if (pm && typeof pm === 'object') {+ const keys = Object.keys(pm);+ projectScannedServers += keys.length;+ if (keys.some(isRufloKey)) projectHits += 1;+ }}- } catch {- // continue to next path}++ const totalServers = topServerKeys.length + projectScannedServers;+ if (topHasRuflo || projectHits > 0) {+ const where = topHasRuflo+ ? 'top-level'+ : `${projectHits} project-scoped`;+ return {+ name: 'MCP Servers',+ status: 'pass',+ message: `${totalServers} servers (ruflo configured: ${where})`,+ };+ }+ if (totalServers > 0) {+ return {+ name: 'MCP Servers',+ status: 'warn',+ message: `${totalServers} servers (ruflo not found)`,+ fix: 'claude mcp add ruflo -- npx -y ruflo@latest mcp start',+ };+ }+ } catch {+ // continue to next path}}- return { name: 'MCP Servers', status: 'warn', message: 'No MCP config found', fix: 'claude mcp add claude-flow npx @claude-flow/cli@v3alpha mcp start' };+ return {+ name: 'MCP Servers',+ status: 'warn',+ message: 'No MCP config found',+ fix: 'claude mcp add ruflo -- npx -y ruflo@latest mcp start',+ };}// Check disk space (async with proper env inheritance)diff --git a/v3/@claude-flow/cli/src/commands/memory.ts b/v3/@claude-flow/cli/src/commands/memory.tsindex a37b4ad79d..2982d24e4f 100644--- a/v3/@claude-flow/cli/src/commands/memory.ts+++ b/v3/@claude-flow/cli/src/commands/memory.ts@@ -346,9 +346,29 @@ const searchCommand: Command = {let smartStats: Record<string, unknown> | undefined;let backendLabel = 'HNSW + sql.js';+ // #1846: feature-detect smartSearch β older published builds of+ // @claude-flow/memory don't expose it. Fall through to plain+ // semantic search with a one-line warning instead of throwing.+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ let smartSearchFn: any | undefined;if (useSmart) {- const { smartSearch } = await import('@claude-flow/memory');+ try {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const memMod: any = await import('@claude-flow/memory');+ if (typeof memMod.smartSearch === 'function') {+ smartSearchFn = memMod.smartSearch;+ }+ } catch {+ /* memory package not loadable */+ }+ if (!smartSearchFn) {+ output.printWarning(+ 'Smart search requested but smartSearch is not available on the installed @claude-flow/memory build (#1846). Falling back to standard semantic search.',+ );+ }+ }+ if (useSmart && smartSearchFn) {// Adapt searchEntries to the SearchFn interfaceconst rawSearch = async (req: { query: string; namespace?: string; limit?: number; threshold?: number }) => {const r = await searchEntries({@@ -368,14 +388,14 @@ const searchCommand: Command = {};};- const smartResult = await smartSearch(rawSearch, {+ const smartResult = await smartSearchFn(rawSearch, {query,namespace,limit,threshold,});- results = smartResult.results.map(r => ({+ results = smartResult.results.map((r: { content: string; key: string; namespace: string; score: number }) => ({key: r.key,score: r.score,namespace: r.namespace,diff --git a/v3/@claude-flow/cli/src/config-adapter.ts b/v3/@claude-flow/cli/src/config-adapter.tsindex 4574f9e93a..b59be06ea4 100644--- a/v3/@claude-flow/cli/src/config-adapter.ts+++ b/v3/@claude-flow/cli/src/config-adapter.ts@@ -132,7 +132,7 @@ export function v3ConfigToSystemConfig(v3Config: V3Config): Partial<SystemConfig},mcp: {- name: 'claude-flow',+ name: 'ruflo',version: '3.0.0',transport: {type: v3Config.mcp.transportType as 'stdio' | 'http' | 'websocket',diff --git a/v3/@claude-flow/cli/src/index.ts b/v3/@claude-flow/cli/src/index.tsindex 5678a6b027..251cd44767 100644--- a/v3/@claude-flow/cli/src/index.ts+++ b/v3/@claude-flow/cli/src/index.ts@@ -416,25 +416,28 @@ export class CLI {}// Walk into subcommands following the path so `hive-mind spawn --help`- // renders spawn's help, not hive-mind's parent help.- const titleParts: string[] = [command.name];+ // renders spawn's help, not hive-mind's parent help. We use a non-null+ // local (`current`) instead of reassigning the optional `command` so+ // TS can prove the value is defined for the rest of the function.+ let current: Command = command;+ const titleParts: string[] = [current.name];for (let i = 1; i < commandPath.length; i++) {const subName = commandPath[i];- const sub = command.subcommands?.find(sc => sc.name === subName || sc.aliases?.includes(subName));+ const sub = current.subcommands?.find(sc => sc.name === subName || sc.aliases?.includes(subName));if (!sub) break; // unknown leaf β fall back to last known- command = sub;+ current = sub;titleParts.push(sub.name);}this.output.writeln();this.output.writeln(this.output.bold(`${this.name} ${titleParts.join(' ')}`));- this.output.writeln(command.description);+ this.output.writeln(current.description);this.output.writeln();// Subcommands- if (command.subcommands && command.subcommands.length > 0) {+ if (current.subcommands && current.subcommands.length > 0) {this.output.writeln(this.output.bold('SUBCOMMANDS:'));- for (const sub of command.subcommands) {+ for (const sub of current.subcommands) {if (sub.hidden) continue;const name = sub.name.padEnd(15);const aliases = sub.aliases ? this.output.dim(` (${sub.aliases.join(', ')})`) : '';@@ -444,9 +447,9 @@ export class CLI {}// Options- if (command.options && command.options.length > 0) {+ if (current.options && current.options.length > 0) {this.output.writeln(this.output.bold('OPTIONS:'));- for (const opt of command.options) {+ for (const opt of current.options) {const flags = opt.short ? `-${opt.short}, --${opt.name}` : ` --${opt.name}`;const required = opt.required ? this.output.error(' (required)') : '';const defaultVal = opt.default !== undefined ? this.output.dim(` [default: ${opt.default}]`) : '';@@ -456,9 +459,9 @@ export class CLI {}// Examples- if (command.examples && command.examples.length > 0) {+ if (current.examples && current.examples.length > 0) {this.output.writeln(this.output.bold('EXAMPLES:'));- for (const example of command.examples) {+ for (const example of current.examples) {this.output.writeln(` ${this.output.dim('$')} ${example.command}`);this.output.writeln(` ${this.output.dim(example.description)}`);}diff --git a/v3/@claude-flow/cli/src/init/executor.ts b/v3/@claude-flow/cli/src/init/executor.tsindex ff423159c5..4c187112cb 100644--- a/v3/@claude-flow/cli/src/init/executor.ts+++ b/v3/@claude-flow/cli/src/init/executor.ts@@ -796,28 +796,59 @@ function detectExistingRufloMCP(targetDir: string): string | null {candidates.add(path.join(home, '.claude', 'mcp.json'));}// Walk parents of targetDir up to root, checking for .mcp.json at each- let dir = path.resolve(targetDir);+ const targetResolved = path.resolve(targetDir);+ let dir = targetResolved;+ const targetAncestors = new Set<string>();while (true) {candidates.add(path.join(dir, '.mcp.json'));+ targetAncestors.add(normalizeProjectKey(dir));const parent = path.dirname(dir);if (parent === dir) break;dir = parent;}// Skip the targetDir itself β that's the one we're about to write- candidates.delete(path.join(path.resolve(targetDir), '.mcp.json'));+ candidates.delete(path.join(targetResolved, '.mcp.json'));for (const candidate of candidates) {if (!fs.existsSync(candidate)) continue;try {const parsed = JSON.parse(fs.readFileSync(candidate, 'utf-8'));- if (parsed && typeof parsed === 'object' && parsed.mcpServers && typeof parsed.mcpServers === 'object') {+ if (!parsed || typeof parsed !== 'object') continue;+ // (a) Top-level mcpServers (legacy / global form)+ if (parsed.mcpServers && typeof parsed.mcpServers === 'object') {if ('ruflo' in parsed.mcpServers) return candidate;}+ // (b) #1840: Claude Code project-scoped registrations under+ // parsed.projects[<projectPath>].mcpServers.ruflo. Match by+ // normalized path against targetDir or any of its ancestors so+ // a `claude mcp add ruflo` in this repo is detected even when+ // Claude stored the key with different casing/slash style.+ if (parsed.projects && typeof parsed.projects === 'object') {+ for (const [projectKey, projectVal] of Object.entries(parsed.projects)) {+ if (!projectVal || typeof projectVal !== 'object') continue;+ const projectMcp = (projectVal as { mcpServers?: unknown }).mcpServers;+ if (!projectMcp || typeof projectMcp !== 'object') continue;+ if (!('ruflo' in (projectMcp as Record<string, unknown>))) continue;+ if (targetAncestors.has(normalizeProjectKey(projectKey))) {+ return `${candidate} (projects[${projectKey}])`;+ }+ }+ }} catch { /* malformed JSON β ignore */ }}return null;}+/**+ * Normalize a project path key for cross-platform comparison.+ * Claude Code stores Windows paths like "C:/Users/.../Project" while+ * Node's `path.resolve()` may emit "C:\Users\...\Project". Lowercase ++ * forward-slash gives a stable comparison key on both platforms.+ */+function normalizeProjectKey(p: string): string {+ return path.resolve(p).replace(/\\/g, '/').toLowerCase();+}+/*** Write .mcp.json*/diff --git a/v3/@claude-flow/cli/src/init/mcp-generator.ts b/v3/@claude-flow/cli/src/init/mcp-generator.tsindex 3f67ce66f8..12da14e4f3 100644--- a/v3/@claude-flow/cli/src/init/mcp-generator.ts+++ b/v3/@claude-flow/cli/src/init/mcp-generator.ts@@ -52,9 +52,9 @@ export function generateMCPConfig(options: InitOptions): object {npm_config_update_notifier: 'false',};- // Claude Flow MCP server (core) β uses ruflo wrapper for portable npm-resolved invocation+ // Ruflo MCP server (core) β uses ruflo wrapper for portable npm-resolved invocationif (config.claudeFlow) {- mcpServers['claude-flow'] = createMCPServerEntry(+ mcpServers['ruflo'] = createMCPServerEntry(['ruflo@latest', 'mcp', 'start'],{...npmEnv,@@ -106,7 +106,7 @@ export function generateMCPCommands(options: InitOptions): string[] {if (isWindows()) {if (config.claudeFlow) {- commands.push('claude mcp add claude-flow -- cmd /c npx -y ruflo@latest mcp start');+ commands.push('claude mcp add ruflo -- cmd /c npx -y ruflo@latest mcp start');}if (config.ruvSwarm) {commands.push('claude mcp add ruv-swarm -- cmd /c npx -y ruv-swarm mcp start');@@ -116,7 +116,7 @@ export function generateMCPCommands(options: InitOptions): string[] {}} else {if (config.claudeFlow) {- commands.push("claude mcp add claude-flow -- npx -y ruflo@latest mcp start");+ commands.push("claude mcp add ruflo -- npx -y ruflo@latest mcp start");}if (config.ruvSwarm) {commands.push("claude mcp add ruv-swarm -- npx -y ruv-swarm mcp start");diff --git a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.tsindex 52ece84ac3..3aae9071ad 100644--- a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts@@ -1573,6 +1573,21 @@ export const hooksPretrain: MCPTool = {patternsStored = patterns.length;} catch { /* AgentDB not available */ }+ // #1847: when the corpus contains files but no patterns were extracted+ // (typical for Markdown vaults), make the source-code-only extraction+ // contract explicit so users don't conclude the hook system is broken.+ const SUPPORTED_EXTRACTION_EXTS = ['.ts', '.js', '.py', '.go', '.rs', '.java'];+ let note: string | undefined;+ if (filesAnalyzed > 0 && patterns.length === 0) {+ const codeFileCount = SUPPORTED_EXTRACTION_EXTS.reduce(+ (sum, ext) => sum + (extCounts[ext] ?? 0),+ 0,+ );+ note = codeFileCount === 0+ ? `No source-code patterns found. hooks_pretrain extracts import/require lines from ${SUPPORTED_EXTRACTION_EXTS.join('/')} files only β Markdown/text/asset corpora produce zero patterns by design. This is not a hook-system failure; live trajectories and statusline are independent.`+ : `Found ${codeFileCount} source-code file(s) but extracted zero import/require patterns. They may be empty, generated, or use non-standard module syntax.`;+ }+return {success: true,_real: true,@@ -1585,7 +1600,14 @@ export const hooksPretrain: MCPTool = {patternsExtracted: patterns.length,patternsStored,fileTypes: Object.entries(extCounts).sort((a, b) => b[1] - a[1]).slice(0, 15).map(([ext, count]) => ({ ext, count })),+ // #1847: explicit extraction contract so callers can tell pretrain+ // patterns apart from live trajectories and hook statusline state.+ sources: {+ extractedFrom: SUPPORTED_EXTRACTION_EXTS,+ scope: 'pretrain-only (live trajectories + statusline are tracked separately)',+ },},+ ...(note ? { note } : {}),};},};@@ -3612,16 +3634,37 @@ export const hooksWorkerDispatch: MCPTool = {activeWorkers.set(workerId, worker);// Determine honest status- let reportedStatus: 'queued' | 'no-daemon' | 'synthetic-completed';- let note: string;+ let reportedStatus: 'queued' | 'no-daemon' | 'synthetic-completed' | 'mcp-only';+ let note = '';if (!daemonAlive) {reportedStatus = 'no-daemon';note = 'No worker daemon detected. Run `claude-flow daemon start` to enable real worker execution. The dispatch was recorded in-process but no actual work will run.';} else if (background) {- // Daemon is alive β record the queued worker. The daemon polls activeWorkers- // via its own state file, so this constitutes a real queue entry.- reportedStatus = 'queued';- note = `Worker queued for daemon (pid ${daemonPid}). Poll hooks_worker-status to track progression β do not assume completion until status === "completed".`;+ // #1845: write a durable queue file the daemon polls every 5s. Until+ // 3.7.0-alpha.11 the dispatch only updated a process-local Map that+ // the daemon (separate process) could never see, so `queued` was a+ // lie. The queue file makes it real and inspectable on disk.+ const queueDir = join(cwd, '.claude-flow', 'daemon-queue');+ const queuePath = join(queueDir, `${workerId}.json`);+ let queueWritten = false;+ try {+ if (!existsSync(queueDir)) mkdirSync(queueDir, { recursive: true });+ writeFileSync(+ queuePath,+ JSON.stringify({ workerId, trigger, context, priority, enqueuedAt: new Date().toISOString() }, null, 2),+ );+ queueWritten = true;+ } catch (err) {+ // Filesystem error β fall back to mcp-only status so we never+ // claim queued without proof.+ note = `Daemon detected (pid ${daemonPid}) but queue write to ${queuePath} failed: ${(err as Error).message}. Worker recorded in-process only; use \`ruflo daemon trigger -w ${trigger}\` to run synchronously.`;+ }+ if (queueWritten) {+ reportedStatus = 'queued';+ note = `Worker queued for daemon (pid ${daemonPid}) at ${queuePath}. Daemon polls every 5s; processed entries move to .claude-flow/daemon-queue/.processed/. Poll hooks_worker-status until status === "completed".`;+ } else {+ reportedStatus = 'mcp-only';+ }} else {// Synchronous mode without a runner β be honest about itreportedStatus = 'synthetic-completed';diff --git a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.tsindex 65185b81c0..45fd777702 100644--- a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts@@ -364,60 +364,84 @@ export const memoryTools: MCPTool[] = [const startTime = performance.now();try {+ // #1846: feature-detect smartSearch on the resolved memory package.+ // The export landed in @claude-flow/memory@>3.0.0-alpha.14 β older+ // installs pin to a build that exposes search/store/retrieve but+ // not smartSearch. Throwing `is not a function` is hostile; instead+ // detect at runtime and gracefully fall through to plain semantic+ // search with an explicit fallback note.+ let smartFallbackReason: string | undefined;if (input.smart) {- // SmartRetrieval pipeline (ADR-090)- const { smartSearch } = await import('@claude-flow/memory');-- // Adapt searchEntries to the SearchFn interface- const rawSearch = async (req: { query: string; namespace?: string; limit?: number; threshold?: number }) => {- const r = await searchEntries({- query: req.query,- namespace: req.namespace || namespace,- limit: req.limit || limit * 3,- threshold: req.threshold ?? threshold,- });- return {- results: r.results.map(e => ({- id: e.id,- key: e.key,- content: e.content,- score: e.score,- namespace: e.namespace,- })),+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ let memMod: any;+ try {+ memMod = await import('@claude-flow/memory');+ } catch (err) {+ smartFallbackReason = `@claude-flow/memory failed to load: ${(err as Error).message}`;+ }+ const smartSearch = memMod && typeof memMod.smartSearch === 'function'+ ? memMod.smartSearch+ : undefined;++ if (smartSearch) {+ // SmartRetrieval pipeline (ADR-090)+ const rawSearch = async (req: { query: string; namespace?: string; limit?: number; threshold?: number }) => {+ const r = await searchEntries({+ query: req.query,+ namespace: req.namespace || namespace,+ limit: req.limit || limit * 3,+ threshold: req.threshold ?? threshold,+ });+ return {+ results: r.results.map(e => ({+ id: e.id,+ key: e.key,+ content: e.content,+ score: e.score,+ namespace: e.namespace,+ })),+ };};- };- const smartResult = await smartSearch(rawSearch, {- query,- namespace,- limit,- threshold,- });+ const smartResult = await smartSearch(rawSearch, {+ query,+ namespace,+ limit,+ threshold,+ });- const duration = performance.now() - startTime;+ const duration = performance.now() - startTime;++ const results = smartResult.results.map((r: { content: string; key: string; namespace: string; score: number }) => {+ let value: unknown = r.content;+ try { value = JSON.parse(r.content); } catch { /* keep as string */ }+ return {+ key: r.key,+ namespace: r.namespace,+ value,+ similarity: r.score,+ };+ });- const results = smartResult.results.map(r => {- let value: unknown = r.content;- try { value = JSON.parse(r.content); } catch { /* keep as string */ }return {- key: r.key,- namespace: r.namespace,- value,- similarity: r.score,+ query,+ results,+ total: results.length,+ searchTime: `${duration.toFixed(2)}ms`,+ backend: 'SmartRetrieval (RRF + MMR + Recency)',+ stats: smartResult.stats,};- });+ }- return {- query,- results,- total: results.length,- searchTime: `${duration.toFixed(2)}ms`,- backend: 'SmartRetrieval (RRF + MMR + Recency)',- stats: smartResult.stats,- };+ // smart=true but smartSearch unavailable on installed package.+ // Fall through to plain search with an explicit warning.+ smartFallbackReason = smartFallbackReason+ ?? 'smartSearch is not exported by the installed @claude-flow/memory build (likely a release lag β see #1846). Falling back to standard semantic search.';}- // Original non-smart path (unchanged)+ // Original non-smart path (unchanged) β also reached when smart was+ // requested but unavailable. We attach `smartFallback` to the+ // response so callers can see the degradation explicitly.const result = await searchEntries({query,namespace,@@ -450,6 +474,7 @@ export const memoryTools: MCPTool[] = [total: results.length,searchTime: `${duration.toFixed(2)}ms`,backend: 'HNSW + sql.js',+ ...(smartFallbackReason ? { smartFallback: smartFallbackReason } : {}),};} catch (error) {return {diff --git a/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/system-tools.tsindex 726bd62f57..0d84749331 100644--- a/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts@@ -313,13 +313,21 @@ export const systemTools: MCPTool[] = [const checks: Array<{ name: string; status: string; latency?: number; message?: string }> = [];const projectCwd = getProjectCwd();- // Memory DB check β verify any supported store file exists+ // Memory DB check β verify any supported store file exists.+ // #1843: cover sql.js / HNSW / .swarm and root-level rvf/db paths,+ // not just the legacy `.claude-flow/memory/*` triple.{const t0 = performance.now();- const legacyPath = join(projectCwd, '.claude-flow', 'memory', 'store.json');- const agentDbPath = join(projectCwd, '.claude-flow', 'memory', 'agentdb.sqlite');- const rvfPath = join(projectCwd, '.claude-flow', 'memory', 'store.rvf');- const memoryExists = existsSync(legacyPath) || existsSync(agentDbPath) || existsSync(rvfPath);+ const memoryCandidates = [+ join(projectCwd, '.claude-flow', 'memory', 'store.json'), // legacy+ join(projectCwd, '.claude-flow', 'memory', 'agentdb.sqlite'),+ join(projectCwd, '.claude-flow', 'memory', 'store.rvf'),+ join(projectCwd, '.claude-flow', 'memory', 'claude-flow.db'), // sql.js+ join(projectCwd, '.swarm', 'memory.db'), // swarm+ join(projectCwd, 'ruvector.db'), // ruvector+ join(projectCwd, 'agentdb.rvf'), // root rvf+ ];+ const memoryExists = memoryCandidates.some(existsSync);const elapsed = performance.now() - t0;checks.push({name: 'memory',@@ -329,12 +337,21 @@ export const systemTools: MCPTool[] = [});}- // Config check β verify config file exists+ // Config check β verify config file exists.+ // #1843: also accept YAML config (.claude-flow/config.yaml) which+ // the rest of v3 treats as canonical; previous code only counted+ // .json variants and reported `degraded` when YAML was used.{const t0 = performance.now();- const configPath = join(projectCwd, '.claude-flow', 'config.json');- const altConfigPath = join(projectCwd, 'claude-flow.config.json');- const configExists = existsSync(configPath) || existsSync(altConfigPath);+ const configCandidates = [+ join(projectCwd, '.claude-flow', 'config.json'),+ join(projectCwd, '.claude-flow', 'config.yaml'),+ join(projectCwd, '.claude-flow', 'config.yml'),+ join(projectCwd, 'claude-flow.config.json'),+ join(projectCwd, 'claude-flow.config.yaml'),+ join(projectCwd, 'claude-flow.config.yml'),+ ];+ const configExists = configCandidates.some(existsSync);const elapsed = performance.now() - t0;checks.push({name: 'config',@@ -438,9 +455,16 @@ export const systemTools: MCPTool[] = [}}+ // #1843: exclude `unknown` checks from the health score denominator.+ // Previously a check reporting `unknown` (e.g. swarm/neural which+ // can't be probed in-process) was counted as a non-healthy hit and+ // dragged the score below 100 even when every actionable check was+ // green. Treat `unknown` as advisory and surface it separately.const healthy = checks.filter(c => c.status === 'healthy').length;+ const advisory = checks.filter(c => c.status === 'unknown').length;const total = checks.length;- const overallHealth = healthy / total;+ const scoreDenominator = total - advisory;+ const overallHealth = scoreDenominator > 0 ? healthy / scoreDenominator : 1;// Update metricsmetrics.health = overallHealth;@@ -451,9 +475,10 @@ export const systemTools: MCPTool[] = [score: Math.round(overallHealth * 100),checks,healthy,+ advisory,total,timestamp: new Date().toISOString(),- issues: checks.filter(c => c.status !== 'healthy').map(c => ({+ issues: checks.filter(c => c.status !== 'healthy' && c.status !== 'unknown').map(c => ({component: c.name,status: c.status,suggestion: `Check ${c.name} component configuration`,diff --git a/v3/@claude-flow/cli/src/services/worker-daemon.ts b/v3/@claude-flow/cli/src/services/worker-daemon.tsindex 009e9eeda3..af446cde7a 100644--- a/v3/@claude-flow/cli/src/services/worker-daemon.ts+++ b/v3/@claude-flow/cli/src/services/worker-daemon.ts@@ -114,6 +114,9 @@ export class WorkerDaemon extends EventEmitter {private config: DaemonConfig;private workers: Map<WorkerType, WorkerState> = new Map();private timers: Map<WorkerType, NodeJS.Timeout> = new Map();+ // #1845: separate timer for the MCP-dispatch queue poller. Kept off+ // the per-worker map so stop() clears both kinds without confusion.+ private queuePollTimer?: NodeJS.Timeout;private running = false;private startedAt?: Date;private projectRoot: string;@@ -268,8 +271,11 @@ export class WorkerDaemon extends EventEmitter {}/**- * Read daemon-specific config from .claude-flow/config.json- * Supports dot-notation keys like 'daemon.resourceThresholds.maxCpuLoad'+ * Read daemon-specific config from .claude-flow/config.{json,yaml,yml}.+ * Supports dot-notation keys like 'daemon.resourceThresholds.maxCpuLoad'.+ * #1844: prefer JSON when both exist (existing behavior) but fall back+ * to YAML so operators using the v3 canonical YAML format aren't silently+ * ignored. The chosen path is logged at info level.*/private readDaemonConfigFromFile(claudeFlowDir: string): {autoStart?: boolean;@@ -278,18 +284,49 @@ export class WorkerDaemon extends EventEmitter {maxCpuLoad?: number;minFreeMemoryPercent?: number;} {- const configPath = join(claudeFlowDir, 'config.json');- if (!existsSync(configPath)) {- // Warn if config.yaml exists but config.json does not (#1395 Bug 4)- const yamlPath = join(claudeFlowDir, 'config.yaml');- const ymlPath = join(claudeFlowDir, 'config.yml');- if (existsSync(yamlPath) || existsSync(ymlPath)) {- this.log('warn', `Found ${existsSync(yamlPath) ? 'config.yaml' : 'config.yml'} but daemon reads only config.json β YAML config is being ignored. Convert to JSON or create config.json.`);+ const jsonPath = join(claudeFlowDir, 'config.json');+ const yamlPath = join(claudeFlowDir, 'config.yaml');+ const ymlPath = join(claudeFlowDir, 'config.yml');++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ let raw: Record<string, any> | undefined;+ let chosenPath: string | undefined;++ if (existsSync(jsonPath)) {+ try {+ raw = JSON.parse(readFileSync(jsonPath, 'utf-8'));+ chosenPath = jsonPath;+ } catch {+ return {};}+ } else if (existsSync(yamlPath) || existsSync(ymlPath)) {+ const yPath = existsSync(yamlPath) ? yamlPath : ymlPath;+ try {+ // Lazy-load yaml so the daemon doesn't hard-require it; if the+ // dep isn't installed, fall back to the previous warn-only path.+ // eslint-disable-next-line @typescript-eslint/no-var-requires+ const yamlMod = require('yaml') as { parse(s: string): unknown };+ const parsed = yamlMod.parse(readFileSync(yPath, 'utf-8'));+ if (parsed && typeof parsed === 'object') {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ raw = parsed as Record<string, any>;+ chosenPath = yPath;+ }+ } catch {+ this.log(+ 'warn',+ `Found ${yPath} but yaml parser unavailable. Install \`yaml\` or convert to JSON. Falling back to defaults.`,+ );+ return {};+ }+ }++ if (!raw || !chosenPath) {return {};}+ this.log('info', `Daemon config loaded from ${chosenPath}`);+try {- const raw = JSON.parse(readFileSync(configPath, 'utf-8'));// Support both flat keys at root and nested under scopes.projectconst cfg = raw?.scopes?.project ?? raw;const rawCpuLoad = cfg['daemon.resourceThresholds.maxCpuLoad'] ?? raw['daemon.resourceThresholds.maxCpuLoad'];@@ -513,12 +550,78 @@ export class WorkerDaemon extends EventEmitter {}}+ // #1845: poll the MCP-dispatch queue directory so workers requested+ // via mcp__hooks_worker-dispatch (in a separate process) actually+ // execute here. Previously the dispatch wrote to a process-local Map+ // that the daemon could never see.+ this.queuePollTimer = setInterval(() => {+ void this.processDispatchQueue();+ }, 5_000);+ if (typeof this.queuePollTimer.unref === 'function') {+ this.queuePollTimer.unref();+ }+// Save statethis.saveState();this.log('info', `Daemon started (PID: ${process.pid}, CPUs: ${cpus().length}, workers: ${this.config.workers.filter(w => w.enabled).length}, maxCpuLoad: ${this.config.resourceThresholds.maxCpuLoad}, minFreeMemoryPercent: ${this.config.resourceThresholds.minFreeMemoryPercent}%)`);}+ /**+ * #1845: ingest queue entries written by mcp__hooks_worker-dispatch.+ * Each entry is a JSON file at `.claude-flow/daemon-queue/<id>.json`+ * with `{ workerId, trigger, context, enqueuedAt }`. We move processed+ * files to `.claude-flow/daemon-queue/.processed/` so the daemon never+ * re-runs the same dispatch and operators can inspect history.+ */+ private async processDispatchQueue(): Promise<void> {+ if (!this.running) return;+ const queueDir = join(this.projectRoot, '.claude-flow', 'daemon-queue');+ if (!existsSync(queueDir)) return;++ let entries: string[];+ try {+ const fs = await import('fs');+ entries = fs.readdirSync(queueDir).filter((n) => n.endsWith('.json'));+ } catch {+ return;+ }+ if (entries.length === 0) return;++ const fs = await import('fs');+ const processedDir = join(queueDir, '.processed');+ if (!existsSync(processedDir)) {+ try { fs.mkdirSync(processedDir, { recursive: true }); } catch { /* race ok */ }+ }++ for (const entry of entries) {+ const src = join(queueDir, entry);+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ let payload: any;+ try {+ payload = JSON.parse(fs.readFileSync(src, 'utf-8'));+ } catch {+ // Malformed entry β quarantine so we don't loop on it+ try { fs.renameSync(src, join(processedDir, `bad-${entry}`)); } catch { /* nothing more we can do */ }+ continue;+ }+ const trigger = payload?.trigger as WorkerType | undefined;+ const workerId = payload?.workerId as string | undefined;+ if (!trigger || !this.config.workers.some((w) => w.type === trigger)) {+ try { fs.renameSync(src, join(processedDir, `unknown-${entry}`)); } catch { /* ok */ }+ continue;+ }+ try {+ this.log('info', `Dequeued ${trigger}${workerId ? ` (id=${workerId})` : ''} from MCP dispatch queue`);+ await this.triggerWorker(trigger);+ } catch (err) {+ this.log('warn', `Queued worker ${trigger} failed: ${(err as Error).message}`);+ } finally {+ try { fs.renameSync(src, join(processedDir, entry)); } catch { /* ignore */ }+ }+ }+ }+/*** Stop the daemon and all workers*/@@ -536,6 +639,12 @@ export class WorkerDaemon extends EventEmitter {}this.timers.clear();+ // #1845: stop the MCP-dispatch queue poller too.+ if (this.queuePollTimer) {+ clearInterval(this.queuePollTimer);+ this.queuePollTimer = undefined;+ }+this.running = false;this.removePidFile();this.saveState();