UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

79 lines • 4.17 kB
import { type FileStat, type LsTimeKind } from '../../../types.ts'; import { type Zone } from '../../../utils/timezone.ts'; import { type Identity } from './identity.ts'; export declare const UNKNOWN_STAT_FIELD = "?"; export declare const STAT_FAILED_KEY = "stat_failed"; /** How --block-size scales the size column: bytes per printed unit * (sizes round up), the suffix GNU prints after the count, and the * human base (1024 for human-readable, 1000 for si) when it is one of * the two -h scales instead of a fixed divisor. */ export interface BlockSize { readonly divisor: number; readonly suffix: string; readonly humanBase: number | null; } /** Which columns an `ls` row carries and how its time is spelled: -g * drops the owner, -o the group; -i leads with the inode column and -Z * puts the context column before the size, both `?` since a VFS has * neither; timeKind picks the timestamp; timeStyle is `locale` (GNU's * six-month rule), `full-iso`, `long-iso`, `iso` or `+FORMAT`. */ export interface LsColumns { readonly owner: boolean; readonly group: boolean; readonly inode: boolean; readonly context: boolean; readonly timeKind: LsTimeKind; readonly timeStyle: string; readonly blockSize: BlockSize | null; } export declare const DEFAULT_COLUMNS: LsColumns; export declare function scaledSize(n: number, block: BlockSize | null, human: boolean): string; export declare function humanScaled(n: number, base: number, units: readonly string[]): string; export declare function humanSize(n: number): string; export declare function lsModeString(s: FileStat): string; /** * A timestamp in GNU's full-iso layout, `%Y-%m-%d %H:%M:%S.%N %z`. The nine * fraction digits are the ones the stamp spells, so both hosts print what the * backend recorded rather than what their clock type keeps (a Python * `datetime` stops at microseconds, a `Date` at milliseconds). The time reads * in `zone`, UTC by default, and an unknown time is the epoch, as GNU renders * a missing file's. Mirrors Python's `full_iso_time`. */ export declare function fullIsoTime(modified: string | null | undefined, zone?: Zone): string; export declare function styledTime(modified: string | null | undefined, style: string): string; export declare function timeOf(s: FileStat, kind: LsTimeKind): string | null; export declare function lsPrefix(columns: LsColumns): string; export declare function lsName(s: FileStat): string; export declare function formatLsLong(stats: readonly FileStat[], opts?: { human?: boolean; identity?: Identity | null; columns?: LsColumns; names?: readonly string[]; }): string[]; /** * One `find -ls` row in findutils' own layout. GNU's `find -ls` row is not * `ls -l`: it leads with the inode and the allocated 1K blocks, then * fixes every column's width (inode 9, blocks 6, links 3, owner and * group 8 left-aligned, size 8) instead of fitting them to the listing, * so a consumer can count fields. The inode and block columns carry * `?`, the answer `stat %i` and `%b` already give: a VFS has no inode * and no block allocation, and a number invented for either would read * as a fact. The remaining columns are the `ls -l` ones, from the same * helpers, so the two listings cannot disagree about a row; only the * name is spelled differently, escaped (`escapeFindName`) so the row * stays one line of fixed fields. `s` is the row named as find printed * it; `identity` is null outside a workspace, where both name columns * fall back to `-`. */ /** * Spell a name the way `find -ls` prints it. findutils escapes a name so * one row stays one line and its fields stay in place: a backslash, a * space and a double quote take a backslash, the C escapes stand for * their control characters, and every other control character and every * byte outside ASCII is an octal escape (`\303\274` for `ü`, as GNU * prints it in the C locale). `-print` is untouched; only the listing is * a table. */ export declare function escapeFindName(text: string): string; export declare function formatFindLs(s: FileStat, identity: Identity | null): string; //# sourceMappingURL=formatting.d.ts.map