message.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. package chat
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "path/filepath"
  6. "slices"
  7. "strings"
  8. "time"
  9. "unicode"
  10. "github.com/charmbracelet/lipgloss/v2"
  11. "github.com/charmbracelet/lipgloss/v2/compat"
  12. "github.com/charmbracelet/x/ansi"
  13. "github.com/sst/opencode-sdk-go"
  14. "github.com/sst/opencode/internal/app"
  15. "github.com/sst/opencode/internal/components/diff"
  16. "github.com/sst/opencode/internal/layout"
  17. "github.com/sst/opencode/internal/styles"
  18. "github.com/sst/opencode/internal/theme"
  19. "github.com/tidwall/gjson"
  20. "golang.org/x/text/cases"
  21. "golang.org/x/text/language"
  22. )
  23. func toMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) string {
  24. r := styles.GetMarkdownRenderer(width-7, backgroundColor)
  25. content = strings.ReplaceAll(content, app.RootPath+"/", "")
  26. rendered, _ := r.Render(content)
  27. lines := strings.Split(rendered, "\n")
  28. if len(lines) > 0 {
  29. firstLine := lines[0]
  30. cleaned := ansi.Strip(firstLine)
  31. nospace := strings.ReplaceAll(cleaned, " ", "")
  32. if nospace == "" {
  33. lines = lines[1:]
  34. }
  35. if len(lines) > 0 {
  36. lastLine := lines[len(lines)-1]
  37. cleaned = ansi.Strip(lastLine)
  38. nospace = strings.ReplaceAll(cleaned, " ", "")
  39. if nospace == "" {
  40. lines = lines[:len(lines)-1]
  41. }
  42. }
  43. }
  44. content = strings.Join(lines, "\n")
  45. return strings.TrimSuffix(content, "\n")
  46. }
  47. type blockRenderer struct {
  48. border bool
  49. borderColor *compat.AdaptiveColor
  50. paddingTop int
  51. paddingBottom int
  52. paddingLeft int
  53. paddingRight int
  54. marginTop int
  55. marginBottom int
  56. }
  57. type renderingOption func(*blockRenderer)
  58. func WithNoBorder() renderingOption {
  59. return func(c *blockRenderer) {
  60. c.border = false
  61. }
  62. }
  63. func WithBorderColor(color compat.AdaptiveColor) renderingOption {
  64. return func(c *blockRenderer) {
  65. c.borderColor = &color
  66. }
  67. }
  68. func WithMarginTop(padding int) renderingOption {
  69. return func(c *blockRenderer) {
  70. c.marginTop = padding
  71. }
  72. }
  73. func WithMarginBottom(padding int) renderingOption {
  74. return func(c *blockRenderer) {
  75. c.marginBottom = padding
  76. }
  77. }
  78. func WithPadding(padding int) renderingOption {
  79. return func(c *blockRenderer) {
  80. c.paddingTop = padding
  81. c.paddingBottom = padding
  82. c.paddingLeft = padding
  83. c.paddingRight = padding
  84. }
  85. }
  86. func WithPaddingLeft(padding int) renderingOption {
  87. return func(c *blockRenderer) {
  88. c.paddingLeft = padding
  89. }
  90. }
  91. func WithPaddingRight(padding int) renderingOption {
  92. return func(c *blockRenderer) {
  93. c.paddingRight = padding
  94. }
  95. }
  96. func WithPaddingTop(padding int) renderingOption {
  97. return func(c *blockRenderer) {
  98. c.paddingTop = padding
  99. }
  100. }
  101. func WithPaddingBottom(padding int) renderingOption {
  102. return func(c *blockRenderer) {
  103. c.paddingBottom = padding
  104. }
  105. }
  106. func renderContentBlock(
  107. content string,
  108. width int,
  109. align lipgloss.Position,
  110. options ...renderingOption,
  111. ) string {
  112. t := theme.CurrentTheme()
  113. renderer := &blockRenderer{
  114. border: true,
  115. paddingTop: 1,
  116. paddingBottom: 1,
  117. paddingLeft: 2,
  118. paddingRight: 2,
  119. }
  120. for _, option := range options {
  121. option(renderer)
  122. }
  123. borderColor := t.BackgroundPanel()
  124. if renderer.borderColor != nil {
  125. borderColor = *renderer.borderColor
  126. }
  127. style := styles.NewStyle().
  128. Foreground(t.TextMuted()).
  129. Background(t.BackgroundPanel()).
  130. Width(width).
  131. PaddingTop(renderer.paddingTop).
  132. PaddingBottom(renderer.paddingBottom).
  133. PaddingLeft(renderer.paddingLeft).
  134. PaddingRight(renderer.paddingRight).
  135. AlignHorizontal(lipgloss.Left)
  136. if renderer.border {
  137. style = style.
  138. BorderStyle(lipgloss.ThickBorder()).
  139. BorderLeft(true).
  140. BorderRight(true).
  141. BorderLeftForeground(borderColor).
  142. BorderLeftBackground(t.Background()).
  143. BorderRightForeground(t.BackgroundPanel()).
  144. BorderRightBackground(t.Background())
  145. }
  146. content = style.Render(content)
  147. content = lipgloss.PlaceHorizontal(
  148. width,
  149. lipgloss.Left,
  150. content,
  151. styles.WhitespaceStyle(t.Background()),
  152. )
  153. content = lipgloss.PlaceHorizontal(
  154. layout.Current.Viewport.Width,
  155. align,
  156. content,
  157. styles.WhitespaceStyle(t.Background()),
  158. )
  159. if renderer.marginTop > 0 {
  160. for range renderer.marginTop {
  161. content = "\n" + content
  162. }
  163. }
  164. if renderer.marginBottom > 0 {
  165. for range renderer.marginBottom {
  166. content = content + "\n"
  167. }
  168. }
  169. return content
  170. }
  171. func renderText(
  172. message opencode.Message,
  173. text string,
  174. author string,
  175. showToolDetails bool,
  176. width int,
  177. align lipgloss.Position,
  178. toolCalls ...opencode.ToolInvocationPart,
  179. ) string {
  180. t := theme.CurrentTheme()
  181. timestamp := time.UnixMilli(int64(message.Metadata.Time.Created)).Local().Format("02 Jan 2006 03:04 PM")
  182. if time.Now().Format("02 Jan 2006") == timestamp[:11] {
  183. // don't show the date if it's today
  184. timestamp = timestamp[12:]
  185. }
  186. info := fmt.Sprintf("%s (%s)", author, timestamp)
  187. messageStyle := styles.NewStyle().
  188. Background(t.BackgroundPanel()).
  189. Foreground(t.Text())
  190. if message.Role == opencode.MessageRoleUser {
  191. messageStyle = messageStyle.Width(width - 6)
  192. }
  193. content := messageStyle.Render(text)
  194. if message.Role == opencode.MessageRoleAssistant {
  195. content = toMarkdown(text, width, t.BackgroundPanel())
  196. }
  197. if !showToolDetails && toolCalls != nil && len(toolCalls) > 0 {
  198. content = content + "\n\n"
  199. for _, toolCall := range toolCalls {
  200. title := renderToolTitle(toolCall, message.Metadata, width)
  201. metadata := opencode.MessageMetadataTool{}
  202. if _, ok := message.Metadata.Tool[toolCall.ToolInvocation.ToolCallID]; ok {
  203. metadata = message.Metadata.Tool[toolCall.ToolInvocation.ToolCallID]
  204. }
  205. style := styles.NewStyle()
  206. if _, ok := metadata.ExtraFields["error"]; ok {
  207. style = style.Foreground(t.Error())
  208. }
  209. title = style.Render(title)
  210. title = "∟ " + title + "\n"
  211. content = content + title
  212. }
  213. }
  214. content = strings.Join([]string{content, info}, "\n")
  215. switch message.Role {
  216. case opencode.MessageRoleUser:
  217. return renderContentBlock(
  218. content,
  219. width,
  220. align,
  221. WithBorderColor(t.Secondary()),
  222. )
  223. case opencode.MessageRoleAssistant:
  224. return renderContentBlock(
  225. content,
  226. width,
  227. align,
  228. WithBorderColor(t.Accent()),
  229. )
  230. }
  231. return ""
  232. }
  233. func renderToolDetails(
  234. toolCall opencode.ToolInvocationPart,
  235. messageMetadata opencode.MessageMetadata,
  236. width int,
  237. align lipgloss.Position,
  238. ) string {
  239. ignoredTools := []string{"todoread"}
  240. if slices.Contains(ignoredTools, toolCall.ToolInvocation.ToolName) {
  241. return ""
  242. }
  243. toolCallID := toolCall.ToolInvocation.ToolCallID
  244. metadata := opencode.MessageMetadataTool{}
  245. if _, ok := messageMetadata.Tool[toolCallID]; ok {
  246. metadata = messageMetadata.Tool[toolCallID]
  247. }
  248. var result *string
  249. if toolCall.ToolInvocation.Result != "" {
  250. result = &toolCall.ToolInvocation.Result
  251. }
  252. if toolCall.ToolInvocation.State == "partial-call" {
  253. title := renderToolTitle(toolCall, messageMetadata, width)
  254. return renderContentBlock(title, width, align)
  255. }
  256. toolArgsMap := make(map[string]any)
  257. if toolCall.ToolInvocation.Args != nil {
  258. value := toolCall.ToolInvocation.Args
  259. if m, ok := value.(map[string]any); ok {
  260. toolArgsMap = m
  261. keys := make([]string, 0, len(toolArgsMap))
  262. for key := range toolArgsMap {
  263. keys = append(keys, key)
  264. }
  265. slices.Sort(keys)
  266. }
  267. }
  268. body := ""
  269. finished := result != nil && *result != ""
  270. t := theme.CurrentTheme()
  271. switch toolCall.ToolInvocation.ToolName {
  272. case "read":
  273. preview := metadata.ExtraFields["preview"]
  274. if preview != nil && toolArgsMap["filePath"] != nil {
  275. filename := toolArgsMap["filePath"].(string)
  276. body = preview.(string)
  277. body = renderFile(filename, body, width, WithTruncate(6))
  278. }
  279. case "edit":
  280. if filename, ok := toolArgsMap["filePath"].(string); ok {
  281. diffField := metadata.ExtraFields["diff"]
  282. if diffField != nil {
  283. patch := diffField.(string)
  284. var formattedDiff string
  285. formattedDiff, _ = diff.FormatUnifiedDiff(
  286. filename,
  287. patch,
  288. diff.WithWidth(width-2),
  289. )
  290. formattedDiff = strings.TrimSpace(formattedDiff)
  291. formattedDiff = styles.NewStyle().
  292. BorderStyle(lipgloss.ThickBorder()).
  293. BorderBackground(t.Background()).
  294. BorderForeground(t.BackgroundPanel()).
  295. BorderLeft(true).
  296. BorderRight(true).
  297. Render(formattedDiff)
  298. body = strings.TrimSpace(formattedDiff)
  299. body = renderContentBlock(
  300. body,
  301. width,
  302. align,
  303. WithNoBorder(),
  304. WithPadding(0),
  305. )
  306. if diagnostics := renderDiagnostics(metadata, filename); diagnostics != "" {
  307. body += "\n" + renderContentBlock(diagnostics, width, align)
  308. }
  309. title := renderToolTitle(toolCall, messageMetadata, width)
  310. title = renderContentBlock(title, width, align)
  311. content := title + "\n" + body
  312. return content
  313. }
  314. }
  315. case "write":
  316. if filename, ok := toolArgsMap["filePath"].(string); ok {
  317. if content, ok := toolArgsMap["content"].(string); ok {
  318. body = renderFile(filename, content, width)
  319. if diagnostics := renderDiagnostics(metadata, filename); diagnostics != "" {
  320. body += "\n\n" + diagnostics
  321. }
  322. }
  323. }
  324. case "bash":
  325. stdout := metadata.ExtraFields["stdout"]
  326. if stdout != nil {
  327. command := toolArgsMap["command"].(string)
  328. body = fmt.Sprintf("```console\n> %s\n%s```", command, stdout)
  329. body = toMarkdown(body, width, t.BackgroundPanel())
  330. }
  331. case "webfetch":
  332. if format, ok := toolArgsMap["format"].(string); ok && result != nil {
  333. body = *result
  334. body = truncateHeight(body, 10)
  335. if format == "html" || format == "markdown" {
  336. body = toMarkdown(body, width, t.BackgroundPanel())
  337. }
  338. }
  339. case "todowrite":
  340. todos := metadata.JSON.ExtraFields["todos"]
  341. if !todos.IsNull() && finished {
  342. strTodos := todos.Raw()
  343. todos := gjson.Parse(strTodos)
  344. for _, todo := range todos.Array() {
  345. content := todo.Get("content").String()
  346. switch todo.Get("status").String() {
  347. case "completed":
  348. body += fmt.Sprintf("- [x] %s\n", content)
  349. // case "in-progress":
  350. // body += fmt.Sprintf("- [ ] %s\n", content)
  351. default:
  352. body += fmt.Sprintf("- [ ] %s\n", content)
  353. }
  354. }
  355. body = toMarkdown(body, width, t.BackgroundPanel())
  356. }
  357. case "task":
  358. summary := metadata.JSON.ExtraFields["summary"]
  359. if !summary.IsNull() {
  360. strValue := summary.Raw()
  361. toolcalls := gjson.Parse(strValue).Array()
  362. steps := []string{}
  363. for _, toolcall := range toolcalls {
  364. call := toolcall.Value().(map[string]any)
  365. if toolInvocation, ok := call["toolInvocation"].(map[string]any); ok {
  366. data, _ := json.Marshal(toolInvocation)
  367. var toolCall opencode.ToolInvocationPart
  368. _ = json.Unmarshal(data, &toolCall)
  369. if metadata, ok := call["metadata"].(map[string]any); ok {
  370. data, _ = json.Marshal(metadata)
  371. var toolMetadata opencode.MessageMetadataTool
  372. _ = json.Unmarshal(data, &toolMetadata)
  373. step := renderToolTitle(toolCall, messageMetadata, width)
  374. step = "∟ " + step
  375. steps = append(steps, step)
  376. }
  377. }
  378. }
  379. body = strings.Join(steps, "\n")
  380. }
  381. default:
  382. if result == nil {
  383. empty := ""
  384. result = &empty
  385. }
  386. body = *result
  387. body = truncateHeight(body, 10)
  388. }
  389. error := ""
  390. if err, ok := metadata.ExtraFields["error"].(bool); ok && err {
  391. if message, ok := metadata.ExtraFields["message"].(string); ok {
  392. error = message
  393. }
  394. }
  395. if error != "" {
  396. body = styles.NewStyle().
  397. Foreground(t.Error()).
  398. Background(t.BackgroundPanel()).
  399. Render(error)
  400. }
  401. if body == "" && error == "" && result != nil {
  402. body = *result
  403. body = truncateHeight(body, 10)
  404. }
  405. title := renderToolTitle(toolCall, messageMetadata, width)
  406. content := title + "\n\n" + body
  407. return renderContentBlock(content, width, align)
  408. }
  409. func renderToolName(name string) string {
  410. switch name {
  411. case "webfetch":
  412. return "Fetch"
  413. case "todowrite", "todoread":
  414. return "Plan"
  415. default:
  416. normalizedName := name
  417. if strings.HasPrefix(name, "opencode_") {
  418. normalizedName = strings.TrimPrefix(name, "opencode_")
  419. }
  420. return cases.Title(language.Und).String(normalizedName)
  421. }
  422. }
  423. func renderToolTitle(
  424. toolCall opencode.ToolInvocationPart,
  425. messageMetadata opencode.MessageMetadata,
  426. width int,
  427. ) string {
  428. // TODO: handle truncate to width
  429. if toolCall.ToolInvocation.State == "partial-call" {
  430. return renderToolAction(toolCall.ToolInvocation.ToolName)
  431. }
  432. toolArgs := ""
  433. toolArgsMap := make(map[string]any)
  434. if toolCall.ToolInvocation.Args != nil {
  435. value := toolCall.ToolInvocation.Args
  436. if m, ok := value.(map[string]any); ok {
  437. toolArgsMap = m
  438. keys := make([]string, 0, len(toolArgsMap))
  439. for key := range toolArgsMap {
  440. keys = append(keys, key)
  441. }
  442. slices.Sort(keys)
  443. firstKey := ""
  444. if len(keys) > 0 {
  445. firstKey = keys[0]
  446. }
  447. toolArgs = renderArgs(&toolArgsMap, firstKey)
  448. }
  449. }
  450. title := renderToolName(toolCall.ToolInvocation.ToolName)
  451. switch toolCall.ToolInvocation.ToolName {
  452. case "read":
  453. toolArgs = renderArgs(&toolArgsMap, "filePath")
  454. title = fmt.Sprintf("%s %s", title, toolArgs)
  455. case "edit", "write":
  456. if filename, ok := toolArgsMap["filePath"].(string); ok {
  457. title = fmt.Sprintf("%s %s", title, relative(filename))
  458. }
  459. case "bash", "task":
  460. if description, ok := toolArgsMap["description"].(string); ok {
  461. title = fmt.Sprintf("%s %s", title, description)
  462. }
  463. case "webfetch":
  464. toolArgs = renderArgs(&toolArgsMap, "url")
  465. title = fmt.Sprintf("%s %s", title, toolArgs)
  466. case "todowrite", "todoread":
  467. // title is just the tool name
  468. default:
  469. toolName := renderToolName(toolCall.ToolInvocation.ToolName)
  470. title = fmt.Sprintf("%s %s", toolName, toolArgs)
  471. }
  472. return title
  473. }
  474. func renderToolAction(name string) string {
  475. switch name {
  476. case "task":
  477. return "Searching..."
  478. case "bash":
  479. return "Writing command..."
  480. case "edit":
  481. return "Preparing edit..."
  482. case "webfetch":
  483. return "Fetching from the web..."
  484. case "glob":
  485. return "Finding files..."
  486. case "grep":
  487. return "Searching content..."
  488. case "list":
  489. return "Listing directory..."
  490. case "read":
  491. return "Reading file..."
  492. case "write":
  493. return "Preparing write..."
  494. case "todowrite", "todoread":
  495. return "Planning..."
  496. case "patch":
  497. return "Preparing patch..."
  498. }
  499. return "Working..."
  500. }
  501. type fileRenderer struct {
  502. filename string
  503. content string
  504. height int
  505. }
  506. type fileRenderingOption func(*fileRenderer)
  507. func WithTruncate(height int) fileRenderingOption {
  508. return func(c *fileRenderer) {
  509. c.height = height
  510. }
  511. }
  512. func renderFile(
  513. filename string,
  514. content string,
  515. width int,
  516. options ...fileRenderingOption) string {
  517. t := theme.CurrentTheme()
  518. renderer := &fileRenderer{
  519. filename: filename,
  520. content: content,
  521. }
  522. for _, option := range options {
  523. option(renderer)
  524. }
  525. lines := []string{}
  526. for line := range strings.SplitSeq(content, "\n") {
  527. line = strings.TrimRightFunc(line, unicode.IsSpace)
  528. line = strings.ReplaceAll(line, "\t", " ")
  529. lines = append(lines, line)
  530. }
  531. content = strings.Join(lines, "\n")
  532. if renderer.height > 0 {
  533. content = truncateHeight(content, renderer.height)
  534. }
  535. content = fmt.Sprintf("```%s\n%s\n```", extension(renderer.filename), content)
  536. content = toMarkdown(content, width, t.BackgroundPanel())
  537. return content
  538. }
  539. func renderArgs(args *map[string]any, titleKey string) string {
  540. if args == nil || len(*args) == 0 {
  541. return ""
  542. }
  543. keys := make([]string, 0, len(*args))
  544. for key := range *args {
  545. keys = append(keys, key)
  546. }
  547. slices.Sort(keys)
  548. title := ""
  549. parts := []string{}
  550. for _, key := range keys {
  551. value := (*args)[key]
  552. if value == nil {
  553. continue
  554. }
  555. if key == "filePath" || key == "path" {
  556. value = relative(value.(string))
  557. }
  558. if key == titleKey {
  559. title = fmt.Sprintf("%s", value)
  560. continue
  561. }
  562. parts = append(parts, fmt.Sprintf("%s=%v", key, value))
  563. }
  564. if len(parts) == 0 {
  565. return title
  566. }
  567. return fmt.Sprintf("%s (%s)", title, strings.Join(parts, ", "))
  568. }
  569. func truncateHeight(content string, height int) string {
  570. lines := strings.Split(content, "\n")
  571. if len(lines) > height {
  572. return strings.Join(lines[:height], "\n")
  573. }
  574. return content
  575. }
  576. func relative(path string) string {
  577. path = strings.TrimPrefix(path, app.CwdPath+"/")
  578. return strings.TrimPrefix(path, app.RootPath+"/")
  579. }
  580. func extension(path string) string {
  581. ext := filepath.Ext(path)
  582. if ext == "" {
  583. ext = ""
  584. } else {
  585. ext = strings.ToLower(ext[1:])
  586. }
  587. return ext
  588. }
  589. // Diagnostic represents an LSP diagnostic
  590. type Diagnostic struct {
  591. Range struct {
  592. Start struct {
  593. Line int `json:"line"`
  594. Character int `json:"character"`
  595. } `json:"start"`
  596. } `json:"range"`
  597. Severity int `json:"severity"`
  598. Message string `json:"message"`
  599. }
  600. // renderDiagnostics formats LSP diagnostics for display in the TUI
  601. func renderDiagnostics(metadata opencode.MessageMetadataTool, filePath string) string {
  602. if diagnosticsData, ok := metadata.ExtraFields["diagnostics"].(map[string]any); ok {
  603. if fileDiagnostics, ok := diagnosticsData[filePath].([]any); ok {
  604. var errorDiagnostics []string
  605. for _, diagInterface := range fileDiagnostics {
  606. diagMap, ok := diagInterface.(map[string]any)
  607. if !ok {
  608. continue
  609. }
  610. // Parse the diagnostic
  611. var diag Diagnostic
  612. diagBytes, err := json.Marshal(diagMap)
  613. if err != nil {
  614. continue
  615. }
  616. if err := json.Unmarshal(diagBytes, &diag); err != nil {
  617. continue
  618. }
  619. // Only show error diagnostics (severity === 1)
  620. if diag.Severity != 1 {
  621. continue
  622. }
  623. line := diag.Range.Start.Line + 1 // 1-based
  624. column := diag.Range.Start.Character + 1 // 1-based
  625. errorDiagnostics = append(errorDiagnostics, fmt.Sprintf("Error [%d:%d] %s", line, column, diag.Message))
  626. }
  627. if len(errorDiagnostics) == 0 {
  628. return ""
  629. }
  630. t := theme.CurrentTheme()
  631. var result strings.Builder
  632. for _, diagnostic := range errorDiagnostics {
  633. if result.Len() > 0 {
  634. result.WriteString("\n")
  635. }
  636. result.WriteString(styles.NewStyle().Foreground(t.Error()).Render(diagnostic))
  637. }
  638. return result.String()
  639. }
  640. }
  641. return ""
  642. // diagnosticsData should be a map[string][]Diagnostic
  643. // strDiagnosticsData := diagnosticsData.Raw()
  644. // diagnosticsMap := gjson.Parse(strDiagnosticsData).Value().(map[string]any)
  645. // fileDiagnostics, ok := diagnosticsMap[filePath]
  646. // if !ok {
  647. // return ""
  648. // }
  649. // diagnosticsList, ok := fileDiagnostics.([]any)
  650. // if !ok {
  651. // return ""
  652. // }
  653. }