@tobi-or-not/quorum 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/bench/fingerprint.d.ts +6 -5
- package/dist/bench/fingerprint.js +11 -5
- package/dist/bench/records.d.ts +100 -2
- package/dist/bench/records.js +80 -5
- package/dist/bench/runner.js +1 -1
- package/dist/cli/io.d.ts +5 -0
- package/dist/cli/main.d.ts +36 -13
- package/dist/cli/main.js +194 -44
- package/dist/cli/print-config.d.ts +5 -5
- package/dist/cli/print-config.js +10 -5
- package/dist/cli/render.d.ts +7 -1
- package/dist/cli/render.js +25 -3
- package/dist/config/claude-code.d.ts +2 -6
- package/dist/config/claude-code.js +6 -44
- package/dist/config/command.d.ts +10 -0
- package/dist/config/command.js +47 -0
- package/dist/config/from-config.js +8 -2
- package/dist/config/resolve.d.ts +4 -0
- package/dist/config/resolve.js +10 -0
- package/dist/config/schema.d.ts +13 -2
- package/dist/config/schema.js +36 -5
- package/dist/core/coverage.d.ts +38 -13
- package/dist/core/coverage.js +105 -28
- package/dist/core/diff.d.ts +77 -0
- package/dist/core/diff.js +122 -24
- package/dist/core/estimate.d.ts +45 -0
- package/dist/core/estimate.js +188 -0
- package/dist/core/flags.d.ts +14 -1
- package/dist/core/flags.js +56 -0
- package/dist/core/inputs.d.ts +38 -0
- package/dist/core/inputs.js +228 -0
- package/dist/core/limits.d.ts +5 -4
- package/dist/core/limits.js +11 -5
- package/dist/core/parts.d.ts +146 -0
- package/dist/core/parts.js +388 -0
- package/dist/core/ports.d.ts +10 -0
- package/dist/core/prompts.d.ts +22 -3
- package/dist/core/prompts.js +43 -7
- package/dist/core/quorum.d.ts +7 -5
- package/dist/core/quorum.js +164 -58
- package/dist/core/secrets.d.ts +98 -0
- package/dist/core/secrets.js +507 -0
- package/dist/core/stages/context.d.ts +16 -3
- package/dist/core/stages/context.js +44 -17
- package/dist/core/stages/panel.d.ts +8 -2
- package/dist/core/stages/panel.js +50 -9
- package/dist/core/stages/research.d.ts +107 -31
- package/dist/core/stages/research.js +290 -53
- package/dist/core/types.d.ts +217 -29
- package/dist/core/verify.d.ts +6 -0
- package/dist/core/verify.js +6 -3
- package/dist/git/run.d.ts +223 -0
- package/dist/git/run.js +608 -0
- package/dist/git/tree.d.ts +43 -0
- package/dist/git/tree.js +171 -0
- package/dist/index.d.ts +26 -2
- package/dist/index.js +34 -2
- package/dist/providers/anthropic.d.ts +2 -1
- package/dist/providers/anthropic.js +4 -2
- package/dist/providers/claude-code.d.ts +5 -0
- package/dist/providers/claude-code.js +11 -1
- package/dist/providers/gemini.d.ts +2 -1
- package/dist/providers/gemini.js +4 -2
- package/dist/providers/ollama.d.ts +2 -1
- package/dist/providers/ollama.js +4 -2
- package/dist/providers/openai-compatible.d.ts +2 -1
- package/dist/providers/openai-compatible.js +4 -2
- package/dist/providers/size.d.ts +9 -1
- package/dist/providers/size.js +18 -4
- package/dist/sources/added.d.ts +49 -0
- package/dist/sources/added.js +134 -0
- package/dist/sources/diff.d.ts +13 -0
- package/dist/sources/diff.js +63 -0
- package/dist/sources/local.d.ts +41 -0
- package/dist/sources/local.js +251 -0
- package/dist/sources/paths.d.ts +45 -0
- package/dist/sources/paths.js +230 -0
- package/dist/sources/range.d.ts +21 -0
- package/dist/sources/range.js +75 -0
- package/dist/sources/read.d.ts +69 -0
- package/dist/sources/read.js +37 -0
- package/dist/sources/repository.d.ts +9 -0
- package/dist/sources/repository.js +28 -0
- package/dist/sources/skips.d.ts +49 -0
- package/dist/sources/skips.js +126 -0
- package/package.json +1 -1
- package/schema/quorum.schema.json +15 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { MAX_DIFF_BYTES } from "../core/diff.js";
|
|
3
|
+
import { ConfigError } from "../core/errors.js";
|
|
4
|
+
import { excludeMatcher } from "../core/exclude.js";
|
|
5
|
+
import { credentialIn, isSecretName } from "../core/secrets.js";
|
|
6
|
+
import { utf8Length } from "../core/tokens.js";
|
|
7
|
+
import { listTree, readBlobs } from "../git/tree.js";
|
|
8
|
+
import { addedDiff, blobText, isBinary, pathName } from "./added.js";
|
|
9
|
+
import { openSourceRepository } from "./repository.js";
|
|
10
|
+
import { isLfsPointer, isMinifiedContent, nameRule } from "./skips.js";
|
|
11
|
+
const FLAG = '--path';
|
|
12
|
+
const EMPTY_PATH = 'must name a path';
|
|
13
|
+
const ABSOLUTE_PATH = 'must be relative to the working directory';
|
|
14
|
+
const NEEDS_COMMIT = 'needs a commit, and HEAD names none: commit first, or name one with --at';
|
|
15
|
+
const NAMES_OVER = 'the selected files\' names are over 16 MiB: name a narrower path';
|
|
16
|
+
const DIFF_OVER = 'its diff is over 16 MiB, the most quorum reads: name a narrower path';
|
|
17
|
+
const leavesTop = (place) => `path ${place} leaves the repository's top level`;
|
|
18
|
+
const namesNothing = (place) => `path ${place} names no file tracked at the commit`;
|
|
19
|
+
const tooMany = (bytes) => `the selected files hold ${bytes} bytes, over the 16 MiB (${MAX_DIFF_BYTES} bytes) a review reads: name a narrower path`;
|
|
20
|
+
function allLeftOut(skipped, excluded, skips) {
|
|
21
|
+
return `every selected file is left out (${skipped} skipped, ${excluded} excluded): ${skips
|
|
22
|
+
? 'pass --no-default-skips to review the skipped ones, narrow exclude, or pass --send to send one held as a secret'
|
|
23
|
+
: 'narrow exclude, pass --send to send one held as a secret, or name a path that holds files other than gitlinks, Git LFS pointers and secrets'}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The problem with a `--path` value that can be told from the text alone, worded to follow `--path: `: it
|
|
27
|
+
* names no path when empty, and is absolute. The CLI refuses a value so before any config and any git, and
|
|
28
|
+
* `pathsSource` for a library caller. A problem never repeats the value.
|
|
29
|
+
*/
|
|
30
|
+
export function pathProblem(value) {
|
|
31
|
+
if (value === '')
|
|
32
|
+
return EMPTY_PATH;
|
|
33
|
+
return posix.isAbsolute(value)
|
|
34
|
+
? ABSOLUTE_PATH
|
|
35
|
+
: undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The problem with an `--at` value that can be told from the text alone, worded to follow `--at: `: a
|
|
39
|
+
* revision that starts with `-` is an option to git, so it is refused before any git runs. The CLI refuses
|
|
40
|
+
* it before any config, and `pathsSource` before it opens the repository, for a library caller. A problem
|
|
41
|
+
* never repeats the value.
|
|
42
|
+
*/
|
|
43
|
+
export function atProblem(value) {
|
|
44
|
+
return value?.startsWith('-')
|
|
45
|
+
? 'a revision may not start with -'
|
|
46
|
+
: undefined;
|
|
47
|
+
}
|
|
48
|
+
function refusal(flag, message) {
|
|
49
|
+
return new ConfigError([
|
|
50
|
+
{ path: flag, message },
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The selections the `--path` values name, each once, in order. A value is taken from the working directory,
|
|
55
|
+
* so `prefix`, its place under the top level, goes before it, and the result is normalized as a path of the
|
|
56
|
+
* tree (`./src` and `src/` are `src`, `.` the whole tree): a value that leaves the top level is refused,
|
|
57
|
+
* naming its place and never repeating it.
|
|
58
|
+
*/
|
|
59
|
+
function selectionsOf(paths, prefix) {
|
|
60
|
+
const selections = new Map();
|
|
61
|
+
for (const [index, value] of paths.entries()) {
|
|
62
|
+
const joined = posix.normalize(`${prefix}${value}`);
|
|
63
|
+
const name = joined.length > 1 && joined.endsWith('/')
|
|
64
|
+
? joined.slice(0, -1)
|
|
65
|
+
: joined;
|
|
66
|
+
if (name === '..' || name.startsWith('../'))
|
|
67
|
+
throw refusal(FLAG, leavesTop(index + 1));
|
|
68
|
+
if (!selections.has(name))
|
|
69
|
+
selections.set(name, { name, place: index + 1 });
|
|
70
|
+
}
|
|
71
|
+
return [
|
|
72
|
+
...selections.values(),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/** Whether `name`, a path of the tree, is the selection or lies under it. */
|
|
76
|
+
function isSelected(name, selection) {
|
|
77
|
+
return selection === '.' || name === selection || name.startsWith(`${selection}/`);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The skip a name or a gitlink decides before any blob is read, or the exclusion that comes first: a gitlink,
|
|
81
|
+
* then `exclude`, then a secret's name (the core's) unless `sent` names the file, whatever the skips, then,
|
|
82
|
+
* while the skips are on, the other name rules.
|
|
83
|
+
*/
|
|
84
|
+
function leftOutBeforeReading({ entry, name }, excluded, skips, sent) {
|
|
85
|
+
if (entry.type === 'commit')
|
|
86
|
+
return { file: name, reason: 'skipped', rule: 'submodule' };
|
|
87
|
+
if (excluded(name))
|
|
88
|
+
return { file: name, reason: 'excluded' };
|
|
89
|
+
if (!sent(name) && isSecretName(name))
|
|
90
|
+
return { file: name, reason: 'skipped', rule: 'secret' };
|
|
91
|
+
const rule = skips
|
|
92
|
+
? nameRule(name, false)
|
|
93
|
+
: undefined;
|
|
94
|
+
return rule === undefined
|
|
95
|
+
? undefined
|
|
96
|
+
: { file: name, reason: 'skipped', rule };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The skip the bytes of a file decide, in this order: a Git LFS pointer always; while the skips are on, a
|
|
100
|
+
* binary file; then, whatever the skips and unless `sent` names the file, one whose text holds a credential
|
|
101
|
+
* (the core's `credentialIn`, of the text as the writer reads it), skipped as `secret`; and while the skips
|
|
102
|
+
* are on, a minified one.
|
|
103
|
+
*/
|
|
104
|
+
function leftOutAfterReading(name, content, skips, sent) {
|
|
105
|
+
if (isLfsPointer(content))
|
|
106
|
+
return { file: name, reason: 'skipped', rule: 'lfs' };
|
|
107
|
+
if (skips && isBinary(content))
|
|
108
|
+
return { file: name, reason: 'skipped', rule: 'binary' };
|
|
109
|
+
if (!sent(name) && credentialIn(blobText(content)) !== undefined)
|
|
110
|
+
return { file: name, reason: 'skipped', rule: 'secret' };
|
|
111
|
+
return skips && isMinifiedContent(name, content)
|
|
112
|
+
? { file: name, reason: 'skipped', rule: 'minified' }
|
|
113
|
+
: undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The path source: the files under one or more paths at a commit, written as an all-added diff, read from
|
|
117
|
+
* the commit's tree by id and never from the working tree (uncommitted edits are `--local`'s). The tree is
|
|
118
|
+
* listed once and filtered in code, so no user path reaches git: a value is checked, normalized against
|
|
119
|
+
* where the working directory sits in the repository, and matched against each name as the diff reads it
|
|
120
|
+
* back (`pathName`), with no pathspec magic and no link to follow. Git is handed one thing the user wrote,
|
|
121
|
+
* the revision of `--at`, resolved once and then known as a full id.
|
|
122
|
+
*
|
|
123
|
+
* Each selected entry, in git's order, is decided in this order: a gitlink is skipped as `submodule`,
|
|
124
|
+
* always; a name `exclude` matches is listed `excluded`; a name the core takes as a secret's is skipped as
|
|
125
|
+
* `secret`, whatever the skips, unless the context's `send` names the file; and with the skips on a name is
|
|
126
|
+
* skipped by the first other rule it fits, `vendored`, `lockfile` or `minified` (`nameRule`). The sizes of
|
|
127
|
+
* what is left must then be within 16 MiB before any blob is read, and the blobs are read through one
|
|
128
|
+
* `cat-file`. Once read, a Git LFS pointer is skipped as `lfs`, always; with the skips on a binary file is
|
|
129
|
+
* skipped as `binary`; a file whose text holds a credential is skipped as `secret`, whatever the skips,
|
|
130
|
+
* unless `send` names it; and with the skips on one whose lines are long is skipped as `minified`. With the
|
|
131
|
+
* skips off a binary file is written as git's binary line, a gap of every profile. So only `send` sends a
|
|
132
|
+
* secret, by its name and by its content, and `--no-default-skips` turns off the vendored, lockfile,
|
|
133
|
+
* minified and binary rules alone. `send` holds exact paths, as the diff writes them and `leftOut` lists
|
|
134
|
+
* them. A template (`.env.example`, a Helm chart's `secrets.yaml`) is no secret by name, so it is read and
|
|
135
|
+
* written unless it holds a credential. Nothing is read from a `.gitattributes`: a tree can still shape a
|
|
136
|
+
* file to match a rule, which is why each skip is listed in `leftOut` with its rule, and no skip is a gap.
|
|
137
|
+
*
|
|
138
|
+
* A `ConfigError` at `--path` or `--at` refuses a `--path` value that is empty or absolute and an `--at`
|
|
139
|
+
* that starts with `-` (before any git), a `--path` that leaves the top level or names no tracked file, a
|
|
140
|
+
* commit that does not exist or an unborn HEAD, a selection whose every file is left out (an empty review
|
|
141
|
+
* never passes), and a selection or a diff over 16 MiB.
|
|
142
|
+
*
|
|
143
|
+
* @see ../../docs/20-using/15-sources.md#the-files-at-a-commit for what a path review reads and skips.
|
|
144
|
+
*/
|
|
145
|
+
export async function pathsSource(paths, at, skips, context) {
|
|
146
|
+
if (paths.length === 0)
|
|
147
|
+
throw refusal(FLAG, EMPTY_PATH);
|
|
148
|
+
for (const value of paths) {
|
|
149
|
+
const problem = pathProblem(value);
|
|
150
|
+
if (problem !== undefined)
|
|
151
|
+
throw refusal(FLAG, problem);
|
|
152
|
+
}
|
|
153
|
+
const atIssue = atProblem(at);
|
|
154
|
+
if (atIssue !== undefined)
|
|
155
|
+
throw refusal('--at', atIssue);
|
|
156
|
+
const repository = await openSourceRepository(context, FLAG);
|
|
157
|
+
const selections = selectionsOf(paths, repository.prefix);
|
|
158
|
+
const commit = await repository.resolveCommit(at ?? 'HEAD');
|
|
159
|
+
if (commit === undefined) {
|
|
160
|
+
throw at === undefined
|
|
161
|
+
? refusal(FLAG, NEEDS_COMMIT)
|
|
162
|
+
: refusal('--at', 'names no commit of this repository');
|
|
163
|
+
}
|
|
164
|
+
const matched = new Set();
|
|
165
|
+
const entries = await listTree(repository, commit, (path) => {
|
|
166
|
+
const name = pathName(path);
|
|
167
|
+
let chosen = false;
|
|
168
|
+
for (const { name: selection } of selections) {
|
|
169
|
+
if (!isSelected(name, selection))
|
|
170
|
+
continue;
|
|
171
|
+
matched.add(selection);
|
|
172
|
+
chosen = true;
|
|
173
|
+
}
|
|
174
|
+
return chosen;
|
|
175
|
+
});
|
|
176
|
+
if (entries === undefined)
|
|
177
|
+
throw refusal(FLAG, NAMES_OVER);
|
|
178
|
+
const unmatched = selections.find(({ name }) => !matched.has(name));
|
|
179
|
+
if (unmatched !== undefined)
|
|
180
|
+
throw refusal(FLAG, namesNothing(unmatched.place));
|
|
181
|
+
const excluded = excludeMatcher(context.exclude ?? []);
|
|
182
|
+
const sendNames = new Set(context.send ?? []);
|
|
183
|
+
const sent = (path) => sendNames.has(path);
|
|
184
|
+
const candidates = entries.map(entry => ({
|
|
185
|
+
entry,
|
|
186
|
+
name: pathName(entry.path),
|
|
187
|
+
}));
|
|
188
|
+
const decided = candidates.map(candidate => leftOutBeforeReading(candidate, excluded, skips, sent));
|
|
189
|
+
const toRead = candidates.filter((_, index) => decided[index] === undefined);
|
|
190
|
+
const total = toRead.reduce((sum, { entry }) => sum + (entry.size ?? 0), 0);
|
|
191
|
+
if (total > MAX_DIFF_BYTES)
|
|
192
|
+
throw refusal(FLAG, tooMany(total));
|
|
193
|
+
const contents = toRead.length === 0
|
|
194
|
+
? []
|
|
195
|
+
: await readBlobs(repository, toRead.map(({ entry }) => entry), MAX_DIFF_BYTES);
|
|
196
|
+
const files = [];
|
|
197
|
+
const leftOut = [];
|
|
198
|
+
let next = 0;
|
|
199
|
+
for (const [index, { entry, name }] of candidates.entries()) {
|
|
200
|
+
const early = decided[index];
|
|
201
|
+
if (early !== undefined) {
|
|
202
|
+
leftOut.push(early);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const content = contents[next++];
|
|
206
|
+
const late = leftOutAfterReading(name, content, skips, sent);
|
|
207
|
+
if (late === undefined)
|
|
208
|
+
files.push({ path: entry.path, mode: entry.mode, content });
|
|
209
|
+
else
|
|
210
|
+
leftOut.push(late);
|
|
211
|
+
}
|
|
212
|
+
if (files.length === 0) {
|
|
213
|
+
const skipped = leftOut.filter(({ reason }) => reason === 'skipped').length;
|
|
214
|
+
throw refusal(FLAG, allLeftOut(skipped, leftOut.length - skipped, skips));
|
|
215
|
+
}
|
|
216
|
+
const diff = addedDiff(files);
|
|
217
|
+
if (utf8Length(diff) > MAX_DIFF_BYTES)
|
|
218
|
+
throw refusal(FLAG, DIFF_OVER);
|
|
219
|
+
return {
|
|
220
|
+
diff,
|
|
221
|
+
source: {
|
|
222
|
+
kind: 'paths',
|
|
223
|
+
commit,
|
|
224
|
+
paths: selections.map(({ name }) => name),
|
|
225
|
+
skips,
|
|
226
|
+
objectFormat: repository.objectFormat,
|
|
227
|
+
},
|
|
228
|
+
leftOut,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SourceContext, SourceRead } from './read.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The two sides of a range written `<base>...<head>`, split at its first `...`, or the problem with the
|
|
4
|
+
* text, worded to follow `--range: `. Each side must be non-empty, hold no `..` and not start with `-`:
|
|
5
|
+
* a revision is never an option, so no side can be read as one. A problem never repeats the text.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseRange(range: string): {
|
|
8
|
+
readonly base: string;
|
|
9
|
+
readonly head: string;
|
|
10
|
+
} | string;
|
|
11
|
+
/**
|
|
12
|
+
* The range source: what `<head>` changed since it left `<base>`, written `--range <base>...<head>`. Both
|
|
13
|
+
* sides are resolved to full commit ids (a revision goes to git once, after `--end-of-options`, and is never
|
|
14
|
+
* printed back), then the diff is the merge base of the two against the head, with the base's attributes. It
|
|
15
|
+
* is git's own `<base>...<head>`, and `<base>..<head>` is refused: that form compares the two ends, so what
|
|
16
|
+
* `<base>` gained since the branch left it shows up as removed lines no one on the branch wrote. A
|
|
17
|
+
* `ConfigError` refuses a side that names no commit, two sides that are one commit (there is nothing to
|
|
18
|
+
* review) and sides with no shared history, as a shallow clone has, and a diff over 16 MiB; a merge base
|
|
19
|
+
* equal to the head is an empty diff. The diff is git's bytes read as `decodeDiff` reads them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rangeSource(range: string, context: SourceContext): Promise<SourceRead>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { decodeDiff } from "../core/diff.js";
|
|
2
|
+
import { ConfigError } from "../core/errors.js";
|
|
3
|
+
import { openSourceRepository } from "./repository.js";
|
|
4
|
+
const FLAG = '--range';
|
|
5
|
+
/**
|
|
6
|
+
* The two sides of a range written `<base>...<head>`, split at its first `...`, or the problem with the
|
|
7
|
+
* text, worded to follow `--range: `. Each side must be non-empty, hold no `..` and not start with `-`:
|
|
8
|
+
* a revision is never an option, so no side can be read as one. A problem never repeats the text.
|
|
9
|
+
*/
|
|
10
|
+
export function parseRange(range) {
|
|
11
|
+
if (range === '')
|
|
12
|
+
return 'must name a range, written <base>...<head>';
|
|
13
|
+
const at = range.indexOf('...');
|
|
14
|
+
if (at === -1) {
|
|
15
|
+
return range.includes('..')
|
|
16
|
+
? 'must be written <base>...<head>, with three dots: <base>..<head> compares the two ends, and shows what <base> gained since as removed'
|
|
17
|
+
: 'must be written <base>...<head>: a single revision names no range';
|
|
18
|
+
}
|
|
19
|
+
const base = range.slice(0, at);
|
|
20
|
+
const head = range.slice(at + 3);
|
|
21
|
+
if (base === '' || head === '')
|
|
22
|
+
return 'must name a revision on each side of ...';
|
|
23
|
+
if (base.includes('..') || head.includes('..'))
|
|
24
|
+
return 'must hold one ... between two revisions';
|
|
25
|
+
if (base.startsWith('-') || head.startsWith('-'))
|
|
26
|
+
return 'a revision may not start with -';
|
|
27
|
+
return { base, head };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The range source: what `<head>` changed since it left `<base>`, written `--range <base>...<head>`. Both
|
|
31
|
+
* sides are resolved to full commit ids (a revision goes to git once, after `--end-of-options`, and is never
|
|
32
|
+
* printed back), then the diff is the merge base of the two against the head, with the base's attributes. It
|
|
33
|
+
* is git's own `<base>...<head>`, and `<base>..<head>` is refused: that form compares the two ends, so what
|
|
34
|
+
* `<base>` gained since the branch left it shows up as removed lines no one on the branch wrote. A
|
|
35
|
+
* `ConfigError` refuses a side that names no commit, two sides that are one commit (there is nothing to
|
|
36
|
+
* review) and sides with no shared history, as a shallow clone has, and a diff over 16 MiB; a merge base
|
|
37
|
+
* equal to the head is an empty diff. The diff is git's bytes read as `decodeDiff` reads them.
|
|
38
|
+
*/
|
|
39
|
+
export async function rangeSource(range, context) {
|
|
40
|
+
const refusal = (message) => new ConfigError([
|
|
41
|
+
{ path: FLAG, message },
|
|
42
|
+
]);
|
|
43
|
+
const parsed = parseRange(range);
|
|
44
|
+
if (typeof parsed === 'string')
|
|
45
|
+
throw refusal(parsed);
|
|
46
|
+
const repository = await openSourceRepository(context, FLAG);
|
|
47
|
+
const base = await repository.resolveCommit(parsed.base);
|
|
48
|
+
if (base === undefined)
|
|
49
|
+
throw refusal('its base names no commit of this repository: fetch it first, as actions/checkout does with fetch-depth: 0');
|
|
50
|
+
const head = await repository.resolveCommit(parsed.head);
|
|
51
|
+
if (head === undefined)
|
|
52
|
+
throw refusal('its head names no commit of this repository');
|
|
53
|
+
if (base === head)
|
|
54
|
+
throw refusal('its two sides are one commit, so it names nothing to review');
|
|
55
|
+
const mergeBase = await repository.mergeBase(base, head);
|
|
56
|
+
if (mergeBase === undefined)
|
|
57
|
+
throw refusal('its two sides share no history in this clone: fetch the base\'s history, as actions/checkout does with fetch-depth: 0');
|
|
58
|
+
const bytes = await repository.diffCommits(mergeBase, head, base);
|
|
59
|
+
const diff = bytes === undefined
|
|
60
|
+
? undefined
|
|
61
|
+
: await decodeDiff([bytes]);
|
|
62
|
+
if (diff === undefined)
|
|
63
|
+
throw refusal('its diff is over 16 MiB, the most quorum reads: review a shorter range');
|
|
64
|
+
return {
|
|
65
|
+
diff,
|
|
66
|
+
source: {
|
|
67
|
+
kind: 'range',
|
|
68
|
+
base,
|
|
69
|
+
mergeBase,
|
|
70
|
+
head,
|
|
71
|
+
objectFormat: repository.objectFormat,
|
|
72
|
+
},
|
|
73
|
+
leftOut: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Env } from '../config/env.ts';
|
|
2
|
+
import type { Clock } from '../core/clock.ts';
|
|
3
|
+
import type { LeftOutFile, ReviewSource } from '../core/types.ts';
|
|
4
|
+
import type { SpawnGit } from '../git/run.ts';
|
|
5
|
+
/**
|
|
6
|
+
* What a review reads its diff from: `diff`, the text of a diff file or of standard input; `range`, the
|
|
7
|
+
* commits `<base>...<head>` as the user wrote them; `local`, what `git add -A` would commit (staged, unstaged
|
|
8
|
+
* and untracked); `staged`, what the next commit holds; or `paths`, the files under `paths` at the commit
|
|
9
|
+
* `at` names, HEAD when unset, as they are written in the user's working directory. `trustRepoConfig` says the
|
|
10
|
+
* repository is the user's, so a filter its own config names may run. `skips` says whether a path review
|
|
11
|
+
* skips what it skips by default, vendored, lockfile, minified and binary files, and is true when unset: a
|
|
12
|
+
* path review skips a secret, by its name or by what it holds, whatever `skips` says, and only the
|
|
13
|
+
* context's `send` sends one.
|
|
14
|
+
*/
|
|
15
|
+
export type SourceSpec = {
|
|
16
|
+
readonly kind: 'diff';
|
|
17
|
+
readonly text: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'range';
|
|
20
|
+
readonly range: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'local' | 'staged';
|
|
23
|
+
readonly trustRepoConfig?: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'paths';
|
|
26
|
+
readonly paths: readonly string[];
|
|
27
|
+
readonly at?: string;
|
|
28
|
+
readonly skips?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** The executable and the spawn of git, which a spec replaces: an absolute path, `spawn` and the clock a deadline runs on. */
|
|
31
|
+
export interface GitSeam {
|
|
32
|
+
readonly executable: string;
|
|
33
|
+
readonly spawn: SpawnGit;
|
|
34
|
+
readonly clock?: Clock;
|
|
35
|
+
}
|
|
36
|
+
/** What a source reads from the machine: the working directory, the environment, the platform (the layer reads no `process`), and the abort signal, `exclude` patterns and git seam of the run. */
|
|
37
|
+
export interface SourceContext {
|
|
38
|
+
readonly cwd: string;
|
|
39
|
+
readonly env: Env;
|
|
40
|
+
readonly platform: NodeJS.Platform;
|
|
41
|
+
readonly signal?: AbortSignal;
|
|
42
|
+
/** The config's `exclude` patterns, which a source that reads files applies before it reads them. */
|
|
43
|
+
readonly exclude?: readonly string[];
|
|
44
|
+
/** The files the operator sends to the models though held as secrets, each a path as the diff writes it: a path review does not skip them as secrets. */
|
|
45
|
+
readonly send?: readonly string[];
|
|
46
|
+
/** The git to run, for a spec; git is looked up on the environment's `PATH` when unset. */
|
|
47
|
+
readonly git?: GitSeam;
|
|
48
|
+
}
|
|
49
|
+
/** What a source made: the diff a review reads, where it came from, and the files the source left out before it made the diff. */
|
|
50
|
+
export interface SourceRead {
|
|
51
|
+
readonly diff: string;
|
|
52
|
+
readonly source: ReviewSource;
|
|
53
|
+
readonly leftOut: LeftOutFile[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads the diff a review is about, from the source `spec` names: a diff file's or standard input's text
|
|
57
|
+
* (`diff`), the commits of a range (`range`), the local changes (`local`, `staged`) or the files at a commit
|
|
58
|
+
* (`paths`). Every source answers with the diff, where it came from (`meta.source`) and the files it left
|
|
59
|
+
* out. No source cuts a diff, drops a file without listing it or reads outside the repository's top level:
|
|
60
|
+
* a source that cannot read what it was asked to refuses with a `ConfigError` that names its flag, or fails
|
|
61
|
+
* with a `GitError`. A `kind` it does not know is a `ConfigError` too, so a caller whose spec is untyped
|
|
62
|
+
* never gets `undefined`.
|
|
63
|
+
*
|
|
64
|
+
* @throws ConfigError for a source it refuses, as each source says, and for a `kind` that is none of the five
|
|
65
|
+
* @throws GitError when a git command a source runs fails
|
|
66
|
+
*
|
|
67
|
+
* @see ../../docs/20-using/15-sources.md for the sources and how quorum runs git.
|
|
68
|
+
*/
|
|
69
|
+
export declare function readSource(spec: SourceSpec, context: SourceContext): Promise<SourceRead>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ConfigError } from "../core/errors.js";
|
|
2
|
+
import { diffSource } from "./diff.js";
|
|
3
|
+
import { localSource } from "./local.js";
|
|
4
|
+
import { pathsSource } from "./paths.js";
|
|
5
|
+
import { rangeSource } from "./range.js";
|
|
6
|
+
/**
|
|
7
|
+
* Reads the diff a review is about, from the source `spec` names: a diff file's or standard input's text
|
|
8
|
+
* (`diff`), the commits of a range (`range`), the local changes (`local`, `staged`) or the files at a commit
|
|
9
|
+
* (`paths`). Every source answers with the diff, where it came from (`meta.source`) and the files it left
|
|
10
|
+
* out. No source cuts a diff, drops a file without listing it or reads outside the repository's top level:
|
|
11
|
+
* a source that cannot read what it was asked to refuses with a `ConfigError` that names its flag, or fails
|
|
12
|
+
* with a `GitError`. A `kind` it does not know is a `ConfigError` too, so a caller whose spec is untyped
|
|
13
|
+
* never gets `undefined`.
|
|
14
|
+
*
|
|
15
|
+
* @throws ConfigError for a source it refuses, as each source says, and for a `kind` that is none of the five
|
|
16
|
+
* @throws GitError when a git command a source runs fails
|
|
17
|
+
*
|
|
18
|
+
* @see ../../docs/20-using/15-sources.md for the sources and how quorum runs git.
|
|
19
|
+
*/
|
|
20
|
+
export async function readSource(spec, context) {
|
|
21
|
+
switch (spec.kind) {
|
|
22
|
+
case 'diff':
|
|
23
|
+
return diffSource(spec.text);
|
|
24
|
+
case 'range':
|
|
25
|
+
return rangeSource(spec.range, context);
|
|
26
|
+
case 'local':
|
|
27
|
+
case 'staged':
|
|
28
|
+
return localSource(spec.kind, spec.trustRepoConfig === true, context);
|
|
29
|
+
case 'paths':
|
|
30
|
+
return pathsSource(spec.paths, spec.at, spec.skips ?? true, context);
|
|
31
|
+
default:
|
|
32
|
+
// A library caller's spec is untyped: a kind it does not know fails closed, never as `undefined`.
|
|
33
|
+
throw new ConfigError([
|
|
34
|
+
{ path: 'kind', message: 'must be diff, range, local, staged or paths' },
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Repository } from '../git/run.ts';
|
|
2
|
+
import type { SourceContext } from './read.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Opens the repository the working directory is in, for the source `flag` names. Every git source starts
|
|
5
|
+
* here: on Windows it refuses before anything is spawned, it finds git on the environment's absolute
|
|
6
|
+
* `PATH` entries unless `context.git` names the executable, and `openRepository` checks the version and
|
|
7
|
+
* the work tree. Each refusal is a `ConfigError` at `flag`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function openSourceRepository(context: SourceContext, flag: string): Promise<Repository>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { findExecutable } from "../config/command.js";
|
|
2
|
+
import { ConfigError } from "../core/errors.js";
|
|
3
|
+
import { openRepository } from "../git/run.js";
|
|
4
|
+
/**
|
|
5
|
+
* Opens the repository the working directory is in, for the source `flag` names. Every git source starts
|
|
6
|
+
* here: on Windows it refuses before anything is spawned, it finds git on the environment's absolute
|
|
7
|
+
* `PATH` entries unless `context.git` names the executable, and `openRepository` checks the version and
|
|
8
|
+
* the work tree. Each refusal is a `ConfigError` at `flag`.
|
|
9
|
+
*/
|
|
10
|
+
export async function openSourceRepository(context, flag) {
|
|
11
|
+
const refusal = (message) => new ConfigError([
|
|
12
|
+
{ path: flag, message },
|
|
13
|
+
]);
|
|
14
|
+
if (context.platform === 'win32')
|
|
15
|
+
throw refusal('the git sources run on Linux and macOS: on Windows, pipe a diff in');
|
|
16
|
+
const git = context.git?.executable ?? findExecutable('git', context.env, context.platform);
|
|
17
|
+
if (git === undefined)
|
|
18
|
+
throw refusal('needs git 2.41 or later on PATH, and none was found: install it, or pipe a diff in');
|
|
19
|
+
return openRepository({
|
|
20
|
+
git,
|
|
21
|
+
cwd: context.cwd,
|
|
22
|
+
env: context.env,
|
|
23
|
+
flag,
|
|
24
|
+
signal: context.signal,
|
|
25
|
+
spawn: context.git?.spawn,
|
|
26
|
+
clock: context.git?.clock,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SkipRule } from '../core/types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What a path review skips by default, as constants a source reads and no tree can change. The lists come
|
|
4
|
+
* from linguist's `vendor.yml` and `generated.rb` and the ecosystems the bench covers (Python, JavaScript and
|
|
5
|
+
* TypeScript, Go, Rust, PHP, Java and Kotlin, Ruby, C#). The names of secrets are the core's (`isSecretName`),
|
|
6
|
+
* the one rule every source and the hold on every diff share, and a path review skips one whatever its default
|
|
7
|
+
* skips say. Nothing here reads a `.gitattributes`: a pull request writes it, and a tree can still shape a file
|
|
8
|
+
* to match a rule, which is why each skip is listed and the flag reviews them all.
|
|
9
|
+
*
|
|
10
|
+
* @see ../../docs/20-using/15-sources.md#what-a-path-review-skips for what each rule takes and why.
|
|
11
|
+
*/
|
|
12
|
+
/** The average line length, in bytes, above which a `.js`, `.mjs`, `.cjs` or `.css` file is minified: linguist's. */
|
|
13
|
+
export declare const MINIFIED_LINE_AVERAGE = 110;
|
|
14
|
+
/** A Git LFS pointer is shorter than this, in bytes. */
|
|
15
|
+
export declare const LFS_POINTER_BYTES = 1024;
|
|
16
|
+
/** The directories whose files are another project's, matched on a directory segment of the path and never on the file's own name. */
|
|
17
|
+
export declare const VENDORED_DIRECTORIES: readonly string[];
|
|
18
|
+
/** The names of lockfiles, matched on the file's own name. */
|
|
19
|
+
export declare const LOCKFILES: readonly string[];
|
|
20
|
+
/** What a minified file's name ends with, in any case. */
|
|
21
|
+
export declare const MINIFIED_SUFFIXES: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The rule that skips a file by its path alone, or undefined when none does. The rules are taken in this
|
|
24
|
+
* order, so a file that fits several is listed under the first: `secret` (the core's `isSecretName`: a
|
|
25
|
+
* secret's name, a template apart), `vendored` (a directory of the path, the file's own name aside, is one
|
|
26
|
+
* of the vendored ones: `vendor.go` is reviewed, and so is a file named `vendor`), `lockfile` (the name is
|
|
27
|
+
* a lockfile's) and `minified` (the name ends in a minified suffix, in any case). A secret is taken before
|
|
28
|
+
* anything, so a `vendor/.env` is still flagged. `secret` false passes the first rule over, for a file the
|
|
29
|
+
* operator sends: it goes to the next rule, so a sent `vendor/.env` is still vendored.
|
|
30
|
+
*/
|
|
31
|
+
export declare function nameRule(path: string, secret?: boolean): SkipRule | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Whether linguist's rule calls a file minified by its lines, applied to `.js`, `.mjs`, `.cjs` and `.css`
|
|
34
|
+
* files only, in any case of the extension: the bytes of its lines, line feeds left out, average over
|
|
35
|
+
* `MINIFIED_LINE_AVERAGE` by integer division. The lines are the pieces of a split at the line feeds that
|
|
36
|
+
* keeps the empty piece after a last one, as linguist's `split("\n", -1)` does, so one long line that ends
|
|
37
|
+
* with a line feed counts as two. Applied to every kind of file the rule would let an author skip a file
|
|
38
|
+
* by its line length; on these four kinds it costs the narrowest reach. An empty file is no minified one.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isMinifiedContent(path: string, content: Uint8Array): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a file is a Git LFS pointer, as strictly as the spec writes one: under `LFS_POINTER_BYTES` bytes,
|
|
43
|
+
* and exactly the version line `version https://git-lfs.github.com/spec/v1`, any `ext-<digit>-<name>
|
|
44
|
+
* sha256:<64 hex>` lines, `oid sha256:<64 hex>` and `size <digits>`, each ended by a line feed, with
|
|
45
|
+
* nothing else. A byte outside printable ASCII and the line feed, a carriage return among them, is no
|
|
46
|
+
* pointer. A pointer holds no code, so skipping one hides none, which is why a path review skips it even
|
|
47
|
+
* with the default skips off; and any file that is not exactly one is reviewed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isLfsPointer(content: Uint8Array): boolean;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { isSecretName } from "../core/secrets.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a path review skips by default, as constants a source reads and no tree can change. The lists come
|
|
4
|
+
* from linguist's `vendor.yml` and `generated.rb` and the ecosystems the bench covers (Python, JavaScript and
|
|
5
|
+
* TypeScript, Go, Rust, PHP, Java and Kotlin, Ruby, C#). The names of secrets are the core's (`isSecretName`),
|
|
6
|
+
* the one rule every source and the hold on every diff share, and a path review skips one whatever its default
|
|
7
|
+
* skips say. Nothing here reads a `.gitattributes`: a pull request writes it, and a tree can still shape a file
|
|
8
|
+
* to match a rule, which is why each skip is listed and the flag reviews them all.
|
|
9
|
+
*
|
|
10
|
+
* @see ../../docs/20-using/15-sources.md#what-a-path-review-skips for what each rule takes and why.
|
|
11
|
+
*/
|
|
12
|
+
/** The average line length, in bytes, above which a `.js`, `.mjs`, `.cjs` or `.css` file is minified: linguist's. */
|
|
13
|
+
export const MINIFIED_LINE_AVERAGE = 110;
|
|
14
|
+
/** A Git LFS pointer is shorter than this, in bytes. */
|
|
15
|
+
export const LFS_POINTER_BYTES = 1024;
|
|
16
|
+
/** The directories whose files are another project's, matched on a directory segment of the path and never on the file's own name. */
|
|
17
|
+
export const VENDORED_DIRECTORIES = Object.freeze([
|
|
18
|
+
'node_modules',
|
|
19
|
+
'bower_components',
|
|
20
|
+
'jspm_packages',
|
|
21
|
+
'vendor',
|
|
22
|
+
'Vendor',
|
|
23
|
+
'vendors',
|
|
24
|
+
'third_party',
|
|
25
|
+
'third-party',
|
|
26
|
+
'thirdparty',
|
|
27
|
+
'Pods',
|
|
28
|
+
'Carthage',
|
|
29
|
+
]);
|
|
30
|
+
/** The names of lockfiles, matched on the file's own name. */
|
|
31
|
+
export const LOCKFILES = Object.freeze([
|
|
32
|
+
'package-lock.json',
|
|
33
|
+
'npm-shrinkwrap.json',
|
|
34
|
+
'yarn.lock',
|
|
35
|
+
'pnpm-lock.yaml',
|
|
36
|
+
'bun.lock',
|
|
37
|
+
'bun.lockb',
|
|
38
|
+
'deno.lock',
|
|
39
|
+
'poetry.lock',
|
|
40
|
+
'Pipfile.lock',
|
|
41
|
+
'pdm.lock',
|
|
42
|
+
'uv.lock',
|
|
43
|
+
'go.sum',
|
|
44
|
+
'go.work.sum',
|
|
45
|
+
'Cargo.lock',
|
|
46
|
+
'composer.lock',
|
|
47
|
+
'gradle.lockfile',
|
|
48
|
+
'Gemfile.lock',
|
|
49
|
+
'packages.lock.json',
|
|
50
|
+
'paket.lock',
|
|
51
|
+
]);
|
|
52
|
+
/** What a minified file's name ends with, in any case. */
|
|
53
|
+
export const MINIFIED_SUFFIXES = Object.freeze([
|
|
54
|
+
'.min.js',
|
|
55
|
+
'.min.mjs',
|
|
56
|
+
'.min.cjs',
|
|
57
|
+
'.min.css',
|
|
58
|
+
'.js.map',
|
|
59
|
+
'.mjs.map',
|
|
60
|
+
'.cjs.map',
|
|
61
|
+
'.css.map',
|
|
62
|
+
]);
|
|
63
|
+
const VENDORED = new Set(VENDORED_DIRECTORIES);
|
|
64
|
+
const LOCKFILE_NAMES = new Set(LOCKFILES);
|
|
65
|
+
const MINIFIED_CONTENT_SUFFIXES = ['.js', '.mjs', '.cjs', '.css'];
|
|
66
|
+
/** The last segment of a path. */
|
|
67
|
+
function nameOf(path) {
|
|
68
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
69
|
+
}
|
|
70
|
+
function endsWithAny(name, suffixes) {
|
|
71
|
+
const lower = name.toLowerCase();
|
|
72
|
+
return suffixes.some(suffix => lower.endsWith(suffix));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The rule that skips a file by its path alone, or undefined when none does. The rules are taken in this
|
|
76
|
+
* order, so a file that fits several is listed under the first: `secret` (the core's `isSecretName`: a
|
|
77
|
+
* secret's name, a template apart), `vendored` (a directory of the path, the file's own name aside, is one
|
|
78
|
+
* of the vendored ones: `vendor.go` is reviewed, and so is a file named `vendor`), `lockfile` (the name is
|
|
79
|
+
* a lockfile's) and `minified` (the name ends in a minified suffix, in any case). A secret is taken before
|
|
80
|
+
* anything, so a `vendor/.env` is still flagged. `secret` false passes the first rule over, for a file the
|
|
81
|
+
* operator sends: it goes to the next rule, so a sent `vendor/.env` is still vendored.
|
|
82
|
+
*/
|
|
83
|
+
export function nameRule(path, secret = true) {
|
|
84
|
+
const name = nameOf(path);
|
|
85
|
+
if (secret && isSecretName(path))
|
|
86
|
+
return 'secret';
|
|
87
|
+
if (path.split('/').slice(0, -1).some(directory => VENDORED.has(directory)))
|
|
88
|
+
return 'vendored';
|
|
89
|
+
if (LOCKFILE_NAMES.has(name))
|
|
90
|
+
return 'lockfile';
|
|
91
|
+
if (endsWithAny(name, MINIFIED_SUFFIXES))
|
|
92
|
+
return 'minified';
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const LINE_FEED = 0x0A;
|
|
96
|
+
/**
|
|
97
|
+
* Whether linguist's rule calls a file minified by its lines, applied to `.js`, `.mjs`, `.cjs` and `.css`
|
|
98
|
+
* files only, in any case of the extension: the bytes of its lines, line feeds left out, average over
|
|
99
|
+
* `MINIFIED_LINE_AVERAGE` by integer division. The lines are the pieces of a split at the line feeds that
|
|
100
|
+
* keeps the empty piece after a last one, as linguist's `split("\n", -1)` does, so one long line that ends
|
|
101
|
+
* with a line feed counts as two. Applied to every kind of file the rule would let an author skip a file
|
|
102
|
+
* by its line length; on these four kinds it costs the narrowest reach. An empty file is no minified one.
|
|
103
|
+
*/
|
|
104
|
+
export function isMinifiedContent(path, content) {
|
|
105
|
+
if (!endsWithAny(path, MINIFIED_CONTENT_SUFFIXES))
|
|
106
|
+
return false;
|
|
107
|
+
let lineFeeds = 0;
|
|
108
|
+
for (let at = content.indexOf(LINE_FEED); at !== -1; at = content.indexOf(LINE_FEED, at + 1))
|
|
109
|
+
lineFeeds++;
|
|
110
|
+
const lines = lineFeeds + 1;
|
|
111
|
+
return Math.floor((content.length - lineFeeds) / lines) > MINIFIED_LINE_AVERAGE;
|
|
112
|
+
}
|
|
113
|
+
/** A pointer, whole: its version line, any extensions (`ext-<digit>-<name>`), then `oid` and `size`, and nothing else, each line ended by a line feed. */
|
|
114
|
+
const LFS_POINTER = /^version https:\/\/git-lfs\.github\.com\/spec\/v1\n(?:ext-\d-[\w-]+ sha256:[0-9a-f]{64}\n)*oid sha256:[0-9a-f]{64}\nsize \d+\n$/;
|
|
115
|
+
const POINTER_DECODER = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
116
|
+
/**
|
|
117
|
+
* Whether a file is a Git LFS pointer, as strictly as the spec writes one: under `LFS_POINTER_BYTES` bytes,
|
|
118
|
+
* and exactly the version line `version https://git-lfs.github.com/spec/v1`, any `ext-<digit>-<name>
|
|
119
|
+
* sha256:<64 hex>` lines, `oid sha256:<64 hex>` and `size <digits>`, each ended by a line feed, with
|
|
120
|
+
* nothing else. A byte outside printable ASCII and the line feed, a carriage return among them, is no
|
|
121
|
+
* pointer. A pointer holds no code, so skipping one hides none, which is why a path review skips it even
|
|
122
|
+
* with the default skips off; and any file that is not exactly one is reviewed.
|
|
123
|
+
*/
|
|
124
|
+
export function isLfsPointer(content) {
|
|
125
|
+
return content.length < LFS_POINTER_BYTES && LFS_POINTER.test(POINTER_DECODER.decode(content));
|
|
126
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tobi-or-not/quorum",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"packageManager": "bun@1.4.4",
|
|
6
6
|
"description": "Multi-agent code review for diffs: a model proposes candidate findings, then a panel of blind voters judges each before it's reported.",
|
|
7
7
|
"license": "Apache-2.0",
|