UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

47 lines (46 loc) • 4.66 kB
/** * THE SHELL'S OWN READINGS OF A PATH ON A WIN TREE — the places Git Bash (the win32 adapter's shell, the MSYS line) may take a * spelling to that a Win32 reading does not: a `..` taken at a drive's root reaches the emulation's root `/` (where the next * one-letter segment is a drive again) instead of staying at the drive's root; a logical `cd` that climbs above a drive's root * stands there; a drive-relative `C:rest` may be read below the working directory or below the drive's root. Each reading only * ADDS a place a word may lead — the readings the station had stay — and on a POSIX tree none applies. The walk that resolves * links lives in the establishment (shell-read-establish.ts): it notes a climb where it takes one ({@link noteClimb}) and hands * its own `resolve` to the readers here, which never read the filesystem themselves. */ import { type PathFamily } from "./safety.js"; import type { EstablishedRead } from "./shell-read-judge.js"; /** One walk of the establishment: where `p` lands (`undefined`: unanswered), noting the shell's climbs it takes in `climbs`. */ export type ClimbWalk = (p: string, climbs: string[]) => Promise<{ readonly value: string; readonly exact: boolean; readonly missing?: boolean; } | undefined>; /** Where ONE spelling is read from at one base: the base itself — or, for a drive-relative spelling on the base's drive, each * place the shell may read it from ({@link driveRelativeReadingsOf}: the base and the drive's root, the rest below each). */ export declare function readingsAt(base: string, spelled: string): ReadonlyArray<readonly [string, string]>; /** At a `..` the walk takes from `at` (the canonical place it stands), with `rest` the segments after it: where `at` is a drive's * root on a win tree, note the shell's reading of the step — the emulation's root `/` and the rest from there — in `climbs` * (once). `true` when a climb was noted: every further `..` of the same run reaches the same `/`, and the walk notes none. */ export declare function noteClimb(family: PathFamily, at: string, rest: readonly string[], climbs: string[]): boolean; /** The drive paths the noted climbs (`climbs`, growing as `each` walks them) lead to, each handed to `each` once * ({@link shellRootedLandingsOf}; a climb that stays in the emulation's own tree leads to none). Past {@link CLIMB_LANDINGS_MAX} * the rest is not followed and `bounded` records it (the judgment is then incomplete, never silently short). */ export declare function landingsOf(climbs: string[], each: (landing: string) => Promise<void>, bounded: (detail: string) => unknown): Promise<void>; /** A climb's landing that reaches a target already held: one read, the landing's spellings and hops it does not hold yet added * for the deny judge (`kept`: the read that stays, by the seats' one rule). */ export declare function withClimbedViews(kept: EstablishedRead, other: EstablishedRead): EstablishedRead; /** A pattern whose walk climbs above a drive's root is expanded where the shell's climb leads too: `patterns` and the landings. */ export declare function withClimbedPatterns(family: PathFamily, patterns: readonly string[], walk: ClimbWalk, bounded: (detail: string) => unknown, signal?: AbortSignal): Promise<string[]>; /** * A word the text could not place past a move it could not follow is judged where the text stood when it lost track — its * floor spellings, each `..` kept. Where such a spelling's walk climbs above a drive's root, the shell's landing (a move through * a link to a drive's root and up leaves the shell in the emulation's root) and where it resolves are views of the word too. */ export declare function withFloorClimbs(family: PathFamily, read: EstablishedRead, walk: ClimbWalk, bounded: (detail: string) => unknown, signal?: AbortSignal): Promise<EstablishedRead>; /** Where a logical move from `base` to `target` stands: where the target placed as an operand is. A stand-in is no place — a * target whose walk climbs above a drive's root into the emulation's own tree (`cd /c/..`, `cd ../..` from `C:\proj`) is one, * so the walk loses track there, as at `cd /` (where Git Bash stands then is design ticket #5314's). A place the walk itself * holds (`cd -`, `cd "$PWD"`) whose spelling climbs above a drive's root ({@link shellWalkLeavesDrive}) keeps that climb as * spelled (`C:\..`); a target the command TYPED as a qualified Win32 path (`typed`) is Windows's to fold and keeps the fold. * `undefined`: no place. */ export declare function movedTo(base: string, target: string, homeDir: string | undefined, typed: boolean): string | undefined;