Limit documentation update prompts

This commit is contained in:
-Puter
2026-07-19 06:30:32 +05:30
parent ec84c52155
commit 87ddc2b73a

View File

@@ -14,6 +14,11 @@ const excludedPrefixes = [
"apps/native/web-build/", "apps/native/web-build/",
"packages/backend/convex/_generated/", "packages/backend/convex/_generated/",
]; ];
const maxPromptCharacters = 900_000;
const diffExclusions = excludedPrefixes.map(
(prefix) => `:(exclude,glob)${prefix}**`
);
const documentationNames = new Set([ const documentationNames = new Set([
"AGENTS.md", "AGENTS.md",
@@ -229,16 +234,7 @@ try {
const [changedFiles, documentationFiles, diffResult] = await Promise.all([ const [changedFiles, documentationFiles, diffResult] = await Promise.all([
listChangedFiles(range), listChangedFiles(range),
listDocumentationFiles(), listDocumentationFiles(),
run([ run(["git", "diff", "--find-renames", range, "--", ".", ...diffExclusions]),
"git",
"diff",
"--binary",
"--find-renames",
range,
"--",
".",
":(exclude)repos/**",
]),
]); ]);
if (diffResult.exitCode !== 0) { if (diffResult.exitCode !== 0) {
throw new Error( throw new Error(
@@ -253,10 +249,16 @@ try {
documentationFiles, documentationFiles,
diff: diffResult.stdout, 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(`Revision: ${range}`);
console.log(`Agent: ${agent}`); console.log(`Agent: ${agent}`);
console.log(`Changed first-party files: ${changedFiles.length}`); console.log(`Changed first-party files: ${changedFiles.length}`);
console.log(`Prompt characters: ${prompt.length}`);
console.log(`Command: ${formatCommand(command)} < generated-prompt`); console.log(`Command: ${formatCommand(command)} < generated-prompt`);
if (values["dry-run"]) { if (values["dry-run"]) {