Files
memind/executor-display-label.test.mjs
T
john f95d766f69
Memind CI / Test, build, and release guards (push) Failing after 14m36s
feat(billing): bill Cursor executor usage via stream-json token parsing
Parse Cursor CLI usage from stream-json output and charge through billSessionUsage so subscription quota is consumed first and wallet overage applies when needed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-27 10:16:38 +08:00

38 lines
1.6 KiB
JavaScript

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',
);
});