Use grep over large files.

This commit is contained in:
Christian Gunderman
2026-02-11 15:38:26 -08:00
parent 6c1773170e
commit 19140f66d6
4 changed files with 86 additions and 3 deletions
+2
View File
@@ -167,6 +167,8 @@ export function renderCoreMandates(options?: CoreMandatesOptions): string {
## Context Efficiency:
- Always scope and limit your searches to avoid context window exhaustion and ensure high-signal results. Use include to target relevant files and strictly limit results using total_max_matches and max_matches_per_file, especially during the research phase.
- For broad discovery, use names_only=true or max_matches_per_file=1 to identify files without retrieving their context.
- Limit unnecessary context consumption from file reads by using ${GREP_TOOL_NAME} to search large files (> 1kb) or ${READ_FILE_TOOL_NAME} with the desired offset and limit.
- If the file is small, prefer reading the whole thing over "scrolling" through it by reading ranges repeatedly.
## Engineering Standards
- **Contextual Precedence:** Instructions found in ${formattedFilenames} files are foundational mandates. They take absolute precedence over the general workflows and tool defaults described in this system prompt.
+2 -2
View File
@@ -235,8 +235,8 @@ describe('LSTool', () => {
expect(entries[0]).toBe('[DIR] x-dir');
expect(entries[1]).toBe('[DIR] y-dir');
expect(entries[2]).toBe('a-file.txt');
expect(entries[3]).toBe('b-file.txt');
expect(entries[2]).toBe('a-file.txt (8 bytes)');
expect(entries[3]).toBe('b-file.txt (8 bytes)');
});
it('should handle permission errors gracefully', async () => {
+6 -1
View File
@@ -241,7 +241,12 @@ class LSToolInvocation extends BaseToolInvocation<LSToolParams, ToolResult> {
// Create formatted content for LLM
const directoryContent = entries
.map((entry) => `${entry.isDirectory ? '[DIR] ' : ''}${entry.name}`)
.map((entry) => {
if (entry.isDirectory) {
return `[DIR] ${entry.name}`;
}
return `${entry.name} (${entry.size} bytes)`;
})
.join('\n');
let resultMessage = `Directory listing for ${resolvedDirPath}:\n${directoryContent}`;