Remove directory structure from system prompt
Remove the getDirectoryStructure() function and its embedding in the system prompt. This was walking up to 500 files and embedding them as a static tree in every API request, adding ~3,500-5,000 tokens per call. The LLM already has tools (listFiles, Glob, Grep) to discover files on demand, making the embedded tree redundant. Claude Code does not include directory structure in its system prompt for the same reason. This also improves prompt cache hit rates since the system prompt no longer varies by project directory contents. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
parent
c28ffbf225
commit
d7aa797a94
2 changed files with 0 additions and 42 deletions
|
|
@ -46,7 +46,6 @@ describe("constructSystemMessage", () => {
|
|||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).toContain("<env>");
|
||||
expect(result).toContain('<context name="directoryStructure">');
|
||||
expect(result).toContain('<context name="gitStatus">');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,10 @@ import { execSync } from "child_process";
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import pkg from "ignore-walk";
|
||||
import { Minimatch } from "minimatch";
|
||||
|
||||
import { processRule } from "./hubLoader.js";
|
||||
import { PermissionMode } from "./permissions/types.js";
|
||||
import { serviceContainer } from "./services/ServiceContainer.js";
|
||||
import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js";
|
||||
const { WalkerSync } = pkg;
|
||||
|
||||
/**
|
||||
* Check if current directory is a git repository
|
||||
|
|
@ -23,39 +19,6 @@ function isGitRepo(): boolean {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get basic directory structure
|
||||
*/
|
||||
function getDirectoryStructure(): string {
|
||||
try {
|
||||
const walker = new WalkerSync({
|
||||
path: process.cwd(),
|
||||
includeEmpty: false,
|
||||
follow: false,
|
||||
ignoreFiles: [".gitignore", ".continueignore", ".customignore"],
|
||||
});
|
||||
|
||||
(walker.ignoreRules as any)[".customignore"] = [
|
||||
new Minimatch(".git/*", {
|
||||
matchBase: true,
|
||||
dot: true,
|
||||
flipNegate: true,
|
||||
nocase: true,
|
||||
}),
|
||||
];
|
||||
|
||||
const files = walker.start().result as string[];
|
||||
|
||||
const filteredFiles = files
|
||||
.slice(0, 500)
|
||||
.map((file: string) => `./${file}`);
|
||||
|
||||
return filteredFiles.join("\n") || "No structure available";
|
||||
} catch {
|
||||
return "Directory structure not available";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get git status
|
||||
*/
|
||||
|
|
@ -89,10 +52,6 @@ Today's date: ${new Date().toISOString().split("T")[0]}
|
|||
|
||||
As you answer the user's questions, you can use the following context:
|
||||
|
||||
<context name="directoryStructure">Below is a snapshot of this project's file structure at the start of the conversation. This snapshot will NOT update during the conversation. It skips over .gitignore patterns.
|
||||
|
||||
${getDirectoryStructure()}
|
||||
</context>
|
||||
<context name="gitStatus">This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation.
|
||||
|
||||
${getGitStatus()}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue