mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-14 04:17:33 +01:00
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.
15 lines
879 B
TypeScript
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 };
|
|
}
|