Repository navigation
Expand file tree
/
Copy pathfix-vuln.config.ts
More file actions
47 lines (43 loc) · 1.88 KB
/
Copy pathfix-vuln.config.ts
File metadata and controls
47 lines (43 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Bug-fixing prompt module for scripts/study-crates.ts, with extra emphasis on
* the patch engine and crawlers.
*
* Pass it with:
* npx tsx scripts/study-crates.ts --prompt-file scripts/fix-vuln.config.ts
*
* The module's default export is a function `(ctx: FileCtx) => string` that
* returns the prompt for one file. This gives you full programmatic control:
* branch on the crate, the path, the file name, inject extra instructions for
* specific subsystems, etc.
*
* FileCtx fields available:
* file repo-relative POSIX path, e.g. "crates/socket-patch-core/src/lib.rs"
* abspath absolute path on disk
* crate crate dir name, e.g. "socket-patch-core"
* name basename, e.g. "lib.rs"
* stem basename without extension, e.g. "lib"
* relInCrate path within the crate's src dir, e.g. "api/client.rs"
*/
import type { FileCtx } from "./study-crates.ts";
export default function render(ctx: FileCtx): string {
const base = [
`There are bugs in ${ctx.file} in the ${ctx.crate} crate.`,
`Carefully read the code line by line and fix all of the bugs. Add additional tests to prevent regressions.`,
`If you can't find any problems, it's ok to quit.`
];
// Example of path-specific emphasis: be extra careful around the patch engine
// and crawlers, which carry the most invariants.
if (ctx.relInCrate.startsWith("patch/")) {
base.push(
`This file is part of the patch engine — pay special attention to`,
`filesystem safety, atomicity, and rollback correctness.`,
);
} else if (ctx.relInCrate.startsWith("crawlers/")) {
base.push(
`This is a package-manager crawler — note the on-disk layout assumptions`,
`it makes and how it handles missing or malformed package metadata.`,
);
}
base.push(`End with a concise 3-6 bullet summary of the most important takeaways.`);
return base.join(" ");
}