import test from 'node:test'; import assert from 'node:assert/strict'; import { resolveExecutorDisplayLabel, sanitizeUserFacingBrandText } from './executor-display-label.mjs'; import { buildCodeRunCompletionReply } from './agent-run-gateway.mjs'; test('resolveExecutorDisplayLabel maps cursor id to TKMind 智趣', () => { assert.equal(resolveExecutorDisplayLabel('cursor'), 'TKMind 智趣'); assert.equal(resolveExecutorDisplayLabel('cursor', 'Cursor'), 'TKMind 智趣'); assert.equal(resolveExecutorDisplayLabel('aider'), 'Aider'); }); test('buildCodeRunCompletionReply never exposes cursor brand to users', () => { const reply = buildCodeRunCompletionReply({ executor: 'cursor', stdout: '' }); assert.match(reply, /已由 TKMind 智趣 完成执行,并通过平台文件验收。/); assert.doesNotMatch(reply, /cursor/i); }); test('buildCodeRunCompletionReply prefers displayStdout over raw stream-json stdout', () => { const reply = buildCodeRunCompletionReply({ executor: 'cursor', stdout: '{"type":"result","result":"hidden"}\n', displayStdout: '已写入 public/spring-poem.html', }); assert.match(reply, /已写入 public\/spring-poem\.html/); assert.doesNotMatch(reply, /"type":"result"/); }); test('sanitizeUserFacingBrandText replaces cursor wording', () => { assert.equal( sanitizeUserFacingBrandText('已由 cursor 完成执行,并通过平台文件验收。'), '已由 TKMind 智趣 完成执行,并通过平台文件验收。', ); assert.equal( sanitizeUserFacingBrandText('cursor agent finished editing public/page.html'), 'TKMind 智趣 finished editing public/page.html', ); });