import { getAgentDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { ensureCondenseEnabledDefault } from "./condense-config.ts";

/** Apply the bundle default before pi-condense reads settings on session_start. */
export default async function bundledCondenseExtension(pi: ExtensionAPI): Promise<void> {
	const result = ensureCondenseEnabledDefault(getAgentDir());
	if (result === "skipped-invalid") {
		console.warn("my-pi: skipped the pi-condense default because settings.json or contextPrune is invalid");
	}
	const { default: condenseExtension } = await import("../node_modules/pi-condense/index.ts");
	condenseExtension(pi);
}
