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

Function GenerateCurrentTabStatePrompt

pkg/aiusechat/tools.go:202–238  ·  view source on GitHub ↗
(blocks []*waveobj.Block, widgetAccess bool)

Source from the content-addressed store, hash-verified

200}
201
202func GenerateCurrentTabStatePrompt(blocks []*waveobj.Block, widgetAccess bool) string {
203 if !widgetAccess {
204 return `<current_tab_state>The user has chosen not to share widget context with you</current_tab_state>`
205 }
206 var widgetDescriptions []string
207 for _, block := range blocks {
208 desc := MakeBlockShortDesc(block)
209 if desc == "" {
210 continue
211 }
212 blockIdPrefix := block.OID[:8]
213 fullDesc := fmt.Sprintf("(%s) %s", blockIdPrefix, desc)
214 widgetDescriptions = append(widgetDescriptions, fullDesc)
215 }
216
217 var prompt strings.Builder
218 prompt.WriteString("<current_tab_state>\n")
219 systemInfo := wavebase.GetSystemSummary()
220 if currentUser, err := user.Current(); err == nil && currentUser.Username != "" {
221 prompt.WriteString(fmt.Sprintf("Local Machine: %s, User: %s\n", systemInfo, currentUser.Username))
222 } else {
223 prompt.WriteString(fmt.Sprintf("Local Machine: %s\n", systemInfo))
224 }
225 if len(widgetDescriptions) == 0 {
226 prompt.WriteString("No widgets open\n")
227 } else {
228 prompt.WriteString("Open Widgets:\n")
229 for _, desc := range widgetDescriptions {
230 prompt.WriteString("* ")
231 prompt.WriteString(desc)
232 prompt.WriteString("\n")
233 }
234 }
235 prompt.WriteString("</current_tab_state>")
236 rtn := prompt.String()
237 return rtn
238}
239
240func generateToolsForTsunamiBlock(block *waveobj.Block) []uctypes.ToolDefinition {
241 var tools []uctypes.ToolDefinition

Callers 1

GenerateTabStateAndToolsFunction · 0.85

Calls 4

GetSystemSummaryFunction · 0.92
MakeBlockShortDescFunction · 0.85
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected