UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

38 lines (37 loc) • 3.14 kB
/** * A `find` whose words in front of the expression the engine does NOT read. `find` takes options before its starting points, * and two grammars read them: GNU findutils (`-H -L -P`, `-D ITEMS`, `-O<level>`, each a word of its own) and BSD `getopt` * over `EHLPXdf:sx`, where letters cluster (`-xL`) and `-f` takes the rest of its word or the next word as a starting point * (`-f PATH`, `-fPATH`, `-xf PATH`, and so `-follow` is `-f ollow`). Nothing in the text says which grammar runs, and a * clustered or attached word moves the starting points; this module does not read them. The words read are ONE table of * single options ({@link FIND_LEAD_SWITCHES}); any other leading dash word BSD's `getopt` would take makes the find unread * ({@link findLeadUnreadAt}) — the reader stops there and aligns nothing after it. A dash word `getopt` refuses (`-name`, * `-delete`, `-depth`) is where GNU's expression starts (BSD refuses the whole command): read as the expression's start. * * An unread find whose words after the unread one, as spelled, include one that deletes, hands a command on, writes a file or reads its starting * points from a file ({@link FIND_ACTING_WORDS}) may remove a protected location: the removal guard asks a person about it * (`removal-targets.ts`), beside whatever it finds by its own reading of the same command. */ import { type LexedWord } from "../../shell/lex.js"; import type { ShellReadPlan } from "./shell-read-plan.js"; /** The words that delete, hand a command on, write a file or read the starting points from a file — found by spelling. */ export declare const FIND_ACTING_WORDS: ReadonlySet<string>; /** * The index (into `args`, the words after the program word) of the first leading word this module does not read, or * `undefined` where every leading word is read: a word of {@link FIND_LEAD_SWITCHES}, and a word of nothing but expansions that * may yield no word, are skipped; a word that does not start * with a literal `-` (a starting point, `-D`'s value, `(`, `!`) and `-` alone end the leading words; any other dash word * `getopt` takes ({@link GETOPT_TAKES}; of a word the shell writes past a literal prefix, one whose prefix holds only option * letters so far) is unread, and one it refuses (`--` among them) starts the expression or ends the options as before. */ export declare function findLeadUnreadAt(args: readonly LexedWord[]): number | undefined; /** One unread find that acts: its program, the first unread leading word, and the segment's text. */ export interface UnreadActingFind { readonly program: string; readonly word: string; readonly text: string; } /** Every unread `find` ({@link findLeadUnreadAt}) in a plan — nested plans included — whose words AFTER the unread one, as * spelled, hold one of {@link FIND_ACTING_WORDS} (the unread word is never its own: `-files0-from` / `-fprint` written first, * with nothing after them that acts, read as before). The program is the one the removal walk names (`removal-actions.ts`'s `walk` row). */ export declare function unreadActingFinds(plan: ShellReadPlan): UnreadActingFind[];