MCPcopy
hub / github.com/wavetermdev/waveterm / GetBuilderWriteAppFileToolDefinition

Function GetBuilderWriteAppFileToolDefinition

pkg/aiusechat/tools_builder.go:77–149  ·  view source on GitHub ↗
(appId string, builderId string)

Source from the content-addressed store, hash-verified

75}
76
77func 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{

Callers 1

WaveAIPostMessageHandlerFunction · 0.85

Calls 5

FormatGoCodeFunction · 0.92
WriteAppFileFunction · 0.92
triggerBuildAndWaitFunction · 0.85
PublishMethod · 0.80

Tested by

no test coverage detected