A diff is ordered by file path, which is almost never the order in which a change makes sense. This adds a Walkthrough surface that reorders it: the model groups related hunks into stops, explains what each group changes about behavior, and orders the stops so each builds on the last. It explains and orders; judging code stays with the existing Review action. Reviews uncommitted work (all, staged, unstaged), a branch against its base, or a pull request. Generation is always user-initiated — nothing runs on a timer, on a file change, or as a side effect of opening a panel. Invariants worth preserving: - Hunk identity is derived on the server and only there. Ids are content hashes, so an anchor that no longer resolves is proof the code it described changed, and staleness needs no heuristics. The client matches ids to ids and never recomputes them; two implementations would have to agree forever. - The digest is never truncated. A diff that does not fit the model's context is refused with an actionable reason, because a walkthrough written against half a diff reads as confident and is wrong. - Nothing disappears. Lockfiles and other generated output are excluded from the model's input by name — never by size — and everything no stop covers is listed at the end, so "have I seen all of it" stays answerable. - Cost is explicit. Results are content-addressed, so returning the working tree to an earlier state costs nothing; generation outlives its request, so a refresh detaches the client rather than discarding paid-for work, and only an explicit cancel stops it. Supporting changes to shared modules: - git: expose the existing getRangeDiff as GET /api/git listUntrackedPaths and getUntrackedDiffs. The latter resolve the repository once for a batch instead of per file, taking a panel ~340ms on an 80-file working tree. - small-model: structured output across four wire forma and abort signal, and an onOverflow policy so an oversized prompt fails loudly instead of being silently clipped. A provider remembered so the prompt-side fallback goes first next time. - models.dev metadata: surface structured_output as tri false blocks a model, a missing field does not, because the catalog omits it for roughly half of all models. Desktop and tablet only: VS Code serves Git through its these routes, and the mobile shell does not consume the surface registry. Docs: packages/docs walkthrough page in English and all eight locales.
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
// Files that are produced by a tool rather than written by a person. Their
|
|
// diffs are enormous, carry no intent, and are exactly the kind of content a
|
|
// reviewer scrolls past — but they are still part of the change, so they are
|
|
// never hidden: they are kept out of the model's input and shown in the
|
|
// uncovered tail instead.
|
|
|
|
const LOCKFILES = new Set([
|
|
'bun.lock',
|
|
'bun.lockb',
|
|
'package-lock.json',
|
|
'npm-shrinkwrap.json',
|
|
'yarn.lock',
|
|
'pnpm-lock.yaml',
|
|
'composer.lock',
|
|
'Gemfile.lock',
|
|
'Pipfile.lock',
|
|
'poetry.lock',
|
|
'uv.lock',
|
|
'Cargo.lock',
|
|
'go.sum',
|
|
'mix.lock',
|
|
'pubspec.lock',
|
|
'flake.lock',
|
|
'gradle.lockfile',
|
|
'packages.lock.json',
|
|
'deno.lock',
|
|
]);
|
|
|
|
const GENERATED_PATTERNS = [
|
|
// Minified or bundled output committed to the repository.
|
|
/\.min\.(js|css)$/i,
|
|
/\.(js|css)\.map$/i,
|
|
// Conventional "this file is generated" naming.
|
|
/\.generated\.[^/]+$/i,
|
|
/\.gen\.[^/]+$/i,
|
|
/(^|\/)generated\//i,
|
|
// Protocol buffers and similar codegen.
|
|
/\.pb\.(go|ts|js)$/i,
|
|
/_pb2(_grpc)?\.py$/i,
|
|
/\.pb\.cc$|\.pb\.h$/i,
|
|
// Test snapshots.
|
|
/(^|\/)__snapshots__\//,
|
|
/\.snap$/,
|
|
];
|
|
|
|
/**
|
|
* Whether a path is a tool-produced artifact rather than authored source.
|
|
*
|
|
* Deliberately conservative: a false positive silently removes real code from
|
|
* the review, which is the failure this whole feature exists to prevent. Only
|
|
* unambiguous, conventional names qualify.
|
|
*/
|
|
export function isGeneratedArtifact(filePath) {
|
|
if (typeof filePath !== 'string' || !filePath) return false;
|
|
const name = filePath.split('/').pop() || '';
|
|
if (LOCKFILES.has(name)) return true;
|
|
return GENERATED_PATTERNS.some((pattern) => pattern.test(filePath));
|
|
}
|