fix(cli): preserve CJK agent header text

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
SpencerJung
2026-05-22 16:39:36 +09:00
parent cb205e1479
commit ed4c04e575
3 changed files with 54 additions and 2 deletions
+44
View File
@@ -0,0 +1,44 @@
import { afterEach, describe, expect, it } from "bun:test"
import { renderAgentHeader } from "./output-renderer"
const originalWrite = process.stdout.write.bind(process.stdout)
function captureStdout(run: () => void): string {
const chunks: string[] = []
process.stdout.write = ((chunk: string | Uint8Array) => {
chunks.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8"))
return true
}) as typeof process.stdout.write
try {
run()
} finally {
process.stdout.write = originalWrite as typeof process.stdout.write
}
return chunks.join("")
}
afterEach(() => {
process.stdout.write = originalWrite as typeof process.stdout.write
})
describe("renderAgentHeader", () => {
it("preserves CJK agent display names in stdout output", () => {
const output = captureStdout(() => {
renderAgentHeader("Sisyphus - 主脑", "zhipu/glm-5.1", "xhigh", {})
})
expect(output).toContain("Sisyphus - 主脑")
expect(output).toContain("zhipu/glm-5.1")
})
it("normalizes decomposed Unicode before rendering", () => {
const output = captureStdout(() => {
renderAgentHeader("헤파", null, null, {})
})
expect(output).toContain("헤파")
})
})
+4 -2
View File
@@ -8,10 +8,12 @@ export function renderAgentHeader(
): void {
if (!agent && !model) return
const normalizedAgent = agent?.normalize("NFC") ?? null
const normalizedModel = model?.normalize("NFC") ?? null
const agentLabel = agent
? pc.bold(colorizeWithProfileColor(agent, agentColorsByName[agent]))
? pc.bold(colorizeWithProfileColor(normalizedAgent ?? agent, agentColorsByName[agent]))
: ""
const modelBase = model ?? ""
const modelBase = normalizedModel ?? ""
const variantSuffix = variant ? ` (${variant})` : ""
const modelLabel = model ? pc.dim(`${modelBase}${variantSuffix}`) : ""
+6
View File
@@ -133,6 +133,12 @@ describe("getAgentDisplayName", () => {
// then returns "multimodal-looker"
expect(result).toBe("multimodal-looker")
})
it("preserves CJK display-name overrides verbatim", () => {
expect(getAgentDisplayName("sisyphus", { sisyphus: { displayName: "Sisyphus - 主脑" } })).toBe("Sisyphus - 主脑")
expect(getAgentDisplayName("hephaestus", { hephaestus: { displayName: "헤파이스토스" } })).toBe("헤파이스토스")
expect(getAgentDisplayName("atlas", { atlas: { displayName: "アトラス" } })).toBe("アトラス")
})
})
describe("getAgentConfigKey", () => {