@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
29 lines • 1.67 kB
TypeScript
import type { ShellWord } from "./auto-shell-segments.ts";
/**
* What a word means to the program, so the judge knows how to check it: `read-file` is read from
* (must be a regular project file), `list` only has its name shown, `text` is never used as a path
* (a pattern, a count, a format), and `ref-or-path` is a git revision unless something exists at
* that name, in which case it is checked like `list` (git reads it as a path).
*/
export type WordRole = "read-file" | "list" | "text" | "ref-or-path";
export interface ClassifiedWord {
readonly role: WordRole;
readonly word: ShellWord;
}
export interface ProgramSpec {
/** Every flag the program may take; `true` = no value, a role = takes one value. */
readonly flags: Readonly<Record<string, true | WordRole>>;
/** The role of operand `index` out of `count` operands, given its text. */
readonly operand: (index: number, count: number, text: string) => WordRole;
readonly minOperands?: number;
readonly maxOperands?: number;
}
/**
* Classifies every word of one simple command against `spec`, or returns undefined when any word
* is not understood: an unknown flag (short or long), a flag in a form the spec does not list, a
* value-taking flag with no value, or an operand count out of range. Short flags may be
* clustered (`-la`), and a value-taking short flag takes the rest of its word as the value
* (`-o/x`, `-ro/x`) or else the next word; a long flag takes `--name=value` or `--name value`.
*/
export declare function classifyWords(words: readonly ShellWord[], spec: ProgramSpec): ClassifiedWord[] | undefined;
//# sourceMappingURL=auto-shell-grammar.d.ts.map