|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | | -import { formatToolDetail, resolveToolDisplay } from "./tool-display.js"; |
| 2 | +import { formatToolDetail, formatToolSummary, resolveToolDisplay } from "./tool-display.js"; |
3 | 3 |
|
4 | 4 | describe("tool display details", () => { |
5 | 5 | it("skips zero/false values for optional detail fields", () => { |
@@ -128,7 +128,7 @@ describe("tool display details", () => { |
128 | 128 | ); |
129 | 129 |
|
130 | 130 | expect(detail).toContain("check git status -> show first 3 lines"); |
131 | | - expect(detail).toContain(".openclaw/workspace)"); |
| 131 | + expect(detail).toContain("(agent)"); |
132 | 132 | }); |
133 | 133 |
|
134 | 134 | it("summarizes bash commands with the same command explainer", () => { |
@@ -166,6 +166,49 @@ describe("tool display details", () => { |
166 | 166 | expect(detail).toBe("install dependencies (in ~/my-project)"); |
167 | 167 | }); |
168 | 168 |
|
| 169 | + it("uses compact workspace markers for common workspace paths", () => { |
| 170 | + expect( |
| 171 | + formatToolDetail( |
| 172 | + resolveToolDisplay({ |
| 173 | + name: "bash", |
| 174 | + args: { command: "git fetch", workdir: "/Users/peter/mantis-workspace/openclaw" }, |
| 175 | + detailMode: "explain", |
| 176 | + }), |
| 177 | + ), |
| 178 | + ).toBe("fetch git changes (agent)"); |
| 179 | + |
| 180 | + expect( |
| 181 | + formatToolDetail( |
| 182 | + resolveToolDisplay({ |
| 183 | + name: "bash", |
| 184 | + args: { command: "git status", workdir: "/Users/peter/Projects/openclaw" }, |
| 185 | + detailMode: "explain", |
| 186 | + }), |
| 187 | + ), |
| 188 | + ).toBe("check git status (repo)"); |
| 189 | + }); |
| 190 | + |
| 191 | + it("omits bash and exec names from compact tool summaries", () => { |
| 192 | + expect( |
| 193 | + formatToolSummary( |
| 194 | + resolveToolDisplay({ |
| 195 | + name: "bash", |
| 196 | + args: { command: "git fetch", workdir: "/Users/peter/mantis-workspace/openclaw" }, |
| 197 | + detailMode: "explain", |
| 198 | + }), |
| 199 | + ), |
| 200 | + ).toBe("🛠️ fetch git changes (agent)"); |
| 201 | + |
| 202 | + expect( |
| 203 | + formatToolSummary( |
| 204 | + resolveToolDisplay({ |
| 205 | + name: "web_search", |
| 206 | + args: { query: "OpenClaw docs" }, |
| 207 | + }), |
| 208 | + ), |
| 209 | + ).toBe('🔎 Web Search: for "OpenClaw docs"'); |
| 210 | + }); |
| 211 | + |
169 | 212 | it("moves cd path to context suffix with multiple stages and raw command", () => { |
170 | 213 | const detail = formatToolDetail( |
171 | 214 | resolveToolDisplay({ |
|
0 commit comments