/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { getProfileOrchestrationMetadata } from '../profiles/metadata.js';
/** Removes the YAML frontmatter block from an `.mdc` file's content. */
export function stripMdcFrontmatter(content) {
    return content.replace(/^---[\s\S]*?---\n/, '');
}
/** Prepends the `<!-- setup-agents: x.y.z -->` version comment to any content string. */
export function versionedContent(content, version) {
    return `<!-- setup-agents: ${version} -->\n${content}`;
}
/** Wraps MDC content for Agentforce Vibes: strips frontmatter and prepends version comment. */
export function toA4dContent(mdcContent, version) {
    return versionedContent(stripMdcFrontmatter(mdcContent), version);
}
export function profileMetadataSection(profile) {
    const metadata = profile.orchestration ?? getProfileOrchestrationMetadata(profile);
    return [
        '## Profile Activation Metadata',
        '',
        'Use this metadata before assigning work to this profile or accepting handoff from another profile.',
        '',
        '### Activation Signals',
        ...metadata.activationCriteria.map((item) => `- ${item}`),
        '',
        '### Expected Evidence',
        ...metadata.expectedEvidence.map((item) => `- ${item}`),
        '',
        '### Gates',
        ...metadata.gates.map((item) => `- ${item}`),
    ].join('\n');
}
export function demandLoadedSkillSection(references) {
    if (references.length === 0)
        return '';
    return [
        '## Demand-Loaded Skills',
        '',
        'Do not load these skill files by default. Read the referenced file only when the task matches its activation signals.',
        '',
        ...references.map((reference) => [`### ${reference.title}`, `- Path: \`${reference.path}\``, `- Load when: ${reference.activation}`].join('\n')),
    ].join('\n\n');
}
export function demandLoadedDocSection(references) {
    if (references.length === 0)
        return '';
    return [
        '## Demand-Loaded Documentation',
        '',
        'Do not fetch these URLs by default. WebFetch the referenced URL only when the task matches its activation signals.',
        '',
        ...references.map((ref) => [`### ${ref.title}`, `- URL: ${ref.url}`, `- Load when: ${ref.activation}`].join('\n')),
    ].join('\n\n');
}
export { managedBlock } from '../services/managed-blocks.js';
export function lines(...parts) {
    return parts.join('\n');
}
//# sourceMappingURL=shared.js.map