Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { matchesSessionQuery } from '../src/search.js';
|
||||
|
||||
const session = {
|
||||
id: 'ABCDEF12-3456-7890-ABCD-EF1234567890',
|
||||
summary: 'Fix OAuth Callback',
|
||||
cwd: '/home/user/IdeaProjects/AgentManager',
|
||||
custom_name: 'Release API Review',
|
||||
};
|
||||
|
||||
test('session search ignores letter case in standard fields', () => {
|
||||
assert.equal(matchesSessionQuery(session, 'oauth'), true);
|
||||
assert.equal(matchesSessionQuery(session, 'OAUTH'), true);
|
||||
assert.equal(matchesSessionQuery(session, 'ideaprojects'), true);
|
||||
assert.equal(matchesSessionQuery(session, 'abcdef12'), true);
|
||||
});
|
||||
|
||||
test('session search ignores letter case in custom names when enabled', () => {
|
||||
assert.equal(matchesSessionQuery(session, 'release api', { includeCustomName: true }), true);
|
||||
assert.equal(matchesSessionQuery(session, 'RELEASE API', { includeCustomName: true }), true);
|
||||
assert.equal(matchesSessionQuery(session, 'release api'), false);
|
||||
});
|
||||
@@ -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