|
4 | 4 | */ |
5 | 5 | import { describe, expect, it } from "vitest"; |
6 | 6 | import { resolveToolSearchCodeDisplayTarget } from "./tool-display-common.js"; |
7 | | -import { resolveExecDetail } from "./tool-display-exec.js"; |
| 7 | +import { resolveExecDetail, stripLeadingExecDisplayVerb } from "./tool-display-exec.js"; |
8 | 8 | import { formatToolDetail, formatToolSummary, resolveToolDisplay } from "./tool-display.js"; |
9 | 9 |
|
10 | 10 | describe("tool display details", () => { |
@@ -586,6 +586,34 @@ describe("compactRawCommand middle truncation", () => { |
586 | 586 | }); |
587 | 587 | }); |
588 | 588 |
|
| 589 | +describe("stripLeadingExecDisplayVerb", () => { |
| 590 | + it("strips a known exec display verb so it stays outside backtick-wrapped command text", () => { |
| 591 | + expect(stripLeadingExecDisplayVerb("run python3 /path/to/script.py")).toBe( |
| 592 | + "python3 /path/to/script.py", |
| 593 | + ); |
| 594 | + expect(stripLeadingExecDisplayVerb("check git status")).toBe("git status"); |
| 595 | + expect(stripLeadingExecDisplayVerb("show some-file.txt (workspace)")).toBe( |
| 596 | + "some-file.txt (workspace)", |
| 597 | + ); |
| 598 | + expect(stripLeadingExecDisplayVerb('find files named "x" in /path')).toBe( |
| 599 | + 'files named "x" in /path', |
| 600 | + ); |
| 601 | + }); |
| 602 | + |
| 603 | + it("returns the meta unchanged when the first token is not a known exec display verb", () => { |
| 604 | + // `cd` is a real shell builtin, not a summary verb, so a raw `cd ~/dir && ls` meta survives. |
| 605 | + expect(stripLeadingExecDisplayVerb("cd ~/dir && ls")).toBe("cd ~/dir && ls"); |
| 606 | + expect(stripLeadingExecDisplayVerb("git status")).toBe("git status"); |
| 607 | + expect(stripLeadingExecDisplayVerb("npm install")).toBe("npm install"); |
| 608 | + }); |
| 609 | + |
| 610 | + it("returns the meta unchanged for single-token or empty input", () => { |
| 611 | + expect(stripLeadingExecDisplayVerb("run")).toBe("run"); |
| 612 | + expect(stripLeadingExecDisplayVerb("")).toBe(""); |
| 613 | + expect(stripLeadingExecDisplayVerb(" ")).toBe(" "); |
| 614 | + }); |
| 615 | +}); |
| 616 | + |
589 | 617 | describe("coerceDisplayValue middle truncation", () => { |
590 | 618 | it("preserves start and end of long string values", () => { |
591 | 619 | const longPath = |
|
0 commit comments