mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
fix(init): use memory search --query in the generated command kit (#5163)
The kit that init copies from v3/@claude-flow/cli/.claude/commands called 'memory query' 21 times in 18 files. memory has no query subcommand, so those lines printed the memory help and exited 0. Rewrite them to 'memory search --query', keeping the prefix and the --namespace/--limit flags, and add a regression test over the kit. Fixes #5160 Co-authored-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
This commit is contained in:
1 parent
d0aafd59c8
commit
89ec2262d3
19 files changed
+77
-21
No files matched your search
@@ -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 <file>` - Export memory
|
||||
- `./claude-flow memory import <file>` - Import memory
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user