feat(sdk): Phase 1 typed query foundation (gsd-sdk query) (#2118)
* feat(sdk): add typed query foundation and gsd-sdk query (Phase 1) Add sdk/src/query registry and handlers with tests, GSDQueryError, CLI query wiring, and supporting type/tool-scoping hooks. Update CHANGELOG. Vitest 4 constructor mock fixes in milestone-runner tests. Made-with: Cursor * chore: gitignore .cursor for local-only Cursor assets Made-with: Cursor * fix(sdk): harden query layer for PR review (paths, locks, CLI, ReDoS) - resolvePathUnderProject: realpath + relative containment for frontmatter and key_links - commitToSubrepo: path checks + sanitizeCommitMessage - statePlannedPhase: readModifyWriteStateMd (lock); MUTATION_COMMANDS + events - key_links: regexForKeyLinkPattern length/ReDoS guard; phase dirs: reject .. and separators - gsd-sdk: strip --pick before parseArgs; strict parser; QueryRegistry.commands() - progress: static GSDError import; tests updated Made-with: Cursor * feat(sdk): query follow-up — tests, QUERY-HANDLERS, registry, locks, intel depth Made-with: Cursor * docs(sdk): use ASCII punctuation in QUERY-HANDLERS.md Made-with: Cursor
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { QueryRegistry, extractField } from './registry.js';
|
||||
import { createRegistry } from './index.js';
|
||||
import { createRegistry, QUERY_MUTATION_COMMANDS } from './index.js';
|
||||
import type { QueryResult } from './utils.js';
|
||||
|
||||
// ─── extractField ──────────────────────────────────────────────────────────
|
||||
@@ -87,6 +87,26 @@ describe('QueryRegistry', () => {
|
||||
await expect(registry.dispatch('unknown-cmd', ['arg1'], '/tmp/project'))
|
||||
.rejects.toThrow('Unknown command: "unknown-cmd"');
|
||||
});
|
||||
|
||||
it('commands() returns all registered command names', () => {
|
||||
const registry = new QueryRegistry();
|
||||
registry.register('alpha', async () => ({ data: 1 }));
|
||||
registry.register('beta', async () => ({ data: 2 }));
|
||||
expect(registry.commands().sort()).toEqual(['alpha', 'beta']);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── QUERY_MUTATION_COMMANDS vs registry ───────────────────────────────────
|
||||
|
||||
describe('QUERY_MUTATION_COMMANDS', () => {
|
||||
it('has a registered handler for every mutation command name', () => {
|
||||
const registry = createRegistry();
|
||||
const missing: string[] = [];
|
||||
for (const cmd of QUERY_MUTATION_COMMANDS) {
|
||||
if (!registry.has(cmd)) missing.push(cmd);
|
||||
}
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── createRegistry ────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user