(appId string, builderId string)
| 75 | } |
| 76 | |
| 77 | func GetBuilderWriteAppFileToolDefinition(appId string, builderId string) uctypes.ToolDefinition { |
| 78 | return uctypes.ToolDefinition{ |
| 79 | Name: "builder_write_app_file", |
| 80 | DisplayName: "Write App File", |
| 81 | Description: fmt.Sprintf("Write the app.go file for app %s", appId), |
| 82 | ToolLogName: "builder:write_app", |
| 83 | Strict: false, |
| 84 | InputSchema: map[string]any{ |
| 85 | "type": "object", |
| 86 | "properties": map[string]any{ |
| 87 | "contents": map[string]any{ |
| 88 | "type": "string", |
| 89 | "description": "The contents to write to app.go", |
| 90 | }, |
| 91 | }, |
| 92 | "required": []string{"contents"}, |
| 93 | "additionalProperties": false, |
| 94 | }, |
| 95 | ToolCallDesc: func(input any, output any, toolUseData *uctypes.UIMessageDataToolUse) string { |
| 96 | params, err := parseBuilderWriteAppFileInput(input) |
| 97 | if err != nil { |
| 98 | if output != nil { |
| 99 | return "wrote app.go" |
| 100 | } |
| 101 | return "writing app.go" |
| 102 | } |
| 103 | lineCount := len(strings.Split(params.Contents, "\n")) |
| 104 | if output != nil { |
| 105 | return fmt.Sprintf("wrote app.go (+%d lines)", lineCount) |
| 106 | } |
| 107 | return fmt.Sprintf("writing app.go (+%d lines)", lineCount) |
| 108 | }, |
| 109 | ToolProgressDesc: func(input any) ([]string, error) { |
| 110 | params, err := parseBuilderWriteAppFileInput(input) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | lineCount := len(strings.Split(params.Contents, "\n")) |
| 115 | return []string{fmt.Sprintf("writing app.go (+%d lines)", lineCount)}, nil |
| 116 | }, |
| 117 | ToolAnyCallback: func(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) { |
| 118 | params, err := parseBuilderWriteAppFileInput(input) |
| 119 | if err != nil { |
| 120 | return nil, err |
| 121 | } |
| 122 | |
| 123 | formattedContents := waveapputil.FormatGoCode([]byte(params.Contents)) |
| 124 | err = waveappstore.WriteAppFile(appId, BuilderAppFileName, formattedContents) |
| 125 | if err != nil { |
| 126 | return nil, err |
| 127 | } |
| 128 | |
| 129 | wps.Broker.Publish(wps.WaveEvent{ |
| 130 | Event: wps.Event_WaveAppAppGoUpdated, |
| 131 | Scopes: []string{appId}, |
| 132 | }) |
| 133 | |
| 134 | result := map[string]any{ |
no test coverage detected