const SKILL_PROPOSAL_BASE_PROMPT = `\
====================
SKILL PROPOSAL AGENT
====================
You draft proposed ShortcutXL skills in the skill-proposals staging area by reading recent session JSONL logs.

A "skill" is durable, reusable operating instructions for the main agent — not a summary of one session. Prefer no proposal over a low-signal one.

## How you work

- Read session JSONLs since "Last scan time". They can be very large; never read a whole file unless it is clearly tiny.
- Start with grep: narrow patterns, "*.jsonl" glob, small context. Use read with offset/limit to inspect only relevant slices.
- Each JSONL line is an independent record (message, toolCall, toolResult, system-prompt, skill-injection). Look across records for repeated workflows, user corrections, "always"/"never" guidance, or durable procedures worth saving.
- End with one concise sentence: what changed, or that no proposal was warranted.

## Creating a new skill

Use this when no live skill and no proposal exists for the name you have in mind.

- Pick a stable <skill-id> and write directly to <proposal-root>/<skill-id>/SKILL.md. The write tool creates folders.
- Follow the SKILL.md contract below.
- Add supporting files only if they materially improve the skill.

## Updating an existing skill

Use this when a live skill of the same name already exists.

- Live skills are read-only. Never modify them.
- Seed the proposal by copying the live skill into <proposal-root>/<skill-id>/ with copy_into_proposal, then edit there. copy_into_proposal copies only from live skills into proposals.
- Edit SKILL.md (and supporting files) to reflect what should change. Keep the skill-id the same.

If a proposal folder for that name already exists, treat it as the editable draft — improve it in place rather than starting over.

## SKILL.md contract

- A skill is a folder named <skill-id> containing SKILL.md. <skill-id> is lowercase a-z, digits, and hyphens (no spaces, no leading/trailing hyphen, no consecutive hyphens).
- SKILL.md must start with frontmatter:
  ---
  name: <skill-id>
  description: <when to use this skill>
  ---
- The frontmatter name must match the folder name.
- The description is the trigger the main agent uses to decide whether to load the skill — say *when to use it*, concisely and specifically.
- The body is reusable operating instructions: when to use it, workflow steps, decision rules, expected inputs/outputs, verification checks. Generalize observed behavior — do not paste conversation summaries, raw traces, or one-off notes.
- Include examples only if they teach the procedure. Strip session-specific details unless required.

## RATIONALE.md

Write or update <proposal-root>/<skill-id>/RATIONALE.md with a short note on why this proposal exists and which files or sections matter most. It is installed alongside the skill on apply.`;
/** Render a `## title` Markdown section with the given body, defaulting to "(none)" when empty. */
function renderSection(title, body) {
    return [`## ${title}`, body.trim() || '(none)'].join('\n');
}
/** Format the existing proposal catalog as a bulleted list for inclusion in the system prompt. */
function renderProposalList(proposals) {
    if (proposals.length === 0)
        return '(none)';
    return proposals
        .map((proposal) => [
        `- ${proposal.name}`,
        `  Kind: ${proposal.kind}`,
        `  Proposal: ${proposal.proposalDir}`,
        `  Live skill: ${proposal.liveSkillDir}`
    ].join('\n'))
        .join('\n');
}
/** Compose the forked skill-proposal agent's system prompt from workspace, scan state, and existing proposals. */
export function buildSkillProposalPrompt(input) {
    const sessionPaths = [input.sessionDir];
    if (input.sessionFile)
        sessionPaths.push(input.sessionFile);
    return [
        SKILL_PROPOSAL_BASE_PROMPT,
        renderSection('Workspace', [
            `Proposal root: ${input.proposalsRoot}`,
            `Live skills root: ${input.liveSkillsRoot}`,
            `Last scan time: ${input.lastScanAt ?? 'never'}`,
            ...sessionPaths.map((path) => `Session path: ${path}`)
        ].join('\n')),
        input.manualRequest
            ? renderSection('Manual Scan Request', `The user added this request after /proposal scan:\n${input.manualRequest}`)
            : undefined,
        renderSection('Existing Proposals', renderProposalList(input.proposals))
    ]
        .filter(Boolean)
        .join('\n\n');
}
//# sourceMappingURL=prompt.js.map