import { t as createSubsystemLogger } from "./subsystem-qDUB67UD.js";
//#region src/cognitive/evolution/skill-usage-tracker.ts
const log = createSubsystemLogger("cognitive/evolution/skill-usage");
/**
* Scan post-turn toolMetas for `read` calls that accessed SKILL.md files
* and call touchSkill() to update usage statistics. Fire-and-forget.
*/
async function trackSkillUsage(params) {
	const skillReads = params.toolMetas.filter((m) => m.toolName === "read" && typeof m.meta === "string" && m.meta.includes("SKILL.md"));
	if (skillReads.length === 0) return;
	const { SkillPersistenceWriter } = await import("./skill-writer-DNOmOldW.js");
	const writer = new SkillPersistenceWriter(params.configDir);
	const seen = /* @__PURE__ */ new Set();
	for (const entry of skillReads) {
		const match = entry.meta.match(/(?:^|[/\\])([^/\\]+)[/\\]SKILL\.md$/);
		if (!match || seen.has(match[1])) continue;
		if (match[1] === "skills" || match[1] === "agent") continue;
		seen.add(match[1]);
		try {
			await writer.touchSkill(match[1]);
			log.debug("skill usage tracked", { skill: match[1] });
		} catch (err) {
			log.debug("touchSkill failed", {
				skill: match[1],
				error: String(err)
			});
		}
	}
}
//#endregion
export { trackSkillUsage };
