// Use dynamic imports for bundler compatibility while maintaining lazy loading
export async function discoverCommands() {
    const commandModules = await Promise.all([
        import("./ai/index.js").then((m) => m.command),
        import("./auth/index.js").then((m) => m.command),
        import("./build/index.js").then((m) => m.command),
        import("./canary/index.js").then((m) => m.command),
        import("./cloud/index.js").then((m) => m.command),
        import("./coder/index.js").then((m) => m.command),
        import("./dev/index.js").then((m) => m.command),
        import("./git/index.js").then((m) => m.gitCommand),
        import("./help/index.js").then((m) => m.command),
        import("./profile/index.js").then((m) => m.command),
        import("./project/index.js").then((m) => m.command),
        import("./repl/index.js").then((m) => m.command),
        import("./setup/index.js").then((m) => m.command),
        import("./status.js").then((m) => m.command),
        import("./support/index.js").then((m) => m.command),
        import("./upgrade/index.js").then((m) => m.command),
        import("./version/index.js").then((m) => m.command),
    ]);
    const commands = [];
    for (const cmd of commandModules) {
        commands.push(cmd);
        // Auto-create hidden top-level aliases for subcommands with toplevel: true
        if (cmd.subcommands) {
            for (const subcommand of cmd.subcommands) {
                if (subcommand.toplevel) {
                    // eslint-disable-next-line @typescript-eslint/no-explicit-any
                    const alias = {
                        name: subcommand.name,
                        description: subcommand.description,
                        aliases: subcommand.aliases,
                        hidden: true,
                        skipSkill: true,
                        requires: subcommand.requires,
                        optional: subcommand.optional,
                        schema: subcommand.schema,
                        handler: subcommand.handler,
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        idempotent: subcommand.idempotent,
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        prerequisites: subcommand.prerequisites,
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        tags: subcommand.tags,
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        examples: subcommand.examples,
                    };
                    commands.push(alias);
                }
            }
        }
    }
    return commands;
}
//# sourceMappingURL=index.js.map