Skip to content

Commit f1ae76d

Browse files
stephentoubCopilot
andcommitted
fix: expand single-line struct defs to multi-line for gofmt
gofmt expands single-line struct definitions with semicolons into multi-line format. Updated the Go codegen to emit API struct definitions in multi-line format directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dae6767 commit f1ae76d

2 files changed

Lines changed: 57 additions & 15 deletions

File tree

go/rpc/generated_rpc.go

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ type ResultUnion struct {
411411
}
412412

413413

414-
type ServerModelsRpcApi struct { client *jsonrpc2.Client }
414+
type ServerModelsRpcApi struct {
415+
client *jsonrpc2.Client
416+
}
415417

416418
func (a *ServerModelsRpcApi) List(ctx context.Context) (*ModelsListResult, error) {
417419
raw, err := a.client.Request("models.list", map[string]interface{}{})
@@ -425,7 +427,9 @@ func (a *ServerModelsRpcApi) List(ctx context.Context) (*ModelsListResult, error
425427
return &result, nil
426428
}
427429

428-
type ServerToolsRpcApi struct { client *jsonrpc2.Client }
430+
type ServerToolsRpcApi struct {
431+
client *jsonrpc2.Client
432+
}
429433

430434
func (a *ServerToolsRpcApi) List(ctx context.Context, params *ToolsListParams) (*ToolsListResult, error) {
431435
raw, err := a.client.Request("tools.list", params)
@@ -439,7 +443,9 @@ func (a *ServerToolsRpcApi) List(ctx context.Context, params *ToolsListParams) (
439443
return &result, nil
440444
}
441445

442-
type ServerAccountRpcApi struct { client *jsonrpc2.Client }
446+
type ServerAccountRpcApi struct {
447+
client *jsonrpc2.Client
448+
}
443449

444450
func (a *ServerAccountRpcApi) GetQuota(ctx context.Context) (*AccountGetQuotaResult, error) {
445451
raw, err := a.client.Request("account.getQuota", map[string]interface{}{})
@@ -481,7 +487,10 @@ func NewServerRpc(client *jsonrpc2.Client) *ServerRpc {
481487
}
482488
}
483489

484-
type ModelRpcApi struct { client *jsonrpc2.Client; sessionID string }
490+
type ModelRpcApi struct {
491+
client *jsonrpc2.Client
492+
sessionID string
493+
}
485494

486495
func (a *ModelRpcApi) GetCurrent(ctx context.Context) (*SessionModelGetCurrentResult, error) {
487496
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -515,7 +524,10 @@ func (a *ModelRpcApi) SwitchTo(ctx context.Context, params *SessionModelSwitchTo
515524
return &result, nil
516525
}
517526

518-
type ModeRpcApi struct { client *jsonrpc2.Client; sessionID string }
527+
type ModeRpcApi struct {
528+
client *jsonrpc2.Client
529+
sessionID string
530+
}
519531

520532
func (a *ModeRpcApi) Get(ctx context.Context) (*SessionModeGetResult, error) {
521533
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -546,7 +558,10 @@ func (a *ModeRpcApi) Set(ctx context.Context, params *SessionModeSetParams) (*Se
546558
return &result, nil
547559
}
548560

549-
type PlanRpcApi struct { client *jsonrpc2.Client; sessionID string }
561+
type PlanRpcApi struct {
562+
client *jsonrpc2.Client
563+
sessionID string
564+
}
550565

551566
func (a *PlanRpcApi) Read(ctx context.Context) (*SessionPlanReadResult, error) {
552567
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -590,7 +605,10 @@ func (a *PlanRpcApi) Delete(ctx context.Context) (*SessionPlanDeleteResult, erro
590605
return &result, nil
591606
}
592607

593-
type WorkspaceRpcApi struct { client *jsonrpc2.Client; sessionID string }
608+
type WorkspaceRpcApi struct {
609+
client *jsonrpc2.Client
610+
sessionID string
611+
}
594612

595613
func (a *WorkspaceRpcApi) ListFiles(ctx context.Context) (*SessionWorkspaceListFilesResult, error) {
596614
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -639,7 +657,10 @@ func (a *WorkspaceRpcApi) CreateFile(ctx context.Context, params *SessionWorkspa
639657
}
640658

641659
// Experimental: FleetRpcApi contains experimental APIs that may change or be removed.
642-
type FleetRpcApi struct { client *jsonrpc2.Client; sessionID string }
660+
type FleetRpcApi struct {
661+
client *jsonrpc2.Client
662+
sessionID string
663+
}
643664

644665
func (a *FleetRpcApi) Start(ctx context.Context, params *SessionFleetStartParams) (*SessionFleetStartResult, error) {
645666
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -660,7 +681,10 @@ func (a *FleetRpcApi) Start(ctx context.Context, params *SessionFleetStartParams
660681
}
661682

662683
// Experimental: AgentRpcApi contains experimental APIs that may change or be removed.
663-
type AgentRpcApi struct { client *jsonrpc2.Client; sessionID string }
684+
type AgentRpcApi struct {
685+
client *jsonrpc2.Client
686+
sessionID string
687+
}
664688

665689
func (a *AgentRpcApi) List(ctx context.Context) (*SessionAgentListResult, error) {
666690
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -718,7 +742,10 @@ func (a *AgentRpcApi) Deselect(ctx context.Context) (*SessionAgentDeselectResult
718742
}
719743

720744
// Experimental: CompactionRpcApi contains experimental APIs that may change or be removed.
721-
type CompactionRpcApi struct { client *jsonrpc2.Client; sessionID string }
745+
type CompactionRpcApi struct {
746+
client *jsonrpc2.Client
747+
sessionID string
748+
}
722749

723750
func (a *CompactionRpcApi) Compact(ctx context.Context) (*SessionCompactionCompactResult, error) {
724751
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -733,7 +760,10 @@ func (a *CompactionRpcApi) Compact(ctx context.Context) (*SessionCompactionCompa
733760
return &result, nil
734761
}
735762

736-
type ToolsRpcApi struct { client *jsonrpc2.Client; sessionID string }
763+
type ToolsRpcApi struct {
764+
client *jsonrpc2.Client
765+
sessionID string
766+
}
737767

738768
func (a *ToolsRpcApi) HandlePendingToolCall(ctx context.Context, params *SessionToolsHandlePendingToolCallParams) (*SessionToolsHandlePendingToolCallResult, error) {
739769
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -757,7 +787,10 @@ func (a *ToolsRpcApi) HandlePendingToolCall(ctx context.Context, params *Session
757787
return &result, nil
758788
}
759789

760-
type PermissionsRpcApi struct { client *jsonrpc2.Client; sessionID string }
790+
type PermissionsRpcApi struct {
791+
client *jsonrpc2.Client
792+
sessionID string
793+
}
761794

762795
func (a *PermissionsRpcApi) HandlePendingPermissionRequest(ctx context.Context, params *SessionPermissionsHandlePendingPermissionRequestParams) (*SessionPermissionsHandlePendingPermissionRequestResult, error) {
763796
req := map[string]interface{}{"sessionId": a.sessionID}
@@ -776,7 +809,10 @@ func (a *PermissionsRpcApi) HandlePendingPermissionRequest(ctx context.Context,
776809
return &result, nil
777810
}
778811

779-
type ShellRpcApi struct { client *jsonrpc2.Client; sessionID string }
812+
type ShellRpcApi struct {
813+
client *jsonrpc2.Client
814+
sessionID string
815+
}
780816

781817
func (a *ShellRpcApi) Exec(ctx context.Context, params *SessionShellExecParams) (*SessionShellExecResult, error) {
782818
req := map[string]interface{}{"sessionId": a.sessionID}

scripts/codegen/go.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,18 @@ function emitRpcWrapper(lines: string[], node: Record<string, unknown>, isSessio
218218
for (const [groupName, groupNode] of groups) {
219219
const prefix = isSession ? "" : "Server";
220220
const apiName = prefix + toPascalCase(groupName) + apiSuffix;
221-
const fields = isSession ? "client *jsonrpc2.Client; sessionID string" : "client *jsonrpc2.Client";
222221
const groupExperimental = isNodeFullyExperimental(groupNode as Record<string, unknown>);
223222
if (groupExperimental) {
224223
lines.push(`// Experimental: ${apiName} contains experimental APIs that may change or be removed.`);
225224
}
226-
lines.push(`type ${apiName} struct { ${fields} }`);
225+
lines.push(`type ${apiName} struct {`);
226+
if (isSession) {
227+
lines.push(`\tclient *jsonrpc2.Client`);
228+
lines.push(`\tsessionID string`);
229+
} else {
230+
lines.push(`\tclient *jsonrpc2.Client`);
231+
}
232+
lines.push(`}`);
227233
lines.push(``);
228234
for (const [key, value] of Object.entries(groupNode as Record<string, unknown>)) {
229235
if (!isRpcMethod(value)) continue;

0 commit comments

Comments
 (0)