import "./paths-CutK9mvd.js";
import "./registry-DScA7GM7.js";
import "./utils-BXq128Ep.js";
import { t as createSubsystemLogger } from "./subsystem-C0jWWDsO.js";
import "./boolean-DtWR5bt3.js";
import "./auth-profiles-Ci0m1nDj.js";
import "./exec-BfxXkFYo.js";
import { c as resolveAgentWorkspaceDir, l as resolveDefaultAgentId } from "./agent-scope-C9lu5zYP.js";
import "./frontmatter-B3s_6fwe.js";
import "./skills-CXwgvGur.js";
import "./manifest-registry-CLylU6AG.js";
import { r as loadConfig } from "./io-CD_zuK0D.js";
import "./config-DiWsrVKe.js";
import "./client-DcGx78uR.js";
import "./call-DfwL1J3H.js";
import "./message-channel-f25bXyKM.js";
import { g as loadCoderClawPlugins } from "./subagent-registry-C2sM5Cyw.js";
import "./sessions-Mt8f23sr.js";
import "./tokens-D7kBZYPD.js";
import "./plugins-CiXA7mtz.js";
import "./accounts-DlyBFGv4.js";
import "./bindings-DjR4yXgA.js";
import "./logging-pqyrk15z.js";
import "./send-BSyWSMGa.js";
import "./send-Bv-Ugxhn.js";
import "./with-timeout-CMUEB0p-.js";
import "./deliver-CkqGoWHC.js";
import "./accounts-DNDn42nY.js";
import "./send-Dbw-1Nv6.js";
import "./image-ops-DX6lds-i.js";
import "./models-config-6QdRrV1c.js";
import "./pi-embedded-helpers-_sjZz5r6.js";
import "./sandbox-Cgi5GRjr.js";
import "./chrome-CCvAKFA-.js";
import "./tailscale-BrDWEIwI.js";
import "./auth-B80pI0Uh.js";
import "./server-context-CPsi2755.js";
import "./routes-MRFMs3Hh.js";
import "./redact-CFj039qF.js";
import "./errors-8VQXhB4u.js";
import "./paths-BKv1HwMq.js";
import "./ssrf-weuQnXiO.js";
import "./store-BgSeZwv0.js";
import "./ports-BTCCmBPN.js";
import "./trash-RPQQ3ep-.js";
import "./accounts-IQLo28rM.js";
import "./paths-mQAx86lp.js";
import "./tool-images-BtNaJzDf.js";
import "./reply-prefix-CTkJoXqQ.js";
import "./memory-cli-DhQ3BMgb.js";
import "./manager-BUwPVwMU.js";
import "./gemini-auth-D_WaKG1u.js";
import "./sqlite-B6wrIncg.js";
import "./retry-eZfsfPJw.js";
import "./common-Cb-qblwg.js";
import "./chunk-CCkvwRI1.js";
import "./markdown-tables-BmPL6gxD.js";
import "./fetch-guard-DgkwAf8y.js";
import "./fetch-Cyj7bUtQ.js";
import "./ir-Zi6SqHuv.js";
import "./render-lL152pED.js";
import "./commands-registry-Bb7wps-U.js";
import "./runner-Dq5pUJw7.js";
import "./tool-display-C_2MZJqm.js";
import "./model-catalog-I10Mw32M.js";
import "./session-utils-rRgbDHdn.js";
import "./pi-tools.policy-Dl38gqLG.js";
import "./pairing-store-BFjZsQfU.js";
import "./fetch-FKiEPHsu.js";
import "./nodes-screen-aqjJyJKK.js";
import "./session-cost-usage-CFkSIl99.js";
import "./send-Dm5td_ud.js";
import "./outbound-attachment-DbnUFGg7.js";
import "./delivery-queue-CrM_98Zj.js";
import "./project-context-CDgzGX_i.js";
import "./control-service-Da4pvhRF.js";
import "./stagger-vDSk1wpM.js";
import "./channel-selection-C9HQldEr.js";
import "./send-DVTkNDIS.js";
import "./resolve-route-DfP8shJU.js";
import "./channel-activity-CjNqpxzA.js";
import "./tables-D0RFg7_p.js";
import "./links-Crq8FXFM.js";
import "./cli-utils-m10N0YX2.js";
import "./help-format-xwRPMYQn.js";
import "./progress-Czj96fRf.js";
import "./replies-D7zeCuNw.js";
import "./onboard-helpers-BfUVfjJm.js";
import "./prompt-style-gyFdZw9z.js";
import "./pairing-labels-DcHuGxfy.js";

//#region src/plugins/cli.ts
const log = createSubsystemLogger("plugins");
function registerPluginCliCommands(program, cfg) {
	const config = cfg ?? loadConfig();
	const workspaceDir = resolveAgentWorkspaceDir(config, resolveDefaultAgentId(config));
	const logger = {
		info: (msg) => log.info(msg),
		warn: (msg) => log.warn(msg),
		error: (msg) => log.error(msg),
		debug: (msg) => log.debug(msg)
	};
	const registry = loadCoderClawPlugins({
		config,
		workspaceDir,
		logger
	});
	const existingCommands = new Set(program.commands.map((cmd) => cmd.name()));
	for (const entry of registry.cliRegistrars) {
		if (entry.commands.length > 0) {
			const overlaps = entry.commands.filter((command) => existingCommands.has(command));
			if (overlaps.length > 0) {
				log.debug(`plugin CLI register skipped (${entry.pluginId}): command already registered (${overlaps.join(", ")})`);
				continue;
			}
		}
		try {
			const result = entry.register({
				program,
				config,
				workspaceDir,
				logger
			});
			if (result && typeof result.then === "function") result.catch((err) => {
				log.warn(`plugin CLI register failed (${entry.pluginId}): ${String(err)}`);
			});
			for (const command of entry.commands) existingCommands.add(command);
		} catch (err) {
			log.warn(`plugin CLI register failed (${entry.pluginId}): ${String(err)}`);
		}
	}
}

//#endregion
export { registerPluginCliCommands };