Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { buildContext, normalizeTitleText } from '../src/title-generator.js';
|
||||
|
||||
test('removes injected instructions before preserving the real user request', () => {
|
||||
const text = '<agents-instructions>project rules</agents-instructions>\n请修复登录接口超时问题';
|
||||
assert.equal(normalizeTitleText(text), '请修复登录接口超时问题');
|
||||
});
|
||||
|
||||
test('ignores internal messages and keeps only the first ten rounds', () => {
|
||||
const messages = [
|
||||
{ type: 'user_message_internal', message: '# AGENTS.md instructions for /tmp/project' },
|
||||
];
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
messages.push({ type: 'user_message', message: `这是第${i}轮用户提出的有效任务` });
|
||||
messages.push({ type: 'assistant_message', message: `这是第${i}轮助手给出的处理回复` });
|
||||
}
|
||||
|
||||
const context = buildContext(messages);
|
||||
assert.equal(context.length, 20);
|
||||
assert.match(context[0], /第1轮/);
|
||||
assert.match(context.at(-1), /第10轮/);
|
||||
assert.equal(context.some(line => line.includes('第11轮')), false);
|
||||
});
|
||||
|
||||
test('does not use assistant output when no real user message exists', () => {
|
||||
const context = buildContext([
|
||||
{ type: 'user_message_internal', message: '<agents-instructions>rules</agents-instructions>' },
|
||||
{ type: 'assistant_message', message: '完成提交并修复构建问题' },
|
||||
]);
|
||||
assert.deepEqual(context, []);
|
||||
});
|
||||
Reference in New Issue
Block a user