"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderWorkflowInstructions = renderWorkflowInstructions;
exports.renderWorkflowRefInstructions = renderWorkflowRefInstructions;
const prompt_text_1 = require("./prompt-text");
const types_1 = require("./types");
const workflow_surface_1 = require("./workflow-surface");
function renderWorkflowInstructions(workflow) {
    switch (workflow.mode) {
        case types_1.WORKER_RUN_MODES.workflowSelect:
            return [
                prompt_text_1.PROMPT_TEXT.workflowSelectOnly,
                prompt_text_1.PROMPT_TEXT.workflowSelectNoEdits,
                prompt_text_1.PROMPT_TEXT.workflowSelectNormalize,
            ];
        case types_1.WORKER_RUN_MODES.workflowPlan:
            return [
                ...renderWorkflowMergeInstructions(workflow),
                prompt_text_1.PROMPT_TEXT.workflowPlanOnly,
                prompt_text_1.PROMPT_TEXT.workflowPlanNormalize,
                ...(workflow.planningIntent === "replan" ||
                    workflow.planningIntent === "revise_plan"
                    ? [prompt_text_1.PROMPT_TEXT.workflowPlanPatchRules]
                    : []),
                prompt_text_1.PROMPT_TEXT.workflowPlanGoalContract,
                prompt_text_1.PROMPT_TEXT.workflowPlanServiceValidationGate,
                prompt_text_1.PROMPT_TEXT.workflowPlanEvaluationContract,
                prompt_text_1.PROMPT_TEXT.workflowPlanNoEdits,
                prompt_text_1.PROMPT_TEXT.workflowPlanInspectableUnknowns,
                prompt_text_1.PROMPT_TEXT.workflowPlanInspectableUnknownsAction,
                prompt_text_1.PROMPT_TEXT.workflowPlanHumanJudgmentBoundary,
                prompt_text_1.PROMPT_TEXT.workflowPlanSplitSteps,
                prompt_text_1.PROMPT_TEXT.workflowPlanStepShape,
                prompt_text_1.PROMPT_TEXT.workflowPlanSchemaValid,
                prompt_text_1.PROMPT_TEXT.workflowPlanFrontier,
                prompt_text_1.PROMPT_TEXT.workflowPlanProcedureOrder,
                prompt_text_1.PROMPT_TEXT.workflowPlanReadinessGate,
                prompt_text_1.PROMPT_TEXT.workflowPlanParallelDependencies,
                prompt_text_1.PROMPT_TEXT.workflowPlanParallelAlternatives,
                prompt_text_1.PROMPT_TEXT.workflowPlanClaimBoundary,
                prompt_text_1.PROMPT_TEXT.workflowPlanSplitTriggers,
                prompt_text_1.PROMPT_TEXT.workflowPlanCombineRule,
                prompt_text_1.PROMPT_TEXT.workflowPlanTitleRule,
                prompt_text_1.PROMPT_TEXT.workflowPlanUserFacingDoneWhen,
                prompt_text_1.PROMPT_TEXT.workflowPlanSoftLimits,
                ...((0, workflow_surface_1.isIssueWorkflowSurface)(workflow)
                    ? [
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerSplitTriggers,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerCombineRule,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerTitleRule,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerSoftLimits,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerChildSteps,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerChildStepsSeed,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerChildDependencySemantics,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerHumanHandoffBoundary,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerChildWorkflowState,
                        prompt_text_1.PROMPT_TEXT.workflowPlanControllerDepth,
                    ]
                    : [
                        "- Do not use child_issue steps on pull_request, unplanned, merge, or follow-up workflow surfaces.",
                    ]),
                prompt_text_1.PROMPT_TEXT.workflowPlanPredictedTouchedPathsExclusions,
                prompt_text_1.PROMPT_TEXT.workflowPlanIssueReportMedium,
                prompt_text_1.PROMPT_TEXT.workflowPlanRequiredSkillsPreflight,
                prompt_text_1.PROMPT_TEXT.workflowPlanCapabilityGapChildIssue,
                prompt_text_1.PROMPT_TEXT.workflowPlanCapabilityGapResolution,
                prompt_text_1.PROMPT_TEXT.workflowPlanMcpCapabilityGapResolution,
                prompt_text_1.PROMPT_TEXT.workflowPlanCapabilityGapNoChild,
                prompt_text_1.PROMPT_TEXT.workflowPlanStateOwnedOptions,
                prompt_text_1.PROMPT_TEXT.workflowPlanNestedSemantics,
                prompt_text_1.PROMPT_TEXT.workflowPlanNestedPromptScope,
                ...(0, prompt_text_1.renderWorkflowStartApprovalPromptText)(workflow.startApprovalMode),
            ];
        case types_1.WORKER_RUN_MODES.workflowExecute:
            return [
                ...renderWorkflowMergeInstructions(workflow),
                prompt_text_1.PROMPT_TEXT.workflowExecuteOnly,
                prompt_text_1.PROMPT_TEXT.workflowExecuteNoSkip,
                ...(workflow.parallelExecution?.sharedWorkspace
                    ? [prompt_text_1.PROMPT_TEXT.workflowExecuteSharedWorkspace]
                    : []),
                prompt_text_1.PROMPT_TEXT.workflowExecuteGuidance,
                prompt_text_1.PROMPT_TEXT.workflowExecuteInspectableUnknowns,
                prompt_text_1.PROMPT_TEXT.workflowExecuteInspectableUnknownsAction,
                prompt_text_1.PROMPT_TEXT.workflowExecuteHumanJudgmentBoundary,
                prompt_text_1.PROMPT_TEXT.workflowExecuteUserFacingSmoke,
                prompt_text_1.PROMPT_TEXT.workflowExecuteImprovementEvidence,
                prompt_text_1.PROMPT_TEXT.workflowExecuteClaimBoundary,
                prompt_text_1.PROMPT_TEXT.workflowExecuteCliHelp,
                prompt_text_1.PROMPT_TEXT.workflowExecuteControlPlaneSideEffects,
                prompt_text_1.PROMPT_TEXT.workflowExecuteIssueReportMedium,
                prompt_text_1.PROMPT_TEXT.workflowExecuteContinuationBoundary,
            ];
        case types_1.WORKER_RUN_MODES.workflowReconcileStepBatch:
            return [
                prompt_text_1.PROMPT_TEXT.workflowReconcileStepBatchOnly,
                prompt_text_1.PROMPT_TEXT.workflowReconcileNoFutureSteps,
                prompt_text_1.PROMPT_TEXT.workflowReconcileSharedWorkspace,
                prompt_text_1.PROMPT_TEXT.workflowConflictResolutionCombinedResult,
                prompt_text_1.PROMPT_TEXT.workflowReconcileVerification,
                prompt_text_1.PROMPT_TEXT.workflowReconcileEvidence,
                prompt_text_1.PROMPT_TEXT.workflowReconcileIssueReportMedium,
                prompt_text_1.PROMPT_TEXT.workflowExecuteControlPlaneSideEffects,
            ];
        case types_1.WORKER_RUN_MODES.workflowClosing:
            return [
                ...renderWorkflowMergeInstructions(workflow),
                prompt_text_1.PROMPT_TEXT.workflowClosingOnly,
                prompt_text_1.PROMPT_TEXT.workflowClosingNoEdits,
                prompt_text_1.PROMPT_TEXT.workflowClosingAudit,
                prompt_text_1.PROMPT_TEXT.workflowClosingIssueReportCompletion,
                prompt_text_1.PROMPT_TEXT.workflowClosingIncompleteBoundary,
                prompt_text_1.PROMPT_TEXT.workflowClosingFollowupBoundary,
                prompt_text_1.PROMPT_TEXT.workflowExecuteHumanJudgmentBoundary,
            ];
        default:
            return [];
    }
}
function renderWorkflowMergeInstructions(workflow) {
    if (workflow.mergeContext === undefined || workflow.mergeContext === null) {
        return [];
    }
    return [prompt_text_1.PROMPT_TEXT.workflowMergeContext];
}
function renderWorkflowRefInstructions(workflow) {
    if (workflow.mode !== types_1.WORKER_RUN_MODES.workflowPlan ||
        !workflow.directChildWorkflows ||
        workflow.directChildWorkflows.length === 0) {
        return [];
    }
    return [
        prompt_text_1.PROMPT_TEXT.workflowPlanNestedStepShape,
        prompt_text_1.PROMPT_TEXT.workflowPlanNestedStepNoObjects,
    ];
}
