Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169/** Subcommand parser definitions for the image-diff CLI. Defines individual subcommand parsers (`compare`, `embed`) that are combined into the top-level parser in `cli-parsers.ts`. @module */
// TODO: deprecate Optiqueimport { object, } from '@optique/core/constructs';// TODO: deprecate Optiqueimport { message, } from '@optique/core/message';// TODO: deprecate Optiqueimport { map, optional,} from '@optique/core/modifiers';// TODO: deprecate Optiqueimport type { Parser, } from '@optique/core/parser';// TODO: deprecate Optiqueimport { argument, command, option,} from '@optique/core/primitives';// TODO: deprecate Optiqueimport { choice, string,} from '@optique/core/valueparser';
import type { ImageDiffArgs, } from './cli-parsers.ts';
/** TODO: deprecate Optique Subcommand parser producing ImageDiffArgs. Uses `any` for TState because Parser is invariant in TState and the deeply-nested state types are opaque implementation details. */// oxlint-disable-next-line typescript/no-explicit-any -- Parser is invariant in TState; opaque nested state types can't use unknowntype SubcommandParser = Parser<'sync', ImageDiffArgs, any>;
//region Shared value parsers
/** TODO: deprecate Optique Recognized provider names. */const providerValue = choice( [ 'voyage', 'gemini', ] as const, { metavar: 'PROVIDER', },);
/** TODO: deprecate Optique Recognized embedding model names across providers. */const modelValue = choice( [ 'voyage-multimodal-3', 'voyage-multimodal-3.5', 'gemini-embedding-2-preview', ] as const, { metavar: 'MODEL', },);
/** TODO: deprecate Optique Value parser for image arguments (file path or URL); URL vs path resolved at runtime. */const imageValue = string({ metavar: 'IMAGE', },);
//endregion Shared value parsers
//region Subcommand parsers
/** TODO: deprecate Optique Parser for `compare <imageA> <imageB> [--provider PROVIDER] [--model MODEL]`. */export const compareCmd: SubcommandParser = command( 'compare', map( object({ imageA: argument(imageValue,), imageB: argument(imageValue,), provider: optional(option( '--provider', providerValue, { description: message`Embedding provider (omit to use all providers)`, }, ),), model: optional(option( '--model', modelValue, { description: message`Model override for the selected provider`, }, ),), },), function toCompareArgs(v,): ImageDiffArgs { /** Parsed fields destructured so optional spreads read plain identifiers. */ const { imageA, imageB, provider, model, } = v; return { cmd: 'compare', imageA, imageB, ...(provider !== undefined ? { provider, } : {}), ...(model !== undefined ? { model, } : {}), }; }, ), { brief: message`Compare two images and report similarity, distance, and a description`, },);
/** TODO: deprecate Optique Parser for `embed <image> [--provider PROVIDER] [--model MODEL]`. */export const embedCmd: SubcommandParser = command( 'embed', map( object({ image: argument(imageValue,), provider: optional(option( '--provider', providerValue, { description: message`Embedding provider (omit to use all providers)`, }, ),), model: optional(option( '--model', modelValue, { description: message`Model override for the selected provider`, }, ),), },), function toEmbedArgs(v,): ImageDiffArgs { /** Parsed fields destructured so optional spreads read plain identifiers. */ const { image, provider, model, } = v; return { cmd: 'embed', image, ...(provider !== undefined ? { provider, } : {}), ...(model !== undefined ? { model, } : {}), }; }, ), { brief: message`Compute multimodal embedding(s) for an image`, },);
//endregion Subcommand parsers