/**
 * auto-prompts-workflow-skills.test.mjs — hidden workflow skill activation.
 *
 * Purpose: prove product-owned workflow skills are runtime prompt inputs, not
 * unused bundled files.
 *
 * Consumer: autonomous prompt assembly via buildSkillActivationBlock.
 */
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, test } from "vitest";
import { buildSkillActivationBlock } from "../auto-prompts.js";

const tempDirs = [];

function makeProject() {
	const dir = mkdtempSync(join(tmpdir(), "sf-workflow-skills-"));
	tempDirs.push(dir);
	return dir;
}

afterEach(() => {
	for (const dir of tempDirs) {
		rmSync(dir, { recursive: true, force: true });
	}
	tempDirs.length = 0;
});

describe("workflow skill prompt activation", () => {
	test("buildSkillActivationBlock_inlines_always_on_and_relevant_hidden_system_patterns", () => {
		const base = makeProject();

		const block = buildSkillActivationBlock({
			base,
			milestoneTitle: "Autonomous forensics recovery",
			sliceTitle: "Trace a stuck autonomous run",
			taskTitle: "Debug crash forensics and write the report",
			preferences: {},
		});

		expect(block).toContain("## Active Workflow Patterns");
		expect(block).toContain("observe-first (always-on constraint)");
		expect(block).toContain("sf-debug-forensics");
		expect(block).not.toContain("frontend-design");
	});
});
