| 2075 | // ── mod.rs generation ─────────────────────────────────────────────────────── |
| 2076 | |
| 2077 | function generateModRs(): string { |
| 2078 | const lines: string[] = []; |
| 2079 | lines.push("//! Auto-generated protocol types — **not part of the public API**."); |
| 2080 | lines.push("//!"); |
| 2081 | lines.push( |
| 2082 | "//! This module is crate-private. Its layout, item visibility, and", |
| 2083 | ); |
| 2084 | lines.push("//! naming may change at any time without notice."); |
| 2085 | lines.push("//!"); |
| 2086 | lines.push("//! Public callers reach the generated types through the stable"); |
| 2087 | lines.push("//! re-export modules at the crate root:"); |
| 2088 | lines.push("//!"); |
| 2089 | lines.push("//! - [`crate::session_events`] for session event payload types"); |
| 2090 | lines.push("//! - [`crate::rpc`] for JSON-RPC request/response types and typed"); |
| 2091 | lines.push("//! namespace builders"); |
| 2092 | lines.push("//!"); |
| 2093 | lines.push( |
| 2094 | "//! Generated from the Copilot protocol JSON Schemas by `scripts/codegen/rust.ts`.", |
| 2095 | ); |
| 2096 | lines.push("#![allow(missing_docs)]"); |
| 2097 | lines.push("#![allow(rustdoc::bare_urls)]"); |
| 2098 | lines.push(""); |
| 2099 | lines.push("pub mod api_types;"); |
| 2100 | lines.push("pub mod rpc;"); |
| 2101 | lines.push("pub mod session_events;"); |
| 2102 | lines.push(""); |
| 2103 | lines.push( |
| 2104 | "// Re-export session event types at the module root — no conflicts with", |
| 2105 | ); |
| 2106 | lines.push( |
| 2107 | "// hand-written types. API types are kept namespaced under `api_types::`", |
| 2108 | ); |
| 2109 | lines.push( |
| 2110 | "// because some names (Tool, ModelCapabilities, etc.) overlap with the", |
| 2111 | ); |
| 2112 | lines.push("// hand-written SDK API types in `types.rs`."); |
| 2113 | lines.push("pub use session_events::*;"); |
| 2114 | lines.push(""); |
| 2115 | return lines.join("\n"); |
| 2116 | } |
| 2117 | |
| 2118 | // ── Format with rustfmt ───────────────────────────────────────────────────── |
| 2119 | |