Opt-in. generateDiff / smartapply still see whatever map you hand them.
filterRelevant (JavaScript) and filter_relevant (Python) ask a cheap model,
once per file, “is this file relevant to the task?” — yes or no — and only the yeses go on.
An answer that is not a leading yes or no is kept, so a confused reply cannot drop a file the edit needs.
Defaults: model xiaomi/mimo-v2.6-flash, prompt version 3, 1024 output tokens, reasoning effort low.
The cache key includes the file path, so two files with the same text are judged separately.
Figures quoted elsewhere — Flask recall 1.0 and 0.8× overhead — are unverified. This page does not treat them as measured results.
generateDiff sees only the kept files.smartapply runs on that same map.
A bookstore Express API, a Python notebook CLI, and a React recipe box.
Each task has a hand-labeled list of relevant files in relevance/corpus.json.
The labels are the files a correct edit has to modify, or has to see. The filter does not get to read them.
Loading the sample projects…
Run the filter, then diff the kept files. Irrelevant files are not in the prompt.
import { filterRelevant, postChat } from "./relevance/filterRelevant.js";
import { buildEnvironment, generateDiff, smartapply } from "patchling";
const filtered = await filterRelevant(files, task, {
model: "xiaomi/mimo-v2.6-flash",
maxOutputTokens: 1024,
reasoningEffort: "none",
callLlm: (req) => postChat(req, { apiKey, baseUrl }),
});
const diff = await generateDiff(buildEnvironment(filtered.relevant), task, { apiKey });
const updated = await smartapply(diff, filtered.relevant, { apiKey });
node relevance/example.js --check validates the labels. Add --project shelf --task paginate-books to call the model, and --apply to continue into generateDiff and smartapply. --dry-run prints one prompt and does not call anything.
from patchling import build_environment, generate_diff, smartapply
from filter_relevant import filter_relevant, post_chat
filtered = filter_relevant(
files,
task,
call_llm=post_chat,
api_key=api_key,
base_url=base_url,
model="xiaomi/mimo-v2.6-flash",
max_output_tokens=1024,
reasoning_effort="none",
)
diff = generate_diff(build_environment(filtered["relevant"]), task, api_key=api_key)
updated = smartapply(diff, filtered["relevant"], api_key=api_key)
python relevance/example.py --check is the same check. --score run.json reports precision and recall against the hand labels. The decisions JSON is what --out writes.
A file is relevant when the change has to modify it, or would be wrong without the symbols it defines.
Sharing a topic is not enough — the health task does not include the books route, and the recipe detail task does not include the data file that already holds cookMinutes.
Shelf’s path-not-content task has two files with the same text at different paths, and only src/notes/note.js is relevant.
That is the positive class a benchmark should score. Every other file under the project root is a negative.