mirror of
https://github.com/thedotmack/claude-mem.git
synced 2026-09-20 04:23:02 +08:00
2a0a407340
Cuts verified dead code, duplication, and speculative abstractions across 14 disjoint areas of the tree: sqlite layer, worker HTTP routes, search pipeline, server, chroma sync, viewer UI, npx-cli, MCP server, shared/utils, telemetry/infra, integrations, scripts, tests, and stale plans/evals docs. Also unifies the Chroma search pipeline onto SearchOrchestrator/strategies and ports dual-project (merged_into_project) scoping plus dateRange filtering into ChromaSearchStrategy, which corpus builds need but had silently lost. Full audit trail: 65-agent verification workflow wf_160a7862-1a6, 14-agent execution wf_c7e48c0f-164, 6-agent fixup wf_865f86a4-c6b. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
2.9 KiB
TypeScript
54 lines
2.9 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
const indexSource = readFileSync(join(__dirname, '..', 'src', 'npx-cli', 'index.ts'), 'utf-8');
|
|
const serverSource = readFileSync(join(__dirname, '..', 'src', 'npx-cli', 'commands', 'server.ts'), 'utf-8');
|
|
const workerServiceSource = readFileSync(join(__dirname, '..', 'src', 'services', 'worker-service.ts'), 'utf-8');
|
|
|
|
describe('npx CLI server namespace', () => {
|
|
it('routes the server namespace through the server command module', () => {
|
|
expect(indexSource).toContain("case 'server'");
|
|
expect(indexSource).toContain("await import('./commands/server.js')");
|
|
expect(indexSource).toContain('await runServerCommand(args.slice(1))');
|
|
});
|
|
|
|
it('routes worker lifecycle aliases through the server command module', () => {
|
|
expect(indexSource).toContain("case 'worker'");
|
|
expect(indexSource).toContain('runWorkerAliasCommand(args.slice(1))');
|
|
expect(serverSource).toContain('runWorkerLifecycleCommand');
|
|
expect(serverSource).toContain('runStartCommand()');
|
|
expect(serverSource).toContain('runStopCommand()');
|
|
expect(serverSource).toContain('runRestartCommand()');
|
|
expect(serverSource).toContain('runStatusCommand()');
|
|
});
|
|
|
|
it('routes server lifecycle commands and falls through to a nonzero failure for unknown commands', () => {
|
|
expect(serverSource).toContain('runServerLifecycleCommand(subCommand)');
|
|
expect(serverSource).toContain('runServerStartCommand()');
|
|
expect(serverSource).toContain('runServerStopCommand()');
|
|
expect(serverSource).toContain('runServerRestartCommand()');
|
|
expect(serverSource).toContain('runServerStatusCommand()');
|
|
expect(serverSource).toContain("process.exit(1)");
|
|
expect(serverSource).toContain('runServerApiKeyCommand(argv.slice(1))');
|
|
expect(serverSource).not.toContain('runServerLogsCommand');
|
|
expect(serverSource).not.toContain("'logs'");
|
|
expect(serverSource).not.toContain("'doctor'");
|
|
expect(serverSource).not.toContain("'migrate'");
|
|
});
|
|
|
|
it('normalizes direct worker-service server invocations', () => {
|
|
expect(workerServiceSource).toContain("rawCommand === 'server'");
|
|
expect(workerServiceSource).toContain('lifecycleCommands.has(maybeSubCommand)');
|
|
expect(workerServiceSource).toContain('command: `server-${maybeSubCommand}`');
|
|
expect(workerServiceSource).toContain("case 'server-start'");
|
|
expect(workerServiceSource).toContain('runServerServiceCli(command.slice');
|
|
expect(workerServiceSource).toContain('serverCommands.has(maybeSubCommand)');
|
|
expect(workerServiceSource).toContain("case 'server-api-key'");
|
|
expect(workerServiceSource).toContain('runServerApiKeyCli(commandArgs)');
|
|
expect(workerServiceSource).toContain("case 'server-help'");
|
|
expect(workerServiceSource).toContain("case 'worker-help'");
|
|
expect(workerServiceSource).not.toContain('command: maybeSubCommand ??');
|
|
});
|
|
});
|