#!/usr/bin/env bun
/**
* Per-package deslop scan. Warnings-only by default: findings are printed for
* review but the process exits 0 so deslop never blocks lint/CI. Set
* DESLOP_FAIL_ON=high (or medium/low) to gate on that tier.
*
* Run from a package root so deslop can resolve that package's tsconfig and
* path aliases — scanning from a non-package root silently no-ops.
*/
import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
type Confidence = "high" | "medium" | "low";
interface Finding {
confidence?: Confidence;
path?: string;
line?: number;
kind?: string;
name?: string;
reason?: string;
instances?: { path: string; startLine?: number }[];
}
type Result = Record<string, unknown> & { totalFiles?: number };
const root = process.cwd();
const failOn = process.env.DESLOP_FAIL_ON as Confidence | undefined;
const args = [
"deslop-cli",
".",
"--json",
"--ignore",
"**/*.test.*",
"--ignore",
"**/*.spec.*",
"--ignore",
"**/dist/**",
"--ignore",
"**/build/**",
"--ignore",