Files
gstack/test/helpers/captured-paths.ts
Garry Tan 6b6e68f7af test: fix Windows CI fixtures and credential scan
Rebase captured JSON values and filesystem evidence using the appropriate
path convention. Compile native fake CLIs on Windows and synchronize pipe
holder readiness, with cleanup retained when assertions fail.

Assemble synthetic credential fixtures at runtime so the added-line scan
keeps enforcing the same gate without flagging its own rejection controls.

Discover generated skills directly for the empty-find regression check,
avoiding a recursive scan through saved evaluation artifacts and dependencies.
2026-09-11 17:37:16 +00:00

15 lines
879 B
TypeScript

import path from 'node:path';
/** Rebase recorded Unix paths without inserting raw backslashes into JSON. */
export function capturedPathRebaser(replacements: Array<[string, string]>) {
const text = (value: string) => replacements.reduce((value, [before, after]) =>
value.replaceAll(before, after.split(path.sep).join('/')), value);
// Translate separators without resolving traversal, redundant separators, or
// relative spelling that an ownership rejection control must still observe.
const file = (value: string) => text(value).split('/').join(path.sep);
const pathKeys = new Set(['cwd', 'config', 'stateRoot', 'file', 'file_path', 'transcriptPath']);
const json = <T>(value: T): T => JSON.parse(JSON.stringify(value), (key, value) =>
typeof value === 'string' ? (pathKeys.has(key) ? file(value) : text(value)) : value);
return { text, file, json };
}