Limit documentation update prompts
This commit is contained in:
@@ -14,6 +14,11 @@ const excludedPrefixes = [
|
||||
"apps/native/web-build/",
|
||||
"packages/backend/convex/_generated/",
|
||||
];
|
||||
const maxPromptCharacters = 900_000;
|
||||
|
||||
const diffExclusions = excludedPrefixes.map(
|
||||
(prefix) => `:(exclude,glob)${prefix}**`
|
||||
);
|
||||
|
||||
const documentationNames = new Set([
|
||||
"AGENTS.md",
|
||||
@@ -229,16 +234,7 @@ try {
|
||||
const [changedFiles, documentationFiles, diffResult] = await Promise.all([
|
||||
listChangedFiles(range),
|
||||
listDocumentationFiles(),
|
||||
run([
|
||||
"git",
|
||||
"diff",
|
||||
"--binary",
|
||||
"--find-renames",
|
||||
range,
|
||||
"--",
|
||||
".",
|
||||
":(exclude)repos/**",
|
||||
]),
|
||||
run(["git", "diff", "--find-renames", range, "--", ".", ...diffExclusions]),
|
||||
]);
|
||||
if (diffResult.exitCode !== 0) {
|
||||
throw new Error(
|
||||
@@ -253,10 +249,16 @@ try {
|
||||
documentationFiles,
|
||||
diff: diffResult.stdout,
|
||||
});
|
||||
if (prompt.length > maxPromptCharacters) {
|
||||
throw new Error(
|
||||
`Generated documentation prompt is ${prompt.length} characters, exceeding the ${maxPromptCharacters} character safety limit. Use a smaller revision range.`
|
||||
);
|
||||
}
|
||||
|
||||
console.log(`Revision: ${range}`);
|
||||
console.log(`Agent: ${agent}`);
|
||||
console.log(`Changed first-party files: ${changedFiles.length}`);
|
||||
console.log(`Prompt characters: ${prompt.length}`);
|
||||
console.log(`Command: ${formatCommand(command)} < generated-prompt`);
|
||||
|
||||
if (values["dry-run"]) {
|
||||
|
||||
Reference in New Issue
Block a user