@@ -228,6 +228,8 @@ async function generateRpc(schemaPath?: string): Promise<void> {
228228 // Post-process quicktype output: fix enum constant names
229229 let qtCode = qtResult . lines . filter ( ( l ) => ! l . startsWith ( "package " ) ) . join ( "\n" ) ;
230230 qtCode = postProcessEnumConstants ( qtCode ) ;
231+ // Strip trailing whitespace from quicktype output (gofmt requirement)
232+ qtCode = qtCode . replace ( / [ \t ] + $ / gm, "" ) ;
231233
232234 // Extract actual type names generated by quicktype (may differ from toPascalCase)
233235 const actualTypeNames = new Map < string , string > ( ) ;
@@ -241,22 +243,7 @@ async function generateRpc(schemaPath?: string): Promise<void> {
241243 // Extract field name mappings (quicktype may rename fields to avoid Go keyword conflicts)
242244 const fieldNames = extractFieldNames ( qtCode ) ;
243245
244- // Build method wrappers
245- const lines : string [ ] = [ ] ;
246- lines . push ( `// AUTO-GENERATED FILE - DO NOT EDIT` ) ;
247- lines . push ( `// Generated from: api.schema.json` ) ;
248- lines . push ( `` ) ;
249- lines . push ( `package rpc` ) ;
250- lines . push ( `` ) ;
251- lines . push ( `import (` ) ;
252- lines . push ( `\t"context"` ) ;
253- lines . push ( `\t"encoding/json"` ) ;
254- lines . push ( `` ) ;
255- lines . push ( `\t"github.com/github/copilot-sdk/go/internal/jsonrpc2"` ) ;
256- lines . push ( `)` ) ;
257- lines . push ( `` ) ;
258-
259- // Add quicktype-generated types (skip package line), annotating experimental types
246+ // Annotate experimental data types
260247 const experimentalTypeNames = new Set < string > ( ) ;
261248 for ( const method of allMethods ) {
262249 if ( method . stability !== "experimental" ) continue ;
@@ -266,9 +253,6 @@ async function generateRpc(schemaPath?: string): Promise<void> {
266253 experimentalTypeNames . add ( baseName + "Params" ) ;
267254 }
268255 }
269- let qtCode = qtResult . lines . filter ( ( l ) => ! l . startsWith ( "package " ) ) . join ( "\n" ) ;
270- // Strip trailing whitespace from quicktype output (gofmt requirement)
271- qtCode = qtCode . replace ( / [ \t ] + $ / gm, "" ) ;
272256 for ( const typeName of experimentalTypeNames ) {
273257 qtCode = qtCode . replace (
274258 new RegExp ( `^(type ${ typeName } struct)` , "m" ) ,
@@ -277,6 +261,22 @@ async function generateRpc(schemaPath?: string): Promise<void> {
277261 }
278262 // Remove trailing blank lines from quicktype output before appending
279263 qtCode = qtCode . replace ( / \n + $ / , "" ) ;
264+
265+ // Build method wrappers
266+ const lines : string [ ] = [ ] ;
267+ lines . push ( `// AUTO-GENERATED FILE - DO NOT EDIT` ) ;
268+ lines . push ( `// Generated from: api.schema.json` ) ;
269+ lines . push ( `` ) ;
270+ lines . push ( `package rpc` ) ;
271+ lines . push ( `` ) ;
272+ lines . push ( `import (` ) ;
273+ lines . push ( `\t"context"` ) ;
274+ lines . push ( `\t"encoding/json"` ) ;
275+ lines . push ( `` ) ;
276+ lines . push ( `\t"github.com/github/copilot-sdk/go/internal/jsonrpc2"` ) ;
277+ lines . push ( `)` ) ;
278+ lines . push ( `` ) ;
279+
280280 lines . push ( qtCode ) ;
281281 lines . push ( `` ) ;
282282
0 commit comments