refactor(query): deepen command/dispatch seams and resolve coderabbit findings
* refactor(query): deepen command definition seam and fold fallback mapping cleanup * refactor(query): add shared dispatch formatting module seam * fix(query): restore QueryResult type import in dispatch deps * test/query: align raw-output policy and definition normalization contracts * refactor(query): deepen diagnosis, invariant report, and error taxonomy seams * refactor(query): deepen dispatch plan, fallback bridge, policy snapshot, and hints seams * refactor(query): deepen validation, fallback policy, capability, and result builder seams * refactor(query): deepen resolution strategy, output classifier, observability, and policy-capability seams * refactor(query): finalize deep strategy/classifier/observability/capability seams * test/query: address coderabbit inline and out-of-diff dispatch nits * fix(query): address remaining coderabbit input-validation and bridge stderr threads * fix(query): address remaining coderabbit dispatch and strategy/output nits
This commit is contained in:
42
sdk/src/query/command-definition.ts
Normal file
42
sdk/src/query/command-definition.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { COMMAND_MANIFEST } from './command-manifest.js';
|
||||
import type { CommandFamily, OutputMode } from './command-manifest.types.js';
|
||||
|
||||
export interface CommandDefinition {
|
||||
family: CommandFamily;
|
||||
canonical: string;
|
||||
aliases: string[];
|
||||
mutation: boolean;
|
||||
output_mode: OutputMode;
|
||||
handler_key: string;
|
||||
}
|
||||
|
||||
export const COMMAND_DEFINITIONS: readonly CommandDefinition[] = COMMAND_MANIFEST.map((entry) => ({
|
||||
family: entry.family,
|
||||
canonical: entry.canonical,
|
||||
aliases: [...entry.aliases],
|
||||
mutation: entry.mutation,
|
||||
output_mode: entry.outputMode,
|
||||
handler_key: entry.handlerKey ?? entry.canonical,
|
||||
})) as readonly CommandDefinition[];
|
||||
|
||||
function byFamily(family: CommandFamily): readonly CommandDefinition[] {
|
||||
return COMMAND_DEFINITIONS.filter((entry) => entry.family === family);
|
||||
}
|
||||
|
||||
export const COMMAND_DEFINITIONS_BY_FAMILY: Readonly<Record<CommandFamily, readonly CommandDefinition[]>> = {
|
||||
state: byFamily('state'),
|
||||
verify: byFamily('verify'),
|
||||
init: byFamily('init'),
|
||||
phase: byFamily('phase'),
|
||||
phases: byFamily('phases'),
|
||||
validate: byFamily('validate'),
|
||||
roadmap: byFamily('roadmap'),
|
||||
} as const;
|
||||
|
||||
export const FAMILY_MUTATION_COMMANDS: readonly string[] = COMMAND_DEFINITIONS
|
||||
.filter((entry) => entry.mutation)
|
||||
.flatMap((entry) => [entry.canonical, ...entry.aliases]);
|
||||
|
||||
export const FAMILY_RAW_OUTPUT_COMMANDS: readonly string[] = COMMAND_DEFINITIONS
|
||||
.filter((entry) => entry.output_mode === 'raw')
|
||||
.flatMap((entry) => [entry.canonical, ...entry.aliases]);
|
||||
Reference in New Issue
Block a user