mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Session-Level Conversation History Management (#1113)
This commit is contained in:
@@ -205,9 +205,7 @@ describe('ExitPlanModeTool', () => {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
expect(invocation.getDescription()).toBe(
|
||||
'Present implementation plan for user approval',
|
||||
);
|
||||
expect(invocation.getDescription()).toBe('Plan:');
|
||||
});
|
||||
|
||||
it('should return empty tool locations', () => {
|
||||
|
||||
@@ -60,7 +60,7 @@ class ExitPlanModeToolInvocation extends BaseToolInvocation<
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return 'Present implementation plan for user approval';
|
||||
return 'Plan:';
|
||||
}
|
||||
|
||||
override async shouldConfirmExecute(
|
||||
|
||||
@@ -29,10 +29,6 @@ vi.mock(import('node:fs/promises'), async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('fs', () => ({
|
||||
mkdirSync: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('os');
|
||||
|
||||
const MEMORY_SECTION_HEADER = '## Qwen Added Memories';
|
||||
|
||||
@@ -144,30 +144,6 @@ describe('ReadFileTool', () => {
|
||||
).toBe(path.join('sub', 'dir', 'file.txt'));
|
||||
});
|
||||
|
||||
it('should return shortened path when file path is deep', () => {
|
||||
const deepPath = path.join(
|
||||
tempRootDir,
|
||||
'very',
|
||||
'deep',
|
||||
'directory',
|
||||
'structure',
|
||||
'that',
|
||||
'exceeds',
|
||||
'the',
|
||||
'normal',
|
||||
'limit',
|
||||
'file.txt',
|
||||
);
|
||||
const params: ReadFileToolParams = { absolute_path: deepPath };
|
||||
const invocation = tool.build(params);
|
||||
expect(typeof invocation).not.toBe('string');
|
||||
const desc = (
|
||||
invocation as ToolInvocation<ReadFileToolParams, ToolResult>
|
||||
).getDescription();
|
||||
expect(desc).toContain('...');
|
||||
expect(desc).toContain('file.txt');
|
||||
});
|
||||
|
||||
it('should handle non-normalized file paths correctly', () => {
|
||||
const subDir = path.join(tempRootDir, 'sub', 'dir');
|
||||
const params: ReadFileToolParams = {
|
||||
|
||||
@@ -57,7 +57,18 @@ class ReadFileToolInvocation extends BaseToolInvocation<
|
||||
this.params.absolute_path,
|
||||
this.config.getTargetDir(),
|
||||
);
|
||||
return shortenPath(relativePath);
|
||||
const shortPath = shortenPath(relativePath);
|
||||
|
||||
const { offset, limit } = this.params;
|
||||
if (offset !== undefined && limit !== undefined) {
|
||||
return `${shortPath} (lines ${offset + 1}-${offset + limit})`;
|
||||
} else if (offset !== undefined) {
|
||||
return `${shortPath} (from line ${offset + 1})`;
|
||||
} else if (limit !== undefined) {
|
||||
return `${shortPath} (first ${limit} lines)`;
|
||||
}
|
||||
|
||||
return shortPath;
|
||||
}
|
||||
|
||||
override toolLocations(): ToolLocation[] {
|
||||
|
||||
@@ -104,7 +104,6 @@ const baseConfigParams: ConfigParameters = {
|
||||
userMemory: '',
|
||||
geminiMdFileCount: 0,
|
||||
approvalMode: ApprovalMode.DEFAULT,
|
||||
sessionId: 'test-session-id',
|
||||
};
|
||||
|
||||
describe('ToolRegistry', () => {
|
||||
|
||||
Reference in New Issue
Block a user