Deepen query dispatch seam with Command Topology Module (#3078)
* Deepen query dispatch seam with command topology module * Stabilize SDK parity defaults and integration test gating * docs(architecture): record pre-project config policy and e2e gate * refactor(query): stop injecting native adapter in CLI dispatch path * fix(config): align workflow auto-chain typing and docs
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
import type { QueryRegistry } from './registry.js';
|
||||
import {
|
||||
normalizeQueryCommand,
|
||||
resolveQueryCommand,
|
||||
type QueryCommandResolution,
|
||||
} from './query-command-resolution-strategy.js';
|
||||
import { normalizeQueryCommand } from './query-command-resolution-strategy.js';
|
||||
import type { CommandTopology, CommandTopologyMatch } from './command-topology.js';
|
||||
|
||||
export type DispatchMode = 'native' | 'cjs' | 'error';
|
||||
|
||||
export interface DispatchPlan {
|
||||
mode: DispatchMode;
|
||||
normalized: { command: string; args: string[]; tokens: string[] };
|
||||
matched: QueryCommandResolution | null;
|
||||
matched: CommandTopologyMatch | null;
|
||||
noMatchMessage?: string;
|
||||
noMatchNormalized?: string;
|
||||
noMatchAttempted?: string[];
|
||||
noMatchHints?: string[];
|
||||
}
|
||||
|
||||
export function planQueryDispatch(
|
||||
queryArgv: string[],
|
||||
registry: QueryRegistry,
|
||||
topology: CommandTopology,
|
||||
cjsFallbackEnabled: boolean,
|
||||
): DispatchPlan {
|
||||
const queryCommand = queryArgv[0];
|
||||
@@ -25,12 +25,23 @@ export function planQueryDispatch(
|
||||
|
||||
const [normCmd, normArgs] = normalizeQueryCommand(queryCommand, queryArgv.slice(1));
|
||||
const normalizedTokens = [normCmd, ...normArgs];
|
||||
const matched = resolveQueryCommand(queryCommand, queryArgv.slice(1), registry);
|
||||
if (matched) {
|
||||
return { mode: 'native', normalized: { command: normCmd, args: normArgs, tokens: normalizedTokens }, matched };
|
||||
const resolved = topology.resolve(queryArgv, !cjsFallbackEnabled);
|
||||
|
||||
if (resolved.kind === 'match') {
|
||||
return { mode: 'native', normalized: { command: normCmd, args: normArgs, tokens: normalizedTokens }, matched: resolved };
|
||||
}
|
||||
|
||||
if (cjsFallbackEnabled) {
|
||||
return { mode: 'cjs', normalized: { command: normCmd, args: normArgs, tokens: normalizedTokens }, matched: null };
|
||||
}
|
||||
return { mode: 'error', normalized: { command: normCmd, args: normArgs, tokens: normalizedTokens }, matched: null };
|
||||
|
||||
return {
|
||||
mode: 'error',
|
||||
normalized: { command: normCmd, args: normArgs, tokens: normalizedTokens },
|
||||
matched: null,
|
||||
noMatchMessage: resolved.message,
|
||||
noMatchNormalized: resolved.normalized,
|
||||
noMatchAttempted: resolved.attempted,
|
||||
noMatchHints: resolved.hints,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user