Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
import { describe, expect, test } from "bun:test"
import { mergeToolEvent, renderToolEvent } from "./tool-renderers"
describe("tool renderers", () => {
test("shows rg search phases and argument boundaries", () => {
const start = { name: "rg", phase: "start", arguments: { args: ["-n", "hello world", "src"] } }
expect(renderToolEvent(start)).toBe(' › Searching files -n "hello world" src')
expect(renderToolEvent(mergeToolEvent(start, { name: "rg", phase: "end", result: "src/a:1:hello world" })))
.toBe(' ✓ Searched files -n "hello world" src')
expect(renderToolEvent({ name: "rg", phase: "error", error: "invalid regex" }))
.toBe(" × Search failed invalid regex")
})
test("shows rg regex characters and empty arguments", () => {
expect(renderToolEvent({ name: "rg", phase: "end", arguments: { args: [String.raw`resolve\(`, ""] } }))
.toBe(' ✓ Searched files resolve\\( ""')
})
test("retains start arguments when an end frame only carries output", () => {
const event = mergeToolEvent(
{ call_id: "exec-1", phase: "start", name: "exec", arguments: { cmd: "git status" } },
{ call_id: "exec-1", phase: "end", name: "exec", result: { output: "clean" } },
)
expect(renderToolEvent(event)).toBe(" ✓ Ran git status")
})
test("uses stable task language for common file and web tools", () => {
expect(renderToolEvent({ phase: "end", name: "read_file", arguments: { path: "README.md" } }))
.toBe(" ✓ Read README.md")
expect(renderToolEvent({ phase: "start", name: "web_search", arguments: { query: "nanobot" } }))
.toBe(" › Search web nanobot")
expect(renderToolEvent({ phase: "error", name: "web_fetch", error: "timeout" }))
.toBe(" × Fetch timeout")
})
test("compresses verification and edits into outcome language", () => {
expect(renderToolEvent({ phase: "end", name: "exec", arguments: { cmd: "bun test" } }))
.toBe(" ✓ Testing bun test")
expect(renderToolEvent({ phase: "end", name: "apply_patch", arguments: { path: "app.ts" } }))
.toBe(" ✓ Edited app.ts")
})
test("shortens file paths relative to the workspace while preserving the useful tail", () => {
const workspace = String.raw`C:\workspace\nanobot`
expect(renderToolEvent({
phase: "end",
name: "read_file",
arguments: { path: String.raw`C:\workspace\nanobot\tui\src\app.ts` },
}, { workspace })).toBe(" ✓ Read tui/src/app.ts")
expect(renderToolEvent({
phase: "end",
name: "read_file",
arguments: {
path: String.raw`C:\workspace\nanobot\.worktrees\feature\nanobot\providers\fallback_provider.py`,
},
}, { workspace })).toBe(" ✓ Read …/feature/nanobot/providers/fallback_provider.py")
})
test("summarizes subagent delegation without exposing raw argument JSON", () => {
expect(renderToolEvent({
phase: "end",
name: "spawn",
arguments: { task: "Simplify the fallback provider implementation" },
})).toBe(" ✓ Delegated Simplify the fallback provider implementation")
})
})