"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_AGENT_ENTRYPOINT_SOURCE_PATH = exports.DEFAULT_AGENT_ENTRYPOINT_PATH = void 0;
exports.scaffoldAgentEntrypoint = scaffoldAgentEntrypoint;
exports.renderDefaultAgentEntrypoint = renderDefaultAgentEntrypoint;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const runtime_contract_1 = require("../runtime/runtime-contract");
const default_assets_1 = require("./default-assets");
exports.DEFAULT_AGENT_ENTRYPOINT_PATH = node_path_1.default.posix.join(runtime_contract_1.DAY_SHIFT_DIRECTORY_NAME, runtime_contract_1.AGENT_ENTRYPOINT_FILE_NAME);
exports.DEFAULT_AGENT_ENTRYPOINT_SOURCE_PATH = node_path_1.default.posix.join(runtime_contract_1.DAY_SHIFT_DIRECTORY_NAME, "scaffolds", "agents.init.md");
function scaffoldAgentEntrypoint(options) {
    const scaffoldAgentEntrypoint = options.scaffoldAgentEntrypoint ?? true;
    const agentEntrypointPath = exports.DEFAULT_AGENT_ENTRYPOINT_PATH;
    const absolutePath = node_path_1.default.join(options.repositoryRoot, agentEntrypointPath);
    if (!scaffoldAgentEntrypoint) {
        return {
            agentEntrypointPath,
            created: false,
            skippedReason: "disabled"
        };
    }
    if (node_fs_1.default.existsSync(absolutePath)) {
        return {
            agentEntrypointPath,
            created: false,
            skippedReason: "exists"
        };
    }
    node_fs_1.default.writeFileSync(absolutePath, renderDefaultAgentEntrypoint(), "utf8");
    return {
        agentEntrypointPath,
        created: true,
        skippedReason: null
    };
}
function renderDefaultAgentEntrypoint() {
    const fallbackContents = [
        "# Day Shift Agent Entrypoint",
        "",
        "Use Day Shift artifacts in this repository to plan and execute work with clear traceability.",
        "",
        "## Planning Root",
        "",
        "- `.day-shift/planning/`",
        "",
        "## Core Shared Paths",
        "",
        "- `.day-shift/prompts/`",
        "- `.day-shift/templates/`",
        "- `.day-shift/workflows/`",
        "- `.day-shift/specs/index.json`",
        ""
    ].join("\n");
    return (0, default_assets_1.readPackagedWorkspaceAsset)(exports.DEFAULT_AGENT_ENTRYPOINT_SOURCE_PATH, fallbackContents);
}
