Merge pull request #4290 from SpencerJung/fix/issue-4170-cjk-agent-header
fix(cli): preserve CJK agent header text
This commit is contained in:
@@ -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("헤파")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -8,10 +8,12 @@ export function renderAgentHeader(
|
|||||||
): void {
|
): void {
|
||||||
if (!agent && !model) return
|
if (!agent && !model) return
|
||||||
|
|
||||||
|
const normalizedAgent = agent?.normalize("NFC") ?? null
|
||||||
|
const normalizedModel = model?.normalize("NFC") ?? null
|
||||||
const agentLabel = agent
|
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 variantSuffix = variant ? ` (${variant})` : ""
|
||||||
const modelLabel = model ? pc.dim(`${modelBase}${variantSuffix}`) : ""
|
const modelLabel = model ? pc.dim(`${modelBase}${variantSuffix}`) : ""
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ describe("getAgentDisplayName", () => {
|
|||||||
// then returns "multimodal-looker"
|
// then returns "multimodal-looker"
|
||||||
expect(result).toBe("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", () => {
|
describe("getAgentConfigKey", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user