feat(core): overhaul system prompt for rigor, integrity, and intent alignment (#17263)

This commit is contained in:
N. Taylor Mullen
2026-02-06 19:13:07 -08:00
committed by GitHub
parent 19dc40825e
commit 9178b31629
10 changed files with 1256 additions and 426 deletions
@@ -49,11 +49,10 @@ describe('getDirectoryContextString', () => {
it('should return context string for a single directory', async () => {
const contextString = await getDirectoryContextString(mockConfig as Config);
expect(contextString).toContain('- **Workspace Directories:**');
expect(contextString).toContain(' - /test/dir');
expect(contextString).toContain(
"I'm currently working in the directory: /test/dir",
);
expect(contextString).toContain(
'Here is the folder structure of the current working directories:\n\nMock Folder Structure',
'- **Directory Structure:**\n\nMock Folder Structure',
);
});
@@ -66,11 +65,11 @@ describe('getDirectoryContextString', () => {
.mockResolvedValueOnce('Structure 2');
const contextString = await getDirectoryContextString(mockConfig as Config);
expect(contextString).toContain('- **Workspace Directories:**');
expect(contextString).toContain(' - /test/dir1');
expect(contextString).toContain(' - /test/dir2');
expect(contextString).toContain(
"I'm currently working in the following directories:\n - /test/dir1\n - /test/dir2",
);
expect(contextString).toContain(
'Here is the folder structure of the current working directories:\n\nStructure 1\nStructure 2',
'- **Directory Structure:**\n\nStructure 1\nStructure 2',
);
});
});
@@ -80,9 +79,6 @@ describe('getEnvironmentContext', () => {
let mockToolRegistry: { getTool: Mock };
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2025-08-05T12:00:00Z'));
mockToolRegistry = {
getTool: vi.fn(),
};
@@ -104,7 +100,6 @@ describe('getEnvironmentContext', () => {
});
afterEach(() => {
vi.useRealTimers();
vi.resetAllMocks();
});
@@ -114,16 +109,14 @@ describe('getEnvironmentContext', () => {
expect(parts.length).toBe(1);
const context = parts[0].text;
expect(context).toContain("Today's date is");
expect(context).toContain("(formatted according to the user's locale)");
expect(context).toContain(`My operating system is: ${process.platform}`);
expect(context).toContain('<session_context>');
expect(context).toContain('- **Workspace Directories:**');
expect(context).toContain(' - /test/dir');
expect(context).toContain(
"I'm currently working in the directory: /test/dir",
);
expect(context).toContain(
'Here is the folder structure of the current working directories:\n\nMock Folder Structure',
'- **Directory Structure:**\n\nMock Folder Structure',
);
expect(context).toContain('Mock Environment Memory');
expect(context).toContain('</session_context>');
expect(getFolderStructure).toHaveBeenCalledWith('/test/dir', {
fileService: undefined,
});
@@ -142,12 +135,14 @@ describe('getEnvironmentContext', () => {
expect(parts.length).toBe(1);
const context = parts[0].text;
expect(context).toContain('<session_context>');
expect(context).toContain('- **Workspace Directories:**');
expect(context).toContain(' - /test/dir1');
expect(context).toContain(' - /test/dir2');
expect(context).toContain(
"I'm currently working in the following directories:\n - /test/dir1\n - /test/dir2",
);
expect(context).toContain(
'Here is the folder structure of the current working directories:\n\nStructure 1\nStructure 2',
'- **Directory Structure:**\n\nStructure 1\nStructure 2',
);
expect(context).toContain('</session_context>');
expect(getFolderStructure).toHaveBeenCalledTimes(2);
});