import { e as executeCliAction } from './cli-action-DQcaqcfn.js';
import './spawn-cli-wI1lBJhm.js';
import 'node:child_process';
import '@sveltejs/kit';

//#region src/routes/api/project/scan/+server.ts
/**
* POST /api/project/scan
*
* Calls `cleo nexus projects scan --json` with optional flags derived from the
* request body. This is a global operation — it scans the filesystem for
* projects and optionally registers them.
*
* Request body (all optional):
*   {
*     roots?: string;     — comma-separated root paths to scan (--roots <paths>)
*     maxDepth?: number;  — max directory depth (--max-depth <n>)
*     autoRegister?: boolean; — auto-register discovered projects (--auto-register)
*   }
*
* Returns a LAFS envelope or a 4xx with structured error envelope on CLI failure.
*
* @task T722
*/
var POST = async ({ request }) => {
	let body = {};
	try {
		const raw = await request.json();
		if (typeof raw === "object" && raw !== null) body = raw;
	} catch {}
	const args = [
		"nexus",
		"projects",
		"scan",
		"--json"
	];
	if (typeof body.roots === "string" && body.roots.trim()) args.push("--roots", body.roots.trim());
	if (typeof body.maxDepth === "number" && body.maxDepth > 0) args.push("--max-depth", String(Math.floor(body.maxDepth)));
	if (body.autoRegister) args.push("--auto-register");
	return executeCliAction(args, {
		errorCode: "E_SCAN_FAILED",
		meta: {
			roots: body.roots,
			maxDepth: body.maxDepth,
			autoRegister: body.autoRegister
		}
	});
};

export { POST };
//# sourceMappingURL=_server.ts-DV6pzF-M.js.map
