import * as fs from 'node:fs';
import { generateReportDir } from '../../../shared/utils/reportDir.js';
import { buildRunPaths } from './run-paths.js';
function generateReportDirSuffix() {
    return Math.random().toString(36).slice(2, 8).padEnd(6, '0');
}
export function generateExecutionReportDir(cwd, task) {
    const baseSlug = `${generateReportDir(task)}-${generateReportDirSuffix()}`;
    let sequence = 1;
    let slug = baseSlug;
    let runRootAbs = buildRunPaths(cwd, slug).runRootAbs;
    while (fs.existsSync(runRootAbs)) {
        sequence += 1;
        slug = `${baseSlug}-${sequence}`;
        runRootAbs = buildRunPaths(cwd, slug).runRootAbs;
    }
    return slug;
}
//# sourceMappingURL=run-slug.js.map