refactor(query): deepen runtime context/native adapter/output seams (#3076)
* refactor(query): deepen runtime context, native adapter, and cli output seams * chore(changeset): add fragment for query seam deepening continuation * refactor(query): converge internal command-resolution imports on canonical seam * refactor(query): remove dead seam wrappers and converge on canonical modules * docs(architecture): update context and adr for query seam completion * fix(query): preserve gsd-tools stderr in cli output and clarify static ws test scope * test(query): cover whitespace stderr and null exitCode fallback
This commit is contained in:
@@ -20,7 +20,7 @@ import type { InitNewProjectInfo, PhaseOpInfo, PhasePlanIndex, RoadmapAnalysis }
|
||||
import type { GSDEventStream } from './event-stream.js';
|
||||
import { GSDError, exitCodeFor } from './errors.js';
|
||||
import { createRegistry } from './query/index.js';
|
||||
import { resolveQueryCommand, type QueryCommandResolution } from './query/command-resolution.js';
|
||||
import { resolveQueryCommand, type QueryCommandResolution } from './query/query-command-resolution-strategy.js';
|
||||
import { formatStateLoadRawStdout } from './query/state-project-load.js';
|
||||
import type { QueryResult } from './query/utils.js';
|
||||
import { GSDTransport } from './gsd-transport.js';
|
||||
@@ -556,32 +556,6 @@ export class GSDTools {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `gsd-sdk query` semantics in-process: normalize argv, resolve registry, dispatch.
|
||||
* Returns handler JSON payload (same as stdout from the `gsd-sdk query` CLI without `--pick`).
|
||||
*/
|
||||
export async function runGsdToolsQuery(projectDir: string, queryArgv: string[]): Promise<unknown> {
|
||||
const { createRegistry } = await import('./query/index.js');
|
||||
const { normalizeQueryCommand } = await import('./query/normalize-query-command.js');
|
||||
const { resolveQueryCommand } = await import('./query/command-resolution.js');
|
||||
const { GSDError, ErrorClassification } = await import('./errors.js');
|
||||
|
||||
if (queryArgv.length === 0 || !queryArgv[0]) {
|
||||
throw new GSDError('runGsdToolsQuery requires a command', ErrorClassification.Validation);
|
||||
}
|
||||
const registry = createRegistry();
|
||||
const [normCmd, normArgs] = normalizeQueryCommand(queryArgv[0], queryArgv.slice(1));
|
||||
const matched = resolveQueryCommand(queryArgv[0], queryArgv.slice(1), registry);
|
||||
if (!matched) {
|
||||
throw new GSDError(
|
||||
`Unknown command: "${[normCmd, ...normArgs].join(' ')}". No native handler registered.`,
|
||||
ErrorClassification.Validation,
|
||||
);
|
||||
}
|
||||
const result = await registry.dispatch(matched.cmd, matched.args, projectDir);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
// ─── Path resolution ────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user