Parse Pickle extents once at the ASAR boundary and carry finalized signature facts through root and nested classification. Scan JSON whitespace within its declared extent and decode budget without retaining the whitespace prefix. Keep prefix storage bounded independently of stream chunk ownership. Fill fixed ASAR prefixes and DMG trailers across short reads, preserve cancellation through admission and stream EOF, and retain existing cleanup ownership. Cover public CLI/MCP selection, root/nested inventory, malformed JSON whitespace and padding, limits, native/XML consumers and descriptor faults. Validation: 24 focused files / 170 tests; full check; docs check; test discovery. Official inert ASAR fixtures and controlled descriptor faults were exercised; real Electron execution, Windows and natural OS short-read frequency remain unverified. Equivalent compact CLI tasks returned identical results and reply token estimates; repeated timings do not establish a speedup. Fixes #3574 Fixes #5188
18 lines
575 B
TypeScript
18 lines
575 B
TypeScript
import { createAsarHeaderSignatureProbe } from "../../src/artifacts/AsarHeader.js";
|
|
import { classifyArtifactContent } from "../../src/artifacts/inventory/ArtifactGraphConstruction.js";
|
|
|
|
/** Observe a supplied byte prefix before assigning an inventory path role. */
|
|
export const classifyArtifactBytesAtPath = (
|
|
path: string,
|
|
bytes: Buffer,
|
|
fileSize = bytes.length,
|
|
) => {
|
|
const probe = createAsarHeaderSignatureProbe();
|
|
probe.write(bytes);
|
|
return classifyArtifactContent(
|
|
path,
|
|
{ prefix: bytes, asarHeader: probe.finish(fileSize) },
|
|
fileSize,
|
|
);
|
|
};
|