Commit 13be118965be

Vincent Demeester <vincent@sbr.pm>
2026-02-10 15:56:55
feat: add renderCall/renderResult to all search tools
Added custom rendering for github_search and stack_overflow_search to show query and result count, matching the web_search rendering pattern.
1 parent 107e410
Changed files (1)
dots
pi
agent
extensions
search
dots/pi/agent/extensions/search/index.ts
@@ -167,6 +167,27 @@ export default function (pi: ExtensionAPI) {
           "The code search query. Examples: 'readFile repo:owner/project', 'my_function language:python'",
       }),
     }),
+    renderCall(args, theme) {
+      let text = theme.fg("toolTitle", theme.bold("github_search "));
+      text += theme.fg("muted", `"${args.query}"`);
+      return new Text(text, 0, 0);
+    },
+
+    renderResult(result, { expanded }, theme) {
+      if (result.isError) {
+        return new Text(theme.fg("error", result.content?.[0]?.text || "Search failed"), 0, 0);
+      }
+      const content = result.content?.[0]?.text || "";
+      const count = (content.match(/^Path:/gm) || []).length;
+      let text = count > 0
+        ? theme.fg("success", `✓ ${count} results`)
+        : theme.fg("warning", content);
+      if (expanded && content) {
+        text += "\n" + theme.fg("muted", content);
+      }
+      return new Text(text, 0, 0);
+    },
+
     async execute(_toolCallId, params, signal) {
       try {
         const tokenResult = await pi.exec("gh", ["auth", "token"], { signal });
@@ -245,6 +266,27 @@ export default function (pi: ExtensionAPI) {
         description: "The question to search for.",
       }),
     }),
+    renderCall(args, theme) {
+      let text = theme.fg("toolTitle", theme.bold("stack_overflow_search "));
+      text += theme.fg("muted", `"${args.query}"`);
+      return new Text(text, 0, 0);
+    },
+
+    renderResult(result, { expanded }, theme) {
+      if (result.isError) {
+        return new Text(theme.fg("error", result.content?.[0]?.text || "Search failed"), 0, 0);
+      }
+      const content = result.content?.[0]?.text || "";
+      const count = (content.match(/^\[Score:/gm) || []).length;
+      let text = count > 0
+        ? theme.fg("success", `✓ ${count} results`)
+        : theme.fg("warning", content);
+      if (expanded && content) {
+        text += "\n" + theme.fg("muted", content);
+      }
+      return new Text(text, 0, 0);
+    },
+
     async execute(_toolCallId, params, signal) {
       try {
         const url = `https://api.stackexchange.com/2.3/search?order=desc&sort=relevance&site=stackoverflow&intitle=${encodeURIComponent(params.query)}`;