import type { IFileSystem } from "../../fs/interface.js"; import type { TransformContext, TransformPlugin, TransformResult } from "../types.js"; export interface TeePluginOptions { outputDir: string; targetCommandPattern?: { test(input: string): boolean; }; timestamp?: Date; } export interface TeeFileInfo { commandIndex: number; commandName: string; /** The full command string (name + arguments) before tee wrapping */ command: string; stdoutFile: string; } export interface TeePluginMetadata { teeFiles: TeeFileInfo[]; } export declare class TeePlugin implements TransformPlugin { readonly name = "tee"; private options; private counter; constructor(options: TeePluginOptions); transform(context: TransformContext): TransformResult; /** * Ensure the capture-output directory exists before the transformed * script runs. The emitted `tee /` commands write into * `outputDir`; in real bash that directory must already exist or `tee` * fails with "No such file or directory" (stdout still passes through). * This mirrors the `mkdir -p` a user would run first. Idempotent — * recursive mkdir is a no-op when the directory already exists. */ prepare(fs: IFileSystem): Promise; private formatTimestamp; private generateStdoutPath; private transformScript; private transformStatement; private transformPipeline; /** * Save PIPESTATUS entries for original commands into temp vars. * Produces: `__tps0=${PIPESTATUS[idx0]} __tps1=${PIPESTATUS[idx1]} ...` * * All expansions happen before any assignment (single simple command), * so all read from the same PIPESTATUS snapshot. */ private makePipestatusSave; /** * Restore PIPESTATUS and exit code with a dummy pipeline. * Produces: `(exit $__tps0) | (exit $__tps1) | ...` * * This sets PIPESTATUS to the original commands' exit codes and * sets $? to the last original command's exit code. */ private makePipestatusRestore; private shouldTarget; private getCommandName; private serializeCommand; private makeTeeCommand; }