mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-31 20:47:00 +00:00
* refactor(testing): remove test-only production seams Use native module boundaries, fake clocks, and temporary filesystem fixtures instead of production dependency bags and test setters. Remove retired agent-exec repair options while retaining public SDK and real lifecycle contracts. * test: classify browser fixtures and prune retired assertions * test: finish module-boundary fixture migration * refactor(testing): remove CLI and readiness injection tables * test: complete native process fixture contracts * test: preserve the logger write gate and strengthen queue proof * test(browser): exercise delegated Windows installation fixtures * test: bind mock cleanup callbacks to their owners * refactor(testing): preserve required fixture lifecycle boundaries * refactor(testing): preserve asynchronous writer typing * refactor(scripts): keep formatter batch budget private * test: preserve native worker ownership in fixtures
33 lines
897 B
TypeScript
33 lines
897 B
TypeScript
// Keep formatter arguments bounded even when pnpm joins them into one shell command.
|
|
const FORMAT_MAX_COMMAND_LINE_BYTES = 24 * 1024;
|
|
|
|
function commandLineBytes(args: string[]) {
|
|
return args.reduce((total, arg) => total + Buffer.byteLength(arg, "utf8") + 3, 0);
|
|
}
|
|
|
|
export function chunkFormatFilesForCommand(
|
|
files: string[],
|
|
prefixArgs: string[],
|
|
maxBytes = FORMAT_MAX_COMMAND_LINE_BYTES,
|
|
) {
|
|
const chunks: string[][] = [];
|
|
let chunk: string[] = [];
|
|
let chunkBytes = commandLineBytes(prefixArgs);
|
|
|
|
for (const file of files) {
|
|
const fileBytes = Buffer.byteLength(file, "utf8") + 3;
|
|
if (chunk.length > 0 && chunkBytes + fileBytes > maxBytes) {
|
|
chunks.push(chunk);
|
|
chunk = [];
|
|
chunkBytes = commandLineBytes(prefixArgs);
|
|
}
|
|
chunk.push(file);
|
|
chunkBytes += fileBytes;
|
|
}
|
|
|
|
if (chunk.length > 0) {
|
|
chunks.push(chunk);
|
|
}
|
|
|
|
return chunks;
|
|
}
|