fix: add git hook setup and stable config hash sorting

This commit is contained in:
Peter Steinberger
2026-01-19 02:02:09 +00:00
parent dd1b08b3e8
commit a9fc2ca0ef
8 changed files with 363 additions and 4 deletions

View File

@@ -9,13 +9,17 @@ type SandboxHashInput = {
agentWorkspaceDir: string;
};
function isPrimitive(value: unknown): value is string | number | boolean | bigint | symbol | null {
return value === null || (typeof value !== "object" && typeof value !== "function");
}
function normalizeForHash(value: unknown): unknown {
if (value === undefined) return undefined;
if (Array.isArray(value)) {
const normalized = value.map(normalizeForHash).filter((item) => item !== undefined);
const allPrimitive = normalized.every((item) => item === null || typeof item !== "object");
if (allPrimitive) {
return [...normalized].sort((a, b) => String(a).localeCompare(String(b)));
const normalized = value.map(normalizeForHash).filter((item): item is unknown => item !== undefined);
const primitives = normalized.filter(isPrimitive);
if (primitives.length === normalized.length) {
return [...primitives].sort((a, b) => String(a).localeCompare(String(b)));
}
return normalized;
}