import { n as clearOnboardingRecommendations, r as readOnboardingRecommendations, t as acknowledgeOnboardingRecommendations } from "./onboarding-recommendations-CzfP1Lhd.js";
//#region src/commands/onboard-recommendations.ts
const SAFE_INSTALL_ID_RE = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/iu;
function bootstrapRecommendations(record) {
	if (record?.acceptedAt != null) return [];
	const byInstall = /* @__PURE__ */ new Map();
	for (const match of record?.matches ?? []) {
		const id = match.candidate.id;
		if (!SAFE_INSTALL_ID_RE.test(id)) continue;
		const source = match.candidate.source === "clawhub-skill" ? "clawhub-skill" : "official-plugin";
		const key = `${source}:${id.toLocaleLowerCase("en-US")}`;
		const existing = byInstall.get(key);
		if (!existing || existing.tier === "optional" && match.tier === "recommended") byInstall.set(key, {
			id,
			source,
			tier: match.tier
		});
	}
	return [...byInstall.values()];
}
function onboardRecommendationsCommand(opts, runtime, deps = {}) {
	const matches = bootstrapRecommendations((deps.read ?? readOnboardingRecommendations)());
	if (opts.json) {
		runtime.log(JSON.stringify(matches, null, 2));
		return;
	}
	if (matches.length === 0) {
		runtime.log("No stored onboarding recommendations.");
		return;
	}
	runtime.log(matches.map((match) => {
		const source = match.source === "clawhub-skill" ? "ClawHub skill" : "official plugin";
		return `- ${match.id} [${source}; ${match.tier}]`;
	}).join("\n"));
}
function acknowledgeOnboardRecommendationsCommand(runtime, deps = {}) {
	const record = (deps.acknowledge ?? acknowledgeOnboardingRecommendations)();
	runtime.log(record ? "Onboarding recommendations acknowledged." : "No stored recommendations.");
}
function refreshOnboardRecommendationsCommand(runtime, deps = {}) {
	const cleared = (deps.clear ?? clearOnboardingRecommendations)();
	runtime.log(cleared ? "Onboarding recommendations cleared. The next onboarding run will rescan." : "No stored recommendations.");
}
//#endregion
export { acknowledgeOnboardRecommendationsCommand, onboardRecommendationsCommand, refreshOnboardRecommendationsCommand };
