refactor(auto-reply): remove stale tool meta helpers

This commit is contained in:
Vincent Koc
2026-06-19 09:11:23 +08:00
parent f19cae6d1d
commit ccc1ad4c74
2 changed files with 3 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
import path from "node:path";
import { describe, expect, it } from "vitest";
import { withEnv } from "../test-utils/env.js";
import { formatToolAggregate, formatToolPrefix, shortenMeta, shortenPath } from "./tool-meta.js";
import { formatToolAggregate, shortenMeta } from "./tool-meta.js";
// Use path.resolve so inputs match the resolved HOME on every platform.
const home = path.resolve("/Users/test");
@@ -12,14 +12,6 @@ function withHome<T>(run: () => T): T {
}
describe("tool meta formatting", () => {
it("shortens paths under HOME", () => {
withHome(() => {
expect(shortenPath(home)).toBe("~");
expect(shortenPath(`${home}/a/b.txt`)).toBe("~/a/b.txt");
expect(shortenPath("/opt/x")).toBe("/opt/x");
});
});
it("shortens meta strings with optional colon suffix", () => {
withHome(() => {
expect(shortenMeta(`${home}/a.txt`)).toBe("~/a.txt");
@@ -64,11 +56,4 @@ describe("tool meta formatting", () => {
expect(out).toBe("🛠️ elevated · `cd ~/dir && gemini 2>&1`");
});
});
it("formats prefixes with default labels", () => {
withHome(() => {
expect(formatToolPrefix(undefined, undefined)).toBe("🧩 Tool");
expect(formatToolPrefix("x", `${home}/a.txt`)).toBe("🧩 X: ~/a.txt");
});
});
});

View File

@@ -1,17 +1,12 @@
/** Formats compact tool metadata labels for auto-reply progress/status messages. */
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
import { formatToolSummary, resolveToolDisplay } from "../agents/tool-display.js";
import { shortenHomeInString, shortenHomePath } from "../utils.js";
import { resolveToolDisplay } from "../agents/tool-display.js";
import { shortenHomeInString } from "../utils.js";
type ToolAggregateOptions = {
markdown?: boolean;
};
/** Shortens a filesystem path for display. */
export function shortenPath(p: string): string {
return shortenHomePath(p);
}
/** Shortens user-home paths inside arbitrary tool metadata. */
export function shortenMeta(meta: string): string {
if (!meta) {
@@ -78,13 +73,6 @@ export function formatToolAggregate(
return compactCommandSummary ? `${prefix} ${formattedMeta}` : `${prefix}: ${formattedMeta}`;
}
/** Formats the prefix for a single tool event. */
export function formatToolPrefix(toolName?: string, meta?: string) {
const extra = meta?.trim() ? shortenMeta(meta) : undefined;
const display = resolveToolDisplay({ name: toolName, meta: extra });
return formatToolSummary(display);
}
function formatMetaForDisplay(
toolName: string | undefined,
meta: string,