@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
46 lines • 2.25 kB
TypeScript
import { FlagView } from '../../spec/flag_view.ts';
import { type FlagValue } from '../../spec/types.ts';
import type { ByteSource } from '../../../io/types.ts';
import { IOResult } from '../../../io/types.ts';
import { LineFacts, type PathSpec } from '../../../types.ts';
import type { Context } from '../../config.ts';
/** `-s` as xxd reads it: `[+][-]offset`. `relative` (`+`) seeks from where
* INFILE stands, which is its start here; `back` (`-`) seeks back from its
* end. Mirrors Python's XxdSeek. */
export interface XxdSeek {
readonly offset: number;
readonly relative: boolean;
readonly back: boolean;
}
export interface XxdFlags {
readonly reverse: boolean;
readonly plain: boolean;
readonly uppercase: boolean;
readonly cols: number;
readonly group: number;
readonly seek: XxdSeek;
readonly limit: number | null;
}
/**
* xxd's counts read by mirage-rs before any operand is resolved: the flags, or
* xxd's refusal of a -c. Mirrors Python's `parse_flags`.
*/
export declare function parseFlags(bag: Record<string, FlagValue>): XxdFlags | IOResult;
/**
* xxd over INFILE (or stdin) to OUTFILE (or stdout). A dump replaces
* OUTFILE; -r writes into it at the dump's offsets and keeps the bytes around
* them, as xxd does, through pwrite where the backend has one, so the stored
* bytes are what it writes into and no gap is held here. Deliberate
* divergence: xxd opens OUTFILE before it
* reads, so an INFILE that is OUTFILE reads empty and a directory INFILE
* leaves an empty OUTFILE behind; this reads first and writes once. Mirrors
* Python's xxd.
*/
export declare function xxdGeneric(parsed: XxdFlags, paths: PathSpec[], ctx: Context, stream: (p: PathSpec) => AsyncIterable<Uint8Array>, writeBytes?: ((p: PathSpec, data: ByteSource) => Promise<void>) | null, pwriteBytes?: ((p: PathSpec, data: Uint8Array, offset: number) => Promise<void>) | null): Promise<[ByteSource | null, IOResult]>;
/**
* An xxd line writes its second operand, which a pattern the backend
* expands may name too; a quoted name is no pattern. Mirrors Python's
* `facts`.
*/
export declare function facts(fl: FlagView, operands: readonly (string | PathSpec)[]): LineFacts;
//# sourceMappingURL=xxd.d.ts.map