diff --git a/v3/@claude-flow/cli/.claude/commands/claude-flow-help.md b/v3/@claude-flow/cli/.claude/commands/claude-flow-help.md index 8f81c6d2f6..46cb19c8ee 100644 --- a/v3/@claude-flow/cli/.claude/commands/claude-flow-help.md +++ b/v3/@claude-flow/cli/.claude/commands/claude-flow-help.md @@ -33,7 +33,7 @@ Claude-Flow is the ultimate multi-terminal orchestration platform that revolutio ### 🧠 Memory Operations - `./claude-flow memory store "key" "value"` - Store data -- `./claude-flow memory query "search"` - Search memory +- `./claude-flow memory search --query "search"` - Search memory - `./claude-flow memory stats` - Memory statistics - `./claude-flow memory export ` - Export memory - `./claude-flow memory import ` - Import memory diff --git a/v3/@claude-flow/cli/.claude/commands/claude-flow-memory.md b/v3/@claude-flow/cli/.claude/commands/claude-flow-memory.md index c0441ffb8e..77c4b6d67e 100644 --- a/v3/@claude-flow/cli/.claude/commands/claude-flow-memory.md +++ b/v3/@claude-flow/cli/.claude/commands/claude-flow-memory.md @@ -19,10 +19,10 @@ The memory system provides persistent storage for cross-session and cross-agent ## Query Memory ```bash # Search across all namespaces -./claude-flow memory query "authentication" +./claude-flow memory search --query "authentication" # Search with filters -./claude-flow memory query "API design" --namespace arch --limit 10 +./claude-flow memory search --query "API design" --namespace arch --limit 10 ``` ## Memory Statistics @@ -97,8 +97,8 @@ The memory system provides persistent storage for cross-session and cross-agent ### Query project decisions: ```bash -./claude-flow memory query "authentication" --namespace arch --limit 5 -./claude-flow memory query "test results" --namespace test +./claude-flow memory search --query "authentication" --namespace arch --limit 5 +./claude-flow memory search --query "test results" --namespace test ``` ### Backup project memory: diff --git a/v3/@claude-flow/cli/.claude/commands/claude-flow-swarm.md b/v3/@claude-flow/cli/.claude/commands/claude-flow-swarm.md index d4027c74af..80580663e3 100644 --- a/v3/@claude-flow/cli/.claude/commands/claude-flow-swarm.md +++ b/v3/@claude-flow/cli/.claude/commands/claude-flow-swarm.md @@ -145,7 +145,7 @@ Swarms automatically use distributed memory for collaboration: ./claude-flow memory store "swarm_objective" "Build scalable API" --namespace swarm # Query swarm progress -./claude-flow memory query "swarm_progress" --namespace swarm +./claude-flow memory search --query "swarm_progress" --namespace swarm # Export swarm memory ./claude-flow memory export swarm-results.json --namespace swarm diff --git a/v3/@claude-flow/cli/.claude/commands/sparc.md b/v3/@claude-flow/cli/.claude/commands/sparc.md index ed1a394795..a4253d1f65 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc.md @@ -127,7 +127,7 @@ npx @claude-flow/cli@latest memory store "spec_auth" "OAuth2 + JWT requirements" ./claude-flow memory store "arch_api" "RESTful microservices design" --namespace arch # Query previous work -./claude-flow memory query "authentication" --limit 10 +./claude-flow memory search --query "authentication" --limit 10 # Export project memory ./claude-flow memory export sparc-project-backup.json diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/ask.md b/v3/@claude-flow/cli/.claude/commands/sparc/ask.md index 682f267398..01f0b18374 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/ask.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/ask.md @@ -93,5 +93,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "ask_context" "important decisions" --namespace ask # Query previous work -npx @claude-flow/cli@latest memory query "ask" --limit 5 +npx @claude-flow/cli@latest memory search --query "ask" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/code.md b/v3/@claude-flow/cli/.claude/commands/sparc/code.md index 0cacbe5de7..f6ce1a4b86 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/code.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/code.md @@ -85,5 +85,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "code_context" "important decisions" --namespace code # Query previous work -npx @claude-flow/cli@latest memory query "code" --limit 5 +npx @claude-flow/cli@latest memory search --query "code" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/debug.md b/v3/@claude-flow/cli/.claude/commands/sparc/debug.md index a1cccf791a..29aab3ecdb 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/debug.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/debug.md @@ -79,5 +79,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "debug_context" "important decisions" --namespace debug # Query previous work -npx @claude-flow/cli@latest memory query "debug" --limit 5 +npx @claude-flow/cli@latest memory search --query "debug" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/devops.md b/v3/@claude-flow/cli/.claude/commands/sparc/devops.md index b606260d86..3510b7a125 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/devops.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/devops.md @@ -105,5 +105,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "devops_context" "important decisions" --namespace devops # Query previous work -npx @claude-flow/cli@latest memory query "devops" --limit 5 +npx @claude-flow/cli@latest memory search --query "devops" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/docs-writer.md b/v3/@claude-flow/cli/.claude/commands/sparc/docs-writer.md index 1fbf324f5f..f7385c6c2f 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/docs-writer.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/docs-writer.md @@ -76,5 +76,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "docs-writer_context" "important decisions" --namespace docs-writer # Query previous work -npx @claude-flow/cli@latest memory query "docs-writer" --limit 5 +npx @claude-flow/cli@latest memory search --query "docs-writer" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/integration.md b/v3/@claude-flow/cli/.claude/commands/sparc/integration.md index 70b8fa1833..7cb3441d4b 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/integration.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/integration.md @@ -79,5 +79,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "integration_context" "important decisions" --namespace integration # Query previous work -npx @claude-flow/cli@latest memory query "integration" --limit 5 +npx @claude-flow/cli@latest memory search --query "integration" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/mcp.md b/v3/@claude-flow/cli/.claude/commands/sparc/mcp.md index fec09e7c19..dc714e6a95 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/mcp.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/mcp.md @@ -113,5 +113,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "mcp_context" "important decisions" --namespace mcp # Query previous work -npx @claude-flow/cli@latest memory query "mcp" --limit 5 +npx @claude-flow/cli@latest memory search --query "mcp" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/post-deployment-monitoring-mode.md b/v3/@claude-flow/cli/.claude/commands/sparc/post-deployment-monitoring-mode.md index 23453a30a5..a8c8c7b912 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/post-deployment-monitoring-mode.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/post-deployment-monitoring-mode.md @@ -79,5 +79,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "post-deployment-monitoring-mode_context" "important decisions" --namespace post-deployment-monitoring-mode # Query previous work -npx @claude-flow/cli@latest memory query "post-deployment-monitoring-mode" --limit 5 +npx @claude-flow/cli@latest memory search --query "post-deployment-monitoring-mode" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/refinement-optimization-mode.md b/v3/@claude-flow/cli/.claude/commands/sparc/refinement-optimization-mode.md index 196ed15c90..ae7077c50d 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/refinement-optimization-mode.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/refinement-optimization-mode.md @@ -79,5 +79,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "refinement-optimization-mode_context" "important decisions" --namespace refinement-optimization-mode # Query previous work -npx @claude-flow/cli@latest memory query "refinement-optimization-mode" --limit 5 +npx @claude-flow/cli@latest memory search --query "refinement-optimization-mode" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/security-review.md b/v3/@claude-flow/cli/.claude/commands/sparc/security-review.md index 5595369d62..fbfd6bb50a 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/security-review.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/security-review.md @@ -76,5 +76,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "security-review_context" "important decisions" --namespace security-review # Query previous work -npx @claude-flow/cli@latest memory query "security-review" --limit 5 +npx @claude-flow/cli@latest memory search --query "security-review" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/sparc.md b/v3/@claude-flow/cli/.claude/commands/sparc/sparc.md index 52e68dc8f0..6fbb7bf3ac 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/sparc.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/sparc.md @@ -107,5 +107,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "sparc_context" "important decisions" --namespace sparc # Query previous work -npx @claude-flow/cli@latest memory query "sparc" --limit 5 +npx @claude-flow/cli@latest memory search --query "sparc" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/spec-pseudocode.md b/v3/@claude-flow/cli/.claude/commands/sparc/spec-pseudocode.md index 9fe8887b22..ea1334cdf7 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/spec-pseudocode.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/spec-pseudocode.md @@ -76,5 +76,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "spec-pseudocode_context" "important decisions" --namespace spec-pseudocode # Query previous work -npx @claude-flow/cli@latest memory query "spec-pseudocode" --limit 5 +npx @claude-flow/cli@latest memory search --query "spec-pseudocode" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/supabase-admin.md b/v3/@claude-flow/cli/.claude/commands/sparc/supabase-admin.md index 3223cd959f..7199832384 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/supabase-admin.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/supabase-admin.md @@ -344,5 +344,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "supabase-admin_context" "important decisions" --namespace supabase-admin # Query previous work -npx @claude-flow/cli@latest memory query "supabase-admin" --limit 5 +npx @claude-flow/cli@latest memory search --query "supabase-admin" --limit 5 ``` diff --git a/v3/@claude-flow/cli/.claude/commands/sparc/tutorial.md b/v3/@claude-flow/cli/.claude/commands/sparc/tutorial.md index 834ef5488c..774f86e474 100644 --- a/v3/@claude-flow/cli/.claude/commands/sparc/tutorial.md +++ b/v3/@claude-flow/cli/.claude/commands/sparc/tutorial.md @@ -75,5 +75,5 @@ mcp__claude-flow__memory_search { npx @claude-flow/cli@latest memory store "tutorial_context" "important decisions" --namespace tutorial # Query previous work -npx @claude-flow/cli@latest memory query "tutorial" --limit 5 +npx @claude-flow/cli@latest memory search --query "tutorial" --limit 5 ``` diff --git a/v3/@claude-flow/cli/__tests__/init-kit-memory-query-5160.test.ts b/v3/@claude-flow/cli/__tests__/init-kit-memory-query-5160.test.ts new file mode 100644 index 0000000000..a5c005a106 --- /dev/null +++ b/v3/@claude-flow/cli/__tests__/init-kit-memory-query-5160.test.ts @@ -0,0 +1,56 @@ +import { existsSync, readFileSync, readdirSync } from 'node:fs'; +import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { describe, expect, it, vi } from 'vitest'; + +vi.mock('../src/mcp-client.js', () => ({ callMCPTool: vi.fn(), MCPClientError: class extends Error {} })); +vi.mock('../src/output.js', () => ({ + output: new Proxy({}, { get: () => (value: unknown) => value }), +})); +vi.mock('../src/commands/memory-distill.js', () => ({ distillCommand: {} })); +vi.mock('../src/commands/memory-backup.js', () => ({ backupCommand: {} })); +vi.mock('../src/memory/memory-initializer.js', () => ({ resolveDbPath: (path: string) => path })); + +import { memoryCommand } from '../src/commands/memory.js'; + +const kitDir = fileURLToPath(new URL('../.claude/commands', import.meta.url)); + +function readMarkdownFiles(dir: string): Array<{ path: string; lines: string[] }> { + return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const path = join(dir, entry.name); + if (entry.isDirectory()) return readMarkdownFiles(path); + if (!entry.isFile() || !entry.name.endsWith('.md')) return []; + return [{ path, lines: readFileSync(path, 'utf8').split(/\r?\n/) }]; + }); +} + +describe('init command kit memory queries (#5160)', () => { + it('contains a readable command kit with no nonexistent memory query invocations', () => { + expect(existsSync(kitDir), `command kit not found: ${kitDir}`).toBe(true); + const files = readMarkdownFiles(kitDir); + expect(files.length, `expected at least 20 Markdown files under ${kitDir}`).toBeGreaterThanOrEqual(20); + + const offenders = files.flatMap((file) => file.lines.flatMap((line, index) => + /\bmemory\s+query\b/.test(line) ? [`${file.path}:${index + 1}: ${line}`] : [], + )); + expect(offenders, `nonexistent memory query invocations:\n${offenders.join('\n')}`).toEqual([]); + }); + + it('uses the real search subcommand and only its declared long options', () => { + const subcommands = memoryCommand.subcommands ?? []; + const verbs = new Set(subcommands.flatMap((command) => [command.name, ...(command.aliases ?? [])])); + expect(verbs.has('query')).toBe(false); + expect(subcommands.some((command) => command.name === 'search')).toBe(true); + + const search = subcommands.find((command) => command.name === 'search')!; + const optionNames = new Set((search.options ?? []).map((option) => option.name)); + const invalidFlags = readMarkdownFiles(kitDir).flatMap((file) => file.lines.flatMap((line, index) => { + if (!/\bmemory\s+search\s+--query\b/.test(line)) return []; + return [...line.matchAll(/--([a-z][a-z0-9-]*)\b/g)] + .map((match) => match[1]) + .filter((flag) => !optionNames.has(flag)) + .map((flag) => `${file.path}:${index + 1}: --${flag}`); + })); + expect(invalidFlags, `memory search flags not declared by the command:\n${invalidFlags.join('\n')}`).toEqual([]); + }); +});