aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
147 lines • 4.78 kB
TypeScript
export interface WriteOptions {
encoding?: BufferEncoding;
mode?: number;
flag?: string;
}
export interface FileStats {
size: number;
isFile: boolean;
isDirectory: boolean;
createdAt: Date;
modifiedAt: Date;
}
/**
* FilesystemSandbox provides isolated temporary filesystems for testing.
*
* Creates temporary directory structures that can be safely manipulated
* without affecting the real filesystem. Automatically cleans up on destruction.
*
* @example
* ```typescript
* const sandbox = new FilesystemSandbox();
* await sandbox.initialize();
* await sandbox.writeFile('test.txt', 'Hello World');
* const content = await sandbox.readFile('test.txt');
* await sandbox.cleanup();
* ```
*/
export declare class FilesystemSandbox {
private sandboxPath;
private initialized;
constructor();
/**
* Initialize the sandbox by creating a temporary directory.
* Must be called before any other operations.
*/
initialize(): Promise<void>;
/**
* Clean up the sandbox by removing the temporary directory.
* Safe to call multiple times.
*/
cleanup(): Promise<void>;
/**
* Write a file to the sandbox.
*
* @param relativePath - Path relative to sandbox root
* @param content - File content (string or Buffer)
* @param options - Write options (encoding, mode, flag)
*/
writeFile(relativePath: string, content: string | Buffer, options?: WriteOptions): Promise<void>;
/**
* Read a file from the sandbox.
*
* @param relativePath - Path relative to sandbox root
* @param encoding - Optional encoding (if not provided, returns Buffer)
* @returns File content as string or Buffer
*/
readFile(relativePath: string): Promise<string>;
readFile(relativePath: string, encoding: BufferEncoding): Promise<string>;
readFile(relativePath: string, encoding: null): Promise<Buffer>;
/**
* Delete a file from the sandbox.
*
* @param relativePath - Path relative to sandbox root
*/
deleteFile(relativePath: string): Promise<void>;
/**
* Check if a file exists.
*
* @param relativePath - Path relative to sandbox root
* @returns True if file exists
*/
fileExists(relativePath: string): Promise<boolean>;
/**
* Get file statistics.
*
* @param relativePath - Path relative to sandbox root
* @returns File statistics
*/
getFileStats(relativePath: string): Promise<FileStats>;
/**
* Create a directory in the sandbox.
*
* @param relativePath - Path relative to sandbox root
*/
createDirectory(relativePath: string): Promise<void>;
/**
* Delete a directory from the sandbox.
*
* @param relativePath - Path relative to sandbox root
* @param recursive - Whether to delete recursively (default: false)
*/
deleteDirectory(relativePath: string, recursive?: boolean): Promise<void>;
/**
* List directory contents.
*
* @param relativePath - Path relative to sandbox root (default: root)
* @returns Array of file/directory names
*/
listDirectory(relativePath?: string): Promise<string[]>;
/**
* Check if a directory exists.
*
* @param relativePath - Path relative to sandbox root
* @returns True if directory exists
*/
directoryExists(relativePath: string): Promise<boolean>;
/**
* Get the absolute path to a file/directory in the sandbox.
*
* @param relativePath - Optional relative path (default: sandbox root)
* @returns Absolute path
*/
getPath(relativePath?: string): string;
/**
* Copy a file from the real filesystem into the sandbox.
*
* @param realPath - Path in the real filesystem
* @param sandboxPath - Target path in sandbox (relative)
*/
copyFromReal(realPath: string, sandboxPath: string): Promise<void>;
/**
* Copy a file from the sandbox to the real filesystem.
*
* @param sandboxPath - Source path in sandbox (relative)
* @param realPath - Target path in the real filesystem
*/
copyToReal(sandboxPath: string, realPath: string): Promise<void>;
/**
* Ensure the sandbox is initialized before operations.
*/
private ensureInitialized;
/**
* Validate that a path doesn't escape the sandbox.
*
* @param relativePath - Path to validate
* @throws Error if path is invalid or escapes sandbox
*/
private validatePath;
/**
* Resolve a relative path to an absolute path within the sandbox.
*
* @param relativePath - Relative path
* @returns Absolute path
*/
private resolvePath;
}
//# sourceMappingURL=filesystem-sandbox.d.ts.map